Module: Google::Cloud::Firestore

Defined in:
lib/google/cloud/firestore.rb,
lib/google/cloud/firestore/batch.rb,
lib/google/cloud/firestore/query.rb,
lib/google/cloud/firestore/client.rb,
lib/google/cloud/firestore/convert.rb,
lib/google/cloud/firestore/service.rb,
lib/google/cloud/firestore/v1beta1.rb,
lib/google/cloud/firestore/version.rb,
lib/google/cloud/firestore/generate.rb,
lib/google/cloud/firestore/field_path.rb,
lib/google/cloud/firestore/credentials.rb,
lib/google/cloud/firestore/field_value.rb,
lib/google/cloud/firestore/transaction.rb,
lib/google/cloud/firestore/commit_response.rb,
lib/google/cloud/firestore/document_snapshot.rb,
lib/google/cloud/firestore/document_reference.rb,
lib/google/cloud/firestore/collection_reference.rb,
lib/google/cloud/firestore/v1beta1/doc/overview.rb,
lib/google/cloud/firestore/v1beta1/firestore_client.rb

Overview

Ruby Client for Google Cloud Firestore API (Beta)

Google Cloud Firestore API:

Quick Start

In order to use this library, you first need to go through the following steps:

  1. Select or create a Cloud Platform project.
  2. Enable the Google Cloud Firestore API.
  3. Setup Authentication.

Installation

$ gem install google-cloud-firestore

Next Steps

Defined Under Namespace

Modules: V1beta1 Classes: Batch, Client, CollectionReference, CommitResponse, DocumentReference, DocumentSnapshot, FieldPath, FieldValue, Query, Transaction

Constant Summary collapse

VERSION =
"0.20.0"

Class Method Summary collapse

Class Method Details

.new(project_id: nil, credentials: nil, scope: nil, timeout: nil, client_config: nil, project: nil, keyfile: nil) ⇒ Google::Cloud::Firestore::Client

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

For more information on connecting to Google Cloud see the Authentication Guide.

Examples:

require "google/cloud/firestore"

firestore = Google::Cloud::Firestore.new

Parameters:

  • project_id (String)

    Identifier for a Firestore project. 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 Datastore::Credentials)

  • scope (String, Array<String>)

    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 scope is:

    • https://www.googleapis.com/auth/datastore
  • timeout (Integer)

    Default timeout to use in requests. Optional.

  • client_config (Hash)

    A hash of values to override the default behavior of the API client. Optional.

  • project (String)

    Alias for the project_id argument. Deprecated.

  • keyfile (String)

    Alias for the credentials argument. Deprecated.

Returns:



495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
# File 'lib/google/cloud/firestore.rb', line 495

def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil,
             client_config: nil, project: nil, keyfile: nil
  project_id ||= (project || Firestore::Service.default_project_id)
  project_id = project_id.to_s # Always cast to a string
  fail ArgumentError, "project_id is missing" if project_id.empty?

  credentials ||= keyfile
  credentials ||= Firestore::Credentials.default(scope: scope)
  unless credentials.is_a? Google::Auth::Credentials
    credentials = Firestore::Credentials.new credentials, scope: scope
  end

  Firestore::Client.new \
    Firestore::Service.new \
      project_id, credentials,
      timeout: timeout, client_config: client_config
end