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

Reference documentation and code samples for the Cloud Spanner API module Google::Cloud.

Methods

.spanner

def self.spanner(project_id = nil, credentials = nil, scope: nil, timeout: 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 the Authentication Guide.

Parameters
  • project_id (String) — 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) — The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See Spanner::Credentials)
  • 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.

    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.
  • 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.
Example
require "google/cloud"

spanner = Google::Cloud.spanner

#spanner

def spanner(scope: nil, timeout: 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 the Authentication Guide.

Parameters
  • 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.

    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.
  • 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.
Examples
require "google/cloud"

gcloud = Google::Cloud.new
spanner = gcloud.spanner

The default scope can be overridden with the scope option:

require "google/cloud"

gcloud  = Google::Cloud.new
platform_scope = "https://www.googleapis.com/auth/cloud-platform"
spanner = gcloud.spanner scope: platform_scope