Client for the Publisher service.
The service that an application uses to manipulate topics, and to send messages to a topic.
Inherits
- Object
Methods
.configure
def self.configure() { |config| ... } -> Client::Configuration
Configure the Publisher Client class.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
# Modify the configuration for all Publisher clients ::Google::Cloud::PubSub::V1::Publisher::Client.configure do |config| config.timeout = 10.0 end
#configure
def configure() { |config| ... } -> Client::Configuration
Configure the Publisher Client instance.
The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
#create_topic
def create_topic(request, options = nil) -> ::Google::Cloud::PubSub::V1::Topic
def create_topic(name: nil, labels: nil, message_storage_policy: nil, kms_key_name: nil, schema_settings: nil, satisfies_pzs: nil, message_retention_duration: nil) -> ::Google::Cloud::PubSub::V1::Topic
Creates the given topic with the given name. See the resource name rules.
def create_topic(request, options = nil) -> ::Google::Cloud::PubSub::V1::Topic
create_topic
via a request object, either of type
Topic or an equivalent Hash.
- request (::Google::Cloud::PubSub::V1::Topic, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def create_topic(name: nil, labels: nil, message_storage_policy: nil, kms_key_name: nil, schema_settings: nil, satisfies_pzs: nil, message_retention_duration: nil) -> ::Google::Cloud::PubSub::V1::Topic
create_topic
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
name (::String) — Required. The name of the topic. It must have the format
"projects/{project}/topics/{topic}"
.{topic}
must start with a letter, and contain only letters ([A-Za-z]
), numbers ([0-9]
), dashes (-
), underscores (_
), periods (.
), tildes (~
), plus (+
) or percent signs (%
). It must be between 3 and 255 characters in length, and it must not start with"goog"
. - labels (::Hash{::String => ::String}) — See Creating and managing labels.
- message_storage_policy (::Google::Cloud::PubSub::V1::MessageStoragePolicy, ::Hash) — Policy constraining the set of Google Cloud Platform regions where messages published to the topic may be stored. If not present, then no constraints are in effect.
-
kms_key_name (::String) — The resource name of the Cloud KMS CryptoKey to be used to protect access
to messages published on this topic.
The expected format is
projects/*/locations/*/keyRings/*/cryptoKeys/*
. - schema_settings (::Google::Cloud::PubSub::V1::SchemaSettings, ::Hash) — Settings for validating messages published against a schema.
- satisfies_pzs (::Boolean) — Reserved for future use. This field is set only in responses from the server; it is ignored if it is set in any requests.
-
message_retention_duration (::Google::Protobuf::Duration, ::Hash) — Indicates the minimum duration to retain a message after it is published to
the topic. If this field is set, messages published to the topic in the
last
message_retention_duration
are always available to subscribers. For instance, it allows any attached subscription to seek to a timestamp that is up tomessage_retention_duration
in the past. If this field is not set, message retention is controlled by settings on individual subscriptions. Cannot be more than 7 days or less than 10 minutes.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::PubSub::V1::Topic)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/pubsub/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::PubSub::V1::Publisher::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::PubSub::V1::Topic.new # Call the create_topic method. result = client.create_topic request # The returned object is of type Google::Cloud::PubSub::V1::Topic. p result
#delete_topic
def delete_topic(request, options = nil) -> ::Google::Protobuf::Empty
def delete_topic(topic: nil) -> ::Google::Protobuf::Empty
Deletes the topic with the given name. Returns NOT_FOUND
if the topic
does not exist. After a topic is deleted, a new topic may be created with
the same name; this is an entirely new topic with none of the old
configuration or subscriptions. Existing subscriptions to this topic are
not deleted, but their topic
field is set to deleted-topic
.
def delete_topic(request, options = nil) -> ::Google::Protobuf::Empty
delete_topic
via a request object, either of type
DeleteTopicRequest or an equivalent Hash.
- request (::Google::Cloud::PubSub::V1::DeleteTopicRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def delete_topic(topic: nil) -> ::Google::Protobuf::Empty
delete_topic
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
topic (::String) — Required. Name of the topic to delete.
Format is
projects/{project}/topics/{topic}
.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Protobuf::Empty)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/pubsub/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::PubSub::V1::Publisher::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::PubSub::V1::DeleteTopicRequest.new # Call the delete_topic method. result = client.delete_topic request # The returned object is of type Google::Protobuf::Empty. p result
#detach_subscription
def detach_subscription(request, options = nil) -> ::Google::Cloud::PubSub::V1::DetachSubscriptionResponse
def detach_subscription(subscription: nil) -> ::Google::Cloud::PubSub::V1::DetachSubscriptionResponse
Detaches a subscription from this topic. All messages retained in the
subscription are dropped. Subsequent Pull
and StreamingPull
requests
will return FAILED_PRECONDITION. If the subscription is a push
subscription, pushes to the endpoint will stop.
def detach_subscription(request, options = nil) -> ::Google::Cloud::PubSub::V1::DetachSubscriptionResponse
detach_subscription
via a request object, either of type
DetachSubscriptionRequest or an equivalent Hash.
- request (::Google::Cloud::PubSub::V1::DetachSubscriptionRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def detach_subscription(subscription: nil) -> ::Google::Cloud::PubSub::V1::DetachSubscriptionResponse
detach_subscription
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
subscription (::String) — Required. The subscription to detach.
Format is
projects/{project}/subscriptions/{subscription}
.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::PubSub::V1::DetachSubscriptionResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/pubsub/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::PubSub::V1::Publisher::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::PubSub::V1::DetachSubscriptionRequest.new # Call the detach_subscription method. result = client.detach_subscription request # The returned object is of type Google::Cloud::PubSub::V1::DetachSubscriptionResponse. p result
#get_topic
def get_topic(request, options = nil) -> ::Google::Cloud::PubSub::V1::Topic
def get_topic(topic: nil) -> ::Google::Cloud::PubSub::V1::Topic
Gets the configuration of a topic.
def get_topic(request, options = nil) -> ::Google::Cloud::PubSub::V1::Topic
get_topic
via a request object, either of type
GetTopicRequest or an equivalent Hash.
- request (::Google::Cloud::PubSub::V1::GetTopicRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_topic(topic: nil) -> ::Google::Cloud::PubSub::V1::Topic
get_topic
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
topic (::String) — Required. The name of the topic to get.
Format is
projects/{project}/topics/{topic}
.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::PubSub::V1::Topic)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/pubsub/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::PubSub::V1::Publisher::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::PubSub::V1::GetTopicRequest.new # Call the get_topic method. result = client.get_topic request # The returned object is of type Google::Cloud::PubSub::V1::Topic. p result
#initialize
def initialize() { |config| ... } -> Client
Create a new Publisher client object.
- (config) — Configure the Publisher client.
- config (Client::Configuration)
- (Client) — a new instance of Client
# Create a client using the default configuration client = ::Google::Cloud::PubSub::V1::Publisher::Client.new # Create a client using a custom configuration client = ::Google::Cloud::PubSub::V1::Publisher::Client.new do |config| config.timeout = 10.0 end
#list_topic_snapshots
def list_topic_snapshots(request, options = nil) -> ::Google::Cloud::PubSub::V1::ListTopicSnapshotsResponse
def list_topic_snapshots(topic: nil, page_size: nil, page_token: nil) -> ::Google::Cloud::PubSub::V1::ListTopicSnapshotsResponse
Lists the names of the snapshots on this topic. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
def list_topic_snapshots(request, options = nil) -> ::Google::Cloud::PubSub::V1::ListTopicSnapshotsResponse
list_topic_snapshots
via a request object, either of type
ListTopicSnapshotsRequest or an equivalent Hash.
- request (::Google::Cloud::PubSub::V1::ListTopicSnapshotsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def list_topic_snapshots(topic: nil, page_size: nil, page_token: nil) -> ::Google::Cloud::PubSub::V1::ListTopicSnapshotsResponse
list_topic_snapshots
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
topic (::String) — Required. The name of the topic that snapshots are attached to.
Format is
projects/{project}/topics/{topic}
. - page_size (::Integer) — Maximum number of snapshot names to return.
-
page_token (::String) — The value returned by the last
ListTopicSnapshotsResponse
; indicates that this is a continuation of a priorListTopicSnapshots
call, and that the system should return the next page of data.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::PubSub::V1::ListTopicSnapshotsResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/pubsub/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::PubSub::V1::Publisher::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::PubSub::V1::ListTopicSnapshotsRequest.new # Call the list_topic_snapshots method. result = client.list_topic_snapshots request # The returned object is of type Google::Cloud::PubSub::V1::ListTopicSnapshotsResponse. p result
#list_topic_subscriptions
def list_topic_subscriptions(request, options = nil) -> ::Google::Cloud::PubSub::V1::ListTopicSubscriptionsResponse
def list_topic_subscriptions(topic: nil, page_size: nil, page_token: nil) -> ::Google::Cloud::PubSub::V1::ListTopicSubscriptionsResponse
Lists the names of the attached subscriptions on this topic.
def list_topic_subscriptions(request, options = nil) -> ::Google::Cloud::PubSub::V1::ListTopicSubscriptionsResponse
list_topic_subscriptions
via a request object, either of type
ListTopicSubscriptionsRequest or an equivalent Hash.
- request (::Google::Cloud::PubSub::V1::ListTopicSubscriptionsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def list_topic_subscriptions(topic: nil, page_size: nil, page_token: nil) -> ::Google::Cloud::PubSub::V1::ListTopicSubscriptionsResponse
list_topic_subscriptions
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
topic (::String) — Required. The name of the topic that subscriptions are attached to.
Format is
projects/{project}/topics/{topic}
. - page_size (::Integer) — Maximum number of subscription names to return.
-
page_token (::String) — The value returned by the last
ListTopicSubscriptionsResponse
; indicates that this is a continuation of a priorListTopicSubscriptions
call, and that the system should return the next page of data.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::PubSub::V1::ListTopicSubscriptionsResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/pubsub/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::PubSub::V1::Publisher::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::PubSub::V1::ListTopicSubscriptionsRequest.new # Call the list_topic_subscriptions method. result = client.list_topic_subscriptions request # The returned object is of type Google::Cloud::PubSub::V1::ListTopicSubscriptionsResponse. p result
#list_topics
def list_topics(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Topic>
def list_topics(project: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Topic>
Lists matching topics.
def list_topics(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Topic>
list_topics
via a request object, either of type
ListTopicsRequest or an equivalent Hash.
- request (::Google::Cloud::PubSub::V1::ListTopicsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def list_topics(project: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Topic>
list_topics
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
project (::String) — Required. The name of the project in which to list topics.
Format is
projects/{project-id}
. - page_size (::Integer) — Maximum number of topics to return.
-
page_token (::String) — The value returned by the last
ListTopicsResponse
; indicates that this is a continuation of a priorListTopics
call, and that the system should return the next page of data.
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Topic>)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Topic>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/pubsub/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::PubSub::V1::Publisher::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::PubSub::V1::ListTopicsRequest.new # Call the list_topics method. result = client.list_topics request # The returned object is of type Gapic::PagedEnumerable. You can # iterate over all elements by calling #each, and the enumerable # will lazily make API calls to fetch subsequent pages. Other # methods are also available for managing paging directly. result.each do |response| # Each element is of type ::Google::Cloud::PubSub::V1::Topic. p response end
#publish
def publish(request, options = nil) -> ::Google::Cloud::PubSub::V1::PublishResponse
def publish(topic: nil, messages: nil) -> ::Google::Cloud::PubSub::V1::PublishResponse
Adds one or more messages to the topic. Returns NOT_FOUND
if the topic
does not exist.
def publish(request, options = nil) -> ::Google::Cloud::PubSub::V1::PublishResponse
publish
via a request object, either of type
Google::Cloud::PubSub::V1::PublishRequest or an equivalent Hash.
- request (::Google::Cloud::PubSub::V1::PublishRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def publish(topic: nil, messages: nil) -> ::Google::Cloud::PubSub::V1::PublishResponse
publish
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
topic (::String) — Required. The messages in the request will be published on this topic.
Format is
projects/{project}/topics/{topic}
. - messages (::Array<::Google::Cloud::PubSub::V1::PubsubMessage, ::Hash>) — Required. The messages to publish.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::PubSub::V1::PublishResponse)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/pubsub/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::PubSub::V1::Publisher::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::PubSub::V1::PublishRequest.new # Call the publish method. result = client.publish request # The returned object is of type Google::Cloud::PubSub::V1::PublishResponse. p result
#update_topic
def update_topic(request, options = nil) -> ::Google::Cloud::PubSub::V1::Topic
def update_topic(topic: nil, update_mask: nil) -> ::Google::Cloud::PubSub::V1::Topic
Updates an existing topic. Note that certain properties of a topic are not modifiable.
def update_topic(request, options = nil) -> ::Google::Cloud::PubSub::V1::Topic
update_topic
via a request object, either of type
UpdateTopicRequest or an equivalent Hash.
- request (::Google::Cloud::PubSub::V1::UpdateTopicRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def update_topic(topic: nil, update_mask: nil) -> ::Google::Cloud::PubSub::V1::Topic
update_topic
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- topic (::Google::Cloud::PubSub::V1::Topic, ::Hash) — Required. The updated topic object.
-
update_mask (::Google::Protobuf::FieldMask, ::Hash) — Required. Indicates which fields in the provided topic to update. Must be
specified and non-empty. Note that if
update_mask
contains "message_storage_policy" but themessage_storage_policy
is not set in thetopic
provided above, then the updated value is determined by the policy configured at the project or organization level.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::PubSub::V1::Topic)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/pubsub/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::PubSub::V1::Publisher::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::PubSub::V1::UpdateTopicRequest.new # Call the update_topic method. result = client.update_topic request # The returned object is of type Google::Cloud::PubSub::V1::Topic. p result