Search in sources :

Example 1 with DeleteBackupRequest

use of com.google.bigtable.admin.v2.DeleteBackupRequest in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClient method deleteBackup.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Deletes a pending or completed Cloud Bigtable backup.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient =
 *     BaseBigtableTableAdminClient.create()) {
 *   BackupName name = BackupName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[BACKUP]");
 *   baseBigtableTableAdminClient.deleteBackup(name);
 * }
 * }</pre>
 *
 * @param name Required. Name of the backup to delete. Values are of the form
 *     `projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup}`.
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void deleteBackup(BackupName name) {
    DeleteBackupRequest request = DeleteBackupRequest.newBuilder().setName(name == null ? null : name.toString()).build();
    deleteBackup(request);
}
Also used : DeleteBackupRequest(com.google.bigtable.admin.v2.DeleteBackupRequest)

Example 2 with DeleteBackupRequest

use of com.google.bigtable.admin.v2.DeleteBackupRequest in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClient method deleteBackup.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Deletes a pending or completed Cloud Bigtable backup.
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * try (BaseBigtableTableAdminClient baseBigtableTableAdminClient =
 *     BaseBigtableTableAdminClient.create()) {
 *   String name = BackupName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[BACKUP]").toString();
 *   baseBigtableTableAdminClient.deleteBackup(name);
 * }
 * }</pre>
 *
 * @param name Required. Name of the backup to delete. Values are of the form
 *     `projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup}`.
 * @throws com.google.api.gax.rpc.ApiException if the remote call fails
 */
public final void deleteBackup(String name) {
    DeleteBackupRequest request = DeleteBackupRequest.newBuilder().setName(name).build();
    deleteBackup(request);
}
Also used : DeleteBackupRequest(com.google.bigtable.admin.v2.DeleteBackupRequest)

Example 3 with DeleteBackupRequest

use of com.google.bigtable.admin.v2.DeleteBackupRequest in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method deleteBackupTest2.

@Test
public void deleteBackupTest2() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockBigtableTableAdmin.addResponse(expectedResponse);
    String name = "name3373707";
    client.deleteBackup(name);
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteBackupRequest actualRequest = ((DeleteBackupRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) ByteString(com.google.protobuf.ByteString) DeleteBackupRequest(com.google.bigtable.admin.v2.DeleteBackupRequest) Test(org.junit.Test)

Example 4 with DeleteBackupRequest

use of com.google.bigtable.admin.v2.DeleteBackupRequest in project java-bigtable by googleapis.

the class BigtableTableAdminClientTest method testDeleteBackup.

@Test
public void testDeleteBackup() {
    // Setup
    Mockito.when(mockStub.deleteBackupCallable()).thenReturn(mockDeleteBackupCallable);
    DeleteBackupRequest testRequest = DeleteBackupRequest.newBuilder().setName(NameUtil.formatBackupName(PROJECT_ID, INSTANCE_ID, CLUSTER_ID, BACKUP_ID)).build();
    Mockito.when(mockDeleteBackupCallable.futureCall(testRequest)).thenReturn(ApiFutures.immediateFuture(Empty.getDefaultInstance()));
    // Execute
    adminClient.deleteBackup(CLUSTER_ID, BACKUP_ID);
    // Verify
    Mockito.verify(mockDeleteBackupCallable, Mockito.times(1)).futureCall(testRequest);
}
Also used : DeleteBackupRequest(com.google.bigtable.admin.v2.DeleteBackupRequest) Test(org.junit.Test)

Example 5 with DeleteBackupRequest

use of com.google.bigtable.admin.v2.DeleteBackupRequest in project java-bigtable by googleapis.

the class BaseBigtableTableAdminClientTest method deleteBackupTest.

@Test
public void deleteBackupTest() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockBigtableTableAdmin.addResponse(expectedResponse);
    BackupName name = BackupName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[BACKUP]");
    client.deleteBackup(name);
    List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    DeleteBackupRequest actualRequest = ((DeleteBackupRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Empty(com.google.protobuf.Empty) AbstractMessage(com.google.protobuf.AbstractMessage) DeleteBackupRequest(com.google.bigtable.admin.v2.DeleteBackupRequest) BackupName(com.google.bigtable.admin.v2.BackupName) Test(org.junit.Test)

Aggregations

DeleteBackupRequest (com.google.bigtable.admin.v2.DeleteBackupRequest)5 Test (org.junit.Test)3 AbstractMessage (com.google.protobuf.AbstractMessage)2 Empty (com.google.protobuf.Empty)2 BackupName (com.google.bigtable.admin.v2.BackupName)1 ByteString (com.google.protobuf.ByteString)1