Search in sources :

Example 6 with ListInstancesRequest

use of com.google.spanner.admin.instance.v1.ListInstancesRequest in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method listInstancesTest2.

@Test
public void listInstancesTest2() throws Exception {
    ListInstancesResponse expectedResponse = ListInstancesResponse.newBuilder().addAllInstances(new ArrayList<Instance>()).addAllFailedLocations(new ArrayList<String>()).setNextPageToken("nextPageToken-1386094857").build();
    mockBigtableInstanceAdmin.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListInstancesResponse actualResponse = client.listInstances(parent);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListInstancesRequest actualRequest = ((ListInstancesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListInstancesResponse(com.google.bigtable.admin.v2.ListInstancesResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListInstancesRequest(com.google.bigtable.admin.v2.ListInstancesRequest) ArrayList(java.util.ArrayList) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 7 with ListInstancesRequest

use of com.google.spanner.admin.instance.v1.ListInstancesRequest in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method listInstancesTest.

@Test
public void listInstancesTest() throws Exception {
    ListInstancesResponse expectedResponse = ListInstancesResponse.newBuilder().addAllInstances(new ArrayList<Instance>()).addAllFailedLocations(new ArrayList<String>()).setNextPageToken("nextPageToken-1386094857").build();
    mockBigtableInstanceAdmin.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListInstancesResponse actualResponse = client.listInstances(parent);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListInstancesRequest actualRequest = ((ListInstancesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListInstancesResponse(com.google.bigtable.admin.v2.ListInstancesResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ProjectName(com.google.bigtable.admin.v2.ProjectName) ListInstancesRequest(com.google.bigtable.admin.v2.ListInstancesRequest) ArrayList(java.util.ArrayList) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 8 with ListInstancesRequest

use of com.google.spanner.admin.instance.v1.ListInstancesRequest in project java-notebooks by googleapis.

the class ITNotebookServiceClientTest method testListInstances.

@Test
public void testListInstances() {
    ListInstancesRequest request = ListInstancesRequest.newBuilder().setParent(PARENT).build();
    for (Instance element : client.listInstances(request).iterateAll()) {
        if (element.getName().equals(NOTEBOOK_INSTANCE_ID)) {
            assertEquals(expectedNotebookInstance.getContainerImage(), element.getContainerImage());
            assertEquals(expectedNotebookInstance.getName(), element.getName());
            assertEquals(expectedNotebookInstance.getMachineType(), element.getMachineType());
            assertEquals(expectedNotebookInstance.getNetwork(), element.getNetwork());
            assertEquals(expectedNotebookInstance.getSubnet(), element.getSubnet());
        }
    }
}
Also used : Instance(com.google.cloud.notebooks.v1beta1.Instance) ListInstancesRequest(com.google.cloud.notebooks.v1beta1.ListInstancesRequest) Test(org.junit.Test)

Example 9 with ListInstancesRequest

use of com.google.spanner.admin.instance.v1.ListInstancesRequest in project gapic-generator-java by googleapis.

the class AsyncListInstances method asyncListInstances.

public static void asyncListInstances() throws Exception {
    // It may require modifications to work in your environment.
    try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
        ListInstancesRequest request = ListInstancesRequest.newBuilder().setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").build();
        ApiFuture<Instance> future = cloudRedisClient.listInstancesPagedCallable().futureCall(request);
        // Do something.
        for (Instance element : future.get().iterateAll()) {
        // doThingsWith(element);
        }
    }
}
Also used : CloudRedisClient(com.google.cloud.redis.v1beta1.CloudRedisClient) Instance(com.google.cloud.redis.v1beta1.Instance) ListInstancesRequest(com.google.cloud.redis.v1beta1.ListInstancesRequest)

Aggregations

Test (org.junit.Test)6 AbstractMessage (com.google.protobuf.AbstractMessage)5 ListInstancesRequest (com.google.spanner.admin.instance.v1.ListInstancesRequest)4 ListInstancesResponse (com.google.spanner.admin.instance.v1.ListInstancesResponse)4 ByteString (com.google.protobuf.ByteString)3 ArrayList (java.util.ArrayList)3 ListInstancesRequest (com.google.bigtable.admin.v2.ListInstancesRequest)2 ListInstancesResponse (com.google.bigtable.admin.v2.ListInstancesResponse)2 CloudRedisClient (com.google.cloud.redis.v1beta1.CloudRedisClient)2 Instance (com.google.cloud.redis.v1beta1.Instance)2 ListInstancesRequest (com.google.cloud.redis.v1beta1.ListInstancesRequest)2 ListInstancesPagedResponse (com.google.cloud.spanner.admin.instance.v1.InstanceAdminClient.ListInstancesPagedResponse)2 Instance (com.google.spanner.admin.instance.v1.Instance)2 ProjectName (com.google.spanner.admin.instance.v1.ProjectName)2 GrpcCallContext (com.google.api.gax.grpc.GrpcCallContext)1 ProjectName (com.google.bigtable.admin.v2.ProjectName)1 Instance (com.google.cloud.notebooks.v1beta1.Instance)1 ListInstancesRequest (com.google.cloud.notebooks.v1beta1.ListInstancesRequest)1 ListInstancesResponse (com.google.cloud.redis.v1beta1.ListInstancesResponse)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1