Cloud Pub/Sub API - Class Google::Cloud::PubSub::Project (v3.0.1)

Reference documentation and code samples for the Cloud Pub/Sub API class Google::Cloud::PubSub::Project.

Project

Represents the project that pubsub messages are pushed to and pulled from.

V1::Topic is a named resource to which messages are sent by using Publisher. V1::Subscription is a named resource representing the stream of messages from a single, specific topic, to be delivered to the subscribing application via Subscriber. Message is a combination of data and attributes that a publisher sends to a topic and is eventually delivered to subscribers.

See Google::Cloud#pubsub

Inherits

  • Object

Example

require "google/cloud/pubsub"

pubsub = Google::Cloud::PubSub.new

publisher = pubsub.publisher "my-topic"
publisher.publish "task completed"

Methods

#iam

def iam() -> Google::Iam::V1::IAMPolicy::Client

Retrieve a client specific for Iam Policy related functions.

Returns
  • (Google::Iam::V1::IAMPolicy::Client)

#project

def project()
Alias Of: #project_id

The Pub/Sub project connected to.

Example
require "google/cloud/pubsub"

pubsub = Google::Cloud::PubSub.new(
  project_id: "my-project",
  credentials: "/path/to/keyfile.json"
)

pubsub.project_id #=> "my-project"

#project_id

def project_id()
Aliases

The Pub/Sub project connected to.

Example
require "google/cloud/pubsub"

pubsub = Google::Cloud::PubSub.new(
  project_id: "my-project",
  credentials: "/path/to/keyfile.json"
)

pubsub.project_id #=> "my-project"

#project_path

def project_path(project_name: nil)

Returns a fully-qualified project path in the form of projects/{project_id}

Parameter
  • project_name (String) (defaults to: nil) — A project name. Optional. If provided, this will be used in place of the default project_id.

#publisher

def publisher(topic_name, project: nil, async: nil) -> Google::Cloud::PubSub::Publisher

Retrieves a Publisher by topic name or full project path.

Parameters
  • topic_name (String) — Name of a topic. The value can be a simple topic ID (relative name) or a fully-qualified topic name.
  • project (String) (defaults to: nil) — The alternate project ID can be specified here. Optional. Not used if a fully-qualified topic name is provided for topic_name.
  • async (Hash) (defaults to: nil) — A hash of values to configure the topic's AsyncPublisher that is created when Google::Cloud::PubSub::Publisher#publish_async is called. Optional.

#schema_path

def schema_path(schema_name, project_name: nil)

Returns a fully-qualified schema path in the form of projects/{project_id}/schemas/{schema_name}

Parameters
  • schema_name (String) — A schema name.
  • project_name (String) (defaults to: nil) — A project name. Optional. If provided, this will be used in place of the default project_id.

#schemas

def schemas() -> Google::Cloud::PubSub::V1::SchemaService::Client

Retrieve a client for managing schemas.

Returns
  • (Google::Cloud::PubSub::V1::SchemaService::Client)

#snapshot_path

def snapshot_path(snapshot_name, project_name: nil)

Returns a fully-qualified snapshot path in the form of projects/{project_id}/snapshots/{snapshot_name}

Parameters
  • snapshot_name (String) — A snapshot name.
  • project_name (String) (defaults to: nil) — A project name. Optional. If provided, this will be used in place of the default project_id.

#subscriber

def subscriber(subscription_name, project: nil, skip_lookup: nil) -> Google::Cloud::PubSub::Subscriber, nil

Retrieves a Subscriber by subscription name or full project path.

Parameters
  • subscription_name (String) — Name of a subscription. The value can be a simple subscription ID (relative name) or a fully-qualified subscription name.
  • project (String) (defaults to: nil) — The alternate project ID can be specified here. Optional. Not used if a fully-qualified topic name is provided for topic_name.
  • skip_lookup (Boolean) (defaults to: nil) — Optionally create a V1::Subscription object without verifying the subscription resource exists on the Pub/Sub service. Calls made on this object will raise errors if the service resource does not exist. Default is false.
Returns

#subscription_admin

def subscription_admin() -> Google::Cloud::PubSub::SubscriptionAdmin::Client

Retrieve a client for managing subscriptions.

#subscription_path

def subscription_path(subscription_name, project_name: nil)

Returns a fully-qualified subscription path in the form of projects/{project_id}/subscriptions/{subscription_name}

Parameters
  • subscription_name (String) — A subscription name.
  • project_name (String) (defaults to: nil) — A project name. Optional. If provided, this will be used in place of the default project_id.

#topic_admin

def topic_admin() -> Google::Cloud::PubSub::TopicAdmin::Client

Retrieve a client for managing topics.

#topic_path

def topic_path(topic_name, project_name: nil)

Returns a fully-qualified topic path in the form of projects/{project_id}/topics/{topic_name}

Parameters
  • topic_name (String) — A topic name.
  • project_name (String) (defaults to: nil) — A project name. Optional. If provided, this will be used in place of the default project_id.

#universe_domain

def universe_domain() -> String

The universe domain the client is connected to

Returns
  • (String)