Module: Google::Cloud

Defined in:
lib/google/cloud.rb,
lib/google/cloud/errors.rb,
lib/google/cloud/credentials.rb,
lib/google/cloud/core/version.rb

Defined Under Namespace

Modules: Core Classes: AbortedError, AlreadyExistsError, CanceledError, DataLossError, DeadlineExceededError, Error, FailedPreconditionError, InternalError, InvalidArgumentError, NotFoundError, OutOfRangeError, PermissionDeniedError, ResourceExhaustedError, UnauthenticatedError, UnavailableError, UnimplementedError, UnknownError

Class Method Summary collapse

Class Method Details

.new(project = nil, keyfile = nil, retries: nil, timeout: nil) ⇒ Google::Cloud

Creates a new object for connecting to Google Cloud.

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

Examples:

require "google/cloud"

gcloud  = Google::Cloud.new
datastore = gcloud.datastore
pubsub  = gcloud.pubsub
storage = gcloud.storage

Parameters:

  • project (String) (defaults to: nil)

    Project identifier for the Pub/Sub service you are connecting to.

  • keyfile (String, Hash) (defaults to: nil)

    Keyfile downloaded from Google Cloud. If file path the file must be readable.

  • retries (Integer)

    Number of times to retry requests on server error. The default value is 3. Optional.

  • timeout (Integer)

    Default timeout to use in requests. Optional.

Returns:



60
61
62
63
64
65
66
67
68
# File 'lib/google/cloud.rb', line 60

def self.new project = nil, keyfile = nil, retries: nil, timeout: nil
  gcloud = Object.new
  gcloud.instance_variable_set "@project", project
  gcloud.instance_variable_set "@keyfile", keyfile
  gcloud.instance_variable_set "@retries", retries
  gcloud.instance_variable_set "@timeout", timeout
  gcloud.extend Google::Cloud
  gcloud
end