Reference documentation and code samples for the Cloud Spanner API module Google::Cloud::Spanner::Admin::Database.
Methods
.configure
defself.configure()->::Google::Cloud::Config
Configure the Google Cloud Spanner Database Admin library. This configuration can be
applied globally to all clients.
The following configuration parameters are supported:
credentials (type:String, Hash, Google::Auth::Credentials) -
The path to the keyfile as a String, the contents of the keyfile as a
Hash, or a Google::Auth::Credentials object.
lib_name (type:String) -
The library name as recorded in instrumentation and logging.
lib_version (type:String) -
The library version as recorded in instrumentation and logging.
interceptors (type:Array<GRPC::ClientInterceptor>) -
An array of interceptors that are run before calls are executed.
timeout (type:Numeric) -
Default timeout in seconds.
emulator_host - (String) Host name of the emulator. Defaults to
ENV["SPANNER_EMULATOR_HOST"].
metadata (type:Hash{Symbol=>String}) -
Additional gRPC headers to be sent with the call.
retry_policy (type:Hash) -
The retry policy. The value is a hash with the following keys:
:initial_delay (type:Numeric) - The initial delay in seconds.
:max_delay (type:Numeric) - The max delay in seconds.
:multiplier (type:Numeric) - The incremental backoff multiplier.
:retry_codes (type:Array<String>) -
The error codes that should trigger a retry.
Yields
(@configure)
Returns
(::Google::Cloud::Config) — The default configuration used by this library
Example
Modify the global config, setting the timeout to 10 seconds for all admin databases.
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.
For more information on connecting to Google Cloud see the
Authentication Guide.
Parameters
project_id (String) (defaults to: nil) — Project identifier for the Spanner service
you are connecting to. If not present, the default project for the
credentials is used.
credentials (String, Hash, Google::Auth::Credentials) (defaults to: nil) — The path to
the keyfile as a String, the contents of the keyfile as a Hash, or a
Google::Auth::Credentials object. (See Credentials)
If emulator_host is present, this becomes optional and the value is
internally overriden with :this_channel_is_insecure.
scope (String, Array<String>) (defaults to: nil) —
timeout (Integer) (defaults to: nil) — Default timeout to use in requests. Optional.
endpoint (String) (defaults to: nil) — Override of the endpoint host name. Optional.
If the param is nil, uses emulator_host or the default endpoint.
project (String) (defaults to: nil) — Alias for the project_id argument. Deprecated.
keyfile (String) (defaults to: nil) — Alias for the credentials argument.
Deprecated.
emulator_host (String) (defaults to: nil) — Spanner emulator host. Optional.
If the param is nil, uses the value of the emulator_host config.
lib_name (String) (defaults to: nil) — Library name. This will be added as a prefix
to the API call tracking header x-goog-api-client with provided
lib version for telemetry. Optional. For example prefix looks like
spanner-activerecord/0.0.1 gccl/1.13.1. Here,
spanner-activerecord/0.0.1 is provided custom library name and
version and gccl/1.13.1 represents the Cloud Spanner Ruby library
with version.
lib_version (String) (defaults to: nil) — Library version. This will be added as a
prefix to the API call tracking header x-goog-api-client with
provided lib name for telemetry. Optional. For example prefix look like
spanner-activerecord/0.0.1 gccl/1.13.1. Here,
spanner-activerecord/0.0.1 is provided custom library name and
version and gccl/1.13.1 represents the Cloud Spanner Ruby library
with version.
Returns
(Admin::Database::V1::DatabaseAdmin::Client) — A client object of version V1.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Cloud Spanner API - Module Google::Cloud::Spanner::Admin::Database (v2.27.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.27.0 (latest)](/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Admin-Database)\n- [2.26.0](/ruby/docs/reference/google-cloud-spanner/2.26.0/Google-Cloud-Spanner-Admin-Database)\n- [2.25.0](/ruby/docs/reference/google-cloud-spanner/2.25.0/Google-Cloud-Spanner-Admin-Database)\n- [2.24.0](/ruby/docs/reference/google-cloud-spanner/2.24.0/Google-Cloud-Spanner-Admin-Database)\n- [2.23.0](/ruby/docs/reference/google-cloud-spanner/2.23.0/Google-Cloud-Spanner-Admin-Database)\n- [2.22.0](/ruby/docs/reference/google-cloud-spanner/2.22.0/Google-Cloud-Spanner-Admin-Database)\n- [2.21.0](/ruby/docs/reference/google-cloud-spanner/2.21.0/Google-Cloud-Spanner-Admin-Database)\n- [2.20.0](/ruby/docs/reference/google-cloud-spanner/2.20.0/Google-Cloud-Spanner-Admin-Database)\n- [2.19.1](/ruby/docs/reference/google-cloud-spanner/2.19.1/Google-Cloud-Spanner-Admin-Database)\n- [2.18.1](/ruby/docs/reference/google-cloud-spanner/2.18.1/Google-Cloud-Spanner-Admin-Database)\n- [2.17.0](/ruby/docs/reference/google-cloud-spanner/2.17.0/Google-Cloud-Spanner-Admin-Database)\n- [2.16.1](/ruby/docs/reference/google-cloud-spanner/2.16.1/Google-Cloud-Spanner-Admin-Database)\n- [2.15.0](/ruby/docs/reference/google-cloud-spanner/2.15.0/Google-Cloud-Spanner-Admin-Database)\n- [2.14.0](/ruby/docs/reference/google-cloud-spanner/2.14.0/Google-Cloud-Spanner-Admin-Database)\n- [2.13.0](/ruby/docs/reference/google-cloud-spanner/2.13.0/Google-Cloud-Spanner-Admin-Database)\n- [2.12.1](/ruby/docs/reference/google-cloud-spanner/2.12.1/Google-Cloud-Spanner-Admin-Database)\n- [2.11.0](/ruby/docs/reference/google-cloud-spanner/2.11.0/Google-Cloud-Spanner-Admin-Database) \nReference documentation and code samples for the Cloud Spanner API module Google::Cloud::Spanner::Admin::Database.\n\nMethods\n-------\n\n### .configure\n\n def self.configure() -\u003e ::Google::Cloud::Config\n\nConfigure the Google Cloud Spanner Database Admin library. This configuration can be\napplied globally to all clients.\n\nThe following configuration parameters are supported:\n\n- `credentials` (*type:* `String, Hash, Google::Auth::Credentials`) - The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object.\n- `lib_name` (*type:* `String`) - The library name as recorded in instrumentation and logging.\n- `lib_version` (*type:* `String`) - The library version as recorded in instrumentation and logging.\n- `interceptors` (*type:* `Array\u003cGRPC::ClientInterceptor\u003e`) - An array of interceptors that are run before calls are executed.\n- `timeout` (*type:* `Numeric`) - Default timeout in seconds.\n- `emulator_host` - (String) Host name of the emulator. Defaults to `ENV[\"SPANNER_EMULATOR_HOST\"]`.\n- `metadata` (*type:* `Hash{Symbol=\u003eString}`) - Additional gRPC headers to be sent with the call.\n- `retry_policy` (*type:* `Hash`) - The retry policy. The value is a hash with the following keys:\n - `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.\n - `:max_delay` (*type:* `Numeric`) - The max delay in seconds.\n - `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.\n- `:retry_codes` (*type:* `Array\u003cString\u003e`) - The error codes that should trigger a retry. \n**Yields**\n\n- (@configure) \n**Returns**\n\n- (::Google::Cloud::Config) --- The default configuration used by this library\n**Example**\n\nModify the global config, setting the timeout to 10 seconds for all admin databases. \n\n```ruby\nrequire \"google/cloud/spanner/admin/database\"\n\n::Google::Cloud::Spanner::Admin::Database.configure do |config|\n config.timeout = 10.0\nend\n```\n\n### .database_admin\n\n def self.database_admin(project_id: nil, credentials: nil, universe_domain: nil, scope: nil, timeout: nil, endpoint: nil, project: nil, keyfile: nil, emulator_host: nil, lib_name: nil, lib_version: nil) -\u003e Admin::Database::V1::DatabaseAdmin::Client\n\nCreate a new client object for a DatabaseAdmin.\n\n\nThis returns an instance of\n[Google::Cloud::Spanner::Admin::Database::V1::DatabaseAdmin::Client](https://googleapis.dev/ruby/google-cloud-spanner-admin-database-v1/latest/Google/Cloud/Spanner/Admin/Database/V1/DatabaseAdmin/Client.html)\nfor version V1 of the API.\n\n#### About DatabaseAdmin\n\nGoogle Cloud Spanner Database Admin Service\n\nThe Cloud Spanner Database Admin API can be used to create, drop, and\nlist databases. It also enables updating the schema of pre-existing\ndatabases. It can be also used to create, delete and list backups for a\ndatabase and to restore from an existing backup.\n\n\u003cbr /\u003e\n\nFor more information on connecting to Google Cloud see the\n[Authentication Guide](./AUTHENTICATION \"Authentication Guide\"). \n**Parameters**\n\n- **project_id** (String) *(defaults to: nil)* --- Project identifier for the Spanner service you are connecting to. If not present, the default project for the credentials is used.\n- **credentials** (String, Hash, Google::Auth::Credentials) *(defaults to: nil)* --- The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See [Credentials](/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Credentials \"Google::Cloud::Spanner::Credentials (class)\")) If `emulator_host` is present, this becomes optional and the value is internally overriden with `:this_channel_is_insecure`.\n- **scope** (String, Array\\\u003cString\\\u003e) *(defaults to: nil)* ---\n\n The OAuth 2.0 scopes controlling\n the set of resources and operations that the connection can access.\n See [Using OAuth 2.0 to Access Google\n APIs](https://developers.google.com/identity/protocols/OAuth2).\n\n The default scopes are:\n - `https://www.googleapis.com/auth/spanner`\n - `https://www.googleapis.com/auth/spanner.data`\n- **timeout** (Integer) *(defaults to: nil)* --- Default timeout to use in requests. Optional.\n- **endpoint** (String) *(defaults to: nil)* --- Override of the endpoint host name. Optional. If the param is nil, uses `emulator_host` or the default endpoint.\n- **project** (String) *(defaults to: nil)* --- Alias for the `project_id` argument. Deprecated.\n- **keyfile** (String) *(defaults to: nil)* --- Alias for the `credentials` argument. Deprecated.\n- **emulator_host** (String) *(defaults to: nil)* --- Spanner emulator host. Optional. If the param is nil, uses the value of the `emulator_host` config.\n- **lib_name** (String) *(defaults to: nil)* --- Library name. This will be added as a prefix to the API call tracking header `x-goog-api-client` with provided lib version for telemetry. Optional. For example prefix looks like `spanner-activerecord/0.0.1 gccl/1.13.1`. Here, `spanner-activerecord/0.0.1` is provided custom library name and version and `gccl/1.13.1` represents the Cloud Spanner Ruby library with version.\n- **lib_version** (String) *(defaults to: nil)* --- Library version. This will be added as a prefix to the API call tracking header `x-goog-api-client` with provided lib name for telemetry. Optional. For example prefix look like `spanner-activerecord/0.0.1 gccl/1.13.1`. Here, `spanner-activerecord/0.0.1` is provided custom library name and version and `gccl/1.13.1` represents the Cloud Spanner Ruby library with version. \n**Returns**\n\n- (Admin::Database::V1::DatabaseAdmin::Client) --- A client object of version V1. \n**Raises**\n\n- (ArgumentError)\n\nConstants\n---------\n\n### Credentials\n\n**value:**V1::DatabaseAdmin::Credentials"]]