use of com.google.spanner.admin.database.v1.BackupName in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method deleteBackupExceptionTest.
@Test
public void deleteBackupExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableTableAdmin.addException(exception);
try {
BackupName name = BackupName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[BACKUP]");
client.deleteBackup(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.spanner.admin.database.v1.BackupName in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method getBackupTest.
@Test
public void getBackupTest() throws Exception {
Backup expectedResponse = Backup.newBuilder().setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[BACKUP]").toString()).setSourceTable("sourceTable-95372173").setExpireTime(Timestamp.newBuilder().build()).setStartTime(Timestamp.newBuilder().build()).setEndTime(Timestamp.newBuilder().build()).setSizeBytes(-1796325715).setEncryptionInfo(EncryptionInfo.newBuilder().build()).build();
mockBigtableTableAdmin.addResponse(expectedResponse);
BackupName name = BackupName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[BACKUP]");
Backup actualResponse = client.getBackup(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockBigtableTableAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetBackupRequest actualRequest = ((GetBackupRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.spanner.admin.database.v1.BackupName in project java-bigtable by googleapis.
the class BaseBigtableTableAdminClientTest method getBackupExceptionTest.
@Test
public void getBackupExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockBigtableTableAdmin.addException(exception);
try {
BackupName name = BackupName.of("[PROJECT]", "[INSTANCE]", "[CLUSTER]", "[BACKUP]");
client.getBackup(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.spanner.admin.database.v1.BackupName in project java-spanner by googleapis.
the class GapicSpannerRpc method getBackup.
@Override
public Backup getBackup(String backupName) throws SpannerException {
acquireAdministrativeRequestsRateLimiter();
final GetBackupRequest request = GetBackupRequest.newBuilder().setName(backupName).build();
final GrpcCallContext context = newCallContext(null, backupName, request, DatabaseAdminGrpc.getGetBackupMethod());
return runWithRetryOnAdministrativeRequestsExceeded(() -> get(databaseAdminStub.getBackupCallable().futureCall(request, context)));
}
use of com.google.spanner.admin.database.v1.BackupName 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/<project>/instances/<instance>/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);
}
Aggregations