google-cloud-pubsub 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,7 +40,7 @@ module Google
40
40
  # @return [Google::Iam::V1::IAMPolicy::Stub]
41
41
  # @!attribute [r] publisher_stub
42
42
  # @return [Google::Pubsub::V1::Publisher::Stub]
43
- class PublisherApi
43
+ class PublisherClient
44
44
  attr_reader :iam_policy_stub, :publisher_stub
45
45
 
46
46
  # The default address of the service.
@@ -173,6 +173,7 @@ module Google
173
173
  require "google/iam/v1/iam_policy_services_pb"
174
174
  require "google/pubsub/v1/pubsub_services_pb"
175
175
 
176
+
176
177
  google_api_client = "#{app_name}/#{app_version} " \
177
178
  "#{CODE_GEN_NAME_VERSION} gax/#{Google::Gax::VERSION} " \
178
179
  "ruby/#{RUBY_VERSION}".freeze
@@ -265,20 +266,20 @@ module Google
265
266
  # @return [Google::Pubsub::V1::Topic]
266
267
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
267
268
  # @example
268
- # require "google/cloud/pubsub/v1/publisher_api"
269
+ # require "google/cloud/pubsub/v1/publisher_client"
269
270
  #
270
- # PublisherApi = Google::Cloud::Pubsub::V1::PublisherApi
271
+ # PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
271
272
  #
272
- # publisher_api = PublisherApi.new
273
- # formatted_name = PublisherApi.topic_path("[PROJECT]", "[TOPIC]")
274
- # response = publisher_api.create_topic(formatted_name)
273
+ # publisher_client = PublisherClient.new
274
+ # formatted_name = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
275
+ # response = publisher_client.create_topic(formatted_name)
275
276
 
276
277
  def create_topic \
277
278
  name,
278
279
  options: nil
279
- req = Google::Pubsub::V1::Topic.new(
280
+ req = Google::Pubsub::V1::Topic.new({
280
281
  name: name
281
- )
282
+ }.delete_if { |_, v| v.nil? })
282
283
  @create_topic.call(req, options)
283
284
  end
284
285
 
@@ -288,6 +289,7 @@ module Google
288
289
  #
289
290
  # @param topic [String]
290
291
  # The messages in the request will be published on this topic.
292
+ # Format is +projects/{project}/topics/{topic}+.
291
293
  # @param messages [Array<Google::Pubsub::V1::PubsubMessage>]
292
294
  # The messages to publish.
293
295
  # @param options [Google::Gax::CallOptions]
@@ -296,27 +298,27 @@ module Google
296
298
  # @return [Google::Pubsub::V1::PublishResponse]
297
299
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
298
300
  # @example
299
- # require "google/cloud/pubsub/v1/publisher_api"
301
+ # require "google/cloud/pubsub/v1/publisher_client"
300
302
  #
301
- # PublisherApi = Google::Cloud::Pubsub::V1::PublisherApi
303
+ # PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
302
304
  # PubsubMessage = Google::Pubsub::V1::PubsubMessage
303
305
  #
304
- # publisher_api = PublisherApi.new
305
- # formatted_topic = PublisherApi.topic_path("[PROJECT]", "[TOPIC]")
306
+ # publisher_client = PublisherClient.new
307
+ # formatted_topic = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
306
308
  # data = ''
307
309
  # messages_element = PubsubMessage.new
308
310
  # messages_element.data = data
309
311
  # messages = [messages_element]
310
- # response = publisher_api.publish(formatted_topic, messages)
312
+ # response = publisher_client.publish(formatted_topic, messages)
311
313
 
312
314
  def publish \
313
315
  topic,
314
316
  messages,
315
317
  options: nil
316
- req = Google::Pubsub::V1::PublishRequest.new(
318
+ req = Google::Pubsub::V1::PublishRequest.new({
317
319
  topic: topic,
318
320
  messages: messages
319
- )
321
+ }.delete_if { |_, v| v.nil? })
320
322
  @publish.call(req, options)
321
323
  end
322
324
 
@@ -324,26 +326,27 @@ module Google
324
326
  #
325
327
  # @param topic [String]
326
328
  # The name of the topic to get.
329
+ # Format is +projects/{project}/topics/{topic}+.
327
330
  # @param options [Google::Gax::CallOptions]
328
331
  # Overrides the default settings for this call, e.g, timeout,
329
332
  # retries, etc.
330
333
  # @return [Google::Pubsub::V1::Topic]
331
334
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
332
335
  # @example
333
- # require "google/cloud/pubsub/v1/publisher_api"
336
+ # require "google/cloud/pubsub/v1/publisher_client"
334
337
  #
335
- # PublisherApi = Google::Cloud::Pubsub::V1::PublisherApi
338
+ # PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
336
339
  #
337
- # publisher_api = PublisherApi.new
338
- # formatted_topic = PublisherApi.topic_path("[PROJECT]", "[TOPIC]")
339
- # response = publisher_api.get_topic(formatted_topic)
340
+ # publisher_client = PublisherClient.new
341
+ # formatted_topic = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
342
+ # response = publisher_client.get_topic(formatted_topic)
340
343
 
341
344
  def get_topic \
342
345
  topic,
343
346
  options: nil
344
- req = Google::Pubsub::V1::GetTopicRequest.new(
347
+ req = Google::Pubsub::V1::GetTopicRequest.new({
345
348
  topic: topic
346
- )
349
+ }.delete_if { |_, v| v.nil? })
347
350
  @get_topic.call(req, options)
348
351
  end
349
352
 
@@ -351,6 +354,7 @@ module Google
351
354
  #
352
355
  # @param project [String]
353
356
  # The name of the cloud project that topics belong to.
357
+ # Format is +projects/{project}+.
354
358
  # @param page_size [Integer]
355
359
  # The maximum number of resources contained in the underlying API
356
360
  # response. If page streaming is performed per-resource, this
@@ -367,20 +371,20 @@ module Google
367
371
  # object.
368
372
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
369
373
  # @example
370
- # require "google/cloud/pubsub/v1/publisher_api"
374
+ # require "google/cloud/pubsub/v1/publisher_client"
371
375
  #
372
- # PublisherApi = Google::Cloud::Pubsub::V1::PublisherApi
376
+ # PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
373
377
  #
374
- # publisher_api = PublisherApi.new
375
- # formatted_project = PublisherApi.project_path("[PROJECT]")
378
+ # publisher_client = PublisherClient.new
379
+ # formatted_project = PublisherClient.project_path("[PROJECT]")
376
380
  #
377
381
  # # Iterate over all results.
378
- # publisher_api.list_topics(formatted_project).each do |element|
382
+ # publisher_client.list_topics(formatted_project).each do |element|
379
383
  # # Process element.
380
384
  # end
381
385
  #
382
386
  # # Or iterate over results one page at a time.
383
- # publisher_api.list_topics(formatted_project).each_page do |page|
387
+ # publisher_client.list_topics(formatted_project).each_page do |page|
384
388
  # # Process each page at a time.
385
389
  # page.each do |element|
386
390
  # # Process element.
@@ -391,10 +395,10 @@ module Google
391
395
  project,
392
396
  page_size: nil,
393
397
  options: nil
394
- req = Google::Pubsub::V1::ListTopicsRequest.new(
395
- project: project
396
- )
397
- req.page_size = page_size unless page_size.nil?
398
+ req = Google::Pubsub::V1::ListTopicsRequest.new({
399
+ project: project,
400
+ page_size: page_size
401
+ }.delete_if { |_, v| v.nil? })
398
402
  @list_topics.call(req, options)
399
403
  end
400
404
 
@@ -402,6 +406,7 @@ module Google
402
406
  #
403
407
  # @param topic [String]
404
408
  # The name of the topic that subscriptions are attached to.
409
+ # Format is +projects/{project}/topics/{topic}+.
405
410
  # @param page_size [Integer]
406
411
  # The maximum number of resources contained in the underlying API
407
412
  # response. If page streaming is performed per-resource, this
@@ -418,20 +423,20 @@ module Google
418
423
  # object.
419
424
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
420
425
  # @example
421
- # require "google/cloud/pubsub/v1/publisher_api"
426
+ # require "google/cloud/pubsub/v1/publisher_client"
422
427
  #
423
- # PublisherApi = Google::Cloud::Pubsub::V1::PublisherApi
428
+ # PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
424
429
  #
425
- # publisher_api = PublisherApi.new
426
- # formatted_topic = PublisherApi.topic_path("[PROJECT]", "[TOPIC]")
430
+ # publisher_client = PublisherClient.new
431
+ # formatted_topic = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
427
432
  #
428
433
  # # Iterate over all results.
429
- # publisher_api.list_topic_subscriptions(formatted_topic).each do |element|
434
+ # publisher_client.list_topic_subscriptions(formatted_topic).each do |element|
430
435
  # # Process element.
431
436
  # end
432
437
  #
433
438
  # # Or iterate over results one page at a time.
434
- # publisher_api.list_topic_subscriptions(formatted_topic).each_page do |page|
439
+ # publisher_client.list_topic_subscriptions(formatted_topic).each_page do |page|
435
440
  # # Process each page at a time.
436
441
  # page.each do |element|
437
442
  # # Process element.
@@ -442,10 +447,10 @@ module Google
442
447
  topic,
443
448
  page_size: nil,
444
449
  options: nil
445
- req = Google::Pubsub::V1::ListTopicSubscriptionsRequest.new(
446
- topic: topic
447
- )
448
- req.page_size = page_size unless page_size.nil?
450
+ req = Google::Pubsub::V1::ListTopicSubscriptionsRequest.new({
451
+ topic: topic,
452
+ page_size: page_size
453
+ }.delete_if { |_, v| v.nil? })
449
454
  @list_topic_subscriptions.call(req, options)
450
455
  end
451
456
 
@@ -457,26 +462,28 @@ module Google
457
462
  #
458
463
  # @param topic [String]
459
464
  # Name of the topic to delete.
465
+ # Format is +projects/{project}/topics/{topic}+.
460
466
  # @param options [Google::Gax::CallOptions]
461
467
  # Overrides the default settings for this call, e.g, timeout,
462
468
  # retries, etc.
463
469
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
464
470
  # @example
465
- # require "google/cloud/pubsub/v1/publisher_api"
471
+ # require "google/cloud/pubsub/v1/publisher_client"
466
472
  #
467
- # PublisherApi = Google::Cloud::Pubsub::V1::PublisherApi
473
+ # PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
468
474
  #
469
- # publisher_api = PublisherApi.new
470
- # formatted_topic = PublisherApi.topic_path("[PROJECT]", "[TOPIC]")
471
- # publisher_api.delete_topic(formatted_topic)
475
+ # publisher_client = PublisherClient.new
476
+ # formatted_topic = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
477
+ # publisher_client.delete_topic(formatted_topic)
472
478
 
473
479
  def delete_topic \
474
480
  topic,
475
481
  options: nil
476
- req = Google::Pubsub::V1::DeleteTopicRequest.new(
482
+ req = Google::Pubsub::V1::DeleteTopicRequest.new({
477
483
  topic: topic
478
- )
484
+ }.delete_if { |_, v| v.nil? })
479
485
  @delete_topic.call(req, options)
486
+ nil
480
487
  end
481
488
 
482
489
  # Sets the access control policy on the specified resource. Replaces any
@@ -497,24 +504,24 @@ module Google
497
504
  # @return [Google::Iam::V1::Policy]
498
505
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
499
506
  # @example
500
- # require "google/cloud/pubsub/v1/publisher_api"
507
+ # require "google/cloud/pubsub/v1/publisher_client"
501
508
  #
502
509
  # Policy = Google::Iam::V1::Policy
503
- # PublisherApi = Google::Cloud::Pubsub::V1::PublisherApi
510
+ # PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
504
511
  #
505
- # publisher_api = PublisherApi.new
506
- # formatted_resource = PublisherApi.topic_path("[PROJECT]", "[TOPIC]")
512
+ # publisher_client = PublisherClient.new
513
+ # formatted_resource = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
507
514
  # policy = Policy.new
508
- # response = publisher_api.set_iam_policy(formatted_resource, policy)
515
+ # response = publisher_client.set_iam_policy(formatted_resource, policy)
509
516
 
510
517
  def set_iam_policy \
511
518
  resource,
512
519
  policy,
513
520
  options: nil
514
- req = Google::Iam::V1::SetIamPolicyRequest.new(
521
+ req = Google::Iam::V1::SetIamPolicyRequest.new({
515
522
  resource: resource,
516
523
  policy: policy
517
- )
524
+ }.delete_if { |_, v| v.nil? })
518
525
  @set_iam_policy.call(req, options)
519
526
  end
520
527
 
@@ -532,24 +539,26 @@ module Google
532
539
  # @return [Google::Iam::V1::Policy]
533
540
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
534
541
  # @example
535
- # require "google/cloud/pubsub/v1/publisher_api"
542
+ # require "google/cloud/pubsub/v1/publisher_client"
536
543
  #
537
- # PublisherApi = Google::Cloud::Pubsub::V1::PublisherApi
544
+ # PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
538
545
  #
539
- # publisher_api = PublisherApi.new
540
- # formatted_resource = PublisherApi.topic_path("[PROJECT]", "[TOPIC]")
541
- # response = publisher_api.get_iam_policy(formatted_resource)
546
+ # publisher_client = PublisherClient.new
547
+ # formatted_resource = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
548
+ # response = publisher_client.get_iam_policy(formatted_resource)
542
549
 
543
550
  def get_iam_policy \
544
551
  resource,
545
552
  options: nil
546
- req = Google::Iam::V1::GetIamPolicyRequest.new(
553
+ req = Google::Iam::V1::GetIamPolicyRequest.new({
547
554
  resource: resource
548
- )
555
+ }.delete_if { |_, v| v.nil? })
549
556
  @get_iam_policy.call(req, options)
550
557
  end
551
558
 
552
559
  # Returns permissions that a caller has on the specified resource.
560
+ # If the resource does not exist, this will return an empty set of
561
+ # permissions, not a NOT_FOUND error.
553
562
  #
554
563
  # @param resource [String]
555
564
  # REQUIRED: The resource for which the policy detail is being requested.
@@ -566,23 +575,23 @@ module Google
566
575
  # @return [Google::Iam::V1::TestIamPermissionsResponse]
567
576
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
568
577
  # @example
569
- # require "google/cloud/pubsub/v1/publisher_api"
578
+ # require "google/cloud/pubsub/v1/publisher_client"
570
579
  #
571
- # PublisherApi = Google::Cloud::Pubsub::V1::PublisherApi
580
+ # PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
572
581
  #
573
- # publisher_api = PublisherApi.new
574
- # formatted_resource = PublisherApi.topic_path("[PROJECT]", "[TOPIC]")
582
+ # publisher_client = PublisherClient.new
583
+ # formatted_resource = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
575
584
  # permissions = []
576
- # response = publisher_api.test_iam_permissions(formatted_resource, permissions)
585
+ # response = publisher_client.test_iam_permissions(formatted_resource, permissions)
577
586
 
578
587
  def test_iam_permissions \
579
588
  resource,
580
589
  permissions,
581
590
  options: nil
582
- req = Google::Iam::V1::TestIamPermissionsRequest.new(
591
+ req = Google::Iam::V1::TestIamPermissionsRequest.new({
583
592
  resource: resource,
584
593
  permissions: permissions
585
- )
594
+ }.delete_if { |_, v| v.nil? })
586
595
  @test_iam_permissions.call(req, options)
587
596
  end
588
597
  end
@@ -40,7 +40,7 @@ module Google
40
40
  # @return [Google::Iam::V1::IAMPolicy::Stub]
41
41
  # @!attribute [r] subscriber_stub
42
42
  # @return [Google::Pubsub::V1::Subscriber::Stub]
43
- class SubscriberApi
43
+ class SubscriberClient
44
44
  attr_reader :iam_policy_stub, :subscriber_stub
45
45
 
46
46
  # The default address of the service.
@@ -189,6 +189,7 @@ module Google
189
189
  require "google/iam/v1/iam_policy_services_pb"
190
190
  require "google/pubsub/v1/pubsub_services_pb"
191
191
 
192
+
192
193
  google_api_client = "#{app_name}/#{app_version} " \
193
194
  "#{CODE_GEN_NAME_VERSION} gax/#{Google::Gax::VERSION} " \
194
195
  "ruby/#{RUBY_VERSION}".freeze
@@ -265,6 +266,10 @@ module Google
265
266
  @subscriber_stub.method(:pull),
266
267
  defaults["pull"]
267
268
  )
269
+ @streaming_pull = Google::Gax.create_api_call(
270
+ @subscriber_stub.method(:streaming_pull),
271
+ defaults["streaming_pull"]
272
+ )
268
273
  @modify_push_config = Google::Gax.create_api_call(
269
274
  @subscriber_stub.method(:modify_push_config),
270
275
  defaults["modify_push_config"]
@@ -278,8 +283,11 @@ module Google
278
283
  # If the corresponding topic doesn't exist, returns +NOT_FOUND+.
279
284
  #
280
285
  # If the name is not provided in the request, the server will assign a random
281
- # name for this subscription on the same project as the topic. Note that
282
- # for REST API requests, you must specify a name.
286
+ # name for this subscription on the same project as the topic, conforming
287
+ # to the
288
+ # {resource name format}[https://cloud.google.com/pubsub/docs/overview#names].
289
+ # The generated name is populated in the returned Subscription object.
290
+ # Note that for REST API requests, you must specify a name in the request.
283
291
  #
284
292
  # @param name [String]
285
293
  # The name of the subscription. It must have the format
@@ -290,6 +298,7 @@ module Google
290
298
  # in length, and it must not start with +"goog"+.
291
299
  # @param topic [String]
292
300
  # The name of the topic from which this subscription is receiving messages.
301
+ # Format is +projects/{project}/topics/{topic}+.
293
302
  # The value of this field will be +_deleted-topic_+ if the topic has been
294
303
  # deleted.
295
304
  # @param push_config [Google::Pubsub::V1::PushConfig]
@@ -307,29 +316,29 @@ module Google
307
316
  # deadline. To override this value for a given message, call
308
317
  # +ModifyAckDeadline+ with the corresponding +ack_id+ if using
309
318
  # pull.
319
+ # The minimum custom deadline you can specify is 10 seconds.
310
320
  # The maximum custom deadline you can specify is 600 seconds (10 minutes).
321
+ # If this parameter is 0, a default value of 10 seconds is used.
311
322
  #
312
323
  # For push delivery, this value is also used to set the request timeout for
313
324
  # the call to the push endpoint.
314
325
  #
315
326
  # If the subscriber never acknowledges the message, the Pub/Sub
316
327
  # system will eventually redeliver the message.
317
- #
318
- # If this parameter is 0, a default value of 10 seconds is used.
319
328
  # @param options [Google::Gax::CallOptions]
320
329
  # Overrides the default settings for this call, e.g, timeout,
321
330
  # retries, etc.
322
331
  # @return [Google::Pubsub::V1::Subscription]
323
332
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
324
333
  # @example
325
- # require "google/cloud/pubsub/v1/subscriber_api"
334
+ # require "google/cloud/pubsub/v1/subscriber_client"
326
335
  #
327
- # SubscriberApi = Google::Cloud::Pubsub::V1::SubscriberApi
336
+ # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
328
337
  #
329
- # subscriber_api = SubscriberApi.new
330
- # formatted_name = SubscriberApi.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
331
- # formatted_topic = SubscriberApi.topic_path("[PROJECT]", "[TOPIC]")
332
- # response = subscriber_api.create_subscription(formatted_name, formatted_topic)
338
+ # subscriber_client = SubscriberClient.new
339
+ # formatted_name = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
340
+ # formatted_topic = SubscriberClient.topic_path("[PROJECT]", "[TOPIC]")
341
+ # response = subscriber_client.create_subscription(formatted_name, formatted_topic)
333
342
 
334
343
  def create_subscription \
335
344
  name,
@@ -337,12 +346,12 @@ module Google
337
346
  push_config: nil,
338
347
  ack_deadline_seconds: nil,
339
348
  options: nil
340
- req = Google::Pubsub::V1::Subscription.new(
349
+ req = Google::Pubsub::V1::Subscription.new({
341
350
  name: name,
342
- topic: topic
343
- )
344
- req.push_config = push_config unless push_config.nil?
345
- req.ack_deadline_seconds = ack_deadline_seconds unless ack_deadline_seconds.nil?
351
+ topic: topic,
352
+ push_config: push_config,
353
+ ack_deadline_seconds: ack_deadline_seconds
354
+ }.delete_if { |_, v| v.nil? })
346
355
  @create_subscription.call(req, options)
347
356
  end
348
357
 
@@ -350,26 +359,27 @@ module Google
350
359
  #
351
360
  # @param subscription [String]
352
361
  # The name of the subscription to get.
362
+ # Format is +projects/{project}/subscriptions/{sub}+.
353
363
  # @param options [Google::Gax::CallOptions]
354
364
  # Overrides the default settings for this call, e.g, timeout,
355
365
  # retries, etc.
356
366
  # @return [Google::Pubsub::V1::Subscription]
357
367
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
358
368
  # @example
359
- # require "google/cloud/pubsub/v1/subscriber_api"
369
+ # require "google/cloud/pubsub/v1/subscriber_client"
360
370
  #
361
- # SubscriberApi = Google::Cloud::Pubsub::V1::SubscriberApi
371
+ # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
362
372
  #
363
- # subscriber_api = SubscriberApi.new
364
- # formatted_subscription = SubscriberApi.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
365
- # response = subscriber_api.get_subscription(formatted_subscription)
373
+ # subscriber_client = SubscriberClient.new
374
+ # formatted_subscription = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
375
+ # response = subscriber_client.get_subscription(formatted_subscription)
366
376
 
367
377
  def get_subscription \
368
378
  subscription,
369
379
  options: nil
370
- req = Google::Pubsub::V1::GetSubscriptionRequest.new(
380
+ req = Google::Pubsub::V1::GetSubscriptionRequest.new({
371
381
  subscription: subscription
372
- )
382
+ }.delete_if { |_, v| v.nil? })
373
383
  @get_subscription.call(req, options)
374
384
  end
375
385
 
@@ -377,6 +387,7 @@ module Google
377
387
  #
378
388
  # @param project [String]
379
389
  # The name of the cloud project that subscriptions belong to.
390
+ # Format is +projects/{project}+.
380
391
  # @param page_size [Integer]
381
392
  # The maximum number of resources contained in the underlying API
382
393
  # response. If page streaming is performed per-resource, this
@@ -393,20 +404,20 @@ module Google
393
404
  # object.
394
405
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
395
406
  # @example
396
- # require "google/cloud/pubsub/v1/subscriber_api"
407
+ # require "google/cloud/pubsub/v1/subscriber_client"
397
408
  #
398
- # SubscriberApi = Google::Cloud::Pubsub::V1::SubscriberApi
409
+ # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
399
410
  #
400
- # subscriber_api = SubscriberApi.new
401
- # formatted_project = SubscriberApi.project_path("[PROJECT]")
411
+ # subscriber_client = SubscriberClient.new
412
+ # formatted_project = SubscriberClient.project_path("[PROJECT]")
402
413
  #
403
414
  # # Iterate over all results.
404
- # subscriber_api.list_subscriptions(formatted_project).each do |element|
415
+ # subscriber_client.list_subscriptions(formatted_project).each do |element|
405
416
  # # Process element.
406
417
  # end
407
418
  #
408
419
  # # Or iterate over results one page at a time.
409
- # subscriber_api.list_subscriptions(formatted_project).each_page do |page|
420
+ # subscriber_client.list_subscriptions(formatted_project).each_page do |page|
410
421
  # # Process each page at a time.
411
422
  # page.each do |element|
412
423
  # # Process element.
@@ -417,41 +428,43 @@ module Google
417
428
  project,
418
429
  page_size: nil,
419
430
  options: nil
420
- req = Google::Pubsub::V1::ListSubscriptionsRequest.new(
421
- project: project
422
- )
423
- req.page_size = page_size unless page_size.nil?
431
+ req = Google::Pubsub::V1::ListSubscriptionsRequest.new({
432
+ project: project,
433
+ page_size: page_size
434
+ }.delete_if { |_, v| v.nil? })
424
435
  @list_subscriptions.call(req, options)
425
436
  end
426
437
 
427
- # Deletes an existing subscription. All pending messages in the subscription
438
+ # Deletes an existing subscription. All messages retained in the subscription
428
439
  # are immediately dropped. Calls to +Pull+ after deletion will return
429
440
  # +NOT_FOUND+. After a subscription is deleted, a new one may be created with
430
441
  # the same name, but the new one has no association with the old
431
- # subscription, or its topic unless the same topic is specified.
442
+ # subscription or its topic unless the same topic is specified.
432
443
  #
433
444
  # @param subscription [String]
434
445
  # The subscription to delete.
446
+ # Format is +projects/{project}/subscriptions/{sub}+.
435
447
  # @param options [Google::Gax::CallOptions]
436
448
  # Overrides the default settings for this call, e.g, timeout,
437
449
  # retries, etc.
438
450
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
439
451
  # @example
440
- # require "google/cloud/pubsub/v1/subscriber_api"
452
+ # require "google/cloud/pubsub/v1/subscriber_client"
441
453
  #
442
- # SubscriberApi = Google::Cloud::Pubsub::V1::SubscriberApi
454
+ # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
443
455
  #
444
- # subscriber_api = SubscriberApi.new
445
- # formatted_subscription = SubscriberApi.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
446
- # subscriber_api.delete_subscription(formatted_subscription)
456
+ # subscriber_client = SubscriberClient.new
457
+ # formatted_subscription = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
458
+ # subscriber_client.delete_subscription(formatted_subscription)
447
459
 
448
460
  def delete_subscription \
449
461
  subscription,
450
462
  options: nil
451
- req = Google::Pubsub::V1::DeleteSubscriptionRequest.new(
463
+ req = Google::Pubsub::V1::DeleteSubscriptionRequest.new({
452
464
  subscription: subscription
453
- )
465
+ }.delete_if { |_, v| v.nil? })
454
466
  @delete_subscription.call(req, options)
467
+ nil
455
468
  end
456
469
 
457
470
  # Modifies the ack deadline for a specific message. This method is useful
@@ -462,40 +475,44 @@ module Google
462
475
  #
463
476
  # @param subscription [String]
464
477
  # The name of the subscription.
478
+ # Format is +projects/{project}/subscriptions/{sub}+.
465
479
  # @param ack_ids [Array<String>]
466
480
  # List of acknowledgment IDs.
467
481
  # @param ack_deadline_seconds [Integer]
468
482
  # The new ack deadline with respect to the time this request was sent to
469
- # the Pub/Sub system. Must be >= 0. For example, if the value is 10, the new
483
+ # the Pub/Sub system. For example, if the value is 10, the new
470
484
  # ack deadline will expire 10 seconds after the +ModifyAckDeadline+ call
471
485
  # was made. Specifying zero may immediately make the message available for
472
486
  # another pull request.
487
+ # The minimum deadline you can specify is 0 seconds.
488
+ # The maximum deadline you can specify is 600 seconds (10 minutes).
473
489
  # @param options [Google::Gax::CallOptions]
474
490
  # Overrides the default settings for this call, e.g, timeout,
475
491
  # retries, etc.
476
492
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
477
493
  # @example
478
- # require "google/cloud/pubsub/v1/subscriber_api"
494
+ # require "google/cloud/pubsub/v1/subscriber_client"
479
495
  #
480
- # SubscriberApi = Google::Cloud::Pubsub::V1::SubscriberApi
496
+ # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
481
497
  #
482
- # subscriber_api = SubscriberApi.new
483
- # formatted_subscription = SubscriberApi.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
498
+ # subscriber_client = SubscriberClient.new
499
+ # formatted_subscription = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
484
500
  # ack_ids = []
485
501
  # ack_deadline_seconds = 0
486
- # subscriber_api.modify_ack_deadline(formatted_subscription, ack_ids, ack_deadline_seconds)
502
+ # subscriber_client.modify_ack_deadline(formatted_subscription, ack_ids, ack_deadline_seconds)
487
503
 
488
504
  def modify_ack_deadline \
489
505
  subscription,
490
506
  ack_ids,
491
507
  ack_deadline_seconds,
492
508
  options: nil
493
- req = Google::Pubsub::V1::ModifyAckDeadlineRequest.new(
509
+ req = Google::Pubsub::V1::ModifyAckDeadlineRequest.new({
494
510
  subscription: subscription,
495
511
  ack_ids: ack_ids,
496
512
  ack_deadline_seconds: ack_deadline_seconds
497
- )
513
+ }.delete_if { |_, v| v.nil? })
498
514
  @modify_ack_deadline.call(req, options)
515
+ nil
499
516
  end
500
517
 
501
518
  # Acknowledges the messages associated with the +ack_ids+ in the
@@ -508,6 +525,7 @@ module Google
508
525
  #
509
526
  # @param subscription [String]
510
527
  # The subscription whose message is being acknowledged.
528
+ # Format is +projects/{project}/subscriptions/{sub}+.
511
529
  # @param ack_ids [Array<String>]
512
530
  # The acknowledgment ID for the messages being acknowledged that was returned
513
531
  # by the Pub/Sub system in the +Pull+ response. Must not be empty.
@@ -516,24 +534,25 @@ module Google
516
534
  # retries, etc.
517
535
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
518
536
  # @example
519
- # require "google/cloud/pubsub/v1/subscriber_api"
537
+ # require "google/cloud/pubsub/v1/subscriber_client"
520
538
  #
521
- # SubscriberApi = Google::Cloud::Pubsub::V1::SubscriberApi
539
+ # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
522
540
  #
523
- # subscriber_api = SubscriberApi.new
524
- # formatted_subscription = SubscriberApi.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
541
+ # subscriber_client = SubscriberClient.new
542
+ # formatted_subscription = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
525
543
  # ack_ids = []
526
- # subscriber_api.acknowledge(formatted_subscription, ack_ids)
544
+ # subscriber_client.acknowledge(formatted_subscription, ack_ids)
527
545
 
528
546
  def acknowledge \
529
547
  subscription,
530
548
  ack_ids,
531
549
  options: nil
532
- req = Google::Pubsub::V1::AcknowledgeRequest.new(
550
+ req = Google::Pubsub::V1::AcknowledgeRequest.new({
533
551
  subscription: subscription,
534
552
  ack_ids: ack_ids
535
- )
553
+ }.delete_if { |_, v| v.nil? })
536
554
  @acknowledge.call(req, options)
555
+ nil
537
556
  end
538
557
 
539
558
  # Pulls messages from the server. Returns an empty list if there are no
@@ -543,12 +562,14 @@ module Google
543
562
  #
544
563
  # @param subscription [String]
545
564
  # The subscription from which messages should be pulled.
565
+ # Format is +projects/{project}/subscriptions/{sub}+.
546
566
  # @param return_immediately [true, false]
547
- # If this is specified as true the system will respond immediately even if
548
- # it is not able to return a message in the +Pull+ response. Otherwise the
549
- # system is allowed to wait until at least one message is available rather
550
- # than returning no messages. The client may cancel the request if it does
551
- # not wish to wait any longer for the response.
567
+ # If this field set to true, the system will respond immediately even if
568
+ # it there are no messages available to return in the +Pull+ response.
569
+ # Otherwise, the system may wait (for a bounded amount of time) until at
570
+ # least one message is available, rather than returning no messages. The
571
+ # client may cancel the request if it does not wish to wait any longer for
572
+ # the response.
552
573
  # @param max_messages [Integer]
553
574
  # The maximum number of messages returned for this request. The Pub/Sub
554
575
  # system may return fewer than the number specified.
@@ -558,28 +579,77 @@ module Google
558
579
  # @return [Google::Pubsub::V1::PullResponse]
559
580
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
560
581
  # @example
561
- # require "google/cloud/pubsub/v1/subscriber_api"
582
+ # require "google/cloud/pubsub/v1/subscriber_client"
562
583
  #
563
- # SubscriberApi = Google::Cloud::Pubsub::V1::SubscriberApi
584
+ # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
564
585
  #
565
- # subscriber_api = SubscriberApi.new
566
- # formatted_subscription = SubscriberApi.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
586
+ # subscriber_client = SubscriberClient.new
587
+ # formatted_subscription = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
567
588
  # max_messages = 0
568
- # response = subscriber_api.pull(formatted_subscription, max_messages)
589
+ # response = subscriber_client.pull(formatted_subscription, max_messages)
569
590
 
570
591
  def pull \
571
592
  subscription,
572
593
  max_messages,
573
594
  return_immediately: nil,
574
595
  options: nil
575
- req = Google::Pubsub::V1::PullRequest.new(
596
+ req = Google::Pubsub::V1::PullRequest.new({
576
597
  subscription: subscription,
577
- max_messages: max_messages
578
- )
579
- req.return_immediately = return_immediately unless return_immediately.nil?
598
+ max_messages: max_messages,
599
+ return_immediately: return_immediately
600
+ }.delete_if { |_, v| v.nil? })
580
601
  @pull.call(req, options)
581
602
  end
582
603
 
604
+ # (EXPERIMENTAL) StreamingPull is an experimental feature. This RPC will
605
+ # respond with UNIMPLEMENTED errors unless you have been invited to test
606
+ # this feature. Contact cloud-pubsub@google.com with any questions.
607
+ #
608
+ # Establishes a stream with the server, which sends messages down to the
609
+ # client. The client streams acknowledgements and ack deadline modifications
610
+ # back to the server. The server will close the stream and return the status
611
+ # on any error. The server may close the stream with status +OK+ to reassign
612
+ # server-side resources, in which case, the client should re-establish the
613
+ # stream. +UNAVAILABLE+ may also be returned in the case of a transient error
614
+ # (e.g., a server restart). These should also be retried by the client. Flow
615
+ # control can be achieved by configuring the underlying RPC channel.
616
+ #
617
+ # @param reqs [Enumerable<Google::Pubsub::V1::StreamingPullRequest>]
618
+ # The input requests.
619
+ # @param options [Google::Gax::CallOptions]
620
+ # Overrides the default settings for this call, e.g, timeout,
621
+ # retries, etc.
622
+ # @return [Enumerable<Google::Pubsub::V1::StreamingPullResponse>]
623
+ # An enumerable of Google::Pubsub::V1::StreamingPullResponse instances.
624
+ #
625
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
626
+ #
627
+ # @note
628
+ # EXPERIMENTAL:
629
+ # Streaming requests are still undergoing review.
630
+ # This method interface might change in the future.
631
+ #
632
+ # @example
633
+ # require "google/cloud/pubsub/v1/subscriber_client"
634
+ #
635
+ # StreamingPullRequest = Google::Pubsub::V1::StreamingPullRequest
636
+ # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
637
+ #
638
+ # subscriber_client = SubscriberClient.new
639
+ # formatted_subscription = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
640
+ # stream_ack_deadline_seconds = 0
641
+ # request = StreamingPullRequest.new
642
+ # request.subscription = formatted_subscription
643
+ # request.stream_ack_deadline_seconds = stream_ack_deadline_seconds
644
+ # requests = [request]
645
+ # subscriber_client.streaming_pull(requests).each do |element|
646
+ # # Process element.
647
+ # end
648
+
649
+ def streaming_pull reqs, options: nil
650
+ @streaming_pull.call(reqs, options)
651
+ end
652
+
583
653
  # Modifies the +PushConfig+ for a specified subscription.
584
654
  #
585
655
  # This may be used to change a push subscription to a pull one (signified by
@@ -589,6 +659,7 @@ module Google
589
659
  #
590
660
  # @param subscription [String]
591
661
  # The name of the subscription.
662
+ # Format is +projects/{project}/subscriptions/{sub}+.
592
663
  # @param push_config [Google::Pubsub::V1::PushConfig]
593
664
  # The push configuration for future deliveries.
594
665
  #
@@ -601,25 +672,26 @@ module Google
601
672
  # retries, etc.
602
673
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
603
674
  # @example
604
- # require "google/cloud/pubsub/v1/subscriber_api"
675
+ # require "google/cloud/pubsub/v1/subscriber_client"
605
676
  #
606
677
  # PushConfig = Google::Pubsub::V1::PushConfig
607
- # SubscriberApi = Google::Cloud::Pubsub::V1::SubscriberApi
678
+ # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
608
679
  #
609
- # subscriber_api = SubscriberApi.new
610
- # formatted_subscription = SubscriberApi.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
680
+ # subscriber_client = SubscriberClient.new
681
+ # formatted_subscription = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
611
682
  # push_config = PushConfig.new
612
- # subscriber_api.modify_push_config(formatted_subscription, push_config)
683
+ # subscriber_client.modify_push_config(formatted_subscription, push_config)
613
684
 
614
685
  def modify_push_config \
615
686
  subscription,
616
687
  push_config,
617
688
  options: nil
618
- req = Google::Pubsub::V1::ModifyPushConfigRequest.new(
689
+ req = Google::Pubsub::V1::ModifyPushConfigRequest.new({
619
690
  subscription: subscription,
620
691
  push_config: push_config
621
- )
692
+ }.delete_if { |_, v| v.nil? })
622
693
  @modify_push_config.call(req, options)
694
+ nil
623
695
  end
624
696
 
625
697
  # Sets the access control policy on the specified resource. Replaces any
@@ -640,24 +712,24 @@ module Google
640
712
  # @return [Google::Iam::V1::Policy]
641
713
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
642
714
  # @example
643
- # require "google/cloud/pubsub/v1/subscriber_api"
715
+ # require "google/cloud/pubsub/v1/subscriber_client"
644
716
  #
645
717
  # Policy = Google::Iam::V1::Policy
646
- # SubscriberApi = Google::Cloud::Pubsub::V1::SubscriberApi
718
+ # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
647
719
  #
648
- # subscriber_api = SubscriberApi.new
649
- # formatted_resource = SubscriberApi.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
720
+ # subscriber_client = SubscriberClient.new
721
+ # formatted_resource = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
650
722
  # policy = Policy.new
651
- # response = subscriber_api.set_iam_policy(formatted_resource, policy)
723
+ # response = subscriber_client.set_iam_policy(formatted_resource, policy)
652
724
 
653
725
  def set_iam_policy \
654
726
  resource,
655
727
  policy,
656
728
  options: nil
657
- req = Google::Iam::V1::SetIamPolicyRequest.new(
729
+ req = Google::Iam::V1::SetIamPolicyRequest.new({
658
730
  resource: resource,
659
731
  policy: policy
660
- )
732
+ }.delete_if { |_, v| v.nil? })
661
733
  @set_iam_policy.call(req, options)
662
734
  end
663
735
 
@@ -675,24 +747,26 @@ module Google
675
747
  # @return [Google::Iam::V1::Policy]
676
748
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
677
749
  # @example
678
- # require "google/cloud/pubsub/v1/subscriber_api"
750
+ # require "google/cloud/pubsub/v1/subscriber_client"
679
751
  #
680
- # SubscriberApi = Google::Cloud::Pubsub::V1::SubscriberApi
752
+ # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
681
753
  #
682
- # subscriber_api = SubscriberApi.new
683
- # formatted_resource = SubscriberApi.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
684
- # response = subscriber_api.get_iam_policy(formatted_resource)
754
+ # subscriber_client = SubscriberClient.new
755
+ # formatted_resource = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
756
+ # response = subscriber_client.get_iam_policy(formatted_resource)
685
757
 
686
758
  def get_iam_policy \
687
759
  resource,
688
760
  options: nil
689
- req = Google::Iam::V1::GetIamPolicyRequest.new(
761
+ req = Google::Iam::V1::GetIamPolicyRequest.new({
690
762
  resource: resource
691
- )
763
+ }.delete_if { |_, v| v.nil? })
692
764
  @get_iam_policy.call(req, options)
693
765
  end
694
766
 
695
767
  # Returns permissions that a caller has on the specified resource.
768
+ # If the resource does not exist, this will return an empty set of
769
+ # permissions, not a NOT_FOUND error.
696
770
  #
697
771
  # @param resource [String]
698
772
  # REQUIRED: The resource for which the policy detail is being requested.
@@ -709,23 +783,23 @@ module Google
709
783
  # @return [Google::Iam::V1::TestIamPermissionsResponse]
710
784
  # @raise [Google::Gax::GaxError] if the RPC is aborted.
711
785
  # @example
712
- # require "google/cloud/pubsub/v1/subscriber_api"
786
+ # require "google/cloud/pubsub/v1/subscriber_client"
713
787
  #
714
- # SubscriberApi = Google::Cloud::Pubsub::V1::SubscriberApi
788
+ # SubscriberClient = Google::Cloud::Pubsub::V1::SubscriberClient
715
789
  #
716
- # subscriber_api = SubscriberApi.new
717
- # formatted_resource = SubscriberApi.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
790
+ # subscriber_client = SubscriberClient.new
791
+ # formatted_resource = SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
718
792
  # permissions = []
719
- # response = subscriber_api.test_iam_permissions(formatted_resource, permissions)
793
+ # response = subscriber_client.test_iam_permissions(formatted_resource, permissions)
720
794
 
721
795
  def test_iam_permissions \
722
796
  resource,
723
797
  permissions,
724
798
  options: nil
725
- req = Google::Iam::V1::TestIamPermissionsRequest.new(
799
+ req = Google::Iam::V1::TestIamPermissionsRequest.new({
726
800
  resource: resource,
727
801
  permissions: permissions
728
- )
802
+ }.delete_if { |_, v| v.nil? })
729
803
  @test_iam_permissions.call(req, options)
730
804
  end
731
805
  end