Cloud Spanner API - Module Google::Cloud::Spanner (v2.15.0)

Methods

.configure

defself.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. (Theparameterproject is considered deprecated, but may also be used.)
  • credentials - (String, Hash, Google::Auth::Credentials) The path tothe keyfile as a String, the contents of the keyfile as a Hash, or aGoogle::Auth::Credentials object. (SeeCredentials) (Theparameterkeyfile is considered deprecated, but may also be used.)
  • scope - (String, Array
  • quota_project - (String) The project ID for a project that can beused by client libraries for quota and billing purposes.
  • timeout - (Integer) Default timeout to use in requests.
  • endpoint - (String) Override of the endpoint host name, ornilto use the default endpoint.
  • emulator_host - (String) Host name of the emulator. Defaults toENV["SPANNER_EMULATOR_HOST"].
  • lib_name - (String) Override the lib name , ornilto use the default lib name without prefix in agent trackingheader.
  • lib_version - (String) Override the lib version , ornilto use the default version lib name without prefix in agenttracking header.
Yields
  • (Google::Cloud.configure.spanner)
Returns
  • (Google::Cloud::Config) — The configuration object theGoogle::Cloud::Spanner library uses.

.new

defself.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)->Google::Cloud::Spanner::Project

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

For more information on connecting to Google Cloud see theAuthentication Guide.

Parameters
  • project_id (String)(defaults to: nil) — Project identifier for the Spanner serviceyou are connecting to. If not present, the default project for thecredentials is used.
  • credentials (String, Hash, Google::Auth::Credentials)(defaults to: nil) — The path tothe keyfile as a String, the contents of the keyfile as a Hash, or aGoogle::Auth::Credentials object. (SeeCredentials)Ifemulator_host is present, this becomes optional and the value isinternally overriden with:this_channel_is_insecure.
  • scope (String, Array<String>)(defaults to: nil)

    The OAuth 2.0 scopes controllingthe set of resources and operations that the connection can access.SeeUsing OAuth 2.0 to Access GoogleAPIs.

    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, usesemulator_host or the default endpoint.
  • project (String)(defaults to: nil) — Alias for theproject_id argument. Deprecated.
  • keyfile (String)(defaults to: nil) — Alias for thecredentials argument.Deprecated.
  • emulator_host (String)(defaults to: nil) — Spanner emulator host. Optional.If the param is nil, uses the value of theemulator_host config.
  • lib_name (String)(defaults to: nil) — Library name. This will be added as a prefixto the API call tracking headerx-goog-api-client with providedlib version for telemetry. Optional. For example prefix looks likespanner-activerecord/0.0.1 gccl/1.13.1. Here,spanner-activerecord/0.0.1 is provided custom library name andversion andgccl/1.13.1 represents the Cloud Spanner Ruby librarywith version.
  • lib_version (String)(defaults to: nil) — Library version. This will be added as aprefix to the API call tracking headerx-goog-api-client withprovided lib name for telemetry. Optional. For example prefix look likespanner-activerecord/0.0.1 gccl/1.13.1. Here,spanner-activerecord/0.0.1 is provided custom library name andversion andgccl/1.13.1 represents the Cloud Spanner Ruby librarywith version.
Raises
  • (ArgumentError)
Example
require"google/cloud/spanner"spanner=Google::Cloud::Spanner.new

Constants

VERSION

value:"2.15.0".freeze

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-11-17 UTC.