google-cloud-pubsub 0.26.0 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +5 -5
  2. data/.yardopts +12 -2
  3. data/AUTHENTICATION.md +178 -0
  4. data/CHANGELOG.md +659 -0
  5. data/CODE_OF_CONDUCT.md +40 -0
  6. data/CONTRIBUTING.md +187 -0
  7. data/EMULATOR.md +37 -0
  8. data/LICENSE +2 -2
  9. data/LOGGING.md +32 -0
  10. data/OVERVIEW.md +528 -0
  11. data/TROUBLESHOOTING.md +31 -0
  12. data/lib/google/cloud/pubsub/async_publisher/batch.rb +310 -0
  13. data/lib/google/cloud/pubsub/async_publisher.rb +402 -0
  14. data/lib/google/cloud/pubsub/batch_publisher.rb +100 -0
  15. data/lib/google/cloud/pubsub/convert.rb +91 -0
  16. data/lib/google/cloud/pubsub/credentials.rb +26 -10
  17. data/lib/google/cloud/pubsub/errors.rb +85 -0
  18. data/lib/google/cloud/pubsub/message.rb +80 -17
  19. data/lib/google/cloud/pubsub/policy.rb +17 -14
  20. data/lib/google/cloud/pubsub/project.rb +364 -250
  21. data/lib/google/cloud/pubsub/publish_result.rb +103 -0
  22. data/lib/google/cloud/pubsub/received_message.rb +162 -24
  23. data/lib/google/cloud/pubsub/retry_policy.rb +88 -0
  24. data/lib/google/cloud/pubsub/schema/list.rb +180 -0
  25. data/lib/google/cloud/pubsub/schema.rb +310 -0
  26. data/lib/google/cloud/pubsub/service.rb +281 -265
  27. data/lib/google/cloud/pubsub/snapshot/list.rb +21 -21
  28. data/lib/google/cloud/pubsub/snapshot.rb +55 -15
  29. data/lib/google/cloud/pubsub/subscriber/enumerator_queue.rb +54 -0
  30. data/lib/google/cloud/pubsub/subscriber/inventory.rb +173 -0
  31. data/lib/google/cloud/pubsub/subscriber/sequencer.rb +115 -0
  32. data/lib/google/cloud/pubsub/subscriber/stream.rb +400 -0
  33. data/lib/google/cloud/pubsub/subscriber/timed_unary_buffer.rb +230 -0
  34. data/lib/google/cloud/pubsub/subscriber.rb +417 -0
  35. data/lib/google/cloud/pubsub/subscription/list.rb +28 -28
  36. data/lib/google/cloud/pubsub/subscription/push_config.rb +268 -0
  37. data/lib/google/cloud/pubsub/subscription.rb +900 -172
  38. data/lib/google/cloud/pubsub/topic/list.rb +21 -21
  39. data/lib/google/cloud/pubsub/topic.rb +674 -95
  40. data/lib/google/cloud/pubsub/version.rb +6 -4
  41. data/lib/google/cloud/pubsub.rb +104 -439
  42. data/lib/google-cloud-pubsub.rb +60 -29
  43. metadata +88 -50
  44. data/README.md +0 -69
  45. data/lib/google/cloud/pubsub/topic/publisher.rb +0 -86
  46. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/duration.rb +0 -77
  47. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/field_mask.rb +0 -223
  48. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/timestamp.rb +0 -81
  49. data/lib/google/cloud/pubsub/v1/doc/google/pubsub/v1/pubsub.rb +0 -503
  50. data/lib/google/cloud/pubsub/v1/publisher_client.rb +0 -605
  51. data/lib/google/cloud/pubsub/v1/publisher_client_config.json +0 -96
  52. data/lib/google/cloud/pubsub/v1/subscriber_client.rb +0 -1104
  53. data/lib/google/cloud/pubsub/v1/subscriber_client_config.json +0 -127
  54. data/lib/google/cloud/pubsub/v1.rb +0 -17
  55. data/lib/google/pubsub/v1/pubsub_pb.rb +0 -187
  56. data/lib/google/pubsub/v1/pubsub_services_pb.rb +0 -159
@@ -1,96 +0,0 @@
1
- {
2
- "interfaces": {
3
- "google.pubsub.v1.Publisher": {
4
- "retry_codes": {
5
- "idempotent": [
6
- "DEADLINE_EXCEEDED",
7
- "UNAVAILABLE"
8
- ],
9
- "one_plus_delivery": [
10
- "CANCELLED",
11
- "UNKNOWN",
12
- "DEADLINE_EXCEEDED",
13
- "RESOURCE_EXHAUSTED",
14
- "ABORTED",
15
- "INTERNAL",
16
- "UNAVAILABLE"
17
- ],
18
- "non_idempotent": []
19
- },
20
- "retry_params": {
21
- "default": {
22
- "initial_retry_delay_millis": 100,
23
- "retry_delay_multiplier": 1.3,
24
- "max_retry_delay_millis": 60000,
25
- "initial_rpc_timeout_millis": 60000,
26
- "rpc_timeout_multiplier": 1.0,
27
- "max_rpc_timeout_millis": 60000,
28
- "total_timeout_millis": 600000
29
- },
30
- "messaging": {
31
- "initial_retry_delay_millis": 100,
32
- "retry_delay_multiplier": 1.3,
33
- "max_retry_delay_millis": 60000,
34
- "initial_rpc_timeout_millis": 12000,
35
- "rpc_timeout_multiplier": 1.0,
36
- "max_rpc_timeout_millis": 12000,
37
- "total_timeout_millis": 600000
38
- }
39
- },
40
- "methods": {
41
- "CreateTopic": {
42
- "timeout_millis": 60000,
43
- "retry_codes_name": "idempotent",
44
- "retry_params_name": "default"
45
- },
46
- "Publish": {
47
- "timeout_millis": 60000,
48
- "retry_codes_name": "one_plus_delivery",
49
- "retry_params_name": "messaging",
50
- "bundling": {
51
- "element_count_threshold": 10,
52
- "element_count_limit": 1000,
53
- "request_byte_threshold": 1024,
54
- "request_byte_limit": 10485760,
55
- "delay_threshold_millis": 10
56
- }
57
- },
58
- "GetTopic": {
59
- "timeout_millis": 60000,
60
- "retry_codes_name": "idempotent",
61
- "retry_params_name": "default"
62
- },
63
- "ListTopics": {
64
- "timeout_millis": 60000,
65
- "retry_codes_name": "idempotent",
66
- "retry_params_name": "default"
67
- },
68
- "ListTopicSubscriptions": {
69
- "timeout_millis": 60000,
70
- "retry_codes_name": "idempotent",
71
- "retry_params_name": "default"
72
- },
73
- "DeleteTopic": {
74
- "timeout_millis": 60000,
75
- "retry_codes_name": "idempotent",
76
- "retry_params_name": "default"
77
- },
78
- "SetIamPolicy": {
79
- "timeout_millis": 60000,
80
- "retry_codes_name": "non_idempotent",
81
- "retry_params_name": "default"
82
- },
83
- "GetIamPolicy": {
84
- "timeout_millis": 60000,
85
- "retry_codes_name": "idempotent",
86
- "retry_params_name": "default"
87
- },
88
- "TestIamPermissions": {
89
- "timeout_millis": 60000,
90
- "retry_codes_name": "non_idempotent",
91
- "retry_params_name": "default"
92
- }
93
- }
94
- }
95
- }
96
- }
@@ -1,1104 +0,0 @@
1
- # Copyright 2017, Google Inc. All rights reserved.
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
- # http://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
- # The only allowed edits are to method and file documentation. A 3-way
23
- # merge preserves those additions if the generated source changes.
24
-
25
- require "json"
26
- require "pathname"
27
-
28
- require "google/gax"
29
-
30
- require "google/iam/v1/iam_policy_pb"
31
- require "google/pubsub/v1/pubsub_pb"
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.
39
- #
40
- # @!attribute [r] iam_policy_stub
41
- # @return [Google::Iam::V1::IAMPolicy::Stub]
42
- # @!attribute [r] subscriber_stub
43
- # @return [Google::Pubsub::V1::Subscriber::Stub]
44
- class SubscriberClient
45
- attr_reader :iam_policy_stub, :subscriber_stub
46
-
47
- # The default address of the service.
48
- SERVICE_ADDRESS = "pubsub.googleapis.com".freeze
49
-
50
- # The default port of the service.
51
- DEFAULT_SERVICE_PORT = 443
52
-
53
- DEFAULT_TIMEOUT = 30
54
-
55
- PAGE_DESCRIPTORS = {
56
- "list_subscriptions" => Google::Gax::PageDescriptor.new(
57
- "page_token",
58
- "next_page_token",
59
- "subscriptions"),
60
- "list_snapshots" => Google::Gax::PageDescriptor.new(
61
- "page_token",
62
- "next_page_token",
63
- "snapshots")
64
- }.freeze
65
-
66
- private_constant :PAGE_DESCRIPTORS
67
-
68
- # The scopes needed to make gRPC calls to all of the methods defined in
69
- # this service.
70
- ALL_SCOPES = [
71
- "https://www.googleapis.com/auth/cloud-platform",
72
- "https://www.googleapis.com/auth/pubsub"
73
- ].freeze
74
-
75
- PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
76
- "projects/{project}"
77
- )
78
-
79
- private_constant :PROJECT_PATH_TEMPLATE
80
-
81
- SNAPSHOT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
82
- "projects/{project}/snapshots/{snapshot}"
83
- )
84
-
85
- private_constant :SNAPSHOT_PATH_TEMPLATE
86
-
87
- SUBSCRIPTION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
88
- "projects/{project}/subscriptions/{subscription}"
89
- )
90
-
91
- private_constant :SUBSCRIPTION_PATH_TEMPLATE
92
-
93
- TOPIC_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
94
- "projects/{project}/topics/{topic}"
95
- )
96
-
97
- private_constant :TOPIC_PATH_TEMPLATE
98
-
99
- # Returns a fully-qualified project resource name string.
100
- # @param project [String]
101
- # @return [String]
102
- def self.project_path project
103
- PROJECT_PATH_TEMPLATE.render(
104
- :"project" => project
105
- )
106
- end
107
-
108
- # Returns a fully-qualified snapshot resource name string.
109
- # @param project [String]
110
- # @param snapshot [String]
111
- # @return [String]
112
- def self.snapshot_path project, snapshot
113
- SNAPSHOT_PATH_TEMPLATE.render(
114
- :"project" => project,
115
- :"snapshot" => snapshot
116
- )
117
- end
118
-
119
- # Returns a fully-qualified subscription resource name string.
120
- # @param project [String]
121
- # @param subscription [String]
122
- # @return [String]
123
- def self.subscription_path project, subscription
124
- SUBSCRIPTION_PATH_TEMPLATE.render(
125
- :"project" => project,
126
- :"subscription" => subscription
127
- )
128
- end
129
-
130
- # Returns a fully-qualified topic resource name string.
131
- # @param project [String]
132
- # @param topic [String]
133
- # @return [String]
134
- def self.topic_path project, topic
135
- TOPIC_PATH_TEMPLATE.render(
136
- :"project" => project,
137
- :"topic" => topic
138
- )
139
- end
140
-
141
- # Parses the project from a project resource.
142
- # @param project_name [String]
143
- # @return [String]
144
- def self.match_project_from_project_name project_name
145
- PROJECT_PATH_TEMPLATE.match(project_name)["project"]
146
- end
147
-
148
- # Parses the project from a snapshot resource.
149
- # @param snapshot_name [String]
150
- # @return [String]
151
- def self.match_project_from_snapshot_name snapshot_name
152
- SNAPSHOT_PATH_TEMPLATE.match(snapshot_name)["project"]
153
- end
154
-
155
- # Parses the snapshot from a snapshot resource.
156
- # @param snapshot_name [String]
157
- # @return [String]
158
- def self.match_snapshot_from_snapshot_name snapshot_name
159
- SNAPSHOT_PATH_TEMPLATE.match(snapshot_name)["snapshot"]
160
- end
161
-
162
- # Parses the project from a subscription resource.
163
- # @param subscription_name [String]
164
- # @return [String]
165
- def self.match_project_from_subscription_name subscription_name
166
- SUBSCRIPTION_PATH_TEMPLATE.match(subscription_name)["project"]
167
- end
168
-
169
- # Parses the subscription from a subscription resource.
170
- # @param subscription_name [String]
171
- # @return [String]
172
- def self.match_subscription_from_subscription_name subscription_name
173
- SUBSCRIPTION_PATH_TEMPLATE.match(subscription_name)["subscription"]
174
- end
175
-
176
- # Parses the project from a topic resource.
177
- # @param topic_name [String]
178
- # @return [String]
179
- def self.match_project_from_topic_name topic_name
180
- TOPIC_PATH_TEMPLATE.match(topic_name)["project"]
181
- end
182
-
183
- # Parses the topic from a topic resource.
184
- # @param topic_name [String]
185
- # @return [String]
186
- def self.match_topic_from_topic_name topic_name
187
- TOPIC_PATH_TEMPLATE.match(topic_name)["topic"]
188
- end
189
-
190
- # @param service_path [String]
191
- # The domain name of the API remote host.
192
- # @param port [Integer]
193
- # The port on which to connect to the remote host.
194
- # @param channel [Channel]
195
- # A Channel object through which to make calls.
196
- # @param chan_creds [Grpc::ChannelCredentials]
197
- # A ChannelCredentials for the setting up the RPC client.
198
- # @param client_config[Hash]
199
- # A Hash for call options for each method. See
200
- # Google::Gax#construct_settings for the structure of
201
- # this data. Falls back to the default config if not specified
202
- # or the specified config is missing data points.
203
- # @param timeout [Numeric]
204
- # The default timeout, in seconds, for calls made through this client.
205
- def initialize \
206
- service_path: SERVICE_ADDRESS,
207
- port: DEFAULT_SERVICE_PORT,
208
- channel: nil,
209
- chan_creds: nil,
210
- scopes: ALL_SCOPES,
211
- client_config: {},
212
- timeout: DEFAULT_TIMEOUT,
213
- app_name: nil,
214
- app_version: nil,
215
- lib_name: nil,
216
- lib_version: ""
217
- # These require statements are intentionally placed here to initialize
218
- # the gRPC module only when it's required.
219
- # See https://github.com/googleapis/toolkit/issues/446
220
- require "google/gax/grpc"
221
- require "google/iam/v1/iam_policy_services_pb"
222
- require "google/pubsub/v1/pubsub_services_pb"
223
-
224
-
225
- if app_name || app_version
226
- warn "`app_name` and `app_version` are no longer being used in the request headers."
227
- end
228
-
229
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
230
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
231
- google_api_client << " gapic/0.6.8 gax/#{Google::Gax::VERSION}"
232
- google_api_client << " grpc/#{GRPC::VERSION}"
233
- google_api_client.freeze
234
-
235
- headers = { :"x-goog-api-client" => google_api_client }
236
- client_config_file = Pathname.new(__dir__).join(
237
- "subscriber_client_config.json"
238
- )
239
- defaults = client_config_file.open do |f|
240
- Google::Gax.construct_settings(
241
- "google.pubsub.v1.Subscriber",
242
- JSON.parse(f.read),
243
- client_config,
244
- Google::Gax::Grpc::STATUS_CODE_NAMES,
245
- timeout,
246
- page_descriptors: PAGE_DESCRIPTORS,
247
- errors: Google::Gax::Grpc::API_ERRORS,
248
- kwargs: headers
249
- )
250
- end
251
- @iam_policy_stub = Google::Gax::Grpc.create_stub(
252
- service_path,
253
- port,
254
- chan_creds: chan_creds,
255
- channel: channel,
256
- scopes: scopes,
257
- &Google::Iam::V1::IAMPolicy::Stub.method(:new)
258
- )
259
- @subscriber_stub = Google::Gax::Grpc.create_stub(
260
- service_path,
261
- port,
262
- chan_creds: chan_creds,
263
- channel: channel,
264
- scopes: scopes,
265
- &Google::Pubsub::V1::Subscriber::Stub.method(:new)
266
- )
267
-
268
- @set_iam_policy = Google::Gax.create_api_call(
269
- @iam_policy_stub.method(:set_iam_policy),
270
- defaults["set_iam_policy"]
271
- )
272
- @get_iam_policy = Google::Gax.create_api_call(
273
- @iam_policy_stub.method(:get_iam_policy),
274
- defaults["get_iam_policy"]
275
- )
276
- @test_iam_permissions = Google::Gax.create_api_call(
277
- @iam_policy_stub.method(:test_iam_permissions),
278
- defaults["test_iam_permissions"]
279
- )
280
- @create_subscription = Google::Gax.create_api_call(
281
- @subscriber_stub.method(:create_subscription),
282
- defaults["create_subscription"]
283
- )
284
- @get_subscription = Google::Gax.create_api_call(
285
- @subscriber_stub.method(:get_subscription),
286
- defaults["get_subscription"]
287
- )
288
- @update_subscription = Google::Gax.create_api_call(
289
- @subscriber_stub.method(:update_subscription),
290
- defaults["update_subscription"]
291
- )
292
- @list_subscriptions = Google::Gax.create_api_call(
293
- @subscriber_stub.method(:list_subscriptions),
294
- defaults["list_subscriptions"]
295
- )
296
- @delete_subscription = Google::Gax.create_api_call(
297
- @subscriber_stub.method(:delete_subscription),
298
- defaults["delete_subscription"]
299
- )
300
- @modify_ack_deadline = Google::Gax.create_api_call(
301
- @subscriber_stub.method(:modify_ack_deadline),
302
- defaults["modify_ack_deadline"]
303
- )
304
- @acknowledge = Google::Gax.create_api_call(
305
- @subscriber_stub.method(:acknowledge),
306
- defaults["acknowledge"]
307
- )
308
- @pull = Google::Gax.create_api_call(
309
- @subscriber_stub.method(:pull),
310
- defaults["pull"]
311
- )
312
- @streaming_pull = Google::Gax.create_api_call(
313
- @subscriber_stub.method(:streaming_pull),
314
- defaults["streaming_pull"]
315
- )
316
- @modify_push_config = Google::Gax.create_api_call(
317
- @subscriber_stub.method(:modify_push_config),
318
- defaults["modify_push_config"]
319
- )
320
- @list_snapshots = Google::Gax.create_api_call(
321
- @subscriber_stub.method(:list_snapshots),
322
- defaults["list_snapshots"]
323
- )
324
- @create_snapshot = Google::Gax.create_api_call(
325
- @subscriber_stub.method(:create_snapshot),
326
- defaults["create_snapshot"]
327
- )
328
- @delete_snapshot = Google::Gax.create_api_call(
329
- @subscriber_stub.method(:delete_snapshot),
330
- defaults["delete_snapshot"]
331
- )
332
- @seek = Google::Gax.create_api_call(
333
- @subscriber_stub.method(:seek),
334
- defaults["seek"]
335
- )
336
- end
337
-
338
- # Service calls
339
-
340
- # Creates a subscription to a given topic.
341
- # If the subscription already exists, returns +ALREADY_EXISTS+.
342
- # If the corresponding topic doesn't exist, returns +NOT_FOUND+.
343
- #
344
- # If the name is not provided in the request, the server will assign a random
345
- # name for this subscription on the same project as the topic, conforming
346
- # to the
347
- # {resource name format}[https://cloud.google.com/pubsub/docs/overview#names].
348
- # The generated name is populated in the returned Subscription object.
349
- # Note that for REST API requests, you must specify a name in the request.
350
- #
351
- # @param name [String]
352
- # The name of the subscription. It must have the format
353
- # +"projects/{project}/subscriptions/{subscription}"+. +{subscription}+ must
354
- # start with a letter, and contain only letters (+[A-Za-z]+), numbers
355
- # (+[0-9]+), dashes (+-+), underscores (+_+), periods (+.+), tildes (+~+),
356
- # plus (+++) or percent signs (+%+). It must be between 3 and 255 characters
357
- # in length, and it must not start with +"goog"+.
358
- # @param topic [String]
359
- # The name of the topic from which this subscription is receiving messages.
360
- # Format is +projects/{project}/topics/{topic}+.
361
- # The value of this field will be +_deleted-topic_+ if the topic has been
362
- # deleted.
363
- # @param push_config [Google::Pubsub::V1::PushConfig]
364
- # If push delivery is used with this subscription, this field is
365
- # used to configure it. An empty +pushConfig+ signifies that the subscriber
366
- # will pull and ack messages using API methods.
367
- # @param ack_deadline_seconds [Integer]
368
- # This value is the maximum time after a subscriber receives a message
369
- # before the subscriber should acknowledge the message. After message
370
- # delivery but before the ack deadline expires and before the message is
371
- # acknowledged, it is an outstanding message and will not be delivered
372
- # again during that time (on a best-effort basis).
373
- #
374
- # For pull subscriptions, this value is used as the initial value for the ack
375
- # deadline. To override this value for a given message, call
376
- # +ModifyAckDeadline+ with the corresponding +ack_id+ if using
377
- # pull.
378
- # The minimum custom deadline you can specify is 10 seconds.
379
- # The maximum custom deadline you can specify is 600 seconds (10 minutes).
380
- # If this parameter is 0, a default value of 10 seconds is used.
381
- #
382
- # For push delivery, this value is also used to set the request timeout for
383
- # the call to the push endpoint.
384
- #
385
- # If the subscriber never acknowledges the message, the Pub/Sub
386
- # system will eventually redeliver the message.
387
- # @param retain_acked_messages [true, false]
388
- # Indicates whether to retain acknowledged messages. If true, then
389
- # messages are not expunged from the subscription's backlog, even if they are
390
- # acknowledged, until they fall out of the +message_retention_duration+
391
- # window.
392
- # @param message_retention_duration [Google::Protobuf::Duration]
393
- # How long to retain unacknowledged messages in the subscription's backlog,
394
- # from the moment a message is published.
395
- # If +retain_acked_messages+ is true, then this also configures the retention
396
- # of acknowledged messages, and thus configures how far back in time a +Seek+
397
- # can be done. Defaults to 7 days. Cannot be more than 7 days or less than 10
398
- # minutes.
399
- # @param options [Google::Gax::CallOptions]
400
- # Overrides the default settings for this call, e.g, timeout,
401
- # retries, etc.
402
- # @return [Google::Pubsub::V1::Subscription]
403
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
404
- # @example
405
- # require "google/cloud/pubsub/v1/subscriber_client"
406
- #
407
- # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
408
- #
409
- # subscriber_client = SubscriberClient.new
410
- # formatted_name = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
411
- # formatted_topic = SubscriberClient.topic_path("[PROJECT]", "[TOPIC]")
412
- # response = subscriber_client.create_subscription(formatted_name, formatted_topic)
413
-
414
- def create_subscription \
415
- name,
416
- topic,
417
- push_config: nil,
418
- ack_deadline_seconds: nil,
419
- retain_acked_messages: nil,
420
- message_retention_duration: nil,
421
- options: nil
422
- req = Google::Pubsub::V1::Subscription.new({
423
- name: name,
424
- topic: topic,
425
- push_config: push_config,
426
- ack_deadline_seconds: ack_deadline_seconds,
427
- retain_acked_messages: retain_acked_messages,
428
- message_retention_duration: message_retention_duration
429
- }.delete_if { |_, v| v.nil? })
430
- @create_subscription.call(req, options)
431
- end
432
-
433
- # Gets the configuration details of a subscription.
434
- #
435
- # @param subscription [String]
436
- # The name of the subscription to get.
437
- # Format is +projects/{project}/subscriptions/{sub}+.
438
- # @param options [Google::Gax::CallOptions]
439
- # Overrides the default settings for this call, e.g, timeout,
440
- # retries, etc.
441
- # @return [Google::Pubsub::V1::Subscription]
442
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
443
- # @example
444
- # require "google/cloud/pubsub/v1/subscriber_client"
445
- #
446
- # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
447
- #
448
- # subscriber_client = SubscriberClient.new
449
- # formatted_subscription = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
450
- # response = subscriber_client.get_subscription(formatted_subscription)
451
-
452
- def get_subscription \
453
- subscription,
454
- options: nil
455
- req = Google::Pubsub::V1::GetSubscriptionRequest.new({
456
- subscription: subscription
457
- }.delete_if { |_, v| v.nil? })
458
- @get_subscription.call(req, options)
459
- end
460
-
461
- # Updates an existing subscription. Note that certain properties of a
462
- # subscription, such as its topic, are not modifiable.
463
- #
464
- # @param subscription [Google::Pubsub::V1::Subscription]
465
- # The updated subscription object.
466
- # @param update_mask [Google::Protobuf::FieldMask]
467
- # Indicates which fields in the provided subscription to update.
468
- # Must be specified and non-empty.
469
- # @param options [Google::Gax::CallOptions]
470
- # Overrides the default settings for this call, e.g, timeout,
471
- # retries, etc.
472
- # @return [Google::Pubsub::V1::Subscription]
473
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
474
- # @example
475
- # require "google/cloud/pubsub/v1/subscriber_client"
476
- #
477
- # FieldMask = Google::Protobuf::FieldMask
478
- # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
479
- # Subscription = Google::Pubsub::V1::Subscription
480
- #
481
- # subscriber_client = SubscriberClient.new
482
- # subscription = Subscription.new
483
- # update_mask = FieldMask.new
484
- # response = subscriber_client.update_subscription(subscription, update_mask)
485
-
486
- def update_subscription \
487
- subscription,
488
- update_mask,
489
- options: nil
490
- req = Google::Pubsub::V1::UpdateSubscriptionRequest.new({
491
- subscription: subscription,
492
- update_mask: update_mask
493
- }.delete_if { |_, v| v.nil? })
494
- @update_subscription.call(req, options)
495
- end
496
-
497
- # Lists matching subscriptions.
498
- #
499
- # @param project [String]
500
- # The name of the cloud project that subscriptions belong to.
501
- # Format is +projects/{project}+.
502
- # @param page_size [Integer]
503
- # The maximum number of resources contained in the underlying API
504
- # response. If page streaming is performed per-resource, this
505
- # parameter does not affect the return value. If page streaming is
506
- # performed per-page, this determines the maximum number of
507
- # resources in a page.
508
- # @param options [Google::Gax::CallOptions]
509
- # Overrides the default settings for this call, e.g, timeout,
510
- # retries, etc.
511
- # @return [Google::Gax::PagedEnumerable<Google::Pubsub::V1::Subscription>]
512
- # An enumerable of Google::Pubsub::V1::Subscription instances.
513
- # See Google::Gax::PagedEnumerable documentation for other
514
- # operations such as per-page iteration or access to the response
515
- # object.
516
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
517
- # @example
518
- # require "google/cloud/pubsub/v1/subscriber_client"
519
- #
520
- # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
521
- #
522
- # subscriber_client = SubscriberClient.new
523
- # formatted_project = SubscriberClient.project_path("[PROJECT]")
524
- #
525
- # # Iterate over all results.
526
- # subscriber_client.list_subscriptions(formatted_project).each do |element|
527
- # # Process element.
528
- # end
529
- #
530
- # # Or iterate over results one page at a time.
531
- # subscriber_client.list_subscriptions(formatted_project).each_page do |page|
532
- # # Process each page at a time.
533
- # page.each do |element|
534
- # # Process element.
535
- # end
536
- # end
537
-
538
- def list_subscriptions \
539
- project,
540
- page_size: nil,
541
- options: nil
542
- req = Google::Pubsub::V1::ListSubscriptionsRequest.new({
543
- project: project,
544
- page_size: page_size
545
- }.delete_if { |_, v| v.nil? })
546
- @list_subscriptions.call(req, options)
547
- end
548
-
549
- # Deletes an existing subscription. All messages retained in the subscription
550
- # are immediately dropped. Calls to +Pull+ after deletion will return
551
- # +NOT_FOUND+. After a subscription is deleted, a new one may be created with
552
- # the same name, but the new one has no association with the old
553
- # subscription or its topic unless the same topic is specified.
554
- #
555
- # @param subscription [String]
556
- # The subscription to delete.
557
- # Format is +projects/{project}/subscriptions/{sub}+.
558
- # @param options [Google::Gax::CallOptions]
559
- # Overrides the default settings for this call, e.g, timeout,
560
- # retries, etc.
561
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
562
- # @example
563
- # require "google/cloud/pubsub/v1/subscriber_client"
564
- #
565
- # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
566
- #
567
- # subscriber_client = SubscriberClient.new
568
- # formatted_subscription = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
569
- # subscriber_client.delete_subscription(formatted_subscription)
570
-
571
- def delete_subscription \
572
- subscription,
573
- options: nil
574
- req = Google::Pubsub::V1::DeleteSubscriptionRequest.new({
575
- subscription: subscription
576
- }.delete_if { |_, v| v.nil? })
577
- @delete_subscription.call(req, options)
578
- nil
579
- end
580
-
581
- # Modifies the ack deadline for a specific message. This method is useful
582
- # to indicate that more time is needed to process a message by the
583
- # subscriber, or to make the message available for redelivery if the
584
- # processing was interrupted. Note that this does not modify the
585
- # subscription-level +ackDeadlineSeconds+ used for subsequent messages.
586
- #
587
- # @param subscription [String]
588
- # The name of the subscription.
589
- # Format is +projects/{project}/subscriptions/{sub}+.
590
- # @param ack_ids [Array<String>]
591
- # List of acknowledgment IDs.
592
- # @param ack_deadline_seconds [Integer]
593
- # The new ack deadline with respect to the time this request was sent to
594
- # the Pub/Sub system. For example, if the value is 10, the new
595
- # ack deadline will expire 10 seconds after the +ModifyAckDeadline+ call
596
- # was made. Specifying zero may immediately make the message available for
597
- # another pull request.
598
- # The minimum deadline you can specify is 0 seconds.
599
- # The maximum deadline you can specify is 600 seconds (10 minutes).
600
- # @param options [Google::Gax::CallOptions]
601
- # Overrides the default settings for this call, e.g, timeout,
602
- # retries, etc.
603
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
604
- # @example
605
- # require "google/cloud/pubsub/v1/subscriber_client"
606
- #
607
- # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
608
- #
609
- # subscriber_client = SubscriberClient.new
610
- # formatted_subscription = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
611
- # ack_ids = []
612
- # ack_deadline_seconds = 0
613
- # subscriber_client.modify_ack_deadline(formatted_subscription, ack_ids, ack_deadline_seconds)
614
-
615
- def modify_ack_deadline \
616
- subscription,
617
- ack_ids,
618
- ack_deadline_seconds,
619
- options: nil
620
- req = Google::Pubsub::V1::ModifyAckDeadlineRequest.new({
621
- subscription: subscription,
622
- ack_ids: ack_ids,
623
- ack_deadline_seconds: ack_deadline_seconds
624
- }.delete_if { |_, v| v.nil? })
625
- @modify_ack_deadline.call(req, options)
626
- nil
627
- end
628
-
629
- # Acknowledges the messages associated with the +ack_ids+ in the
630
- # +AcknowledgeRequest+. The Pub/Sub system can remove the relevant messages
631
- # from the subscription.
632
- #
633
- # Acknowledging a message whose ack deadline has expired may succeed,
634
- # but such a message may be redelivered later. Acknowledging a message more
635
- # than once will not result in an error.
636
- #
637
- # @param subscription [String]
638
- # The subscription whose message is being acknowledged.
639
- # Format is +projects/{project}/subscriptions/{sub}+.
640
- # @param ack_ids [Array<String>]
641
- # The acknowledgment ID for the messages being acknowledged that was returned
642
- # by the Pub/Sub system in the +Pull+ response. Must not be empty.
643
- # @param options [Google::Gax::CallOptions]
644
- # Overrides the default settings for this call, e.g, timeout,
645
- # retries, etc.
646
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
647
- # @example
648
- # require "google/cloud/pubsub/v1/subscriber_client"
649
- #
650
- # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
651
- #
652
- # subscriber_client = SubscriberClient.new
653
- # formatted_subscription = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
654
- # ack_ids = []
655
- # subscriber_client.acknowledge(formatted_subscription, ack_ids)
656
-
657
- def acknowledge \
658
- subscription,
659
- ack_ids,
660
- options: nil
661
- req = Google::Pubsub::V1::AcknowledgeRequest.new({
662
- subscription: subscription,
663
- ack_ids: ack_ids
664
- }.delete_if { |_, v| v.nil? })
665
- @acknowledge.call(req, options)
666
- nil
667
- end
668
-
669
- # Pulls messages from the server. Returns an empty list if there are no
670
- # messages available in the backlog. The server may return +UNAVAILABLE+ if
671
- # there are too many concurrent pull requests pending for the given
672
- # subscription.
673
- #
674
- # @param subscription [String]
675
- # The subscription from which messages should be pulled.
676
- # Format is +projects/{project}/subscriptions/{sub}+.
677
- # @param max_messages [Integer]
678
- # The maximum number of messages returned for this request. The Pub/Sub
679
- # system may return fewer than the number specified.
680
- # @param return_immediately [true, false]
681
- # If this field set to true, the system will respond immediately even if
682
- # it there are no messages available to return in the +Pull+ response.
683
- # Otherwise, the system may wait (for a bounded amount of time) until at
684
- # least one message is available, rather than returning no messages. The
685
- # client may cancel the request if it does not wish to wait any longer for
686
- # the response.
687
- # @param options [Google::Gax::CallOptions]
688
- # Overrides the default settings for this call, e.g, timeout,
689
- # retries, etc.
690
- # @return [Google::Pubsub::V1::PullResponse]
691
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
692
- # @example
693
- # require "google/cloud/pubsub/v1/subscriber_client"
694
- #
695
- # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
696
- #
697
- # subscriber_client = SubscriberClient.new
698
- # formatted_subscription = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
699
- # max_messages = 0
700
- # response = subscriber_client.pull(formatted_subscription, max_messages)
701
-
702
- def pull \
703
- subscription,
704
- max_messages,
705
- return_immediately: nil,
706
- options: nil
707
- req = Google::Pubsub::V1::PullRequest.new({
708
- subscription: subscription,
709
- max_messages: max_messages,
710
- return_immediately: return_immediately
711
- }.delete_if { |_, v| v.nil? })
712
- @pull.call(req, options)
713
- end
714
-
715
- # (EXPERIMENTAL) StreamingPull is an experimental feature. This RPC will
716
- # respond with UNIMPLEMENTED errors unless you have been invited to test
717
- # this feature. Contact cloud-pubsub@google.com with any questions.
718
- #
719
- # Establishes a stream with the server, which sends messages down to the
720
- # client. The client streams acknowledgements and ack deadline modifications
721
- # back to the server. The server will close the stream and return the status
722
- # on any error. The server may close the stream with status +OK+ to reassign
723
- # server-side resources, in which case, the client should re-establish the
724
- # stream. +UNAVAILABLE+ may also be returned in the case of a transient error
725
- # (e.g., a server restart). These should also be retried by the client. Flow
726
- # control can be achieved by configuring the underlying RPC channel.
727
- #
728
- # @param reqs [Enumerable<Google::Pubsub::V1::StreamingPullRequest>]
729
- # The input requests.
730
- # @param options [Google::Gax::CallOptions]
731
- # Overrides the default settings for this call, e.g, timeout,
732
- # retries, etc.
733
- # @return [Enumerable<Google::Pubsub::V1::StreamingPullResponse>]
734
- # An enumerable of Google::Pubsub::V1::StreamingPullResponse instances.
735
- #
736
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
737
- #
738
- # @note
739
- # EXPERIMENTAL:
740
- # Streaming requests are still undergoing review.
741
- # This method interface might change in the future.
742
- #
743
- # @example
744
- # require "google/cloud/pubsub/v1/subscriber_client"
745
- #
746
- # StreamingPullRequest = Google::Pubsub::V1::StreamingPullRequest
747
- # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
748
- #
749
- # subscriber_client = SubscriberClient.new
750
- # formatted_subscription = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
751
- # stream_ack_deadline_seconds = 0
752
- # request = StreamingPullRequest.new
753
- # request.subscription = formatted_subscription
754
- # request.stream_ack_deadline_seconds = stream_ack_deadline_seconds
755
- # requests = [request]
756
- # subscriber_client.streaming_pull(requests).each do |element|
757
- # # Process element.
758
- # end
759
-
760
- def streaming_pull reqs, options: nil
761
- @streaming_pull.call(reqs, options)
762
- end
763
-
764
- # Modifies the +PushConfig+ for a specified subscription.
765
- #
766
- # This may be used to change a push subscription to a pull one (signified by
767
- # an empty +PushConfig+) or vice versa, or change the endpoint URL and other
768
- # attributes of a push subscription. Messages will accumulate for delivery
769
- # continuously through the call regardless of changes to the +PushConfig+.
770
- #
771
- # @param subscription [String]
772
- # The name of the subscription.
773
- # Format is +projects/{project}/subscriptions/{sub}+.
774
- # @param push_config [Google::Pubsub::V1::PushConfig]
775
- # The push configuration for future deliveries.
776
- #
777
- # An empty +pushConfig+ indicates that the Pub/Sub system should
778
- # stop pushing messages from the given subscription and allow
779
- # messages to be pulled and acknowledged - effectively pausing
780
- # the subscription if +Pull+ is not called.
781
- # @param options [Google::Gax::CallOptions]
782
- # Overrides the default settings for this call, e.g, timeout,
783
- # retries, etc.
784
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
785
- # @example
786
- # require "google/cloud/pubsub/v1/subscriber_client"
787
- #
788
- # PushConfig = Google::Pubsub::V1::PushConfig
789
- # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
790
- #
791
- # subscriber_client = SubscriberClient.new
792
- # formatted_subscription = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
793
- # push_config = PushConfig.new
794
- # subscriber_client.modify_push_config(formatted_subscription, push_config)
795
-
796
- def modify_push_config \
797
- subscription,
798
- push_config,
799
- options: nil
800
- req = Google::Pubsub::V1::ModifyPushConfigRequest.new({
801
- subscription: subscription,
802
- push_config: push_config
803
- }.delete_if { |_, v| v.nil? })
804
- @modify_push_config.call(req, options)
805
- nil
806
- end
807
-
808
- # Lists the existing snapshots.
809
- #
810
- # @param project [String]
811
- # The name of the cloud project that snapshots belong to.
812
- # Format is +projects/{project}+.
813
- # @param page_size [Integer]
814
- # The maximum number of resources contained in the underlying API
815
- # response. If page streaming is performed per-resource, this
816
- # parameter does not affect the return value. If page streaming is
817
- # performed per-page, this determines the maximum number of
818
- # resources in a page.
819
- # @param options [Google::Gax::CallOptions]
820
- # Overrides the default settings for this call, e.g, timeout,
821
- # retries, etc.
822
- # @return [Google::Gax::PagedEnumerable<Google::Pubsub::V1::Snapshot>]
823
- # An enumerable of Google::Pubsub::V1::Snapshot instances.
824
- # See Google::Gax::PagedEnumerable documentation for other
825
- # operations such as per-page iteration or access to the response
826
- # object.
827
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
828
- # @example
829
- # require "google/cloud/pubsub/v1/subscriber_client"
830
- #
831
- # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
832
- #
833
- # subscriber_client = SubscriberClient.new
834
- # formatted_project = SubscriberClient.project_path("[PROJECT]")
835
- #
836
- # # Iterate over all results.
837
- # subscriber_client.list_snapshots(formatted_project).each do |element|
838
- # # Process element.
839
- # end
840
- #
841
- # # Or iterate over results one page at a time.
842
- # subscriber_client.list_snapshots(formatted_project).each_page do |page|
843
- # # Process each page at a time.
844
- # page.each do |element|
845
- # # Process element.
846
- # end
847
- # end
848
-
849
- def list_snapshots \
850
- project,
851
- page_size: nil,
852
- options: nil
853
- req = Google::Pubsub::V1::ListSnapshotsRequest.new({
854
- project: project,
855
- page_size: page_size
856
- }.delete_if { |_, v| v.nil? })
857
- @list_snapshots.call(req, options)
858
- end
859
-
860
- # Creates a snapshot from the requested subscription.
861
- # If the snapshot already exists, returns +ALREADY_EXISTS+.
862
- # If the requested subscription doesn't exist, returns +NOT_FOUND+.
863
- #
864
- # If the name is not provided in the request, the server will assign a random
865
- # name for this snapshot on the same project as the subscription, conforming
866
- # to the
867
- # {resource name format}[https://cloud.google.com/pubsub/docs/overview#names].
868
- # The generated name is populated in the returned Snapshot object.
869
- # Note that for REST API requests, you must specify a name in the request.
870
- #
871
- # @param name [String]
872
- # Optional user-provided name for this snapshot.
873
- # If the name is not provided in the request, the server will assign a random
874
- # name for this snapshot on the same project as the subscription.
875
- # Note that for REST API requests, you must specify a name.
876
- # Format is +projects/{project}/snapshots/{snap}+.
877
- # @param subscription [String]
878
- # The subscription whose backlog the snapshot retains.
879
- # Specifically, the created snapshot is guaranteed to retain:
880
- # (a) The existing backlog on the subscription. More precisely, this is
881
- # defined as the messages in the subscription's backlog that are
882
- # unacknowledged upon the successful completion of the
883
- # +CreateSnapshot+ request; as well as:
884
- # (b) Any messages published to the subscription's topic following the
885
- # successful completion of the CreateSnapshot request.
886
- # Format is +projects/{project}/subscriptions/{sub}+.
887
- # @param options [Google::Gax::CallOptions]
888
- # Overrides the default settings for this call, e.g, timeout,
889
- # retries, etc.
890
- # @return [Google::Pubsub::V1::Snapshot]
891
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
892
- # @example
893
- # require "google/cloud/pubsub/v1/subscriber_client"
894
- #
895
- # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
896
- #
897
- # subscriber_client = SubscriberClient.new
898
- # formatted_name = SubscriberClient.snapshot_path("[PROJECT]", "[SNAPSHOT]")
899
- # formatted_subscription = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
900
- # response = subscriber_client.create_snapshot(formatted_name, formatted_subscription)
901
-
902
- def create_snapshot \
903
- name,
904
- subscription,
905
- options: nil
906
- req = Google::Pubsub::V1::CreateSnapshotRequest.new({
907
- name: name,
908
- subscription: subscription
909
- }.delete_if { |_, v| v.nil? })
910
- @create_snapshot.call(req, options)
911
- end
912
-
913
- # Removes an existing snapshot. All messages retained in the snapshot
914
- # are immediately dropped. After a snapshot is deleted, a new one may be
915
- # created with the same name, but the new one has no association with the old
916
- # snapshot or its subscription, unless the same subscription is specified.
917
- #
918
- # @param snapshot [String]
919
- # The name of the snapshot to delete.
920
- # Format is +projects/{project}/snapshots/{snap}+.
921
- # @param options [Google::Gax::CallOptions]
922
- # Overrides the default settings for this call, e.g, timeout,
923
- # retries, etc.
924
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
925
- # @example
926
- # require "google/cloud/pubsub/v1/subscriber_client"
927
- #
928
- # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
929
- #
930
- # subscriber_client = SubscriberClient.new
931
- # formatted_snapshot = SubscriberClient.snapshot_path("[PROJECT]", "[SNAPSHOT]")
932
- # subscriber_client.delete_snapshot(formatted_snapshot)
933
-
934
- def delete_snapshot \
935
- snapshot,
936
- options: nil
937
- req = Google::Pubsub::V1::DeleteSnapshotRequest.new({
938
- snapshot: snapshot
939
- }.delete_if { |_, v| v.nil? })
940
- @delete_snapshot.call(req, options)
941
- nil
942
- end
943
-
944
- # Seeks an existing subscription to a point in time or to a given snapshot,
945
- # whichever is provided in the request.
946
- #
947
- # @param subscription [String]
948
- # The subscription to affect.
949
- # @param time [Google::Protobuf::Timestamp]
950
- # The time to seek to.
951
- # Messages retained in the subscription that were published before this
952
- # time are marked as acknowledged, and messages retained in the
953
- # subscription that were published after this time are marked as
954
- # unacknowledged. Note that this operation affects only those messages
955
- # retained in the subscription (configured by the combination of
956
- # +message_retention_duration+ and +retain_acked_messages+). For example,
957
- # if +time+ corresponds to a point before the message retention
958
- # window (or to a point before the system's notion of the subscription
959
- # creation time), only retained messages will be marked as unacknowledged,
960
- # and already-expunged messages will not be restored.
961
- # @param snapshot [String]
962
- # The snapshot to seek to. The snapshot's topic must be the same as that of
963
- # the provided subscription.
964
- # Format is +projects/{project}/snapshots/{snap}+.
965
- # @param options [Google::Gax::CallOptions]
966
- # Overrides the default settings for this call, e.g, timeout,
967
- # retries, etc.
968
- # @return [Google::Pubsub::V1::SeekResponse]
969
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
970
- # @example
971
- # require "google/cloud/pubsub/v1/subscriber_client"
972
- #
973
- # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
974
- #
975
- # subscriber_client = SubscriberClient.new
976
- # formatted_subscription = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
977
- # response = subscriber_client.seek(formatted_subscription)
978
-
979
- def seek \
980
- subscription,
981
- time: nil,
982
- snapshot: nil,
983
- options: nil
984
- req = Google::Pubsub::V1::SeekRequest.new({
985
- subscription: subscription,
986
- time: time,
987
- snapshot: snapshot
988
- }.delete_if { |_, v| v.nil? })
989
- @seek.call(req, options)
990
- end
991
-
992
- # Sets the access control policy on the specified resource. Replaces any
993
- # existing policy.
994
- #
995
- # @param resource [String]
996
- # REQUIRED: The resource for which the policy is being specified.
997
- # +resource+ is usually specified as a path. For example, a Project
998
- # resource is specified as +projects/{project}+.
999
- # @param policy [Google::Iam::V1::Policy]
1000
- # REQUIRED: The complete policy to be applied to the +resource+. The size of
1001
- # the policy is limited to a few 10s of KB. An empty policy is a
1002
- # valid policy but certain Cloud Platform services (such as Projects)
1003
- # might reject them.
1004
- # @param options [Google::Gax::CallOptions]
1005
- # Overrides the default settings for this call, e.g, timeout,
1006
- # retries, etc.
1007
- # @return [Google::Iam::V1::Policy]
1008
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1009
- # @example
1010
- # require "google/cloud/pubsub/v1/subscriber_client"
1011
- #
1012
- # Policy = Google::Iam::V1::Policy
1013
- # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
1014
- #
1015
- # subscriber_client = SubscriberClient.new
1016
- # formatted_resource = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
1017
- # policy = Policy.new
1018
- # response = subscriber_client.set_iam_policy(formatted_resource, policy)
1019
-
1020
- def set_iam_policy \
1021
- resource,
1022
- policy,
1023
- options: nil
1024
- req = Google::Iam::V1::SetIamPolicyRequest.new({
1025
- resource: resource,
1026
- policy: policy
1027
- }.delete_if { |_, v| v.nil? })
1028
- @set_iam_policy.call(req, options)
1029
- end
1030
-
1031
- # Gets the access control policy for a resource.
1032
- # Returns an empty policy if the resource exists and does not have a policy
1033
- # set.
1034
- #
1035
- # @param resource [String]
1036
- # REQUIRED: The resource for which the policy is being requested.
1037
- # +resource+ is usually specified as a path. For example, a Project
1038
- # resource is specified as +projects/{project}+.
1039
- # @param options [Google::Gax::CallOptions]
1040
- # Overrides the default settings for this call, e.g, timeout,
1041
- # retries, etc.
1042
- # @return [Google::Iam::V1::Policy]
1043
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1044
- # @example
1045
- # require "google/cloud/pubsub/v1/subscriber_client"
1046
- #
1047
- # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
1048
- #
1049
- # subscriber_client = SubscriberClient.new
1050
- # formatted_resource = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
1051
- # response = subscriber_client.get_iam_policy(formatted_resource)
1052
-
1053
- def get_iam_policy \
1054
- resource,
1055
- options: nil
1056
- req = Google::Iam::V1::GetIamPolicyRequest.new({
1057
- resource: resource
1058
- }.delete_if { |_, v| v.nil? })
1059
- @get_iam_policy.call(req, options)
1060
- end
1061
-
1062
- # Returns permissions that a caller has on the specified resource.
1063
- # If the resource does not exist, this will return an empty set of
1064
- # permissions, not a NOT_FOUND error.
1065
- #
1066
- # @param resource [String]
1067
- # REQUIRED: The resource for which the policy detail is being requested.
1068
- # +resource+ is usually specified as a path. For example, a Project
1069
- # resource is specified as +projects/{project}+.
1070
- # @param permissions [Array<String>]
1071
- # The set of permissions to check for the +resource+. Permissions with
1072
- # wildcards (such as '*' or 'storage.*') are not allowed. For more
1073
- # information see
1074
- # {IAM Overview}[https://cloud.google.com/iam/docs/overview#permissions].
1075
- # @param options [Google::Gax::CallOptions]
1076
- # Overrides the default settings for this call, e.g, timeout,
1077
- # retries, etc.
1078
- # @return [Google::Iam::V1::TestIamPermissionsResponse]
1079
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
1080
- # @example
1081
- # require "google/cloud/pubsub/v1/subscriber_client"
1082
- #
1083
- # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
1084
- #
1085
- # subscriber_client = SubscriberClient.new
1086
- # formatted_resource = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
1087
- # permissions = []
1088
- # response = subscriber_client.test_iam_permissions(formatted_resource, permissions)
1089
-
1090
- def test_iam_permissions \
1091
- resource,
1092
- permissions,
1093
- options: nil
1094
- req = Google::Iam::V1::TestIamPermissionsRequest.new({
1095
- resource: resource,
1096
- permissions: permissions
1097
- }.delete_if { |_, v| v.nil? })
1098
- @test_iam_permissions.call(req, options)
1099
- end
1100
- end
1101
- end
1102
- end
1103
- end
1104
- end