use of com.google.cloud.compute.v1.GetInstanceTemplateRequest in project java-docs-samples by GoogleCloudPlatform.
the class GetInstanceTemplate method getInstanceTemplate.
// Retrieve an instance template, which you can use to create virtual machine
// (VM) instances and managed instance groups (MIGs).
public static void getInstanceTemplate(String projectId, String templateName) throws IOException {
try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
GetInstanceTemplateRequest getInstanceTemplateRequest = GetInstanceTemplateRequest.newBuilder().setProject(projectId).setInstanceTemplate(templateName).build();
InstanceTemplate instanceTemplate = instanceTemplatesClient.get(getInstanceTemplateRequest);
System.out.println("Instance Template retrieved: " + instanceTemplate.getName());
}
}
Aggregations