google-cloud-pubsub 1.1.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +2 -1
  3. data/CHANGELOG.md +145 -0
  4. data/EMULATOR.md +1 -1
  5. data/TROUBLESHOOTING.md +2 -8
  6. data/lib/google/cloud/pubsub/async_publisher.rb +16 -21
  7. data/lib/google/cloud/pubsub/credentials.rb +2 -2
  8. data/lib/google/cloud/pubsub/project.rb +18 -26
  9. data/lib/google/cloud/pubsub/received_message.rb +38 -0
  10. data/lib/google/cloud/pubsub/retry_policy.rb +90 -0
  11. data/lib/google/cloud/pubsub/service.rb +125 -252
  12. data/lib/google/cloud/pubsub/subscriber/inventory.rb +43 -15
  13. data/lib/google/cloud/pubsub/subscriber/stream.rb +8 -10
  14. data/lib/google/cloud/pubsub/subscriber.rb +86 -15
  15. data/lib/google/cloud/pubsub/subscription/push_config.rb +2 -2
  16. data/lib/google/cloud/pubsub/subscription.rb +297 -7
  17. data/lib/google/cloud/pubsub/topic.rb +65 -2
  18. data/lib/google/cloud/pubsub/version.rb +1 -1
  19. data/lib/google/cloud/pubsub.rb +15 -18
  20. data/lib/google-cloud-pubsub.rb +13 -13
  21. metadata +11 -81
  22. data/lib/google/cloud/pubsub/v1/credentials.rb +0 -41
  23. data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/iam_policy.rb +0 -21
  24. data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/options.rb +0 -21
  25. data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/policy.rb +0 -21
  26. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/duration.rb +0 -91
  27. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/empty.rb +0 -29
  28. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/field_mask.rb +0 -222
  29. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/timestamp.rb +0 -113
  30. data/lib/google/cloud/pubsub/v1/doc/google/pubsub/v1/pubsub.rb +0 -744
  31. data/lib/google/cloud/pubsub/v1/doc/google/type/expr.rb +0 -19
  32. data/lib/google/cloud/pubsub/v1/publisher_client.rb +0 -786
  33. data/lib/google/cloud/pubsub/v1/publisher_client_config.json +0 -105
  34. data/lib/google/cloud/pubsub/v1/subscriber_client.rb +0 -1385
  35. data/lib/google/cloud/pubsub/v1/subscriber_client_config.json +0 -144
  36. data/lib/google/cloud/pubsub/v1.rb +0 -17
  37. data/lib/google/pubsub/v1/pubsub_pb.rb +0 -249
  38. data/lib/google/pubsub/v1/pubsub_services_pb.rb +0 -211
@@ -1,1385 +0,0 @@
1
- # Copyright 2019 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
- # EDITING INSTRUCTIONS
16
- # This file was generated from the file
17
- # https://github.com/googleapis/googleapis/blob/master/google/pubsub/v1/pubsub.proto,
18
- # and updates to that file get reflected here through a refresh process.
19
- # For the short term, the refresh process will only be runnable by Google
20
- # engineers.
21
-
22
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
-
28
- require "google/iam/v1/iam_policy_pb"
29
- require "google/pubsub/v1/pubsub_pb"
30
- require "google/cloud/pubsub/v1/credentials"
31
- require "google/cloud/pubsub/version"
32
-
33
- module Google
34
- module Cloud
35
- module PubSub
36
- module V1
37
- # The service that an application uses to manipulate subscriptions and to
38
- # consume messages from a subscription via the `Pull` method or by
39
- # establishing a bi-directional stream using the `StreamingPull` method.
40
- #
41
- # @!attribute [r] iam_policy_stub
42
- # @return [Google::Iam::V1::IAMPolicy::Stub]
43
- # @!attribute [r] subscriber_stub
44
- # @return [Google::Cloud::PubSub::V1::Subscriber::Stub]
45
- class SubscriberClient
46
- # @private
47
- attr_reader :iam_policy_stub, :subscriber_stub
48
-
49
- # The default address of the service.
50
- SERVICE_ADDRESS = "pubsub.googleapis.com".freeze
51
-
52
- # The default port of the service.
53
- DEFAULT_SERVICE_PORT = 443
54
-
55
- # The default set of gRPC interceptors.
56
- GRPC_INTERCEPTORS = []
57
-
58
- DEFAULT_TIMEOUT = 30
59
-
60
- PAGE_DESCRIPTORS = {
61
- "list_subscriptions" => Google::Gax::PageDescriptor.new(
62
- "page_token",
63
- "next_page_token",
64
- "subscriptions"),
65
- "list_snapshots" => Google::Gax::PageDescriptor.new(
66
- "page_token",
67
- "next_page_token",
68
- "snapshots")
69
- }.freeze
70
-
71
- private_constant :PAGE_DESCRIPTORS
72
-
73
- # The scopes needed to make gRPC calls to all of the methods defined in
74
- # this service.
75
- ALL_SCOPES = [
76
- "https://www.googleapis.com/auth/cloud-platform",
77
- "https://www.googleapis.com/auth/pubsub"
78
- ].freeze
79
-
80
-
81
- PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
82
- "projects/{project}"
83
- )
84
-
85
- private_constant :PROJECT_PATH_TEMPLATE
86
-
87
- SNAPSHOT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
88
- "projects/{project}/snapshots/{snapshot}"
89
- )
90
-
91
- private_constant :SNAPSHOT_PATH_TEMPLATE
92
-
93
- SUBSCRIPTION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
94
- "projects/{project}/subscriptions/{subscription}"
95
- )
96
-
97
- private_constant :SUBSCRIPTION_PATH_TEMPLATE
98
-
99
- TOPIC_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
100
- "projects/{project}/topics/{topic}"
101
- )
102
-
103
- private_constant :TOPIC_PATH_TEMPLATE
104
-
105
- # Returns a fully-qualified project resource name string.
106
- # @param project [String]
107
- # @return [String]
108
- def self.project_path project
109
- PROJECT_PATH_TEMPLATE.render(
110
- :"project" => project
111
- )
112
- end
113
-
114
- # Returns a fully-qualified snapshot resource name string.
115
- # @param project [String]
116
- # @param snapshot [String]
117
- # @return [String]
118
- def self.snapshot_path project, snapshot
119
- SNAPSHOT_PATH_TEMPLATE.render(
120
- :"project" => project,
121
- :"snapshot" => snapshot
122
- )
123
- end
124
-
125
- # Returns a fully-qualified subscription resource name string.
126
- # @param project [String]
127
- # @param subscription [String]
128
- # @return [String]
129
- def self.subscription_path project, subscription
130
- SUBSCRIPTION_PATH_TEMPLATE.render(
131
- :"project" => project,
132
- :"subscription" => subscription
133
- )
134
- end
135
-
136
- # Returns a fully-qualified topic resource name string.
137
- # @param project [String]
138
- # @param topic [String]
139
- # @return [String]
140
- def self.topic_path project, topic
141
- TOPIC_PATH_TEMPLATE.render(
142
- :"project" => project,
143
- :"topic" => topic
144
- )
145
- end
146
-
147
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
148
- # Provides the means for authenticating requests made by the client. This parameter can
149
- # be many types.
150
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
151
- # authenticating requests made by this client.
152
- # A `String` will be treated as the path to the keyfile to be used for the construction of
153
- # credentials for this client.
154
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
155
- # credentials for this client.
156
- # A `GRPC::Core::Channel` will be used to make calls through.
157
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
158
- # should already be composed with a `GRPC::Core::CallCredentials` object.
159
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
160
- # metadata for requests, generally, to give OAuth credentials.
161
- # @param scopes [Array<String>]
162
- # The OAuth scopes for this service. This parameter is ignored if
163
- # an updater_proc is supplied.
164
- # @param client_config [Hash]
165
- # A Hash for call options for each method. See
166
- # Google::Gax#construct_settings for the structure of
167
- # this data. Falls back to the default config if not specified
168
- # or the specified config is missing data points.
169
- # @param timeout [Numeric]
170
- # The default timeout, in seconds, for calls made through this client.
171
- # @param metadata [Hash]
172
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
173
- # @param service_address [String]
174
- # Override for the service hostname, or `nil` to leave as the default.
175
- # @param service_port [Integer]
176
- # Override for the service port, or `nil` to leave as the default.
177
- # @param exception_transformer [Proc]
178
- # An optional proc that intercepts any exceptions raised during an API call to inject
179
- # custom error handling.
180
- def initialize \
181
- credentials: nil,
182
- scopes: ALL_SCOPES,
183
- client_config: {},
184
- timeout: DEFAULT_TIMEOUT,
185
- metadata: nil,
186
- service_address: nil,
187
- service_port: nil,
188
- exception_transformer: nil,
189
- lib_name: nil,
190
- lib_version: ""
191
- # These require statements are intentionally placed here to initialize
192
- # the gRPC module only when it's required.
193
- # See https://github.com/googleapis/toolkit/issues/446
194
- require "google/gax/grpc"
195
- require "google/iam/v1/iam_policy_services_pb"
196
- require "google/pubsub/v1/pubsub_services_pb"
197
-
198
- credentials ||= Google::Cloud::PubSub::V1::Credentials.default
199
-
200
- if credentials.is_a?(String) || credentials.is_a?(Hash)
201
- updater_proc = Google::Cloud::PubSub::V1::Credentials.new(credentials).updater_proc
202
- end
203
- if credentials.is_a?(GRPC::Core::Channel)
204
- channel = credentials
205
- end
206
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
207
- chan_creds = credentials
208
- end
209
- if credentials.is_a?(Proc)
210
- updater_proc = credentials
211
- end
212
- if credentials.is_a?(Google::Auth::Credentials)
213
- updater_proc = credentials.updater_proc
214
- end
215
-
216
- package_version = Google::Cloud::PubSub::VERSION
217
-
218
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
219
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
220
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
221
- google_api_client << " grpc/#{GRPC::VERSION}"
222
- google_api_client.freeze
223
-
224
- headers = { :"x-goog-api-client" => google_api_client }
225
- headers.merge!(metadata) unless metadata.nil?
226
- client_config_file = Pathname.new(__dir__).join(
227
- "subscriber_client_config.json"
228
- )
229
- defaults = client_config_file.open do |f|
230
- Google::Gax.construct_settings(
231
- "google.pubsub.v1.Subscriber",
232
- JSON.parse(f.read),
233
- client_config,
234
- Google::Gax::Grpc::STATUS_CODE_NAMES,
235
- timeout,
236
- page_descriptors: PAGE_DESCRIPTORS,
237
- errors: Google::Gax::Grpc::API_ERRORS,
238
- metadata: headers
239
- )
240
- end
241
-
242
- # Allow overriding the service path/port in subclasses.
243
- service_path = service_address || self.class::SERVICE_ADDRESS
244
- port = service_port || self.class::DEFAULT_SERVICE_PORT
245
- interceptors = self.class::GRPC_INTERCEPTORS
246
- @iam_policy_stub = Google::Gax::Grpc.create_stub(
247
- service_path,
248
- port,
249
- chan_creds: chan_creds,
250
- channel: channel,
251
- updater_proc: updater_proc,
252
- scopes: scopes,
253
- interceptors: interceptors,
254
- &Google::Iam::V1::IAMPolicy::Stub.method(:new)
255
- )
256
- @subscriber_stub = Google::Gax::Grpc.create_stub(
257
- service_path,
258
- port,
259
- chan_creds: chan_creds,
260
- channel: channel,
261
- updater_proc: updater_proc,
262
- scopes: scopes,
263
- interceptors: interceptors,
264
- &Google::Cloud::PubSub::V1::Subscriber::Stub.method(:new)
265
- )
266
-
267
- @create_subscription = Google::Gax.create_api_call(
268
- @subscriber_stub.method(:create_subscription),
269
- defaults["create_subscription"],
270
- exception_transformer: exception_transformer,
271
- params_extractor: proc do |request|
272
- {'name' => request.name}
273
- end
274
- )
275
- @get_subscription = Google::Gax.create_api_call(
276
- @subscriber_stub.method(:get_subscription),
277
- defaults["get_subscription"],
278
- exception_transformer: exception_transformer,
279
- params_extractor: proc do |request|
280
- {'subscription' => request.subscription}
281
- end
282
- )
283
- @update_subscription = Google::Gax.create_api_call(
284
- @subscriber_stub.method(:update_subscription),
285
- defaults["update_subscription"],
286
- exception_transformer: exception_transformer,
287
- params_extractor: proc do |request|
288
- {'subscription.name' => request.subscription.name}
289
- end
290
- )
291
- @list_subscriptions = Google::Gax.create_api_call(
292
- @subscriber_stub.method(:list_subscriptions),
293
- defaults["list_subscriptions"],
294
- exception_transformer: exception_transformer,
295
- params_extractor: proc do |request|
296
- {'project' => request.project}
297
- end
298
- )
299
- @delete_subscription = Google::Gax.create_api_call(
300
- @subscriber_stub.method(:delete_subscription),
301
- defaults["delete_subscription"],
302
- exception_transformer: exception_transformer,
303
- params_extractor: proc do |request|
304
- {'subscription' => request.subscription}
305
- end
306
- )
307
- @modify_ack_deadline = Google::Gax.create_api_call(
308
- @subscriber_stub.method(:modify_ack_deadline),
309
- defaults["modify_ack_deadline"],
310
- exception_transformer: exception_transformer,
311
- params_extractor: proc do |request|
312
- {'subscription' => request.subscription}
313
- end
314
- )
315
- @acknowledge = Google::Gax.create_api_call(
316
- @subscriber_stub.method(:acknowledge),
317
- defaults["acknowledge"],
318
- exception_transformer: exception_transformer,
319
- params_extractor: proc do |request|
320
- {'subscription' => request.subscription}
321
- end
322
- )
323
- @pull = Google::Gax.create_api_call(
324
- @subscriber_stub.method(:pull),
325
- defaults["pull"],
326
- exception_transformer: exception_transformer,
327
- params_extractor: proc do |request|
328
- {'subscription' => request.subscription}
329
- end
330
- )
331
- @streaming_pull = Google::Gax.create_api_call(
332
- @subscriber_stub.method(:streaming_pull),
333
- defaults["streaming_pull"],
334
- exception_transformer: exception_transformer
335
- )
336
- @modify_push_config = Google::Gax.create_api_call(
337
- @subscriber_stub.method(:modify_push_config),
338
- defaults["modify_push_config"],
339
- exception_transformer: exception_transformer,
340
- params_extractor: proc do |request|
341
- {'subscription' => request.subscription}
342
- end
343
- )
344
- @list_snapshots = Google::Gax.create_api_call(
345
- @subscriber_stub.method(:list_snapshots),
346
- defaults["list_snapshots"],
347
- exception_transformer: exception_transformer,
348
- params_extractor: proc do |request|
349
- {'project' => request.project}
350
- end
351
- )
352
- @create_snapshot = Google::Gax.create_api_call(
353
- @subscriber_stub.method(:create_snapshot),
354
- defaults["create_snapshot"],
355
- exception_transformer: exception_transformer,
356
- params_extractor: proc do |request|
357
- {'name' => request.name}
358
- end
359
- )
360
- @update_snapshot = Google::Gax.create_api_call(
361
- @subscriber_stub.method(:update_snapshot),
362
- defaults["update_snapshot"],
363
- exception_transformer: exception_transformer,
364
- params_extractor: proc do |request|
365
- {'snapshot.name' => request.snapshot.name}
366
- end
367
- )
368
- @delete_snapshot = Google::Gax.create_api_call(
369
- @subscriber_stub.method(:delete_snapshot),
370
- defaults["delete_snapshot"],
371
- exception_transformer: exception_transformer,
372
- params_extractor: proc do |request|
373
- {'snapshot' => request.snapshot}
374
- end
375
- )
376
- @seek = Google::Gax.create_api_call(
377
- @subscriber_stub.method(:seek),
378
- defaults["seek"],
379
- exception_transformer: exception_transformer,
380
- params_extractor: proc do |request|
381
- {'subscription' => request.subscription}
382
- end
383
- )
384
- @set_iam_policy = Google::Gax.create_api_call(
385
- @iam_policy_stub.method(:set_iam_policy),
386
- defaults["set_iam_policy"],
387
- exception_transformer: exception_transformer,
388
- params_extractor: proc do |request|
389
- {'resource' => request.resource}
390
- end
391
- )
392
- @get_iam_policy = Google::Gax.create_api_call(
393
- @iam_policy_stub.method(:get_iam_policy),
394
- defaults["get_iam_policy"],
395
- exception_transformer: exception_transformer,
396
- params_extractor: proc do |request|
397
- {'resource' => request.resource}
398
- end
399
- )
400
- @test_iam_permissions = Google::Gax.create_api_call(
401
- @iam_policy_stub.method(:test_iam_permissions),
402
- defaults["test_iam_permissions"],
403
- exception_transformer: exception_transformer,
404
- params_extractor: proc do |request|
405
- {'resource' => request.resource}
406
- end
407
- )
408
- end
409
-
410
- # Service calls
411
-
412
- # Creates a subscription to a given topic. See the
413
- # <a href="https://cloud.google.com/pubsub/docs/admin#resource_names">
414
- # resource name rules</a>.
415
- # If the subscription already exists, returns `ALREADY_EXISTS`.
416
- # If the corresponding topic doesn't exist, returns `NOT_FOUND`.
417
- #
418
- # If the name is not provided in the request, the server will assign a random
419
- # name for this subscription on the same project as the topic, conforming
420
- # to the
421
- # [resource name
422
- # format](https://cloud.google.com/pubsub/docs/admin#resource_names). The
423
- # generated name is populated in the returned Subscription object. Note that
424
- # for REST API requests, you must specify a name in the request.
425
- #
426
- # @param name [String]
427
- # The name of the subscription. It must have the format
428
- # `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
429
- # start with a letter, and contain only letters (`[A-Za-z]`), numbers
430
- # (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
431
- # plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
432
- # in length, and it must not start with `"goog"`
433
- # @param topic [String]
434
- # The name of the topic from which this subscription is receiving messages.
435
- # Format is `projects/{project}/topics/{topic}`.
436
- # The value of this field will be `_deleted-topic_` if the topic has been
437
- # deleted.
438
- # @param push_config [Google::Cloud::PubSub::V1::PushConfig | Hash]
439
- # If push delivery is used with this subscription, this field is
440
- # used to configure it. An empty `pushConfig` signifies that the subscriber
441
- # will pull and ack messages using API methods.
442
- # A hash of the same form as `Google::Cloud::PubSub::V1::PushConfig`
443
- # can also be provided.
444
- # @param ack_deadline_seconds [Integer]
445
- # The approximate amount of time (on a best-effort basis) Pub/Sub waits for
446
- # the subscriber to acknowledge receipt before resending the message. In the
447
- # interval after the message is delivered and before it is acknowledged, it
448
- # is considered to be <i>outstanding</i>. During that time period, the
449
- # message will not be redelivered (on a best-effort basis).
450
- #
451
- # For pull subscriptions, this value is used as the initial value for the ack
452
- # deadline. To override this value for a given message, call
453
- # `ModifyAckDeadline` with the corresponding `ack_id` if using
454
- # non-streaming pull or send the `ack_id` in a
455
- # `StreamingModifyAckDeadlineRequest` if using streaming pull.
456
- # The minimum custom deadline you can specify is 10 seconds.
457
- # The maximum custom deadline you can specify is 600 seconds (10 minutes).
458
- # If this parameter is 0, a default value of 10 seconds is used.
459
- #
460
- # For push delivery, this value is also used to set the request timeout for
461
- # the call to the push endpoint.
462
- #
463
- # If the subscriber never acknowledges the message, the Pub/Sub
464
- # system will eventually redeliver the message.
465
- # @param retain_acked_messages [true, false]
466
- # Indicates whether to retain acknowledged messages. If true, then
467
- # messages are not expunged from the subscription's backlog, even if they are
468
- # acknowledged, until they fall out of the `message_retention_duration`
469
- # window. This must be true if you would like to
470
- # <a
471
- # href="https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time">
472
- # Seek to a timestamp</a>.
473
- # @param message_retention_duration [Google::Protobuf::Duration | Hash]
474
- # How long to retain unacknowledged messages in the subscription's backlog,
475
- # from the moment a message is published.
476
- # If `retain_acked_messages` is true, then this also configures the retention
477
- # of acknowledged messages, and thus configures how far back in time a `Seek`
478
- # can be done. Defaults to 7 days. Cannot be more than 7 days or less than 10
479
- # minutes.
480
- # A hash of the same form as `Google::Protobuf::Duration`
481
- # can also be provided.
482
- # @param labels [Hash{String => String}]
483
- # See <a href="https://cloud.google.com/pubsub/docs/labels"> Creating and
484
- # managing labels</a>.
485
- # @param enable_message_ordering [true, false]
486
- # If true, messages published with the same `ordering_key` in `PubsubMessage`
487
- # will be delivered to the subscribers in the order in which they
488
- # are received by the Pub/Sub system. Otherwise, they may be delivered in
489
- # any order.
490
- # <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
491
- # API might be changed in backward-incompatible ways and is not recommended
492
- # for production use. It is not subject to any SLA or deprecation policy.
493
- # @param expiration_policy [Google::Cloud::PubSub::V1::ExpirationPolicy | Hash]
494
- # A policy that specifies the conditions for this subscription's expiration.
495
- # A subscription is considered active as long as any connected subscriber is
496
- # successfully consuming messages from the subscription or is issuing
497
- # operations on the subscription. If `expiration_policy` is not set, a
498
- # *default policy* with `ttl` of 31 days will be used. The minimum allowed
499
- # value for `expiration_policy.ttl` is 1 day.
500
- # A hash of the same form as `Google::Cloud::PubSub::V1::ExpirationPolicy`
501
- # can also be provided.
502
- # @param dead_letter_policy [Google::Cloud::PubSub::V1::DeadLetterPolicy | Hash]
503
- # A policy that specifies the conditions for dead lettering messages in
504
- # this subscription. If dead_letter_policy is not set, dead lettering
505
- # is disabled.
506
- #
507
- # The Cloud Pub/Sub service account associated with this subscriptions's
508
- # parent project (i.e.,
509
- # service-\\{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have
510
- # permission to Acknowledge() messages on this subscription.
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
- # A hash of the same form as `Google::Cloud::PubSub::V1::DeadLetterPolicy`
515
- # can also be provided.
516
- # @param options [Google::Gax::CallOptions]
517
- # Overrides the default settings for this call, e.g, timeout,
518
- # retries, etc.
519
- # @yield [result, operation] Access the result along with the RPC operation
520
- # @yieldparam result [Google::Cloud::PubSub::V1::Subscription]
521
- # @yieldparam operation [GRPC::ActiveCall::Operation]
522
- # @return [Google::Cloud::PubSub::V1::Subscription]
523
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
524
- # @example
525
- # require "google/cloud/pubsub"
526
- #
527
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
528
- # formatted_name = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
529
- # formatted_topic = Google::Cloud::PubSub::V1::SubscriberClient.topic_path("[PROJECT]", "[TOPIC]")
530
- # response = subscriber_client.create_subscription(formatted_name, formatted_topic)
531
-
532
- def create_subscription \
533
- name,
534
- topic,
535
- push_config: nil,
536
- ack_deadline_seconds: nil,
537
- retain_acked_messages: nil,
538
- message_retention_duration: nil,
539
- labels: nil,
540
- enable_message_ordering: nil,
541
- expiration_policy: nil,
542
- dead_letter_policy: nil,
543
- options: nil,
544
- &block
545
- req = {
546
- name: name,
547
- topic: topic,
548
- push_config: push_config,
549
- ack_deadline_seconds: ack_deadline_seconds,
550
- retain_acked_messages: retain_acked_messages,
551
- message_retention_duration: message_retention_duration,
552
- labels: labels,
553
- enable_message_ordering: enable_message_ordering,
554
- expiration_policy: expiration_policy,
555
- dead_letter_policy: dead_letter_policy
556
- }.delete_if { |_, v| v.nil? }
557
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::Subscription)
558
- @create_subscription.call(req, options, &block)
559
- end
560
-
561
- # Gets the configuration details of a subscription.
562
- #
563
- # @param subscription [String]
564
- # The name of the subscription to get.
565
- # Format is `projects/{project}/subscriptions/{sub}`.
566
- # @param options [Google::Gax::CallOptions]
567
- # Overrides the default settings for this call, e.g, timeout,
568
- # retries, etc.
569
- # @yield [result, operation] Access the result along with the RPC operation
570
- # @yieldparam result [Google::Cloud::PubSub::V1::Subscription]
571
- # @yieldparam operation [GRPC::ActiveCall::Operation]
572
- # @return [Google::Cloud::PubSub::V1::Subscription]
573
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
574
- # @example
575
- # require "google/cloud/pubsub"
576
- #
577
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
578
- # formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
579
- # response = subscriber_client.get_subscription(formatted_subscription)
580
-
581
- def get_subscription \
582
- subscription,
583
- options: nil,
584
- &block
585
- req = {
586
- subscription: subscription
587
- }.delete_if { |_, v| v.nil? }
588
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::GetSubscriptionRequest)
589
- @get_subscription.call(req, options, &block)
590
- end
591
-
592
- # Updates an existing subscription. Note that certain properties of a
593
- # subscription, such as its topic, are not modifiable.
594
- #
595
- # @param subscription [Google::Cloud::PubSub::V1::Subscription | Hash]
596
- # The updated subscription object.
597
- # A hash of the same form as `Google::Cloud::PubSub::V1::Subscription`
598
- # can also be provided.
599
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
600
- # Indicates which fields in the provided subscription to update.
601
- # Must be specified and non-empty.
602
- # A hash of the same form as `Google::Protobuf::FieldMask`
603
- # can also be provided.
604
- # @param options [Google::Gax::CallOptions]
605
- # Overrides the default settings for this call, e.g, timeout,
606
- # retries, etc.
607
- # @yield [result, operation] Access the result along with the RPC operation
608
- # @yieldparam result [Google::Cloud::PubSub::V1::Subscription]
609
- # @yieldparam operation [GRPC::ActiveCall::Operation]
610
- # @return [Google::Cloud::PubSub::V1::Subscription]
611
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
612
- # @example
613
- # require "google/cloud/pubsub"
614
- #
615
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
616
- # ack_deadline_seconds = 42
617
- # subscription = { ack_deadline_seconds: ack_deadline_seconds }
618
- # paths_element = "ack_deadline_seconds"
619
- # paths = [paths_element]
620
- # update_mask = { paths: paths }
621
- # response = subscriber_client.update_subscription(subscription, update_mask)
622
-
623
- def update_subscription \
624
- subscription,
625
- update_mask,
626
- options: nil,
627
- &block
628
- req = {
629
- subscription: subscription,
630
- update_mask: update_mask
631
- }.delete_if { |_, v| v.nil? }
632
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::UpdateSubscriptionRequest)
633
- @update_subscription.call(req, options, &block)
634
- end
635
-
636
- # Lists matching subscriptions.
637
- #
638
- # @param project [String]
639
- # The name of the project in which to list subscriptions.
640
- # Format is `projects/{project-id}`.
641
- # @param page_size [Integer]
642
- # The maximum number of resources contained in the underlying API
643
- # response. If page streaming is performed per-resource, this
644
- # parameter does not affect the return value. If page streaming is
645
- # performed per-page, this determines the maximum number of
646
- # resources in a page.
647
- # @param options [Google::Gax::CallOptions]
648
- # Overrides the default settings for this call, e.g, timeout,
649
- # retries, etc.
650
- # @yield [result, operation] Access the result along with the RPC operation
651
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::PubSub::V1::Subscription>]
652
- # @yieldparam operation [GRPC::ActiveCall::Operation]
653
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::PubSub::V1::Subscription>]
654
- # An enumerable of Google::Cloud::PubSub::V1::Subscription instances.
655
- # See Google::Gax::PagedEnumerable documentation for other
656
- # operations such as per-page iteration or access to the response
657
- # object.
658
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
659
- # @example
660
- # require "google/cloud/pubsub"
661
- #
662
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
663
- # formatted_project = Google::Cloud::PubSub::V1::SubscriberClient.project_path("[PROJECT]")
664
- #
665
- # # Iterate over all results.
666
- # subscriber_client.list_subscriptions(formatted_project).each do |element|
667
- # # Process element.
668
- # end
669
- #
670
- # # Or iterate over results one page at a time.
671
- # subscriber_client.list_subscriptions(formatted_project).each_page do |page|
672
- # # Process each page at a time.
673
- # page.each do |element|
674
- # # Process element.
675
- # end
676
- # end
677
-
678
- def list_subscriptions \
679
- project,
680
- page_size: nil,
681
- options: nil,
682
- &block
683
- req = {
684
- project: project,
685
- page_size: page_size
686
- }.delete_if { |_, v| v.nil? }
687
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::ListSubscriptionsRequest)
688
- @list_subscriptions.call(req, options, &block)
689
- end
690
-
691
- # Deletes an existing subscription. All messages retained in the subscription
692
- # are immediately dropped. Calls to `Pull` after deletion will return
693
- # `NOT_FOUND`. After a subscription is deleted, a new one may be created with
694
- # the same name, but the new one has no association with the old
695
- # subscription or its topic unless the same topic is specified.
696
- #
697
- # @param subscription [String]
698
- # The subscription to delete.
699
- # Format is `projects/{project}/subscriptions/{sub}`.
700
- # @param options [Google::Gax::CallOptions]
701
- # Overrides the default settings for this call, e.g, timeout,
702
- # retries, etc.
703
- # @yield [result, operation] Access the result along with the RPC operation
704
- # @yieldparam result []
705
- # @yieldparam operation [GRPC::ActiveCall::Operation]
706
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
707
- # @example
708
- # require "google/cloud/pubsub"
709
- #
710
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
711
- # formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
712
- # subscriber_client.delete_subscription(formatted_subscription)
713
-
714
- def delete_subscription \
715
- subscription,
716
- options: nil,
717
- &block
718
- req = {
719
- subscription: subscription
720
- }.delete_if { |_, v| v.nil? }
721
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::DeleteSubscriptionRequest)
722
- @delete_subscription.call(req, options, &block)
723
- nil
724
- end
725
-
726
- # Modifies the ack deadline for a specific message. This method is useful
727
- # to indicate that more time is needed to process a message by the
728
- # subscriber, or to make the message available for redelivery if the
729
- # processing was interrupted. Note that this does not modify the
730
- # subscription-level `ackDeadlineSeconds` used for subsequent messages.
731
- #
732
- # @param subscription [String]
733
- # The name of the subscription.
734
- # Format is `projects/{project}/subscriptions/{sub}`.
735
- # @param ack_ids [Array<String>]
736
- # List of acknowledgment IDs.
737
- # @param ack_deadline_seconds [Integer]
738
- # The new ack deadline with respect to the time this request was sent to
739
- # the Pub/Sub system. For example, if the value is 10, the new
740
- # ack deadline will expire 10 seconds after the `ModifyAckDeadline` call
741
- # was made. Specifying zero might immediately make the message available for
742
- # delivery to another subscriber client. This typically results in an
743
- # increase in the rate of message redeliveries (that is, duplicates).
744
- # The minimum deadline you can specify is 0 seconds.
745
- # The maximum deadline you can specify is 600 seconds (10 minutes).
746
- # @param options [Google::Gax::CallOptions]
747
- # Overrides the default settings for this call, e.g, timeout,
748
- # retries, etc.
749
- # @yield [result, operation] Access the result along with the RPC operation
750
- # @yieldparam result []
751
- # @yieldparam operation [GRPC::ActiveCall::Operation]
752
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
753
- # @example
754
- # require "google/cloud/pubsub"
755
- #
756
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
757
- # formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
758
- #
759
- # # TODO: Initialize `ack_ids`:
760
- # ack_ids = []
761
- #
762
- # # TODO: Initialize `ack_deadline_seconds`:
763
- # ack_deadline_seconds = 0
764
- # subscriber_client.modify_ack_deadline(formatted_subscription, ack_ids, ack_deadline_seconds)
765
-
766
- def modify_ack_deadline \
767
- subscription,
768
- ack_ids,
769
- ack_deadline_seconds,
770
- options: nil,
771
- &block
772
- req = {
773
- subscription: subscription,
774
- ack_ids: ack_ids,
775
- ack_deadline_seconds: ack_deadline_seconds
776
- }.delete_if { |_, v| v.nil? }
777
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::ModifyAckDeadlineRequest)
778
- @modify_ack_deadline.call(req, options, &block)
779
- nil
780
- end
781
-
782
- # Acknowledges the messages associated with the `ack_ids` in the
783
- # `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages
784
- # from the subscription.
785
- #
786
- # Acknowledging a message whose ack deadline has expired may succeed,
787
- # but such a message may be redelivered later. Acknowledging a message more
788
- # than once will not result in an error.
789
- #
790
- # @param subscription [String]
791
- # The subscription whose message is being acknowledged.
792
- # Format is `projects/{project}/subscriptions/{sub}`.
793
- # @param ack_ids [Array<String>]
794
- # The acknowledgment ID for the messages being acknowledged that was returned
795
- # by the Pub/Sub system in the `Pull` response. Must not be empty.
796
- # @param options [Google::Gax::CallOptions]
797
- # Overrides the default settings for this call, e.g, timeout,
798
- # retries, etc.
799
- # @yield [result, operation] Access the result along with the RPC operation
800
- # @yieldparam result []
801
- # @yieldparam operation [GRPC::ActiveCall::Operation]
802
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
803
- # @example
804
- # require "google/cloud/pubsub"
805
- #
806
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
807
- # formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
808
- #
809
- # # TODO: Initialize `ack_ids`:
810
- # ack_ids = []
811
- # subscriber_client.acknowledge(formatted_subscription, ack_ids)
812
-
813
- def acknowledge \
814
- subscription,
815
- ack_ids,
816
- options: nil,
817
- &block
818
- req = {
819
- subscription: subscription,
820
- ack_ids: ack_ids
821
- }.delete_if { |_, v| v.nil? }
822
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::AcknowledgeRequest)
823
- @acknowledge.call(req, options, &block)
824
- nil
825
- end
826
-
827
- # Pulls messages from the server. The server may return `UNAVAILABLE` if
828
- # there are too many concurrent pull requests pending for the given
829
- # subscription.
830
- #
831
- # @param subscription [String]
832
- # The subscription from which messages should be pulled.
833
- # Format is `projects/{project}/subscriptions/{sub}`.
834
- # @param max_messages [Integer]
835
- # The maximum number of messages to return for this request. Must be a
836
- # positive integer. The Pub/Sub system may return fewer than the number
837
- # specified.
838
- # @param return_immediately [true, false]
839
- # If this field set to true, the system will respond immediately even if
840
- # it there are no messages available to return in the `Pull` response.
841
- # Otherwise, the system may wait (for a bounded amount of time) until at
842
- # least one message is available, rather than returning no messages.
843
- # @param options [Google::Gax::CallOptions]
844
- # Overrides the default settings for this call, e.g, timeout,
845
- # retries, etc.
846
- # @yield [result, operation] Access the result along with the RPC operation
847
- # @yieldparam result [Google::Cloud::PubSub::V1::PullResponse]
848
- # @yieldparam operation [GRPC::ActiveCall::Operation]
849
- # @return [Google::Cloud::PubSub::V1::PullResponse]
850
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
851
- # @example
852
- # require "google/cloud/pubsub"
853
- #
854
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
855
- # formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
856
- #
857
- # # TODO: Initialize `max_messages`:
858
- # max_messages = 0
859
- # response = subscriber_client.pull(formatted_subscription, max_messages)
860
-
861
- def pull \
862
- subscription,
863
- max_messages,
864
- return_immediately: nil,
865
- options: nil,
866
- &block
867
- req = {
868
- subscription: subscription,
869
- max_messages: max_messages,
870
- return_immediately: return_immediately
871
- }.delete_if { |_, v| v.nil? }
872
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::PullRequest)
873
- @pull.call(req, options, &block)
874
- end
875
-
876
- # Establishes a stream with the server, which sends messages down to the
877
- # client. The client streams acknowledgements and ack deadline modifications
878
- # back to the server. The server will close the stream and return the status
879
- # on any error. The server may close the stream with status `UNAVAILABLE` to
880
- # reassign server-side resources, in which case, the client should
881
- # re-establish the stream. Flow control can be achieved by configuring the
882
- # underlying RPC channel.
883
- #
884
- # @param reqs [Enumerable<Google::Cloud::PubSub::V1::StreamingPullRequest>]
885
- # The input requests.
886
- # @param options [Google::Gax::CallOptions]
887
- # Overrides the default settings for this call, e.g, timeout,
888
- # retries, etc.
889
- # @return [Enumerable<Google::Cloud::PubSub::V1::StreamingPullResponse>]
890
- # An enumerable of Google::Cloud::PubSub::V1::StreamingPullResponse instances.
891
- #
892
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
893
- #
894
- # @note
895
- # EXPERIMENTAL:
896
- # Streaming requests are still undergoing review.
897
- # This method interface might change in the future.
898
- #
899
- # @example
900
- # require "google/cloud/pubsub"
901
- #
902
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
903
- # formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
904
- #
905
- # # TODO: Initialize `stream_ack_deadline_seconds`:
906
- # stream_ack_deadline_seconds = 0
907
- # request = { subscription: formatted_subscription, stream_ack_deadline_seconds: stream_ack_deadline_seconds }
908
- # requests = [request]
909
- # subscriber_client.streaming_pull(requests).each do |element|
910
- # # Process element.
911
- # end
912
-
913
- def streaming_pull reqs, options: nil
914
- request_protos = reqs.lazy.map do |req|
915
- Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::StreamingPullRequest)
916
- end
917
- @streaming_pull.call(request_protos, options)
918
- end
919
-
920
- # Modifies the `PushConfig` for a specified subscription.
921
- #
922
- # This may be used to change a push subscription to a pull one (signified by
923
- # an empty `PushConfig`) or vice versa, or change the endpoint URL and other
924
- # attributes of a push subscription. Messages will accumulate for delivery
925
- # continuously through the call regardless of changes to the `PushConfig`.
926
- #
927
- # @param subscription [String]
928
- # The name of the subscription.
929
- # Format is `projects/{project}/subscriptions/{sub}`.
930
- # @param push_config [Google::Cloud::PubSub::V1::PushConfig | Hash]
931
- # The push configuration for future deliveries.
932
- #
933
- # An empty `pushConfig` indicates that the Pub/Sub system should
934
- # stop pushing messages from the given subscription and allow
935
- # messages to be pulled and acknowledged - effectively pausing
936
- # the subscription if `Pull` or `StreamingPull` is not called.
937
- # A hash of the same form as `Google::Cloud::PubSub::V1::PushConfig`
938
- # can also be provided.
939
- # @param options [Google::Gax::CallOptions]
940
- # Overrides the default settings for this call, e.g, timeout,
941
- # retries, etc.
942
- # @yield [result, operation] Access the result along with the RPC operation
943
- # @yieldparam result []
944
- # @yieldparam operation [GRPC::ActiveCall::Operation]
945
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
946
- # @example
947
- # require "google/cloud/pubsub"
948
- #
949
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
950
- # formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
951
- #
952
- # # TODO: Initialize `push_config`:
953
- # push_config = {}
954
- # subscriber_client.modify_push_config(formatted_subscription, push_config)
955
-
956
- def modify_push_config \
957
- subscription,
958
- push_config,
959
- options: nil,
960
- &block
961
- req = {
962
- subscription: subscription,
963
- push_config: push_config
964
- }.delete_if { |_, v| v.nil? }
965
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::ModifyPushConfigRequest)
966
- @modify_push_config.call(req, options, &block)
967
- nil
968
- end
969
-
970
- # Lists the existing snapshots. Snapshots are used in
971
- # <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
972
- # operations, which allow
973
- # you to manage message acknowledgments in bulk. That is, you can set the
974
- # acknowledgment state of messages in an existing subscription to the state
975
- # captured by a snapshot.
976
- #
977
- # @param project [String]
978
- # The name of the project in which to list snapshots.
979
- # Format is `projects/{project-id}`.
980
- # @param page_size [Integer]
981
- # The maximum number of resources contained in the underlying API
982
- # response. If page streaming is performed per-resource, this
983
- # parameter does not affect the return value. If page streaming is
984
- # performed per-page, this determines the maximum number of
985
- # resources in a page.
986
- # @param options [Google::Gax::CallOptions]
987
- # Overrides the default settings for this call, e.g, timeout,
988
- # retries, etc.
989
- # @yield [result, operation] Access the result along with the RPC operation
990
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::PubSub::V1::Snapshot>]
991
- # @yieldparam operation [GRPC::ActiveCall::Operation]
992
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::PubSub::V1::Snapshot>]
993
- # An enumerable of Google::Cloud::PubSub::V1::Snapshot instances.
994
- # See Google::Gax::PagedEnumerable documentation for other
995
- # operations such as per-page iteration or access to the response
996
- # object.
997
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
998
- # @example
999
- # require "google/cloud/pubsub"
1000
- #
1001
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
1002
- # formatted_project = Google::Cloud::PubSub::V1::SubscriberClient.project_path("[PROJECT]")
1003
- #
1004
- # # Iterate over all results.
1005
- # subscriber_client.list_snapshots(formatted_project).each do |element|
1006
- # # Process element.
1007
- # end
1008
- #
1009
- # # Or iterate over results one page at a time.
1010
- # subscriber_client.list_snapshots(formatted_project).each_page do |page|
1011
- # # Process each page at a time.
1012
- # page.each do |element|
1013
- # # Process element.
1014
- # end
1015
- # end
1016
-
1017
- def list_snapshots \
1018
- project,
1019
- page_size: nil,
1020
- options: nil,
1021
- &block
1022
- req = {
1023
- project: project,
1024
- page_size: page_size
1025
- }.delete_if { |_, v| v.nil? }
1026
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::ListSnapshotsRequest)
1027
- @list_snapshots.call(req, options, &block)
1028
- end
1029
-
1030
- # Creates a snapshot from the requested subscription. Snapshots are used in
1031
- # <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
1032
- # operations, which allow
1033
- # you to manage message acknowledgments in bulk. That is, you can set the
1034
- # acknowledgment state of messages in an existing subscription to the state
1035
- # captured by a snapshot.
1036
- # <br><br>If the snapshot already exists, returns `ALREADY_EXISTS`.
1037
- # If the requested subscription doesn't exist, returns `NOT_FOUND`.
1038
- # If the backlog in the subscription is too old -- and the resulting snapshot
1039
- # would expire in less than 1 hour -- then `FAILED_PRECONDITION` is returned.
1040
- # See also the `Snapshot.expire_time` field. If the name is not provided in
1041
- # the request, the server will assign a random
1042
- # name for this snapshot on the same project as the subscription, conforming
1043
- # to the
1044
- # [resource name
1045
- # format](https://cloud.google.com/pubsub/docs/admin#resource_names). The
1046
- # generated name is populated in the returned Snapshot object. Note that for
1047
- # REST API requests, you must specify a name in the request.
1048
- #
1049
- # @param name [String]
1050
- # Optional user-provided name for this snapshot.
1051
- # If the name is not provided in the request, the server will assign a random
1052
- # name for this snapshot on the same project as the subscription.
1053
- # Note that for REST API requests, you must specify a name. See the
1054
- # <a href="https://cloud.google.com/pubsub/docs/admin#resource_names">
1055
- # resource name rules</a>.
1056
- # Format is `projects/{project}/snapshots/{snap}`.
1057
- # @param subscription [String]
1058
- # The subscription whose backlog the snapshot retains.
1059
- # Specifically, the created snapshot is guaranteed to retain:
1060
- # (a) The existing backlog on the subscription. More precisely, this is
1061
- # defined as the messages in the subscription's backlog that are
1062
- # unacknowledged upon the successful completion of the
1063
- # `CreateSnapshot` request; as well as:
1064
- # (b) Any messages published to the subscription's topic following the
1065
- # successful completion of the CreateSnapshot request.
1066
- # Format is `projects/{project}/subscriptions/{sub}`.
1067
- # @param labels [Hash{String => String}]
1068
- # See <a href="https://cloud.google.com/pubsub/docs/labels"> Creating and
1069
- # managing labels</a>.
1070
- # @param options [Google::Gax::CallOptions]
1071
- # Overrides the default settings for this call, e.g, timeout,
1072
- # retries, etc.
1073
- # @yield [result, operation] Access the result along with the RPC operation
1074
- # @yieldparam result [Google::Cloud::PubSub::V1::Snapshot]
1075
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1076
- # @return [Google::Cloud::PubSub::V1::Snapshot]
1077
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1078
- # @example
1079
- # require "google/cloud/pubsub"
1080
- #
1081
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
1082
- # formatted_name = Google::Cloud::PubSub::V1::SubscriberClient.snapshot_path("[PROJECT]", "[SNAPSHOT]")
1083
- # formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
1084
- # response = subscriber_client.create_snapshot(formatted_name, formatted_subscription)
1085
-
1086
- def create_snapshot \
1087
- name,
1088
- subscription,
1089
- labels: nil,
1090
- options: nil,
1091
- &block
1092
- req = {
1093
- name: name,
1094
- subscription: subscription,
1095
- labels: labels
1096
- }.delete_if { |_, v| v.nil? }
1097
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::CreateSnapshotRequest)
1098
- @create_snapshot.call(req, options, &block)
1099
- end
1100
-
1101
- # Updates an existing snapshot. Snapshots are used in
1102
- # <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
1103
- # operations, which allow
1104
- # you to manage message acknowledgments in bulk. That is, you can set the
1105
- # acknowledgment state of messages in an existing subscription to the state
1106
- # captured by a snapshot.
1107
- #
1108
- # @param snapshot [Google::Cloud::PubSub::V1::Snapshot | Hash]
1109
- # The updated snapshot object.
1110
- # A hash of the same form as `Google::Cloud::PubSub::V1::Snapshot`
1111
- # can also be provided.
1112
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
1113
- # Indicates which fields in the provided snapshot to update.
1114
- # Must be specified and non-empty.
1115
- # A hash of the same form as `Google::Protobuf::FieldMask`
1116
- # can also be provided.
1117
- # @param options [Google::Gax::CallOptions]
1118
- # Overrides the default settings for this call, e.g, timeout,
1119
- # retries, etc.
1120
- # @yield [result, operation] Access the result along with the RPC operation
1121
- # @yieldparam result [Google::Cloud::PubSub::V1::Snapshot]
1122
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1123
- # @return [Google::Cloud::PubSub::V1::Snapshot]
1124
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1125
- # @example
1126
- # require "google/cloud/pubsub"
1127
- #
1128
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
1129
- # seconds = 123456
1130
- # expire_time = { seconds: seconds }
1131
- # snapshot = { expire_time: expire_time }
1132
- # paths_element = "expire_time"
1133
- # paths = [paths_element]
1134
- # update_mask = { paths: paths }
1135
- # response = subscriber_client.update_snapshot(snapshot, update_mask)
1136
-
1137
- def update_snapshot \
1138
- snapshot,
1139
- update_mask,
1140
- options: nil,
1141
- &block
1142
- req = {
1143
- snapshot: snapshot,
1144
- update_mask: update_mask
1145
- }.delete_if { |_, v| v.nil? }
1146
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::UpdateSnapshotRequest)
1147
- @update_snapshot.call(req, options, &block)
1148
- end
1149
-
1150
- # Removes an existing snapshot. Snapshots are used in
1151
- # <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
1152
- # operations, which allow
1153
- # you to manage message acknowledgments in bulk. That is, you can set the
1154
- # acknowledgment state of messages in an existing subscription to the state
1155
- # captured by a snapshot.<br><br>
1156
- # When the snapshot is deleted, all messages retained in the snapshot
1157
- # are immediately dropped. After a snapshot is deleted, a new one may be
1158
- # created with the same name, but the new one has no association with the old
1159
- # snapshot or its subscription, unless the same subscription is specified.
1160
- #
1161
- # @param snapshot [String]
1162
- # The name of the snapshot to delete.
1163
- # Format is `projects/{project}/snapshots/{snap}`.
1164
- # @param options [Google::Gax::CallOptions]
1165
- # Overrides the default settings for this call, e.g, timeout,
1166
- # retries, etc.
1167
- # @yield [result, operation] Access the result along with the RPC operation
1168
- # @yieldparam result []
1169
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1170
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1171
- # @example
1172
- # require "google/cloud/pubsub"
1173
- #
1174
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
1175
- # formatted_snapshot = Google::Cloud::PubSub::V1::SubscriberClient.snapshot_path("[PROJECT]", "[SNAPSHOT]")
1176
- # subscriber_client.delete_snapshot(formatted_snapshot)
1177
-
1178
- def delete_snapshot \
1179
- snapshot,
1180
- options: nil,
1181
- &block
1182
- req = {
1183
- snapshot: snapshot
1184
- }.delete_if { |_, v| v.nil? }
1185
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::DeleteSnapshotRequest)
1186
- @delete_snapshot.call(req, options, &block)
1187
- nil
1188
- end
1189
-
1190
- # Seeks an existing subscription to a point in time or to a given snapshot,
1191
- # whichever is provided in the request. Snapshots are used in
1192
- # <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
1193
- # operations, which allow
1194
- # you to manage message acknowledgments in bulk. That is, you can set the
1195
- # acknowledgment state of messages in an existing subscription to the state
1196
- # captured by a snapshot. Note that both the subscription and the snapshot
1197
- # must be on the same topic.
1198
- #
1199
- # @param subscription [String]
1200
- # The subscription to affect.
1201
- # @param time [Google::Protobuf::Timestamp | Hash]
1202
- # The time to seek to.
1203
- # Messages retained in the subscription that were published before this
1204
- # time are marked as acknowledged, and messages retained in the
1205
- # subscription that were published after this time are marked as
1206
- # unacknowledged. Note that this operation affects only those messages
1207
- # retained in the subscription (configured by the combination of
1208
- # `message_retention_duration` and `retain_acked_messages`). For example,
1209
- # if `time` corresponds to a point before the message retention
1210
- # window (or to a point before the system's notion of the subscription
1211
- # creation time), only retained messages will be marked as unacknowledged,
1212
- # and already-expunged messages will not be restored.
1213
- # A hash of the same form as `Google::Protobuf::Timestamp`
1214
- # can also be provided.
1215
- # @param snapshot [String]
1216
- # The snapshot to seek to. The snapshot's topic must be the same as that of
1217
- # the provided subscription.
1218
- # Format is `projects/{project}/snapshots/{snap}`.
1219
- # @param options [Google::Gax::CallOptions]
1220
- # Overrides the default settings for this call, e.g, timeout,
1221
- # retries, etc.
1222
- # @yield [result, operation] Access the result along with the RPC operation
1223
- # @yieldparam result [Google::Cloud::PubSub::V1::SeekResponse]
1224
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1225
- # @return [Google::Cloud::PubSub::V1::SeekResponse]
1226
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1227
- # @example
1228
- # require "google/cloud/pubsub"
1229
- #
1230
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
1231
- # formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
1232
- # response = subscriber_client.seek(formatted_subscription)
1233
-
1234
- def seek \
1235
- subscription,
1236
- time: nil,
1237
- snapshot: nil,
1238
- options: nil,
1239
- &block
1240
- req = {
1241
- subscription: subscription,
1242
- time: time,
1243
- snapshot: snapshot
1244
- }.delete_if { |_, v| v.nil? }
1245
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::SeekRequest)
1246
- @seek.call(req, options, &block)
1247
- end
1248
-
1249
- # Sets the access control policy on the specified resource. Replaces any
1250
- # existing policy.
1251
- #
1252
- # @param resource [String]
1253
- # REQUIRED: The resource for which the policy is being specified.
1254
- # See the operation documentation for the appropriate value for this field.
1255
- # @param policy [Google::Iam::V1::Policy | Hash]
1256
- # REQUIRED: The complete policy to be applied to the `resource`. The size of
1257
- # the policy is limited to a few 10s of KB. An empty policy is a
1258
- # valid policy but certain Cloud Platform services (such as Projects)
1259
- # might reject them.
1260
- # A hash of the same form as `Google::Iam::V1::Policy`
1261
- # can also be provided.
1262
- # @param options [Google::Gax::CallOptions]
1263
- # Overrides the default settings for this call, e.g, timeout,
1264
- # retries, etc.
1265
- # @yield [result, operation] Access the result along with the RPC operation
1266
- # @yieldparam result [Google::Iam::V1::Policy]
1267
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1268
- # @return [Google::Iam::V1::Policy]
1269
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1270
- # @example
1271
- # require "google/cloud/pubsub"
1272
- #
1273
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
1274
- # formatted_resource = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
1275
- #
1276
- # # TODO: Initialize `policy`:
1277
- # policy = {}
1278
- # response = subscriber_client.set_iam_policy(formatted_resource, policy)
1279
-
1280
- def set_iam_policy \
1281
- resource,
1282
- policy,
1283
- options: nil,
1284
- &block
1285
- req = {
1286
- resource: resource,
1287
- policy: policy
1288
- }.delete_if { |_, v| v.nil? }
1289
- req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
1290
- @set_iam_policy.call(req, options, &block)
1291
- end
1292
-
1293
- # Gets the access control policy for a resource.
1294
- # Returns an empty policy if the resource exists and does not have a policy
1295
- # set.
1296
- #
1297
- # @param resource [String]
1298
- # REQUIRED: The resource for which the policy is being requested.
1299
- # See the operation documentation for the appropriate value for this field.
1300
- # @param options_ [Google::Iam::V1::GetPolicyOptions | Hash]
1301
- # OPTIONAL: A `GetPolicyOptions` object for specifying options to
1302
- # `GetIamPolicy`. This field is only used by Cloud IAM.
1303
- # A hash of the same form as `Google::Iam::V1::GetPolicyOptions`
1304
- # can also be provided.
1305
- # @param options [Google::Gax::CallOptions]
1306
- # Overrides the default settings for this call, e.g, timeout,
1307
- # retries, etc.
1308
- # @yield [result, operation] Access the result along with the RPC operation
1309
- # @yieldparam result [Google::Iam::V1::Policy]
1310
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1311
- # @return [Google::Iam::V1::Policy]
1312
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1313
- # @example
1314
- # require "google/cloud/pubsub"
1315
- #
1316
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
1317
- # formatted_resource = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
1318
- # response = subscriber_client.get_iam_policy(formatted_resource)
1319
-
1320
- def get_iam_policy \
1321
- resource,
1322
- options_: nil,
1323
- options: nil,
1324
- &block
1325
- req = {
1326
- resource: resource,
1327
- options: options_
1328
- }.delete_if { |_, v| v.nil? }
1329
- req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
1330
- @get_iam_policy.call(req, options, &block)
1331
- end
1332
-
1333
- # Returns permissions that a caller has on the specified resource.
1334
- # If the resource does not exist, this will return an empty set of
1335
- # permissions, not a NOT_FOUND error.
1336
- #
1337
- # Note: This operation is designed to be used for building permission-aware
1338
- # UIs and command-line tools, not for authorization checking. This operation
1339
- # may "fail open" without warning.
1340
- #
1341
- # @param resource [String]
1342
- # REQUIRED: The resource for which the policy detail is being requested.
1343
- # See the operation documentation for the appropriate value for this field.
1344
- # @param permissions [Array<String>]
1345
- # The set of permissions to check for the `resource`. Permissions with
1346
- # wildcards (such as '*' or 'storage.*') are not allowed. For more
1347
- # information see
1348
- # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
1349
- # @param options [Google::Gax::CallOptions]
1350
- # Overrides the default settings for this call, e.g, timeout,
1351
- # retries, etc.
1352
- # @yield [result, operation] Access the result along with the RPC operation
1353
- # @yieldparam result [Google::Iam::V1::TestIamPermissionsResponse]
1354
- # @yieldparam operation [GRPC::ActiveCall::Operation]
1355
- # @return [Google::Iam::V1::TestIamPermissionsResponse]
1356
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1357
- # @example
1358
- # require "google/cloud/pubsub"
1359
- #
1360
- # subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
1361
- # formatted_resource = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
1362
- #
1363
- # # TODO: Initialize `permissions`:
1364
- # permissions = []
1365
- # response = subscriber_client.test_iam_permissions(formatted_resource, permissions)
1366
-
1367
- def test_iam_permissions \
1368
- resource,
1369
- permissions,
1370
- options: nil,
1371
- &block
1372
- req = {
1373
- resource: resource,
1374
- permissions: permissions
1375
- }.delete_if { |_, v| v.nil? }
1376
- req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
1377
- @test_iam_permissions.call(req, options, &block)
1378
- end
1379
- end
1380
- end
1381
- end
1382
-
1383
- Pubsub = PubSub unless const_defined? :Pubsub
1384
- end
1385
- end