use of com.google.bigtable.admin.v2.ClusterName in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method snapshotTableExceptionTest3.
@Test
public void snapshotTableExceptionTest3() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableTableAdmin.addException(exception);
try {
String name = "name3373707";
ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
String snapshotId = "snapshotId-1113817601";
String description = "description-1724546052";
client.snapshotTableAsync(name, cluster, snapshotId, description).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());
}
}
use of com.google.bigtable.admin.v2.ClusterName in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method snapshotTableExceptionTest.
@Test
public void snapshotTableExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableTableAdmin.addException(exception);
try {
TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
String snapshotId = "snapshotId-1113817601";
String description = "description-1724546052";
client.snapshotTableAsync(name, cluster, snapshotId, description).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());
}
}
use of com.google.bigtable.admin.v2.ClusterName in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method listBackupsExceptionTest.
@Test
public void listBackupsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableTableAdmin.addException(exception);
try {
ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
client.listBackups(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.bigtable.admin.v2.ClusterName in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method listBackupsTest.
@Test
public void listBackupsTest() throws Exception {
Backup responsesElement = Backup.newBuilder().build();
ListBackupsResponse expectedResponse = ListBackupsResponse.newBuilder().setNextPageToken("").addAllBackups(Arrays.asList(responsesElement)).build();
mockBigtableTableAdmin.addResponse(expectedResponse);
ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
ListBackupsPagedResponse pagedListResponse = client.listBackups(parent);
List<Backup> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getBackupsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListBackupsRequest actualRequest = ((ListBackupsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.admin.v2.ClusterName in project java-bigtable by googleapis.
the class BaseBigtableInstanceAdminClient method deleteCluster.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Deletes a cluster from an instance.
*
* <p>Sample code:
*
* <pre>{@code
* try (BaseBigtableInstanceAdminClient baseBigtableInstanceAdminClient =
* BaseBigtableInstanceAdminClient.create()) {
* ClusterName name = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
* baseBigtableInstanceAdminClient.deleteCluster(name);
* }
* }</pre>
*
* @param name Required. The unique name of the cluster to be deleted. Values are of the form
* `projects/{project}/instances/{instance}/clusters/{cluster}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteCluster(ClusterName name) {
DeleteClusterRequest request = DeleteClusterRequest.newBuilder().setName(name == null ? null : name.toString()).build();
deleteCluster(request);
}
Aggregations