Search in sources :

Example 6 with DeleteBackupRequest

use of com.google.spanner.admin.database.v1.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)

Example 7 with DeleteBackupRequest

use of com.google.spanner.admin.database.v1.DeleteBackupRequest in project java-bigtable by googleapis.

the class BigtableTableAdminClientTests 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 8 with DeleteBackupRequest

use of com.google.spanner.admin.database.v1.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 9 with DeleteBackupRequest

use of com.google.spanner.admin.database.v1.DeleteBackupRequest in project java-spanner by googleapis.

the class DatabaseAdminClient method deleteBackup.

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
 * Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
 *
 * <p>Sample code:
 *
 * <pre>{@code
 * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
 *   BackupName name = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
 *   databaseAdminClient.deleteBackup(name);
 * }
 * }</pre>
 *
 * @param name Required. Name of the backup to delete. Values are of the form
 *     `projects/&lt;project&gt;/instances/&lt;instance&gt;/backups/&lt;backup&gt;`.
 * @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.spanner.admin.database.v1.DeleteBackupRequest)

Example 10 with DeleteBackupRequest

use of com.google.spanner.admin.database.v1.DeleteBackupRequest in project java-spanner by googleapis.

the class DatabaseAdminClientTest method deleteBackupTest2.

@Test
public void deleteBackupTest2() throws Exception {
    Empty expectedResponse = Empty.newBuilder().build();
    mockDatabaseAdmin.addResponse(expectedResponse);
    String name = "name3373707";
    client.deleteBackup(name);
    List<AbstractMessage> actualRequests = mockDatabaseAdmin.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.spanner.admin.database.v1.DeleteBackupRequest) Test(org.junit.Test)

Aggregations

DeleteBackupRequest (com.google.bigtable.admin.v2.DeleteBackupRequest)6 Test (org.junit.Test)6 DeleteBackupRequest (com.google.spanner.admin.database.v1.DeleteBackupRequest)5 AbstractMessage (com.google.protobuf.AbstractMessage)4 Empty (com.google.protobuf.Empty)4 ByteString (com.google.protobuf.ByteString)2 GrpcCallContext (com.google.api.gax.grpc.GrpcCallContext)1 BackupName (com.google.bigtable.admin.v2.BackupName)1 BackupName (com.google.spanner.admin.database.v1.BackupName)1