Class: Google::Cloud::Pubsub::Project
- Inherits:
-
Object
- Object
- Google::Cloud::Pubsub::Project
- Defined in:
- lib/google/cloud/pubsub/project.rb
Overview
Project
Represents the project that pubsub messages are pushed to and pulled from. Topic is a named resource to which messages are sent by publishers. Subscription is a named resource representing the stream of messages from a single, specific topic, to be delivered to the subscribing application. Message is a combination of data and attributes that a publisher sends to a topic and is eventually delivered to subscribers.
Instance Method Summary collapse
-
#create_topic(topic_name, async: nil) ⇒ Google::Cloud::Pubsub::Topic
(also: #new_topic)
Creates a new topic.
-
#project_id ⇒ Object
(also: #project)
The Pub/Sub project connected to.
-
#snapshots(token: nil, max: nil) ⇒ Array<Google::Cloud::Pubsub::Snapshot>
(also: #find_snapshots, #list_snapshots)
Retrieves a list of snapshots for the given project.
-
#subscription(subscription_name, project: nil, skip_lookup: nil) ⇒ Google::Cloud::Pubsub::Subscription?
(also: #get_subscription, #find_subscription)
Retrieves subscription by name.
-
#subscriptions(token: nil, max: nil) ⇒ Array<Google::Cloud::Pubsub::Subscription>
(also: #find_subscriptions, #list_subscriptions)
Retrieves a list of subscriptions for the given project.
-
#topic(topic_name, project: nil, skip_lookup: nil, async: nil) ⇒ Google::Cloud::Pubsub::Topic?
(also: #get_topic, #find_topic)
Retrieves topic by name.
-
#topics(token: nil, max: nil) ⇒ Array<Google::Cloud::Pubsub::Topic>
(also: #find_topics, #list_topics)
Retrieves a list of topics for the given project.
Instance Method Details
#create_topic(topic_name, async: nil) ⇒ Google::Cloud::Pubsub::Topic Also known as: new_topic
Creates a new topic.
204 205 206 207 208 |
# File 'lib/google/cloud/pubsub/project.rb', line 204 def create_topic topic_name, async: nil ensure_service! grpc = service.create_topic topic_name Topic.from_grpc grpc, service, async: async end |
#project_id ⇒ Object Also known as: project
The Pub/Sub project connected to.
71 72 73 |
# File 'lib/google/cloud/pubsub/project.rb', line 71 def project_id service.project end |
#snapshots(token: nil, max: nil) ⇒ Array<Google::Cloud::Pubsub::Snapshot> Also known as: find_snapshots, list_snapshots
Retrieves a list of snapshots for the given project.
367 368 369 370 371 372 |
# File 'lib/google/cloud/pubsub/project.rb', line 367 def snapshots token: nil, max: nil ensure_service! = { token: token, max: max } grpc = service.list_snapshots Snapshot::List.from_grpc grpc, service, max end |
#subscription(subscription_name, project: nil, skip_lookup: nil) ⇒ Google::Cloud::Pubsub::Subscription? Also known as: get_subscription, find_subscription
Retrieves subscription by name.
283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/google/cloud/pubsub/project.rb', line 283 def subscription subscription_name, project: nil, skip_lookup: nil ensure_service! = { project: project } if skip_lookup return Subscription.new_lazy subscription_name, service, end grpc = service.get_subscription subscription_name Subscription.from_grpc grpc, service rescue Google::Cloud::NotFoundError nil end |
#subscriptions(token: nil, max: nil) ⇒ Array<Google::Cloud::Pubsub::Subscription> Also known as: find_subscriptions, list_subscriptions
Retrieves a list of subscriptions for the given project.
327 328 329 330 331 332 |
# File 'lib/google/cloud/pubsub/project.rb', line 327 def subscriptions token: nil, max: nil ensure_service! = { token: token, max: max } grpc = service.list_subscriptions Subscription::List.from_grpc grpc, service, max end |
#topic(topic_name, project: nil, skip_lookup: nil, async: nil) ⇒ Google::Cloud::Pubsub::Topic? Also known as: get_topic, find_topic
Retrieves topic by name.
160 161 162 163 164 165 166 167 168 |
# File 'lib/google/cloud/pubsub/project.rb', line 160 def topic topic_name, project: nil, skip_lookup: nil, async: nil ensure_service! = { project: project } return Topic.new_lazy(topic_name, service, ) if skip_lookup grpc = service.get_topic topic_name Topic.from_grpc grpc, service, async: async rescue Google::Cloud::NotFoundError nil end |
#topics(token: nil, max: nil) ⇒ Array<Google::Cloud::Pubsub::Topic> Also known as: find_topics, list_topics
Retrieves a list of topics for the given project.
242 243 244 245 246 247 |
# File 'lib/google/cloud/pubsub/project.rb', line 242 def topics token: nil, max: nil ensure_service! = { token: token, max: max } grpc = service.list_topics Topic::List.from_grpc grpc, service, max end |