Cloud Spanner V1 Client - Class DatabaseAdminClient (1.80.0)

Reference documentation and code samples for the Cloud Spanner V1 Client class DatabaseAdminClient.

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

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 parseName method to extract the individual identifiers contained within formatted names that are returned by the API.

Namespace

Google \ Cloud \ Spanner \ Admin \ Database \ V1 \ Client

Methods

__construct

Constructor.

Setting the "SPANNER_EMULATOR_HOST" environment variable will automatically set the API Endpoint to the value specified in the variable, as well as ensure that empty credentials are used in the transport layer.

Parameters
Name Description
options array

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials string|array|FetchAuthTokenInterface|CredentialsWrapper

The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|TransportInterface

The transport used for executing network requests. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

copyBackup

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 destination backup. Concurrent CopyBackup requests can run on the same source backup.

The async variant is Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient::copyBackupAsync() .

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\CopyBackupRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse

createBackup

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.

The async variant is Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient::createBackupAsync() .

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\CreateBackupRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse

createDatabase

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.

The async variant is Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient::createDatabaseAsync() .

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\CreateDatabaseRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse

deleteBackup

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\DeleteBackupRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

dropDatabase

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.

The async variant is Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient::dropDatabaseAsync() .

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\DropDatabaseRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

getBackup

Gets metadata on a pending or completed Backup.

The async variant is Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient::getBackupAsync() .

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\GetBackupRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Spanner\Admin\Database\V1\Backup

getDatabase

Gets the state of a Cloud Spanner database.

The async variant is Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient::getDatabaseAsync() .

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\GetDatabaseRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Spanner\Admin\Database\V1\Database

getDatabaseDdl

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.

The async variant is Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient::getDatabaseDdlAsync() .

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\GetDatabaseDdlRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Spanner\Admin\Database\V1\GetDatabaseDdlResponse

getIamPolicy

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.

The async variant is Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient::getIamPolicyAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V1\GetIamPolicyRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Iam\V1\Policy

listBackupOperations

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.

The async variant is Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient::listBackupOperationsAsync() .

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\ListBackupOperationsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse

listBackups

Lists completed and pending backups.

Backups returned are ordered by create_time in descending order, starting from the most recent create_time.

The async variant is Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient::listBackupsAsync() .

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\ListBackupsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse

listDatabaseOperations

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.

The async variant is Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient::listDatabaseOperationsAsync() .

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\ListDatabaseOperationsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse

listDatabaseRoles

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\ListDatabaseRolesRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse

listDatabases

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\ListDatabasesRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse

restoreDatabase

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.

The async variant is Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient::restoreDatabaseAsync() .

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\RestoreDatabaseRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse

setIamPolicy

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.

The async variant is Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient::setIamPolicyAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V1\SetIamPolicyRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Iam\V1\Policy

testIamPermissions

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.

The async variant is Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient::testIamPermissionsAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V1\TestIamPermissionsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Iam\V1\TestIamPermissionsResponse

updateBackup

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\UpdateBackupRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Spanner\Admin\Database\V1\Backup

updateDatabase

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.

The async variant is Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient::updateDatabaseAsync() .

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse

updateDatabaseDdl

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.

The async variant is Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient::updateDatabaseDdlAsync() .

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseDdlRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse

copyBackupAsync

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\CopyBackupRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createBackupAsync

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\CreateBackupRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createDatabaseAsync

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\CreateDatabaseRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteBackupAsync

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\DeleteBackupRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

dropDatabaseAsync

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\DropDatabaseRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getBackupAsync

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\GetBackupRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getDatabaseAsync

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\GetDatabaseRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getDatabaseDdlAsync

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\GetDatabaseDdlRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getIamPolicyAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\GetIamPolicyRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listBackupOperationsAsync

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\ListBackupOperationsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listBackupsAsync

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\ListBackupsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listDatabaseOperationsAsync

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\ListDatabaseOperationsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listDatabaseRolesAsync

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\ListDatabaseRolesRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listDatabasesAsync

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\ListDatabasesRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

restoreDatabaseAsync

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\RestoreDatabaseRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

setIamPolicyAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\SetIamPolicyRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

testIamPermissionsAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\TestIamPermissionsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateBackupAsync

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\UpdateBackupRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateDatabaseAsync

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateDatabaseDdlAsync

Parameters
Name Description
request Google\Cloud\Spanner\Admin\Database\V1\UpdateDatabaseDdlRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getOperationsClient

Return an OperationsClient object with the same endpoint as $this.

Returns
Type Description
Google\ApiCore\LongRunning\OperationsClient

resumeOperation

Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.

Parameters
Name Description
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
Type Description
Google\ApiCore\OperationResponse

static::backupName

Formats a string containing the fully-qualified path to represent a backup resource.

Parameters
Name Description
project string
instance string
backup string
Returns
Type Description
string The formatted backup resource.

static::cryptoKeyName

Formats a string containing the fully-qualified path to represent a crypto_key resource.

Parameters
Name Description
project string
location string
keyRing string
cryptoKey string
Returns
Type Description
string The formatted crypto_key resource.

static::cryptoKeyVersionName

Formats a string containing the fully-qualified path to represent a crypto_key_version resource.

Parameters
Name Description
project string
location string
keyRing string
cryptoKey string
cryptoKeyVersion string
Returns
Type Description
string The formatted crypto_key_version resource.

static::databaseName

Formats a string containing the fully-qualified path to represent a database resource.

Parameters
Name Description
project string
instance string
database string
Returns
Type Description
string The formatted database resource.

static::instanceName

Formats a string containing the fully-qualified path to represent a instance resource.

Parameters
Name Description
project string
instance string
Returns
Type Description
string The formatted instance resource.

static::parseName

Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported: Template: Pattern

  • backup: projects/{project}/instances/{instance}/backups/{backup}
  • cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}
  • cryptoKeyVersion: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}
  • database: projects/{project}/instances/{instance}/databases/{database}
  • instance: projects/{project}/instances/{instance}

The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.

Parameters
Name Description
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
Type Description
array An associative array from name component IDs to component values.