google-cloud-pubsub 0.31.1 → 0.32.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/README.md +8 -8
  4. data/lib/google/cloud/pubsub/async_publisher.rb +4 -0
  5. data/lib/google/cloud/pubsub/credentials.rb +2 -14
  6. data/lib/google/cloud/pubsub/subscriber.rb +85 -0
  7. data/lib/google/cloud/pubsub/subscriber/async_stream_pusher.rb +24 -19
  8. data/lib/google/cloud/pubsub/subscriber/async_unary_pusher.rb +45 -26
  9. data/lib/google/cloud/pubsub/subscriber/inventory.rb +136 -0
  10. data/lib/google/cloud/pubsub/subscriber/stream.rb +80 -138
  11. data/lib/google/cloud/pubsub/subscription.rb +2 -2
  12. data/lib/google/cloud/pubsub/topic.rb +4 -4
  13. data/lib/google/cloud/pubsub/v1/credentials.rb +38 -0
  14. data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/iam_policy.rb +62 -0
  15. data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/policy.rb +127 -0
  16. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/duration.rb +1 -1
  17. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/empty.rb +28 -0
  18. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/field_mask.rb +1 -1
  19. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/timestamp.rb +1 -1
  20. data/lib/google/cloud/pubsub/v1/doc/google/pubsub/v1/pubsub.rb +113 -31
  21. data/lib/google/cloud/pubsub/v1/publisher_client.rb +180 -109
  22. data/lib/google/cloud/pubsub/v1/subscriber_client.rb +322 -193
  23. data/lib/google/cloud/pubsub/v1/subscriber_client_config.json +1 -1
  24. data/lib/google/cloud/pubsub/version.rb +1 -1
  25. data/lib/google/pubsub/v1/pubsub_pb.rb +21 -0
  26. data/lib/google/pubsub/v1/pubsub_services_pb.rb +87 -73
  27. metadata +23 -5
  28. data/lib/google/cloud/pubsub/v1/doc/overview.rb +0 -75
@@ -1,4 +1,4 @@
1
- # Copyright 2017 Google LLC
1
+ # Copyright 2018 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -18,9 +18,6 @@
18
18
  # and updates to that file get reflected here through a refresh process.
19
19
  # For the short term, the refresh process will only be runnable by Google
20
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
21
 
25
22
  require "json"
26
23
  require "pathname"
@@ -29,14 +26,15 @@ require "google/gax"
29
26
 
30
27
  require "google/iam/v1/iam_policy_pb"
31
28
  require "google/pubsub/v1/pubsub_pb"
32
- require "google/cloud/pubsub/credentials"
29
+ require "google/cloud/pubsub/v1/credentials"
33
30
 
34
31
  module Google
35
32
  module Cloud
36
33
  module Pubsub
37
34
  module V1
38
35
  # The service that an application uses to manipulate subscriptions and to
39
- # consume messages from a subscription via the +Pull+ method.
36
+ # consume messages from a subscription via the +Pull+ method or by
37
+ # establishing a bi-directional stream using the +StreamingPull+ method.
40
38
  #
41
39
  # @!attribute [r] iam_policy_stub
42
40
  # @return [Google::Iam::V1::IAMPolicy::Stub]
@@ -51,6 +49,9 @@ module Google
51
49
  # The default port of the service.
52
50
  DEFAULT_SERVICE_PORT = 443
53
51
 
52
+ # The default set of gRPC interceptors.
53
+ GRPC_INTERCEPTORS = []
54
+
54
55
  DEFAULT_TIMEOUT = 30
55
56
 
56
57
  PAGE_DESCRIPTORS = {
@@ -73,17 +74,6 @@ module Google
73
74
  "https://www.googleapis.com/auth/pubsub"
74
75
  ].freeze
75
76
 
76
- PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
77
- "projects/{project}"
78
- )
79
-
80
- private_constant :PROJECT_PATH_TEMPLATE
81
-
82
- SNAPSHOT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
83
- "projects/{project}/snapshots/{snapshot}"
84
- )
85
-
86
- private_constant :SNAPSHOT_PATH_TEMPLATE
87
77
 
88
78
  SUBSCRIPTION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
89
79
  "projects/{project}/subscriptions/{subscription}"
@@ -97,25 +87,17 @@ module Google
97
87
 
98
88
  private_constant :TOPIC_PATH_TEMPLATE
99
89
 
100
- # Returns a fully-qualified project resource name string.
101
- # @param project [String]
102
- # @return [String]
103
- def self.project_path project
104
- PROJECT_PATH_TEMPLATE.render(
105
- :"project" => project
106
- )
107
- end
90
+ PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
91
+ "projects/{project}"
92
+ )
108
93
 
109
- # Returns a fully-qualified snapshot resource name string.
110
- # @param project [String]
111
- # @param snapshot [String]
112
- # @return [String]
113
- def self.snapshot_path project, snapshot
114
- SNAPSHOT_PATH_TEMPLATE.render(
115
- :"project" => project,
116
- :"snapshot" => snapshot
117
- )
118
- end
94
+ private_constant :PROJECT_PATH_TEMPLATE
95
+
96
+ SNAPSHOT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
97
+ "projects/{project}/snapshots/{snapshot}"
98
+ )
99
+
100
+ private_constant :SNAPSHOT_PATH_TEMPLATE
119
101
 
120
102
  # Returns a fully-qualified subscription resource name string.
121
103
  # @param project [String]
@@ -139,6 +121,26 @@ module Google
139
121
  )
140
122
  end
141
123
 
124
+ # Returns a fully-qualified project resource name string.
125
+ # @param project [String]
126
+ # @return [String]
127
+ def self.project_path project
128
+ PROJECT_PATH_TEMPLATE.render(
129
+ :"project" => project
130
+ )
131
+ end
132
+
133
+ # Returns a fully-qualified snapshot resource name string.
134
+ # @param project [String]
135
+ # @param snapshot [String]
136
+ # @return [String]
137
+ def self.snapshot_path project, snapshot
138
+ SNAPSHOT_PATH_TEMPLATE.render(
139
+ :"project" => project,
140
+ :"snapshot" => snapshot
141
+ )
142
+ end
143
+
142
144
  # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
143
145
  # Provides the means for authenticating requests made by the client. This parameter can
144
146
  # be many types.
@@ -163,16 +165,18 @@ module Google
163
165
  # or the specified config is missing data points.
164
166
  # @param timeout [Numeric]
165
167
  # The default timeout, in seconds, for calls made through this client.
168
+ # @param metadata [Hash]
169
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
170
+ # @param exception_transformer [Proc]
171
+ # An optional proc that intercepts any exceptions raised during an API call to inject
172
+ # custom error handling.
166
173
  def initialize \
167
- service_path: SERVICE_ADDRESS,
168
- port: DEFAULT_SERVICE_PORT,
169
- channel: nil,
170
- chan_creds: nil,
171
- updater_proc: nil,
172
174
  credentials: nil,
173
175
  scopes: ALL_SCOPES,
174
176
  client_config: {},
175
177
  timeout: DEFAULT_TIMEOUT,
178
+ metadata: nil,
179
+ exception_transformer: nil,
176
180
  lib_name: nil,
177
181
  lib_version: ""
178
182
  # These require statements are intentionally placed here to initialize
@@ -182,21 +186,10 @@ module Google
182
186
  require "google/iam/v1/iam_policy_services_pb"
183
187
  require "google/pubsub/v1/pubsub_services_pb"
184
188
 
185
- if channel || chan_creds || updater_proc
186
- warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
187
- "on 2017/09/08"
188
- credentials ||= channel
189
- credentials ||= chan_creds
190
- credentials ||= updater_proc
191
- end
192
- if service_path != SERVICE_ADDRESS || port != DEFAULT_SERVICE_PORT
193
- warn "`service_path` and `port` parameters are deprecated and will be removed"
194
- end
195
-
196
- credentials ||= Google::Cloud::Pubsub::Credentials.default
189
+ credentials ||= Google::Cloud::Pubsub::V1::Credentials.default
197
190
 
198
191
  if credentials.is_a?(String) || credentials.is_a?(Hash)
199
- updater_proc = Google::Cloud::Pubsub::Credentials.new(credentials).updater_proc
192
+ updater_proc = Google::Cloud::Pubsub::V1::Credentials.new(credentials).updater_proc
200
193
  end
201
194
  if credentials.is_a?(GRPC::Core::Channel)
202
195
  channel = credentials
@@ -211,13 +204,16 @@ module Google
211
204
  updater_proc = credentials.updater_proc
212
205
  end
213
206
 
207
+ package_version = Gem.loaded_specs['google-cloud-pubsub'].version.version
208
+
214
209
  google_api_client = "gl-ruby/#{RUBY_VERSION}"
215
210
  google_api_client << " #{lib_name}/#{lib_version}" if lib_name
216
- google_api_client << " gapic/0.1.0 gax/#{Google::Gax::VERSION}"
211
+ google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
217
212
  google_api_client << " grpc/#{GRPC::VERSION}"
218
213
  google_api_client.freeze
219
214
 
220
215
  headers = { :"x-goog-api-client" => google_api_client }
216
+ headers.merge!(metadata) unless metadata.nil?
221
217
  client_config_file = Pathname.new(__dir__).join(
222
218
  "subscriber_client_config.json"
223
219
  )
@@ -230,9 +226,14 @@ module Google
230
226
  timeout,
231
227
  page_descriptors: PAGE_DESCRIPTORS,
232
228
  errors: Google::Gax::Grpc::API_ERRORS,
233
- kwargs: headers
229
+ metadata: headers
234
230
  )
235
231
  end
232
+
233
+ # Allow overriding the service path/port in subclasses.
234
+ service_path = self.class::SERVICE_ADDRESS
235
+ port = self.class::DEFAULT_SERVICE_PORT
236
+ interceptors = self.class::GRPC_INTERCEPTORS
236
237
  @iam_policy_stub = Google::Gax::Grpc.create_stub(
237
238
  service_path,
238
239
  port,
@@ -240,6 +241,7 @@ module Google
240
241
  channel: channel,
241
242
  updater_proc: updater_proc,
242
243
  scopes: scopes,
244
+ interceptors: interceptors,
243
245
  &Google::Iam::V1::IAMPolicy::Stub.method(:new)
244
246
  )
245
247
  @subscriber_stub = Google::Gax::Grpc.create_stub(
@@ -249,86 +251,106 @@ module Google
249
251
  channel: channel,
250
252
  updater_proc: updater_proc,
251
253
  scopes: scopes,
254
+ interceptors: interceptors,
252
255
  &Google::Pubsub::V1::Subscriber::Stub.method(:new)
253
256
  )
254
257
 
255
- @set_iam_policy = Google::Gax.create_api_call(
256
- @iam_policy_stub.method(:set_iam_policy),
257
- defaults["set_iam_policy"]
258
- )
259
- @get_iam_policy = Google::Gax.create_api_call(
260
- @iam_policy_stub.method(:get_iam_policy),
261
- defaults["get_iam_policy"]
262
- )
263
- @test_iam_permissions = Google::Gax.create_api_call(
264
- @iam_policy_stub.method(:test_iam_permissions),
265
- defaults["test_iam_permissions"]
266
- )
267
258
  @create_subscription = Google::Gax.create_api_call(
268
259
  @subscriber_stub.method(:create_subscription),
269
- defaults["create_subscription"]
260
+ defaults["create_subscription"],
261
+ exception_transformer: exception_transformer
270
262
  )
271
263
  @get_subscription = Google::Gax.create_api_call(
272
264
  @subscriber_stub.method(:get_subscription),
273
- defaults["get_subscription"]
265
+ defaults["get_subscription"],
266
+ exception_transformer: exception_transformer
274
267
  )
275
268
  @update_subscription = Google::Gax.create_api_call(
276
269
  @subscriber_stub.method(:update_subscription),
277
- defaults["update_subscription"]
270
+ defaults["update_subscription"],
271
+ exception_transformer: exception_transformer
278
272
  )
279
273
  @list_subscriptions = Google::Gax.create_api_call(
280
274
  @subscriber_stub.method(:list_subscriptions),
281
- defaults["list_subscriptions"]
275
+ defaults["list_subscriptions"],
276
+ exception_transformer: exception_transformer
282
277
  )
283
278
  @delete_subscription = Google::Gax.create_api_call(
284
279
  @subscriber_stub.method(:delete_subscription),
285
- defaults["delete_subscription"]
280
+ defaults["delete_subscription"],
281
+ exception_transformer: exception_transformer
286
282
  )
287
283
  @modify_ack_deadline = Google::Gax.create_api_call(
288
284
  @subscriber_stub.method(:modify_ack_deadline),
289
- defaults["modify_ack_deadline"]
285
+ defaults["modify_ack_deadline"],
286
+ exception_transformer: exception_transformer
290
287
  )
291
288
  @acknowledge = Google::Gax.create_api_call(
292
289
  @subscriber_stub.method(:acknowledge),
293
- defaults["acknowledge"]
290
+ defaults["acknowledge"],
291
+ exception_transformer: exception_transformer
294
292
  )
295
293
  @pull = Google::Gax.create_api_call(
296
294
  @subscriber_stub.method(:pull),
297
- defaults["pull"]
295
+ defaults["pull"],
296
+ exception_transformer: exception_transformer
298
297
  )
299
298
  @streaming_pull = Google::Gax.create_api_call(
300
299
  @subscriber_stub.method(:streaming_pull),
301
- defaults["streaming_pull"]
300
+ defaults["streaming_pull"],
301
+ exception_transformer: exception_transformer
302
302
  )
303
303
  @modify_push_config = Google::Gax.create_api_call(
304
304
  @subscriber_stub.method(:modify_push_config),
305
- defaults["modify_push_config"]
305
+ defaults["modify_push_config"],
306
+ exception_transformer: exception_transformer
306
307
  )
307
308
  @list_snapshots = Google::Gax.create_api_call(
308
309
  @subscriber_stub.method(:list_snapshots),
309
- defaults["list_snapshots"]
310
+ defaults["list_snapshots"],
311
+ exception_transformer: exception_transformer
310
312
  )
311
313
  @create_snapshot = Google::Gax.create_api_call(
312
314
  @subscriber_stub.method(:create_snapshot),
313
- defaults["create_snapshot"]
315
+ defaults["create_snapshot"],
316
+ exception_transformer: exception_transformer
314
317
  )
315
318
  @update_snapshot = Google::Gax.create_api_call(
316
319
  @subscriber_stub.method(:update_snapshot),
317
- defaults["update_snapshot"]
320
+ defaults["update_snapshot"],
321
+ exception_transformer: exception_transformer
318
322
  )
319
323
  @delete_snapshot = Google::Gax.create_api_call(
320
324
  @subscriber_stub.method(:delete_snapshot),
321
- defaults["delete_snapshot"]
325
+ defaults["delete_snapshot"],
326
+ exception_transformer: exception_transformer
322
327
  )
323
328
  @seek = Google::Gax.create_api_call(
324
329
  @subscriber_stub.method(:seek),
325
- defaults["seek"]
330
+ defaults["seek"],
331
+ exception_transformer: exception_transformer
332
+ )
333
+ @set_iam_policy = Google::Gax.create_api_call(
334
+ @iam_policy_stub.method(:set_iam_policy),
335
+ defaults["set_iam_policy"],
336
+ exception_transformer: exception_transformer
337
+ )
338
+ @get_iam_policy = Google::Gax.create_api_call(
339
+ @iam_policy_stub.method(:get_iam_policy),
340
+ defaults["get_iam_policy"],
341
+ exception_transformer: exception_transformer
342
+ )
343
+ @test_iam_permissions = Google::Gax.create_api_call(
344
+ @iam_policy_stub.method(:test_iam_permissions),
345
+ defaults["test_iam_permissions"],
346
+ exception_transformer: exception_transformer
326
347
  )
327
348
  end
328
349
 
329
350
  # Service calls
330
351
 
331
- # Creates a subscription to a given topic.
352
+ # Creates a subscription to a given topic. See the
353
+ # <a href="/pubsub/docs/admin#resource_names"> resource name rules</a>.
332
354
  # If the subscription already exists, returns +ALREADY_EXISTS+.
333
355
  # If the corresponding topic doesn't exist, returns +NOT_FOUND+.
334
356
  #
@@ -345,7 +367,7 @@ module Google
345
367
  # start with a letter, and contain only letters (+[A-Za-z]+), numbers
346
368
  # (+[0-9]+), dashes (+-+), underscores (+_+), periods (+.+), tildes (+~+),
347
369
  # plus (+++) or percent signs (+%+). It must be between 3 and 255 characters
348
- # in length, and it must not start with +"goog"+.
370
+ # in length, and it must not start with +"goog"+
349
371
  # @param topic [String]
350
372
  # The name of the topic from which this subscription is receiving messages.
351
373
  # Format is +projects/{project}/topics/{topic}+.
@@ -367,7 +389,8 @@ module Google
367
389
  # For pull subscriptions, this value is used as the initial value for the ack
368
390
  # deadline. To override this value for a given message, call
369
391
  # +ModifyAckDeadline+ with the corresponding +ack_id+ if using
370
- # pull.
392
+ # non-streaming pull or send the +ack_id+ in a
393
+ # +StreamingModifyAckDeadlineRequest+ if using streaming pull.
371
394
  # The minimum custom deadline you can specify is 10 seconds.
372
395
  # The maximum custom deadline you can specify is 600 seconds (10 minutes).
373
396
  # If this parameter is 0, a default value of 10 seconds is used.
@@ -381,14 +404,20 @@ module Google
381
404
  # Indicates whether to retain acknowledged messages. If true, then
382
405
  # messages are not expunged from the subscription's backlog, even if they are
383
406
  # acknowledged, until they fall out of the +message_retention_duration+
384
- # window.
407
+ # window.<br><br>
408
+ # <b>ALPHA:</b> This feature is part of an alpha release. This API might be
409
+ # changed in backward-incompatible ways and is not recommended for production
410
+ # use. It is not subject to any SLA or deprecation policy.
385
411
  # @param message_retention_duration [Google::Protobuf::Duration | Hash]
386
412
  # How long to retain unacknowledged messages in the subscription's backlog,
387
413
  # from the moment a message is published.
388
414
  # If +retain_acked_messages+ is true, then this also configures the retention
389
415
  # of acknowledged messages, and thus configures how far back in time a +Seek+
390
416
  # can be done. Defaults to 7 days. Cannot be more than 7 days or less than 10
391
- # minutes.
417
+ # minutes.<br><br>
418
+ # <b>ALPHA:</b> This feature is part of an alpha release. This API might be
419
+ # changed in backward-incompatible ways and is not recommended for production
420
+ # use. It is not subject to any SLA or deprecation policy.
392
421
  # A hash of the same form as `Google::Protobuf::Duration`
393
422
  # can also be provided.
394
423
  # @param labels [Hash{String => String}]
@@ -396,12 +425,15 @@ module Google
396
425
  # @param options [Google::Gax::CallOptions]
397
426
  # Overrides the default settings for this call, e.g, timeout,
398
427
  # retries, etc.
428
+ # @yield [result, operation] Access the result along with the RPC operation
429
+ # @yieldparam result [Google::Pubsub::V1::Subscription]
430
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
399
431
  # @return [Google::Pubsub::V1::Subscription]
400
432
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
401
433
  # @example
402
- # require "google/cloud/pubsub/v1"
434
+ # require "google/cloud/pubsub"
403
435
  #
404
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
436
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
405
437
  # formatted_name = Google::Cloud::Pubsub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
406
438
  # formatted_topic = Google::Cloud::Pubsub::V1::SubscriberClient.topic_path("[PROJECT]", "[TOPIC]")
407
439
  # response = subscriber_client.create_subscription(formatted_name, formatted_topic)
@@ -414,7 +446,8 @@ module Google
414
446
  retain_acked_messages: nil,
415
447
  message_retention_duration: nil,
416
448
  labels: nil,
417
- options: nil
449
+ options: nil,
450
+ &block
418
451
  req = {
419
452
  name: name,
420
453
  topic: topic,
@@ -425,7 +458,7 @@ module Google
425
458
  labels: labels
426
459
  }.delete_if { |_, v| v.nil? }
427
460
  req = Google::Gax::to_proto(req, Google::Pubsub::V1::Subscription)
428
- @create_subscription.call(req, options)
461
+ @create_subscription.call(req, options, &block)
429
462
  end
430
463
 
431
464
  # Gets the configuration details of a subscription.
@@ -436,31 +469,31 @@ module Google
436
469
  # @param options [Google::Gax::CallOptions]
437
470
  # Overrides the default settings for this call, e.g, timeout,
438
471
  # retries, etc.
472
+ # @yield [result, operation] Access the result along with the RPC operation
473
+ # @yieldparam result [Google::Pubsub::V1::Subscription]
474
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
439
475
  # @return [Google::Pubsub::V1::Subscription]
440
476
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
441
477
  # @example
442
- # require "google/cloud/pubsub/v1"
478
+ # require "google/cloud/pubsub"
443
479
  #
444
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
480
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
445
481
  # formatted_subscription = Google::Cloud::Pubsub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
446
482
  # response = subscriber_client.get_subscription(formatted_subscription)
447
483
 
448
484
  def get_subscription \
449
485
  subscription,
450
- options: nil
486
+ options: nil,
487
+ &block
451
488
  req = {
452
489
  subscription: subscription
453
490
  }.delete_if { |_, v| v.nil? }
454
491
  req = Google::Gax::to_proto(req, Google::Pubsub::V1::GetSubscriptionRequest)
455
- @get_subscription.call(req, options)
492
+ @get_subscription.call(req, options, &block)
456
493
  end
457
494
 
458
495
  # Updates an existing subscription. Note that certain properties of a
459
496
  # subscription, such as its topic, are not modifiable.
460
- # NOTE: The style guide requires body: "subscription" instead of body: "*".
461
- # Keeping the latter for internal consistency in V1, however it should be
462
- # corrected in V2. See
463
- # https://cloud.google.com/apis/design/standard_methods#update for details.
464
497
  #
465
498
  # @param subscription [Google::Pubsub::V1::Subscription | Hash]
466
499
  # The updated subscription object.
@@ -474,26 +507,33 @@ module Google
474
507
  # @param options [Google::Gax::CallOptions]
475
508
  # Overrides the default settings for this call, e.g, timeout,
476
509
  # retries, etc.
510
+ # @yield [result, operation] Access the result along with the RPC operation
511
+ # @yieldparam result [Google::Pubsub::V1::Subscription]
512
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
477
513
  # @return [Google::Pubsub::V1::Subscription]
478
514
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
479
515
  # @example
480
- # require "google/cloud/pubsub/v1"
516
+ # require "google/cloud/pubsub"
481
517
  #
482
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
483
- # subscription = {}
484
- # update_mask = {}
518
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
519
+ # ack_deadline_seconds = 42
520
+ # subscription = { ack_deadline_seconds: ack_deadline_seconds }
521
+ # paths_element = "ack_deadline_seconds"
522
+ # paths = [paths_element]
523
+ # update_mask = { paths: paths }
485
524
  # response = subscriber_client.update_subscription(subscription, update_mask)
486
525
 
487
526
  def update_subscription \
488
527
  subscription,
489
528
  update_mask,
490
- options: nil
529
+ options: nil,
530
+ &block
491
531
  req = {
492
532
  subscription: subscription,
493
533
  update_mask: update_mask
494
534
  }.delete_if { |_, v| v.nil? }
495
535
  req = Google::Gax::to_proto(req, Google::Pubsub::V1::UpdateSubscriptionRequest)
496
- @update_subscription.call(req, options)
536
+ @update_subscription.call(req, options, &block)
497
537
  end
498
538
 
499
539
  # Lists matching subscriptions.
@@ -510,6 +550,9 @@ module Google
510
550
  # @param options [Google::Gax::CallOptions]
511
551
  # Overrides the default settings for this call, e.g, timeout,
512
552
  # retries, etc.
553
+ # @yield [result, operation] Access the result along with the RPC operation
554
+ # @yieldparam result [Google::Gax::PagedEnumerable<Google::Pubsub::V1::Subscription>]
555
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
513
556
  # @return [Google::Gax::PagedEnumerable<Google::Pubsub::V1::Subscription>]
514
557
  # An enumerable of Google::Pubsub::V1::Subscription instances.
515
558
  # See Google::Gax::PagedEnumerable documentation for other
@@ -517,9 +560,9 @@ module Google
517
560
  # object.
518
561
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
519
562
  # @example
520
- # require "google/cloud/pubsub/v1"
563
+ # require "google/cloud/pubsub"
521
564
  #
522
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
565
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
523
566
  # formatted_project = Google::Cloud::Pubsub::V1::SubscriberClient.project_path("[PROJECT]")
524
567
  #
525
568
  # # Iterate over all results.
@@ -538,13 +581,14 @@ module Google
538
581
  def list_subscriptions \
539
582
  project,
540
583
  page_size: nil,
541
- options: nil
584
+ options: nil,
585
+ &block
542
586
  req = {
543
587
  project: project,
544
588
  page_size: page_size
545
589
  }.delete_if { |_, v| v.nil? }
546
590
  req = Google::Gax::to_proto(req, Google::Pubsub::V1::ListSubscriptionsRequest)
547
- @list_subscriptions.call(req, options)
591
+ @list_subscriptions.call(req, options, &block)
548
592
  end
549
593
 
550
594
  # Deletes an existing subscription. All messages retained in the subscription
@@ -559,22 +603,26 @@ module Google
559
603
  # @param options [Google::Gax::CallOptions]
560
604
  # Overrides the default settings for this call, e.g, timeout,
561
605
  # retries, etc.
606
+ # @yield [result, operation] Access the result along with the RPC operation
607
+ # @yieldparam result []
608
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
562
609
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
563
610
  # @example
564
- # require "google/cloud/pubsub/v1"
611
+ # require "google/cloud/pubsub"
565
612
  #
566
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
613
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
567
614
  # formatted_subscription = Google::Cloud::Pubsub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
568
615
  # subscriber_client.delete_subscription(formatted_subscription)
569
616
 
570
617
  def delete_subscription \
571
618
  subscription,
572
- options: nil
619
+ options: nil,
620
+ &block
573
621
  req = {
574
622
  subscription: subscription
575
623
  }.delete_if { |_, v| v.nil? }
576
624
  req = Google::Gax::to_proto(req, Google::Pubsub::V1::DeleteSubscriptionRequest)
577
- @delete_subscription.call(req, options)
625
+ @delete_subscription.call(req, options, &block)
578
626
  nil
579
627
  end
580
628
 
@@ -600,13 +648,20 @@ module Google
600
648
  # @param options [Google::Gax::CallOptions]
601
649
  # Overrides the default settings for this call, e.g, timeout,
602
650
  # retries, etc.
651
+ # @yield [result, operation] Access the result along with the RPC operation
652
+ # @yieldparam result []
653
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
603
654
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
604
655
  # @example
605
- # require "google/cloud/pubsub/v1"
656
+ # require "google/cloud/pubsub"
606
657
  #
607
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
658
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
608
659
  # formatted_subscription = Google::Cloud::Pubsub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
660
+ #
661
+ # # TODO: Initialize +ack_ids+:
609
662
  # ack_ids = []
663
+ #
664
+ # # TODO: Initialize +ack_deadline_seconds+:
610
665
  # ack_deadline_seconds = 0
611
666
  # subscriber_client.modify_ack_deadline(formatted_subscription, ack_ids, ack_deadline_seconds)
612
667
 
@@ -614,14 +669,15 @@ module Google
614
669
  subscription,
615
670
  ack_ids,
616
671
  ack_deadline_seconds,
617
- options: nil
672
+ options: nil,
673
+ &block
618
674
  req = {
619
675
  subscription: subscription,
620
676
  ack_ids: ack_ids,
621
677
  ack_deadline_seconds: ack_deadline_seconds
622
678
  }.delete_if { |_, v| v.nil? }
623
679
  req = Google::Gax::to_proto(req, Google::Pubsub::V1::ModifyAckDeadlineRequest)
624
- @modify_ack_deadline.call(req, options)
680
+ @modify_ack_deadline.call(req, options, &block)
625
681
  nil
626
682
  end
627
683
 
@@ -642,25 +698,31 @@ module Google
642
698
  # @param options [Google::Gax::CallOptions]
643
699
  # Overrides the default settings for this call, e.g, timeout,
644
700
  # retries, etc.
701
+ # @yield [result, operation] Access the result along with the RPC operation
702
+ # @yieldparam result []
703
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
645
704
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
646
705
  # @example
647
- # require "google/cloud/pubsub/v1"
706
+ # require "google/cloud/pubsub"
648
707
  #
649
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
708
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
650
709
  # formatted_subscription = Google::Cloud::Pubsub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
710
+ #
711
+ # # TODO: Initialize +ack_ids+:
651
712
  # ack_ids = []
652
713
  # subscriber_client.acknowledge(formatted_subscription, ack_ids)
653
714
 
654
715
  def acknowledge \
655
716
  subscription,
656
717
  ack_ids,
657
- options: nil
718
+ options: nil,
719
+ &block
658
720
  req = {
659
721
  subscription: subscription,
660
722
  ack_ids: ack_ids
661
723
  }.delete_if { |_, v| v.nil? }
662
724
  req = Google::Gax::to_proto(req, Google::Pubsub::V1::AcknowledgeRequest)
663
- @acknowledge.call(req, options)
725
+ @acknowledge.call(req, options, &block)
664
726
  nil
665
727
  end
666
728
 
@@ -685,13 +747,18 @@ module Google
685
747
  # @param options [Google::Gax::CallOptions]
686
748
  # Overrides the default settings for this call, e.g, timeout,
687
749
  # retries, etc.
750
+ # @yield [result, operation] Access the result along with the RPC operation
751
+ # @yieldparam result [Google::Pubsub::V1::PullResponse]
752
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
688
753
  # @return [Google::Pubsub::V1::PullResponse]
689
754
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
690
755
  # @example
691
- # require "google/cloud/pubsub/v1"
756
+ # require "google/cloud/pubsub"
692
757
  #
693
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
758
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
694
759
  # formatted_subscription = Google::Cloud::Pubsub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
760
+ #
761
+ # # TODO: Initialize +max_messages+:
695
762
  # max_messages = 0
696
763
  # response = subscriber_client.pull(formatted_subscription, max_messages)
697
764
 
@@ -699,28 +766,24 @@ module Google
699
766
  subscription,
700
767
  max_messages,
701
768
  return_immediately: nil,
702
- options: nil
769
+ options: nil,
770
+ &block
703
771
  req = {
704
772
  subscription: subscription,
705
773
  max_messages: max_messages,
706
774
  return_immediately: return_immediately
707
775
  }.delete_if { |_, v| v.nil? }
708
776
  req = Google::Gax::to_proto(req, Google::Pubsub::V1::PullRequest)
709
- @pull.call(req, options)
777
+ @pull.call(req, options, &block)
710
778
  end
711
779
 
712
- # (EXPERIMENTAL) StreamingPull is an experimental feature. This RPC will
713
- # respond with UNIMPLEMENTED errors unless you have been invited to test
714
- # this feature. Contact cloud-pubsub@google.com with any questions.
715
- #
716
780
  # Establishes a stream with the server, which sends messages down to the
717
781
  # client. The client streams acknowledgements and ack deadline modifications
718
782
  # back to the server. The server will close the stream and return the status
719
- # on any error. The server may close the stream with status +OK+ to reassign
720
- # server-side resources, in which case, the client should re-establish the
721
- # stream. +UNAVAILABLE+ may also be returned in the case of a transient error
722
- # (e.g., a server restart). These should also be retried by the client. Flow
723
- # control can be achieved by configuring the underlying RPC channel.
783
+ # on any error. The server may close the stream with status +UNAVAILABLE+ to
784
+ # reassign server-side resources, in which case, the client should
785
+ # re-establish the stream. Flow control can be achieved by configuring the
786
+ # underlying RPC channel.
724
787
  #
725
788
  # @param reqs [Enumerable<Google::Pubsub::V1::StreamingPullRequest>]
726
789
  # The input requests.
@@ -738,10 +801,12 @@ module Google
738
801
  # This method interface might change in the future.
739
802
  #
740
803
  # @example
741
- # require "google/cloud/pubsub/v1"
804
+ # require "google/cloud/pubsub"
742
805
  #
743
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
806
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
744
807
  # formatted_subscription = Google::Cloud::Pubsub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
808
+ #
809
+ # # TODO: Initialize +stream_ack_deadline_seconds+:
745
810
  # stream_ack_deadline_seconds = 0
746
811
  # request = { subscription: formatted_subscription, stream_ack_deadline_seconds: stream_ack_deadline_seconds }
747
812
  # requests = [request]
@@ -772,35 +837,44 @@ module Google
772
837
  # An empty +pushConfig+ indicates that the Pub/Sub system should
773
838
  # stop pushing messages from the given subscription and allow
774
839
  # messages to be pulled and acknowledged - effectively pausing
775
- # the subscription if +Pull+ is not called.
840
+ # the subscription if +Pull+ or +StreamingPull+ is not called.
776
841
  # A hash of the same form as `Google::Pubsub::V1::PushConfig`
777
842
  # can also be provided.
778
843
  # @param options [Google::Gax::CallOptions]
779
844
  # Overrides the default settings for this call, e.g, timeout,
780
845
  # retries, etc.
846
+ # @yield [result, operation] Access the result along with the RPC operation
847
+ # @yieldparam result []
848
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
781
849
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
782
850
  # @example
783
- # require "google/cloud/pubsub/v1"
851
+ # require "google/cloud/pubsub"
784
852
  #
785
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
853
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
786
854
  # formatted_subscription = Google::Cloud::Pubsub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
855
+ #
856
+ # # TODO: Initialize +push_config+:
787
857
  # push_config = {}
788
858
  # subscriber_client.modify_push_config(formatted_subscription, push_config)
789
859
 
790
860
  def modify_push_config \
791
861
  subscription,
792
862
  push_config,
793
- options: nil
863
+ options: nil,
864
+ &block
794
865
  req = {
795
866
  subscription: subscription,
796
867
  push_config: push_config
797
868
  }.delete_if { |_, v| v.nil? }
798
869
  req = Google::Gax::to_proto(req, Google::Pubsub::V1::ModifyPushConfigRequest)
799
- @modify_push_config.call(req, options)
870
+ @modify_push_config.call(req, options, &block)
800
871
  nil
801
872
  end
802
873
 
803
- # Lists the existing snapshots.
874
+ # Lists the existing snapshots.<br><br>
875
+ # <b>ALPHA:</b> This feature is part of an alpha release. This API might be
876
+ # changed in backward-incompatible ways and is not recommended for production
877
+ # use. It is not subject to any SLA or deprecation policy.
804
878
  #
805
879
  # @param project [String]
806
880
  # The name of the cloud project that snapshots belong to.
@@ -814,6 +888,9 @@ module Google
814
888
  # @param options [Google::Gax::CallOptions]
815
889
  # Overrides the default settings for this call, e.g, timeout,
816
890
  # retries, etc.
891
+ # @yield [result, operation] Access the result along with the RPC operation
892
+ # @yieldparam result [Google::Gax::PagedEnumerable<Google::Pubsub::V1::Snapshot>]
893
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
817
894
  # @return [Google::Gax::PagedEnumerable<Google::Pubsub::V1::Snapshot>]
818
895
  # An enumerable of Google::Pubsub::V1::Snapshot instances.
819
896
  # See Google::Gax::PagedEnumerable documentation for other
@@ -821,9 +898,9 @@ module Google
821
898
  # object.
822
899
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
823
900
  # @example
824
- # require "google/cloud/pubsub/v1"
901
+ # require "google/cloud/pubsub"
825
902
  #
826
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
903
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
827
904
  # formatted_project = Google::Cloud::Pubsub::V1::SubscriberClient.project_path("[PROJECT]")
828
905
  #
829
906
  # # Iterate over all results.
@@ -842,25 +919,31 @@ module Google
842
919
  def list_snapshots \
843
920
  project,
844
921
  page_size: nil,
845
- options: nil
922
+ options: nil,
923
+ &block
846
924
  req = {
847
925
  project: project,
848
926
  page_size: page_size
849
927
  }.delete_if { |_, v| v.nil? }
850
928
  req = Google::Gax::to_proto(req, Google::Pubsub::V1::ListSnapshotsRequest)
851
- @list_snapshots.call(req, options)
929
+ @list_snapshots.call(req, options, &block)
852
930
  end
853
931
 
854
- # Creates a snapshot from the requested subscription.
932
+ # Creates a snapshot from the requested subscription.<br><br>
933
+ # <b>ALPHA:</b> This feature is part of an alpha release. This API might be
934
+ # changed in backward-incompatible ways and is not recommended for production
935
+ # use. It is not subject to any SLA or deprecation policy.
855
936
  # If the snapshot already exists, returns +ALREADY_EXISTS+.
856
937
  # If the requested subscription doesn't exist, returns +NOT_FOUND+.
857
- #
858
- # If the name is not provided in the request, the server will assign a random
938
+ # If the backlog in the subscription is too old -- and the resulting snapshot
939
+ # would expire in less than 1 hour -- then +FAILED_PRECONDITION+ is returned.
940
+ # See also the +Snapshot.expire_time+ field. If the name is not provided in
941
+ # the request, the server will assign a random
859
942
  # name for this snapshot on the same project as the subscription, conforming
860
- # to the
861
- # [resource name format](https://cloud.google.com/pubsub/docs/overview#names).
862
- # The generated name is populated in the returned Snapshot object.
863
- # Note that for REST API requests, you must specify a name in the request.
943
+ # to the [resource name format](https://cloud.google.com/pubsub/docs/overview#names).
944
+ # The generated
945
+ # name is populated in the returned Snapshot object. Note that for REST API
946
+ # requests, you must specify a name in the request.
864
947
  #
865
948
  # @param name [String]
866
949
  # Optional user-provided name for this snapshot.
@@ -878,15 +961,20 @@ module Google
878
961
  # (b) Any messages published to the subscription's topic following the
879
962
  # successful completion of the CreateSnapshot request.
880
963
  # Format is +projects/{project}/subscriptions/{sub}+.
964
+ # @param labels [Hash{String => String}]
965
+ # User labels.
881
966
  # @param options [Google::Gax::CallOptions]
882
967
  # Overrides the default settings for this call, e.g, timeout,
883
968
  # retries, etc.
969
+ # @yield [result, operation] Access the result along with the RPC operation
970
+ # @yieldparam result [Google::Pubsub::V1::Snapshot]
971
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
884
972
  # @return [Google::Pubsub::V1::Snapshot]
885
973
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
886
974
  # @example
887
- # require "google/cloud/pubsub/v1"
975
+ # require "google/cloud/pubsub"
888
976
  #
889
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
977
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
890
978
  # formatted_name = Google::Cloud::Pubsub::V1::SubscriberClient.snapshot_path("[PROJECT]", "[SNAPSHOT]")
891
979
  # formatted_subscription = Google::Cloud::Pubsub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
892
980
  # response = subscriber_client.create_snapshot(formatted_name, formatted_subscription)
@@ -894,24 +982,26 @@ module Google
894
982
  def create_snapshot \
895
983
  name,
896
984
  subscription,
897
- options: nil
985
+ labels: nil,
986
+ options: nil,
987
+ &block
898
988
  req = {
899
989
  name: name,
900
- subscription: subscription
990
+ subscription: subscription,
991
+ labels: labels
901
992
  }.delete_if { |_, v| v.nil? }
902
993
  req = Google::Gax::to_proto(req, Google::Pubsub::V1::CreateSnapshotRequest)
903
- @create_snapshot.call(req, options)
994
+ @create_snapshot.call(req, options, &block)
904
995
  end
905
996
 
906
- # Updates an existing snapshot. Note that certain properties of a snapshot
907
- # are not modifiable.
908
- # NOTE: The style guide requires body: "snapshot" instead of body: "*".
909
- # Keeping the latter for internal consistency in V1, however it should be
910
- # corrected in V2. See
911
- # https://cloud.google.com/apis/design/standard_methods#update for details.
997
+ # Updates an existing snapshot.<br><br>
998
+ # <b>ALPHA:</b> This feature is part of an alpha release. This API might be
999
+ # changed in backward-incompatible ways and is not recommended for production
1000
+ # use. It is not subject to any SLA or deprecation policy.
1001
+ # Note that certain properties of a snapshot are not modifiable.
912
1002
  #
913
1003
  # @param snapshot [Google::Pubsub::V1::Snapshot | Hash]
914
- # The updated snpashot object.
1004
+ # The updated snapshot object.
915
1005
  # A hash of the same form as `Google::Pubsub::V1::Snapshot`
916
1006
  # can also be provided.
917
1007
  # @param update_mask [Google::Protobuf::FieldMask | Hash]
@@ -922,29 +1012,41 @@ module Google
922
1012
  # @param options [Google::Gax::CallOptions]
923
1013
  # Overrides the default settings for this call, e.g, timeout,
924
1014
  # retries, etc.
1015
+ # @yield [result, operation] Access the result along with the RPC operation
1016
+ # @yieldparam result [Google::Pubsub::V1::Snapshot]
1017
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
925
1018
  # @return [Google::Pubsub::V1::Snapshot]
926
1019
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
927
1020
  # @example
928
- # require "google/cloud/pubsub/v1"
1021
+ # require "google/cloud/pubsub"
929
1022
  #
930
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
931
- # snapshot = {}
932
- # update_mask = {}
1023
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
1024
+ # seconds = 123456
1025
+ # expire_time = { seconds: seconds }
1026
+ # snapshot = { expire_time: expire_time }
1027
+ # paths_element = "expire_time"
1028
+ # paths = [paths_element]
1029
+ # update_mask = { paths: paths }
933
1030
  # response = subscriber_client.update_snapshot(snapshot, update_mask)
934
1031
 
935
1032
  def update_snapshot \
936
1033
  snapshot,
937
1034
  update_mask,
938
- options: nil
1035
+ options: nil,
1036
+ &block
939
1037
  req = {
940
1038
  snapshot: snapshot,
941
1039
  update_mask: update_mask
942
1040
  }.delete_if { |_, v| v.nil? }
943
1041
  req = Google::Gax::to_proto(req, Google::Pubsub::V1::UpdateSnapshotRequest)
944
- @update_snapshot.call(req, options)
1042
+ @update_snapshot.call(req, options, &block)
945
1043
  end
946
1044
 
947
- # Removes an existing snapshot. All messages retained in the snapshot
1045
+ # Removes an existing snapshot. <br><br>
1046
+ # <b>ALPHA:</b> This feature is part of an alpha release. This API might be
1047
+ # changed in backward-incompatible ways and is not recommended for production
1048
+ # use. It is not subject to any SLA or deprecation policy.
1049
+ # When the snapshot is deleted, all messages retained in the snapshot
948
1050
  # are immediately dropped. After a snapshot is deleted, a new one may be
949
1051
  # created with the same name, but the new one has no association with the old
950
1052
  # snapshot or its subscription, unless the same subscription is specified.
@@ -955,27 +1057,34 @@ module Google
955
1057
  # @param options [Google::Gax::CallOptions]
956
1058
  # Overrides the default settings for this call, e.g, timeout,
957
1059
  # retries, etc.
1060
+ # @yield [result, operation] Access the result along with the RPC operation
1061
+ # @yieldparam result []
1062
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
958
1063
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
959
1064
  # @example
960
- # require "google/cloud/pubsub/v1"
1065
+ # require "google/cloud/pubsub"
961
1066
  #
962
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
1067
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
963
1068
  # formatted_snapshot = Google::Cloud::Pubsub::V1::SubscriberClient.snapshot_path("[PROJECT]", "[SNAPSHOT]")
964
1069
  # subscriber_client.delete_snapshot(formatted_snapshot)
965
1070
 
966
1071
  def delete_snapshot \
967
1072
  snapshot,
968
- options: nil
1073
+ options: nil,
1074
+ &block
969
1075
  req = {
970
1076
  snapshot: snapshot
971
1077
  }.delete_if { |_, v| v.nil? }
972
1078
  req = Google::Gax::to_proto(req, Google::Pubsub::V1::DeleteSnapshotRequest)
973
- @delete_snapshot.call(req, options)
1079
+ @delete_snapshot.call(req, options, &block)
974
1080
  nil
975
1081
  end
976
1082
 
977
1083
  # Seeks an existing subscription to a point in time or to a given snapshot,
978
- # whichever is provided in the request.
1084
+ # whichever is provided in the request.<br><br>
1085
+ # <b>ALPHA:</b> This feature is part of an alpha release. This API might be
1086
+ # changed in backward-incompatible ways and is not recommended for production
1087
+ # use. It is not subject to any SLA or deprecation policy.
979
1088
  #
980
1089
  # @param subscription [String]
981
1090
  # The subscription to affect.
@@ -1000,12 +1109,15 @@ module Google
1000
1109
  # @param options [Google::Gax::CallOptions]
1001
1110
  # Overrides the default settings for this call, e.g, timeout,
1002
1111
  # retries, etc.
1112
+ # @yield [result, operation] Access the result along with the RPC operation
1113
+ # @yieldparam result [Google::Pubsub::V1::SeekResponse]
1114
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
1003
1115
  # @return [Google::Pubsub::V1::SeekResponse]
1004
1116
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
1005
1117
  # @example
1006
- # require "google/cloud/pubsub/v1"
1118
+ # require "google/cloud/pubsub"
1007
1119
  #
1008
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
1120
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
1009
1121
  # formatted_subscription = Google::Cloud::Pubsub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
1010
1122
  # response = subscriber_client.seek(formatted_subscription)
1011
1123
 
@@ -1013,14 +1125,15 @@ module Google
1013
1125
  subscription,
1014
1126
  time: nil,
1015
1127
  snapshot: nil,
1016
- options: nil
1128
+ options: nil,
1129
+ &block
1017
1130
  req = {
1018
1131
  subscription: subscription,
1019
1132
  time: time,
1020
1133
  snapshot: snapshot
1021
1134
  }.delete_if { |_, v| v.nil? }
1022
1135
  req = Google::Gax::to_proto(req, Google::Pubsub::V1::SeekRequest)
1023
- @seek.call(req, options)
1136
+ @seek.call(req, options, &block)
1024
1137
  end
1025
1138
 
1026
1139
  # Sets the access control policy on the specified resource. Replaces any
@@ -1040,26 +1153,32 @@ module Google
1040
1153
  # @param options [Google::Gax::CallOptions]
1041
1154
  # Overrides the default settings for this call, e.g, timeout,
1042
1155
  # retries, etc.
1156
+ # @yield [result, operation] Access the result along with the RPC operation
1157
+ # @yieldparam result [Google::Iam::V1::Policy]
1158
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
1043
1159
  # @return [Google::Iam::V1::Policy]
1044
1160
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
1045
1161
  # @example
1046
- # require "google/cloud/pubsub/v1"
1162
+ # require "google/cloud/pubsub"
1047
1163
  #
1048
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
1164
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
1049
1165
  # formatted_resource = Google::Cloud::Pubsub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
1166
+ #
1167
+ # # TODO: Initialize +policy+:
1050
1168
  # policy = {}
1051
1169
  # response = subscriber_client.set_iam_policy(formatted_resource, policy)
1052
1170
 
1053
1171
  def set_iam_policy \
1054
1172
  resource,
1055
1173
  policy,
1056
- options: nil
1174
+ options: nil,
1175
+ &block
1057
1176
  req = {
1058
1177
  resource: resource,
1059
1178
  policy: policy
1060
1179
  }.delete_if { |_, v| v.nil? }
1061
1180
  req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
1062
- @set_iam_policy.call(req, options)
1181
+ @set_iam_policy.call(req, options, &block)
1063
1182
  end
1064
1183
 
1065
1184
  # Gets the access control policy for a resource.
@@ -1073,23 +1192,27 @@ module Google
1073
1192
  # @param options [Google::Gax::CallOptions]
1074
1193
  # Overrides the default settings for this call, e.g, timeout,
1075
1194
  # retries, etc.
1195
+ # @yield [result, operation] Access the result along with the RPC operation
1196
+ # @yieldparam result [Google::Iam::V1::Policy]
1197
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
1076
1198
  # @return [Google::Iam::V1::Policy]
1077
1199
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
1078
1200
  # @example
1079
- # require "google/cloud/pubsub/v1"
1201
+ # require "google/cloud/pubsub"
1080
1202
  #
1081
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
1203
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
1082
1204
  # formatted_resource = Google::Cloud::Pubsub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
1083
1205
  # response = subscriber_client.get_iam_policy(formatted_resource)
1084
1206
 
1085
1207
  def get_iam_policy \
1086
1208
  resource,
1087
- options: nil
1209
+ options: nil,
1210
+ &block
1088
1211
  req = {
1089
1212
  resource: resource
1090
1213
  }.delete_if { |_, v| v.nil? }
1091
1214
  req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
1092
- @get_iam_policy.call(req, options)
1215
+ @get_iam_policy.call(req, options, &block)
1093
1216
  end
1094
1217
 
1095
1218
  # Returns permissions that a caller has on the specified resource.
@@ -1108,26 +1231,32 @@ module Google
1108
1231
  # @param options [Google::Gax::CallOptions]
1109
1232
  # Overrides the default settings for this call, e.g, timeout,
1110
1233
  # retries, etc.
1234
+ # @yield [result, operation] Access the result along with the RPC operation
1235
+ # @yieldparam result [Google::Iam::V1::TestIamPermissionsResponse]
1236
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
1111
1237
  # @return [Google::Iam::V1::TestIamPermissionsResponse]
1112
1238
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
1113
1239
  # @example
1114
- # require "google/cloud/pubsub/v1"
1240
+ # require "google/cloud/pubsub"
1115
1241
  #
1116
- # subscriber_client = Google::Cloud::Pubsub::V1::Subscriber.new
1242
+ # subscriber_client = Google::Cloud::Pubsub::Subscriber.new(version: :v1)
1117
1243
  # formatted_resource = Google::Cloud::Pubsub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
1244
+ #
1245
+ # # TODO: Initialize +permissions+:
1118
1246
  # permissions = []
1119
1247
  # response = subscriber_client.test_iam_permissions(formatted_resource, permissions)
1120
1248
 
1121
1249
  def test_iam_permissions \
1122
1250
  resource,
1123
1251
  permissions,
1124
- options: nil
1252
+ options: nil,
1253
+ &block
1125
1254
  req = {
1126
1255
  resource: resource,
1127
1256
  permissions: permissions
1128
1257
  }.delete_if { |_, v| v.nil? }
1129
1258
  req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
1130
- @test_iam_permissions.call(req, options)
1259
+ @test_iam_permissions.call(req, options, &block)
1131
1260
  end
1132
1261
  end
1133
1262
  end