0

我正在尝试在使用 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 文档显示有一个可选的查询参数。我想知道如何从上面显示的 Java 客户端设置它。

4

1 回答 1

1

DeploymentManager.deployments.instert 类 java 文档可以帮助您完成可能的操作。

我有根据的猜测是您需要在执行()之前调用它:

insReq.setPreview(true);

于 2019-03-22T08:09:01.353 回答