module Google::Cloud

Constants

Pubsub

Legacy veneer namespace

Public Class Methods

pubsub(project_id = nil, credentials = nil, scope: nil, timeout: nil) click to toggle source

Creates a new object for connecting to the Pub/Sub service. Each call creates a new connection.

For more information on connecting to Google Cloud see the {file:AUTHENTICATION.md Authentication Guide}.

@param [String] project_id Project identifier for the Pub/Sub service you

are connecting to. If not present, the default project for the
credentials is used.

@param [String, Hash, Google::Auth::Credentials] credentials 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::PubSub::Credentials})

@param [String, Array<String>] scope 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](https://developers.google.com/identity/protocols/OAuth2).

The default scope is:

* `https://www.googleapis.com/auth/pubsub`

@param [Integer] timeout Default timeout to use in requests. Optional.

@return [Google::Cloud::PubSub::Project]

@example

require "google/cloud"

pubsub = Google::Cloud.pubsub

topic = pubsub.topic "my-topic"
topic.publish "task completed"
# File lib/google-cloud-pubsub.rb, line 102
def self.pubsub project_id = nil,
                credentials = nil,
                scope: nil,
                timeout: nil
  require "google/cloud/pubsub"
  Google::Cloud::PubSub.new project_id: project_id, credentials: credentials, scope: scope, timeout: timeout
end

Public Instance Methods

pubsub(scope: nil, timeout: nil) click to toggle source

Creates a new object for connecting to the Pub/Sub service. Each call creates a new connection.

For more information on connecting to Google Cloud see the {file:AUTHENTICATION.md Authentication Guide}.

@param [String, Array<String>] scope 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](https://developers.google.com/identity/protocols/OAuth2).

The default scope is:

* `https://www.googleapis.com/auth/pubsub`

@param [Integer] timeout Default timeout to use in requests. Optional.

@return [Google::Cloud::PubSub::Project]

@example

require "google/cloud"

gcloud = Google::Cloud.new
pubsub = gcloud.pubsub
topic = pubsub.topic "my-topic"
topic.publish "task completed"

@example 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"
pubsub = gcloud.pubsub scope: platform_scope
# File lib/google-cloud-pubsub.rb, line 63
def pubsub scope: nil, timeout: nil
  timeout ||= @timeout
  Google::Cloud.pubsub @project, @keyfile, scope: scope, timeout: timeout
end