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

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, client_config: 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 Datastore::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.

  • client_config (Hash) (defaults to: nil)

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

Returns:



99
100
101
102
103
104
105
106
# File 'lib/google-cloud-firestore.rb', line 99

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

Instance Method Details

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

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.

  • client_config (Hash) (defaults to: nil)

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

Returns:



62
63
64
65
66
# File 'lib/google-cloud-firestore.rb', line 62

def firestore scope: nil, timeout: nil, client_config: nil
  Google::Cloud.firestore @project, @keyfile,
                          scope: scope, timeout: (timeout || @timeout),
                          client_config: client_config
end