class ProjectsInstancesDatabases extends Resource (View source)

The "databases" collection of methods.

Typical usage is:

 $spannerService = new Google\Service\Spanner(...);
 $databases = $spannerService->projects_instances_databases;

Methods

changequorum(string $name, ChangeQuorumRequest $postBody, array $optParams = [])

ChangeQuorum is strictly restricted to databases that use dual-region instance configurations. Initiates a background operation to change the quorum of a database from dual-region mode to single-region mode or vice versa. The returned long-running operation has a name of the format projects//instances//databases//operations/ and can be used to track execution of the ChangeQuorum. The metadata field type is ChangeQuorumMetadata. Authorization requires spanner.databases.changequorum permission on the resource database. (databases.changequorum)

create(string $parent, CreateDatabaseRequest $postBody, array $optParams = [])

Creates a new Spanner database and starts to prepare it for serving. The returned long-running operation will have a name of the format /operations/ and can be used to track preparation of the database. The metadata field type is CreateDatabaseMetadata. The response field type is Database, if successful. (databases.create)

dropDatabase(string $database, array $optParams = [])

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. (databases.dropDatabase)

get(string $name, array $optParams = [])

Gets the state of a Cloud Spanner database. (databases.get)

getDdl(string $database, array $optParams = [])

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. (databases.getDdl)

getIamPolicy(string $resource, GetIamPolicyRequest $postBody, array $optParams = [])

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.

getScans(string $name, array $optParams = [])

Request a specific scan with Database-specific data for Cloud Key Visualizer.

listProjectsInstancesDatabases(string $parent, array $optParams = [])

Lists Cloud Spanner databases. (databases.listProjectsInstancesDatabases)

patch(string $name, Database $postBody, array $optParams = [])

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//instances//databases//operations/ and can be used to track the database modification. The metadata field type is UpdateDatabaseMetadata. The response field type is Database, if successful.

restore(string $parent, RestoreDatabaseRequest $postBody, array $optParams = [])

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//instances//databases//operations/, 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.

setIamPolicy(string $resource, SetIamPolicyRequest $postBody, array $optParams = [])

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.

testIamPermissions(string $resource, TestIamPermissionsRequest $postBody, array $optParams = [])

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. (databases.testIamPermissions)

updateDdl(string $database, UpdateDatabaseDdlRequest $postBody, array $optParams = [])

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 /operations/ and can be used to track execution of the schema change(s). The metadata field type is UpdateDatabaseDdlMetadata. The operation has no response. (databases.updateDdl)

Details

Operation changequorum(string $name, ChangeQuorumRequest $postBody, array $optParams = [])

ChangeQuorum is strictly restricted to databases that use dual-region instance configurations. Initiates a background operation to change the quorum of a database from dual-region mode to single-region mode or vice versa. The returned long-running operation has a name of the format projects//instances//databases//operations/ and can be used to track execution of the ChangeQuorum. The metadata field type is ChangeQuorumMetadata. Authorization requires spanner.databases.changequorum permission on the resource database. (databases.changequorum)

Parameters

string $name

Required. Name of the database in which to apply ChangeQuorum. Values are of the form projects//instances//databases/.

ChangeQuorumRequest $postBody
array $optParams

Optional parameters.

Return Value

Operation

Exceptions

Exception

Operation create(string $parent, CreateDatabaseRequest $postBody, array $optParams = [])

Creates a new Spanner database and starts to prepare it for serving. The returned long-running operation will have a name of the format /operations/ and can be used to track preparation of the database. The metadata field type is CreateDatabaseMetadata. The response field type is Database, if successful. (databases.create)

Parameters

string $parent

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

CreateDatabaseRequest $postBody
array $optParams

Optional parameters.

Return Value

Operation

Exceptions

Exception

SpannerEmpty dropDatabase(string $database, array $optParams = [])

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. (databases.dropDatabase)

Parameters

string $database

Required. The database to be dropped.

array $optParams

Optional parameters.

Return Value

SpannerEmpty

Exceptions

Exception

Database get(string $name, array $optParams = [])

Gets the state of a Cloud Spanner database. (databases.get)

Parameters

string $name

Required. The name of the requested database. Values are of the form projects//instances//databases/.

array $optParams

Optional parameters.

Return Value

Database

Exceptions

Exception

GetDatabaseDdlResponse getDdl(string $database, array $optParams = [])

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. (databases.getDdl)

Parameters

string $database

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

array $optParams

Optional parameters.

Return Value

GetDatabaseDdlResponse

Exceptions

Exception

Policy getIamPolicy(string $resource, GetIamPolicyRequest $postBody, array $optParams = [])

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. (databases.getIamPolicy)

Parameters

string $resource

REQUIRED: The Cloud Spanner resource for which the policy is being retrieved. The format is projects//instances/ for instance resources and projects//instances//databases/ for database resources.

GetIamPolicyRequest $postBody
array $optParams

Optional parameters.

Return Value

Policy

Exceptions

Exception

Scan getScans(string $name, array $optParams = [])

Request a specific scan with Database-specific data for Cloud Key Visualizer.

(databases.getScans)

Parameters

string $name

Required. The unique name of the scan containing the requested information, specific to the Database service implementing this interface.

array $optParams

Optional parameters.

Return Value

Scan

Exceptions

Exception

ListDatabasesResponse listProjectsInstancesDatabases(string $parent, array $optParams = [])

Lists Cloud Spanner databases. (databases.listProjectsInstancesDatabases)

Parameters

string $parent

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

array $optParams

Optional parameters.

Return Value

ListDatabasesResponse

Exceptions

Exception

Operation patch(string $name, Database $postBody, array $optParams = [])

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//instances//databases//operations/ and can be used to track the database modification. The metadata field type is UpdateDatabaseMetadata. The response field type is Database, if successful.

(databases.patch)

Parameters

string $name

Required. The name of the database. Values are of the form projects//instances//databases/, where ` is as specified in the CREATE DATABASE` statement. This name can be passed to other API methods to identify the database.

Database $postBody
array $optParams

Optional parameters.

Return Value

Operation

Exceptions

Exception

Operation restore(string $parent, RestoreDatabaseRequest $postBody, array $optParams = [])

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//instances//databases//operations/, 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. (databases.restore)

Parameters

string $parent

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

RestoreDatabaseRequest $postBody
array $optParams

Optional parameters.

Return Value

Operation

Exceptions

Exception

Policy setIamPolicy(string $resource, SetIamPolicyRequest $postBody, array $optParams = [])

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.

(databases.setIamPolicy)

Parameters

string $resource

REQUIRED: The Cloud Spanner resource for which the policy is being set. The format is projects//instances/ for instance resources and projects//instances//databases/ for databases resources.

SetIamPolicyRequest $postBody
array $optParams

Optional parameters.

Return Value

Policy

Exceptions

Exception

TestIamPermissionsResponse testIamPermissions(string $resource, TestIamPermissionsRequest $postBody, array $optParams = [])

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. (databases.testIamPermissions)

Parameters

string $resource

REQUIRED: The Cloud Spanner resource for which permissions are being tested. The format is projects//instances/ for instance resources and projects//instances//databases/ for database resources.

TestIamPermissionsRequest $postBody
array $optParams

Optional parameters.

Return Value

TestIamPermissionsResponse

Exceptions

Exception

Operation updateDdl(string $database, UpdateDatabaseDdlRequest $postBody, array $optParams = [])

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 /operations/ and can be used to track execution of the schema change(s). The metadata field type is UpdateDatabaseDdlMetadata. The operation has no response. (databases.updateDdl)

Parameters

string $database

Required. The database to update.

UpdateDatabaseDdlRequest $postBody
array $optParams

Optional parameters.

Return Value

Operation

Exceptions

Exception