Search in sources :

Example 66 with Instance

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

the class ITNotebookServiceClientTest method testGetInstance.

@Test
public void testGetInstance() {
    GetInstanceRequest request = GetInstanceRequest.newBuilder().setName(INSTANCE_NAME).build();
    Instance actualNotebookInstance = client.getInstance(request);
    assertEquals(expectedNotebookInstance.getContainerImage(), actualNotebookInstance.getContainerImage());
    assertEquals(expectedNotebookInstance.getName(), actualNotebookInstance.getName());
    assertEquals(expectedNotebookInstance.getNetwork(), actualNotebookInstance.getNetwork());
    assertEquals(expectedNotebookInstance.getSubnet(), actualNotebookInstance.getSubnet());
}
Also used : GetInstanceRequest(com.google.cloud.notebooks.v1beta1.GetInstanceRequest) Instance(com.google.cloud.notebooks.v1beta1.Instance) Test(org.junit.Test)

Example 67 with Instance

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

the class ITNotebookServiceClientTest method stopInstance.

private String stopInstance() throws ExecutionException, InterruptedException {
    StopInstanceRequest request = StopInstanceRequest.newBuilder().setName(INSTANCE_NAME).build();
    Instance response = client.stopInstanceAsync(request).get();
    return response.getState().name();
}
Also used : Instance(com.google.cloud.notebooks.v1beta1.Instance) StopInstanceRequest(com.google.cloud.notebooks.v1beta1.StopInstanceRequest)

Example 68 with Instance

use of com.google.spanner.admin.instance.v1.Instance 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 69 with Instance

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

the class GapicSpannerRpc method createInstance.

@Override
public OperationFuture<Instance, CreateInstanceMetadata> createInstance(String parent, String instanceId, Instance instance) throws SpannerException {
    CreateInstanceRequest request = CreateInstanceRequest.newBuilder().setParent(parent).setInstanceId(instanceId).setInstance(instance).build();
    GrpcCallContext context = newCallContext(null, parent, request, InstanceAdminGrpc.getCreateInstanceMethod());
    return instanceAdminStub.createInstanceOperationCallable().futureCall(request, context);
}
Also used : GrpcCallContext(com.google.api.gax.grpc.GrpcCallContext) CreateInstanceRequest(com.google.spanner.admin.instance.v1.CreateInstanceRequest)

Example 70 with Instance

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

the class GapicSpannerRpc method updateInstance.

@Override
public OperationFuture<Instance, UpdateInstanceMetadata> updateInstance(Instance instance, FieldMask fieldMask) throws SpannerException {
    UpdateInstanceRequest request = UpdateInstanceRequest.newBuilder().setInstance(instance).setFieldMask(fieldMask).build();
    GrpcCallContext context = newCallContext(null, instance.getName(), request, InstanceAdminGrpc.getUpdateInstanceMethod());
    return instanceAdminStub.updateInstanceOperationCallable().futureCall(request, context);
}
Also used : GrpcCallContext(com.google.api.gax.grpc.GrpcCallContext) UpdateInstanceRequest(com.google.spanner.admin.instance.v1.UpdateInstanceRequest)

Aggregations

Test (org.junit.Test)50 AbstractMessage (com.google.protobuf.AbstractMessage)19 ByteString (com.google.protobuf.ByteString)17 ExecutionException (java.util.concurrent.ExecutionException)16 Instance (com.google.cloud.spanner.Instance)15 StatusRuntimeException (io.grpc.StatusRuntimeException)14 Instance (com.google.cloud.compute.v1.Instance)11 InstancesClient (com.google.cloud.compute.v1.InstancesClient)11 CreateInstanceMetadata (com.google.spanner.admin.instance.v1.CreateInstanceMetadata)11 Instance (com.google.spanner.admin.instance.v1.Instance)11 Instance (com.google.bigtable.admin.v2.Instance)10 InstanceAdminClient (com.google.cloud.spanner.InstanceAdminClient)10 InstanceInfo (com.google.cloud.spanner.InstanceInfo)10 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)9 Instance (com.google.cloud.notebooks.v1beta1.Instance)9 Spanner (com.google.cloud.spanner.Spanner)8 ArrayList (java.util.ArrayList)8 Operation (com.google.cloud.compute.v1.Operation)7 FieldMask (com.google.protobuf.FieldMask)7 InstanceName (com.google.spanner.admin.instance.v1.InstanceName)7