Module: Google::Cloud::Datastore
- Defined in:
- lib/google/cloud/datastore.rb,
lib/google/cloud/datastore/key.rb,
lib/google/cloud/datastore/query.rb,
lib/google/cloud/datastore/commit.rb,
lib/google/cloud/datastore/cursor.rb,
lib/google/cloud/datastore/entity.rb,
lib/google/cloud/datastore/errors.rb,
lib/google/cloud/datastore/convert.rb,
lib/google/cloud/datastore/dataset.rb,
lib/google/cloud/datastore/service.rb,
lib/google/cloud/datastore/version.rb,
lib/google/cloud/datastore/gql_query.rb,
lib/google/cloud/datastore/properties.rb,
lib/google/cloud/datastore/credentials.rb,
lib/google/cloud/datastore/transaction.rb,
lib/google/cloud/datastore/v1/doc/overview.rb,
lib/google/cloud/datastore/v1/datastore_client.rb,
lib/google/cloud/datastore/dataset/query_results.rb,
lib/google/cloud/datastore/read_only_transaction.rb,
lib/google/cloud/datastore/dataset/lookup_results.rb
Overview
Ruby Client for Google Cloud Datastore API (Alpha)
Google Cloud Datastore API: Accesses the schemaless NoSQL database to provide fully managed, robust, scalable storage for your application.
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 the Google Cloud Datastore API.
- Setup Authentication.
Installation
$ gem install google-cloud-datastore
Next Steps
- Read the Google Cloud Datastore 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: V1 Classes: Commit, Credentials, Cursor, Dataset, Entity, GqlQuery, Key, KeyError, Properties, PropertyError, Query, ReadOnlyTransaction, Transaction, TransactionError
Constant Summary collapse
- VERSION =
"1.4.0".freeze
Class Method Summary collapse
-
.configure {|Google::Cloud.configure.datastore| ... } ⇒ Google::Cloud::Config
Configure the Google Cloud Datastore library.
-
.new(project_id: nil, credentials: nil, scope: nil, timeout: nil, client_config: nil, emulator_host: nil, project: nil, keyfile: nil) ⇒ Google::Cloud::Datastore::Dataset
Creates a new object for connecting to the Datastore service.
Class Method Details
.configure {|Google::Cloud.configure.datastore| ... } ⇒ Google::Cloud::Config
Configure the Google Cloud Datastore library.
The following Datastore configuration parameters are supported:
project_id
- (String) Identifier for a Datastore 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.emulator_host
- (String) Host name of the emulator. Defaults toENV["DATASTORE_EMULATOR_HOST"]
673 674 675 676 677 |
# File 'lib/google/cloud/datastore.rb', line 673 def self.configure yield Google::Cloud.configure.datastore if block_given? Google::Cloud.configure.datastore end |
.new(project_id: nil, credentials: nil, scope: nil, timeout: nil, client_config: nil, emulator_host: nil, project: nil, keyfile: nil) ⇒ Google::Cloud::Datastore::Dataset
Creates a new object for connecting to the Datastore service. Each call creates a new connection.
For more information on connecting to Google Cloud see the Authentication Guide.
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 |
# File 'lib/google/cloud/datastore.rb', line 618 def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil, client_config: nil, emulator_host: 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 emulator_host ||= configure.emulator_host if emulator_host return Datastore::Dataset.new( Datastore::Service.new( project_id, :this_channel_is_insecure, host: emulator_host, client_config: client_config ) ) end credentials ||= (keyfile || default_credentials(scope: scope)) unless credentials.is_a? Google::Auth::Credentials credentials = Datastore::Credentials.new credentials, scope: scope end Datastore::Dataset.new( Datastore::Service.new( project_id, credentials, timeout: timeout, client_config: client_config ) ) end |