Search in sources :

Example 56 with InstanceName

use of com.google.spanner.admin.database.v1.InstanceName in project java-spanner by googleapis.

the class InstanceAdminClientTest method getInstanceExceptionTest.

@Test
public void getInstanceExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockInstanceAdmin.addException(exception);
    try {
        InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
        client.getInstance(name);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InstanceName(com.google.spanner.admin.instance.v1.InstanceName) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 57 with InstanceName

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

the class SyncFailoverInstanceInstancenameFailoverinstancerequestdataprotectionmode method syncFailoverInstanceInstancenameFailoverinstancerequestdataprotectionmode.

public static void syncFailoverInstanceInstancenameFailoverinstancerequestdataprotectionmode() throws Exception {
    // It may require modifications to work in your environment.
    try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
        InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
        FailoverInstanceRequest.DataProtectionMode dataProtectionMode = FailoverInstanceRequest.DataProtectionMode.forNumber(0);
        Instance response = cloudRedisClient.failoverInstanceAsync(name, dataProtectionMode).get();
    }
}
Also used : InstanceName(com.google.cloud.redis.v1beta1.InstanceName) FailoverInstanceRequest(com.google.cloud.redis.v1beta1.FailoverInstanceRequest) CloudRedisClient(com.google.cloud.redis.v1beta1.CloudRedisClient) Instance(com.google.cloud.redis.v1beta1.Instance)

Aggregations

Test (org.junit.Test)44 AbstractMessage (com.google.protobuf.AbstractMessage)24 StatusRuntimeException (io.grpc.StatusRuntimeException)24 ByteString (com.google.protobuf.ByteString)21 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)20 InstanceName (com.google.bigtable.admin.v2.InstanceName)20 InstanceName (com.google.spanner.admin.database.v1.InstanceName)16 ExecutionException (java.util.concurrent.ExecutionException)11 Operation (com.google.longrunning.Operation)9 InstanceName (com.google.spanner.admin.instance.v1.InstanceName)9 ArrayList (java.util.ArrayList)7 CloudRedisClient (com.google.cloud.redis.v1beta1.CloudRedisClient)6 Table (com.google.bigtable.admin.v2.Table)5 InstanceName (com.google.cloud.redis.v1beta1.InstanceName)5 Database (com.google.spanner.admin.database.v1.Database)5 GrpcCallContext (com.google.api.gax.grpc.GrpcCallContext)4 Backup (com.google.spanner.admin.database.v1.Backup)4 InstanceConfigName (com.google.spanner.admin.instance.v1.InstanceConfigName)4 IOException (java.io.IOException)4 ExpectedException (org.junit.rules.ExpectedException)4