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