Module: Google::Cloud

Defined in:
lib/google-cloud-firestore.rb,
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/errors.rb,
lib/google/cloud/firestore/filter.rb,
lib/google/cloud/firestore/convert.rb,
lib/google/cloud/firestore/service.rb,
lib/google/cloud/firestore/version.rb,
lib/google/cloud/firestore/generate.rb,
lib/google/cloud/firestore/field_path.rb,
lib/google/cloud/firestore/bulk_writer.rb,
lib/google/cloud/firestore/credentials.rb,
lib/google/cloud/firestore/field_value.rb,
lib/google/cloud/firestore/transaction.rb,
lib/google/cloud/firestore/watch/order.rb,
lib/google/cloud/firestore/rate_limiter.rb,
lib/google/cloud/firestore/resource_path.rb,
lib/google/cloud/firestore/promise/future.rb,
lib/google/cloud/firestore/query_listener.rb,
lib/google/cloud/firestore/query_snapshot.rb,
lib/google/cloud/firestore/watch/listener.rb,
lib/google/cloud/firestore/aggregate_query.rb,
lib/google/cloud/firestore/commit_response.rb,
lib/google/cloud/firestore/document_change.rb,
lib/google/cloud/firestore/query_partition.rb,
lib/google/cloud/firestore/watch/inventory.rb,
lib/google/cloud/firestore/collection_group.rb,
lib/google/cloud/firestore/bulk_commit_batch.rb,
lib/google/cloud/firestore/document_listener.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/bulk_writer_exception.rb,
lib/google/cloud/firestore/bulk_writer_operation.rb,
lib/google/cloud/firestore/bulk_writer_scheduler.rb,
lib/google/cloud/firestore/watch/enumerator_queue.rb,
lib/google/cloud/firestore/document_reference/list.rb,
lib/google/cloud/firestore/aggregate_query_snapshot.rb,
lib/google/cloud/firestore/collection_reference_list.rb

Defined Under Namespace

Modules: Firestore

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.firestore(project_id = nil, credentials = nil, scope: nil, timeout: nil, database_id: nil, transport: 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 = Google::Cloud.firestore

Parameters:

  • project_id (String) (defaults to: nil)

    Identifier for a Firestore project. 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::Firestore::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 scope is:

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

    Default timeout to use in requests. Optional.

  • database_id (String) (defaults to: nil)

    Identifier for a Firestore database. If not present, the default database of the project is used.

  • transport (:grpc, :rest) (defaults to: nil)

    Which transport to use to communicate with the server. Defaults to :grpc.

Returns:



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/google-cloud-firestore.rb', line 117

def self.firestore project_id = nil,
                   credentials = nil,
                   scope: nil,
                   timeout: nil,
                   database_id: nil,
                   transport: nil
  require "google/cloud/firestore"
  transport ||= Google::Cloud.configure.firestore.transport
  Google::Cloud::Firestore.new project_id: project_id,
                               credentials: credentials,
                               scope: scope,
                               timeout: timeout,
                               database_id: database_id,
                               transport: transport
end

Instance Method Details

#firestore(scope: nil, timeout: nil, database_id: nil, transport: 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"

gcloud = Google::Cloud.new
firestore = gcloud.firestore

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"
firestore = gcloud.firestore scope: platform_scope

The default database can be overridden with the database_id option:

require "google/cloud"

gcloud  = Google::Cloud.new
database_id = "my-todo-database"
firestore = gcloud.firestore database_id: database_id

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

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

    Default timeout to use in requests. Optional.

  • database_id (String) (defaults to: nil)

    Identifier for a Firestore database. If not present, the default database of the project is used.

  • transport (:grpc, :rest) (defaults to: nil)

    Which transport to use to communicate with the server. Defaults to :grpc.

Returns:



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/google-cloud-firestore.rb', line 72

def firestore scope: nil,
              timeout: nil,
              database_id: nil,
              transport: nil
  transport ||= Google::Cloud.configure.firestore.transport
  Google::Cloud.firestore @project, @keyfile,
                          scope: scope,
                          timeout: (timeout || @timeout),
                          database_id: database_id,
                          transport: transport
end