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.
194 195 196 197 198 |
# File 'lib/google/cloud/pubsub/project.rb', line 194 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.
70 71 72 |
# File 'lib/google/cloud/pubsub/project.rb', line 70 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.
357 358 359 360 361 362 |
# File 'lib/google/cloud/pubsub/project.rb', line 357 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.
273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/google/cloud/pubsub/project.rb', line 273 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.
317 318 319 320 321 322 |
# File 'lib/google/cloud/pubsub/project.rb', line 317 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.
150 151 152 153 154 155 156 157 158 |
# File 'lib/google/cloud/pubsub/project.rb', line 150 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.
232 233 234 235 236 237 |
# File 'lib/google/cloud/pubsub/project.rb', line 232 def topics token: nil, max: nil ensure_service! = { token: token, max: max } grpc = service.list_topics Topic::List.from_grpc grpc, service, max end |