Class DatabaseAdminClient (6.51.0)

publicclassDatabaseAdminClientimplementsBackgroundResource

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){DatabaseNamename=DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]");Databaseresponse=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:

  1. 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.
  2. 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.
  3. 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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_libraryDatabaseAdminSettingsdatabaseAdminSettings=DatabaseAdminSettings.newBuilder().setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)).build();DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create(databaseAdminSettings);

To customize the endpoint:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_libraryDatabaseAdminSettingsdatabaseAdminSettings=DatabaseAdminSettings.newBuilder().setEndpoint(myEndpoint).build();DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create(databaseAdminSettings);

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_libraryDatabaseAdminSettingsdatabaseAdminSettings=DatabaseAdminSettings.newHttpJsonBuilder().build();DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create(databaseAdminSettings);

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > DatabaseAdminClient

Static Methods

create()

publicstaticfinalDatabaseAdminClientcreate()

Constructs an instance of DatabaseAdminClient with default settings.

Returns
TypeDescription
DatabaseAdminClient
Exceptions
TypeDescription
IOException

create(DatabaseAdminSettings settings)

publicstaticfinalDatabaseAdminClientcreate(DatabaseAdminSettingssettings)

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.

Parameter
NameDescription
settingsDatabaseAdminSettings
Returns
TypeDescription
DatabaseAdminClient
Exceptions
TypeDescription
IOException

create(DatabaseAdminStub stub)

publicstaticfinalDatabaseAdminClientcreate(DatabaseAdminStubstub)

Constructs an instance of DatabaseAdminClient, using the given stub for making calls. This is for advanced usage - prefer using create(DatabaseAdminSettings).

Parameter
NameDescription
stubDatabaseAdminStub
Returns
TypeDescription
DatabaseAdminClient

Constructors

DatabaseAdminClient(DatabaseAdminSettings settings)

protectedDatabaseAdminClient(DatabaseAdminSettingssettings)

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.

Parameter
NameDescription
settingsDatabaseAdminSettings

DatabaseAdminClient(DatabaseAdminStub stub)

protectedDatabaseAdminClient(DatabaseAdminStubstub)
Parameter
NameDescription
stubDatabaseAdminStub

Methods

awaitTermination(long duration, TimeUnit unit)

publicbooleanawaitTermination(longduration,TimeUnitunit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
InterruptedException

close()

publicfinalvoidclose()

copyBackupAsync(CopyBackupRequest request)

publicfinalOperationFuture<Backup,CopyBackupMetadata>copyBackupAsync(CopyBackupRequestrequest)

Starts copying a 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 copying of the backup. The operation is associated with the destination backup. The metadata field type is CopyBackupMetadata. The response field type is Backup, if successful. Cancelling the returned operation will stop the copying and delete the backup. Concurrent CopyBackup requests can run on the same source backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){CopyBackupRequestrequest=CopyBackupRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setBackupId("backupId2121930365").setSourceBackup(BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString()).setExpireTime(Timestamp.newBuilder().build()).setEncryptionConfig(CopyBackupEncryptionConfig.newBuilder().build()).build();Backupresponse=databaseAdminClient.copyBackupAsync(request).get();}
Parameter
NameDescription
requestCopyBackupRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Backup,CopyBackupMetadata>

copyBackupAsync(InstanceName parent, String backupId, BackupName sourceBackup, Timestamp expireTime)

publicfinalOperationFuture<Backup,CopyBackupMetadata>copyBackupAsync(InstanceNameparent,StringbackupId,BackupNamesourceBackup,TimestampexpireTime)

Starts copying a 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 copying of the backup. The operation is associated with the destination backup. The metadata field type is CopyBackupMetadata. The response field type is Backup, if successful. Cancelling the returned operation will stop the copying and delete the backup. Concurrent CopyBackup requests can run on the same source backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){InstanceNameparent=InstanceName.of("[PROJECT]","[INSTANCE]");StringbackupId="backupId2121930365";BackupNamesourceBackup=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]");TimestampexpireTime=Timestamp.newBuilder().build();Backupresponse=databaseAdminClient.copyBackupAsync(parent,backupId,sourceBackup,expireTime).get();}
Parameters
NameDescription
parentInstanceName

Required. The name of the destination instance that will contain the backup copy. Values are of the form: projects/<project>/instances/<instance>.

backupIdString

Required. The id of the backup copy. The backup_id appended to parent forms the full backup_uri of the form projects/<project>/instances/<instance>/backups/<backup>.

sourceBackupBackupName

Required. The source backup to be copied. The source backup needs to be in READY state for it to be copied. Once CopyBackup is in progress, the source backup cannot be deleted or cleaned up on expiration until CopyBackup is finished. Values are of the form: projects/<project>/instances/<instance>/backups/<backup>.

expireTimeTimestamp

Required. The expiration time of the backup in microsecond granularity. The expiration time must be at least 6 hours and at most 366 days from the create_time of the source backup. Once the expire_time has passed, the backup is eligible to be automatically deleted by Cloud Spanner to free the resources used by the backup.

Returns
TypeDescription
OperationFuture<Backup,CopyBackupMetadata>

copyBackupAsync(InstanceName parent, String backupId, String sourceBackup, Timestamp expireTime)

publicfinalOperationFuture<Backup,CopyBackupMetadata>copyBackupAsync(InstanceNameparent,StringbackupId,StringsourceBackup,TimestampexpireTime)

Starts copying a 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 copying of the backup. The operation is associated with the destination backup. The metadata field type is CopyBackupMetadata. The response field type is Backup, if successful. Cancelling the returned operation will stop the copying and delete the backup. Concurrent CopyBackup requests can run on the same source backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){InstanceNameparent=InstanceName.of("[PROJECT]","[INSTANCE]");StringbackupId="backupId2121930365";StringsourceBackup=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString();TimestampexpireTime=Timestamp.newBuilder().build();Backupresponse=databaseAdminClient.copyBackupAsync(parent,backupId,sourceBackup,expireTime).get();}
Parameters
NameDescription
parentInstanceName

Required. The name of the destination instance that will contain the backup copy. Values are of the form: projects/<project>/instances/<instance>.

backupIdString

Required. The id of the backup copy. The backup_id appended to parent forms the full backup_uri of the form projects/<project>/instances/<instance>/backups/<backup>.

sourceBackupString

Required. The source backup to be copied. The source backup needs to be in READY state for it to be copied. Once CopyBackup is in progress, the source backup cannot be deleted or cleaned up on expiration until CopyBackup is finished. Values are of the form: projects/<project>/instances/<instance>/backups/<backup>.

expireTimeTimestamp

Required. The expiration time of the backup in microsecond granularity. The expiration time must be at least 6 hours and at most 366 days from the create_time of the source backup. Once the expire_time has passed, the backup is eligible to be automatically deleted by Cloud Spanner to free the resources used by the backup.

Returns
TypeDescription
OperationFuture<Backup,CopyBackupMetadata>

copyBackupAsync(String parent, String backupId, BackupName sourceBackup, Timestamp expireTime)

publicfinalOperationFuture<Backup,CopyBackupMetadata>copyBackupAsync(Stringparent,StringbackupId,BackupNamesourceBackup,TimestampexpireTime)

Starts copying a 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 copying of the backup. The operation is associated with the destination backup. The metadata field type is CopyBackupMetadata. The response field type is Backup, if successful. Cancelling the returned operation will stop the copying and delete the backup. Concurrent CopyBackup requests can run on the same source backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringparent=InstanceName.of("[PROJECT]","[INSTANCE]").toString();StringbackupId="backupId2121930365";BackupNamesourceBackup=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]");TimestampexpireTime=Timestamp.newBuilder().build();Backupresponse=databaseAdminClient.copyBackupAsync(parent,backupId,sourceBackup,expireTime).get();}
Parameters
NameDescription
parentString

Required. The name of the destination instance that will contain the backup copy. Values are of the form: projects/<project>/instances/<instance>.

backupIdString

Required. The id of the backup copy. The backup_id appended to parent forms the full backup_uri of the form projects/<project>/instances/<instance>/backups/<backup>.

sourceBackupBackupName

Required. The source backup to be copied. The source backup needs to be in READY state for it to be copied. Once CopyBackup is in progress, the source backup cannot be deleted or cleaned up on expiration until CopyBackup is finished. Values are of the form: projects/<project>/instances/<instance>/backups/<backup>.

expireTimeTimestamp

Required. The expiration time of the backup in microsecond granularity. The expiration time must be at least 6 hours and at most 366 days from the create_time of the source backup. Once the expire_time has passed, the backup is eligible to be automatically deleted by Cloud Spanner to free the resources used by the backup.

Returns
TypeDescription
OperationFuture<Backup,CopyBackupMetadata>

copyBackupAsync(String parent, String backupId, String sourceBackup, Timestamp expireTime)

publicfinalOperationFuture<Backup,CopyBackupMetadata>copyBackupAsync(Stringparent,StringbackupId,StringsourceBackup,TimestampexpireTime)

Starts copying a 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 copying of the backup. The operation is associated with the destination backup. The metadata field type is CopyBackupMetadata. The response field type is Backup, if successful. Cancelling the returned operation will stop the copying and delete the backup. Concurrent CopyBackup requests can run on the same source backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringparent=InstanceName.of("[PROJECT]","[INSTANCE]").toString();StringbackupId="backupId2121930365";StringsourceBackup=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString();TimestampexpireTime=Timestamp.newBuilder().build();Backupresponse=databaseAdminClient.copyBackupAsync(parent,backupId,sourceBackup,expireTime).get();}
Parameters
NameDescription
parentString

Required. The name of the destination instance that will contain the backup copy. Values are of the form: projects/<project>/instances/<instance>.

backupIdString

Required. The id of the backup copy. The backup_id appended to parent forms the full backup_uri of the form projects/<project>/instances/<instance>/backups/<backup>.

sourceBackupString

Required. The source backup to be copied. The source backup needs to be in READY state for it to be copied. Once CopyBackup is in progress, the source backup cannot be deleted or cleaned up on expiration until CopyBackup is finished. Values are of the form: projects/<project>/instances/<instance>/backups/<backup>.

expireTimeTimestamp

Required. The expiration time of the backup in microsecond granularity. The expiration time must be at least 6 hours and at most 366 days from the create_time of the source backup. Once the expire_time has passed, the backup is eligible to be automatically deleted by Cloud Spanner to free the resources used by the backup.

Returns
TypeDescription
OperationFuture<Backup,CopyBackupMetadata>

copyBackupCallable()

publicfinalUnaryCallable<CopyBackupRequest,Operation>copyBackupCallable()

Starts copying a 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 copying of the backup. The operation is associated with the destination backup. The metadata field type is CopyBackupMetadata. The response field type is Backup, if successful. Cancelling the returned operation will stop the copying and delete the backup. Concurrent CopyBackup requests can run on the same source backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){CopyBackupRequestrequest=CopyBackupRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setBackupId("backupId2121930365").setSourceBackup(BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString()).setExpireTime(Timestamp.newBuilder().build()).setEncryptionConfig(CopyBackupEncryptionConfig.newBuilder().build()).build();ApiFuture<Operation>future=databaseAdminClient.copyBackupCallable().futureCall(request);// Do something.Operationresponse=future.get();}
Returns
TypeDescription
UnaryCallable<CopyBackupRequest,Operation>

copyBackupOperationCallable()

publicfinalOperationCallable<CopyBackupRequest,Backup,CopyBackupMetadata>copyBackupOperationCallable()

Starts copying a 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 copying of the backup. The operation is associated with the destination backup. The metadata field type is CopyBackupMetadata. The response field type is Backup, if successful. Cancelling the returned operation will stop the copying and delete the backup. Concurrent CopyBackup requests can run on the same source backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){CopyBackupRequestrequest=CopyBackupRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setBackupId("backupId2121930365").setSourceBackup(BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString()).setExpireTime(Timestamp.newBuilder().build()).setEncryptionConfig(CopyBackupEncryptionConfig.newBuilder().build()).build();OperationFuture<Backup,CopyBackupMetadata>future=databaseAdminClient.copyBackupOperationCallable().futureCall(request);// Do something.Backupresponse=future.get();}
Returns
TypeDescription
OperationCallable<CopyBackupRequest,Backup,CopyBackupMetadata>

createBackupAsync(CreateBackupRequest request)

publicfinalOperationFuture<Backup,CreateBackupMetadata>createBackupAsync(CreateBackupRequestrequest)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){CreateBackupRequestrequest=CreateBackupRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setBackupId("backupId2121930365").setBackup(Backup.newBuilder().build()).setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build()).build();Backupresponse=databaseAdminClient.createBackupAsync(request).get();}
Parameter
NameDescription
requestCreateBackupRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Backup,CreateBackupMetadata>

createBackupAsync(InstanceName parent, Backup backup, String backupId)

publicfinalOperationFuture<Backup,CreateBackupMetadata>createBackupAsync(InstanceNameparent,Backupbackup,StringbackupId)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){InstanceNameparent=InstanceName.of("[PROJECT]","[INSTANCE]");Backupbackup=Backup.newBuilder().build();StringbackupId="backupId2121930365";Backupresponse=databaseAdminClient.createBackupAsync(parent,backup,backupId).get();}
Parameters
NameDescription
parentInstanceName

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 projects/<project>/instances/<instance>.

backupBackup

Required. The backup to create.

backupIdString

Required. The id of the backup to be created. The backup_id appended to parent forms the full backup name of the form projects/<project>/instances/<instance>/backups/<backup_id>.

Returns
TypeDescription
OperationFuture<Backup,CreateBackupMetadata>

createBackupAsync(String parent, Backup backup, String backupId)

publicfinalOperationFuture<Backup,CreateBackupMetadata>createBackupAsync(Stringparent,Backupbackup,StringbackupId)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringparent=InstanceName.of("[PROJECT]","[INSTANCE]").toString();Backupbackup=Backup.newBuilder().build();StringbackupId="backupId2121930365";Backupresponse=databaseAdminClient.createBackupAsync(parent,backup,backupId).get();}
Parameters
NameDescription
parentString

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 projects/<project>/instances/<instance>.

backupBackup

Required. The backup to create.

backupIdString

Required. The id of the backup to be created. The backup_id appended to parent forms the full backup name of the form projects/<project>/instances/<instance>/backups/<backup_id>.

Returns
TypeDescription
OperationFuture<Backup,CreateBackupMetadata>

createBackupCallable()

publicfinalUnaryCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){CreateBackupRequestrequest=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.Operationresponse=future.get();}
Returns
TypeDescription
UnaryCallable<CreateBackupRequest,Operation>

createBackupOperationCallable()

publicfinalOperationCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){CreateBackupRequestrequest=CreateBackupRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setBackupId("backupId2121930365").setBackup(Backup.newBuilder().build()).setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build()).build();OperationFuture<Backup,CreateBackupMetadata>future=databaseAdminClient.createBackupOperationCallable().futureCall(request);// Do something.Backupresponse=future.get();}
Returns
TypeDescription
OperationCallable<CreateBackupRequest,Backup,CreateBackupMetadata>

createDatabaseAsync(CreateDatabaseRequest request)

publicfinalOperationFuture<Database,CreateDatabaseMetadata>createDatabaseAsync(CreateDatabaseRequestrequest)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){CreateDatabaseRequestrequest=CreateDatabaseRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setCreateStatement("createStatement744686547").addAllExtraStatements(newArrayList<String>()).setEncryptionConfig(EncryptionConfig.newBuilder().build()).setDatabaseDialect(DatabaseDialect.forNumber(0)).build();Databaseresponse=databaseAdminClient.createDatabaseAsync(request).get();}
Parameter
NameDescription
requestCreateDatabaseRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Database,CreateDatabaseMetadata>

createDatabaseAsync(InstanceName parent, String createStatement)

publicfinalOperationFuture<Database,CreateDatabaseMetadata>createDatabaseAsync(InstanceNameparent,StringcreateStatement)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){InstanceNameparent=InstanceName.of("[PROJECT]","[INSTANCE]");StringcreateStatement="createStatement744686547";Databaseresponse=databaseAdminClient.createDatabaseAsync(parent,createStatement).get();}
Parameters
NameDescription
parentInstanceName

Required. The name of the instance that will serve the new database. Values are of the form projects/<project>/instances/<instance>.

createStatementString

Required. A CREATE DATABASE statement, which specifies the ID of the new database. The database ID must conform to the regular expression a-z*[a-z0-9] and be between 2 and 30 characters in length. If the database ID is a reserved word or if it contains a hyphen, the database ID must be enclosed in backticks (` ``).

Returns
TypeDescription
OperationFuture<Database,CreateDatabaseMetadata>

createDatabaseAsync(String parent, String createStatement)

publicfinalOperationFuture<Database,CreateDatabaseMetadata>createDatabaseAsync(Stringparent,StringcreateStatement)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringparent=InstanceName.of("[PROJECT]","[INSTANCE]").toString();StringcreateStatement="createStatement744686547";Databaseresponse=databaseAdminClient.createDatabaseAsync(parent,createStatement).get();}
Parameters
NameDescription
parentString

Required. The name of the instance that will serve the new database. Values are of the form projects/<project>/instances/<instance>.

createStatementString

Required. A CREATE DATABASE statement, which specifies the ID of the new database. The database ID must conform to the regular expression a-z*[a-z0-9] and be between 2 and 30 characters in length. If the database ID is a reserved word or if it contains a hyphen, the database ID must be enclosed in backticks (` ``).

Returns
TypeDescription
OperationFuture<Database,CreateDatabaseMetadata>

createDatabaseCallable()

publicfinalUnaryCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){CreateDatabaseRequestrequest=CreateDatabaseRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setCreateStatement("createStatement744686547").addAllExtraStatements(newArrayList<String>()).setEncryptionConfig(EncryptionConfig.newBuilder().build()).setDatabaseDialect(DatabaseDialect.forNumber(0)).build();ApiFuture<Operation>future=databaseAdminClient.createDatabaseCallable().futureCall(request);// Do something.Operationresponse=future.get();}
Returns
TypeDescription
UnaryCallable<CreateDatabaseRequest,Operation>

createDatabaseOperationCallable()

publicfinalOperationCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){CreateDatabaseRequestrequest=CreateDatabaseRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setCreateStatement("createStatement744686547").addAllExtraStatements(newArrayList<String>()).setEncryptionConfig(EncryptionConfig.newBuilder().build()).setDatabaseDialect(DatabaseDialect.forNumber(0)).build();OperationFuture<Database,CreateDatabaseMetadata>future=databaseAdminClient.createDatabaseOperationCallable().futureCall(request);// Do something.Databaseresponse=future.get();}
Returns
TypeDescription
OperationCallable<CreateDatabaseRequest,Database,CreateDatabaseMetadata>

deleteBackup(BackupName name)

publicfinalvoiddeleteBackup(BackupNamename)

Deletes a pending or completed Backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){BackupNamename=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]");databaseAdminClient.deleteBackup(name);}
Parameter
NameDescription
nameBackupName

Required. Name of the backup to delete. Values are of the form projects/<project>/instances/<instance>/backups/<backup>.

deleteBackup(DeleteBackupRequest request)

publicfinalvoiddeleteBackup(DeleteBackupRequestrequest)

Deletes a pending or completed Backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){DeleteBackupRequestrequest=DeleteBackupRequest.newBuilder().setName(BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString()).build();databaseAdminClient.deleteBackup(request);}
Parameter
NameDescription
requestDeleteBackupRequest

The request object containing all of the parameters for the API call.

deleteBackup(String name)

publicfinalvoiddeleteBackup(Stringname)

Deletes a pending or completed Backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringname=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString();databaseAdminClient.deleteBackup(name);}
Parameter
NameDescription
nameString

Required. Name of the backup to delete. Values are of the form projects/<project>/instances/<instance>/backups/<backup>.

deleteBackupCallable()

publicfinalUnaryCallable<DeleteBackupRequest,Empty>deleteBackupCallable()

Deletes a pending or completed Backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){DeleteBackupRequestrequest=DeleteBackupRequest.newBuilder().setName(BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString()).build();ApiFuture<Empty>future=databaseAdminClient.deleteBackupCallable().futureCall(request);// Do something.future.get();}
Returns
TypeDescription
UnaryCallable<DeleteBackupRequest,Empty>

dropDatabase(DatabaseName database)

publicfinalvoiddropDatabase(DatabaseNamedatabase)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){DatabaseNamedatabase=DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]");databaseAdminClient.dropDatabase(database);}
Parameter
NameDescription
databaseDatabaseName

Required. The database to be dropped.

dropDatabase(DropDatabaseRequest request)

publicfinalvoiddropDatabase(DropDatabaseRequestrequest)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){DropDatabaseRequestrequest=DropDatabaseRequest.newBuilder().setDatabase(DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]").toString()).build();databaseAdminClient.dropDatabase(request);}
Parameter
NameDescription
requestDropDatabaseRequest

The request object containing all of the parameters for the API call.

dropDatabase(String database)

publicfinalvoiddropDatabase(Stringdatabase)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringdatabase=DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]").toString();databaseAdminClient.dropDatabase(database);}
Parameter
NameDescription
databaseString

Required. The database to be dropped.

dropDatabaseCallable()

publicfinalUnaryCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){DropDatabaseRequestrequest=DropDatabaseRequest.newBuilder().setDatabase(DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]").toString()).build();ApiFuture<Empty>future=databaseAdminClient.dropDatabaseCallable().futureCall(request);// Do something.future.get();}
Returns
TypeDescription
UnaryCallable<DropDatabaseRequest,Empty>

getBackup(BackupName name)

publicfinalBackupgetBackup(BackupNamename)

Gets metadata on a pending or completed Backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){BackupNamename=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]");Backupresponse=databaseAdminClient.getBackup(name);}
Parameter
NameDescription
nameBackupName

Required. Name of the backup. Values are of the form projects/<project>/instances/<instance>/backups/<backup>.

Returns
TypeDescription
Backup

getBackup(GetBackupRequest request)

publicfinalBackupgetBackup(GetBackupRequestrequest)

Gets metadata on a pending or completed Backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){GetBackupRequestrequest=GetBackupRequest.newBuilder().setName(BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString()).build();Backupresponse=databaseAdminClient.getBackup(request);}
Parameter
NameDescription
requestGetBackupRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
Backup

getBackup(String name)

publicfinalBackupgetBackup(Stringname)

Gets metadata on a pending or completed Backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringname=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString();Backupresponse=databaseAdminClient.getBackup(name);}
Parameter
NameDescription
nameString

Required. Name of the backup. Values are of the form projects/<project>/instances/<instance>/backups/<backup>.

Returns
TypeDescription
Backup

getBackupCallable()

publicfinalUnaryCallable<GetBackupRequest,Backup>getBackupCallable()

Gets metadata on a pending or completed Backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){GetBackupRequestrequest=GetBackupRequest.newBuilder().setName(BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString()).build();ApiFuture<Backup>future=databaseAdminClient.getBackupCallable().futureCall(request);// Do something.Backupresponse=future.get();}
Returns
TypeDescription
UnaryCallable<GetBackupRequest,Backup>

getDatabase(DatabaseName name)

publicfinalDatabasegetDatabase(DatabaseNamename)

Gets the state of a Cloud Spanner database.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){DatabaseNamename=DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]");Databaseresponse=databaseAdminClient.getDatabase(name);}
Parameter
NameDescription
nameDatabaseName

Required. The name of the requested database. Values are of the form projects/<project>/instances/<instance>/databases/<database>.

Returns
TypeDescription
Database

getDatabase(GetDatabaseRequest request)

publicfinalDatabasegetDatabase(GetDatabaseRequestrequest)

Gets the state of a Cloud Spanner database.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){GetDatabaseRequestrequest=GetDatabaseRequest.newBuilder().setName(DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]").toString()).build();Databaseresponse=databaseAdminClient.getDatabase(request);}
Parameter
NameDescription
requestGetDatabaseRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
Database

getDatabase(String name)

publicfinalDatabasegetDatabase(Stringname)

Gets the state of a Cloud Spanner database.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringname=DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]").toString();Databaseresponse=databaseAdminClient.getDatabase(name);}
Parameter
NameDescription
nameString

Required. The name of the requested database. Values are of the form projects/<project>/instances/<instance>/databases/<database>.

Returns
TypeDescription
Database

getDatabaseCallable()

publicfinalUnaryCallable<GetDatabaseRequest,Database>getDatabaseCallable()

Gets the state of a Cloud Spanner database.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){GetDatabaseRequestrequest=GetDatabaseRequest.newBuilder().setName(DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]").toString()).build();ApiFuture<Database>future=databaseAdminClient.getDatabaseCallable().futureCall(request);// Do something.Databaseresponse=future.get();}
Returns
TypeDescription
UnaryCallable<GetDatabaseRequest,Database>

getDatabaseDdl(DatabaseName database)

publicfinalGetDatabaseDdlResponsegetDatabaseDdl(DatabaseNamedatabase)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){DatabaseNamedatabase=DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]");GetDatabaseDdlResponseresponse=databaseAdminClient.getDatabaseDdl(database);}
Parameter
NameDescription
databaseDatabaseName

Required. The database whose schema we wish to get. Values are of the form projects/<project>/instances/<instance>/databases/<database>

Returns
TypeDescription
GetDatabaseDdlResponse

getDatabaseDdl(GetDatabaseDdlRequest request)

publicfinalGetDatabaseDdlResponsegetDatabaseDdl(GetDatabaseDdlRequestrequest)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){GetDatabaseDdlRequestrequest=GetDatabaseDdlRequest.newBuilder().setDatabase(DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]").toString()).build();GetDatabaseDdlResponseresponse=databaseAdminClient.getDatabaseDdl(request);}
Parameter
NameDescription
requestGetDatabaseDdlRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
GetDatabaseDdlResponse

getDatabaseDdl(String database)

publicfinalGetDatabaseDdlResponsegetDatabaseDdl(Stringdatabase)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringdatabase=DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]").toString();GetDatabaseDdlResponseresponse=databaseAdminClient.getDatabaseDdl(database);}
Parameter
NameDescription
databaseString

Required. The database whose schema we wish to get. Values are of the form projects/<project>/instances/<instance>/databases/<database>

Returns
TypeDescription
GetDatabaseDdlResponse

getDatabaseDdlCallable()

publicfinalUnaryCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){GetDatabaseDdlRequestrequest=GetDatabaseDdlRequest.newBuilder().setDatabase(DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]").toString()).build();ApiFuture<GetDatabaseDdlResponse>future=databaseAdminClient.getDatabaseDdlCallable().futureCall(request);// Do something.GetDatabaseDdlResponseresponse=future.get();}
Returns
TypeDescription
UnaryCallable<GetDatabaseDdlRequest,GetDatabaseDdlResponse>

getHttpJsonOperationsClient()

publicfinalOperationsClientgetHttpJsonOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
TypeDescription
OperationsClient

getIamPolicy(ResourceName resource)

publicfinalPolicygetIamPolicy(ResourceNameresource)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ResourceNameresource=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]");Policyresponse=databaseAdminClient.getIamPolicy(resource);}
Parameter
NameDescription
resourcecom.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.

Returns
TypeDescription
com.google.iam.v1.Policy

getIamPolicy(GetIamPolicyRequest request)

publicfinalPolicygetIamPolicy(GetIamPolicyRequestrequest)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){GetIamPolicyRequestrequest=GetIamPolicyRequest.newBuilder().setResource(BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString()).setOptions(GetPolicyOptions.newBuilder().build()).build();Policyresponse=databaseAdminClient.getIamPolicy(request);}
Parameter
NameDescription
requestcom.google.iam.v1.GetIamPolicyRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
com.google.iam.v1.Policy

getIamPolicy(String resource)

publicfinalPolicygetIamPolicy(Stringresource)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringresource=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString();Policyresponse=databaseAdminClient.getIamPolicy(resource);}
Parameter
NameDescription
resourceString

REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.

Returns
TypeDescription
com.google.iam.v1.Policy

getIamPolicyCallable()

publicfinalUnaryCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){GetIamPolicyRequestrequest=GetIamPolicyRequest.newBuilder().setResource(BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString()).setOptions(GetPolicyOptions.newBuilder().build()).build();ApiFuture<Policy>future=databaseAdminClient.getIamPolicyCallable().futureCall(request);// Do something.Policyresponse=future.get();}
Returns
TypeDescription
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy>

getOperationsClient()

publicfinalOperationsClientgetOperationsClient()

Returns the OperationsClient that can be used to query the status of a long-running operation returned by another API method call.

Returns
TypeDescription
OperationsClient

getSettings()

publicfinalDatabaseAdminSettingsgetSettings()
Returns
TypeDescription
DatabaseAdminSettings

getStub()

publicDatabaseAdminStubgetStub()
Returns
TypeDescription
DatabaseAdminStub

isShutdown()

publicbooleanisShutdown()
Returns
TypeDescription
boolean

isTerminated()

publicbooleanisTerminated()
Returns
TypeDescription
boolean

listBackupOperations(InstanceName parent)

publicfinalDatabaseAdminClient.ListBackupOperationsPagedResponselistBackupOperations(InstanceNameparent)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){InstanceNameparent=InstanceName.of("[PROJECT]","[INSTANCE]");for(Operationelement:databaseAdminClient.listBackupOperations(parent).iterateAll()){// doThingsWith(element);}}
Parameter
NameDescription
parentInstanceName

Required. The instance of the backup operations. Values are of the form projects/<project>/instances/<instance>.

Returns
TypeDescription
DatabaseAdminClient.ListBackupOperationsPagedResponse

listBackupOperations(ListBackupOperationsRequest request)

publicfinalDatabaseAdminClient.ListBackupOperationsPagedResponselistBackupOperations(ListBackupOperationsRequestrequest)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ListBackupOperationsRequestrequest=ListBackupOperationsRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setFilter("filter-1274492040").setPageSize(883849137).setPageToken("pageToken873572522").build();for(Operationelement:databaseAdminClient.listBackupOperations(request).iterateAll()){// doThingsWith(element);}}
Parameter
NameDescription
requestListBackupOperationsRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
DatabaseAdminClient.ListBackupOperationsPagedResponse

listBackupOperations(String parent)

publicfinalDatabaseAdminClient.ListBackupOperationsPagedResponselistBackupOperations(Stringparent)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringparent=InstanceName.of("[PROJECT]","[INSTANCE]").toString();for(Operationelement:databaseAdminClient.listBackupOperations(parent).iterateAll()){// doThingsWith(element);}}
Parameter
NameDescription
parentString

Required. The instance of the backup operations. Values are of the form projects/<project>/instances/<instance>.

Returns
TypeDescription
DatabaseAdminClient.ListBackupOperationsPagedResponse

listBackupOperationsCallable()

publicfinalUnaryCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ListBackupOperationsRequestrequest=ListBackupOperationsRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setFilter("filter-1274492040").setPageSize(883849137).setPageToken("pageToken873572522").build();while(true){ListBackupOperationsResponseresponse=databaseAdminClient.listBackupOperationsCallable().call(request);for(Operationelement:response.getOperationsList()){// doThingsWith(element);}StringnextPageToken=response.getNextPageToken();if(!Strings.isNullOrEmpty(nextPageToken)){request=request.toBuilder().setPageToken(nextPageToken).build();}else{break;}}}
Returns
TypeDescription
UnaryCallable<ListBackupOperationsRequest,ListBackupOperationsResponse>

listBackupOperationsPagedCallable()

publicfinalUnaryCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ListBackupOperationsRequestrequest=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(Operationelement:future.get().iterateAll()){// doThingsWith(element);}}
Returns
TypeDescription
UnaryCallable<ListBackupOperationsRequest,ListBackupOperationsPagedResponse>

listBackups(InstanceName parent)

publicfinalDatabaseAdminClient.ListBackupsPagedResponselistBackups(InstanceNameparent)

Lists completed and pending backups. Backups returned are ordered by create_time in descending order, starting from the most recent create_time.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){InstanceNameparent=InstanceName.of("[PROJECT]","[INSTANCE]");for(Backupelement:databaseAdminClient.listBackups(parent).iterateAll()){// doThingsWith(element);}}
Parameter
NameDescription
parentInstanceName

Required. The instance to list backups from. Values are of the form projects/<project>/instances/<instance>.

Returns
TypeDescription
DatabaseAdminClient.ListBackupsPagedResponse

listBackups(ListBackupsRequest request)

publicfinalDatabaseAdminClient.ListBackupsPagedResponselistBackups(ListBackupsRequestrequest)

Lists completed and pending backups. Backups returned are ordered by create_time in descending order, starting from the most recent create_time.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ListBackupsRequestrequest=ListBackupsRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setFilter("filter-1274492040").setPageSize(883849137).setPageToken("pageToken873572522").build();for(Backupelement:databaseAdminClient.listBackups(request).iterateAll()){// doThingsWith(element);}}
Parameter
NameDescription
requestListBackupsRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
DatabaseAdminClient.ListBackupsPagedResponse

listBackups(String parent)

publicfinalDatabaseAdminClient.ListBackupsPagedResponselistBackups(Stringparent)

Lists completed and pending backups. Backups returned are ordered by create_time in descending order, starting from the most recent create_time.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringparent=InstanceName.of("[PROJECT]","[INSTANCE]").toString();for(Backupelement:databaseAdminClient.listBackups(parent).iterateAll()){// doThingsWith(element);}}
Parameter
NameDescription
parentString

Required. The instance to list backups from. Values are of the form projects/<project>/instances/<instance>.

Returns
TypeDescription
DatabaseAdminClient.ListBackupsPagedResponse

listBackupsCallable()

publicfinalUnaryCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ListBackupsRequestrequest=ListBackupsRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setFilter("filter-1274492040").setPageSize(883849137).setPageToken("pageToken873572522").build();while(true){ListBackupsResponseresponse=databaseAdminClient.listBackupsCallable().call(request);for(Backupelement:response.getBackupsList()){// doThingsWith(element);}StringnextPageToken=response.getNextPageToken();if(!Strings.isNullOrEmpty(nextPageToken)){request=request.toBuilder().setPageToken(nextPageToken).build();}else{break;}}}
Returns
TypeDescription
UnaryCallable<ListBackupsRequest,ListBackupsResponse>

listBackupsPagedCallable()

publicfinalUnaryCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ListBackupsRequestrequest=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(Backupelement:future.get().iterateAll()){// doThingsWith(element);}}
Returns
TypeDescription
UnaryCallable<ListBackupsRequest,ListBackupsPagedResponse>

listDatabaseOperations(InstanceName parent)

publicfinalDatabaseAdminClient.ListDatabaseOperationsPagedResponselistDatabaseOperations(InstanceNameparent)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){InstanceNameparent=InstanceName.of("[PROJECT]","[INSTANCE]");for(Operationelement:databaseAdminClient.listDatabaseOperations(parent).iterateAll()){// doThingsWith(element);}}
Parameter
NameDescription
parentInstanceName

Required. The instance of the database operations. Values are of the form projects/<project>/instances/<instance>.

Returns
TypeDescription
DatabaseAdminClient.ListDatabaseOperationsPagedResponse

listDatabaseOperations(ListDatabaseOperationsRequest request)

publicfinalDatabaseAdminClient.ListDatabaseOperationsPagedResponselistDatabaseOperations(ListDatabaseOperationsRequestrequest)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ListDatabaseOperationsRequestrequest=ListDatabaseOperationsRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setFilter("filter-1274492040").setPageSize(883849137).setPageToken("pageToken873572522").build();for(Operationelement:databaseAdminClient.listDatabaseOperations(request).iterateAll()){// doThingsWith(element);}}
Parameter
NameDescription
requestListDatabaseOperationsRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
DatabaseAdminClient.ListDatabaseOperationsPagedResponse

listDatabaseOperations(String parent)

publicfinalDatabaseAdminClient.ListDatabaseOperationsPagedResponselistDatabaseOperations(Stringparent)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringparent=InstanceName.of("[PROJECT]","[INSTANCE]").toString();for(Operationelement:databaseAdminClient.listDatabaseOperations(parent).iterateAll()){// doThingsWith(element);}}
Parameter
NameDescription
parentString

Required. The instance of the database operations. Values are of the form projects/<project>/instances/<instance>.

Returns
TypeDescription
DatabaseAdminClient.ListDatabaseOperationsPagedResponse

listDatabaseOperationsCallable()

publicfinalUnaryCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ListDatabaseOperationsRequestrequest=ListDatabaseOperationsRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setFilter("filter-1274492040").setPageSize(883849137).setPageToken("pageToken873572522").build();while(true){ListDatabaseOperationsResponseresponse=databaseAdminClient.listDatabaseOperationsCallable().call(request);for(Operationelement:response.getOperationsList()){// doThingsWith(element);}StringnextPageToken=response.getNextPageToken();if(!Strings.isNullOrEmpty(nextPageToken)){request=request.toBuilder().setPageToken(nextPageToken).build();}else{break;}}}
Returns
TypeDescription
UnaryCallable<ListDatabaseOperationsRequest,ListDatabaseOperationsResponse>

listDatabaseOperationsPagedCallable()

publicfinalUnaryCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ListDatabaseOperationsRequestrequest=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(Operationelement:future.get().iterateAll()){// doThingsWith(element);}}
Returns
TypeDescription
UnaryCallable<ListDatabaseOperationsRequest,ListDatabaseOperationsPagedResponse>

listDatabaseRoles(DatabaseName parent)

publicfinalDatabaseAdminClient.ListDatabaseRolesPagedResponselistDatabaseRoles(DatabaseNameparent)

Lists Cloud Spanner database roles.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){DatabaseNameparent=DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]");for(DatabaseRoleelement:databaseAdminClient.listDatabaseRoles(parent).iterateAll()){// doThingsWith(element);}}
Parameter
NameDescription
parentDatabaseName

Required. The database whose roles should be listed. Values are of the form projects/<project>/instances/<instance>/databases/<database>/databaseRoles.

Returns
TypeDescription
DatabaseAdminClient.ListDatabaseRolesPagedResponse

listDatabaseRoles(ListDatabaseRolesRequest request)

publicfinalDatabaseAdminClient.ListDatabaseRolesPagedResponselistDatabaseRoles(ListDatabaseRolesRequestrequest)

Lists Cloud Spanner database roles.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ListDatabaseRolesRequestrequest=ListDatabaseRolesRequest.newBuilder().setParent(DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").build();for(DatabaseRoleelement:databaseAdminClient.listDatabaseRoles(request).iterateAll()){// doThingsWith(element);}}
Parameter
NameDescription
requestListDatabaseRolesRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
DatabaseAdminClient.ListDatabaseRolesPagedResponse

listDatabaseRoles(String parent)

publicfinalDatabaseAdminClient.ListDatabaseRolesPagedResponselistDatabaseRoles(Stringparent)

Lists Cloud Spanner database roles.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringparent=DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]").toString();for(DatabaseRoleelement:databaseAdminClient.listDatabaseRoles(parent).iterateAll()){// doThingsWith(element);}}
Parameter
NameDescription
parentString

Required. The database whose roles should be listed. Values are of the form projects/<project>/instances/<instance>/databases/<database>/databaseRoles.

Returns
TypeDescription
DatabaseAdminClient.ListDatabaseRolesPagedResponse

listDatabaseRolesCallable()

publicfinalUnaryCallable<ListDatabaseRolesRequest,ListDatabaseRolesResponse>listDatabaseRolesCallable()

Lists Cloud Spanner database roles.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ListDatabaseRolesRequestrequest=ListDatabaseRolesRequest.newBuilder().setParent(DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").build();while(true){ListDatabaseRolesResponseresponse=databaseAdminClient.listDatabaseRolesCallable().call(request);for(DatabaseRoleelement:response.getDatabaseRolesList()){// doThingsWith(element);}StringnextPageToken=response.getNextPageToken();if(!Strings.isNullOrEmpty(nextPageToken)){request=request.toBuilder().setPageToken(nextPageToken).build();}else{break;}}}
Returns
TypeDescription
UnaryCallable<ListDatabaseRolesRequest,ListDatabaseRolesResponse>

listDatabaseRolesPagedCallable()

publicfinalUnaryCallable<ListDatabaseRolesRequest,DatabaseAdminClient.ListDatabaseRolesPagedResponse>listDatabaseRolesPagedCallable()

Lists Cloud Spanner database roles.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ListDatabaseRolesRequestrequest=ListDatabaseRolesRequest.newBuilder().setParent(DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").build();ApiFuture<DatabaseRole>future=databaseAdminClient.listDatabaseRolesPagedCallable().futureCall(request);// Do something.for(DatabaseRoleelement:future.get().iterateAll()){// doThingsWith(element);}}
Returns
TypeDescription
UnaryCallable<ListDatabaseRolesRequest,ListDatabaseRolesPagedResponse>

listDatabases(InstanceName parent)

publicfinalDatabaseAdminClient.ListDatabasesPagedResponselistDatabases(InstanceNameparent)

Lists Cloud Spanner databases.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){InstanceNameparent=InstanceName.of("[PROJECT]","[INSTANCE]");for(Databaseelement:databaseAdminClient.listDatabases(parent).iterateAll()){// doThingsWith(element);}}
Parameter
NameDescription
parentInstanceName

Required. The instance whose databases should be listed. Values are of the form projects/<project>/instances/<instance>.

Returns
TypeDescription
DatabaseAdminClient.ListDatabasesPagedResponse

listDatabases(ListDatabasesRequest request)

publicfinalDatabaseAdminClient.ListDatabasesPagedResponselistDatabases(ListDatabasesRequestrequest)

Lists Cloud Spanner databases.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ListDatabasesRequestrequest=ListDatabasesRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").build();for(Databaseelement:databaseAdminClient.listDatabases(request).iterateAll()){// doThingsWith(element);}}
Parameter
NameDescription
requestListDatabasesRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
DatabaseAdminClient.ListDatabasesPagedResponse

listDatabases(String parent)

publicfinalDatabaseAdminClient.ListDatabasesPagedResponselistDatabases(Stringparent)

Lists Cloud Spanner databases.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringparent=InstanceName.of("[PROJECT]","[INSTANCE]").toString();for(Databaseelement:databaseAdminClient.listDatabases(parent).iterateAll()){// doThingsWith(element);}}
Parameter
NameDescription
parentString

Required. The instance whose databases should be listed. Values are of the form projects/<project>/instances/<instance>.

Returns
TypeDescription
DatabaseAdminClient.ListDatabasesPagedResponse

listDatabasesCallable()

publicfinalUnaryCallable<ListDatabasesRequest,ListDatabasesResponse>listDatabasesCallable()

Lists Cloud Spanner databases.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ListDatabasesRequestrequest=ListDatabasesRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").build();while(true){ListDatabasesResponseresponse=databaseAdminClient.listDatabasesCallable().call(request);for(Databaseelement:response.getDatabasesList()){// doThingsWith(element);}StringnextPageToken=response.getNextPageToken();if(!Strings.isNullOrEmpty(nextPageToken)){request=request.toBuilder().setPageToken(nextPageToken).build();}else{break;}}}
Returns
TypeDescription
UnaryCallable<ListDatabasesRequest,ListDatabasesResponse>

listDatabasesPagedCallable()

publicfinalUnaryCallable<ListDatabasesRequest,DatabaseAdminClient.ListDatabasesPagedResponse>listDatabasesPagedCallable()

Lists Cloud Spanner databases.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ListDatabasesRequestrequest=ListDatabasesRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setPageSize(883849137).setPageToken("pageToken873572522").build();ApiFuture<Database>future=databaseAdminClient.listDatabasesPagedCallable().futureCall(request);// Do something.for(Databaseelement:future.get().iterateAll()){// doThingsWith(element);}}
Returns
TypeDescription
UnaryCallable<ListDatabasesRequest,ListDatabasesPagedResponse>

restoreDatabaseAsync(InstanceName parent, String databaseId, BackupName backup)

publicfinalOperationFuture<Database,RestoreDatabaseMetadata>restoreDatabaseAsync(InstanceNameparent,StringdatabaseId,BackupNamebackup)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){InstanceNameparent=InstanceName.of("[PROJECT]","[INSTANCE]");StringdatabaseId="databaseId1688905718";BackupNamebackup=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]");Databaseresponse=databaseAdminClient.restoreDatabaseAsync(parent,databaseId,backup).get();}
Parameters
NameDescription
parentInstanceName

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 projects/<project>/instances/<instance>.

databaseIdString

Required. The id of the database to create and restore to. This database must not already exist. The database_id appended to parent forms the full database name of the form projects/<project>/instances/<instance>/databases/<database_id>.

backupBackupName

Name of the backup from which to restore. Values are of the form projects/<project>/instances/<instance>/backups/<backup>.

Returns
TypeDescription
OperationFuture<Database,RestoreDatabaseMetadata>

restoreDatabaseAsync(InstanceName parent, String databaseId, String backup)

publicfinalOperationFuture<Database,RestoreDatabaseMetadata>restoreDatabaseAsync(InstanceNameparent,StringdatabaseId,Stringbackup)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){InstanceNameparent=InstanceName.of("[PROJECT]","[INSTANCE]");StringdatabaseId="databaseId1688905718";Stringbackup=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString();Databaseresponse=databaseAdminClient.restoreDatabaseAsync(parent,databaseId,backup).get();}
Parameters
NameDescription
parentInstanceName

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 projects/<project>/instances/<instance>.

databaseIdString

Required. The id of the database to create and restore to. This database must not already exist. The database_id appended to parent forms the full database name of the form projects/<project>/instances/<instance>/databases/<database_id>.

backupString

Name of the backup from which to restore. Values are of the form projects/<project>/instances/<instance>/backups/<backup>.

Returns
TypeDescription
OperationFuture<Database,RestoreDatabaseMetadata>

restoreDatabaseAsync(RestoreDatabaseRequest request)

publicfinalOperationFuture<Database,RestoreDatabaseMetadata>restoreDatabaseAsync(RestoreDatabaseRequestrequest)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){RestoreDatabaseRequestrequest=RestoreDatabaseRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setDatabaseId("databaseId1688905718").setEncryptionConfig(RestoreDatabaseEncryptionConfig.newBuilder().build()).build();Databaseresponse=databaseAdminClient.restoreDatabaseAsync(request).get();}
Parameter
NameDescription
requestRestoreDatabaseRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Database,RestoreDatabaseMetadata>

restoreDatabaseAsync(String parent, String databaseId, BackupName backup)

publicfinalOperationFuture<Database,RestoreDatabaseMetadata>restoreDatabaseAsync(Stringparent,StringdatabaseId,BackupNamebackup)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringparent=InstanceName.of("[PROJECT]","[INSTANCE]").toString();StringdatabaseId="databaseId1688905718";BackupNamebackup=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]");Databaseresponse=databaseAdminClient.restoreDatabaseAsync(parent,databaseId,backup).get();}
Parameters
NameDescription
parentString

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 projects/<project>/instances/<instance>.

databaseIdString

Required. The id of the database to create and restore to. This database must not already exist. The database_id appended to parent forms the full database name of the form projects/<project>/instances/<instance>/databases/<database_id>.

backupBackupName

Name of the backup from which to restore. Values are of the form projects/<project>/instances/<instance>/backups/<backup>.

Returns
TypeDescription
OperationFuture<Database,RestoreDatabaseMetadata>

restoreDatabaseAsync(String parent, String databaseId, String backup)

publicfinalOperationFuture<Database,RestoreDatabaseMetadata>restoreDatabaseAsync(Stringparent,StringdatabaseId,Stringbackup)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringparent=InstanceName.of("[PROJECT]","[INSTANCE]").toString();StringdatabaseId="databaseId1688905718";Stringbackup=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString();Databaseresponse=databaseAdminClient.restoreDatabaseAsync(parent,databaseId,backup).get();}
Parameters
NameDescription
parentString

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 projects/<project>/instances/<instance>.

databaseIdString

Required. The id of the database to create and restore to. This database must not already exist. The database_id appended to parent forms the full database name of the form projects/<project>/instances/<instance>/databases/<database_id>.

backupString

Name of the backup from which to restore. Values are of the form projects/<project>/instances/<instance>/backups/<backup>.

Returns
TypeDescription
OperationFuture<Database,RestoreDatabaseMetadata>

restoreDatabaseCallable()

publicfinalUnaryCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){RestoreDatabaseRequestrequest=RestoreDatabaseRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setDatabaseId("databaseId1688905718").setEncryptionConfig(RestoreDatabaseEncryptionConfig.newBuilder().build()).build();ApiFuture<Operation>future=databaseAdminClient.restoreDatabaseCallable().futureCall(request);// Do something.Operationresponse=future.get();}
Returns
TypeDescription
UnaryCallable<RestoreDatabaseRequest,Operation>

restoreDatabaseOperationCallable()

publicfinalOperationCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){RestoreDatabaseRequestrequest=RestoreDatabaseRequest.newBuilder().setParent(InstanceName.of("[PROJECT]","[INSTANCE]").toString()).setDatabaseId("databaseId1688905718").setEncryptionConfig(RestoreDatabaseEncryptionConfig.newBuilder().build()).build();OperationFuture<Database,RestoreDatabaseMetadata>future=databaseAdminClient.restoreDatabaseOperationCallable().futureCall(request);// Do something.Databaseresponse=future.get();}
Returns
TypeDescription
OperationCallable<RestoreDatabaseRequest,Database,RestoreDatabaseMetadata>

setIamPolicy(ResourceName resource, Policy policy)

publicfinalPolicysetIamPolicy(ResourceNameresource,Policypolicy)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ResourceNameresource=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]");Policypolicy=Policy.newBuilder().build();Policyresponse=databaseAdminClient.setIamPolicy(resource,policy);}
Parameters
NameDescription
resourcecom.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.

policycom.google.iam.v1.Policy

REQUIRED: The complete policy to be applied to the resource. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.

Returns
TypeDescription
com.google.iam.v1.Policy

setIamPolicy(SetIamPolicyRequest request)

publicfinalPolicysetIamPolicy(SetIamPolicyRequestrequest)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){SetIamPolicyRequestrequest=SetIamPolicyRequest.newBuilder().setResource(BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString()).setPolicy(Policy.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();Policyresponse=databaseAdminClient.setIamPolicy(request);}
Parameter
NameDescription
requestcom.google.iam.v1.SetIamPolicyRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
com.google.iam.v1.Policy

setIamPolicy(String resource, Policy policy)

publicfinalPolicysetIamPolicy(Stringresource,Policypolicy)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringresource=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString();Policypolicy=Policy.newBuilder().build();Policyresponse=databaseAdminClient.setIamPolicy(resource,policy);}
Parameters
NameDescription
resourceString

REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.

policycom.google.iam.v1.Policy

REQUIRED: The complete policy to be applied to the resource. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.

Returns
TypeDescription
com.google.iam.v1.Policy

setIamPolicyCallable()

publicfinalUnaryCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){SetIamPolicyRequestrequest=SetIamPolicyRequest.newBuilder().setResource(BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString()).setPolicy(Policy.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();ApiFuture<Policy>future=databaseAdminClient.setIamPolicyCallable().futureCall(request);// Do something.Policyresponse=future.get();}
Returns
TypeDescription
UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy>

shutdown()

publicvoidshutdown()

shutdownNow()

publicvoidshutdownNow()

testIamPermissions(ResourceName resource, List<String> permissions)

publicfinalTestIamPermissionsResponsetestIamPermissions(ResourceNameresource,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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){ResourceNameresource=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]");List<String>permissions=newArrayList<>();TestIamPermissionsResponseresponse=databaseAdminClient.testIamPermissions(resource,permissions);}
Parameters
NameDescription
resourcecom.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.

permissionsList<String>

The set of permissions to check for the resource. Permissions with wildcards (such as '*' or 'storage.*') are not allowed. For more information see IAM Overview.

Returns
TypeDescription
com.google.iam.v1.TestIamPermissionsResponse

testIamPermissions(TestIamPermissionsRequest request)

publicfinalTestIamPermissionsResponsetestIamPermissions(TestIamPermissionsRequestrequest)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){TestIamPermissionsRequestrequest=TestIamPermissionsRequest.newBuilder().setResource(BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString()).addAllPermissions(newArrayList<String>()).build();TestIamPermissionsResponseresponse=databaseAdminClient.testIamPermissions(request);}
Parameter
NameDescription
requestcom.google.iam.v1.TestIamPermissionsRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
com.google.iam.v1.TestIamPermissionsResponse

testIamPermissions(String resource, List<String> permissions)

publicfinalTestIamPermissionsResponsetestIamPermissions(Stringresource,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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringresource=BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString();List<String>permissions=newArrayList<>();TestIamPermissionsResponseresponse=databaseAdminClient.testIamPermissions(resource,permissions);}
Parameters
NameDescription
resourceString

REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.

permissionsList<String>

The set of permissions to check for the resource. Permissions with wildcards (such as '*' or 'storage.*') are not allowed. For more information see IAM Overview.

Returns
TypeDescription
com.google.iam.v1.TestIamPermissionsResponse

testIamPermissionsCallable()

publicfinalUnaryCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){TestIamPermissionsRequestrequest=TestIamPermissionsRequest.newBuilder().setResource(BackupName.of("[PROJECT]","[INSTANCE]","[BACKUP]").toString()).addAllPermissions(newArrayList<String>()).build();ApiFuture<TestIamPermissionsResponse>future=databaseAdminClient.testIamPermissionsCallable().futureCall(request);// Do something.TestIamPermissionsResponseresponse=future.get();}
Returns
TypeDescription
UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse>

updateBackup(Backup backup, FieldMask updateMask)

publicfinalBackupupdateBackup(Backupbackup,FieldMaskupdateMask)

Updates a pending or completed Backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Backupbackup=Backup.newBuilder().build();FieldMaskupdateMask=FieldMask.newBuilder().build();Backupresponse=databaseAdminClient.updateBackup(backup,updateMask);}
Parameters
NameDescription
backupBackup

Required. The backup to update. backup.name, and the fields to be updated as specified by update_mask are required. Other fields are ignored. Update is only supported for the following fields: * backup.expire_time.

updateMaskFieldMask

Required. A mask specifying which fields (e.g. expire_time) in the Backup resource should be updated. This mask is relative to the Backup resource, not to the request message. The field mask must always be specified; this prevents any future fields from being erased accidentally by clients that do not know about them.

Returns
TypeDescription
Backup

updateBackup(UpdateBackupRequest request)

publicfinalBackupupdateBackup(UpdateBackupRequestrequest)

Updates a pending or completed Backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){UpdateBackupRequestrequest=UpdateBackupRequest.newBuilder().setBackup(Backup.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();Backupresponse=databaseAdminClient.updateBackup(request);}
Parameter
NameDescription
requestUpdateBackupRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
Backup

updateBackupCallable()

publicfinalUnaryCallable<UpdateBackupRequest,Backup>updateBackupCallable()

Updates a pending or completed Backup.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){UpdateBackupRequestrequest=UpdateBackupRequest.newBuilder().setBackup(Backup.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();ApiFuture<Backup>future=databaseAdminClient.updateBackupCallable().futureCall(request);// Do something.Backupresponse=future.get();}
Returns
TypeDescription
UnaryCallable<UpdateBackupRequest,Backup>

updateDatabaseAsync(Database database, FieldMask updateMask)

publicfinalOperationFuture<Database,UpdateDatabaseMetadata>updateDatabaseAsync(Databasedatabase,FieldMaskupdateMask)

Updates a Cloud Spanner database. The returned long-running operation can be used to track the progress of updating the database. If the named database does not exist, returns NOT_FOUND.

While the operation is pending:

* The database's reconciling field is set to true. * Cancelling the operation is best-effort. If the cancellation succeeds, the operation metadata's cancel_time is set, the updates are reverted, and the operation terminates with a CANCELLED status. * New UpdateDatabase requests will return a FAILED_PRECONDITION error until the pending operation is done (returns successfully or with error). * Reading the database via the API continues to give the pre-request values.

Upon completion of the returned operation:

* The new values are in effect and readable via the API. * The database's reconciling field becomes false.

The returned long-running operation will have a name of the format projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id> and can be used to track the database modification. The metadata field type is UpdateDatabaseMetadata. The response field type is Database, if successful.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Databasedatabase=Database.newBuilder().build();FieldMaskupdateMask=FieldMask.newBuilder().build();Databaseresponse=databaseAdminClient.updateDatabaseAsync(database,updateMask).get();}
Parameters
NameDescription
databaseDatabase

Required. The database to update. The name field of the database is of the form projects/<project>/instances/<instance>/databases/<database>.

updateMaskFieldMask

Required. The list of fields to update. Currently, only enable_drop_protection field can be updated.

Returns
TypeDescription
OperationFuture<Database,UpdateDatabaseMetadata>

updateDatabaseAsync(UpdateDatabaseRequest request)

publicfinalOperationFuture<Database,UpdateDatabaseMetadata>updateDatabaseAsync(UpdateDatabaseRequestrequest)

Updates a Cloud Spanner database. The returned long-running operation can be used to track the progress of updating the database. If the named database does not exist, returns NOT_FOUND.

While the operation is pending:

* The database's reconciling field is set to true. * Cancelling the operation is best-effort. If the cancellation succeeds, the operation metadata's cancel_time is set, the updates are reverted, and the operation terminates with a CANCELLED status. * New UpdateDatabase requests will return a FAILED_PRECONDITION error until the pending operation is done (returns successfully or with error). * Reading the database via the API continues to give the pre-request values.

Upon completion of the returned operation:

* The new values are in effect and readable via the API. * The database's reconciling field becomes false.

The returned long-running operation will have a name of the format projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id> and can be used to track the database modification. The metadata field type is UpdateDatabaseMetadata. The response field type is Database, if successful.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){UpdateDatabaseRequestrequest=UpdateDatabaseRequest.newBuilder().setDatabase(Database.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();Databaseresponse=databaseAdminClient.updateDatabaseAsync(request).get();}
Parameter
NameDescription
requestUpdateDatabaseRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Database,UpdateDatabaseMetadata>

updateDatabaseCallable()

publicfinalUnaryCallable<UpdateDatabaseRequest,Operation>updateDatabaseCallable()

Updates a Cloud Spanner database. The returned long-running operation can be used to track the progress of updating the database. If the named database does not exist, returns NOT_FOUND.

While the operation is pending:

* The database's reconciling field is set to true. * Cancelling the operation is best-effort. If the cancellation succeeds, the operation metadata's cancel_time is set, the updates are reverted, and the operation terminates with a CANCELLED status. * New UpdateDatabase requests will return a FAILED_PRECONDITION error until the pending operation is done (returns successfully or with error). * Reading the database via the API continues to give the pre-request values.

Upon completion of the returned operation:

* The new values are in effect and readable via the API. * The database's reconciling field becomes false.

The returned long-running operation will have a name of the format projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id> and can be used to track the database modification. The metadata field type is UpdateDatabaseMetadata. The response field type is Database, if successful.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){UpdateDatabaseRequestrequest=UpdateDatabaseRequest.newBuilder().setDatabase(Database.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();ApiFuture<Operation>future=databaseAdminClient.updateDatabaseCallable().futureCall(request);// Do something.Operationresponse=future.get();}
Returns
TypeDescription
UnaryCallable<UpdateDatabaseRequest,Operation>

updateDatabaseDdlAsync(DatabaseName database, List<String> statements)

publicfinalOperationFuture<Empty,UpdateDatabaseDdlMetadata>updateDatabaseDdlAsync(DatabaseNamedatabase,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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){DatabaseNamedatabase=DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]");List<String>statements=newArrayList<>();databaseAdminClient.updateDatabaseDdlAsync(database,statements).get();}
Parameters
NameDescription
databaseDatabaseName

Required. The database to update.

statementsList<String>

Required. DDL statements to be applied to the database.

Returns
TypeDescription
OperationFuture<Empty,UpdateDatabaseDdlMetadata>

updateDatabaseDdlAsync(UpdateDatabaseDdlRequest request)

publicfinalOperationFuture<Empty,UpdateDatabaseDdlMetadata>updateDatabaseDdlAsync(UpdateDatabaseDdlRequestrequest)

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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){UpdateDatabaseDdlRequestrequest=UpdateDatabaseDdlRequest.newBuilder().setDatabase(DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]").toString()).addAllStatements(newArrayList<String>()).setOperationId("operationId129704162").build();databaseAdminClient.updateDatabaseDdlAsync(request).get();}
Parameter
NameDescription
requestUpdateDatabaseDdlRequest

The request object containing all of the parameters for the API call.

Returns
TypeDescription
OperationFuture<Empty,UpdateDatabaseDdlMetadata>

updateDatabaseDdlAsync(String database, List<String> statements)

publicfinalOperationFuture<Empty,UpdateDatabaseDdlMetadata>updateDatabaseDdlAsync(Stringdatabase,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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){Stringdatabase=DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]").toString();List<String>statements=newArrayList<>();databaseAdminClient.updateDatabaseDdlAsync(database,statements).get();}
Parameters
NameDescription
databaseString

Required. The database to update.

statementsList<String>

Required. DDL statements to be applied to the database.

Returns
TypeDescription
OperationFuture<Empty,UpdateDatabaseDdlMetadata>

updateDatabaseDdlCallable()

publicfinalUnaryCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){UpdateDatabaseDdlRequestrequest=UpdateDatabaseDdlRequest.newBuilder().setDatabase(DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]").toString()).addAllStatements(newArrayList<String>()).setOperationId("operationId129704162").build();ApiFuture<Operation>future=databaseAdminClient.updateDatabaseDdlCallable().futureCall(request);// Do something.future.get();}
Returns
TypeDescription
UnaryCallable<UpdateDatabaseDdlRequest,Operation>

updateDatabaseDdlOperationCallable()

publicfinalOperationCallable<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:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){UpdateDatabaseDdlRequestrequest=UpdateDatabaseDdlRequest.newBuilder().setDatabase(DatabaseName.of("[PROJECT]","[INSTANCE]","[DATABASE]").toString()).addAllStatements(newArrayList<String>()).setOperationId("operationId129704162").build();OperationFuture<Empty,UpdateDatabaseDdlMetadata>future=databaseAdminClient.updateDatabaseDdlOperationCallable().futureCall(request);// Do something.future.get();}
Returns
TypeDescription
OperationCallable<UpdateDatabaseDdlRequest,Empty,UpdateDatabaseDdlMetadata>

updateDatabaseOperationCallable()

publicfinalOperationCallable<UpdateDatabaseRequest,Database,UpdateDatabaseMetadata>updateDatabaseOperationCallable()

Updates a Cloud Spanner database. The returned long-running operation can be used to track the progress of updating the database. If the named database does not exist, returns NOT_FOUND.

While the operation is pending:

* The database's reconciling field is set to true. * Cancelling the operation is best-effort. If the cancellation succeeds, the operation metadata's cancel_time is set, the updates are reverted, and the operation terminates with a CANCELLED status. * New UpdateDatabase requests will return a FAILED_PRECONDITION error until the pending operation is done (returns successfully or with error). * Reading the database via the API continues to give the pre-request values.

Upon completion of the returned operation:

* The new values are in effect and readable via the API. * The database's reconciling field becomes false.

The returned long-running operation will have a name of the format projects/<project>/instances/<instance>/databases/<database>/operations/<operation_id> and can be used to track the database modification. The metadata field type is UpdateDatabaseMetadata. The response field type is Database, if successful.

Sample code:

// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_librarytry(DatabaseAdminClientdatabaseAdminClient=DatabaseAdminClient.create()){UpdateDatabaseRequestrequest=UpdateDatabaseRequest.newBuilder().setDatabase(Database.newBuilder().build()).setUpdateMask(FieldMask.newBuilder().build()).build();OperationFuture<Database,UpdateDatabaseMetadata>future=databaseAdminClient.updateDatabaseOperationCallable().futureCall(request);// Do something.Databaseresponse=future.get();}
Returns
TypeDescription
OperationCallable<UpdateDatabaseRequest,Database,UpdateDatabaseMetadata>