use of com.google.cloud.compute.v1.InstanceTemplatesClient.ListPagedResponse in project java-docs-samples by GoogleCloudPlatform.
the class ListInstanceTemplates method listInstanceTemplates.
// Get a list of InstanceTemplate objects available in a project.
public static ListPagedResponse listInstanceTemplates(String projectId) throws IOException {
try (InstanceTemplatesClient instanceTemplatesClient = InstanceTemplatesClient.create()) {
int count = 0;
System.out.println("Listing instance templates...");
ListPagedResponse templates = instanceTemplatesClient.list(projectId);
for (InstanceTemplate instanceTemplate : templates.iterateAll()) {
System.out.printf("%s. %s%n", ++count, instanceTemplate.getName());
}
return templates;
}
}
Aggregations