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_schema(schema_id, type, definition, project: nil) ⇒ Google::Cloud::PubSub::Schema
(also: #new_schema)
Creates a new schema.
-
#create_topic(topic_name, labels: nil, kms_key: nil, persistence_regions: nil, async: nil, schema_name: nil, message_encoding: nil, retention: nil, ingestion_data_source_settings: nil) ⇒ Google::Cloud::PubSub::Topic
(also: #new_topic)
Creates a new topic.
-
#project_id ⇒ Object
(also: #project)
The Pub/Sub project connected to.
-
#schema(schema_name, view: nil, project: nil, skip_lookup: nil) ⇒ Google::Cloud::PubSub::Schema?
(also: #get_schema, #find_schema)
Retrieves schema by name.
-
#schemas(view: nil, token: nil, max: nil) ⇒ Array<Google::Cloud::PubSub::Schema>
(also: #find_schemas, #list_schemas)
Retrieves a list of schemas for the given project.
-
#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.
-
#universe_domain ⇒ String
The universe domain the client is connected to.
-
#valid_schema?(type, definition, project: nil) ⇒ Boolean
(also: #validate_schema)
Validates a schema type and definition.
Instance Method Details
#create_schema(schema_id, type, definition, project: nil) ⇒ Google::Cloud::PubSub::Schema Also known as: new_schema
Creates a new schema.
569 570 571 572 573 574 |
# File 'lib/google/cloud/pubsub/project.rb', line 569 def create_schema schema_id, type, definition, project: nil ensure_service! type = type.to_s.upcase grpc = service.create_schema schema_id, type, definition, project: project Schema.from_grpc grpc, service end |
#create_topic(topic_name, labels: nil, kms_key: nil, persistence_regions: nil, async: nil, schema_name: nil, message_encoding: nil, retention: nil, ingestion_data_source_settings: nil) ⇒ Google::Cloud::PubSub::Topic Also known as: new_topic
Creates a new topic.
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/google/cloud/pubsub/project.rb', line 277 def create_topic topic_name, labels: nil, kms_key: nil, persistence_regions: nil, async: nil, schema_name: nil, message_encoding: nil, retention: nil, ingestion_data_source_settings: nil ensure_service! grpc = service.create_topic topic_name, labels: labels, kms_key_name: kms_key, persistence_regions: persistence_regions, schema_name: schema_name, message_encoding: , retention: retention, ingestion_data_source_settings: ingestion_data_source_settings Topic.from_grpc grpc, service, async: async end |
#project_id ⇒ Object Also known as: project
The Pub/Sub project connected to.
74 75 76 |
# File 'lib/google/cloud/pubsub/project.rb', line 74 def project_id service.project end |
#schema(schema_name, view: nil, project: nil, skip_lookup: nil) ⇒ Google::Cloud::PubSub::Schema? Also known as: get_schema, find_schema
Retrieves schema by name.
522 523 524 525 526 527 528 529 530 531 |
# File 'lib/google/cloud/pubsub/project.rb', line 522 def schema schema_name, view: nil, project: nil, skip_lookup: nil ensure_service! = { project: project } return Schema.from_name schema_name, view, service, if skip_lookup view ||= :FULL grpc = service.get_schema schema_name, view, Schema.from_grpc grpc, service rescue Google::Cloud::NotFoundError nil end |
#schemas(view: nil, token: nil, max: nil) ⇒ Array<Google::Cloud::PubSub::Schema> Also known as: find_schemas, list_schemas
Retrieves a list of schemas for the given project.
The default value is FULL
.
613 614 615 616 617 618 619 |
# File 'lib/google/cloud/pubsub/project.rb', line 613 def schemas view: nil, token: nil, max: nil ensure_service! view ||= :FULL = { token: token, max: max } grpc = service.list_schemas view, Schema::List.from_grpc grpc, service, view, max 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.
457 458 459 460 461 462 |
# File 'lib/google/cloud/pubsub/project.rb', line 457 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.
375 376 377 378 379 380 381 382 383 |
# File 'lib/google/cloud/pubsub/project.rb', line 375 def subscription subscription_name, project: nil, skip_lookup: nil ensure_service! = { project: project } return Subscription.from_name subscription_name, service, if skip_lookup 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.
417 418 419 420 421 422 |
# File 'lib/google/cloud/pubsub/project.rb', line 417 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.
176 177 178 179 180 181 182 183 184 |
# File 'lib/google/cloud/pubsub/project.rb', line 176 def topic topic_name, project: nil, skip_lookup: nil, async: nil ensure_service! = { project: project, async: async } return Topic.from_name 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.
330 331 332 333 334 335 |
# File 'lib/google/cloud/pubsub/project.rb', line 330 def topics token: nil, max: nil ensure_service! = { token: token, max: max } grpc = service.list_topics Topic::List.from_grpc grpc, service, max end |
#universe_domain ⇒ String
The universe domain the client is connected to
84 85 86 |
# File 'lib/google/cloud/pubsub/project.rb', line 84 def universe_domain service.universe_domain end |
#valid_schema?(type, definition, project: nil) ⇒ Boolean Also known as: validate_schema
Validates a schema type and definition.
648 649 650 651 652 653 654 655 |
# File 'lib/google/cloud/pubsub/project.rb', line 648 def valid_schema? type, definition, project: nil ensure_service! type = type.to_s.upcase service.validate_schema type, definition, project: project # return type is empty true rescue Google::Cloud::InvalidArgumentError false end |