Package google.spanner.admin.database.v1

Index

DatabaseAdmin

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.

CreateDatabase

rpc CreateDatabase(CreateDatabaseRequest) returns (Operation)

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.

Authorization

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/spanner.admin
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

DropDatabase

rpc DropDatabase(DropDatabaseRequest) returns (Empty)

Drops (aka deletes) a Cloud Spanner database.

Authorization

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/spanner.admin
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

GetDatabase

rpc GetDatabase(GetDatabaseRequest) returns (Database)

Gets the state of a Cloud Spanner database.

Authorization

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/spanner.admin
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

GetDatabaseDdl

rpc GetDatabaseDdl(GetDatabaseDdlRequest) returns (GetDatabaseDdlResponse)

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.

Authorization

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/spanner.admin
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

GetIamPolicy

rpc GetIamPolicy(GetIamPolicyRequest) returns (Policy)

Gets the access control policy for a database resource. Returns an empty policy if a database exists but does not have a policy set.

Authorization requires spanner.databases.getIamPolicy permission on resource.

Authorization

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/spanner.admin
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

ListDatabases

rpc ListDatabases(ListDatabasesRequest) returns (ListDatabasesResponse)

Lists Cloud Spanner databases.

Authorization

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/spanner.admin
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

SetIamPolicy

rpc SetIamPolicy(SetIamPolicyRequest) returns (Policy)

Sets the access control policy on a database resource. Replaces any existing policy.

Authorization requires spanner.databases.setIamPolicy permission on resource.

Authorization

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/spanner.admin
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

TestIamPermissions

rpc TestIamPermissions(TestIamPermissionsRequest) returns (TestIamPermissionsResponse)

Returns permissions that the caller has on the specified database 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.

Authorization

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/spanner.admin
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

UpdateDatabaseDdl

rpc UpdateDatabaseDdl(UpdateDatabaseDdlRequest) returns (Operation)

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.

Authorization

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/spanner.admin
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Auth Guide.

CreateDatabaseMetadata

Metadata type for the operation returned by CreateDatabase.

Fields
database

string

The database being created.

CreateDatabaseRequest

The request for CreateDatabase.

Fields
parent

string

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

Authorization requires the following Google IAM permission on the specified resource parent:

  • spanner.databases.create

create_statement

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_\-]*[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 (`).

extra_statements[]

string

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

Database

A Cloud Spanner database.

Fields
name

string

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

state

State

Output only. The current database state.

State

Indicates the current state of the database.

Enums
STATE_UNSPECIFIED Not specified.
CREATING The database is still being created. Operations on the database may fail with FAILED_PRECONDITION in this state.
READY The database is fully created and ready for use.

DropDatabaseRequest

The request for DropDatabase.

Fields
database

string

Required. The database to be dropped.

Authorization requires the following Google IAM permission on the specified resource database:

  • spanner.databases.drop

GetDatabaseDdlRequest

The request for GetDatabaseDdl.

Fields
database

string

Required. The database whose schema we wish to get.

Authorization requires the following Google IAM permission on the specified resource database:

  • spanner.databases.getDdl

GetDatabaseDdlResponse

The response for GetDatabaseDdl.

Fields
statements[]

string

A list of formatted DDL statements defining the schema of the database specified in the request.

GetDatabaseRequest

The request for GetDatabase.

Fields
name

string

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

Authorization requires the following Google IAM permission on the specified resource name:

  • spanner.databases.get

ListDatabasesRequest

The request for ListDatabases.

Fields
parent

string

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

Authorization requires the following Google IAM permission on the specified resource parent:

  • spanner.databases.list

page_size

int32

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

page_token

string

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

ListDatabasesResponse

The response for ListDatabases.

Fields
databases[]

Database

Databases that matched the request.

next_page_token

string

next_page_token can be sent in a subsequent ListDatabases call to fetch more of the matching databases.

UpdateDatabaseDdlMetadata

Metadata type for the operation returned by UpdateDatabaseDdl.

Fields
database

string

The database being modified.

statements[]

string

For an update this list contains all the statements. For an individual statement, this list contains only that statement.

commit_timestamps[]

Timestamp

Reports the commit timestamps of all statements that have succeeded so far, where commit_timestamps[i] is the commit timestamp for the statement statements[i].

UpdateDatabaseDdlRequest

Enqueues the given DDL statements to be applied, in order but not necessarily all at once, to the database schema at some point (or points) in the future. The server checks that the statements are executable (syntactically valid, name tables that exist, etc.) before enqueueing them, but they may still fail upon later execution (e.g., if a statement from another batch of statements is applied first and it conflicts in some way, or if there is some data-related problem like a NULL value in a column to which NOT NULL would be added). If a statement fails, all subsequent statements in the batch are automatically cancelled.

Each batch of statements is assigned a name which can be used with the Operations API to monitor progress. See the operation_id field for more details.

Fields
database

string

Required. The database to update.

Authorization requires the following Google IAM permission on the specified resource database:

  • spanner.databases.updateDdl

statements[]

string

DDL statements to be applied to the database.

operation_id

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][a-z0-9_]*. Note that automatically-generated operation IDs always begin with an underscore. If the named operation already exists, UpdateDatabaseDdl returns ALREADY_EXISTS.

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Cloud Spanner Documentation