Class: Google::Cloud::PubSub::V1::Subscriber::Client

Inherits:
Object
  • Object
show all
Includes:
Paths
Defined in:
lib/google/cloud/pubsub/v1/subscriber/client.rb

Overview

Client for the Subscriber service.

The service that an application uses to manipulate subscriptions and to consume messages from a subscription via the Pull method or by establishing a bi-directional stream using the StreamingPull method.

Defined Under Namespace

Classes: Configuration

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Paths

#project_path, #snapshot_path, #subscription_path, #topic_path

Constructor Details

#initialize {|config| ... } ⇒ Client

Create a new Subscriber client object.

Examples:


# Create a client using the default configuration
client = ::Google::Cloud::PubSub::V1::Subscriber::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::PubSub::V1::Subscriber::Client.new do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Subscriber client.

Yield Parameters:



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 191

def initialize
  # These require statements are intentionally placed here to initialize
  # the gRPC module only when it's required.
  # See https://github.com/googleapis/toolkit/issues/446
  require "gapic/grpc"
  require "google/pubsub/v1/pubsub_services_pb"

  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  # Use self-signed JWT if the endpoint is unchanged from default,
  # but only if the default endpoint does not have a region prefix.
  enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
                           !@config.endpoint.split(".").first.include?("-")
  credentials ||= Credentials.default scope: @config.scope,
                                      enable_self_signed_jwt: enable_self_signed_jwt
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end
  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @subscriber_stub = ::Gapic::ServiceStub.new(
    ::Google::Cloud::PubSub::V1::Subscriber::Stub,
    credentials:  credentials,
    endpoint:     @config.endpoint,
    channel_args: @config.channel_args,
    interceptors: @config.interceptors
  )
end

Class Method Details

.configure {|config| ... } ⇒ Client::Configuration

Configure the Subscriber Client class.

See Configuration for a description of the configuration fields.

Examples:


# Modify the configuration for all Subscriber clients
::Google::Cloud::PubSub::V1::Subscriber::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 58

def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "PubSub", "V1"]
    parent_config = while namespace.any?
                      parent_name = namespace.join "::"
                      parent_const = const_get parent_name
                      break parent_const.configure if parent_const.respond_to? :configure
                      namespace.pop
                    end
    default_config = Client::Configuration.new parent_config

    default_config.rpcs.create_subscription.timeout = 60.0
    default_config.rpcs.create_subscription.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [2, 10, 14]
    }

    default_config.rpcs.get_subscription.timeout = 60.0
    default_config.rpcs.get_subscription.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [2, 10, 14]
    }

    default_config.rpcs.update_subscription.timeout = 60.0
    default_config.rpcs.update_subscription.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config.rpcs.list_subscriptions.timeout = 60.0
    default_config.rpcs.list_subscriptions.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [2, 10, 14]
    }

    default_config.rpcs.delete_subscription.timeout = 60.0
    default_config.rpcs.delete_subscription.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config.rpcs.modify_ack_deadline.timeout = 60.0
    default_config.rpcs.modify_ack_deadline.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config.rpcs.acknowledge.timeout = 60.0
    default_config.rpcs.acknowledge.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config.rpcs.pull.timeout = 60.0
    default_config.rpcs.pull.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [2, 10, 14]
    }

    default_config.rpcs.streaming_pull.timeout = 900.0
    default_config.rpcs.streaming_pull.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 8, 10, 13, 14]
    }

    default_config.rpcs.modify_push_config.timeout = 60.0
    default_config.rpcs.modify_push_config.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config.rpcs.get_snapshot.timeout = 60.0
    default_config.rpcs.get_snapshot.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [2, 10, 14]
    }

    default_config.rpcs.list_snapshots.timeout = 60.0
    default_config.rpcs.list_snapshots.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [2, 10, 14]
    }

    default_config.rpcs.create_snapshot.timeout = 60.0
    default_config.rpcs.create_snapshot.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config.rpcs.update_snapshot.timeout = 60.0
    default_config.rpcs.update_snapshot.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config.rpcs.delete_snapshot.timeout = 60.0
    default_config.rpcs.delete_snapshot.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config.rpcs.seek.timeout = 60.0
    default_config.rpcs.seek.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [2, 10, 14]
    }

    default_config
  end
  yield @configure if block_given?
  @configure
end

Instance Method Details

#acknowledge(request, options = nil) ⇒ ::Google::Protobuf::Empty #acknowledge(subscription: nil, ack_ids: nil) ⇒ ::Google::Protobuf::Empty

Acknowledges the messages associated with the ack_ids in the AcknowledgeRequest. The Pub/Sub system can remove the relevant messages from the subscription.

Acknowledging a message whose ack deadline has expired may succeed, but such a message may be redelivered later. Acknowledging a message more than once will not result in an error.

Examples:

Basic example

require "google/cloud/pubsub/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::PubSub::V1::Subscriber::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::PubSub::V1::AcknowledgeRequest.new

# Call the acknowledge method.
result = client.acknowledge request

# The returned object is of type Google::Protobuf::Empty.
p result

Overloads:

  • #acknowledge(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to acknowledge via a request object, either of type AcknowledgeRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::PubSub::V1::AcknowledgeRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #acknowledge(subscription: nil, ack_ids: nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to acknowledge 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).

    Parameters:

    • subscription (::String) (defaults to: nil)

      Required. The subscription whose message is being acknowledged. Format is projects/{project}/subscriptions/{sub}.

    • ack_ids (::Array<::String>) (defaults to: nil)

      Required. The acknowledgment ID for the messages being acknowledged that was returned by the Pub/Sub system in the Pull response. Must not be empty.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 936

def acknowledge request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::AcknowledgeRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.acknowledge..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::PubSub::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.subscription
    header_params["subscription"] = request.subscription
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.acknowledge.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.acknowledge.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @subscriber_stub.call_rpc :acknowledge, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#configure {|config| ... } ⇒ Client::Configuration

Configure the Subscriber 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 configure.

See Configuration for a description of the configuration fields.

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



170
171
172
173
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 170

def configure
  yield @config if block_given?
  @config
end

#create_snapshot(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot #create_snapshot(name: nil, subscription: nil, labels: nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot

Creates a snapshot from the requested subscription. 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. If the snapshot already exists, returns ALREADY_EXISTS. If the requested subscription doesn't exist, returns NOT_FOUND. If the backlog in the subscription is too old -- and the resulting snapshot would expire in less than 1 hour -- then FAILED_PRECONDITION is returned. See also the Snapshot.expire_time field. If the name is not provided in the request, the server will assign a random name for this snapshot on the same project as the subscription, conforming to the resource name format. The generated name is populated in the returned Snapshot object. Note that for REST API requests, you must specify a name in the request.

Examples:

Basic example

require "google/cloud/pubsub/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::PubSub::V1::Subscriber::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::PubSub::V1::CreateSnapshotRequest.new

# Call the create_snapshot method.
result = client.create_snapshot request

# The returned object is of type Google::Cloud::PubSub::V1::Snapshot.
p result

Overloads:

  • #create_snapshot(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot

    Pass arguments to create_snapshot via a request object, either of type CreateSnapshotRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::PubSub::V1::CreateSnapshotRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #create_snapshot(name: nil, subscription: nil, labels: nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot

    Pass arguments to create_snapshot 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).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. User-provided name for this snapshot. If the name is not provided in the request, the server will assign a random name for this snapshot on the same project as the subscription. Note that for REST API requests, you must specify a name. See the resource name rules. Format is projects/{project}/snapshots/{snap}.

    • subscription (::String) (defaults to: nil)

      Required. The subscription whose backlog the snapshot retains. Specifically, the created snapshot is guaranteed to retain: (a) The existing backlog on the subscription. More precisely, this is defined as the messages in the subscription's backlog that are unacknowledged upon the successful completion of the CreateSnapshot request; as well as: (b) Any messages published to the subscription's topic following the successful completion of the CreateSnapshot request. Format is projects/{project}/subscriptions/{sub}.

    • labels (::Hash{::String => ::String}) (defaults to: nil)

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 1529

def create_snapshot request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::CreateSnapshotRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_snapshot..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::PubSub::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.create_snapshot.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_snapshot.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @subscriber_stub.call_rpc :create_snapshot, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#create_subscription(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription #create_subscription(name: nil, topic: nil, push_config: nil, ack_deadline_seconds: nil, retain_acked_messages: nil, message_retention_duration: nil, labels: nil, enable_message_ordering: nil, expiration_policy: nil, filter: nil, dead_letter_policy: nil, retry_policy: nil, detached: nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription

Creates a subscription to a given topic. See the resource name rules. If the subscription already exists, returns ALREADY_EXISTS. If the corresponding topic doesn't exist, returns NOT_FOUND.

If the name is not provided in the request, the server will assign a random name for this subscription on the same project as the topic, conforming to the resource name format. The generated name is populated in the returned Subscription object. Note that for REST API requests, you must specify a name in the request.

Examples:

Basic example

require "google/cloud/pubsub/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::PubSub::V1::Subscriber::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::PubSub::V1::Subscription.new

# Call the create_subscription method.
result = client.create_subscription request

# The returned object is of type Google::Cloud::PubSub::V1::Subscription.
p result

Overloads:

  • #create_subscription(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription

    Pass arguments to create_subscription via a request object, either of type Google::Cloud::PubSub::V1::Subscription or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::PubSub::V1::Subscription, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #create_subscription(name: nil, topic: nil, push_config: nil, ack_deadline_seconds: nil, retain_acked_messages: nil, message_retention_duration: nil, labels: nil, enable_message_ordering: nil, expiration_policy: nil, filter: nil, dead_letter_policy: nil, retry_policy: nil, detached: nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription

    Pass arguments to create_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).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. The name of the subscription. It must have the format "projects/{project}/subscriptions/{subscription}". {subscription} 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".

    • topic (::String) (defaults to: nil)

      Required. The name of the topic from which this subscription is receiving messages. Format is projects/{project}/topics/{topic}. The value of this field will be _deleted-topic_ if the topic has been deleted.

    • push_config (::Google::Cloud::PubSub::V1::PushConfig, ::Hash) (defaults to: nil)

      If push delivery is used with this subscription, this field is used to configure it. An empty pushConfig signifies that the subscriber will pull and ack messages using API methods.

    • ack_deadline_seconds (::Integer) (defaults to: nil)

      The approximate amount of time (on a best-effort basis) Pub/Sub waits for the subscriber to acknowledge receipt before resending the message. In the interval after the message is delivered and before it is acknowledged, it is considered to be outstanding. During that time period, the message will not be redelivered (on a best-effort basis).

      For pull subscriptions, this value is used as the initial value for the ack deadline. To override this value for a given message, call ModifyAckDeadline with the corresponding ack_id if using non-streaming pull or send the ack_id in a StreamingModifyAckDeadlineRequest if using streaming pull. The minimum custom deadline you can specify is 10 seconds. The maximum custom deadline you can specify is 600 seconds (10 minutes). If this parameter is 0, a default value of 10 seconds is used.

      For push delivery, this value is also used to set the request timeout for the call to the push endpoint.

      If the subscriber never acknowledges the message, the Pub/Sub system will eventually redeliver the message.

    • retain_acked_messages (::Boolean) (defaults to: nil)

      Indicates whether to retain acknowledged messages. If true, then messages are not expunged from the subscription's backlog, even if they are acknowledged, until they fall out of the message_retention_duration window. This must be true if you would like to Seek to a timestamp in the past to replay previously-acknowledged messages.

    • message_retention_duration (::Google::Protobuf::Duration, ::Hash) (defaults to: nil)

      How long to retain unacknowledged messages in the subscription's backlog, from the moment a message is published. If retain_acked_messages is true, then this also configures the retention of acknowledged messages, and thus configures how far back in time a Seek can be done. Defaults to 7 days. Cannot be more than 7 days or less than 10 minutes.

    • labels (::Hash{::String => ::String}) (defaults to: nil)
    • enable_message_ordering (::Boolean) (defaults to: nil)

      If true, messages published with the same ordering_key in PubsubMessage will be delivered to the subscribers in the order in which they are received by the Pub/Sub system. Otherwise, they may be delivered in any order.

    • expiration_policy (::Google::Cloud::PubSub::V1::ExpirationPolicy, ::Hash) (defaults to: nil)

      A policy that specifies the conditions for this subscription's expiration. A subscription is considered active as long as any connected subscriber is successfully consuming messages from the subscription or is issuing operations on the subscription. If expiration_policy is not set, a default policy with ttl of 31 days will be used. The minimum allowed value for expiration_policy.ttl is 1 day.

    • filter (::String) (defaults to: nil)

      An expression written in the Pub/Sub filter language. If non-empty, then only PubsubMessages whose attributes field matches the filter are delivered on this subscription. If empty, then no messages are filtered out.

    • dead_letter_policy (::Google::Cloud::PubSub::V1::DeadLetterPolicy, ::Hash) (defaults to: nil)

      A policy that specifies the conditions for dead lettering messages in this subscription. If dead_letter_policy is not set, dead lettering is disabled.

      The Cloud Pub/Sub service account associated with this subscriptions's parent project (i.e., service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have permission to Acknowledge() messages on this subscription.

    • retry_policy (::Google::Cloud::PubSub::V1::RetryPolicy, ::Hash) (defaults to: nil)

      A policy that specifies how Pub/Sub retries message delivery for this subscription.

      If not set, the default retry policy is applied. This generally implies that messages will be retried as soon as possible for healthy subscribers. RetryPolicy will be triggered on NACKs or acknowledgement deadline exceeded events for a given message.

    • detached (::Boolean) (defaults to: nil)

      Indicates whether the subscription is detached from its topic. Detached subscriptions don't receive messages from their topic and don't retain any backlog. Pull and StreamingPull requests will return FAILED_PRECONDITION. If the subscription is a push subscription, pushes to the endpoint will not be made.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 375

def create_subscription request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::Subscription

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.create_subscription..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::PubSub::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.create_subscription.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.create_subscription.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @subscriber_stub.call_rpc :create_subscription, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_snapshot(request, options = nil) ⇒ ::Google::Protobuf::Empty #delete_snapshot(snapshot: nil) ⇒ ::Google::Protobuf::Empty

Removes an existing snapshot. 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. When the snapshot is deleted, all messages retained in the snapshot are immediately dropped. After a snapshot is deleted, a new one may be created with the same name, but the new one has no association with the old snapshot or its subscription, unless the same subscription is specified.

Examples:

Basic example

require "google/cloud/pubsub/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::PubSub::V1::Subscriber::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::PubSub::V1::DeleteSnapshotRequest.new

# Call the delete_snapshot method.
result = client.delete_snapshot request

# The returned object is of type Google::Protobuf::Empty.
p result

Overloads:

  • #delete_snapshot(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_snapshot via a request object, either of type DeleteSnapshotRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::PubSub::V1::DeleteSnapshotRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #delete_snapshot(snapshot: nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_snapshot 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).

    Parameters:

    • snapshot (::String) (defaults to: nil)

      Required. The name of the snapshot to delete. Format is projects/{project}/snapshots/{snap}.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 1716

def delete_snapshot request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::DeleteSnapshotRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.delete_snapshot..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::PubSub::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.snapshot
    header_params["snapshot"] = request.snapshot
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.delete_snapshot.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_snapshot.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @subscriber_stub.call_rpc :delete_snapshot, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#delete_subscription(request, options = nil) ⇒ ::Google::Protobuf::Empty #delete_subscription(subscription: nil) ⇒ ::Google::Protobuf::Empty

Deletes an existing subscription. All messages retained in the subscription are immediately dropped. Calls to Pull after deletion will return NOT_FOUND. After a subscription is deleted, a new one may be created with the same name, but the new one has no association with the old subscription or its topic unless the same topic is specified.

Examples:

Basic example

require "google/cloud/pubsub/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::PubSub::V1::Subscriber::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::PubSub::V1::DeleteSubscriptionRequest.new

# Call the delete_subscription method.
result = client.delete_subscription request

# The returned object is of type Google::Protobuf::Empty.
p result

Overloads:

  • #delete_subscription(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_subscription via a request object, either of type DeleteSubscriptionRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::PubSub::V1::DeleteSubscriptionRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #delete_subscription(subscription: nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_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).

    Parameters:

    • subscription (::String) (defaults to: nil)

      Required. The subscription to delete. Format is projects/{project}/subscriptions/{sub}.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 739

def delete_subscription request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::DeleteSubscriptionRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.delete_subscription..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::PubSub::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.subscription
    header_params["subscription"] = request.subscription
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.delete_subscription.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_subscription.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @subscriber_stub.call_rpc :delete_subscription, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_snapshot(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot #get_snapshot(snapshot: nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot

Gets the configuration details of a snapshot. 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.

Examples:

Basic example

require "google/cloud/pubsub/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::PubSub::V1::Subscriber::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::PubSub::V1::GetSnapshotRequest.new

# Call the get_snapshot method.
result = client.get_snapshot request

# The returned object is of type Google::Cloud::PubSub::V1::Snapshot.
p result

Overloads:

  • #get_snapshot(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot

    Pass arguments to get_snapshot via a request object, either of type GetSnapshotRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::PubSub::V1::GetSnapshotRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_snapshot(snapshot: nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot

    Pass arguments to get_snapshot 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).

    Parameters:

    • snapshot (::String) (defaults to: nil)

      Required. The name of the snapshot to get. Format is projects/{project}/snapshots/{snap}.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 1308

def get_snapshot request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::GetSnapshotRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_snapshot..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::PubSub::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.snapshot
    header_params["snapshot"] = request.snapshot
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_snapshot.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_snapshot.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @subscriber_stub.call_rpc :get_snapshot, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_subscription(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription #get_subscription(subscription: nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription

Gets the configuration details of a subscription.

Examples:

Basic example

require "google/cloud/pubsub/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::PubSub::V1::Subscriber::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::PubSub::V1::GetSubscriptionRequest.new

# Call the get_subscription method.
result = client.get_subscription request

# The returned object is of type Google::Cloud::PubSub::V1::Subscription.
p result

Overloads:

  • #get_subscription(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription

    Pass arguments to get_subscription via a request object, either of type GetSubscriptionRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::PubSub::V1::GetSubscriptionRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_subscription(subscription: nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription

    Pass arguments to get_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).

    Parameters:

    • subscription (::String) (defaults to: nil)

      Required. The name of the subscription to get. Format is projects/{project}/subscriptions/{sub}.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 461

def get_subscription request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::GetSubscriptionRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_subscription..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::PubSub::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.subscription
    header_params["subscription"] = request.subscription
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_subscription.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_subscription.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @subscriber_stub.call_rpc :get_subscription, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_snapshots(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Snapshot> #list_snapshots(project: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Snapshot>

Lists the existing snapshots. 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.

Examples:

Basic example

require "google/cloud/pubsub/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::PubSub::V1::Subscriber::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::PubSub::V1::ListSnapshotsRequest.new

# Call the list_snapshots method.
result = client.list_snapshots 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::Snapshot.
  p response
end

Overloads:

  • #list_snapshots(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Snapshot>

    Pass arguments to list_snapshots via a request object, either of type ListSnapshotsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::PubSub::V1::ListSnapshotsRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_snapshots(project: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Snapshot>

    Pass arguments to list_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).

    Parameters:

    • project (::String) (defaults to: nil)

      Required. The name of the project in which to list snapshots. Format is projects/{project-id}.

    • page_size (::Integer) (defaults to: nil)

      Maximum number of snapshots to return.

    • page_token (::String) (defaults to: nil)

      The value returned by the last ListSnapshotsResponse; indicates that this is a continuation of a prior ListSnapshots call, and that the system should return the next page of data.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 1410

def list_snapshots request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ListSnapshotsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_snapshots..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::PubSub::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.project
    header_params["project"] = request.project
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_snapshots.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_snapshots.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @subscriber_stub.call_rpc :list_snapshots, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @subscriber_stub, :list_snapshots, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_subscriptions(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Subscription> #list_subscriptions(project: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Subscription>

Lists matching subscriptions.

Examples:

Basic example

require "google/cloud/pubsub/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::PubSub::V1::Subscriber::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::PubSub::V1::ListSubscriptionsRequest.new

# Call the list_subscriptions method.
result = client.list_subscriptions 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::Subscription.
  p response
end

Overloads:

  • #list_subscriptions(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Subscription>

    Pass arguments to list_subscriptions via a request object, either of type ListSubscriptionsRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::PubSub::V1::ListSubscriptionsRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_subscriptions(project: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Subscription>

    Pass arguments to list_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).

    Parameters:

    • project (::String) (defaults to: nil)

      Required. The name of the project in which to list subscriptions. Format is projects/{project-id}.

    • page_size (::Integer) (defaults to: nil)

      Maximum number of subscriptions to return.

    • page_token (::String) (defaults to: nil)

      The value returned by the last ListSubscriptionsResponse; indicates that this is a continuation of a prior ListSubscriptions call, and that the system should return the next page of data.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 648

def list_subscriptions request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ListSubscriptionsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_subscriptions..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::PubSub::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.project
    header_params["project"] = request.project
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_subscriptions.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_subscriptions.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @subscriber_stub.call_rpc :list_subscriptions, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @subscriber_stub, :list_subscriptions, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#modify_ack_deadline(request, options = nil) ⇒ ::Google::Protobuf::Empty #modify_ack_deadline(subscription: nil, ack_ids: nil, ack_deadline_seconds: nil) ⇒ ::Google::Protobuf::Empty

Modifies the ack deadline for a specific message. This method is useful to indicate that more time is needed to process a message by the subscriber, or to make the message available for redelivery if the processing was interrupted. Note that this does not modify the subscription-level ackDeadlineSeconds used for subsequent messages.

Examples:

Basic example

require "google/cloud/pubsub/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::PubSub::V1::Subscriber::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::PubSub::V1::ModifyAckDeadlineRequest.new

# Call the modify_ack_deadline method.
result = client.modify_ack_deadline request

# The returned object is of type Google::Protobuf::Empty.
p result

Overloads:

  • #modify_ack_deadline(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to modify_ack_deadline via a request object, either of type ModifyAckDeadlineRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::PubSub::V1::ModifyAckDeadlineRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #modify_ack_deadline(subscription: nil, ack_ids: nil, ack_deadline_seconds: nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to modify_ack_deadline 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).

    Parameters:

    • subscription (::String) (defaults to: nil)

      Required. The name of the subscription. Format is projects/{project}/subscriptions/{sub}.

    • ack_ids (::Array<::String>) (defaults to: nil)

      Required. List of acknowledgment IDs.

    • ack_deadline_seconds (::Integer) (defaults to: nil)

      Required. The new ack deadline with respect to the time this request was sent to the Pub/Sub system. For example, if the value is 10, the new ack deadline will expire 10 seconds after the ModifyAckDeadline call was made. Specifying zero might immediately make the message available for delivery to another subscriber client. This typically results in an increase in the rate of message redeliveries (that is, duplicates). The minimum deadline you can specify is 0 seconds. The maximum deadline you can specify is 600 seconds (10 minutes).

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 840

def modify_ack_deadline request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ModifyAckDeadlineRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.modify_ack_deadline..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::PubSub::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.subscription
    header_params["subscription"] = request.subscription
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.modify_ack_deadline.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.modify_ack_deadline.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @subscriber_stub.call_rpc :modify_ack_deadline, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#modify_push_config(request, options = nil) ⇒ ::Google::Protobuf::Empty #modify_push_config(subscription: nil, push_config: nil) ⇒ ::Google::Protobuf::Empty

Modifies the PushConfig for a specified subscription.

This may be used to change a push subscription to a pull one (signified by an empty PushConfig) or vice versa, or change the endpoint URL and other attributes of a push subscription. Messages will accumulate for delivery continuously through the call regardless of changes to the PushConfig.

Examples:

Basic example

require "google/cloud/pubsub/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::PubSub::V1::Subscriber::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::PubSub::V1::ModifyPushConfigRequest.new

# Call the modify_push_config method.
result = client.modify_push_config request

# The returned object is of type Google::Protobuf::Empty.
p result

Overloads:

  • #modify_push_config(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to modify_push_config via a request object, either of type ModifyPushConfigRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::PubSub::V1::ModifyPushConfigRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #modify_push_config(subscription: nil, push_config: nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to modify_push_config 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).

    Parameters:

    • subscription (::String) (defaults to: nil)

      Required. The name of the subscription. Format is projects/{project}/subscriptions/{sub}.

    • push_config (::Google::Cloud::PubSub::V1::PushConfig, ::Hash) (defaults to: nil)

      Required. The push configuration for future deliveries.

      An empty pushConfig indicates that the Pub/Sub system should stop pushing messages from the given subscription and allow messages to be pulled and acknowledged - effectively pausing the subscription if Pull or StreamingPull is not called.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 1218

def modify_push_config request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ModifyPushConfigRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.modify_push_config..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::PubSub::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.subscription
    header_params["subscription"] = request.subscription
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.modify_push_config.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.modify_push_config.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @subscriber_stub.call_rpc :modify_push_config, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#pull(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::PullResponse #pull(subscription: nil, return_immediately: nil, max_messages: nil) ⇒ ::Google::Cloud::PubSub::V1::PullResponse

Pulls messages from the server. The server may return UNAVAILABLE if there are too many concurrent pull requests pending for the given subscription.

Examples:

Basic example

require "google/cloud/pubsub/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::PubSub::V1::Subscriber::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::PubSub::V1::PullRequest.new

# Call the pull method.
result = client.pull request

# The returned object is of type Google::Cloud::PubSub::V1::PullResponse.
p result

Overloads:

  • #pull(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::PullResponse

    Pass arguments to pull via a request object, either of type PullRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::PubSub::V1::PullRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #pull(subscription: nil, return_immediately: nil, max_messages: nil) ⇒ ::Google::Cloud::PubSub::V1::PullResponse

    Pass arguments to pull 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).

    Parameters:

    • subscription (::String) (defaults to: nil)

      Required. The subscription from which messages should be pulled. Format is projects/{project}/subscriptions/{sub}.

    • return_immediately (::Boolean) (defaults to: nil)

      Optional. If this field set to true, the system will respond immediately even if it there are no messages available to return in the Pull response. Otherwise, the system may wait (for a bounded amount of time) until at least one message is available, rather than returning no messages. Warning: setting this field to true is discouraged because it adversely impacts the performance of Pull operations. We recommend that users do not set this field.

    • max_messages (::Integer) (defaults to: nil)

      Required. The maximum number of messages to return for this request. Must be a positive integer. The Pub/Sub system may return fewer than the number specified.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 1036

def pull request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::PullRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.pull..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::PubSub::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.subscription
    header_params["subscription"] = request.subscription
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.pull.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.pull.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @subscriber_stub.call_rpc :pull, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#seek(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::SeekResponse #seek(subscription: nil, time: nil, snapshot: nil) ⇒ ::Google::Cloud::PubSub::V1::SeekResponse

Seeks an existing subscription to a point in time or to a given snapshot, whichever is provided in the request. 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. Note that both the subscription and the snapshot must be on the same topic.

Examples:

Basic example

require "google/cloud/pubsub/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::PubSub::V1::Subscriber::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::PubSub::V1::SeekRequest.new

# Call the seek method.
result = client.seek request

# The returned object is of type Google::Cloud::PubSub::V1::SeekResponse.
p result

Overloads:

  • #seek(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::SeekResponse

    Pass arguments to seek via a request object, either of type Google::Cloud::PubSub::V1::SeekRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::PubSub::V1::SeekRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #seek(subscription: nil, time: nil, snapshot: nil) ⇒ ::Google::Cloud::PubSub::V1::SeekResponse

    Pass arguments to seek 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).

    Parameters:

    • subscription (::String) (defaults to: nil)

      Required. The subscription to affect.

    • time (::Google::Protobuf::Timestamp, ::Hash) (defaults to: nil)

      The time to seek to. Messages retained in the subscription that were published before this time are marked as acknowledged, and messages retained in the subscription that were published after this time are marked as unacknowledged. Note that this operation affects only those messages retained in the subscription (configured by the combination of message_retention_duration and retain_acked_messages). For example, if time corresponds to a point before the message retention window (or to a point before the system's notion of the subscription creation time), only retained messages will be marked as unacknowledged, and already-expunged messages will not be restored.

    • snapshot (::String) (defaults to: nil)

      The snapshot to seek to. The snapshot's topic must be the same as that of the provided subscription. Format is projects/{project}/snapshots/{snap}.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 1823

def seek request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::SeekRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.seek..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::PubSub::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.subscription
    header_params["subscription"] = request.subscription
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.seek.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.seek.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @subscriber_stub.call_rpc :seek, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#streaming_pull(request, options = nil) {|response, operation| ... } ⇒ ::Enumerable<::Google::Cloud::PubSub::V1::StreamingPullResponse>

Establishes a stream with the server, which sends messages down to the client. The client streams acknowledgements and ack deadline modifications back to the server. The server will close the stream and return the status on any error. The server may close the stream with status UNAVAILABLE to reassign server-side resources, in which case, the client should re-establish the stream. Flow control can be achieved by configuring the underlying RPC channel.

Examples:

Basic example

require "google/cloud/pubsub/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::PubSub::V1::Subscriber::Client.new

# Create an input stream
input = Gapic::StreamInput.new

# Call the streaming_pull method to start streaming.
output = client.streaming_pull input

# Send requests on the stream. For each request, pass in keyword
# arguments to set fields. Be sure to close the stream when done.
input << Google::Cloud::PubSub::V1::StreamingPullRequest.new
input << Google::Cloud::PubSub::V1::StreamingPullRequest.new
input.close

# Handle streamed responses. These may be interleaved with inputs.
# Each response is of type ::Google::Cloud::PubSub::V1::StreamingPullResponse.
output.each do |response|
  p response
end

Parameters:

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 1123

def streaming_pull request, options = nil
  unless request.is_a? ::Enumerable
    raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
    request = request.to_enum
  end

  request = request.lazy.map do |req|
    ::Gapic::Protobuf.coerce req, to: ::Google::Cloud::PubSub::V1::StreamingPullRequest
  end

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.streaming_pull..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::PubSub::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  options.apply_defaults timeout:      @config.rpcs.streaming_pull.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.streaming_pull.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @subscriber_stub.call_rpc :streaming_pull, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#update_snapshot(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot #update_snapshot(snapshot: nil, update_mask: nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot

Updates an existing snapshot. 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.

Examples:

Basic example

require "google/cloud/pubsub/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::PubSub::V1::Subscriber::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::PubSub::V1::UpdateSnapshotRequest.new

# Call the update_snapshot method.
result = client.update_snapshot request

# The returned object is of type Google::Cloud::PubSub::V1::Snapshot.
p result

Overloads:

  • #update_snapshot(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot

    Pass arguments to update_snapshot via a request object, either of type UpdateSnapshotRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::PubSub::V1::UpdateSnapshotRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #update_snapshot(snapshot: nil, update_mask: nil) ⇒ ::Google::Cloud::PubSub::V1::Snapshot

    Pass arguments to update_snapshot 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).

    Parameters:

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 1622

def update_snapshot request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::UpdateSnapshotRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_snapshot..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::PubSub::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.snapshot&.name
    header_params["snapshot.name"] = request.snapshot.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.update_snapshot.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_snapshot.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @subscriber_stub.call_rpc :update_snapshot, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#update_subscription(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription #update_subscription(subscription: nil, update_mask: nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription

Updates an existing subscription. Note that certain properties of a subscription, such as its topic, are not modifiable.

Examples:

Basic example

require "google/cloud/pubsub/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::PubSub::V1::Subscriber::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::PubSub::V1::UpdateSubscriptionRequest.new

# Call the update_subscription method.
result = client.update_subscription request

# The returned object is of type Google::Cloud::PubSub::V1::Subscription.
p result

Overloads:

  • #update_subscription(request, options = nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription

    Pass arguments to update_subscription via a request object, either of type UpdateSubscriptionRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::PubSub::V1::UpdateSubscriptionRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #update_subscription(subscription: nil, update_mask: nil) ⇒ ::Google::Cloud::PubSub::V1::Subscription

    Pass arguments to update_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).

    Parameters:

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
# File 'lib/google/cloud/pubsub/v1/subscriber/client.rb', line 550

def update_subscription request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::UpdateSubscriptionRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_subscription..to_h

  # Set x-goog-api-client and x-goog-user-project headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::PubSub::V1::VERSION
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.subscription&.name
    header_params["subscription.name"] = request.subscription.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.update_subscription.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_subscription.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @subscriber_stub.call_rpc :update_subscription, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end