Module: Google::Cloud

Defined in:
lib/google-cloud-spanner.rb,
lib/google/cloud/spanner.rb,
lib/google/cloud/spanner/data.rb,
lib/google/cloud/spanner/pool.rb,
lib/google/cloud/spanner/range.rb,
lib/google/cloud/spanner/backup.rb,
lib/google/cloud/spanner/client.rb,
lib/google/cloud/spanner/commit.rb,
lib/google/cloud/spanner/errors.rb,
lib/google/cloud/spanner/fields.rb,
lib/google/cloud/spanner/policy.rb,
lib/google/cloud/spanner/status.rb,
lib/google/cloud/spanner/convert.rb,
lib/google/cloud/spanner/project.rb,
lib/google/cloud/spanner/results.rb,
lib/google/cloud/spanner/service.rb,
lib/google/cloud/spanner/session.rb,
lib/google/cloud/spanner/version.rb,
lib/google/cloud/spanner/database.rb,
lib/google/cloud/spanner/instance.rb,
lib/google/cloud/spanner/snapshot.rb,
lib/google/cloud/spanner/partition.rb,
lib/google/cloud/spanner/backup/job.rb,
lib/google/cloud/spanner/backup/list.rb,
lib/google/cloud/spanner/batch_write.rb,
lib/google/cloud/spanner/credentials.rb,
lib/google/cloud/spanner/lar_headers.rb,
lib/google/cloud/spanner/transaction.rb,
lib/google/cloud/spanner/batch_client.rb,
lib/google/cloud/spanner/batch_update.rb,
lib/google/cloud/spanner/column_value.rb,
lib/google/cloud/spanner/database/job.rb,
lib/google/cloud/spanner/instance/job.rb,
lib/google/cloud/spanner/database/list.rb,
lib/google/cloud/spanner/instance/list.rb,
lib/google/cloud/spanner/admin/database.rb,
lib/google/cloud/spanner/admin/instance.rb,
lib/google/cloud/spanner/batch_snapshot.rb,
lib/google/cloud/spanner/mutation_group.rb,
lib/google/cloud/spanner/backup/job/list.rb,
lib/google/cloud/spanner/commit_response.rb,
lib/google/cloud/spanner/instance/config.rb,
lib/google/cloud/spanner/database/job/list.rb,
lib/google/cloud/spanner/backup/restore/job.rb,
lib/google/cloud/spanner/batch_write_results.rb,
lib/google/cloud/spanner/batch_update_results.rb,
lib/google/cloud/spanner/database/backup_info.rb,
lib/google/cloud/spanner/instance/config/list.rb,
lib/google/cloud/spanner/database/restore_info.rb,
lib/google/cloud/spanner/admin/database/credentials.rb,
lib/google/cloud/spanner/admin/instance/credentials.rb,
lib/google/cloud/spanner/commit_response/commit_stats.rb

Defined Under Namespace

Modules: Spanner

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

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

Examples:

require "google/cloud"

spanner = Google::Cloud.spanner

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 Google::Cloud::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.

Returns:



129
130
131
132
133
134
135
136
137
138
# File 'lib/google-cloud-spanner.rb', line 129

def self.spanner project_id = nil, credentials = nil, scope: nil,
                 timeout: nil, lib_name: nil, lib_version: nil
  require "google/cloud/spanner"
  Google::Cloud::Spanner.new project_id: project_id,
                             credentials: credentials,
                             scope: scope,
                             timeout: timeout,
                             lib_name: lib_name,
                             lib_version: lib_version
end

Instance Method Details

#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.

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

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.

Returns:



76
77
78
79
80
81
82
# File 'lib/google-cloud-spanner.rb', line 76

def spanner scope: nil, timeout: nil, lib_name: nil, lib_version: nil
  timeout ||= @timeout
  Google::Cloud.spanner @project, @keyfile, scope: scope,
                                            timeout: timeout,
                                            lib_name: lib_name,
                                            lib_version: lib_version
end