google-cloud-pubsub 1.5.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1306c932b52a6c12aa2aa1e6ba1100ca90ae78a364ce07d8c5844c517c547f4
4
- data.tar.gz: f6b9413d4d64cebd698f02b7e7a169da5066c9f05d967432ac69737f1e8d76e5
3
+ metadata.gz: 5dc069dbd6e0c8e77d39c6a27b148755fe6935d58ca2af7babc2c167c22513e0
4
+ data.tar.gz: b2509a217ba7e2a76675a95e1b95884c1e285224c8b194af9299e56aedf9ceea
5
5
  SHA512:
6
- metadata.gz: ebd17aea2e53e2b4fbcaa7b5dd76954fe73aa6eb36402db2014e7d7904df0db022f49a7a2cac574567b9f58c70632f7d4360b12c9a96fed15e1f1f133e3a9df2
7
- data.tar.gz: a1c0e15330824046f66db7ccb5105b16ee07984c36080338d38302ace2c1c5fded2c3e59ba4979c0d4e63c7becdc425a1b25587fda71508b86492cd03fadf8ba
6
+ metadata.gz: e5d900b940dd93fb85be47f23f233d9183a5cb150a18a7e93687ed4dba45ece70d044129ccc5162477f0bc4a58b439c25b7aca2cc3ccdc5dc1ff7434b869b5e6
7
+ data.tar.gz: 4e5960220728a2ab73ff69ee3da5a6e11322a6fb1c50d40d7aadaffb7adf26d01383a9972d15ea2af0ed29b3b867f8b05b4194dac55db9f3c808eeea55030e51
@@ -1,5 +1,48 @@
1
1
  # Release History
2
2
 
3
+ ### 1.8.0 / 2020-06-29
4
+
5
+ #### Features
6
+
7
+ * Add Subscription#filter
8
+
9
+ ### 1.7.1 / 2020-05-28
10
+
11
+ #### Documentation
12
+
13
+ * Fix a few broken links
14
+
15
+ ### 1.7.0 / 2020-05-21
16
+
17
+ #### Features
18
+
19
+ * Add Retry Policy support
20
+ * Add RetryPolicy
21
+ * Add retry_policy param to Topic#subscribe
22
+ * Add Subscription#retry_policy
23
+ * Add Subscription#retry_policy=
24
+ * Set client-scoped UUID in initial StreamingPullRequest#client_id
25
+
26
+ ### 1.6.1 / 2020-05-06
27
+
28
+ #### Documentation
29
+
30
+ * Fix example in Emulator documentation
31
+ * Remove experimental notice from ReceivedMessage#delivery_attempt
32
+ * Wrap example URLs in backticks
33
+
34
+ ### 1.6.0 / 2020-04-06
35
+
36
+ #### Features
37
+
38
+ * Add list_topic_snapshots and get_snapshot
39
+ * Add PublisherClient#list_topic_snapshots
40
+ * Add SubscriberClient#get_snapshot
41
+
42
+ #### Documentation
43
+
44
+ * Remove a spurious link in the low-level interface documentation.
45
+
3
46
  ### 1.5.0 / 2020-03-25
4
47
 
5
48
  #### Features
@@ -17,7 +17,7 @@ require "google/cloud/pubsub"
17
17
  # Make Pub/Sub use the emulator
18
18
  ENV["PUBSUB_EMULATOR_HOST"] = "localhost:8918"
19
19
 
20
- pubsub = Google::Cloud::PubSub.new "emulator-project-id"
20
+ pubsub = Google::Cloud::PubSub.new project_id:"emulator-project-id"
21
21
 
22
22
  # Get a topic in the current project
23
23
  my_topic = pubsub.new_topic "my-topic"
@@ -24,14 +24,8 @@ improved, *please* create a new issue on GitHub so we can talk about it.
24
24
 
25
25
  - [New issue][gh-ruby]
26
26
 
27
- Or, you can ask questions on the [Google Cloud Platform Slack][slack-ruby]. You
28
- can use the "ruby" channel for general Ruby questions, or use the
29
- "google-cloud-ruby" channel if you have questions about this gem in particular.
30
-
31
27
  [so-ruby]: http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby+pubsub
32
28
 
33
- [gh-search-ruby]: https://github.com/googlecloudplatform/google-cloud-ruby/issues?q=label%3A%22api%3A+pubsub%22
34
-
35
- [gh-ruby]: https://github.com/googlecloudplatform/google-cloud-ruby/issues/new
29
+ [gh-search-ruby]: https://github.com/googleapis/google-cloud-ruby/issues?q=label%3A%22api%3A+pubsub%22
36
30
 
37
- [slack-ruby]: https://gcp-slack.appspot.com/
31
+ [gh-ruby]: https://github.com/googleapis/google-cloud-ruby/issues/new
@@ -78,11 +78,6 @@ module Google
78
78
  # The first delivery of a given message will have this value as `1`. The value is calculated at best effort and
79
79
  # is approximate.
80
80
  #
81
- # EXPERIMENTAL: This feature is part of a closed alpha release and is available only to whitelisted partners.
82
- # This method will return `nil` if a dead letter policy is not set on the subscription. This API might be
83
- # changed in backward-incompatible ways and is not recommended for production use. It is not subject to any SLA
84
- # or deprecation policy.
85
- #
86
81
  # @return [Integer, nil] A delivery attempt value of `1` or greater, or `nil` if a dead letter policy is not set
87
82
  # on the subscription.
88
83
  #
@@ -0,0 +1,90 @@
1
+ # Copyright 2016 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+
16
+ require "google/cloud/errors"
17
+
18
+ module Google
19
+ module Cloud
20
+ module PubSub
21
+ ##
22
+ # # RetryPolicy
23
+ #
24
+ # An immutable Retry Policy value object that specifies how Cloud Pub/Sub retries message delivery.
25
+ #
26
+ # Retry delay will be exponential based on provided minimum and maximum backoffs. (See [Exponential
27
+ # backoff](https://en.wikipedia.org/wiki/Exponential_backoff).)
28
+ #
29
+ # Retry Policy will be triggered on NACKs or acknowledgement deadline exceeded events for a given message.
30
+ #
31
+ # Retry Policy is implemented on a best effort basis. At times, the delay between consecutive deliveries may not
32
+ # match the configuration. That is, delay can be more or less than configured backoff.
33
+ #
34
+ # **EXPERIMENTAL:** This API might be changed in backward-incompatible ways and is not recommended for production
35
+ # use. It is not subject to any SLA or deprecation policy.
36
+ #
37
+ # @attr [Numeric] minimum_backoff The minimum delay between consecutive deliveries of a given message. Value
38
+ # should be between 0 and 600 seconds. The default value is 10 seconds.
39
+ # @attr [Numeric] maximum_backoff The maximum delay between consecutive deliveries of a given message. Value
40
+ # should be between 0 and 600 seconds. The default value is 600 seconds.
41
+ #
42
+ # @example
43
+ # require "google/cloud/pubsub"
44
+ #
45
+ # pubsub = Google::Cloud::PubSub.new
46
+ #
47
+ # sub = pubsub.subscription "my-topic-sub"
48
+ #
49
+ # sub.retry_policy = Google::Cloud::PubSub::RetryPolicy.new minimum_backoff: 5, maximum_backoff: 300
50
+ #
51
+ # sub.retry_policy.minimum_backoff #=> 5
52
+ # sub.retry_policy.maximum_backoff #=> 300
53
+ #
54
+ class RetryPolicy
55
+ attr_reader :minimum_backoff, :maximum_backoff
56
+
57
+ ##
58
+ # Creates a new, immutable RetryPolicy value object.
59
+ #
60
+ # @attr [Numeric, nil] minimum_backoff The minimum delay between consecutive deliveries of a given message.
61
+ # Value should be between 0 and 600 seconds. If `nil` is provided, the default value is 10 seconds.
62
+ # @attr [Numeric, nil] maximum_backoff The maximum delay between consecutive deliveries of a given message.
63
+ # Value should be between 0 and 600 seconds. If `nil` is provided, the default value is 600 seconds.
64
+ #
65
+ def initialize minimum_backoff: nil, maximum_backoff: nil
66
+ @minimum_backoff = minimum_backoff
67
+ @maximum_backoff = maximum_backoff
68
+ end
69
+
70
+ ##
71
+ # @private Convert the RetryPolicy to a Google::Cloud::PubSub::V1::RetryPolicy object.
72
+ def to_grpc
73
+ Google::Cloud::PubSub::V1::RetryPolicy.new(
74
+ minimum_backoff: Convert.number_to_duration(minimum_backoff),
75
+ maximum_backoff: Convert.number_to_duration(maximum_backoff)
76
+ )
77
+ end
78
+
79
+ ##
80
+ # @private New RetryPolicy from a Google::Cloud::PubSub::V1::RetryPolicy object.
81
+ def self.from_grpc grpc
82
+ new(
83
+ minimum_backoff: Convert.duration_to_number(grpc.minimum_backoff),
84
+ maximum_backoff: Convert.duration_to_number(grpc.maximum_backoff)
85
+ )
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -19,6 +19,7 @@ require "google/cloud/pubsub/convert"
19
19
  require "google/cloud/pubsub/version"
20
20
  require "google/cloud/pubsub/v1"
21
21
  require "google/gax/errors"
22
+ require "securerandom"
22
23
 
23
24
  module Google
24
25
  module Cloud
@@ -28,6 +29,12 @@ module Google
28
29
  # methods.
29
30
  class Service
30
31
  attr_accessor :project, :credentials, :host, :timeout, :client_config
32
+ ###
33
+ # The same client_id is used across all streaming pull connections that are created by this client. This is
34
+ # intentional, as it indicates to the server that any guarantees, such as message ordering, made for a stream
35
+ # that is disconnected will be made for the stream that is created to replace it. The attr_accessor allows the
36
+ # value to be replaced for unit testing.
37
+ attr_accessor :client_id
31
38
 
32
39
  ##
33
40
  # Creates a new Service instance.
@@ -38,6 +45,7 @@ module Google
38
45
  @host = host || V1::PublisherClient::SERVICE_ADDRESS
39
46
  @timeout = timeout
40
47
  @client_config = client_config || {}
48
+ @client_id = SecureRandom.uuid.freeze
41
49
  end
42
50
 
43
51
  def channel
@@ -233,21 +241,19 @@ module Google
233
241
  push_endpoint: options[:endpoint],
234
242
  attributes: (options[:attributes] || {}).to_h
235
243
  end
236
- deadline = options[:deadline]
237
- retain_acked = options[:retain_acked]
238
244
  mrd = Convert.number_to_duration options[:retention]
239
- labels = options[:labels]
240
- message_ordering = options[:message_ordering]
241
245
  execute do
242
246
  subscriber.create_subscription \
243
247
  name, topic,
244
248
  push_config: push_config,
245
- ack_deadline_seconds: deadline,
246
- retain_acked_messages: retain_acked,
249
+ ack_deadline_seconds: options[:deadline],
250
+ retain_acked_messages: options[:retain_acked],
247
251
  message_retention_duration: mrd,
248
- labels: labels,
249
- enable_message_ordering: message_ordering,
252
+ labels: options[:labels],
253
+ enable_message_ordering: options[:message_ordering],
254
+ filter: options[:filter],
250
255
  dead_letter_policy: dead_letter_policy(options),
256
+ retry_policy: options[:retry_policy],
251
257
  options: default_options
252
258
  end
253
259
  end
@@ -363,6 +363,7 @@ module Google
363
363
  req.stream_ack_deadline_seconds = @subscriber.deadline
364
364
  req.modify_deadline_ack_ids += @inventory.ack_ids
365
365
  req.modify_deadline_seconds += @inventory.ack_ids.map { @subscriber.deadline }
366
+ req.client_id = @subscriber.service.client_id
366
367
  end
367
368
  end
368
369
 
@@ -18,6 +18,7 @@ require "google/cloud/errors"
18
18
  require "google/cloud/pubsub/subscription/list"
19
19
  require "google/cloud/pubsub/subscription/push_config"
20
20
  require "google/cloud/pubsub/received_message"
21
+ require "google/cloud/pubsub/retry_policy"
21
22
  require "google/cloud/pubsub/snapshot"
22
23
  require "google/cloud/pubsub/subscriber"
23
24
  require "google/cloud/pubsub/v1"
@@ -188,7 +189,7 @@ module Google
188
189
  ##
189
190
  # Returns the URL locating the endpoint to which messages should be
190
191
  # pushed. For example, a Webhook endpoint might use
191
- # "https://example.com/push".
192
+ # `https://example.com/push`.
192
193
  #
193
194
  # Makes an API call to retrieve the endpoint value when called on a
194
195
  # reference object. See {#reference?}.
@@ -202,7 +203,7 @@ module Google
202
203
 
203
204
  ##
204
205
  # Sets the URL locating the endpoint to which messages should be pushed.
205
- # For example, a Webhook endpoint might use "https://example.com/push".
206
+ # For example, a Webhook endpoint might use `https://example.com/push`.
206
207
  #
207
208
  # @param [String] new_endpoint The new endpoint value.
208
209
  #
@@ -352,6 +353,18 @@ module Google
352
353
  @resource_name = nil
353
354
  end
354
355
 
356
+ ##
357
+ # An expression written in the Cloud Pub/Sub filter language. If non-empty, then only {Message} instances whose
358
+ # `attributes` field matches the filter are delivered on this subscription. If empty, then no messages are
359
+ # filtered out.
360
+ #
361
+ # @return [String] The frozen filter string.
362
+ #
363
+ def filter
364
+ ensure_grpc!
365
+ @grpc.filter.freeze
366
+ end
367
+
355
368
  ##
356
369
  # Returns the {Topic} to which dead letter messages should be published if a dead letter policy is configured,
357
370
  # otherwise `nil`. Dead lettering is done on a best effort basis. The same message might be dead lettered
@@ -483,6 +496,65 @@ module Google
483
496
  @resource_name = nil
484
497
  end
485
498
 
499
+ ##
500
+ # A policy that specifies how Cloud Pub/Sub retries message delivery for this subscription. If `nil`, the
501
+ # default retry policy is applied. This generally implies that messages will be retried as soon as possible
502
+ # for healthy subscribers. Retry Policy will be triggered on NACKs or acknowledgement deadline exceeded events
503
+ # for a given message.
504
+ #
505
+ # **EXPERIMENTAL:** This API might be changed in backward-incompatible ways and is not recommended for
506
+ # production use. It is not subject to any SLA or deprecation policy.
507
+ #
508
+ # @return [RetryPolicy, nil] The retry policy for the subscription, or `nil`.
509
+ #
510
+ # @example
511
+ # require "google/cloud/pubsub"
512
+ #
513
+ # pubsub = Google::Cloud::PubSub.new
514
+ #
515
+ # sub = pubsub.subscription "my-topic-sub"
516
+ #
517
+ # sub.retry_policy = Google::Cloud::PubSub::RetryPolicy.new minimum_backoff: 5, maximum_backoff: 300
518
+ #
519
+ # sub.retry_policy.minimum_backoff #=> 5
520
+ # sub.retry_policy.maximum_backoff #=> 300
521
+ #
522
+ def retry_policy
523
+ ensure_grpc!
524
+ return nil unless @grpc.retry_policy
525
+ RetryPolicy.from_grpc @grpc.retry_policy
526
+ end
527
+
528
+ ##
529
+ # Sets a policy that specifies how Cloud Pub/Sub retries message delivery for this subscription. If `nil`, the
530
+ # default retry policy is applied. This generally implies that messages will be retried as soon as possible
531
+ # for healthy subscribers. Retry Policy will be triggered on NACKs or acknowledgement deadline exceeded events
532
+ # for a given message.
533
+ #
534
+ # **EXPERIMENTAL:** This API might be changed in backward-incompatible ways and is not recommended for
535
+ # production use. It is not subject to any SLA or deprecation policy.
536
+ #
537
+ # @param [RetryPolicy, nil] new_retry_policy A new retry policy for the subscription, or `nil`.
538
+ #
539
+ # @example
540
+ # require "google/cloud/pubsub"
541
+ #
542
+ # pubsub = Google::Cloud::PubSub.new
543
+ #
544
+ # sub = pubsub.subscription "my-topic-sub"
545
+ #
546
+ # sub.retry_policy = Google::Cloud::PubSub::RetryPolicy.new minimum_backoff: 5, maximum_backoff: 300
547
+ #
548
+ # sub.retry_policy.minimum_backoff #=> 5
549
+ # sub.retry_policy.maximum_backoff #=> 300
550
+ #
551
+ def retry_policy= new_retry_policy
552
+ ensure_grpc!
553
+ new_retry_policy = new_retry_policy.to_grpc if new_retry_policy
554
+ update_grpc = Google::Cloud::PubSub::V1::Subscription.new name: name, retry_policy: new_retry_policy
555
+ @grpc = service.update_subscription update_grpc, :retry_policy
556
+ end
557
+
486
558
  ##
487
559
  # Whether message ordering has been enabled. When enabled, messages
488
560
  # published with the same `ordering_key` will be delivered in the order
@@ -52,7 +52,7 @@ module Google
52
52
 
53
53
  ##
54
54
  # A URL locating the endpoint to which messages should be pushed. For
55
- # example, a Webhook endpoint might use "https://example.com/push".
55
+ # example, a Webhook endpoint might use `https://example.com/push`.
56
56
  #
57
57
  # @return [String]
58
58
  def endpoint
@@ -62,7 +62,7 @@ module Google
62
62
  ##
63
63
  # Sets the URL locating the endpoint to which messages should be
64
64
  # pushed. For example, a Webhook endpoint might use
65
- # "https://example.com/push".
65
+ # `https://example.com/push`.
66
66
  #
67
67
  # @param [String, nil] new_endpoint New URL value
68
68
  def endpoint= new_endpoint
@@ -19,6 +19,7 @@ require "google/cloud/pubsub/async_publisher"
19
19
  require "google/cloud/pubsub/batch_publisher"
20
20
  require "google/cloud/pubsub/subscription"
21
21
  require "google/cloud/pubsub/policy"
22
+ require "google/cloud/pubsub/retry_policy"
22
23
 
23
24
  module Google
24
25
  module Cloud
@@ -285,6 +286,9 @@ module Google
285
286
  # Managing Labels](https://cloud.google.com/pubsub/docs/labels).
286
287
  # @param [Boolean] message_ordering Whether to enable message ordering
287
288
  # on the subscription.
289
+ # @param [String] filter An expression written in the Cloud Pub/Sub filter language. If non-empty, then only
290
+ # {Message} instances whose `attributes` field matches the filter are delivered on this subscription. If
291
+ # empty, then no messages are filtered out. Optional.
288
292
  # @param [Topic] dead_letter_topic The {Topic} to which dead letter messages for the subscription should be
289
293
  # published. Dead lettering is done on a best effort basis. The same message might be dead lettered multiple
290
294
  # times. The Cloud Pub/Sub service account associated with the enclosing subscription's parent project (i.e.,
@@ -297,6 +301,13 @@ module Google
297
301
  # the subscription's dead letter policy. Dead lettering is done on a best effort basis. The same message might
298
302
  # be dead lettered multiple times. The value must be between 5 and 100. If this parameter is 0, a default
299
303
  # value of 5 is used. The `dead_letter_topic` must also be set.
304
+ # @param [RetryPolicy] retry_policy A policy that specifies how Cloud Pub/Sub retries message delivery for
305
+ # this subscription. If not set, the default retry policy is applied. This generally implies that messages
306
+ # will be retried as soon as possible for healthy subscribers. Retry Policy will be triggered on NACKs or
307
+ # acknowledgement deadline exceeded events for a given message.
308
+ #
309
+ # **EXPERIMENTAL:** This API might be changed in backward-incompatible ways and is not recommended for
310
+ # production use. It is not subject to any SLA or deprecation policy.
300
311
  #
301
312
  # @return [Google::Cloud::PubSub::Subscription]
302
313
  #
@@ -340,17 +351,29 @@ module Google
340
351
  # dead_letter_topic: dead_letter_topic,
341
352
  # dead_letter_max_delivery_attempts: 10
342
353
  #
354
+ # @example Configure a Retry Policy:
355
+ # require "google/cloud/pubsub"
356
+ #
357
+ # pubsub = Google::Cloud::PubSub.new
358
+ #
359
+ # topic = pubsub.topic "my-topic"
360
+ #
361
+ # retry_policy = Google::Cloud::PubSub::RetryPolicy.new minimum_backoff: 5, maximum_backoff: 300
362
+ # sub = topic.subscribe "my-topic-sub", retry_policy: retry_policy
363
+ #
343
364
  def subscribe subscription_name, deadline: nil, retain_acked: false, retention: nil, endpoint: nil, labels: nil,
344
- message_ordering: nil, dead_letter_topic: nil, dead_letter_max_delivery_attempts: nil
365
+ message_ordering: nil, filter: nil, dead_letter_topic: nil,
366
+ dead_letter_max_delivery_attempts: nil, retry_policy: nil
345
367
  ensure_service!
346
368
  options = { deadline: deadline, retain_acked: retain_acked, retention: retention, endpoint: endpoint,
347
- labels: labels, message_ordering: message_ordering,
369
+ labels: labels, message_ordering: message_ordering, filter: filter,
348
370
  dead_letter_max_delivery_attempts: dead_letter_max_delivery_attempts }
349
371
  options[:dead_letter_topic_name] = dead_letter_topic.name if dead_letter_topic
350
372
  if options[:dead_letter_max_delivery_attempts] && !options[:dead_letter_topic_name]
351
373
  # Service error message "3:Invalid resource name given (name=)." does not identify param.
352
374
  raise ArgumentError, "dead_letter_topic is required with dead_letter_max_delivery_attempts"
353
375
  end
376
+ options[:retry_policy] = retry_policy.to_grpc if retry_policy
354
377
  grpc = service.create_subscription name, subscription_name, options
355
378
  Subscription.from_grpc grpc, service
356
379
  end
@@ -17,6 +17,7 @@ module Google
17
17
  module Cloud
18
18
  module PubSub
19
19
  module V1
20
+ # A policy constraining the storage of messages published to the topic.
20
21
  # @!attribute [rw] allowed_persistence_regions
21
22
  # @return [Array<String>]
22
23
  # A list of IDs of GCP regions where messages that are published to the topic
@@ -67,7 +68,8 @@ module Google
67
68
  # @!attribute [rw] attributes
68
69
  # @return [Hash{String => String}]
69
70
  # Attributes for this message. If this field is empty, the message must
70
- # contain non-empty data.
71
+ # contain non-empty data. This can be used to filter messages on the
72
+ # subscription.
71
73
  # @!attribute [rw] message_id
72
74
  # @return [String]
73
75
  # ID of this message, assigned by the server when the message is published.
@@ -107,9 +109,9 @@ module Google
107
109
  # @return [Google::Protobuf::FieldMask]
108
110
  # Required. Indicates which fields in the provided topic to update. Must be
109
111
  # specified and non-empty. Note that if `update_mask` contains
110
- # "message_storage_policy" then the new value will be determined based on the
111
- # policy configured at the project or organization level. The
112
- # `message_storage_policy` must not be set in the `topic` provided above.
112
+ # "message_storage_policy" but the `message_storage_policy` is not set in
113
+ # the `topic` provided above, then the updated value is determined by the
114
+ # policy configured at the project or organization level.
113
115
  class UpdateTopicRequest; end
114
116
 
115
117
  # Request for the Publish method.
@@ -173,7 +175,7 @@ module Google
173
175
  # Response for the `ListTopicSubscriptions` method.
174
176
  # @!attribute [rw] subscriptions
175
177
  # @return [Array<String>]
176
- # The names of the subscriptions that match the request.
178
+ # The names of subscriptions attached to the topic specified in the request.
177
179
  # @!attribute [rw] next_page_token
178
180
  # @return [String]
179
181
  # If not empty, indicates that there may be more subscriptions that match
@@ -214,6 +216,17 @@ module Google
214
216
  # Format is `projects/{project}/topics/{topic}`.
215
217
  class DeleteTopicRequest; end
216
218
 
219
+ # Request for the DetachSubscription method.
220
+ # @!attribute [rw] subscription
221
+ # @return [String]
222
+ # Required. The subscription to detach.
223
+ # Format is `projects/{project}/subscriptions/{subscription}`.
224
+ class DetachSubscriptionRequest; end
225
+
226
+ # Response for the DetachSubscription method.
227
+ # Reserved for future use.
228
+ class DetachSubscriptionResponse; end
229
+
217
230
  # A subscription resource.
218
231
  # @!attribute [rw] name
219
232
  # @return [String]
@@ -295,13 +308,11 @@ module Google
295
308
  # value for `expiration_policy.ttl` is 1 day.
296
309
  # @!attribute [rw] filter
297
310
  # @return [String]
298
- # An expression written in the Cloud Pub/Sub filter language. If non-empty,
311
+ # An expression written in the Pub/Sub [filter
312
+ # language](https://cloud.google.com/pubsub/docs/filtering). If non-empty,
299
313
  # then only `PubsubMessage`s whose `attributes` field matches the filter are
300
314
  # delivered on this subscription. If empty, then no messages are filtered
301
315
  # out.
302
- # <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
303
- # API might be changed in backward-incompatible ways and is not recommended
304
- # for production use. It is not subject to any SLA or deprecation policy.
305
316
  # @!attribute [rw] dead_letter_policy
306
317
  # @return [Google::Cloud::PubSub::V1::DeadLetterPolicy]
307
318
  # A policy that specifies the conditions for dead lettering messages in
@@ -312,21 +323,22 @@ module Google
312
323
  # parent project (i.e.,
313
324
  # service-\\{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have
314
325
  # permission to Acknowledge() messages on this subscription.
315
- # <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
316
- # API might be changed in backward-incompatible ways and is not recommended
317
- # for production use. It is not subject to any SLA or deprecation policy.
318
326
  # @!attribute [rw] retry_policy
319
327
  # @return [Google::Cloud::PubSub::V1::RetryPolicy]
320
- # A policy that specifies how Cloud Pub/Sub retries message delivery for this
328
+ # A policy that specifies how Pub/Sub retries message delivery for this
321
329
  # subscription.
322
330
  #
323
331
  # If not set, the default retry policy is applied. This generally implies
324
332
  # that messages will be retried as soon as possible for healthy subscribers.
325
333
  # RetryPolicy will be triggered on NACKs or acknowledgement deadline
326
334
  # exceeded events for a given message.
327
- # <b>EXPERIMENTAL:</b> This API might be changed in backward-incompatible
328
- # ways and is not recommended for production use. It is not subject to any
329
- # SLA or deprecation policy.
335
+ # @!attribute [rw] detached
336
+ # @return [true, false]
337
+ # Indicates whether the subscription is detached from its topic. Detached
338
+ # subscriptions don't receive messages from their topic and don't retain any
339
+ # backlog. `Pull` and `StreamingPull` requests will return
340
+ # FAILED_PRECONDITION. If the subscription is a push subscription, pushes to
341
+ # the endpoint will not be made.
330
342
  class Subscription; end
331
343
 
332
344
  # A policy that specifies how Cloud Pub/Sub retries message delivery.
@@ -399,7 +411,7 @@ module Google
399
411
  # @!attribute [rw] push_endpoint
400
412
  # @return [String]
401
413
  # A URL locating the endpoint to which messages should be pushed.
402
- # For example, a Webhook endpoint might use "https://example.com/push".
414
+ # For example, a Webhook endpoint might use `https://example.com/push`.
403
415
  # @!attribute [rw] attributes
404
416
  # @return [Hash{String => String}]
405
417
  # Endpoint configuration attributes that can be used to control different
@@ -458,8 +470,11 @@ module Google
458
470
  # The message.
459
471
  # @!attribute [rw] delivery_attempt
460
472
  # @return [Integer]
461
- # Delivery attempt counter is 1 + (the sum of number of NACKs and number of
462
- # ack_deadline exceeds) for this message.
473
+ # The approximate number of times that Cloud Pub/Sub has attempted to deliver
474
+ # the associated message to a subscriber.
475
+ #
476
+ # More precisely, this is 1 + (number of NACKs) +
477
+ # (number of ack_deadline exceeds) for this message.
463
478
  #
464
479
  # A NACK is any call to ModifyAckDeadline with a 0 deadline. An ack_deadline
465
480
  # exceeds event is whenever a message is not acknowledged within
@@ -467,13 +482,10 @@ module Google
467
482
  # Subscription.ackDeadlineSeconds, but may get extended automatically by
468
483
  # the client library.
469
484
  #
470
- # The first delivery of a given message will have this value as 1. The value
471
- # is calculated at best effort and is approximate.
485
+ # Upon the first delivery of a given message, `delivery_attempt` will have a
486
+ # value of 1. The value is calculated at best effort and is approximate.
472
487
  #
473
488
  # If a DeadLetterPolicy is not set on the subscription, this will be 0.
474
- # <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
475
- # API might be changed in backward-incompatible ways and is not recommended
476
- # for production use. It is not subject to any SLA or deprecation policy.
477
489
  class ReceivedMessage; end
478
490
 
479
491
  # Request for the GetSubscription method.
@@ -653,6 +665,28 @@ module Google
653
665
  # to the same value so that state associated with the old stream can be
654
666
  # transferred to the new stream. The same client_id should not be used for
655
667
  # different client instances.
668
+ # @!attribute [rw] max_outstanding_messages
669
+ # @return [Integer]
670
+ # Flow control settings for the maximum number of outstanding messages. When
671
+ # there are `max_outstanding_messages` or more currently sent to the
672
+ # streaming pull client that have not yet been acked or nacked, the server
673
+ # stops sending more messages. The sending of messages resumes once the
674
+ # number of outstanding messages is less than this value. If the value is
675
+ # <= 0, there is no limit to the number of outstanding messages. This
676
+ # property can only be set on the initial StreamingPullRequest. If it is set
677
+ # on a subsequent request, the stream will be aborted with status
678
+ # `INVALID_ARGUMENT`.
679
+ # @!attribute [rw] max_outstanding_bytes
680
+ # @return [Integer]
681
+ # Flow control settings for the maximum number of outstanding bytes. When
682
+ # there are `max_outstanding_bytes` or more worth of messages currently sent
683
+ # to the streaming pull client that have not yet been acked or nacked, the
684
+ # server will stop sending more messages. The sending of messages resumes
685
+ # once the number of outstanding bytes is less than this value. If the value
686
+ # is <= 0, there is no limit to the number of outstanding bytes. This
687
+ # property can only be set on the initial StreamingPullRequest. If it is set
688
+ # on a subsequent request, the stream will be aborted with status
689
+ # `INVALID_ARGUMENT`.
656
690
  class StreamingPullRequest; end
657
691
 
658
692
  # Response for the `StreamingPull` method. This response is used to stream
@@ -64,7 +64,11 @@ module Google
64
64
  "list_topic_subscriptions" => Google::Gax::PageDescriptor.new(
65
65
  "page_token",
66
66
  "next_page_token",
67
- "subscriptions")
67
+ "subscriptions"),
68
+ "list_topic_snapshots" => Google::Gax::PageDescriptor.new(
69
+ "page_token",
70
+ "next_page_token",
71
+ "snapshots")
68
72
  }.freeze
69
73
 
70
74
  private_constant :PAGE_DESCRIPTORS
@@ -94,6 +98,12 @@ module Google
94
98
 
95
99
  private_constant :PROJECT_PATH_TEMPLATE
96
100
 
101
+ SUBSCRIPTION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
102
+ "projects/{project}/subscriptions/{subscription}"
103
+ )
104
+
105
+ private_constant :SUBSCRIPTION_PATH_TEMPLATE
106
+
97
107
  TOPIC_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
98
108
  "projects/{project}/topics/{topic}"
99
109
  )
@@ -109,9 +119,18 @@ module Google
109
119
  )
110
120
  end
111
121
 
122
+ # Returns a fully-qualified subscription resource name string.
123
+ # @param project [String]
124
+ # @param subscription [String]
125
+ # @return [String]
126
+ def self.subscription_path project, subscription
127
+ SUBSCRIPTION_PATH_TEMPLATE.render(
128
+ :"project" => project,
129
+ :"subscription" => subscription
130
+ )
131
+ end
132
+
112
133
  # Returns a fully-qualified topic resource name string.
113
- # @deprecated Multi-pattern resource names will have unified creation and parsing helper functions.
114
- # This helper function will be deleted in the next major version.
115
134
  # @param project [String]
116
135
  # @param topic [String]
117
136
  # @return [String]
@@ -294,6 +313,14 @@ module Google
294
313
  {'topic' => request.topic}
295
314
  end
296
315
  )
316
+ @list_topic_snapshots = Google::Gax.create_api_call(
317
+ @publisher_stub.method(:list_topic_snapshots),
318
+ defaults["list_topic_snapshots"],
319
+ exception_transformer: exception_transformer,
320
+ params_extractor: proc do |request|
321
+ {'topic' => request.topic}
322
+ end
323
+ )
297
324
  @delete_topic = Google::Gax.create_api_call(
298
325
  @publisher_stub.method(:delete_topic),
299
326
  defaults["delete_topic"],
@@ -326,6 +353,14 @@ module Google
326
353
  {'resource' => request.resource}
327
354
  end
328
355
  )
356
+ @detach_subscription = Google::Gax.create_api_call(
357
+ @publisher_stub.method(:detach_subscription),
358
+ defaults["detach_subscription"],
359
+ exception_transformer: exception_transformer,
360
+ params_extractor: proc do |request|
361
+ {'subscription' => request.subscription}
362
+ end
363
+ )
329
364
  end
330
365
 
331
366
  # Service calls
@@ -397,9 +432,9 @@ module Google
397
432
  # @param update_mask [Google::Protobuf::FieldMask | Hash]
398
433
  # Required. Indicates which fields in the provided topic to update. Must be
399
434
  # specified and non-empty. Note that if `update_mask` contains
400
- # "message_storage_policy" then the new value will be determined based on the
401
- # policy configured at the project or organization level. The
402
- # `message_storage_policy` must not be set in the `topic` provided above.
435
+ # "message_storage_policy" but the `message_storage_policy` is not set in
436
+ # the `topic` provided above, then the updated value is determined by the
437
+ # policy configured at the project or organization level.
403
438
  # A hash of the same form as `Google::Protobuf::FieldMask`
404
439
  # can also be provided.
405
440
  # @param options [Google::Gax::CallOptions]
@@ -562,7 +597,7 @@ module Google
562
597
  @list_topics.call(req, options, &block)
563
598
  end
564
599
 
565
- # Lists the names of the subscriptions on this topic.
600
+ # Lists the names of the attached subscriptions on this topic.
566
601
  #
567
602
  # @param topic [String]
568
603
  # Required. The name of the topic that subscriptions are attached to.
@@ -617,6 +652,66 @@ module Google
617
652
  @list_topic_subscriptions.call(req, options, &block)
618
653
  end
619
654
 
655
+ # Lists the names of the snapshots on this topic. Snapshots are used in
656
+ # <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
657
+ # operations, which allow
658
+ # you to manage message acknowledgments in bulk. That is, you can set the
659
+ # acknowledgment state of messages in an existing subscription to the state
660
+ # captured by a snapshot.
661
+ #
662
+ # @param topic [String]
663
+ # Required. The name of the topic that snapshots are attached to.
664
+ # Format is `projects/{project}/topics/{topic}`.
665
+ # @param page_size [Integer]
666
+ # The maximum number of resources contained in the underlying API
667
+ # response. If page streaming is performed per-resource, this
668
+ # parameter does not affect the return value. If page streaming is
669
+ # performed per-page, this determines the maximum number of
670
+ # resources in a page.
671
+ # @param options [Google::Gax::CallOptions]
672
+ # Overrides the default settings for this call, e.g, timeout,
673
+ # retries, etc.
674
+ # @yield [result, operation] Access the result along with the RPC operation
675
+ # @yieldparam result [Google::Gax::PagedEnumerable<String>]
676
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
677
+ # @return [Google::Gax::PagedEnumerable<String>]
678
+ # An enumerable of String instances.
679
+ # See Google::Gax::PagedEnumerable documentation for other
680
+ # operations such as per-page iteration or access to the response
681
+ # object.
682
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
683
+ # @example
684
+ # require "google/cloud/pubsub"
685
+ #
686
+ # publisher_client = Google::Cloud::PubSub::Publisher.new(version: :v1)
687
+ # formatted_topic = Google::Cloud::PubSub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
688
+ #
689
+ # # Iterate over all results.
690
+ # publisher_client.list_topic_snapshots(formatted_topic).each do |element|
691
+ # # Process element.
692
+ # end
693
+ #
694
+ # # Or iterate over results one page at a time.
695
+ # publisher_client.list_topic_snapshots(formatted_topic).each_page do |page|
696
+ # # Process each page at a time.
697
+ # page.each do |element|
698
+ # # Process element.
699
+ # end
700
+ # end
701
+
702
+ def list_topic_snapshots \
703
+ topic,
704
+ page_size: nil,
705
+ options: nil,
706
+ &block
707
+ req = {
708
+ topic: topic,
709
+ page_size: page_size
710
+ }.delete_if { |_, v| v.nil? }
711
+ req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::ListTopicSnapshotsRequest)
712
+ @list_topic_snapshots.call(req, options, &block)
713
+ end
714
+
620
715
  # Deletes the topic with the given name. Returns `NOT_FOUND` if the topic
621
716
  # does not exist. After a topic is deleted, a new topic may be created with
622
717
  # the same name; this is an entirely new topic with none of the old
@@ -655,8 +750,8 @@ module Google
655
750
  # Sets the access control policy on the specified resource. Replaces
656
751
  # any existing policy.
657
752
  #
658
- # Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and
659
- # PERMISSION_DENIED
753
+ # Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
754
+ # errors.
660
755
  #
661
756
  # @param resource [String]
662
757
  # REQUIRED: The resource for which the policy is being specified.
@@ -744,7 +839,7 @@ module Google
744
839
 
745
840
  # Returns permissions that a caller has on the specified resource. If the
746
841
  # resource does not exist, this will return an empty set of
747
- # permissions, not a NOT_FOUND error.
842
+ # permissions, not a `NOT_FOUND` error.
748
843
  #
749
844
  # Note: This operation is designed to be used for building
750
845
  # permission-aware UIs and command-line tools, not for authorization
@@ -790,6 +885,40 @@ module Google
790
885
  req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
791
886
  @test_iam_permissions.call(req, options, &block)
792
887
  end
888
+
889
+ # Detaches a subscription from this topic. All messages retained in the
890
+ # subscription are dropped. Subsequent `Pull` and `StreamingPull` requests
891
+ # will return FAILED_PRECONDITION. If the subscription is a push
892
+ # subscription, pushes to the endpoint will stop.
893
+ #
894
+ # @param subscription [String]
895
+ # Required. The subscription to detach.
896
+ # Format is `projects/{project}/subscriptions/{subscription}`.
897
+ # @param options [Google::Gax::CallOptions]
898
+ # Overrides the default settings for this call, e.g, timeout,
899
+ # retries, etc.
900
+ # @yield [result, operation] Access the result along with the RPC operation
901
+ # @yieldparam result [Google::Cloud::PubSub::V1::DetachSubscriptionResponse]
902
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
903
+ # @return [Google::Cloud::PubSub::V1::DetachSubscriptionResponse]
904
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
905
+ # @example
906
+ # require "google/cloud/pubsub"
907
+ #
908
+ # publisher_client = Google::Cloud::PubSub::Publisher.new(version: :v1)
909
+ # formatted_subscription = Google::Cloud::PubSub::V1::PublisherClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
910
+ # response = publisher_client.detach_subscription(formatted_subscription)
911
+
912
+ def detach_subscription \
913
+ subscription,
914
+ options: nil,
915
+ &block
916
+ req = {
917
+ subscription: subscription
918
+ }.delete_if { |_, v| v.nil? }
919
+ req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::DetachSubscriptionRequest)
920
+ @detach_subscription.call(req, options, &block)
921
+ end
793
922
  end
794
923
  end
795
924
  end
@@ -7,9 +7,14 @@
7
7
  "UNAVAILABLE",
8
8
  "UNKNOWN"
9
9
  ],
10
+ "non_idempotent2": [],
10
11
  "non_idempotent": [
11
12
  "UNAVAILABLE"
12
13
  ],
14
+ "idempotent2": [
15
+ "DEADLINE_EXCEEDED",
16
+ "UNAVAILABLE"
17
+ ],
13
18
  "none": [],
14
19
  "publish": [
15
20
  "ABORTED",
@@ -79,6 +84,11 @@
79
84
  "retry_codes_name": "idempotent",
80
85
  "retry_params_name": "default"
81
86
  },
87
+ "ListTopicSnapshots": {
88
+ "timeout_millis": 60000,
89
+ "retry_codes_name": "idempotent2",
90
+ "retry_params_name": "default"
91
+ },
82
92
  "DeleteTopic": {
83
93
  "timeout_millis": 60000,
84
94
  "retry_codes_name": "non_idempotent",
@@ -98,6 +108,11 @@
98
108
  "timeout_millis": 60000,
99
109
  "retry_codes_name": "non_idempotent",
100
110
  "retry_params_name": "default"
111
+ },
112
+ "DetachSubscription": {
113
+ "timeout_millis": 60000,
114
+ "retry_codes_name": "non_idempotent2",
115
+ "retry_params_name": "default"
101
116
  }
102
117
  }
103
118
  }
@@ -134,8 +134,6 @@ module Google
134
134
  end
135
135
 
136
136
  # Returns a fully-qualified topic resource name string.
137
- # @deprecated Multi-pattern resource names will have unified creation and parsing helper functions.
138
- # This helper function will be deleted in the next major version.
139
137
  # @param project [String]
140
138
  # @param topic [String]
141
139
  # @return [String]
@@ -309,6 +307,14 @@ module Google
309
307
  {'subscription' => request.subscription}
310
308
  end
311
309
  )
310
+ @get_snapshot = Google::Gax.create_api_call(
311
+ @subscriber_stub.method(:get_snapshot),
312
+ defaults["get_snapshot"],
313
+ exception_transformer: exception_transformer,
314
+ params_extractor: proc do |request|
315
+ {'snapshot' => request.snapshot}
316
+ end
317
+ )
312
318
  @modify_ack_deadline = Google::Gax.create_api_call(
313
319
  @subscriber_stub.method(:modify_ack_deadline),
314
320
  defaults["modify_ack_deadline"],
@@ -504,13 +510,11 @@ module Google
504
510
  # A hash of the same form as `Google::Cloud::PubSub::V1::ExpirationPolicy`
505
511
  # can also be provided.
506
512
  # @param filter [String]
507
- # An expression written in the Cloud Pub/Sub filter language. If non-empty,
513
+ # An expression written in the Pub/Sub [filter
514
+ # language](https://cloud.google.com/pubsub/docs/filtering). If non-empty,
508
515
  # then only `PubsubMessage`s whose `attributes` field matches the filter are
509
516
  # delivered on this subscription. If empty, then no messages are filtered
510
517
  # out.
511
- # <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
512
- # API might be changed in backward-incompatible ways and is not recommended
513
- # for production use. It is not subject to any SLA or deprecation policy.
514
518
  # @param dead_letter_policy [Google::Cloud::PubSub::V1::DeadLetterPolicy | Hash]
515
519
  # A policy that specifies the conditions for dead lettering messages in
516
520
  # this subscription. If dead_letter_policy is not set, dead lettering
@@ -520,24 +524,24 @@ module Google
520
524
  # parent project (i.e.,
521
525
  # service-\\{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have
522
526
  # permission to Acknowledge() messages on this subscription.
523
- # <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
524
- # API might be changed in backward-incompatible ways and is not recommended
525
- # for production use. It is not subject to any SLA or deprecation policy.
526
527
  # A hash of the same form as `Google::Cloud::PubSub::V1::DeadLetterPolicy`
527
528
  # can also be provided.
528
529
  # @param retry_policy [Google::Cloud::PubSub::V1::RetryPolicy | Hash]
529
- # A policy that specifies how Cloud Pub/Sub retries message delivery for this
530
+ # A policy that specifies how Pub/Sub retries message delivery for this
530
531
  # subscription.
531
532
  #
532
533
  # If not set, the default retry policy is applied. This generally implies
533
534
  # that messages will be retried as soon as possible for healthy subscribers.
534
535
  # RetryPolicy will be triggered on NACKs or acknowledgement deadline
535
536
  # exceeded events for a given message.
536
- # <b>EXPERIMENTAL:</b> This API might be changed in backward-incompatible
537
- # ways and is not recommended for production use. It is not subject to any
538
- # SLA or deprecation policy.
539
537
  # A hash of the same form as `Google::Cloud::PubSub::V1::RetryPolicy`
540
538
  # can also be provided.
539
+ # @param detached [true, false]
540
+ # Indicates whether the subscription is detached from its topic. Detached
541
+ # subscriptions don't receive messages from their topic and don't retain any
542
+ # backlog. `Pull` and `StreamingPull` requests will return
543
+ # FAILED_PRECONDITION. If the subscription is a push subscription, pushes to
544
+ # the endpoint will not be made.
541
545
  # @param options [Google::Gax::CallOptions]
542
546
  # Overrides the default settings for this call, e.g, timeout,
543
547
  # retries, etc.
@@ -567,6 +571,7 @@ module Google
567
571
  filter: nil,
568
572
  dead_letter_policy: nil,
569
573
  retry_policy: nil,
574
+ detached: nil,
570
575
  options: nil,
571
576
  &block
572
577
  req = {
@@ -581,7 +586,8 @@ module Google
581
586
  expiration_policy: expiration_policy,
582
587
  filter: filter,
583
588
  dead_letter_policy: dead_letter_policy,
584
- retry_policy: retry_policy
589
+ retry_policy: retry_policy,
590
+ detached: detached
585
591
  }.delete_if { |_, v| v.nil? }
586
592
  req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::Subscription)
587
593
  @create_subscription.call(req, options, &block)
@@ -752,6 +758,41 @@ module Google
752
758
  nil
753
759
  end
754
760
 
761
+ # Gets the configuration details of a snapshot. Snapshots are used in
762
+ # <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
763
+ # operations, which allow you to manage message acknowledgments in bulk. That
764
+ # is, you can set the acknowledgment state of messages in an existing
765
+ # subscription to the state captured by a snapshot.
766
+ #
767
+ # @param snapshot [String]
768
+ # Required. The name of the snapshot to get.
769
+ # Format is `projects/{project}/snapshots/{snap}`.
770
+ # @param options [Google::Gax::CallOptions]
771
+ # Overrides the default settings for this call, e.g, timeout,
772
+ # retries, etc.
773
+ # @yield [result, operation] Access the result along with the RPC operation
774
+ # @yieldparam result [Google::Cloud::PubSub::V1::Snapshot]
775
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
776
+ # @return [Google::Cloud::PubSub::V1::Snapshot]
777
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
778
+ # @example
779
+ # require "google/cloud/pubsub"
780
+ #
781
+ # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
782
+ # formatted_snapshot = Google::Cloud::PubSub::V1::SubscriberClient.snapshot_path("[PROJECT]", "[SNAPSHOT]")
783
+ # response = subscriber_client.get_snapshot(formatted_snapshot)
784
+
785
+ def get_snapshot \
786
+ snapshot,
787
+ options: nil,
788
+ &block
789
+ req = {
790
+ snapshot: snapshot
791
+ }.delete_if { |_, v| v.nil? }
792
+ req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::GetSnapshotRequest)
793
+ @get_snapshot.call(req, options, &block)
794
+ end
795
+
755
796
  # Modifies the ack deadline for a specific message. This method is useful
756
797
  # to indicate that more time is needed to process a message by the
757
798
  # subscriber, or to make the message available for redelivery if the
@@ -1281,8 +1322,8 @@ module Google
1281
1322
  # Sets the access control policy on the specified resource. Replaces
1282
1323
  # any existing policy.
1283
1324
  #
1284
- # Can return Public Errors: NOT_FOUND, INVALID_ARGUMENT and
1285
- # PERMISSION_DENIED
1325
+ # Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
1326
+ # errors.
1286
1327
  #
1287
1328
  # @param resource [String]
1288
1329
  # REQUIRED: The resource for which the policy is being specified.
@@ -1370,7 +1411,7 @@ module Google
1370
1411
 
1371
1412
  # Returns permissions that a caller has on the specified resource. If the
1372
1413
  # resource does not exist, this will return an empty set of
1373
- # permissions, not a NOT_FOUND error.
1414
+ # permissions, not a `NOT_FOUND` error.
1374
1415
  #
1375
1416
  # Note: This operation is designed to be used for building
1376
1417
  # permission-aware UIs and command-line tools, not for authorization
@@ -10,6 +10,10 @@
10
10
  "non_idempotent": [
11
11
  "UNAVAILABLE"
12
12
  ],
13
+ "idempotent2": [
14
+ "DEADLINE_EXCEEDED",
15
+ "UNAVAILABLE"
16
+ ],
13
17
  "streaming_pull": [
14
18
  "ABORTED",
15
19
  "DEADLINE_EXCEEDED",
@@ -73,6 +77,11 @@
73
77
  "retry_codes_name": "non_idempotent",
74
78
  "retry_params_name": "default"
75
79
  },
80
+ "GetSnapshot": {
81
+ "timeout_millis": 60000,
82
+ "retry_codes_name": "idempotent2",
83
+ "retry_params_name": "default"
84
+ },
76
85
  "ModifyAckDeadline": {
77
86
  "timeout_millis": 60000,
78
87
  "retry_codes_name": "non_idempotent",
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module PubSub
19
- VERSION = "1.5.0".freeze
19
+ VERSION = "1.8.0".freeze
20
20
  end
21
21
 
22
22
  Pubsub = PubSub unless const_defined? :Pubsub
@@ -73,6 +73,11 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
73
73
  add_message "google.pubsub.v1.DeleteTopicRequest" do
74
74
  optional :topic, :string, 1
75
75
  end
76
+ add_message "google.pubsub.v1.DetachSubscriptionRequest" do
77
+ optional :subscription, :string, 1
78
+ end
79
+ add_message "google.pubsub.v1.DetachSubscriptionResponse" do
80
+ end
76
81
  add_message "google.pubsub.v1.Subscription" do
77
82
  optional :name, :string, 1
78
83
  optional :topic, :string, 2
@@ -86,6 +91,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
86
91
  optional :filter, :string, 12
87
92
  optional :dead_letter_policy, :message, 13, "google.pubsub.v1.DeadLetterPolicy"
88
93
  optional :retry_policy, :message, 14, "google.pubsub.v1.RetryPolicy"
94
+ optional :detached, :bool, 15
89
95
  end
90
96
  add_message "google.pubsub.v1.RetryPolicy" do
91
97
  optional :minimum_backoff, :message, 1, "google.protobuf.Duration"
@@ -161,6 +167,8 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
161
167
  repeated :modify_deadline_ack_ids, :string, 4
162
168
  optional :stream_ack_deadline_seconds, :int32, 5
163
169
  optional :client_id, :string, 6
170
+ optional :max_outstanding_messages, :int64, 7
171
+ optional :max_outstanding_bytes, :int64, 8
164
172
  end
165
173
  add_message "google.pubsub.v1.StreamingPullResponse" do
166
174
  repeated :received_messages, :message, 1, "google.pubsub.v1.ReceivedMessage"
@@ -228,6 +236,8 @@ module Google::Cloud::PubSub::V1
228
236
  ListTopicSnapshotsRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.ListTopicSnapshotsRequest").msgclass
229
237
  ListTopicSnapshotsResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.ListTopicSnapshotsResponse").msgclass
230
238
  DeleteTopicRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.DeleteTopicRequest").msgclass
239
+ DetachSubscriptionRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.DetachSubscriptionRequest").msgclass
240
+ DetachSubscriptionResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.DetachSubscriptionResponse").msgclass
231
241
  Subscription = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.Subscription").msgclass
232
242
  RetryPolicy = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.RetryPolicy").msgclass
233
243
  DeadLetterPolicy = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.pubsub.v1.DeadLetterPolicy").msgclass
@@ -53,7 +53,7 @@ module Google::Cloud::PubSub::V1
53
53
  rpc :GetTopic, GetTopicRequest, Topic
54
54
  # Lists matching topics.
55
55
  rpc :ListTopics, ListTopicsRequest, ListTopicsResponse
56
- # Lists the names of the subscriptions on this topic.
56
+ # Lists the names of the attached subscriptions on this topic.
57
57
  rpc :ListTopicSubscriptions, ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse
58
58
  # Lists the names of the snapshots on this topic. Snapshots are used in
59
59
  # <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
@@ -68,6 +68,11 @@ module Google::Cloud::PubSub::V1
68
68
  # configuration or subscriptions. Existing subscriptions to this topic are
69
69
  # not deleted, but their `topic` field is set to `_deleted-topic_`.
70
70
  rpc :DeleteTopic, DeleteTopicRequest, Google::Protobuf::Empty
71
+ # Detaches a subscription from this topic. All messages retained in the
72
+ # subscription are dropped. Subsequent `Pull` and `StreamingPull` requests
73
+ # will return FAILED_PRECONDITION. If the subscription is a push
74
+ # subscription, pushes to the endpoint will stop.
75
+ rpc :DetachSubscription, DetachSubscriptionRequest, DetachSubscriptionResponse
71
76
  end
72
77
 
73
78
  Stub = Service.rpc_stub_class
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-pubsub
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-03-25 00:00:00.000000000 Z
12
+ date: 2020-06-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby
@@ -141,14 +141,14 @@ dependencies:
141
141
  requirements:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
- version: '5.10'
144
+ version: '5.14'
145
145
  type: :development
146
146
  prerelease: false
147
147
  version_requirements: !ruby/object:Gem::Requirement
148
148
  requirements:
149
149
  - - "~>"
150
150
  - !ruby/object:Gem::Version
151
- version: '5.10'
151
+ version: '5.14'
152
152
  - !ruby/object:Gem::Dependency
153
153
  name: minitest-autotest
154
154
  requirement: !ruby/object:Gem::Requirement
@@ -278,6 +278,7 @@ files:
278
278
  - lib/google/cloud/pubsub/project.rb
279
279
  - lib/google/cloud/pubsub/publish_result.rb
280
280
  - lib/google/cloud/pubsub/received_message.rb
281
+ - lib/google/cloud/pubsub/retry_policy.rb
281
282
  - lib/google/cloud/pubsub/service.rb
282
283
  - lib/google/cloud/pubsub/snapshot.rb
283
284
  - lib/google/cloud/pubsub/snapshot/list.rb
@@ -329,7 +330,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
329
330
  - !ruby/object:Gem::Version
330
331
  version: '0'
331
332
  requirements: []
332
- rubygems_version: 3.0.6
333
+ rubygems_version: 3.1.3
333
334
  signing_key:
334
335
  specification_version: 4
335
336
  summary: API Client library for Google Cloud Pub/Sub