Module: Google::Cloud::Spanner
- Defined in:
- 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/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/credentials.rb,
lib/google/cloud/spanner/transaction.rb,
lib/google/cloud/spanner/batch_client.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/instance/config.rb,
lib/google/cloud/spanner/v1/doc/overview.rb,
lib/google/cloud/spanner/v1/spanner_client.rb,
lib/google/cloud/spanner/instance/config/list.rb,
lib/google/cloud/spanner/admin/database/credentials.rb,
lib/google/cloud/spanner/admin/instance/credentials.rb,
lib/google/cloud/spanner/admin/database/v1/doc/overview.rb,
lib/google/cloud/spanner/admin/instance/v1/doc/overview.rb,
lib/google/cloud/spanner/admin/database/v1/database_admin_client.rb,
lib/google/cloud/spanner/admin/instance/v1/instance_admin_client.rb
Overview
Ruby Client for Cloud Spanner API (GA)
Cloud Spanner API: Cloud Spanner is a managed, mission-critical, globally consistent and scalable relational database service.
Quick Start
In order to use this library, you first need to go through the following steps:
- Select or create a Cloud Platform project.
- Enable billing for your project.
- Enable the Cloud Spanner API.
- Setup Authentication.
Installation
$ gem install google-cloud-spanner
Next Steps
- Read the Cloud Spanner API Product documentation to learn more about the product and see How-to Guides.
- View this repository's main README to see the full list of Cloud APIs that we cover.
Defined Under Namespace
Modules: Admin, V1 Classes: BatchClient, BatchSnapshot, Client, ClientClosedError, ColumnValue, Commit, Credentials, Data, Database, DuplicateNameError, Fields, Instance, Partition, Policy, Project, Range, Results, Rollback, SessionLimitError, Snapshot, Status, Transaction
Constant Summary collapse
- VERSION =
"1.5.0".freeze
Class Method Summary collapse
-
.configure {|Google::Cloud.configure.spanner| ... } ⇒ Google::Cloud::Config
Configure the Google Cloud Spanner library.
-
.new(project_id: nil, credentials: nil, scope: nil, timeout: nil, client_config: nil, project: nil, keyfile: nil) ⇒ Google::Cloud::Spanner::Project
Creates a new object for connecting to the Spanner service.
Class Method Details
.configure {|Google::Cloud.configure.spanner| ... } ⇒ 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 parameterproject
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) (The parameterkeyfile
is considered deprecated, but may also be used.)scope
- (String, Array) The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. timeout
- (Integer) Default timeout to use in requests.client_config
- (Hash) A hash of values to override the default behavior of the API client.
459 460 461 462 463 |
# File 'lib/google/cloud/spanner.rb', line 459 def self.configure yield Google::Cloud.configure.spanner if block_given? Google::Cloud.configure.spanner end |
.new(project_id: nil, credentials: nil, scope: nil, timeout: nil, client_config: nil, project: nil, keyfile: 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.
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'lib/google/cloud/spanner.rb', line 417 def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil, client_config: nil, project: nil, keyfile: nil project_id ||= (project || default_project_id) project_id = project_id.to_s # Always cast to a string raise ArgumentError, "project_id is missing" if project_id.empty? scope ||= configure.scope timeout ||= configure.timeout client_config ||= configure.client_config credentials ||= (keyfile || default_credentials(scope: scope)) unless credentials.is_a? Google::Auth::Credentials credentials = Spanner::Credentials.new credentials, scope: scope end Spanner::Project.new( Spanner::Service.new( project_id, credentials, timeout: timeout, client_config: client_config ) ) end |