google-cloud-pubsub-v1 0.5.2 → 0.7.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.
@@ -43,13 +43,12 @@ module Google
43
43
  # See {::Google::Cloud::PubSub::V1::Subscriber::Client::Configuration}
44
44
  # for a description of the configuration fields.
45
45
  #
46
- # ## Example
46
+ # @example
47
47
  #
48
- # To modify the configuration for all Subscriber clients:
49
- #
50
- # ::Google::Cloud::PubSub::V1::Subscriber::Client.configure do |config|
51
- # config.timeout = 10.0
52
- # end
48
+ # # Modify the configuration for all Subscriber clients
49
+ # ::Google::Cloud::PubSub::V1::Subscriber::Client.configure do |config|
50
+ # config.timeout = 10.0
51
+ # end
53
52
  #
54
53
  # @yield [config] Configure the Client client.
55
54
  # @yieldparam config [Client::Configuration]
@@ -176,19 +175,15 @@ module Google
176
175
  ##
177
176
  # Create a new Subscriber client object.
178
177
  #
179
- # ## Examples
180
- #
181
- # To create a new Subscriber client with the default
182
- # configuration:
183
- #
184
- # client = ::Google::Cloud::PubSub::V1::Subscriber::Client.new
178
+ # @example
185
179
  #
186
- # To create a new Subscriber client with a custom
187
- # configuration:
180
+ # # Create a client using the default configuration
181
+ # client = ::Google::Cloud::PubSub::V1::Subscriber::Client.new
188
182
  #
189
- # client = ::Google::Cloud::PubSub::V1::Subscriber::Client.new do |config|
190
- # config.timeout = 10.0
191
- # end
183
+ # # Create a client using a custom configuration
184
+ # client = ::Google::Cloud::PubSub::V1::Subscriber::Client.new do |config|
185
+ # config.timeout = 10.0
186
+ # end
192
187
  #
193
188
  # @yield [config] Configure the Subscriber client.
194
189
  # @yieldparam config [Client::Configuration]
@@ -208,10 +203,9 @@ module Google
208
203
 
209
204
  # Create credentials
210
205
  credentials = @config.credentials
211
- # Use self-signed JWT if the scope and endpoint are unchanged from default,
206
+ # Use self-signed JWT if the endpoint is unchanged from default,
212
207
  # but only if the default endpoint does not have a region prefix.
213
- enable_self_signed_jwt = @config.scope == Client.configure.scope &&
214
- @config.endpoint == Client.configure.endpoint &&
208
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
215
209
  !@config.endpoint.split(".").first.include?("-")
216
210
  credentials ||= Credentials.default scope: @config.scope,
217
211
  enable_self_signed_jwt: enable_self_signed_jwt
@@ -255,7 +249,7 @@ module Google
255
249
  # @param options [::Gapic::CallOptions, ::Hash]
256
250
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
257
251
  #
258
- # @overload create_subscription(name: nil, topic: nil, push_config: nil, ack_deadline_seconds: nil, retain_acked_messages: nil, message_retention_duration: nil, labels: nil, enable_message_ordering: nil, expiration_policy: nil, filter: nil, dead_letter_policy: nil, retry_policy: nil, detached: nil)
252
+ # @overload create_subscription(name: nil, topic: nil, push_config: nil, ack_deadline_seconds: nil, retain_acked_messages: nil, message_retention_duration: nil, labels: nil, enable_message_ordering: nil, expiration_policy: nil, filter: nil, dead_letter_policy: nil, retry_policy: nil, detached: nil, enable_exactly_once_delivery: nil)
259
253
  # Pass arguments to `create_subscription` via keyword arguments. Note that at
260
254
  # least one keyword argument is required. To specify no parameters, or to keep all
261
255
  # the default parameter values, pass an empty Hash as a request object (see above).
@@ -300,8 +294,9 @@ module Google
300
294
  # Indicates whether to retain acknowledged messages. If true, then
301
295
  # messages are not expunged from the subscription's backlog, even if they are
302
296
  # acknowledged, until they fall out of the `message_retention_duration`
303
- # window. This must be true if you would like to [Seek to a timestamp]
304
- # (https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time).
297
+ # window. This must be true if you would like to [`Seek` to a timestamp]
298
+ # (https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time) in
299
+ # the past to replay previously-acknowledged messages.
305
300
  # @param message_retention_duration [::Google::Protobuf::Duration, ::Hash]
306
301
  # How long to retain unacknowledged messages in the subscription's backlog,
307
302
  # from the moment a message is published.
@@ -353,6 +348,18 @@ module Google
353
348
  # backlog. `Pull` and `StreamingPull` requests will return
354
349
  # FAILED_PRECONDITION. If the subscription is a push subscription, pushes to
355
350
  # the endpoint will not be made.
351
+ # @param enable_exactly_once_delivery [::Boolean]
352
+ # If true, Pub/Sub provides the following guarantees for the delivery of
353
+ # a message with a given value of `message_id` on this subscription:
354
+ #
355
+ # * The message sent to a subscriber is guaranteed not to be resent
356
+ # before the message's acknowledgement deadline expires.
357
+ # * An acknowledged message will not be resent to a subscriber.
358
+ #
359
+ # Note that subscribers may still receive multiple copies of a message
360
+ # when `enable_exactly_once_delivery` is true if the message was published
361
+ # multiple times by a publisher client. These copies are considered distinct
362
+ # by Pub/Sub and have distinct `message_id` values.
356
363
  #
357
364
  # @yield [response, operation] Access the result along with the RPC operation
358
365
  # @yieldparam response [::Google::Cloud::PubSub::V1::Subscription]
@@ -362,6 +369,21 @@ module Google
362
369
  #
363
370
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
364
371
  #
372
+ # @example Basic example
373
+ # require "google/cloud/pubsub/v1"
374
+ #
375
+ # # Create a client object. The client can be reused for multiple calls.
376
+ # client = Google::Cloud::PubSub::V1::Subscriber::Client.new
377
+ #
378
+ # # Create a request. To set request fields, pass in keyword arguments.
379
+ # request = Google::Cloud::PubSub::V1::Subscription.new
380
+ #
381
+ # # Call the create_subscription method.
382
+ # result = client.create_subscription request
383
+ #
384
+ # # The returned object is of type Google::Cloud::PubSub::V1::Subscription.
385
+ # p result
386
+ #
365
387
  def create_subscription request, options = nil
366
388
  raise ::ArgumentError, "request must be provided" if request.nil?
367
389
 
@@ -379,16 +401,20 @@ module Google
379
401
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
380
402
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
381
403
 
382
- header_params = {
383
- "name" => request.name
384
- }
404
+ header_params = {}
405
+ if request.name
406
+ header_params["name"] = request.name
407
+ end
408
+
385
409
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
386
410
  metadata[:"x-goog-request-params"] ||= request_params_header
387
411
 
388
412
  options.apply_defaults timeout: @config.rpcs.create_subscription.timeout,
389
413
  metadata: metadata,
390
414
  retry_policy: @config.rpcs.create_subscription.retry_policy
391
- options.apply_defaults metadata: @config.metadata,
415
+
416
+ options.apply_defaults timeout: @config.timeout,
417
+ metadata: @config.metadata,
392
418
  retry_policy: @config.retry_policy
393
419
 
394
420
  @subscriber_stub.call_rpc :create_subscription, request, options: options do |response, operation|
@@ -429,6 +455,21 @@ module Google
429
455
  #
430
456
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
431
457
  #
458
+ # @example Basic example
459
+ # require "google/cloud/pubsub/v1"
460
+ #
461
+ # # Create a client object. The client can be reused for multiple calls.
462
+ # client = Google::Cloud::PubSub::V1::Subscriber::Client.new
463
+ #
464
+ # # Create a request. To set request fields, pass in keyword arguments.
465
+ # request = Google::Cloud::PubSub::V1::GetSubscriptionRequest.new
466
+ #
467
+ # # Call the get_subscription method.
468
+ # result = client.get_subscription request
469
+ #
470
+ # # The returned object is of type Google::Cloud::PubSub::V1::Subscription.
471
+ # p result
472
+ #
432
473
  def get_subscription request, options = nil
433
474
  raise ::ArgumentError, "request must be provided" if request.nil?
434
475
 
@@ -446,16 +487,20 @@ module Google
446
487
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
447
488
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
448
489
 
449
- header_params = {
450
- "subscription" => request.subscription
451
- }
490
+ header_params = {}
491
+ if request.subscription
492
+ header_params["subscription"] = request.subscription
493
+ end
494
+
452
495
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
453
496
  metadata[:"x-goog-request-params"] ||= request_params_header
454
497
 
455
498
  options.apply_defaults timeout: @config.rpcs.get_subscription.timeout,
456
499
  metadata: metadata,
457
500
  retry_policy: @config.rpcs.get_subscription.retry_policy
458
- options.apply_defaults metadata: @config.metadata,
501
+
502
+ options.apply_defaults timeout: @config.timeout,
503
+ metadata: @config.metadata,
459
504
  retry_policy: @config.retry_policy
460
505
 
461
506
  @subscriber_stub.call_rpc :get_subscription, request, options: options do |response, operation|
@@ -499,6 +544,21 @@ module Google
499
544
  #
500
545
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
501
546
  #
547
+ # @example Basic example
548
+ # require "google/cloud/pubsub/v1"
549
+ #
550
+ # # Create a client object. The client can be reused for multiple calls.
551
+ # client = Google::Cloud::PubSub::V1::Subscriber::Client.new
552
+ #
553
+ # # Create a request. To set request fields, pass in keyword arguments.
554
+ # request = Google::Cloud::PubSub::V1::UpdateSubscriptionRequest.new
555
+ #
556
+ # # Call the update_subscription method.
557
+ # result = client.update_subscription request
558
+ #
559
+ # # The returned object is of type Google::Cloud::PubSub::V1::Subscription.
560
+ # p result
561
+ #
502
562
  def update_subscription request, options = nil
503
563
  raise ::ArgumentError, "request must be provided" if request.nil?
504
564
 
@@ -516,16 +576,20 @@ module Google
516
576
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
517
577
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
518
578
 
519
- header_params = {
520
- "subscription.name" => request.subscription.name
521
- }
579
+ header_params = {}
580
+ if request.subscription&.name
581
+ header_params["subscription.name"] = request.subscription.name
582
+ end
583
+
522
584
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
523
585
  metadata[:"x-goog-request-params"] ||= request_params_header
524
586
 
525
587
  options.apply_defaults timeout: @config.rpcs.update_subscription.timeout,
526
588
  metadata: metadata,
527
589
  retry_policy: @config.rpcs.update_subscription.retry_policy
528
- options.apply_defaults metadata: @config.metadata,
590
+
591
+ options.apply_defaults timeout: @config.timeout,
592
+ metadata: @config.metadata,
529
593
  retry_policy: @config.retry_policy
530
594
 
531
595
  @subscriber_stub.call_rpc :update_subscription, request, options: options do |response, operation|
@@ -572,6 +636,27 @@ module Google
572
636
  #
573
637
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
574
638
  #
639
+ # @example Basic example
640
+ # require "google/cloud/pubsub/v1"
641
+ #
642
+ # # Create a client object. The client can be reused for multiple calls.
643
+ # client = Google::Cloud::PubSub::V1::Subscriber::Client.new
644
+ #
645
+ # # Create a request. To set request fields, pass in keyword arguments.
646
+ # request = Google::Cloud::PubSub::V1::ListSubscriptionsRequest.new
647
+ #
648
+ # # Call the list_subscriptions method.
649
+ # result = client.list_subscriptions request
650
+ #
651
+ # # The returned object is of type Gapic::PagedEnumerable. You can
652
+ # # iterate over all elements by calling #each, and the enumerable
653
+ # # will lazily make API calls to fetch subsequent pages. Other
654
+ # # methods are also available for managing paging directly.
655
+ # result.each do |response|
656
+ # # Each element is of type ::Google::Cloud::PubSub::V1::Subscription.
657
+ # p response
658
+ # end
659
+ #
575
660
  def list_subscriptions request, options = nil
576
661
  raise ::ArgumentError, "request must be provided" if request.nil?
577
662
 
@@ -589,16 +674,20 @@ module Google
589
674
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
590
675
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
591
676
 
592
- header_params = {
593
- "project" => request.project
594
- }
677
+ header_params = {}
678
+ if request.project
679
+ header_params["project"] = request.project
680
+ end
681
+
595
682
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
596
683
  metadata[:"x-goog-request-params"] ||= request_params_header
597
684
 
598
685
  options.apply_defaults timeout: @config.rpcs.list_subscriptions.timeout,
599
686
  metadata: metadata,
600
687
  retry_policy: @config.rpcs.list_subscriptions.retry_policy
601
- options.apply_defaults metadata: @config.metadata,
688
+
689
+ options.apply_defaults timeout: @config.timeout,
690
+ metadata: @config.metadata,
602
691
  retry_policy: @config.retry_policy
603
692
 
604
693
  @subscriber_stub.call_rpc :list_subscriptions, request, options: options do |response, operation|
@@ -644,6 +733,21 @@ module Google
644
733
  #
645
734
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
646
735
  #
736
+ # @example Basic example
737
+ # require "google/cloud/pubsub/v1"
738
+ #
739
+ # # Create a client object. The client can be reused for multiple calls.
740
+ # client = Google::Cloud::PubSub::V1::Subscriber::Client.new
741
+ #
742
+ # # Create a request. To set request fields, pass in keyword arguments.
743
+ # request = Google::Cloud::PubSub::V1::DeleteSubscriptionRequest.new
744
+ #
745
+ # # Call the delete_subscription method.
746
+ # result = client.delete_subscription request
747
+ #
748
+ # # The returned object is of type Google::Protobuf::Empty.
749
+ # p result
750
+ #
647
751
  def delete_subscription request, options = nil
648
752
  raise ::ArgumentError, "request must be provided" if request.nil?
649
753
 
@@ -661,16 +765,20 @@ module Google
661
765
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
662
766
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
663
767
 
664
- header_params = {
665
- "subscription" => request.subscription
666
- }
768
+ header_params = {}
769
+ if request.subscription
770
+ header_params["subscription"] = request.subscription
771
+ end
772
+
667
773
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
668
774
  metadata[:"x-goog-request-params"] ||= request_params_header
669
775
 
670
776
  options.apply_defaults timeout: @config.rpcs.delete_subscription.timeout,
671
777
  metadata: metadata,
672
778
  retry_policy: @config.rpcs.delete_subscription.retry_policy
673
- options.apply_defaults metadata: @config.metadata,
779
+
780
+ options.apply_defaults timeout: @config.timeout,
781
+ metadata: @config.metadata,
674
782
  retry_policy: @config.retry_policy
675
783
 
676
784
  @subscriber_stub.call_rpc :delete_subscription, request, options: options do |response, operation|
@@ -726,6 +834,21 @@ module Google
726
834
  #
727
835
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
728
836
  #
837
+ # @example Basic example
838
+ # require "google/cloud/pubsub/v1"
839
+ #
840
+ # # Create a client object. The client can be reused for multiple calls.
841
+ # client = Google::Cloud::PubSub::V1::Subscriber::Client.new
842
+ #
843
+ # # Create a request. To set request fields, pass in keyword arguments.
844
+ # request = Google::Cloud::PubSub::V1::ModifyAckDeadlineRequest.new
845
+ #
846
+ # # Call the modify_ack_deadline method.
847
+ # result = client.modify_ack_deadline request
848
+ #
849
+ # # The returned object is of type Google::Protobuf::Empty.
850
+ # p result
851
+ #
729
852
  def modify_ack_deadline request, options = nil
730
853
  raise ::ArgumentError, "request must be provided" if request.nil?
731
854
 
@@ -743,16 +866,20 @@ module Google
743
866
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
744
867
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
745
868
 
746
- header_params = {
747
- "subscription" => request.subscription
748
- }
869
+ header_params = {}
870
+ if request.subscription
871
+ header_params["subscription"] = request.subscription
872
+ end
873
+
749
874
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
750
875
  metadata[:"x-goog-request-params"] ||= request_params_header
751
876
 
752
877
  options.apply_defaults timeout: @config.rpcs.modify_ack_deadline.timeout,
753
878
  metadata: metadata,
754
879
  retry_policy: @config.rpcs.modify_ack_deadline.retry_policy
755
- options.apply_defaults metadata: @config.metadata,
880
+
881
+ options.apply_defaults timeout: @config.timeout,
882
+ metadata: @config.metadata,
756
883
  retry_policy: @config.retry_policy
757
884
 
758
885
  @subscriber_stub.call_rpc :modify_ack_deadline, request, options: options do |response, operation|
@@ -803,6 +930,21 @@ module Google
803
930
  #
804
931
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
805
932
  #
933
+ # @example Basic example
934
+ # require "google/cloud/pubsub/v1"
935
+ #
936
+ # # Create a client object. The client can be reused for multiple calls.
937
+ # client = Google::Cloud::PubSub::V1::Subscriber::Client.new
938
+ #
939
+ # # Create a request. To set request fields, pass in keyword arguments.
940
+ # request = Google::Cloud::PubSub::V1::AcknowledgeRequest.new
941
+ #
942
+ # # Call the acknowledge method.
943
+ # result = client.acknowledge request
944
+ #
945
+ # # The returned object is of type Google::Protobuf::Empty.
946
+ # p result
947
+ #
806
948
  def acknowledge request, options = nil
807
949
  raise ::ArgumentError, "request must be provided" if request.nil?
808
950
 
@@ -820,16 +962,20 @@ module Google
820
962
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
821
963
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
822
964
 
823
- header_params = {
824
- "subscription" => request.subscription
825
- }
965
+ header_params = {}
966
+ if request.subscription
967
+ header_params["subscription"] = request.subscription
968
+ end
969
+
826
970
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
827
971
  metadata[:"x-goog-request-params"] ||= request_params_header
828
972
 
829
973
  options.apply_defaults timeout: @config.rpcs.acknowledge.timeout,
830
974
  metadata: metadata,
831
975
  retry_policy: @config.rpcs.acknowledge.retry_policy
832
- options.apply_defaults metadata: @config.metadata,
976
+
977
+ options.apply_defaults timeout: @config.timeout,
978
+ metadata: @config.metadata,
833
979
  retry_policy: @config.retry_policy
834
980
 
835
981
  @subscriber_stub.call_rpc :acknowledge, request, options: options do |response, operation|
@@ -884,6 +1030,21 @@ module Google
884
1030
  #
885
1031
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
886
1032
  #
1033
+ # @example Basic example
1034
+ # require "google/cloud/pubsub/v1"
1035
+ #
1036
+ # # Create a client object. The client can be reused for multiple calls.
1037
+ # client = Google::Cloud::PubSub::V1::Subscriber::Client.new
1038
+ #
1039
+ # # Create a request. To set request fields, pass in keyword arguments.
1040
+ # request = Google::Cloud::PubSub::V1::PullRequest.new
1041
+ #
1042
+ # # Call the pull method.
1043
+ # result = client.pull request
1044
+ #
1045
+ # # The returned object is of type Google::Cloud::PubSub::V1::PullResponse.
1046
+ # p result
1047
+ #
887
1048
  def pull request, options = nil
888
1049
  raise ::ArgumentError, "request must be provided" if request.nil?
889
1050
 
@@ -901,16 +1062,20 @@ module Google
901
1062
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
902
1063
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
903
1064
 
904
- header_params = {
905
- "subscription" => request.subscription
906
- }
1065
+ header_params = {}
1066
+ if request.subscription
1067
+ header_params["subscription"] = request.subscription
1068
+ end
1069
+
907
1070
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
908
1071
  metadata[:"x-goog-request-params"] ||= request_params_header
909
1072
 
910
1073
  options.apply_defaults timeout: @config.rpcs.pull.timeout,
911
1074
  metadata: metadata,
912
1075
  retry_policy: @config.rpcs.pull.retry_policy
913
- options.apply_defaults metadata: @config.metadata,
1076
+
1077
+ options.apply_defaults timeout: @config.timeout,
1078
+ metadata: @config.metadata,
914
1079
  retry_policy: @config.retry_policy
915
1080
 
916
1081
  @subscriber_stub.call_rpc :pull, request, options: options do |response, operation|
@@ -943,6 +1108,30 @@ module Google
943
1108
  #
944
1109
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
945
1110
  #
1111
+ # @example Basic example
1112
+ # require "google/cloud/pubsub/v1"
1113
+ #
1114
+ # # Create a client object. The client can be reused for multiple calls.
1115
+ # client = Google::Cloud::PubSub::V1::Subscriber::Client.new
1116
+ #
1117
+ # # Create an input stream
1118
+ # input = Gapic::StreamInput.new
1119
+ #
1120
+ # # Call the streaming_pull method to start streaming.
1121
+ # output = client.streaming_pull input
1122
+ #
1123
+ # # Send requests on the stream. For each request, pass in keyword
1124
+ # # arguments to set fields. Be sure to close the stream when done.
1125
+ # input << Google::Cloud::PubSub::V1::StreamingPullRequest.new
1126
+ # input << Google::Cloud::PubSub::V1::StreamingPullRequest.new
1127
+ # input.close
1128
+ #
1129
+ # # Handle streamed responses. These may be interleaved with inputs.
1130
+ # # Each response is of type ::Google::Cloud::PubSub::V1::StreamingPullResponse.
1131
+ # output.each do |response|
1132
+ # p response
1133
+ # end
1134
+ #
946
1135
  def streaming_pull request, options = nil
947
1136
  unless request.is_a? ::Enumerable
948
1137
  raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
@@ -968,7 +1157,9 @@ module Google
968
1157
  options.apply_defaults timeout: @config.rpcs.streaming_pull.timeout,
969
1158
  metadata: metadata,
970
1159
  retry_policy: @config.rpcs.streaming_pull.retry_policy
971
- options.apply_defaults metadata: @config.metadata,
1160
+
1161
+ options.apply_defaults timeout: @config.timeout,
1162
+ metadata: @config.metadata,
972
1163
  retry_policy: @config.retry_policy
973
1164
 
974
1165
  @subscriber_stub.call_rpc :streaming_pull, request, options: options do |response, operation|
@@ -1021,6 +1212,21 @@ module Google
1021
1212
  #
1022
1213
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1023
1214
  #
1215
+ # @example Basic example
1216
+ # require "google/cloud/pubsub/v1"
1217
+ #
1218
+ # # Create a client object. The client can be reused for multiple calls.
1219
+ # client = Google::Cloud::PubSub::V1::Subscriber::Client.new
1220
+ #
1221
+ # # Create a request. To set request fields, pass in keyword arguments.
1222
+ # request = Google::Cloud::PubSub::V1::ModifyPushConfigRequest.new
1223
+ #
1224
+ # # Call the modify_push_config method.
1225
+ # result = client.modify_push_config request
1226
+ #
1227
+ # # The returned object is of type Google::Protobuf::Empty.
1228
+ # p result
1229
+ #
1024
1230
  def modify_push_config request, options = nil
1025
1231
  raise ::ArgumentError, "request must be provided" if request.nil?
1026
1232
 
@@ -1038,16 +1244,20 @@ module Google
1038
1244
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
1039
1245
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1040
1246
 
1041
- header_params = {
1042
- "subscription" => request.subscription
1043
- }
1247
+ header_params = {}
1248
+ if request.subscription
1249
+ header_params["subscription"] = request.subscription
1250
+ end
1251
+
1044
1252
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1045
1253
  metadata[:"x-goog-request-params"] ||= request_params_header
1046
1254
 
1047
1255
  options.apply_defaults timeout: @config.rpcs.modify_push_config.timeout,
1048
1256
  metadata: metadata,
1049
1257
  retry_policy: @config.rpcs.modify_push_config.retry_policy
1050
- options.apply_defaults metadata: @config.metadata,
1258
+
1259
+ options.apply_defaults timeout: @config.timeout,
1260
+ metadata: @config.metadata,
1051
1261
  retry_policy: @config.retry_policy
1052
1262
 
1053
1263
  @subscriber_stub.call_rpc :modify_push_config, request, options: options do |response, operation|
@@ -1092,6 +1302,21 @@ module Google
1092
1302
  #
1093
1303
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1094
1304
  #
1305
+ # @example Basic example
1306
+ # require "google/cloud/pubsub/v1"
1307
+ #
1308
+ # # Create a client object. The client can be reused for multiple calls.
1309
+ # client = Google::Cloud::PubSub::V1::Subscriber::Client.new
1310
+ #
1311
+ # # Create a request. To set request fields, pass in keyword arguments.
1312
+ # request = Google::Cloud::PubSub::V1::GetSnapshotRequest.new
1313
+ #
1314
+ # # Call the get_snapshot method.
1315
+ # result = client.get_snapshot request
1316
+ #
1317
+ # # The returned object is of type Google::Cloud::PubSub::V1::Snapshot.
1318
+ # p result
1319
+ #
1095
1320
  def get_snapshot request, options = nil
1096
1321
  raise ::ArgumentError, "request must be provided" if request.nil?
1097
1322
 
@@ -1109,16 +1334,20 @@ module Google
1109
1334
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
1110
1335
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1111
1336
 
1112
- header_params = {
1113
- "snapshot" => request.snapshot
1114
- }
1337
+ header_params = {}
1338
+ if request.snapshot
1339
+ header_params["snapshot"] = request.snapshot
1340
+ end
1341
+
1115
1342
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1116
1343
  metadata[:"x-goog-request-params"] ||= request_params_header
1117
1344
 
1118
1345
  options.apply_defaults timeout: @config.rpcs.get_snapshot.timeout,
1119
1346
  metadata: metadata,
1120
1347
  retry_policy: @config.rpcs.get_snapshot.retry_policy
1121
- options.apply_defaults metadata: @config.metadata,
1348
+
1349
+ options.apply_defaults timeout: @config.timeout,
1350
+ metadata: @config.metadata,
1122
1351
  retry_policy: @config.retry_policy
1123
1352
 
1124
1353
  @subscriber_stub.call_rpc :get_snapshot, request, options: options do |response, operation|
@@ -1169,6 +1398,27 @@ module Google
1169
1398
  #
1170
1399
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1171
1400
  #
1401
+ # @example Basic example
1402
+ # require "google/cloud/pubsub/v1"
1403
+ #
1404
+ # # Create a client object. The client can be reused for multiple calls.
1405
+ # client = Google::Cloud::PubSub::V1::Subscriber::Client.new
1406
+ #
1407
+ # # Create a request. To set request fields, pass in keyword arguments.
1408
+ # request = Google::Cloud::PubSub::V1::ListSnapshotsRequest.new
1409
+ #
1410
+ # # Call the list_snapshots method.
1411
+ # result = client.list_snapshots request
1412
+ #
1413
+ # # The returned object is of type Gapic::PagedEnumerable. You can
1414
+ # # iterate over all elements by calling #each, and the enumerable
1415
+ # # will lazily make API calls to fetch subsequent pages. Other
1416
+ # # methods are also available for managing paging directly.
1417
+ # result.each do |response|
1418
+ # # Each element is of type ::Google::Cloud::PubSub::V1::Snapshot.
1419
+ # p response
1420
+ # end
1421
+ #
1172
1422
  def list_snapshots request, options = nil
1173
1423
  raise ::ArgumentError, "request must be provided" if request.nil?
1174
1424
 
@@ -1186,16 +1436,20 @@ module Google
1186
1436
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
1187
1437
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1188
1438
 
1189
- header_params = {
1190
- "project" => request.project
1191
- }
1439
+ header_params = {}
1440
+ if request.project
1441
+ header_params["project"] = request.project
1442
+ end
1443
+
1192
1444
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1193
1445
  metadata[:"x-goog-request-params"] ||= request_params_header
1194
1446
 
1195
1447
  options.apply_defaults timeout: @config.rpcs.list_snapshots.timeout,
1196
1448
  metadata: metadata,
1197
1449
  retry_policy: @config.rpcs.list_snapshots.retry_policy
1198
- options.apply_defaults metadata: @config.metadata,
1450
+
1451
+ options.apply_defaults timeout: @config.timeout,
1452
+ metadata: @config.metadata,
1199
1453
  retry_policy: @config.retry_policy
1200
1454
 
1201
1455
  @subscriber_stub.call_rpc :list_snapshots, request, options: options do |response, operation|
@@ -1269,6 +1523,21 @@ module Google
1269
1523
  #
1270
1524
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1271
1525
  #
1526
+ # @example Basic example
1527
+ # require "google/cloud/pubsub/v1"
1528
+ #
1529
+ # # Create a client object. The client can be reused for multiple calls.
1530
+ # client = Google::Cloud::PubSub::V1::Subscriber::Client.new
1531
+ #
1532
+ # # Create a request. To set request fields, pass in keyword arguments.
1533
+ # request = Google::Cloud::PubSub::V1::CreateSnapshotRequest.new
1534
+ #
1535
+ # # Call the create_snapshot method.
1536
+ # result = client.create_snapshot request
1537
+ #
1538
+ # # The returned object is of type Google::Cloud::PubSub::V1::Snapshot.
1539
+ # p result
1540
+ #
1272
1541
  def create_snapshot request, options = nil
1273
1542
  raise ::ArgumentError, "request must be provided" if request.nil?
1274
1543
 
@@ -1286,16 +1555,20 @@ module Google
1286
1555
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
1287
1556
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1288
1557
 
1289
- header_params = {
1290
- "name" => request.name
1291
- }
1558
+ header_params = {}
1559
+ if request.name
1560
+ header_params["name"] = request.name
1561
+ end
1562
+
1292
1563
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1293
1564
  metadata[:"x-goog-request-params"] ||= request_params_header
1294
1565
 
1295
1566
  options.apply_defaults timeout: @config.rpcs.create_snapshot.timeout,
1296
1567
  metadata: metadata,
1297
1568
  retry_policy: @config.rpcs.create_snapshot.retry_policy
1298
- options.apply_defaults metadata: @config.metadata,
1569
+
1570
+ options.apply_defaults timeout: @config.timeout,
1571
+ metadata: @config.metadata,
1299
1572
  retry_policy: @config.retry_policy
1300
1573
 
1301
1574
  @subscriber_stub.call_rpc :create_snapshot, request, options: options do |response, operation|
@@ -1343,6 +1616,21 @@ module Google
1343
1616
  #
1344
1617
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1345
1618
  #
1619
+ # @example Basic example
1620
+ # require "google/cloud/pubsub/v1"
1621
+ #
1622
+ # # Create a client object. The client can be reused for multiple calls.
1623
+ # client = Google::Cloud::PubSub::V1::Subscriber::Client.new
1624
+ #
1625
+ # # Create a request. To set request fields, pass in keyword arguments.
1626
+ # request = Google::Cloud::PubSub::V1::UpdateSnapshotRequest.new
1627
+ #
1628
+ # # Call the update_snapshot method.
1629
+ # result = client.update_snapshot request
1630
+ #
1631
+ # # The returned object is of type Google::Cloud::PubSub::V1::Snapshot.
1632
+ # p result
1633
+ #
1346
1634
  def update_snapshot request, options = nil
1347
1635
  raise ::ArgumentError, "request must be provided" if request.nil?
1348
1636
 
@@ -1360,16 +1648,20 @@ module Google
1360
1648
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
1361
1649
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1362
1650
 
1363
- header_params = {
1364
- "snapshot.name" => request.snapshot.name
1365
- }
1651
+ header_params = {}
1652
+ if request.snapshot&.name
1653
+ header_params["snapshot.name"] = request.snapshot.name
1654
+ end
1655
+
1366
1656
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1367
1657
  metadata[:"x-goog-request-params"] ||= request_params_header
1368
1658
 
1369
1659
  options.apply_defaults timeout: @config.rpcs.update_snapshot.timeout,
1370
1660
  metadata: metadata,
1371
1661
  retry_policy: @config.rpcs.update_snapshot.retry_policy
1372
- options.apply_defaults metadata: @config.metadata,
1662
+
1663
+ options.apply_defaults timeout: @config.timeout,
1664
+ metadata: @config.metadata,
1373
1665
  retry_policy: @config.retry_policy
1374
1666
 
1375
1667
  @subscriber_stub.call_rpc :update_snapshot, request, options: options do |response, operation|
@@ -1418,6 +1710,21 @@ module Google
1418
1710
  #
1419
1711
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1420
1712
  #
1713
+ # @example Basic example
1714
+ # require "google/cloud/pubsub/v1"
1715
+ #
1716
+ # # Create a client object. The client can be reused for multiple calls.
1717
+ # client = Google::Cloud::PubSub::V1::Subscriber::Client.new
1718
+ #
1719
+ # # Create a request. To set request fields, pass in keyword arguments.
1720
+ # request = Google::Cloud::PubSub::V1::DeleteSnapshotRequest.new
1721
+ #
1722
+ # # Call the delete_snapshot method.
1723
+ # result = client.delete_snapshot request
1724
+ #
1725
+ # # The returned object is of type Google::Protobuf::Empty.
1726
+ # p result
1727
+ #
1421
1728
  def delete_snapshot request, options = nil
1422
1729
  raise ::ArgumentError, "request must be provided" if request.nil?
1423
1730
 
@@ -1435,16 +1742,20 @@ module Google
1435
1742
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
1436
1743
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1437
1744
 
1438
- header_params = {
1439
- "snapshot" => request.snapshot
1440
- }
1745
+ header_params = {}
1746
+ if request.snapshot
1747
+ header_params["snapshot"] = request.snapshot
1748
+ end
1749
+
1441
1750
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1442
1751
  metadata[:"x-goog-request-params"] ||= request_params_header
1443
1752
 
1444
1753
  options.apply_defaults timeout: @config.rpcs.delete_snapshot.timeout,
1445
1754
  metadata: metadata,
1446
1755
  retry_policy: @config.rpcs.delete_snapshot.retry_policy
1447
- options.apply_defaults metadata: @config.metadata,
1756
+
1757
+ options.apply_defaults timeout: @config.timeout,
1758
+ metadata: @config.metadata,
1448
1759
  retry_policy: @config.retry_policy
1449
1760
 
1450
1761
  @subscriber_stub.call_rpc :delete_snapshot, request, options: options do |response, operation|
@@ -1506,6 +1817,21 @@ module Google
1506
1817
  #
1507
1818
  # @raise [::Google::Cloud::Error] if the RPC is aborted.
1508
1819
  #
1820
+ # @example Basic example
1821
+ # require "google/cloud/pubsub/v1"
1822
+ #
1823
+ # # Create a client object. The client can be reused for multiple calls.
1824
+ # client = Google::Cloud::PubSub::V1::Subscriber::Client.new
1825
+ #
1826
+ # # Create a request. To set request fields, pass in keyword arguments.
1827
+ # request = Google::Cloud::PubSub::V1::SeekRequest.new
1828
+ #
1829
+ # # Call the seek method.
1830
+ # result = client.seek request
1831
+ #
1832
+ # # The returned object is of type Google::Cloud::PubSub::V1::SeekResponse.
1833
+ # p result
1834
+ #
1509
1835
  def seek request, options = nil
1510
1836
  raise ::ArgumentError, "request must be provided" if request.nil?
1511
1837
 
@@ -1523,16 +1849,20 @@ module Google
1523
1849
  gapic_version: ::Google::Cloud::PubSub::V1::VERSION
1524
1850
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1525
1851
 
1526
- header_params = {
1527
- "subscription" => request.subscription
1528
- }
1852
+ header_params = {}
1853
+ if request.subscription
1854
+ header_params["subscription"] = request.subscription
1855
+ end
1856
+
1529
1857
  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1530
1858
  metadata[:"x-goog-request-params"] ||= request_params_header
1531
1859
 
1532
1860
  options.apply_defaults timeout: @config.rpcs.seek.timeout,
1533
1861
  metadata: metadata,
1534
1862
  retry_policy: @config.rpcs.seek.retry_policy
1535
- options.apply_defaults metadata: @config.metadata,
1863
+
1864
+ options.apply_defaults timeout: @config.timeout,
1865
+ metadata: @config.metadata,
1536
1866
  retry_policy: @config.retry_policy
1537
1867
 
1538
1868
  @subscriber_stub.call_rpc :seek, request, options: options do |response, operation|
@@ -1556,22 +1886,21 @@ module Google
1556
1886
  # Configuration can be applied globally to all clients, or to a single client
1557
1887
  # on construction.
1558
1888
  #
1559
- # # Examples
1560
- #
1561
- # To modify the global config, setting the timeout for create_subscription
1562
- # to 20 seconds, and all remaining timeouts to 10 seconds:
1563
- #
1564
- # ::Google::Cloud::PubSub::V1::Subscriber::Client.configure do |config|
1565
- # config.timeout = 10.0
1566
- # config.rpcs.create_subscription.timeout = 20.0
1567
- # end
1568
- #
1569
- # To apply the above configuration only to a new client:
1570
- #
1571
- # client = ::Google::Cloud::PubSub::V1::Subscriber::Client.new do |config|
1572
- # config.timeout = 10.0
1573
- # config.rpcs.create_subscription.timeout = 20.0
1574
- # end
1889
+ # @example
1890
+ #
1891
+ # # Modify the global config, setting the timeout for
1892
+ # # create_subscription to 20 seconds,
1893
+ # # and all remaining timeouts to 10 seconds.
1894
+ # ::Google::Cloud::PubSub::V1::Subscriber::Client.configure do |config|
1895
+ # config.timeout = 10.0
1896
+ # config.rpcs.create_subscription.timeout = 20.0
1897
+ # end
1898
+ #
1899
+ # # Apply the above configuration only to a new client.
1900
+ # client = ::Google::Cloud::PubSub::V1::Subscriber::Client.new do |config|
1901
+ # config.timeout = 10.0
1902
+ # config.rpcs.create_subscription.timeout = 20.0
1903
+ # end
1575
1904
  #
1576
1905
  # @!attribute [rw] endpoint
1577
1906
  # The hostname or hostname:port of the service endpoint.