use of com.google.bigtable.admin.v2.Snapshot 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
* 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.Snapshot 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
* 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.Snapshot in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method snapshotTableTest2.
@Test
public void snapshotTableTest2() throws Exception {
Snapshot expectedResponse = Snapshot.newBuilder().setName(SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]").toString()).setSourceTable(Table.newBuilder().build()).setDataSizeBytes(-2110122398).setCreateTime(Timestamp.newBuilder().build()).setDeleteTime(Timestamp.newBuilder().build()).setDescription("description-1724546052").build();
Operation resultOperation = Operation.newBuilder().setName("snapshotTableTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockBigtableTableAdmin.addResponse(resultOperation);
TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
String cluster = "cluster872092154";
String snapshotId = "snapshotId-1113817601";
String description = "description-1724546052";
Snapshot actualResponse = client.snapshotTableAsync(name, cluster, snapshotId, description).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
SnapshotTableRequest actualRequest = ((SnapshotTableRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertEquals(cluster, actualRequest.getCluster());
Assert.assertEquals(snapshotId, actualRequest.getSnapshotId());
Assert.assertEquals(description, actualRequest.getDescription());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.admin.v2.Snapshot in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method snapshotTableTest.
@Test
public void snapshotTableTest() throws Exception {
Snapshot expectedResponse = Snapshot.newBuilder().setName(SnapshotName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[SNAPSHOT]").toString()).setSourceTable(Table.newBuilder().build()).setDataSizeBytes(-2110122398).setCreateTime(Timestamp.newBuilder().build()).setDeleteTime(Timestamp.newBuilder().build()).setDescription("description-1724546052").build();
Operation resultOperation = Operation.newBuilder().setName("snapshotTableTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
mockBigtableTableAdmin.addResponse(resultOperation);
TableName name = TableName.of("[PROJECT]", "[INSTANCE]", "[TABLE]");
ClusterName cluster = ClusterName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]");
String snapshotId = "snapshotId-1113817601";
String description = "description-1724546052";
Snapshot actualResponse = client.snapshotTableAsync(name, cluster, snapshotId, description).get();
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
SnapshotTableRequest actualRequest = ((SnapshotTableRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertEquals(cluster.toString(), actualRequest.getCluster());
Assert.assertEquals(snapshotId, actualRequest.getSnapshotId());
Assert.assertEquals(description, actualRequest.getDescription());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.bigtable.admin.v2.Snapshot in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method createTableFromSnapshotExceptionTest3.
@Test
public void createTableFromSnapshotExceptionTest3() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableTableAdmin.addException(exception);
try {
String parent = "parent-995424086";
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());
}
}
Aggregations