use of com.google.spanner.admin.database.v1.DropDatabaseRequest in project java-spanner by googleapis.
the class DatabaseAdminClient method dropDatabase.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Drops (aka deletes) a Cloud Spanner database. Completed backups for the database will be
* retained according to their `expire_time`. Note: Cloud Spanner might continue to accept
* requests for a few seconds after the database has been deleted.
*
* <p>Sample code:
*
* <pre>{@code
* try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
* DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
* databaseAdminClient.dropDatabase(database);
* }
* }</pre>
*
* @param database Required. The database to be dropped.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void dropDatabase(DatabaseName database) {
DropDatabaseRequest request = DropDatabaseRequest.newBuilder().setDatabase(database == null ? null : database.toString()).build();
dropDatabase(request);
}
use of com.google.spanner.admin.database.v1.DropDatabaseRequest in project java-spanner by googleapis.
the class DatabaseAdminClient method dropDatabase.
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Drops (aka deletes) a Cloud Spanner database. Completed backups for the database will be
* retained according to their `expire_time`. Note: Cloud Spanner might continue to accept
* requests for a few seconds after the database has been deleted.
*
* <p>Sample code:
*
* <pre>{@code
* try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
* String database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString();
* databaseAdminClient.dropDatabase(database);
* }
* }</pre>
*
* @param database Required. The database to be dropped.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final void dropDatabase(String database) {
DropDatabaseRequest request = DropDatabaseRequest.newBuilder().setDatabase(database).build();
dropDatabase(request);
}
use of com.google.spanner.admin.database.v1.DropDatabaseRequest in project java-spanner by googleapis.
the class GapicSpannerRpc method dropDatabase.
@Override
public void dropDatabase(String databaseName) throws SpannerException {
acquireAdministrativeRequestsRateLimiter();
final DropDatabaseRequest request = DropDatabaseRequest.newBuilder().setDatabase(databaseName).build();
final GrpcCallContext context = newCallContext(null, databaseName, request, DatabaseAdminGrpc.getDropDatabaseMethod());
runWithRetryOnAdministrativeRequestsExceeded(() -> {
get(databaseAdminStub.dropDatabaseCallable().futureCall(request, context));
return null;
});
}
use of com.google.spanner.admin.database.v1.DropDatabaseRequest in project java-spanner by googleapis.
the class DatabaseAdminClientTest method dropDatabaseTest2.
@Test
public void dropDatabaseTest2() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockDatabaseAdmin.addResponse(expectedResponse);
String database = "database1789464955";
client.dropDatabase(database);
List<AbstractMessage> actualRequests = mockDatabaseAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
DropDatabaseRequest actualRequest = ((DropDatabaseRequest) actualRequests.get(0));
Assert.assertEquals(database, actualRequest.getDatabase());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.spanner.admin.database.v1.DropDatabaseRequest in project java-spanner by googleapis.
the class DatabaseAdminClientTest method dropDatabaseTest.
@Test
public void dropDatabaseTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockDatabaseAdmin.addResponse(expectedResponse);
DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
client.dropDatabase(database);
List<AbstractMessage> actualRequests = mockDatabaseAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
DropDatabaseRequest actualRequest = ((DropDatabaseRequest) actualRequests.get(0));
Assert.assertEquals(database.toString(), actualRequest.getDatabase());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations