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.
The options accepted by the constructor are described in detail
in this document.
The common options are:
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.
clientConfig
gax.ClientConfig
<optional>
Client configuration override.
Follows the structure of gapicConfig.
fallback
boolean
<optional>
Use HTTP fallback mode.
In fallback mode, a special browser-compatible transport implementation is used
instead of gRPC transport. In browser context (if the window object is defined)
the fallback mode is enabled automatically; set options.fallback to false
if you need to override this behavior.
Members
apiEndpoint
The DNS address for this API service - same as servicePath(),
exists for compatibility reasons.
port
The port for this API service.
scopes
The scopes needed to make gRPC calls for every method defined
in this service.
servicePath
The DNS address for this API service.
Methods
backupPath(project, instance, backup) → {string}
Return a fully-qualified backup resource name string.
Check the status of the long running operation returned by createBackup().
Parameters:
Name
Type
Description
name
String
The operation name that will be passed.
Returns:
Type
Description
Promise
The promise which resolves to an object.
The decoded operation object has result and metadata field to get information from.
Please see the
documentation
for more details and examples.
Check the status of the long running operation returned by createDatabase().
Parameters:
Name
Type
Description
name
String
The operation name that will be passed.
Returns:
Type
Description
Promise
The promise which resolves to an object.
The decoded operation object has result and metadata field to get information from.
Please see the
documentation
for more details and examples.
Check the status of the long running operation returned by restoreDatabase().
Parameters:
Name
Type
Description
name
String
The operation name that will be passed.
Returns:
Type
Description
Promise
The promise which resolves to an object.
The decoded operation object has result and metadata field to get information from.
Please see the
documentation
for more details and examples.
Check the status of the long running operation returned by updateDatabaseDdl().
Parameters:
Name
Type
Description
name
String
The operation name that will be passed.
Returns:
Type
Description
Promise
The promise which resolves to an object.
The decoded operation object has result and metadata field to get information from.
Please see the
documentation
for more details and examples.
The client will no longer be usable and all future behavior is undefined.
Returns:
Type
Description
Promise
A promise that resolves when the client is closed.
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
Attributes
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>.
Optional. The encryption configuration used to encrypt the backup. If this field is
not specified, the backup will use the same
encryption configuration as the database by default, namely
encryption_type =
USE_DATABASE_ENCRYPTION.
The promise which resolves to an array.
The first element of the array is an object representing
a long running operation. Its promise() method returns a promise
you can await for.
Please see the
documentation
for more details and examples.
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.
Optional. The encryption configuration for the database. If this field is not
specified, Cloud Spanner will encrypt/decrypt all data at rest using
Google default encryption.
The promise which resolves to an array.
The first element of the array is an object representing
a long running operation. Its promise() method returns a promise
you can await for.
Please see the
documentation
for more details and examples.
The promise which resolves to an array.
The first element of the array is an object representing Empty.
Please see the
documentation
for more details and examples.
The promise which resolves to an array.
The first element of the array is an object representing Empty.
Please see the
documentation
for more details and examples.
The promise which resolves to an array.
The first element of the array is an object representing Backup.
Please see the
documentation
for more details and examples.
The promise which resolves to an array.
The first element of the array is an object representing Database.
Please see the
documentation
for more details and examples.
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.
Values are of the form
projects/<project>/instances/<instance>/databases/<database>
The promise which resolves to an array.
The first element of the array is an object representing GetDatabaseDdlResponse.
Please see the
documentation
for more details and examples.
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.
The promise which resolves to an array.
The first element of the array is an object representing Policy.
Please see the
documentation
for more details and examples.
A promise that resolves to string containing the 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.
Returns:
Type
Description
Promise
A promise that resolves to an authenticated service stub.
instancePath(project, instance) → {string}
Return a fully-qualified instance resource name string.
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` \
`(metadata.name:howl) AND` \
`(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \
`(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.
The promise which resolves to an array.
The first element of the array is Array of Operation.
The client library will perform auto-pagination by default: it will call the API as many
times as needed and will merge results from all the pages into this array.
Note that it can affect your quota.
We recommend using listBackupOperationsAsync()
method described below for async iteration which you can stop as needed.
Please see the
documentation
for more details and examples.
Equivalent to listBackupOperations, but returns an iterable object.
for-await-of syntax is used with the iterable to get response elements 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` \
`(metadata.name:howl) AND` \
`(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \
`(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.
An iterable Object that allows async iteration.
When you iterate the returned iterable, each element will be an object representing
Operation. The API will be called under the hood as needed, once per the page,
so you can stop the iteration when you don't need more results.
Please see the
documentation
for more details and examples.
Example
const iterable = client.listBackupOperationsAsync(request);
for await (const response of iterable) {
// process response
}
Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.
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` \
`(metadata.name:howl) AND` \
`(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \
`(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.
An object stream which emits an object representing Operation on 'data' event.
The client library will perform auto-pagination by default: it will call the API as many
times as needed. Note that it can affect your quota.
We recommend using listBackupOperationsAsync()
method described below for async iteration which you can stop as needed.
Please see the
documentation
for more details and examples.
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)
* `version_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.
The promise which resolves to an array.
The first element of the array is Array of Backup.
The client library will perform auto-pagination by default: it will call the API as many
times as needed and will merge results from all the pages into this array.
Note that it can affect your quota.
We recommend using listBackupsAsync()
method described below for async iteration which you can stop as needed.
Please see the
documentation
for more details and examples.
listBackupsAsync(request, optionsopt) → {Object}
Equivalent to listBackups, but returns an iterable object.
for-await-of syntax is used with the iterable to get response elements 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)
* `version_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.
An iterable Object that allows async iteration.
When you iterate the returned iterable, each element will be an object representing
Backup. The API will be called under the hood as needed, once per the page,
so you can stop the iteration when you don't need more results.
Please see the
documentation
for more details and examples.
Example
const iterable = client.listBackupsAsync(request);
for await (const response of iterable) {
// process response
}
listBackupsStream(request, optionsopt) → {Stream}
Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.
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)
* `version_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.
An object stream which emits an object representing Backup on 'data' event.
The client library will perform auto-pagination by default: it will call the API as many
times as needed. Note that it can affect your quota.
We recommend using listBackupsAsync()
method described below for async iteration which you can stop as needed.
Please see the
documentation
for more details and examples.
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` \
`(metadata.source_type:BACKUP) AND` \
`(metadata.backup_info.backup:backup_howl) AND` \
`(metadata.name:restored_howl) AND` \
`(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \
`(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.
The promise which resolves to an array.
The first element of the array is Array of Operation.
The client library will perform auto-pagination by default: it will call the API as many
times as needed and will merge results from all the pages into this array.
Note that it can affect your quota.
We recommend using listDatabaseOperationsAsync()
method described below for async iteration which you can stop as needed.
Please see the
documentation
for more details and examples.
Equivalent to listDatabaseOperations, but returns an iterable object.
for-await-of syntax is used with the iterable to get response elements 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` \
`(metadata.source_type:BACKUP) AND` \
`(metadata.backup_info.backup:backup_howl) AND` \
`(metadata.name:restored_howl) AND` \
`(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \
`(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.
An iterable Object that allows async iteration.
When you iterate the returned iterable, each element will be an object representing
Operation. The API will be called under the hood as needed, once per the page,
so you can stop the iteration when you don't need more results.
Please see the
documentation
for more details and examples.
Example
const iterable = client.listDatabaseOperationsAsync(request);
for await (const response of iterable) {
// process response
}
Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.
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` \
`(metadata.source_type:BACKUP) AND` \
`(metadata.backup_info.backup:backup_howl) AND` \
`(metadata.name:restored_howl) AND` \
`(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND` \
`(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.
An object stream which emits an object representing Operation on 'data' event.
The client library will perform auto-pagination by default: it will call the API as many
times as needed. Note that it can affect your quota.
We recommend using listDatabaseOperationsAsync()
method described below for async iteration which you can stop as needed.
Please see the
documentation
for more details and examples.
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.
The promise which resolves to an array.
The first element of the array is Array of Database.
The client library will perform auto-pagination by default: it will call the API as many
times as needed and will merge results from all the pages into this array.
Note that it can affect your quota.
We recommend using listDatabasesAsync()
method described below for async iteration which you can stop as needed.
Please see the
documentation
for more details and examples.
An iterable Object that allows async iteration.
When you iterate the returned iterable, each element will be an object representing
Database. The API will be called under the hood as needed, once per the page,
so you can stop the iteration when you don't need more results.
Please see the
documentation
for more details and examples.
Example
const iterable = client.listDatabasesAsync(request);
for await (const response of iterable) {
// process response
}
An object stream which emits an object representing Database on 'data' event.
The client library will perform auto-pagination by default: it will call the API as many
times as needed. Note that it can affect your quota.
We recommend using listDatabasesAsync()
method described below for async iteration which you can stop as needed.
Please see the
documentation
for more details and examples.
matchBackupFromBackupName(backupName) → {string}
Parse the backup from Backup resource.
Parameters:
Name
Type
Description
backupName
string
A fully-qualified path representing Backup resource.
A fully-qualified path representing Instance resource.
Returns:
Type
Description
string
A string representing the project.
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
Attributes
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>.
Optional. An encryption configuration describing the encryption type and key
resources in Cloud KMS used to encrypt/decrypt the database to restore to.
If this field is not specified, the restored database will use
the same encryption configuration as the backup by default, namely
encryption_type =
USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION.
The promise which resolves to an array.
The first element of the array is an object representing
a long running operation. Its promise() method returns a promise
you can await for.
Please see the
documentation
for more details and examples.
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.
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.
The promise which resolves to an array.
The first element of the array is an object representing Policy.
Please see the
documentation
for more details and examples.
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.
The promise which resolves to an array.
The first element of the array is an object representing TestIamPermissionsResponse.
Please see the
documentation
for more details and examples.
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:
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.
The promise which resolves to an array.
The first element of the array is an object representing Backup.
Please see the
documentation
for more details and examples.
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.
The promise which resolves to an array.
The first element of the array is an object representing
a long running operation. Its promise() method returns a promise
you can await for.
Please see the
documentation
for more details and examples.