use of com.google.cloud.compute.v1.DiskTypesClient.ListPagedResponse in project java-compute by googleapis.
the class SnapshotsClientTest method listTest.
@Test
public void listTest() throws Exception {
Snapshot responsesElement = Snapshot.newBuilder().build();
SnapshotList expectedResponse = SnapshotList.newBuilder().setNextPageToken("").addAllItems(Arrays.asList(responsesElement)).build();
mockService.addResponse(expectedResponse);
String project = "project-6911";
ListPagedResponse pagedListResponse = client.list(project);
List<Snapshot> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getItemsList().get(0), resources.get(0));
List<String> actualRequests = mockService.getRequestPaths();
Assert.assertEquals(1, actualRequests.size());
String apiClientHeaderKey = mockService.getRequestHeaders().get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next();
Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern().matcher(apiClientHeaderKey).matches());
}
use of com.google.cloud.compute.v1.DiskTypesClient.ListPagedResponse in project java-compute by googleapis.
the class AcceleratorTypesClientTest method listTest.
@Test
public void listTest() throws Exception {
AcceleratorType responsesElement = AcceleratorType.newBuilder().build();
AcceleratorTypeList expectedResponse = AcceleratorTypeList.newBuilder().setNextPageToken("").addAllItems(Arrays.asList(responsesElement)).build();
mockService.addResponse(expectedResponse);
String project = "project-6911";
String zone = "zone-5246";
ListPagedResponse pagedListResponse = client.list(project, zone);
List<AcceleratorType> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getItemsList().get(0), resources.get(0));
List<String> actualRequests = mockService.getRequestPaths();
Assert.assertEquals(1, actualRequests.size());
String apiClientHeaderKey = mockService.getRequestHeaders().get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next();
Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern().matcher(apiClientHeaderKey).matches());
}
use of com.google.cloud.compute.v1.DiskTypesClient.ListPagedResponse in project java-docs-samples by GoogleCloudPlatform.
the class PreemptibleIT method testListZoneOperations.
@Test
public void testListZoneOperations() throws IOException {
String filter = String.format("targetLink=\"https://www.googleapis.com/compute/v1/projects/%s/zones/%s/instances/%s\"", PROJECT_ID, ZONE, INSTANCE_NAME);
ListPagedResponse response = ListZoneOperations.listZoneOperations(PROJECT_ID, ZONE, filter);
boolean elementPresent = false;
for (Operation operation : response.iterateAll()) {
elementPresent = true;
break;
}
assertWithMessage("There should be at least one operation for this instance at this point.").that(elementPresent).isTrue();
}
use of com.google.cloud.compute.v1.DiskTypesClient.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;
}
}
use of com.google.cloud.compute.v1.DiskTypesClient.ListPagedResponse in project java-compute by googleapis.
the class ImagesClientTest method listTest.
@Test
public void listTest() throws Exception {
Image responsesElement = Image.newBuilder().build();
ImageList expectedResponse = ImageList.newBuilder().setNextPageToken("").addAllItems(Arrays.asList(responsesElement)).build();
mockService.addResponse(expectedResponse);
String project = "project-6911";
ListPagedResponse pagedListResponse = client.list(project);
List<Image> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getItemsList().get(0), resources.get(0));
List<String> actualRequests = mockService.getRequestPaths();
Assert.assertEquals(1, actualRequests.size());
String apiClientHeaderKey = mockService.getRequestHeaders().get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next();
Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern().matcher(apiClientHeaderKey).matches());
}
Aggregations