Search in sources :

Example 1 with DeleteInstanceTemplateRequest

use of com.google.cloud.compute.v1.DeleteInstanceTemplateRequest in project java-docs-samples by GoogleCloudPlatform.

the class DeleteInstanceTemplate method deleteInstanceTemplate.

// Delete an instance template.
public static void deleteInstanceTemplate(String projectId, String templateName) throws IOException, ExecutionException, InterruptedException {
    try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
        DeleteInstanceTemplateRequest deleteInstanceTemplateRequest = DeleteInstanceTemplateRequest.newBuilder().setProject(projectId).setInstanceTemplate(templateName).build();
        Operation response = instanceTemplatesClient.deleteAsync(deleteInstanceTemplateRequest).get();
        if (response.hasError()) {
            System.out.println("Instance template deletion failed ! ! " + response);
            return;
        }
        System.out.printf("Instance template deletion operation status for %s: %s ", templateName, response.getStatus());
    }
}
Also used : DeleteInstanceTemplateRequest(com.google.cloud.compute.v1.DeleteInstanceTemplateRequest) Operation(com.google.cloud.compute.v1.Operation) InstanceTemplatesClient(com.google.cloud.compute.v1.InstanceTemplatesClient)

Aggregations

DeleteInstanceTemplateRequest (com.google.cloud.compute.v1.DeleteInstanceTemplateRequest)1 InstanceTemplatesClient (com.google.cloud.compute.v1.InstanceTemplatesClient)1 Operation (com.google.cloud.compute.v1.Operation)1