# Cloud Spanner API - Module Google::Cloud::Spanner (v2.36.0)

2.36.0 (latest) 2.35.0 2.34.0 2.33.0 2.32.0 2.31.0 2.30.0 2.29.0 2.28.0 2.27.0 2.26.0 2.25.0 2.24.0 2.23.0 2.22.0 2.21.0 2.20.0 2.19.1 2.18.1 2.17.0 2.16.1 2.15.0 2.14.0 2.13.0 2.12.1 2.11.0 Reference documentation and code samples for the Cloud Spanner API module Google::Cloud::Spanner.

## Cloud Spanner

Cloud Spanner is a fully managed, mission-critical, relational database
service that offers transactional consistency at global scale, schemas,
SQL (ANSI 2011 with extensions), and automatic, synchronous replication
for high availability.

For more information about Cloud Spanner, read the [Cloud
Spanner Documentation](https://cloud.google.com/spanner/docs/).

See [Spanner Overview](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/index.html "Spanner Overview").

## Methods

### .configure

    def self.configure() -> Google::Cloud::Config

Configure the Google Cloud Spanner library.

The following Spanner configuration parameters are supported:

- `project_id` - (String) Identifier for a Spanner project. (The parameter `project` is considered deprecated, but may also be used.)
- `credentials` - (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. (See [Credentials](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Credentials "Google::Cloud::Spanner::Credentials (class)")) (The parameter `keyfile` is considered deprecated, but may also be used.)
- `scope` - (String, Array
- `quota_project` - (String) The project ID for a project that can be used by client libraries for quota and billing purposes.
- `timeout` - (Integer) Default timeout to use in requests.
- `endpoint` - (String) Override of the endpoint host name, or `nil` to use the default endpoint.
- `emulator_host` - (String) Host name of the emulator. Defaults to `ENV["SPANNER_EMULATOR_HOST"]`.
- `lib_name` - (String) Override the lib name , or `nil` to use the default lib name without prefix in agent tracking header.
- `lib_version` - (String) Override the lib version , or `nil` to use the default version lib name without prefix in agent tracking header.
**Yields**

- (Google::Cloud.configure.spanner)
**Returns**

- (Google::Cloud::Config) --- The configuration object the Google::Cloud::Spanner library uses.

### .new

    def self.new(project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil, project: nil, keyfile: nil, emulator_host: nil, lib_name: nil, lib_version: nil, enable_leader_aware_routing: true, universe_domain: nil, process_id: nil) -> Google::Cloud::Spanner::Project

Creates a new object for connecting to the Spanner service.
Each call creates a new connection.


<br />

For more information on connecting to Google Cloud see the
[Authentication Guide](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/AUTHENTICATION "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](https://docs.cloud.google.com/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`.
- **scope** (String, Array\<String\>) *(defaults to: nil)* ---

  The OAuth 2.0 scopes controlling
  the set of resources and operations that the connection can access.
  See [Using OAuth 2.0 to Access Google
  APIs](https://developers.google.com/identity/protocols/OAuth2).

  The default scopes are:
  - `https://www.googleapis.com/auth/spanner`
  - `https://www.googleapis.com/auth/spanner.data`
- **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.
- **enable_leader_aware_routing** (Boolean) *(defaults to: true)* --- Specifies whether Leader Aware Routing should be enabled. Defaults to true.
- **universe_domain** (String) *(defaults to: nil)* --- A custom universe domain. Optional.
**Returns**

- ([Google::Cloud::Spanner::Project](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Project))
**Raises**

- (ArgumentError)
**Example**

```ruby
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new
```

## Constants

### VERSION

**value:**"2.36.0".freeze