use of com.google.bigtable.admin.v2.Instance in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClient method deleteTable.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Permanently deletes a specified table and all of its data.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* try (BaseBigtableTableAdminClient baseBigtableTableAdminClient =
* BaseBigtableTableAdminClient.create()) {
* String name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]").toString();
* baseBigtableTableAdminClient.deleteTable(name);
* }
* }</pre>
*
* @param name Required. The unique name of the table to be deleted. Values are of the form
* `projects/{project}/instances/{instance}/tables/{table}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteTable(String name) {
DeleteTableRequest request = DeleteTableRequest.newBuilder().setName(name).build();
deleteTable(request);
}
use of com.google.bigtable.admin.v2.Instance in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClient method deleteSnapshot.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Permanently deletes the specified snapshot.
*
* <p>Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not
* currently available to most Cloud Bigtable customers. This feature might be changed in
* backward-incompatible ways and is not recommended for production use. It is not subject to any
* SLA or deprecation policy.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* try (BaseBigtableTableAdminClient baseBigtableTableAdminClient =
* BaseBigtableTableAdminClient.create()) {
* SnapshotName name = SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]");
* baseBigtableTableAdminClient.deleteSnapshot(name);
* }
* }</pre>
*
* @param name Required. The unique name of the snapshot to be deleted. Values are of the form
* `projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteSnapshot(SnapshotName name) {
DeleteSnapshotRequest request = DeleteSnapshotRequest.newBuilder().setName(name == null ? null : name.toString()).build();
deleteSnapshot(request);
}
use of com.google.bigtable.admin.v2.Instance in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClient method deleteSnapshot.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Permanently deletes the specified snapshot.
*
* <p>Note: This is a private alpha release of Cloud Bigtable snapshots. This feature is not
* currently available to most Cloud Bigtable customers. This feature might be changed in
* backward-incompatible ways and is not recommended for production use. It is not subject to any
* SLA or deprecation policy.
*
* <p>Sample code:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* try (BaseBigtableTableAdminClient baseBigtableTableAdminClient =
* BaseBigtableTableAdminClient.create()) {
* String name =
* SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]").toString();
* baseBigtableTableAdminClient.deleteSnapshot(name);
* }
* }</pre>
*
* @param name Required. The unique name of the snapshot to be deleted. Values are of the form
* `projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot}`.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void deleteSnapshot(String name) {
DeleteSnapshotRequest request = DeleteSnapshotRequest.newBuilder().setName(name).build();
deleteSnapshot(request);
}
use of com.google.bigtable.admin.v2.Instance in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method createBackupExceptionTest.
@Test
public void createBackupExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableTableAdmin.addException(exception);
try {
ClusterName parent = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
String backupId = "backupId2121930365";
Backup backup = Backup.newBuilder().build();
client.createBackupAsync(parent, backupId, backup).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.Instance in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method dropRowRangeTest.
@Test
public void dropRowRangeTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockBigtableTableAdmin.addResponse(expectedResponse);
DropRowRangeRequest request = DropRowRangeRequest.newBuilder().setName(TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]").toString()).build();
client.dropRowRange(request);
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
DropRowRangeRequest actualRequest = ((DropRowRangeRequest) actualRequests.get(0));
Assert.assertEquals(request.getName(), actualRequest.getName());
Assert.assertEquals(request.getRowKeyPrefix(), actualRequest.getRowKeyPrefix());
Assert.assertEquals(request.getDeleteAllDataFromTable(), actualRequest.getDeleteAllDataFromTable());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations