Search in sources :

Example 1 with GetInstanceTemplateRequest

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());
    }
}
Also used : GetInstanceTemplateRequest(com.google.cloud.compute.v1.GetInstanceTemplateRequest) InstanceTemplatesClient(com.google.cloud.compute.v1.InstanceTemplatesClient) InstanceTemplate(com.google.cloud.compute.v1.InstanceTemplate)

Aggregations

GetInstanceTemplateRequest (com.google.cloud.compute.v1.GetInstanceTemplateRequest)1 InstanceTemplate (com.google.cloud.compute.v1.InstanceTemplate)1 InstanceTemplatesClient (com.google.cloud.compute.v1.InstanceTemplatesClient)1