I'm trying to preview a configuration before creating it using the Java client libraries for Google Cloud Deployment Manager like shown below.
DeploymentManager deploymentManagerService = createDeploymentManagerService();
Deployment requestBody = new Deployment();
requestBody.setName(deployment);
TargetConfiguration config = new TargetConfiguration();
ConfigFile configFile = new ConfigFile();
File file = new File("C:\\gcp-work\\two-vms.yaml");
byte[] encoded = Files.readAllBytes(Paths.get(file.getPath()));
String content = new String(encoded);
configFile.setContent(content);
config.setConfig(configFile);
requestBody.setTarget(config);
Deployments.Insert insReq = deploymentManagerService.deployments().insert(PROJECT_NAME, requestBody);
Operation oprtn = insReq.execute();
For the insert I'm not finding a way to set the preview flag. The API documentation on shows that there is an optional query parameter. I'm wondering how to set it from a Java client like mine shown above.
The DeploymentManager.deployments.instert class java doc may help you with the possible actions.
My educated guess is you need to call this before execute():
insReq.setPreview(true);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.