public class DatabaseAdminClient implements BackgroundResource
Service Description: Cloud Spanner Database Admin API
The Cloud Spanner Database Admin API can be used to: * create, drop, and list databases * update the schema of pre-existing databases * create, delete and list backups for a database * restore a database from an existing backup
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
Database response = databaseAdminClient.getDatabase(name);
}
Note: close() needs to be called on the DatabaseAdminClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of DatabaseAdminSettings to create(). For example:
To customize credentials:
DatabaseAdminSettings databaseAdminSettings =
DatabaseAdminSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create(databaseAdminSettings);
To customize the endpoint:
DatabaseAdminSettings databaseAdminSettings =
DatabaseAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create(databaseAdminSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceStatic Methods
create()
public static final DatabaseAdminClient create()
Constructs an instance of DatabaseAdminClient with default settings.
Type | Description |
DatabaseAdminClient |
Type | Description |
IOException |
create(DatabaseAdminSettings settings)
public static final DatabaseAdminClient create(DatabaseAdminSettings settings)
Constructs an instance of DatabaseAdminClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
Name | Description |
settings | DatabaseAdminSettings |
Type | Description |
DatabaseAdminClient |
Type | Description |
IOException |
create(DatabaseAdminStub stub)
public static final DatabaseAdminClient create(DatabaseAdminStub stub)
Constructs an instance of DatabaseAdminClient, using the given stub for making calls. This is for advanced usage - prefer using create(DatabaseAdminSettings).
Name | Description |
stub | DatabaseAdminStub |
Type | Description |
DatabaseAdminClient |
Constructors
DatabaseAdminClient(DatabaseAdminSettings settings)
protected DatabaseAdminClient(DatabaseAdminSettings settings)
Constructs an instance of DatabaseAdminClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
Name | Description |
settings | DatabaseAdminSettings |
DatabaseAdminClient(DatabaseAdminStub stub)
protected DatabaseAdminClient(DatabaseAdminStub stub)
Name | Description |
stub | DatabaseAdminStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Name | Description |
duration | long |
unit | TimeUnit |
Type | Description |
boolean |
Type | Description |
InterruptedException |
close()
public final void close()
createBackupAsync(CreateBackupRequest request)
public final OperationFuture<Backup,CreateBackupMetadata> createBackupAsync(CreateBackupRequest request)
Starts creating a new Cloud Spanner Backup. The returned backup long-running
operation will have a name of the format
projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>
and can be used to track creation of the backup. The
metadata field type is
CreateBackupMetadata. The
response field type is
Backup, if successful. Cancelling the returned
operation will stop the creation and delete the backup. There can be only one pending backup
creation per database. Backup creation of different databases can run concurrently.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
CreateBackupRequest request =
CreateBackupRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setBackupId("backupId2121930365")
.setBackup(Backup.newBuilder().build())
.setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build())
.build();
Backup response = databaseAdminClient.createBackupAsync(request).get();
}
Name | Description |
request | CreateBackupRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Backup,CreateBackupMetadata> |
createBackupAsync(InstanceName parent, Backup backup, String backupId)
public final OperationFuture<Backup,CreateBackupMetadata> createBackupAsync(InstanceName parent, Backup backup, String backupId)
Starts creating a new Cloud Spanner Backup. The returned backup long-running
operation will have a name of the format
projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>
and can be used to track creation of the backup. The
metadata field type is
CreateBackupMetadata. The
response field type is
Backup, if successful. Cancelling the returned
operation will stop the creation and delete the backup. There can be only one pending backup
creation per database. Backup creation of different databases can run concurrently.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
Backup backup = Backup.newBuilder().build();
String backupId = "backupId2121930365";
Backup response = databaseAdminClient.createBackupAsync(parent, backup, backupId).get();
}
Name | Description |
parent | InstanceName Required. The name of the instance in which the backup will be created. This must
be the same instance that contains the database the backup will be created from. The backup
will be stored in the location(s) specified in the instance configuration of this instance.
Values are of the form |
backup | Backup Required. The backup to create. |
backupId | String Required. The id of the backup to be created. The |
Type | Description |
OperationFuture<Backup,CreateBackupMetadata> |
createBackupAsync(String parent, Backup backup, String backupId)
public final OperationFuture<Backup,CreateBackupMetadata> createBackupAsync(String parent, Backup backup, String backupId)
Starts creating a new Cloud Spanner Backup. The returned backup long-running
operation will have a name of the format
projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>
and can be used to track creation of the backup. The
metadata field type is
CreateBackupMetadata. The
response field type is
Backup, if successful. Cancelling the returned
operation will stop the creation and delete the backup. There can be only one pending backup
creation per database. Backup creation of different databases can run concurrently.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
Backup backup = Backup.newBuilder().build();
String backupId = "backupId2121930365";
Backup response = databaseAdminClient.createBackupAsync(parent, backup, backupId).get();
}
Name | Description |
parent | String Required. The name of the instance in which the backup will be created. This must
be the same instance that contains the database the backup will be created from. The backup
will be stored in the location(s) specified in the instance configuration of this instance.
Values are of the form |
backup | Backup Required. The backup to create. |
backupId | String Required. The id of the backup to be created. The |
Type | Description |
OperationFuture<Backup,CreateBackupMetadata> |
createBackupCallable()
public final UnaryCallable<CreateBackupRequest,Operation> createBackupCallable()
Starts creating a new Cloud Spanner Backup. The returned backup long-running
operation will have a name of the format
projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>
and can be used to track creation of the backup. The
metadata field type is
CreateBackupMetadata. The
response field type is
Backup, if successful. Cancelling the returned
operation will stop the creation and delete the backup. There can be only one pending backup
creation per database. Backup creation of different databases can run concurrently.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
CreateBackupRequest request =
CreateBackupRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setBackupId("backupId2121930365")
.setBackup(Backup.newBuilder().build())
.setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build())
.build();
ApiFuture<Operation> future = databaseAdminClient.createBackupCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
Type | Description |
UnaryCallable<CreateBackupRequest,Operation> |
createBackupOperationCallable()
public final OperationCallable<CreateBackupRequest,Backup,CreateBackupMetadata> createBackupOperationCallable()
Starts creating a new Cloud Spanner Backup. The returned backup long-running
operation will have a name of the format
projects/<project>/instances/<instance>/backups/<backup>/operations/<operation_id>
and can be used to track creation of the backup. The
metadata field type is
CreateBackupMetadata. The
response field type is
Backup, if successful. Cancelling the returned
operation will stop the creation and delete the backup. There can be only one pending backup
creation per database. Backup creation of different databases can run concurrently.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
CreateBackupRequest request =
CreateBackupRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setBackupId("backupId2121930365")
.setBackup(Backup.newBuilder().build())
.setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build())
.build();
OperationFuture
Type | Description |
OperationCallable<CreateBackupRequest,Backup,CreateBackupMetadata> |
createDatabaseAsync(CreateDatabaseRequest request)
public final OperationFuture<Database,CreateDatabaseMetadata> createDatabaseAsync(CreateDatabaseRequest request)
Creates a new Cloud Spanner database and starts to prepare it for serving. The returned
long-running operation will have a name of the format
<database_name>/operations/<operation_id>
and can be used to track preparation of
the database. The metadata field type is
CreateDatabaseMetadata. The
response field type is
Database, if successful.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
CreateDatabaseRequest request =
CreateDatabaseRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setCreateStatement("createStatement744686547")
.addAllExtraStatements(new ArrayList<String>())
.setEncryptionConfig(EncryptionConfig.newBuilder().build())
.setDatabaseDialect(DatabaseDialect.forNumber(0))
.build();
Database response = databaseAdminClient.createDatabaseAsync(request).get();
}
Name | Description |
request | CreateDatabaseRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Database,CreateDatabaseMetadata> |
createDatabaseAsync(InstanceName parent, String createStatement)
public final OperationFuture<Database,CreateDatabaseMetadata> createDatabaseAsync(InstanceName parent, String createStatement)
Creates a new Cloud Spanner database and starts to prepare it for serving. The returned
long-running operation will have a name of the format
<database_name>/operations/<operation_id>
and can be used to track preparation of
the database. The metadata field type is
CreateDatabaseMetadata. The
response field type is
Database, if successful.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String createStatement = "createStatement744686547";
Database response = databaseAdminClient.createDatabaseAsync(parent, createStatement).get();
}
Name | Description |
parent | InstanceName Required. The name of the instance that will serve the new database. Values are
of the form |
createStatement | String Required. A |
Type | Description |
OperationFuture<Database,CreateDatabaseMetadata> |
createDatabaseAsync(String parent, String createStatement)
public final OperationFuture<Database,CreateDatabaseMetadata> createDatabaseAsync(String parent, String createStatement)
Creates a new Cloud Spanner database and starts to prepare it for serving. The returned
long-running operation will have a name of the format
<database_name>/operations/<operation_id>
and can be used to track preparation of
the database. The metadata field type is
CreateDatabaseMetadata. The
response field type is
Database, if successful.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
String createStatement = "createStatement744686547";
Database response = databaseAdminClient.createDatabaseAsync(parent, createStatement).get();
}
Name | Description |
parent | String Required. The name of the instance that will serve the new database. Values are
of the form |
createStatement | String Required. A |
Type | Description |
OperationFuture<Database,CreateDatabaseMetadata> |
createDatabaseCallable()
public final UnaryCallable<CreateDatabaseRequest,Operation> createDatabaseCallable()
Creates a new Cloud Spanner database and starts to prepare it for serving. The returned
long-running operation will have a name of the format
<database_name>/operations/<operation_id>
and can be used to track preparation of
the database. The metadata field type is
CreateDatabaseMetadata. The
response field type is
Database, if successful.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
CreateDatabaseRequest request =
CreateDatabaseRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setCreateStatement("createStatement744686547")
.addAllExtraStatements(new ArrayList<String>())
.setEncryptionConfig(EncryptionConfig.newBuilder().build())
.setDatabaseDialect(DatabaseDialect.forNumber(0))
.build();
ApiFuture<Operation> future =
databaseAdminClient.createDatabaseCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
Type | Description |
UnaryCallable<CreateDatabaseRequest,Operation> |
createDatabaseOperationCallable()
public final OperationCallable<CreateDatabaseRequest,Database,CreateDatabaseMetadata> createDatabaseOperationCallable()
Creates a new Cloud Spanner database and starts to prepare it for serving. The returned
long-running operation will have a name of the format
<database_name>/operations/<operation_id>
and can be used to track preparation of
the database. The metadata field type is
CreateDatabaseMetadata. The
response field type is
Database, if successful.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
CreateDatabaseRequest request =
CreateDatabaseRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setCreateStatement("createStatement744686547")
.addAllExtraStatements(new ArrayList<String>())
.setEncryptionConfig(EncryptionConfig.newBuilder().build())
.setDatabaseDialect(DatabaseDialect.forNumber(0))
.build();
OperationFuture
Type | Description |
OperationCallable<CreateDatabaseRequest,Database,CreateDatabaseMetadata> |
deleteBackup(BackupName name)
public final void deleteBackup(BackupName name)
Deletes a pending or completed Backup.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
BackupName name = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
databaseAdminClient.deleteBackup(name);
}
Name | Description |
name | BackupName Required. Name of the backup to delete. Values are of the form
|
deleteBackup(DeleteBackupRequest request)
public final void deleteBackup(DeleteBackupRequest request)
Deletes a pending or completed Backup.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DeleteBackupRequest request =
DeleteBackupRequest.newBuilder()
.setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.build();
databaseAdminClient.deleteBackup(request);
}
Name | Description |
request | DeleteBackupRequest The request object containing all of the parameters for the API call. |
deleteBackup(String name)
public final void deleteBackup(String name)
Deletes a pending or completed Backup.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String name = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
databaseAdminClient.deleteBackup(name);
}
Name | Description |
name | String Required. Name of the backup to delete. Values are of the form
|
deleteBackupCallable()
public final UnaryCallable<DeleteBackupRequest,Empty> deleteBackupCallable()
Deletes a pending or completed Backup.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DeleteBackupRequest request =
DeleteBackupRequest.newBuilder()
.setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.build();
ApiFuture<Empty> future = databaseAdminClient.deleteBackupCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
UnaryCallable<DeleteBackupRequest,Empty> |
dropDatabase(DatabaseName database)
public final void dropDatabase(DatabaseName database)
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.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
databaseAdminClient.dropDatabase(database);
}
Name | Description |
database | DatabaseName Required. The database to be dropped. |
dropDatabase(DropDatabaseRequest request)
public final void dropDatabase(DropDatabaseRequest request)
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.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DropDatabaseRequest request =
DropDatabaseRequest.newBuilder()
.setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.build();
databaseAdminClient.dropDatabase(request);
}
Name | Description |
request | DropDatabaseRequest The request object containing all of the parameters for the API call. |
dropDatabase(String database)
public final void dropDatabase(String database)
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.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString();
databaseAdminClient.dropDatabase(database);
}
Name | Description |
database | String Required. The database to be dropped. |
dropDatabaseCallable()
public final UnaryCallable<DropDatabaseRequest,Empty> dropDatabaseCallable()
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.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DropDatabaseRequest request =
DropDatabaseRequest.newBuilder()
.setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.build();
ApiFuture<Empty> future = databaseAdminClient.dropDatabaseCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
UnaryCallable<DropDatabaseRequest,Empty> |
getBackup(BackupName name)
public final Backup getBackup(BackupName name)
Gets metadata on a pending or completed Backup.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
BackupName name = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
Backup response = databaseAdminClient.getBackup(name);
}
Name | Description |
name | BackupName Required. Name of the backup. Values are of the form
|
Type | Description |
Backup |
getBackup(GetBackupRequest request)
public final Backup getBackup(GetBackupRequest request)
Gets metadata on a pending or completed Backup.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
GetBackupRequest request =
GetBackupRequest.newBuilder()
.setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.build();
Backup response = databaseAdminClient.getBackup(request);
}
Name | Description |
request | GetBackupRequest The request object containing all of the parameters for the API call. |
Type | Description |
Backup |
getBackup(String name)
public final Backup getBackup(String name)
Gets metadata on a pending or completed Backup.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String name = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
Backup response = databaseAdminClient.getBackup(name);
}
Name | Description |
name | String Required. Name of the backup. Values are of the form
|
Type | Description |
Backup |
getBackupCallable()
public final UnaryCallable<GetBackupRequest,Backup> getBackupCallable()
Gets metadata on a pending or completed Backup.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
GetBackupRequest request =
GetBackupRequest.newBuilder()
.setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.build();
ApiFuture<Backup> future = databaseAdminClient.getBackupCallable().futureCall(request);
// Do something.
Backup response = future.get();
}
Type | Description |
UnaryCallable<GetBackupRequest,Backup> |
getDatabase(DatabaseName name)
public final Database getDatabase(DatabaseName name)
Gets the state of a Cloud Spanner database.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DatabaseName name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
Database response = databaseAdminClient.getDatabase(name);
}
Name | Description |
name | DatabaseName Required. The name of the requested database. Values are of the form
|
Type | Description |
Database |
getDatabase(GetDatabaseRequest request)
public final Database getDatabase(GetDatabaseRequest request)
Gets the state of a Cloud Spanner database.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
GetDatabaseRequest request =
GetDatabaseRequest.newBuilder()
.setName(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.build();
Database response = databaseAdminClient.getDatabase(request);
}
Name | Description |
request | GetDatabaseRequest The request object containing all of the parameters for the API call. |
Type | Description |
Database |
getDatabase(String name)
public final Database getDatabase(String name)
Gets the state of a Cloud Spanner database.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String name = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString();
Database response = databaseAdminClient.getDatabase(name);
}
Name | Description |
name | String Required. The name of the requested database. Values are of the form
|
Type | Description |
Database |
getDatabaseCallable()
public final UnaryCallable<GetDatabaseRequest,Database> getDatabaseCallable()
Gets the state of a Cloud Spanner database.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
GetDatabaseRequest request =
GetDatabaseRequest.newBuilder()
.setName(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.build();
ApiFuture<Database> future = databaseAdminClient.getDatabaseCallable().futureCall(request);
// Do something.
Database response = future.get();
}
Type | Description |
UnaryCallable<GetDatabaseRequest,Database> |
getDatabaseDdl(DatabaseName database)
public final GetDatabaseDdlResponse getDatabaseDdl(DatabaseName database)
Returns the schema of a Cloud Spanner database as a list of formatted DDL statements. This method does not show pending schema updates, those may be queried using the Operations API.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
GetDatabaseDdlResponse response = databaseAdminClient.getDatabaseDdl(database);
}
Name | Description |
database | DatabaseName Required. The database whose schema we wish to get. Values are of the form
|
Type | Description |
GetDatabaseDdlResponse |
getDatabaseDdl(GetDatabaseDdlRequest request)
public final GetDatabaseDdlResponse getDatabaseDdl(GetDatabaseDdlRequest request)
Returns the schema of a Cloud Spanner database as a list of formatted DDL statements. This method does not show pending schema updates, those may be queried using the Operations API.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
GetDatabaseDdlRequest request =
GetDatabaseDdlRequest.newBuilder()
.setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.build();
GetDatabaseDdlResponse response = databaseAdminClient.getDatabaseDdl(request);
}
Name | Description |
request | GetDatabaseDdlRequest The request object containing all of the parameters for the API call. |
Type | Description |
GetDatabaseDdlResponse |
getDatabaseDdl(String database)
public final GetDatabaseDdlResponse getDatabaseDdl(String database)
Returns the schema of a Cloud Spanner database as a list of formatted DDL statements. This method does not show pending schema updates, those may be queried using the Operations API.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString();
GetDatabaseDdlResponse response = databaseAdminClient.getDatabaseDdl(database);
}
Name | Description |
database | String Required. The database whose schema we wish to get. Values are of the form
|
Type | Description |
GetDatabaseDdlResponse |
getDatabaseDdlCallable()
public final UnaryCallable<GetDatabaseDdlRequest,GetDatabaseDdlResponse> getDatabaseDdlCallable()
Returns the schema of a Cloud Spanner database as a list of formatted DDL statements. This method does not show pending schema updates, those may be queried using the Operations API.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
GetDatabaseDdlRequest request =
GetDatabaseDdlRequest.newBuilder()
.setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.build();
ApiFuture
Type | Description |
UnaryCallable<GetDatabaseDdlRequest,GetDatabaseDdlResponse> |
getIamPolicy(ResourceName resource)
public final Policy getIamPolicy(ResourceName resource)
Gets the access control policy for a database or backup resource. Returns an empty policy if a database or backup exists but does not have a policy set.
Authorization requires spanner.databases.getIamPolicy
permission on
resource. For backups, authorization requires
spanner.backups.getIamPolicy
permission on
resource.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ResourceName resource = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
Policy response = databaseAdminClient.getIamPolicy(resource);
}
Name | Description |
resource | com.google.api.resourcenames.ResourceName REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. |
Type | Description |
com.google.iam.v1.Policy |
getIamPolicy(GetIamPolicyRequest request)
public final Policy getIamPolicy(GetIamPolicyRequest request)
Gets the access control policy for a database or backup resource. Returns an empty policy if a database or backup exists but does not have a policy set.
Authorization requires spanner.databases.getIamPolicy
permission on
resource. For backups, authorization requires
spanner.backups.getIamPolicy
permission on
resource.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
Policy response = databaseAdminClient.getIamPolicy(request);
}
Name | Description |
request | com.google.iam.v1.GetIamPolicyRequest The request object containing all of the parameters for the API call. |
Type | Description |
com.google.iam.v1.Policy |
getIamPolicy(String resource)
public final Policy getIamPolicy(String resource)
Gets the access control policy for a database or backup resource. Returns an empty policy if a database or backup exists but does not have a policy set.
Authorization requires spanner.databases.getIamPolicy
permission on
resource. For backups, authorization requires
spanner.backups.getIamPolicy
permission on
resource.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String resource = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
Policy response = databaseAdminClient.getIamPolicy(resource);
}
Name | Description |
resource | String REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. |
Type | Description |
com.google.iam.v1.Policy |
getIamPolicyCallable()
public final UnaryCallable<GetIamPolicyRequest,Policy> getIamPolicyCallable()
Gets the access control policy for a database or backup resource. Returns an empty policy if a database or backup exists but does not have a policy set.
Authorization requires spanner.databases.getIamPolicy
permission on
resource. For backups, authorization requires
spanner.backups.getIamPolicy
permission on
resource.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
ApiFuture<Policy> future = databaseAdminClient.getIamPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
Type | Description |
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> |
getOperationsClient()
public final OperationsClient getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.
Type | Description |
OperationsClient |
getSettings()
public final DatabaseAdminSettings getSettings()
Type | Description |
DatabaseAdminSettings |
getStub()
public DatabaseAdminStub getStub()
Type | Description |
DatabaseAdminStub |
isShutdown()
public boolean isShutdown()
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Type | Description |
boolean |
listBackupOperations(InstanceName parent)
public final DatabaseAdminClient.ListBackupOperationsPagedResponse listBackupOperations(InstanceName parent)
Lists the backup long-running operations in the given instance.
A backup operation has a name of the form
projects/<project>/instances/<instance>/backups/<backup>/operations/<operation>
.
The long-running operation metadata field type
metadata.type_url
describes the type of the metadata. Operations returned include those that
have completed/failed/canceled within the last 7 days, and pending operations. Operations
returned are ordered by operation.metadata.value.progress.start_time
in descending order
starting from the most recently started operation.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
for (Operation element : databaseAdminClient.listBackupOperations(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | InstanceName Required. The instance of the backup operations. Values are of the form
|
Type | Description |
DatabaseAdminClient.ListBackupOperationsPagedResponse |
listBackupOperations(ListBackupOperationsRequest request)
public final DatabaseAdminClient.ListBackupOperationsPagedResponse listBackupOperations(ListBackupOperationsRequest request)
Lists the backup long-running operations in the given instance.
A backup operation has a name of the form
projects/<project>/instances/<instance>/backups/<backup>/operations/<operation>
.
The long-running operation metadata field type
metadata.type_url
describes the type of the metadata. Operations returned include those that
have completed/failed/canceled within the last 7 days, and pending operations. Operations
returned are ordered by operation.metadata.value.progress.start_time
in descending order
starting from the most recently started operation.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListBackupOperationsRequest request =
ListBackupOperationsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Operation element : databaseAdminClient.listBackupOperations(request).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
request | ListBackupOperationsRequest The request object containing all of the parameters for the API call. |
Type | Description |
DatabaseAdminClient.ListBackupOperationsPagedResponse |
listBackupOperations(String parent)
public final DatabaseAdminClient.ListBackupOperationsPagedResponse listBackupOperations(String parent)
Lists the backup long-running operations in the given instance.
A backup operation has a name of the form
projects/<project>/instances/<instance>/backups/<backup>/operations/<operation>
.
The long-running operation metadata field type
metadata.type_url
describes the type of the metadata. Operations returned include those that
have completed/failed/canceled within the last 7 days, and pending operations. Operations
returned are ordered by operation.metadata.value.progress.start_time
in descending order
starting from the most recently started operation.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
for (Operation element : databaseAdminClient.listBackupOperations(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Required. The instance of the backup operations. Values are of the form
|
Type | Description |
DatabaseAdminClient.ListBackupOperationsPagedResponse |
listBackupOperationsCallable()
public final UnaryCallable<ListBackupOperationsRequest,ListBackupOperationsResponse> listBackupOperationsCallable()
Lists the backup long-running operations in the given instance.
A backup operation has a name of the form
projects/<project>/instances/<instance>/backups/<backup>/operations/<operation>
.
The long-running operation metadata field type
metadata.type_url
describes the type of the metadata. Operations returned include those that
have completed/failed/canceled within the last 7 days, and pending operations. Operations
returned are ordered by operation.metadata.value.progress.start_time
in descending order
starting from the most recently started operation.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListBackupOperationsRequest request =
ListBackupOperationsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListBackupOperationsResponse response =
databaseAdminClient.listBackupOperationsCallable().call(request);
for (Operation element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListBackupOperationsRequest,ListBackupOperationsResponse> |
listBackupOperationsPagedCallable()
public final UnaryCallable<ListBackupOperationsRequest,DatabaseAdminClient.ListBackupOperationsPagedResponse> listBackupOperationsPagedCallable()
Lists the backup long-running operations in the given instance.
A backup operation has a name of the form
projects/<project>/instances/<instance>/backups/<backup>/operations/<operation>
.
The long-running operation metadata field type
metadata.type_url
describes the type of the metadata. Operations returned include those that
have completed/failed/canceled within the last 7 days, and pending operations. Operations
returned are ordered by operation.metadata.value.progress.start_time
in descending order
starting from the most recently started operation.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListBackupOperationsRequest request =
ListBackupOperationsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Operation> future =
databaseAdminClient.listBackupOperationsPagedCallable().futureCall(request);
// Do something.
for (Operation element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Type | Description |
UnaryCallable<ListBackupOperationsRequest,ListBackupOperationsPagedResponse> |
listBackups(InstanceName parent)
public final DatabaseAdminClient.ListBackupsPagedResponse listBackups(InstanceName parent)
Lists completed and pending backups. Backups returned are ordered by create_time
in
descending order, starting from the most recent create_time
.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
for (Backup element : databaseAdminClient.listBackups(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | InstanceName Required. The instance to list backups from. Values are of the form
|
Type | Description |
DatabaseAdminClient.ListBackupsPagedResponse |
listBackups(ListBackupsRequest request)
public final DatabaseAdminClient.ListBackupsPagedResponse listBackups(ListBackupsRequest request)
Lists completed and pending backups. Backups returned are ordered by create_time
in
descending order, starting from the most recent create_time
.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListBackupsRequest request =
ListBackupsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Backup element : databaseAdminClient.listBackups(request).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
request | ListBackupsRequest The request object containing all of the parameters for the API call. |
Type | Description |
DatabaseAdminClient.ListBackupsPagedResponse |
listBackups(String parent)
public final DatabaseAdminClient.ListBackupsPagedResponse listBackups(String parent)
Lists completed and pending backups. Backups returned are ordered by create_time
in
descending order, starting from the most recent create_time
.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
for (Backup element : databaseAdminClient.listBackups(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Required. The instance to list backups from. Values are of the form
|
Type | Description |
DatabaseAdminClient.ListBackupsPagedResponse |
listBackupsCallable()
public final UnaryCallable<ListBackupsRequest,ListBackupsResponse> listBackupsCallable()
Lists completed and pending backups. Backups returned are ordered by create_time
in
descending order, starting from the most recent create_time
.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListBackupsRequest request =
ListBackupsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListBackupsResponse response = databaseAdminClient.listBackupsCallable().call(request);
for (Backup element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListBackupsRequest,ListBackupsResponse> |
listBackupsPagedCallable()
public final UnaryCallable<ListBackupsRequest,DatabaseAdminClient.ListBackupsPagedResponse> listBackupsPagedCallable()
Lists completed and pending backups. Backups returned are ordered by create_time
in
descending order, starting from the most recent create_time
.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListBackupsRequest request =
ListBackupsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Backup> future = databaseAdminClient.listBackupsPagedCallable().futureCall(request);
// Do something.
for (Backup element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Type | Description |
UnaryCallable<ListBackupsRequest,ListBackupsPagedResponse> |
listDatabaseOperations(InstanceName parent)
public final DatabaseAdminClient.ListDatabaseOperationsPagedResponse listDatabaseOperations(InstanceName parent)
Lists database longrunning-operations. A database operation has
a name of the form
projects/<project>/instances/<instance>/databases/<database>/operations/<operation>
.
The long-running operation metadata field type
metadata.type_url
describes the type of the metadata. Operations returned include those that
have completed/failed/canceled within the last 7 days, and pending operations.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
for (Operation element : databaseAdminClient.listDatabaseOperations(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | InstanceName Required. The instance of the database operations. Values are of the form
|
Type | Description |
DatabaseAdminClient.ListDatabaseOperationsPagedResponse |
listDatabaseOperations(ListDatabaseOperationsRequest request)
public final DatabaseAdminClient.ListDatabaseOperationsPagedResponse listDatabaseOperations(ListDatabaseOperationsRequest request)
Lists database longrunning-operations. A database operation has
a name of the form
projects/<project>/instances/<instance>/databases/<database>/operations/<operation>
.
The long-running operation metadata field type
metadata.type_url
describes the type of the metadata. Operations returned include those that
have completed/failed/canceled within the last 7 days, and pending operations.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListDatabaseOperationsRequest request =
ListDatabaseOperationsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Operation element : databaseAdminClient.listDatabaseOperations(request).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
request | ListDatabaseOperationsRequest The request object containing all of the parameters for the API call. |
Type | Description |
DatabaseAdminClient.ListDatabaseOperationsPagedResponse |
listDatabaseOperations(String parent)
public final DatabaseAdminClient.ListDatabaseOperationsPagedResponse listDatabaseOperations(String parent)
Lists database longrunning-operations. A database operation has
a name of the form
projects/<project>/instances/<instance>/databases/<database>/operations/<operation>
.
The long-running operation metadata field type
metadata.type_url
describes the type of the metadata. Operations returned include those that
have completed/failed/canceled within the last 7 days, and pending operations.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
for (Operation element : databaseAdminClient.listDatabaseOperations(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Required. The instance of the database operations. Values are of the form
|
Type | Description |
DatabaseAdminClient.ListDatabaseOperationsPagedResponse |
listDatabaseOperationsCallable()
public final UnaryCallable<ListDatabaseOperationsRequest,ListDatabaseOperationsResponse> listDatabaseOperationsCallable()
Lists database longrunning-operations. A database operation has
a name of the form
projects/<project>/instances/<instance>/databases/<database>/operations/<operation>
.
The long-running operation metadata field type
metadata.type_url
describes the type of the metadata. Operations returned include those that
have completed/failed/canceled within the last 7 days, and pending operations.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListDatabaseOperationsRequest request =
ListDatabaseOperationsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListDatabaseOperationsResponse response =
databaseAdminClient.listDatabaseOperationsCallable().call(request);
for (Operation element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListDatabaseOperationsRequest,ListDatabaseOperationsResponse> |
listDatabaseOperationsPagedCallable()
public final UnaryCallable<ListDatabaseOperationsRequest,DatabaseAdminClient.ListDatabaseOperationsPagedResponse> listDatabaseOperationsPagedCallable()
Lists database longrunning-operations. A database operation has
a name of the form
projects/<project>/instances/<instance>/databases/<database>/operations/<operation>
.
The long-running operation metadata field type
metadata.type_url
describes the type of the metadata. Operations returned include those that
have completed/failed/canceled within the last 7 days, and pending operations.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListDatabaseOperationsRequest request =
ListDatabaseOperationsRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setFilter("filter-1274492040")
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Operation> future =
databaseAdminClient.listDatabaseOperationsPagedCallable().futureCall(request);
// Do something.
for (Operation element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Type | Description |
UnaryCallable<ListDatabaseOperationsRequest,ListDatabaseOperationsPagedResponse> |
listDatabases(InstanceName parent)
public final DatabaseAdminClient.ListDatabasesPagedResponse listDatabases(InstanceName parent)
Lists Cloud Spanner databases.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
for (Database element : databaseAdminClient.listDatabases(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | InstanceName Required. The instance whose databases should be listed. Values are of the form
|
Type | Description |
DatabaseAdminClient.ListDatabasesPagedResponse |
listDatabases(ListDatabasesRequest request)
public final DatabaseAdminClient.ListDatabasesPagedResponse listDatabases(ListDatabasesRequest request)
Lists Cloud Spanner databases.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListDatabasesRequest request =
ListDatabasesRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Database element : databaseAdminClient.listDatabases(request).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
request | ListDatabasesRequest The request object containing all of the parameters for the API call. |
Type | Description |
DatabaseAdminClient.ListDatabasesPagedResponse |
listDatabases(String parent)
public final DatabaseAdminClient.ListDatabasesPagedResponse listDatabases(String parent)
Lists Cloud Spanner databases.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
for (Database element : databaseAdminClient.listDatabases(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Required. The instance whose databases should be listed. Values are of the form
|
Type | Description |
DatabaseAdminClient.ListDatabasesPagedResponse |
listDatabasesCallable()
public final UnaryCallable<ListDatabasesRequest,ListDatabasesResponse> listDatabasesCallable()
Lists Cloud Spanner databases.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListDatabasesRequest request =
ListDatabasesRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListDatabasesResponse response = databaseAdminClient.listDatabasesCallable().call(request);
for (Database element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListDatabasesRequest,ListDatabasesResponse> |
listDatabasesPagedCallable()
public final UnaryCallable<ListDatabasesRequest,DatabaseAdminClient.ListDatabasesPagedResponse> listDatabasesPagedCallable()
Lists Cloud Spanner databases.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ListDatabasesRequest request =
ListDatabasesRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Database> future =
databaseAdminClient.listDatabasesPagedCallable().futureCall(request);
// Do something.
for (Database element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
Type | Description |
UnaryCallable<ListDatabasesRequest,ListDatabasesPagedResponse> |
restoreDatabaseAsync(InstanceName parent, String databaseId, BackupName backup)
public final OperationFuture<Database,RestoreDatabaseMetadata> restoreDatabaseAsync(InstanceName parent, String databaseId, BackupName backup)
Create a new database by restoring from a completed backup. The new database must be in the
same project and in an instance with the same instance configuration as the instance containing
the backup. The returned database long-running operation has a
name of the format
projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>
,
and can be used to track the progress of the operation, and to cancel it. The
metadata field type is
RestoreDatabaseMetadata. The
response type is
Database, if successful. Cancelling the returned
operation will stop the restore and delete the database. There can be only one database being
restored into an instance at a time. Once the restore operation completes, a new restore
operation can be initiated, without waiting for the optimize operation associated with the
first restore to complete.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String databaseId = "databaseId1688905718";
BackupName backup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
Database response =
databaseAdminClient.restoreDatabaseAsync(parent, databaseId, backup).get();
}
Name | Description |
parent | InstanceName Required. The name of the instance in which to create the restored database. This
instance must be in the same project and have the same instance configuration as the
instance containing the source backup. Values are of the form
|
databaseId | String Required. The id of the database to create and restore to. This database must
not already exist. The |
backup | BackupName Name of the backup from which to restore. Values are of the form
|
Type | Description |
OperationFuture<Database,RestoreDatabaseMetadata> |
restoreDatabaseAsync(InstanceName parent, String databaseId, String backup)
public final OperationFuture<Database,RestoreDatabaseMetadata> restoreDatabaseAsync(InstanceName parent, String databaseId, String backup)
Create a new database by restoring from a completed backup. The new database must be in the
same project and in an instance with the same instance configuration as the instance containing
the backup. The returned database long-running operation has a
name of the format
projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>
,
and can be used to track the progress of the operation, and to cancel it. The
metadata field type is
RestoreDatabaseMetadata. The
response type is
Database, if successful. Cancelling the returned
operation will stop the restore and delete the database. There can be only one database being
restored into an instance at a time. Once the restore operation completes, a new restore
operation can be initiated, without waiting for the optimize operation associated with the
first restore to complete.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
InstanceName parent = InstanceName.of("[PROJECT]", "[INSTANCE]");
String databaseId = "databaseId1688905718";
String backup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
Database response =
databaseAdminClient.restoreDatabaseAsync(parent, databaseId, backup).get();
}
Name | Description |
parent | InstanceName Required. The name of the instance in which to create the restored database. This
instance must be in the same project and have the same instance configuration as the
instance containing the source backup. Values are of the form
|
databaseId | String Required. The id of the database to create and restore to. This database must
not already exist. The |
backup | String Name of the backup from which to restore. Values are of the form
|
Type | Description |
OperationFuture<Database,RestoreDatabaseMetadata> |
restoreDatabaseAsync(RestoreDatabaseRequest request)
public final OperationFuture<Database,RestoreDatabaseMetadata> restoreDatabaseAsync(RestoreDatabaseRequest request)
Create a new database by restoring from a completed backup. The new database must be in the
same project and in an instance with the same instance configuration as the instance containing
the backup. The returned database long-running operation has a
name of the format
projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>
,
and can be used to track the progress of the operation, and to cancel it. The
metadata field type is
RestoreDatabaseMetadata. The
response type is
Database, if successful. Cancelling the returned
operation will stop the restore and delete the database. There can be only one database being
restored into an instance at a time. Once the restore operation completes, a new restore
operation can be initiated, without waiting for the optimize operation associated with the
first restore to complete.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
RestoreDatabaseRequest request =
RestoreDatabaseRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setDatabaseId("databaseId1688905718")
.setEncryptionConfig(RestoreDatabaseEncryptionConfig.newBuilder().build())
.build();
Database response = databaseAdminClient.restoreDatabaseAsync(request).get();
}
Name | Description |
request | RestoreDatabaseRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Database,RestoreDatabaseMetadata> |
restoreDatabaseAsync(String parent, String databaseId, BackupName backup)
public final OperationFuture<Database,RestoreDatabaseMetadata> restoreDatabaseAsync(String parent, String databaseId, BackupName backup)
Create a new database by restoring from a completed backup. The new database must be in the
same project and in an instance with the same instance configuration as the instance containing
the backup. The returned database long-running operation has a
name of the format
projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>
,
and can be used to track the progress of the operation, and to cancel it. The
metadata field type is
RestoreDatabaseMetadata. The
response type is
Database, if successful. Cancelling the returned
operation will stop the restore and delete the database. There can be only one database being
restored into an instance at a time. Once the restore operation completes, a new restore
operation can be initiated, without waiting for the optimize operation associated with the
first restore to complete.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
String databaseId = "databaseId1688905718";
BackupName backup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
Database response =
databaseAdminClient.restoreDatabaseAsync(parent, databaseId, backup).get();
}
Name | Description |
parent | String Required. The name of the instance in which to create the restored database. This
instance must be in the same project and have the same instance configuration as the
instance containing the source backup. Values are of the form
|
databaseId | String Required. The id of the database to create and restore to. This database must
not already exist. The |
backup | BackupName Name of the backup from which to restore. Values are of the form
|
Type | Description |
OperationFuture<Database,RestoreDatabaseMetadata> |
restoreDatabaseAsync(String parent, String databaseId, String backup)
public final OperationFuture<Database,RestoreDatabaseMetadata> restoreDatabaseAsync(String parent, String databaseId, String backup)
Create a new database by restoring from a completed backup. The new database must be in the
same project and in an instance with the same instance configuration as the instance containing
the backup. The returned database long-running operation has a
name of the format
projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>
,
and can be used to track the progress of the operation, and to cancel it. The
metadata field type is
RestoreDatabaseMetadata. The
response type is
Database, if successful. Cancelling the returned
operation will stop the restore and delete the database. There can be only one database being
restored into an instance at a time. Once the restore operation completes, a new restore
operation can be initiated, without waiting for the optimize operation associated with the
first restore to complete.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String parent = InstanceName.of("[PROJECT]", "[INSTANCE]").toString();
String databaseId = "databaseId1688905718";
String backup = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
Database response =
databaseAdminClient.restoreDatabaseAsync(parent, databaseId, backup).get();
}
Name | Description |
parent | String Required. The name of the instance in which to create the restored database. This
instance must be in the same project and have the same instance configuration as the
instance containing the source backup. Values are of the form
|
databaseId | String Required. The id of the database to create and restore to. This database must
not already exist. The |
backup | String Name of the backup from which to restore. Values are of the form
|
Type | Description |
OperationFuture<Database,RestoreDatabaseMetadata> |
restoreDatabaseCallable()
public final UnaryCallable<RestoreDatabaseRequest,Operation> restoreDatabaseCallable()
Create a new database by restoring from a completed backup. The new database must be in the
same project and in an instance with the same instance configuration as the instance containing
the backup. The returned database long-running operation has a
name of the format
projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>
,
and can be used to track the progress of the operation, and to cancel it. The
metadata field type is
RestoreDatabaseMetadata. The
response type is
Database, if successful. Cancelling the returned
operation will stop the restore and delete the database. There can be only one database being
restored into an instance at a time. Once the restore operation completes, a new restore
operation can be initiated, without waiting for the optimize operation associated with the
first restore to complete.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
RestoreDatabaseRequest request =
RestoreDatabaseRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setDatabaseId("databaseId1688905718")
.setEncryptionConfig(RestoreDatabaseEncryptionConfig.newBuilder().build())
.build();
ApiFuture<Operation> future =
databaseAdminClient.restoreDatabaseCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
Type | Description |
UnaryCallable<RestoreDatabaseRequest,Operation> |
restoreDatabaseOperationCallable()
public final OperationCallable<RestoreDatabaseRequest,Database,RestoreDatabaseMetadata> restoreDatabaseOperationCallable()
Create a new database by restoring from a completed backup. The new database must be in the
same project and in an instance with the same instance configuration as the instance containing
the backup. The returned database long-running operation has a
name of the format
projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id>
,
and can be used to track the progress of the operation, and to cancel it. The
metadata field type is
RestoreDatabaseMetadata. The
response type is
Database, if successful. Cancelling the returned
operation will stop the restore and delete the database. There can be only one database being
restored into an instance at a time. Once the restore operation completes, a new restore
operation can be initiated, without waiting for the optimize operation associated with the
first restore to complete.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
RestoreDatabaseRequest request =
RestoreDatabaseRequest.newBuilder()
.setParent(InstanceName.of("[PROJECT]", "[INSTANCE]").toString())
.setDatabaseId("databaseId1688905718")
.setEncryptionConfig(RestoreDatabaseEncryptionConfig.newBuilder().build())
.build();
OperationFuture
Type | Description |
OperationCallable<RestoreDatabaseRequest,Database,RestoreDatabaseMetadata> |
setIamPolicy(ResourceName resource, Policy policy)
public final Policy setIamPolicy(ResourceName resource, Policy policy)
Sets the access control policy on a database or backup resource. Replaces any existing policy.
Authorization requires spanner.databases.setIamPolicy
permission on
resource. For backups, authorization requires
spanner.backups.setIamPolicy
permission on
resource.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ResourceName resource = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
Policy policy = Policy.newBuilder().build();
Policy response = databaseAdminClient.setIamPolicy(resource, policy);
}
Name | Description |
resource | com.google.api.resourcenames.ResourceName REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. |
policy | com.google.iam.v1.Policy REQUIRED: The complete policy to be applied to the |
Type | Description |
com.google.iam.v1.Policy |
setIamPolicy(SetIamPolicyRequest request)
public final Policy setIamPolicy(SetIamPolicyRequest request)
Sets the access control policy on a database or backup resource. Replaces any existing policy.
Authorization requires spanner.databases.setIamPolicy
permission on
resource. For backups, authorization requires
spanner.backups.setIamPolicy
permission on
resource.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.setPolicy(Policy.newBuilder().build())
.build();
Policy response = databaseAdminClient.setIamPolicy(request);
}
Name | Description |
request | com.google.iam.v1.SetIamPolicyRequest The request object containing all of the parameters for the API call. |
Type | Description |
com.google.iam.v1.Policy |
setIamPolicy(String resource, Policy policy)
public final Policy setIamPolicy(String resource, Policy policy)
Sets the access control policy on a database or backup resource. Replaces any existing policy.
Authorization requires spanner.databases.setIamPolicy
permission on
resource. For backups, authorization requires
spanner.backups.setIamPolicy
permission on
resource.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String resource = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
Policy policy = Policy.newBuilder().build();
Policy response = databaseAdminClient.setIamPolicy(resource, policy);
}
Name | Description |
resource | String REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. |
policy | com.google.iam.v1.Policy REQUIRED: The complete policy to be applied to the |
Type | Description |
com.google.iam.v1.Policy |
setIamPolicyCallable()
public final UnaryCallable<SetIamPolicyRequest,Policy> setIamPolicyCallable()
Sets the access control policy on a database or backup resource. Replaces any existing policy.
Authorization requires spanner.databases.setIamPolicy
permission on
resource. For backups, authorization requires
spanner.backups.setIamPolicy
permission on
resource.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
SetIamPolicyRequest request =
SetIamPolicyRequest.newBuilder()
.setResource(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.setPolicy(Policy.newBuilder().build())
.build();
ApiFuture<Policy> future = databaseAdminClient.setIamPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
Type | Description |
UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()
testIamPermissions(ResourceName resource, List<String> permissions)
public final TestIamPermissionsResponse testIamPermissions(ResourceName resource, List<String> permissions)
Returns permissions that the caller has on the specified database or backup resource.
Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND
error if the user has spanner.databases.list
permission on the containing Cloud Spanner
instance. Otherwise returns an empty set of permissions. Calling this method on a backup that
does not exist will result in a NOT_FOUND error if the user has spanner.backups.list
permission on the containing instance.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
ResourceName resource = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsResponse response =
databaseAdminClient.testIamPermissions(resource, permissions);
}
Name | Description |
resource | com.google.api.resourcenames.ResourceName REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. |
permissions | List<String> The set of permissions to check for the |
Type | Description |
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(TestIamPermissionsRequest request)
public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request)
Returns permissions that the caller has on the specified database or backup resource.
Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND
error if the user has spanner.databases.list
permission on the containing Cloud Spanner
instance. Otherwise returns an empty set of permissions. Calling this method on a backup that
does not exist will result in a NOT_FOUND error if the user has spanner.backups.list
permission on the containing instance.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.addAllPermissions(new ArrayList<String>())
.build();
TestIamPermissionsResponse response = databaseAdminClient.testIamPermissions(request);
}
Name | Description |
request | com.google.iam.v1.TestIamPermissionsRequest The request object containing all of the parameters for the API call. |
Type | Description |
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(String resource, List<String> permissions)
public final TestIamPermissionsResponse testIamPermissions(String resource, List<String> permissions)
Returns permissions that the caller has on the specified database or backup resource.
Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND
error if the user has spanner.databases.list
permission on the containing Cloud Spanner
instance. Otherwise returns an empty set of permissions. Calling this method on a backup that
does not exist will result in a NOT_FOUND error if the user has spanner.backups.list
permission on the containing instance.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String resource = BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString();
List<String> permissions = new ArrayList<>();
TestIamPermissionsResponse response =
databaseAdminClient.testIamPermissions(resource, permissions);
}
Name | Description |
resource | String REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. |
permissions | List<String> The set of permissions to check for the |
Type | Description |
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissionsCallable()
public final UnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse> testIamPermissionsCallable()
Returns permissions that the caller has on the specified database or backup resource.
Attempting this RPC on a non-existent Cloud Spanner database will result in a NOT_FOUND
error if the user has spanner.databases.list
permission on the containing Cloud Spanner
instance. Otherwise returns an empty set of permissions. Calling this method on a backup that
does not exist will result in a NOT_FOUND error if the user has spanner.backups.list
permission on the containing instance.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
TestIamPermissionsRequest request =
TestIamPermissionsRequest.newBuilder()
.setResource(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString())
.addAllPermissions(new ArrayList<String>())
.build();
ApiFuture
Type | Description |
UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> |
updateBackup(Backup backup, FieldMask updateMask)
public final Backup updateBackup(Backup backup, FieldMask updateMask)
Updates a pending or completed Backup.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
Backup backup = Backup.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Backup response = databaseAdminClient.updateBackup(backup, updateMask);
}
Name | Description |
backup | Backup Required. The backup to update. |
updateMask | FieldMask Required. A mask specifying which fields (e.g. |
Type | Description |
Backup |
updateBackup(UpdateBackupRequest request)
public final Backup updateBackup(UpdateBackupRequest request)
Updates a pending or completed Backup.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
UpdateBackupRequest request =
UpdateBackupRequest.newBuilder()
.setBackup(Backup.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Backup response = databaseAdminClient.updateBackup(request);
}
Name | Description |
request | UpdateBackupRequest The request object containing all of the parameters for the API call. |
Type | Description |
Backup |
updateBackupCallable()
public final UnaryCallable<UpdateBackupRequest,Backup> updateBackupCallable()
Updates a pending or completed Backup.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
UpdateBackupRequest request =
UpdateBackupRequest.newBuilder()
.setBackup(Backup.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Backup> future = databaseAdminClient.updateBackupCallable().futureCall(request);
// Do something.
Backup response = future.get();
}
Type | Description |
UnaryCallable<UpdateBackupRequest,Backup> |
updateDatabaseDdlAsync(DatabaseName database, List<String> statements)
public final OperationFuture<Empty,UpdateDatabaseDdlMetadata> updateDatabaseDdlAsync(DatabaseName database, List<String> statements)
Updates the schema of a Cloud Spanner database by creating/altering/dropping tables, columns,
indexes, etc. The returned long-running operation will have a
name of the format <database_name>/operations/<operation_id>
and can be used to
track execution of the schema change(s). The metadata
field type is
UpdateDatabaseDdlMetadata. The
operation has no response.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
DatabaseName database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
List<String> statements = new ArrayList<>();
databaseAdminClient.updateDatabaseDdlAsync(database, statements).get();
}
Name | Description |
database | DatabaseName Required. The database to update. |
statements | List<String> Required. DDL statements to be applied to the database. |
Type | Description |
OperationFuture<Empty,UpdateDatabaseDdlMetadata> |
updateDatabaseDdlAsync(UpdateDatabaseDdlRequest request)
public final OperationFuture<Empty,UpdateDatabaseDdlMetadata> updateDatabaseDdlAsync(UpdateDatabaseDdlRequest request)
Updates the schema of a Cloud Spanner database by creating/altering/dropping tables, columns,
indexes, etc. The returned long-running operation will have a
name of the format <database_name>/operations/<operation_id>
and can be used to
track execution of the schema change(s). The metadata
field type is
UpdateDatabaseDdlMetadata. The
operation has no response.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
UpdateDatabaseDdlRequest request =
UpdateDatabaseDdlRequest.newBuilder()
.setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.addAllStatements(new ArrayList<String>())
.setOperationId("operationId129704162")
.build();
databaseAdminClient.updateDatabaseDdlAsync(request).get();
}
Name | Description |
request | UpdateDatabaseDdlRequest The request object containing all of the parameters for the API call. |
Type | Description |
OperationFuture<Empty,UpdateDatabaseDdlMetadata> |
updateDatabaseDdlAsync(String database, List<String> statements)
public final OperationFuture<Empty,UpdateDatabaseDdlMetadata> updateDatabaseDdlAsync(String database, List<String> statements)
Updates the schema of a Cloud Spanner database by creating/altering/dropping tables, columns,
indexes, etc. The returned long-running operation will have a
name of the format <database_name>/operations/<operation_id>
and can be used to
track execution of the schema change(s). The metadata
field type is
UpdateDatabaseDdlMetadata. The
operation has no response.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
String database = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString();
List<String> statements = new ArrayList<>();
databaseAdminClient.updateDatabaseDdlAsync(database, statements).get();
}
Name | Description |
database | String Required. The database to update. |
statements | List<String> Required. DDL statements to be applied to the database. |
Type | Description |
OperationFuture<Empty,UpdateDatabaseDdlMetadata> |
updateDatabaseDdlCallable()
public final UnaryCallable<UpdateDatabaseDdlRequest,Operation> updateDatabaseDdlCallable()
Updates the schema of a Cloud Spanner database by creating/altering/dropping tables, columns,
indexes, etc. The returned long-running operation will have a
name of the format <database_name>/operations/<operation_id>
and can be used to
track execution of the schema change(s). The metadata
field type is
UpdateDatabaseDdlMetadata. The
operation has no response.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
UpdateDatabaseDdlRequest request =
UpdateDatabaseDdlRequest.newBuilder()
.setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.addAllStatements(new ArrayList<String>())
.setOperationId("operationId129704162")
.build();
ApiFuture<Operation> future =
databaseAdminClient.updateDatabaseDdlCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
UnaryCallable<UpdateDatabaseDdlRequest,Operation> |
updateDatabaseDdlOperationCallable()
public final OperationCallable<UpdateDatabaseDdlRequest,Empty,UpdateDatabaseDdlMetadata> updateDatabaseDdlOperationCallable()
Updates the schema of a Cloud Spanner database by creating/altering/dropping tables, columns,
indexes, etc. The returned long-running operation will have a
name of the format <database_name>/operations/<operation_id>
and can be used to
track execution of the schema change(s). The metadata
field type is
UpdateDatabaseDdlMetadata. The
operation has no response.
Sample code:
try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
UpdateDatabaseDdlRequest request =
UpdateDatabaseDdlRequest.newBuilder()
.setDatabase(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
.addAllStatements(new ArrayList<String>())
.setOperationId("operationId129704162")
.build();
OperationFuture
Type | Description |
OperationCallable<UpdateDatabaseDdlRequest,Empty,UpdateDatabaseDdlMetadata> |