Search in sources :

Example 56 with Instance

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);
}
Also used : DeleteTableRequest(com.google.bigtable.admin.v2.DeleteTableRequest)

Example 57 with Instance

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);
}
Also used : DeleteSnapshotRequest(com.google.bigtable.admin.v2.DeleteSnapshotRequest)

Example 58 with Instance

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);
}
Also used : DeleteSnapshotRequest(com.google.bigtable.admin.v2.DeleteSnapshotRequest)

Example 59 with Instance

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());
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) Backup(com.google.bigtable.admin.v2.Backup) StatusRuntimeException(io.grpc.StatusRuntimeException) ClusterName(com.google.bigtable.admin.v2.ClusterName) ByteString(com.google.protobuf.ByteString) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 60 with Instance

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()));
}
Also used : Empty(com.google.protobuf.Empty) DropRowRangeRequest(com.google.bigtable.admin.v2.DropRowRangeRequest) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)137 AbstractMessage (com.google.protobuf.AbstractMessage)63 ByteString (com.google.protobuf.ByteString)57 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)41 StatusRuntimeException (io.grpc.StatusRuntimeException)41 Instance (com.google.cloud.redis.v1beta1.Instance)34 CloudRedisClient (com.google.cloud.redis.v1beta1.CloudRedisClient)30 Instance (com.google.cloud.compute.v1.Instance)25 Operation (com.google.longrunning.Operation)22 InstanceName (com.google.bigtable.admin.v2.InstanceName)20 InstancesClient (com.google.cloud.compute.v1.InstancesClient)19 ExecutionException (java.util.concurrent.ExecutionException)17 ClusterName (com.google.bigtable.admin.v2.ClusterName)16 Table (com.google.bigtable.admin.v2.Table)16 HashMap (java.util.HashMap)16 TableName (com.google.bigtable.admin.v2.TableName)15 Cluster (com.google.bigtable.admin.v2.Cluster)13 ColumnFamily (com.google.bigtable.admin.v2.ColumnFamily)13 Operation (com.google.cloud.compute.v1.Operation)13 ArrayList (java.util.ArrayList)13