我正在尝试预览配置,然后使用Google Cloud Deployment Manager的Java客户端库创建配置,如下所示。


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();


对于插入,我找不到设置预览标志的方法。
API documentation上显示有一个可选的查询参数。我想知道如何从上面显示的我的Java客户端设置它。

最佳答案

DeploymentManager.deployments.instert class java doc可能会帮助您采取可能的措施。

我的猜测是您需要在execute()之前调用此函数:


  insReq.setPreview(true);

关于java - 如何在Java中为Google Cloud Deployment Manager deployments.insert()API设置预览标志,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55290993/

10-11 04:09
查看更多