DatabaseAdminClient

DatabaseAdminClient

Cloud Spanner Database Admin API

The Cloud Spanner Database Admin API can be used to create, drop, and list databases. It also enables updating the schema of pre-existing databases. It can be also used to create, delete and list backups for a database and to restore from an existing backup.

Constructor

new DatabaseAdminClient(optionsopt)

Construct an instance of DatabaseAdminClient.

Parameters:
Name Type Attributes Description
options object <optional>

The configuration object. See the subsequent parameters for more details.

Properties
Name Type Attributes Description
credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
email string <optional>

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename string <optional>

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option below is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port number <optional>

The port on which to connect to the remote host.

projectId string <optional>

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

apiEndpoint string <optional>

The domain name of the API remote host.

Members

(static) apiEndpoint

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

(static) port

The port for this API service.

(static) scopes

The scopes needed to make gRPC calls for every method defined in this service.

(static) servicePath

The DNS address for this API service.

Methods

backupPath(project, instance, backup) → {string}

Return a fully-qualified backup resource name string.

Parameters:
Name Type Description
project string
instance string
backup string

(async) checkCreateBackupProgress(name) → {Promise}

Check the status of the long running operation returned by the createBackup() method.

Parameters:
Name Type Description
name String

The operation name that will be passed.

(async) checkCreateDatabaseProgress(name) → {Promise}

Check the status of the long running operation returned by the createDatabase() method.

Parameters:
Name Type Description
name String

The operation name that will be passed.

(async) checkRestoreDatabaseProgress(name) → {Promise}

Check the status of the long running operation returned by the restoreDatabase() method.

Parameters:
Name Type Description
name String

The operation name that will be passed.

(async) checkUpdateDatabaseDdlProgress(name) → {Promise}

Check the status of the long running operation returned by the updateDatabaseDdl() method.

Parameters:
Name Type Description
name String

The operation name that will be passed.

close()

Terminate the GRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

createBackup(request, optionsopt) → {Promise}

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The name of the instance in which the backup will be created. This must be the same instance that contains the database the backup will be created from. The backup will be stored in the location(s) specified in the instance configuration of this instance. Values are of the form projects/<project>/instances/<instance>.

backupId string

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>.

backup google.spanner.admin.database.v1.Backup

Required. The backup to create.

options object <optional>

Call options. See CallOptions for more details.

createDatabase(request, optionsopt) → {Promise}

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

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

createStatement string

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 (`).

extraStatements Array.<string> <optional>

Optional. A list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: if there is an error in any statement, the database is not created.

options object <optional>

Call options. See CallOptions for more details.

databasePath(project, instance, database) → {string}

Return a fully-qualified database resource name string.

Parameters:
Name Type Description
project string
instance string
database string

deleteBackup(request, optionsopt) → {Promise}

Deletes a pending or completed Backup.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

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

options object <optional>

Call options. See CallOptions for more details.

dropDatabase(request, optionsopt) → {Promise}

Drops (aka deletes) a Cloud Spanner database. Completed backups for the database will be retained according to their expire_time.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
database string

Required. The database to be dropped.

options object <optional>

Call options. See CallOptions for more details.

getBackup(request, optionsopt) → {Promise}

Gets metadata on a pending or completed Backup.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

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

options object <optional>

Call options. See CallOptions for more details.

getDatabase(request, optionsopt) → {Promise}

Gets the state of a Cloud Spanner database.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

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

options object <optional>

Call options. See CallOptions for more details.

getDatabaseDdl(request, optionsopt) → {Promise}

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
database string

Required. The database whose schema we wish to get.

options object <optional>

Call options. See CallOptions for more details.

getIamPolicy(request, optionsopt) → {Promise}

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
resource string

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

options google.iam.v1.GetPolicyOptions

OPTIONAL: A GetPolicyOptions object for specifying options to GetIamPolicy. This field is only used by Cloud IAM.

options object <optional>

Call options. See CallOptions for more details.

getProjectId(callback)

Return the project ID used by this class.

Parameters:
Name Type Description
callback function

the callback to be called with the current project Id.

initialize() → {Promise}

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

instancePath(project, instance) → {string}

Return a fully-qualified instance resource name string.

Parameters:
Name Type Description
project string
instance string

listBackupOperations(request, optionsopt) → {Promise}

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

filter string

An expression that filters the list of returned backup operations.

A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: <, >, <=, >=, !=, =, or :. Colon : is the contains operator. Filter rules are not case sensitive.

The following fields in the operation are eligible for filtering:

* `name` - The name of the long-running operation
* `done` - False if the operation is in progress, else true.
* `metadata.@type` - the type of metadata. For example, the type string
   for CreateBackupMetadata is
   `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`.
* `metadata.<field_name>` - any field in metadata.value.
* `error` - Error associated with the long-running operation.
* `response.@type` - the type of response.
* `response.<field_name>` - any field in response.value.

You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic, but you can specify AND, OR, and NOT logic explicitly.

Here are a few examples:

* `done:true` - The operation is complete.
* `metadata.database:prod` - The database the backup was taken from has
   a name containing the string "prod".
* `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` <br/>
  `(metadata.name:howl) AND` <br/>
  `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` <br/>
  `(error:*)` - Returns operations where:
  * The operation's metadata type is CreateBackupMetadata.
  * The backup name contains the string "howl".
  * The operation started before 2018-03-28T14:50:00Z.
  * The operation resulted in an error.
pageSize number

Number of operations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListBackupOperationsResponse to the same parent and with the same filter.

options object <optional>

Call options. See CallOptions for more details.

listBackupOperationsAsync(request, optionsopt) → {Object}

Equivalent to listBackupOperations, but returns an iterable object.

for-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

filter string

An expression that filters the list of returned backup operations.

A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: <, >, <=, >=, !=, =, or :. Colon : is the contains operator. Filter rules are not case sensitive.

The following fields in the operation are eligible for filtering:

* `name` - The name of the long-running operation
* `done` - False if the operation is in progress, else true.
* `metadata.@type` - the type of metadata. For example, the type string
   for CreateBackupMetadata is
   `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`.
* `metadata.<field_name>` - any field in metadata.value.
* `error` - Error associated with the long-running operation.
* `response.@type` - the type of response.
* `response.<field_name>` - any field in response.value.

You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic, but you can specify AND, OR, and NOT logic explicitly.

Here are a few examples:

* `done:true` - The operation is complete.
* `metadata.database:prod` - The database the backup was taken from has
   a name containing the string "prod".
* `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` <br/>
  `(metadata.name:howl) AND` <br/>
  `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` <br/>
  `(error:*)` - Returns operations where:
  * The operation's metadata type is CreateBackupMetadata.
  * The backup name contains the string "howl".
  * The operation started before 2018-03-28T14:50:00Z.
  * The operation resulted in an error.
pageSize number

Number of operations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListBackupOperationsResponse to the same parent and with the same filter.

options object <optional>

Call options. See CallOptions for more details.

listBackupOperationsStream(request, optionsopt) → {Stream}

Equivalent to listBackupOperations, but returns a NodeJS Stream object.

This fetches the paged responses for listBackupOperations continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

filter string

An expression that filters the list of returned backup operations.

A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: <, >, <=, >=, !=, =, or :. Colon : is the contains operator. Filter rules are not case sensitive.

The following fields in the operation are eligible for filtering:

* `name` - The name of the long-running operation
* `done` - False if the operation is in progress, else true.
* `metadata.@type` - the type of metadata. For example, the type string
   for CreateBackupMetadata is
   `type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata`.
* `metadata.<field_name>` - any field in metadata.value.
* `error` - Error associated with the long-running operation.
* `response.@type` - the type of response.
* `response.<field_name>` - any field in response.value.

You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic, but you can specify AND, OR, and NOT logic explicitly.

Here are a few examples:

* `done:true` - The operation is complete.
* `metadata.database:prod` - The database the backup was taken from has
   a name containing the string "prod".
* `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND` <br/>
  `(metadata.name:howl) AND` <br/>
  `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` <br/>
  `(error:*)` - Returns operations where:
  * The operation's metadata type is CreateBackupMetadata.
  * The backup name contains the string "howl".
  * The operation started before 2018-03-28T14:50:00Z.
  * The operation resulted in an error.
pageSize number

Number of operations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListBackupOperationsResponse to the same parent and with the same filter.

options object <optional>

Call options. See CallOptions for more details.

See:

listBackups(request, optionsopt) → {Promise}

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

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

filter string

An expression that filters the list of returned backups.

A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: <, >, <=, >=, !=, =, or :. Colon : is the contains operator. Filter rules are not case sensitive.

The following fields in the Backup are eligible for filtering:

* `name`
* `database`
* `state`
* `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
* `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
* `size_bytes`

You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic, but you can specify AND, OR, and NOT logic explicitly.

Here are a few examples:

* `name:Howl` - The backup's name contains the string "howl".
* `database:prod`
       - The database's name contains the string "prod".
* `state:CREATING` - The backup is pending creation.
* `state:READY` - The backup is fully created and ready for use.
* `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")`
       - The backup name contains the string "howl" and `create_time`
           of the backup is before 2018-03-28T14:50:00Z.
* `expire_time < \"2018-03-28T14:50:00Z\"`
       - The backup `expire_time` is before 2018-03-28T14:50:00Z.
* `size_bytes > 10000000000` - The backup's size is greater than 10GB
pageSize number

Number of backups to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListBackupsResponse to the same parent and with the same filter.

options object <optional>

Call options. See CallOptions for more details.

listBackupsAsync(request, optionsopt) → {Object}

Equivalent to listBackups, but returns an iterable object.

for-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

filter string

An expression that filters the list of returned backups.

A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: <, >, <=, >=, !=, =, or :. Colon : is the contains operator. Filter rules are not case sensitive.

The following fields in the Backup are eligible for filtering:

* `name`
* `database`
* `state`
* `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
* `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
* `size_bytes`

You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic, but you can specify AND, OR, and NOT logic explicitly.

Here are a few examples:

* `name:Howl` - The backup's name contains the string "howl".
* `database:prod`
       - The database's name contains the string "prod".
* `state:CREATING` - The backup is pending creation.
* `state:READY` - The backup is fully created and ready for use.
* `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")`
       - The backup name contains the string "howl" and `create_time`
           of the backup is before 2018-03-28T14:50:00Z.
* `expire_time < \"2018-03-28T14:50:00Z\"`
       - The backup `expire_time` is before 2018-03-28T14:50:00Z.
* `size_bytes > 10000000000` - The backup's size is greater than 10GB
pageSize number

Number of backups to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListBackupsResponse to the same parent and with the same filter.

options object <optional>

Call options. See CallOptions for more details.

listBackupsStream(request, optionsopt) → {Stream}

Equivalent to listBackups, but returns a NodeJS Stream object.

This fetches the paged responses for listBackups continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

filter string

An expression that filters the list of returned backups.

A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: <, >, <=, >=, !=, =, or :. Colon : is the contains operator. Filter rules are not case sensitive.

The following fields in the Backup are eligible for filtering:

* `name`
* `database`
* `state`
* `create_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
* `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
* `size_bytes`

You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic, but you can specify AND, OR, and NOT logic explicitly.

Here are a few examples:

* `name:Howl` - The backup's name contains the string "howl".
* `database:prod`
       - The database's name contains the string "prod".
* `state:CREATING` - The backup is pending creation.
* `state:READY` - The backup is fully created and ready for use.
* `(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")`
       - The backup name contains the string "howl" and `create_time`
           of the backup is before 2018-03-28T14:50:00Z.
* `expire_time < \"2018-03-28T14:50:00Z\"`
       - The backup `expire_time` is before 2018-03-28T14:50:00Z.
* `size_bytes > 10000000000` - The backup's size is greater than 10GB
pageSize number

Number of backups to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListBackupsResponse to the same parent and with the same filter.

options object <optional>

Call options. See CallOptions for more details.

See:

listDatabaseOperations(request, optionsopt) → {Promise}

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

filter string

An expression that filters the list of returned operations.

A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: <, >, <=, >=, !=, =, or :. Colon : is the contains operator. Filter rules are not case sensitive.

The following fields in the Operation are eligible for filtering:

* `name` - The name of the long-running operation
* `done` - False if the operation is in progress, else true.
* `metadata.@type` - the type of metadata. For example, the type string
   for RestoreDatabaseMetadata is
   `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`.
* `metadata.<field_name>` - any field in metadata.value.
* `error` - Error associated with the long-running operation.
* `response.@type` - the type of response.
* `response.<field_name>` - any field in response.value.

You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic. However, you can specify AND, OR, and NOT logic explicitly.

Here are a few examples:

* `done:true` - The operation is complete.
* `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` <br/>
  `(metadata.source_type:BACKUP) AND` <br/>
  `(metadata.backup_info.backup:backup_howl) AND` <br/>
  `(metadata.name:restored_howl) AND` <br/>
  `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` <br/>
  `(error:*)` - Return operations where:
  * The operation's metadata type is RestoreDatabaseMetadata.
  * The database is restored from a backup.
  * The backup name contains "backup_howl".
  * The restored database's name contains "restored_howl".
  * The operation started before 2018-03-28T14:50:00Z.
  * The operation resulted in an error.
pageSize number

Number of operations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListDatabaseOperationsResponse to the same parent and with the same filter.

options object <optional>

Call options. See CallOptions for more details.

listDatabaseOperationsAsync(request, optionsopt) → {Object}

Equivalent to listDatabaseOperations, but returns an iterable object.

for-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

filter string

An expression that filters the list of returned operations.

A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: <, >, <=, >=, !=, =, or :. Colon : is the contains operator. Filter rules are not case sensitive.

The following fields in the Operation are eligible for filtering:

* `name` - The name of the long-running operation
* `done` - False if the operation is in progress, else true.
* `metadata.@type` - the type of metadata. For example, the type string
   for RestoreDatabaseMetadata is
   `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`.
* `metadata.<field_name>` - any field in metadata.value.
* `error` - Error associated with the long-running operation.
* `response.@type` - the type of response.
* `response.<field_name>` - any field in response.value.

You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic. However, you can specify AND, OR, and NOT logic explicitly.

Here are a few examples:

* `done:true` - The operation is complete.
* `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` <br/>
  `(metadata.source_type:BACKUP) AND` <br/>
  `(metadata.backup_info.backup:backup_howl) AND` <br/>
  `(metadata.name:restored_howl) AND` <br/>
  `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` <br/>
  `(error:*)` - Return operations where:
  * The operation's metadata type is RestoreDatabaseMetadata.
  * The database is restored from a backup.
  * The backup name contains "backup_howl".
  * The restored database's name contains "restored_howl".
  * The operation started before 2018-03-28T14:50:00Z.
  * The operation resulted in an error.
pageSize number

Number of operations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListDatabaseOperationsResponse to the same parent and with the same filter.

options object <optional>

Call options. See CallOptions for more details.

listDatabaseOperationsStream(request, optionsopt) → {Stream}

Equivalent to listDatabaseOperations, but returns a NodeJS Stream object.

This fetches the paged responses for listDatabaseOperations continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

filter string

An expression that filters the list of returned operations.

A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: <, >, <=, >=, !=, =, or :. Colon : is the contains operator. Filter rules are not case sensitive.

The following fields in the Operation are eligible for filtering:

* `name` - The name of the long-running operation
* `done` - False if the operation is in progress, else true.
* `metadata.@type` - the type of metadata. For example, the type string
   for RestoreDatabaseMetadata is
   `type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata`.
* `metadata.<field_name>` - any field in metadata.value.
* `error` - Error associated with the long-running operation.
* `response.@type` - the type of response.
* `response.<field_name>` - any field in response.value.

You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic. However, you can specify AND, OR, and NOT logic explicitly.

Here are a few examples:

* `done:true` - The operation is complete.
* `(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND` <br/>
  `(metadata.source_type:BACKUP) AND` <br/>
  `(metadata.backup_info.backup:backup_howl) AND` <br/>
  `(metadata.name:restored_howl) AND` <br/>
  `(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` <br/>
  `(error:*)` - Return operations where:
  * The operation's metadata type is RestoreDatabaseMetadata.
  * The database is restored from a backup.
  * The backup name contains "backup_howl".
  * The restored database's name contains "restored_howl".
  * The operation started before 2018-03-28T14:50:00Z.
  * The operation resulted in an error.
pageSize number

Number of operations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListDatabaseOperationsResponse to the same parent and with the same filter.

options object <optional>

Call options. See CallOptions for more details.

See:

listDatabases(request, optionsopt) → {Promise}

Lists Cloud Spanner databases.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

pageSize number

Number of databases to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListDatabasesResponse.

options object <optional>

Call options. See CallOptions for more details.

listDatabasesAsync(request, optionsopt) → {Object}

Equivalent to listDatabases, but returns an iterable object.

for-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

pageSize number

Number of databases to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListDatabasesResponse.

options object <optional>

Call options. See CallOptions for more details.

listDatabasesStream(request, optionsopt) → {Stream}

Equivalent to listDatabases, but returns a NodeJS Stream object.

This fetches the paged responses for listDatabases continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

pageSize number

Number of databases to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListDatabasesResponse.

options object <optional>

Call options. See CallOptions for more details.

See:

matchBackupFromBackupName(backupName) → {string}

Parse the backup from Backup resource.

Parameters:
Name Type Description
backupName string

A fully-qualified path representing Backup resource.

matchDatabaseFromDatabaseName(databaseName) → {string}

Parse the database from Database resource.

Parameters:
Name Type Description
databaseName string

A fully-qualified path representing Database resource.

matchInstanceFromBackupName(backupName) → {string}

Parse the instance from Backup resource.

Parameters:
Name Type Description
backupName string

A fully-qualified path representing Backup resource.

matchInstanceFromDatabaseName(databaseName) → {string}

Parse the instance from Database resource.

Parameters:
Name Type Description
databaseName string

A fully-qualified path representing Database resource.

matchInstanceFromInstanceName(instanceName) → {string}

Parse the instance from Instance resource.

Parameters:
Name Type Description
instanceName string

A fully-qualified path representing Instance resource.

matchProjectFromBackupName(backupName) → {string}

Parse the project from Backup resource.

Parameters:
Name Type Description
backupName string

A fully-qualified path representing Backup resource.

matchProjectFromDatabaseName(databaseName) → {string}

Parse the project from Database resource.

Parameters:
Name Type Description
databaseName string

A fully-qualified path representing Database resource.

matchProjectFromInstanceName(instanceName) → {string}

Parse the project from Instance resource.

Parameters:
Name Type Description
instanceName string

A fully-qualified path representing Instance resource.

restoreDatabase(request, optionsopt) → {Promise}

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][google.longrunning.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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The name of the instance in which to create the restored database. This instance must be in the same project and have the same instance configuration as the instance containing the source backup. Values are of the form projects/<project>/instances/<instance>.

databaseId string

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>.

backup string

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

options object <optional>

Call options. See CallOptions for more details.

setIamPolicy(request, optionsopt) → {Promise}

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
resource string

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

policy 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.

options object <optional>

Call options. See CallOptions for more details.

testIamPermissions(request, optionsopt) → {Promise}

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
resource string

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

permissions Array.<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.

options object <optional>

Call options. See CallOptions for more details.

updateBackup(request, optionsopt) → {Promise}

Updates a pending or completed Backup.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
backup google.spanner.admin.database.v1.Backup

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.
updateMask google.protobuf.FieldMask

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.

options object <optional>

Call options. See CallOptions for more details.

updateDatabaseDdl(request, optionsopt) → {Promise}

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
database string

Required. The database to update.

statements Array.<string>

Required. DDL statements to be applied to the database.

operationId string

If empty, the new update request is assigned an automatically-generated operation ID. Otherwise, operation_id is used to construct the name of the resulting Operation.

Specifying an explicit operation ID simplifies determining whether the statements were executed in the event that the UpdateDatabaseDdl call is replayed, or the return value is otherwise lost: the database and operation_id fields can be combined to form the name of the resulting longrunning.Operation: <database>/operations/<operation_id>.

operation_id should be unique within the database, and must be a valid identifier: a-z*. Note that automatically-generated operation IDs always begin with an underscore. If the named operation already exists, UpdateDatabaseDdl returns ALREADY_EXISTS.

options object <optional>

Call options. See CallOptions for more details.