Search in sources :

Example 11 with InstanceName

use of com.google.cloud.redis.v1beta1.InstanceName in project gapic-generator-java by googleapis.

the class SyncGetInstanceAuthStringInstancename method syncGetInstanceAuthStringInstancename.

public static void syncGetInstanceAuthStringInstancename() throws Exception {
    // It may require modifications to work in your environment.
    try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
        InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
        InstanceAuthString response = cloudRedisClient.getInstanceAuthString(name);
    }
}
Also used : InstanceName(com.google.cloud.redis.v1beta1.InstanceName) CloudRedisClient(com.google.cloud.redis.v1beta1.CloudRedisClient) InstanceAuthString(com.google.cloud.redis.v1beta1.InstanceAuthString)

Example 12 with InstanceName

use of com.google.cloud.redis.v1beta1.InstanceName in project gapic-generator-java by googleapis.

the class SyncUpgradeInstanceInstancenameString method syncUpgradeInstanceInstancenameString.

public static void syncUpgradeInstanceInstancenameString() throws Exception {
    // It may require modifications to work in your environment.
    try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
        InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
        String redisVersion = "redisVersion-1972584739";
        Instance response = cloudRedisClient.upgradeInstanceAsync(name, redisVersion).get();
    }
}
Also used : InstanceName(com.google.cloud.redis.v1beta1.InstanceName) CloudRedisClient(com.google.cloud.redis.v1beta1.CloudRedisClient) Instance(com.google.cloud.redis.v1beta1.Instance)

Example 13 with InstanceName

use of com.google.cloud.redis.v1beta1.InstanceName in project gapic-generator-java by googleapis.

the class SyncRescheduleMaintenanceInstancenameReschedulemaintenancerequestrescheduletypeTimestamp method syncRescheduleMaintenanceInstancenameReschedulemaintenancerequestrescheduletypeTimestamp.

public static void syncRescheduleMaintenanceInstancenameReschedulemaintenancerequestrescheduletypeTimestamp() throws Exception {
    // It may require modifications to work in your environment.
    try (CloudRedisClient cloudRedisClient = CloudRedisClient.create()) {
        InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]");
        RescheduleMaintenanceRequest.RescheduleType rescheduleType = RescheduleMaintenanceRequest.RescheduleType.forNumber(0);
        Timestamp scheduleTime = Timestamp.newBuilder().build();
        Instance response = cloudRedisClient.rescheduleMaintenanceAsync(name, rescheduleType, scheduleTime).get();
    }
}
Also used : InstanceName(com.google.cloud.redis.v1beta1.InstanceName) CloudRedisClient(com.google.cloud.redis.v1beta1.CloudRedisClient) Instance(com.google.cloud.redis.v1beta1.Instance) RescheduleMaintenanceRequest(com.google.cloud.redis.v1beta1.RescheduleMaintenanceRequest) Timestamp(com.google.protobuf.Timestamp)

Example 14 with InstanceName

use of com.google.cloud.redis.v1beta1.InstanceName in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method createTableExceptionTest.

@Test
public void createTableExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockBigtableTableAdmin.addException(exception);
    try {
        InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
        String tableId = "tableId-1552905847";
        Table table = Table.newBuilder().build();
        client.createTable(parent, tableId, table);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InstanceName(com.google.bigtable.admin.v2.InstanceName) Table(com.google.bigtable.admin.v2.Table) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 15 with InstanceName

use of com.google.cloud.redis.v1beta1.InstanceName in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method createTableFromSnapshotExceptionTest.

@Test
public void createTableFromSnapshotExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockBigtableTableAdmin.addException(exception);
    try {
        InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
        String tableId = "tableId-1552905847";
        SnapshotName sourceSnapshot = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
        client.createTableFromSnapshotAsync(parent, tableId, sourceSnapshot).get();
        Assert.fail("No exception raised");
    } catch (ExecutionException e) {
        Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
        InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
        Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
    }
}
Also used : InstanceName(com.google.bigtable.admin.v2.InstanceName) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) ByteString(com.google.protobuf.ByteString) ExecutionException(java.util.concurrent.ExecutionException) SnapshotName(com.google.bigtable.admin.v2.SnapshotName) Test(org.junit.Test)

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 InstanceName (com.google.cloud.redis.v1beta1.InstanceName)6 Table (com.google.bigtable.admin.v2.Table)5 Instance (com.google.cloud.redis.v1beta1.Instance)4 Database (com.google.spanner.admin.database.v1.Database)4 InstanceConfigName (com.google.spanner.admin.instance.v1.InstanceConfigName)4 IOException (java.io.IOException)4 ExpectedException (org.junit.rules.ExpectedException)4 AppProfile (com.google.bigtable.admin.v2.AppProfile)3