google-cloud-pubsub-v1 0.1.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.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +169 -0
  4. data/LICENSE.md +203 -0
  5. data/README.md +75 -0
  6. data/lib/google-cloud-pubsub-v1.rb +21 -0
  7. data/lib/google/cloud/pubsub/v1.rb +37 -0
  8. data/lib/google/cloud/pubsub/v1/iam_policy.rb +72 -0
  9. data/lib/google/cloud/pubsub/v1/iam_policy/client.rb +562 -0
  10. data/lib/google/cloud/pubsub/v1/iam_policy/credentials.rb +52 -0
  11. data/lib/google/cloud/pubsub/v1/publisher.rb +50 -0
  12. data/lib/google/cloud/pubsub/v1/publisher/client.rb +1093 -0
  13. data/lib/google/cloud/pubsub/v1/publisher/credentials.rb +52 -0
  14. data/lib/google/cloud/pubsub/v1/publisher/helpers.rb +23 -0
  15. data/lib/google/cloud/pubsub/v1/publisher/paths.rb +98 -0
  16. data/lib/google/cloud/pubsub/v1/subscriber.rb +51 -0
  17. data/lib/google/cloud/pubsub/v1/subscriber/client.rb +1861 -0
  18. data/lib/google/cloud/pubsub/v1/subscriber/credentials.rb +52 -0
  19. data/lib/google/cloud/pubsub/v1/subscriber/helpers.rb +23 -0
  20. data/lib/google/cloud/pubsub/v1/subscriber/paths.rb +115 -0
  21. data/lib/google/cloud/pubsub/v1/version.rb +28 -0
  22. data/lib/google/iam/v1/iam_policy_services_pb.rb +81 -0
  23. data/lib/google/pubsub/v1/pubsub_pb.rb +269 -0
  24. data/lib/google/pubsub/v1/pubsub_services_pb.rb +213 -0
  25. data/proto_docs/README.md +4 -0
  26. data/proto_docs/google/api/field_behavior.rb +59 -0
  27. data/proto_docs/google/api/resource.rb +247 -0
  28. data/proto_docs/google/iam/v1/iam_policy.rb +80 -0
  29. data/proto_docs/google/iam/v1/options.rb +40 -0
  30. data/proto_docs/google/iam/v1/policy.rb +248 -0
  31. data/proto_docs/google/protobuf/duration.rb +98 -0
  32. data/proto_docs/google/protobuf/empty.rb +36 -0
  33. data/proto_docs/google/protobuf/field_mask.rb +229 -0
  34. data/proto_docs/google/protobuf/timestamp.rb +120 -0
  35. data/proto_docs/google/pubsub/v1/pubsub.rb +1023 -0
  36. data/proto_docs/google/type/expr.rb +52 -0
  37. metadata +238 -0
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "googleauth"
20
+
21
+ module Google
22
+ module Cloud
23
+ module PubSub
24
+ module V1
25
+ module Publisher
26
+ # Credentials for the Publisher API.
27
+ class Credentials < ::Google::Auth::Credentials
28
+ self.scope = [
29
+ "https://www.googleapis.com/auth/cloud-platform",
30
+ "https://www.googleapis.com/auth/pubsub"
31
+ ]
32
+ self.env_vars = [
33
+ "PUBSUB_CREDENTIALS",
34
+ "PUBSUB_KEYFILE",
35
+ "GOOGLE_CLOUD_CREDENTIALS",
36
+ "GOOGLE_CLOUD_KEYFILE",
37
+ "GCLOUD_KEYFILE",
38
+ "PUBSUB_CREDENTIALS_JSON",
39
+ "PUBSUB_KEYFILE_JSON",
40
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
41
+ "GOOGLE_CLOUD_KEYFILE_JSON",
42
+ "GCLOUD_KEYFILE_JSON"
43
+ ]
44
+ self.paths = [
45
+ "~/.config/google_cloud/application_default_credentials.json"
46
+ ]
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+
18
+ Google::Cloud::PubSub::V1::Publisher::Client.configure do |config|
19
+ config.channel_args ||= {}
20
+ config.channel_args["grpc.max_send_message_length"] = -1
21
+ config.channel_args["grpc.max_receive_message_length"] = -1
22
+ config.channel_args["grpc.keepalive_time_ms"] = 300_000
23
+ end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+
20
+ module Google
21
+ module Cloud
22
+ module PubSub
23
+ module V1
24
+ module Publisher
25
+ # Path helper methods for the Publisher API.
26
+ module Paths
27
+ ##
28
+ # Create a fully-qualified Project resource string.
29
+ #
30
+ # The resource will be in the following format:
31
+ #
32
+ # `projects/{project}`
33
+ #
34
+ # @param project [String]
35
+ #
36
+ # @return [::String]
37
+ def project_path project:
38
+ "projects/#{project}"
39
+ end
40
+
41
+ ##
42
+ # Create a fully-qualified Subscription resource string.
43
+ #
44
+ # The resource will be in the following format:
45
+ #
46
+ # `projects/{project}/subscriptions/{subscription}`
47
+ #
48
+ # @param project [String]
49
+ # @param subscription [String]
50
+ #
51
+ # @return [::String]
52
+ def subscription_path project:, subscription:
53
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
54
+
55
+ "projects/#{project}/subscriptions/#{subscription}"
56
+ end
57
+
58
+ ##
59
+ # Create a fully-qualified Topic resource string.
60
+ #
61
+ # @overload topic_path(project:, topic:)
62
+ # The resource will be in the following format:
63
+ #
64
+ # `projects/{project}/topics/{topic}`
65
+ #
66
+ # @param project [String]
67
+ # @param topic [String]
68
+ #
69
+ # @overload topic_path()
70
+ # The resource will be in the following format:
71
+ #
72
+ # `_deleted-topic_`
73
+ #
74
+ # @return [::String]
75
+ def topic_path **args
76
+ resources = {
77
+ "project:topic" => (proc do |project:, topic:|
78
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
79
+
80
+ "projects/#{project}/topics/#{topic}"
81
+ end),
82
+ "" => (proc do
83
+ "_deleted-topic_"
84
+ end)
85
+ }
86
+
87
+ resource = resources[args.keys.sort.join(":")]
88
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
89
+ resource.call(**args)
90
+ end
91
+
92
+ extend self
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/pubsub/v1/version"
24
+
25
+ require "google/cloud/pubsub/v1/subscriber/credentials"
26
+ require "google/cloud/pubsub/v1/subscriber/paths"
27
+ require "google/cloud/pubsub/v1/subscriber/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module PubSub
32
+ module V1
33
+ ##
34
+ # The service that an application uses to manipulate subscriptions and to
35
+ # consume messages from a subscription via the `Pull` method or by
36
+ # establishing a bi-directional stream using the `StreamingPull` method.
37
+ #
38
+ # To load this service and instantiate a client:
39
+ #
40
+ # require "google/cloud/pubsub/v1/subscriber"
41
+ # client = ::Google::Cloud::PubSub::V1::Subscriber::Client.new
42
+ #
43
+ module Subscriber
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ helper_path = ::File.join __dir__, "subscriber", "helpers.rb"
51
+ require "google/cloud/pubsub/v1/subscriber/helpers" if ::File.file? helper_path
@@ -0,0 +1,1861 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/pubsub/v1/pubsub_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module PubSub
25
+ module V1
26
+ module Subscriber
27
+ ##
28
+ # Client for the Subscriber service.
29
+ #
30
+ # The service that an application uses to manipulate subscriptions and to
31
+ # consume messages from a subscription via the `Pull` method or by
32
+ # establishing a bi-directional stream using the `StreamingPull` method.
33
+ #
34
+ class Client
35
+ include Paths
36
+
37
+ # @private
38
+ attr_reader :subscriber_stub
39
+
40
+ ##
41
+ # Configure the Subscriber Client class.
42
+ #
43
+ # See {::Google::Cloud::PubSub::V1::Subscriber::Client::Configuration}
44
+ # for a description of the configuration fields.
45
+ #
46
+ # ## Example
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
53
+ #
54
+ # @yield [config] Configure the Client client.
55
+ # @yieldparam config [Client::Configuration]
56
+ #
57
+ # @return [Client::Configuration]
58
+ #
59
+ def self.configure
60
+ @configure ||= begin
61
+ namespace = ["Google", "Cloud", "PubSub", "V1"]
62
+ parent_config = while namespace.any?
63
+ parent_name = namespace.join "::"
64
+ parent_const = const_get parent_name
65
+ break parent_const.configure if parent_const&.respond_to? :configure
66
+ namespace.pop
67
+ end
68
+ default_config = Client::Configuration.new parent_config
69
+
70
+ default_config.rpcs.create_subscription.timeout = 60.0
71
+ default_config.rpcs.create_subscription.retry_policy = {
72
+ initial_delay: 0.1,
73
+ max_delay: 60.0,
74
+ multiplier: 1.3,
75
+ retry_codes: ["UNKNOWN", "ABORTED", "UNAVAILABLE"]
76
+ }
77
+
78
+ default_config.rpcs.get_subscription.timeout = 60.0
79
+ default_config.rpcs.get_subscription.retry_policy = {
80
+ initial_delay: 0.1,
81
+ max_delay: 60.0,
82
+ multiplier: 1.3,
83
+ retry_codes: ["UNKNOWN", "ABORTED", "UNAVAILABLE"]
84
+ }
85
+
86
+ default_config.rpcs.update_subscription.timeout = 60.0
87
+ default_config.rpcs.update_subscription.retry_policy = {
88
+ initial_delay: 0.1,
89
+ max_delay: 60.0,
90
+ multiplier: 1.3,
91
+ retry_codes: ["UNAVAILABLE"]
92
+ }
93
+
94
+ default_config.rpcs.list_subscriptions.timeout = 60.0
95
+ default_config.rpcs.list_subscriptions.retry_policy = {
96
+ initial_delay: 0.1,
97
+ max_delay: 60.0,
98
+ multiplier: 1.3,
99
+ retry_codes: ["UNKNOWN", "ABORTED", "UNAVAILABLE"]
100
+ }
101
+
102
+ default_config.rpcs.delete_subscription.timeout = 60.0
103
+ default_config.rpcs.delete_subscription.retry_policy = {
104
+ initial_delay: 0.1,
105
+ max_delay: 60.0,
106
+ multiplier: 1.3,
107
+ retry_codes: ["UNAVAILABLE"]
108
+ }
109
+
110
+ default_config.rpcs.modify_ack_deadline.timeout = 60.0
111
+ default_config.rpcs.modify_ack_deadline.retry_policy = {
112
+ initial_delay: 0.1,
113
+ max_delay: 60.0,
114
+ multiplier: 1.3,
115
+ retry_codes: ["UNAVAILABLE"]
116
+ }
117
+
118
+ default_config.rpcs.acknowledge.timeout = 60.0
119
+ default_config.rpcs.acknowledge.retry_policy = {
120
+ initial_delay: 0.1,
121
+ max_delay: 60.0,
122
+ multiplier: 1.3,
123
+ retry_codes: ["UNAVAILABLE"]
124
+ }
125
+
126
+ default_config.rpcs.pull.timeout = 60.0
127
+ default_config.rpcs.pull.retry_policy = {
128
+ initial_delay: 0.1,
129
+ max_delay: 60.0,
130
+ multiplier: 1.3,
131
+ retry_codes: ["UNKNOWN", "ABORTED", "UNAVAILABLE"]
132
+ }
133
+
134
+ default_config.rpcs.streaming_pull.timeout = 900.0
135
+ default_config.rpcs.streaming_pull.retry_policy = {
136
+ initial_delay: 0.1,
137
+ max_delay: 60.0,
138
+ multiplier: 1.3,
139
+ retry_codes: ["DEADLINE_EXCEEDED", "RESOURCE_EXHAUSTED", "ABORTED", "INTERNAL", "UNAVAILABLE"]
140
+ }
141
+
142
+ default_config.rpcs.modify_push_config.timeout = 60.0
143
+ default_config.rpcs.modify_push_config.retry_policy = {
144
+ initial_delay: 0.1,
145
+ max_delay: 60.0,
146
+ multiplier: 1.3,
147
+ retry_codes: ["UNAVAILABLE"]
148
+ }
149
+
150
+ default_config.rpcs.get_snapshot.timeout = 60.0
151
+ default_config.rpcs.get_snapshot.retry_policy = {
152
+ initial_delay: 0.1,
153
+ max_delay: 60.0,
154
+ multiplier: 1.3,
155
+ retry_codes: ["UNKNOWN", "ABORTED", "UNAVAILABLE"]
156
+ }
157
+
158
+ default_config.rpcs.list_snapshots.timeout = 60.0
159
+ default_config.rpcs.list_snapshots.retry_policy = {
160
+ initial_delay: 0.1,
161
+ max_delay: 60.0,
162
+ multiplier: 1.3,
163
+ retry_codes: ["UNKNOWN", "ABORTED", "UNAVAILABLE"]
164
+ }
165
+
166
+ default_config.rpcs.create_snapshot.timeout = 60.0
167
+ default_config.rpcs.create_snapshot.retry_policy = {
168
+ initial_delay: 0.1,
169
+ max_delay: 60.0,
170
+ multiplier: 1.3,
171
+ retry_codes: ["UNAVAILABLE"]
172
+ }
173
+
174
+ default_config.rpcs.update_snapshot.timeout = 60.0
175
+ default_config.rpcs.update_snapshot.retry_policy = {
176
+ initial_delay: 0.1,
177
+ max_delay: 60.0,
178
+ multiplier: 1.3,
179
+ retry_codes: ["UNAVAILABLE"]
180
+ }
181
+
182
+ default_config.rpcs.delete_snapshot.timeout = 60.0
183
+ default_config.rpcs.delete_snapshot.retry_policy = {
184
+ initial_delay: 0.1,
185
+ max_delay: 60.0,
186
+ multiplier: 1.3,
187
+ retry_codes: ["UNAVAILABLE"]
188
+ }
189
+
190
+ default_config.rpcs.seek.timeout = 60.0
191
+ default_config.rpcs.seek.retry_policy = {
192
+ initial_delay: 0.1,
193
+ max_delay: 60.0,
194
+ multiplier: 1.3,
195
+ retry_codes: ["UNKNOWN", "ABORTED", "UNAVAILABLE"]
196
+ }
197
+
198
+ default_config
199
+ end
200
+ yield @configure if block_given?
201
+ @configure
202
+ end
203
+
204
+ ##
205
+ # Configure the Subscriber Client instance.
206
+ #
207
+ # The configuration is set to the derived mode, meaning that values can be changed,
208
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
209
+ # should be made on {Client.configure}.
210
+ #
211
+ # See {::Google::Cloud::PubSub::V1::Subscriber::Client::Configuration}
212
+ # for a description of the configuration fields.
213
+ #
214
+ # @yield [config] Configure the Client client.
215
+ # @yieldparam config [Client::Configuration]
216
+ #
217
+ # @return [Client::Configuration]
218
+ #
219
+ def configure
220
+ yield @config if block_given?
221
+ @config
222
+ end
223
+
224
+ ##
225
+ # Create a new Subscriber client object.
226
+ #
227
+ # ## Examples
228
+ #
229
+ # To create a new Subscriber client with the default
230
+ # configuration:
231
+ #
232
+ # client = ::Google::Cloud::PubSub::V1::Subscriber::Client.new
233
+ #
234
+ # To create a new Subscriber client with a custom
235
+ # configuration:
236
+ #
237
+ # client = ::Google::Cloud::PubSub::V1::Subscriber::Client.new do |config|
238
+ # config.timeout = 10.0
239
+ # end
240
+ #
241
+ # @yield [config] Configure the Subscriber client.
242
+ # @yieldparam config [Client::Configuration]
243
+ #
244
+ def initialize
245
+ # These require statements are intentionally placed here to initialize
246
+ # the gRPC module only when it's required.
247
+ # See https://github.com/googleapis/toolkit/issues/446
248
+ require "gapic/grpc"
249
+ require "google/pubsub/v1/pubsub_services_pb"
250
+
251
+ # Create the configuration object
252
+ @config = Configuration.new Client.configure
253
+
254
+ # Yield the configuration if needed
255
+ yield @config if block_given?
256
+
257
+ # Create credentials
258
+ credentials = @config.credentials
259
+ credentials ||= Credentials.default scope: @config.scope
260
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
261
+ credentials = Credentials.new credentials, scope: @config.scope
262
+ end
263
+ @quota_project_id = @config.quota_project
264
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
265
+
266
+ @subscriber_stub = ::Gapic::ServiceStub.new(
267
+ ::Google::Cloud::PubSub::V1::Subscriber::Stub,
268
+ credentials: credentials,
269
+ endpoint: @config.endpoint,
270
+ channel_args: @config.channel_args,
271
+ interceptors: @config.interceptors
272
+ )
273
+ end
274
+
275
+ # Service calls
276
+
277
+ ##
278
+ # Creates a subscription to a given topic. See the
279
+ # <a href="https://cloud.google.com/pubsub/docs/admin#resource_names">
280
+ # resource name rules</a>.
281
+ # If the subscription already exists, returns `ALREADY_EXISTS`.
282
+ # If the corresponding topic doesn't exist, returns `NOT_FOUND`.
283
+ #
284
+ # If the name is not provided in the request, the server will assign a random
285
+ # name for this subscription on the same project as the topic, conforming
286
+ # to the
287
+ # [resource name
288
+ # format](https://cloud.google.com/pubsub/docs/admin#resource_names). The
289
+ # generated name is populated in the returned Subscription object. Note that
290
+ # for REST API requests, you must specify a name in the request.
291
+ #
292
+ # @overload create_subscription(request, options = nil)
293
+ # Pass arguments to `create_subscription` via a request object, either of type
294
+ # {::Google::Cloud::PubSub::V1::Subscription} or an equivalent Hash.
295
+ #
296
+ # @param request [::Google::Cloud::PubSub::V1::Subscription, ::Hash]
297
+ # A request object representing the call parameters. Required. To specify no
298
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
299
+ # @param options [::Gapic::CallOptions, ::Hash]
300
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
301
+ #
302
+ # @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)
303
+ # Pass arguments to `create_subscription` via keyword arguments. Note that at
304
+ # least one keyword argument is required. To specify no parameters, or to keep all
305
+ # the default parameter values, pass an empty Hash as a request object (see above).
306
+ #
307
+ # @param name [::String]
308
+ # Required. The name of the subscription. It must have the format
309
+ # `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
310
+ # start with a letter, and contain only letters (`[A-Za-z]`), numbers
311
+ # (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
312
+ # plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
313
+ # in length, and it must not start with `"goog"`.
314
+ # @param topic [::String]
315
+ # Required. The name of the topic from which this subscription is receiving
316
+ # messages. Format is `projects/{project}/topics/{topic}`. The value of this
317
+ # field will be `_deleted-topic_` if the topic has been deleted.
318
+ # @param push_config [::Google::Cloud::PubSub::V1::PushConfig, ::Hash]
319
+ # If push delivery is used with this subscription, this field is
320
+ # used to configure it. An empty `pushConfig` signifies that the subscriber
321
+ # will pull and ack messages using API methods.
322
+ # @param ack_deadline_seconds [::Integer]
323
+ # The approximate amount of time (on a best-effort basis) Pub/Sub waits for
324
+ # the subscriber to acknowledge receipt before resending the message. In the
325
+ # interval after the message is delivered and before it is acknowledged, it
326
+ # is considered to be <i>outstanding</i>. During that time period, the
327
+ # message will not be redelivered (on a best-effort basis).
328
+ #
329
+ # For pull subscriptions, this value is used as the initial value for the ack
330
+ # deadline. To override this value for a given message, call
331
+ # `ModifyAckDeadline` with the corresponding `ack_id` if using
332
+ # non-streaming pull or send the `ack_id` in a
333
+ # `StreamingModifyAckDeadlineRequest` if using streaming pull.
334
+ # The minimum custom deadline you can specify is 10 seconds.
335
+ # The maximum custom deadline you can specify is 600 seconds (10 minutes).
336
+ # If this parameter is 0, a default value of 10 seconds is used.
337
+ #
338
+ # For push delivery, this value is also used to set the request timeout for
339
+ # the call to the push endpoint.
340
+ #
341
+ # If the subscriber never acknowledges the message, the Pub/Sub
342
+ # system will eventually redeliver the message.
343
+ # @param retain_acked_messages [::Boolean]
344
+ # Indicates whether to retain acknowledged messages. If true, then
345
+ # messages are not expunged from the subscription's backlog, even if they are
346
+ # acknowledged, until they fall out of the `message_retention_duration`
347
+ # window. This must be true if you would like to
348
+ # <a
349
+ # href="https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time">
350
+ # Seek to a timestamp</a>.
351
+ # @param message_retention_duration [::Google::Protobuf::Duration, ::Hash]
352
+ # How long to retain unacknowledged messages in the subscription's backlog,
353
+ # from the moment a message is published.
354
+ # If `retain_acked_messages` is true, then this also configures the retention
355
+ # of acknowledged messages, and thus configures how far back in time a `Seek`
356
+ # can be done. Defaults to 7 days. Cannot be more than 7 days or less than 10
357
+ # minutes.
358
+ # @param labels [::Hash{::String => ::String}]
359
+ # See <a href="https://cloud.google.com/pubsub/docs/labels"> Creating and
360
+ # managing labels</a>.
361
+ # @param enable_message_ordering [::Boolean]
362
+ # If true, messages published with the same `ordering_key` in `PubsubMessage`
363
+ # will be delivered to the subscribers in the order in which they
364
+ # are received by the Pub/Sub system. Otherwise, they may be delivered in
365
+ # any order.
366
+ # <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
367
+ # API might be changed in backward-incompatible ways and is not recommended
368
+ # for production use. It is not subject to any SLA or deprecation policy.
369
+ # @param expiration_policy [::Google::Cloud::PubSub::V1::ExpirationPolicy, ::Hash]
370
+ # A policy that specifies the conditions for this subscription's expiration.
371
+ # A subscription is considered active as long as any connected subscriber is
372
+ # successfully consuming messages from the subscription or is issuing
373
+ # operations on the subscription. If `expiration_policy` is not set, a
374
+ # *default policy* with `ttl` of 31 days will be used. The minimum allowed
375
+ # value for `expiration_policy.ttl` is 1 day.
376
+ # @param filter [::String]
377
+ # An expression written in the Pub/Sub [filter
378
+ # language](https://cloud.google.com/pubsub/docs/filtering). If non-empty,
379
+ # then only `PubsubMessage`s whose `attributes` field matches the filter are
380
+ # delivered on this subscription. If empty, then no messages are filtered
381
+ # out.
382
+ # @param dead_letter_policy [::Google::Cloud::PubSub::V1::DeadLetterPolicy, ::Hash]
383
+ # A policy that specifies the conditions for dead lettering messages in
384
+ # this subscription. If dead_letter_policy is not set, dead lettering
385
+ # is disabled.
386
+ #
387
+ # The Cloud Pub/Sub service account associated with this subscriptions's
388
+ # parent project (i.e.,
389
+ # service-\\{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have
390
+ # permission to Acknowledge() messages on this subscription.
391
+ # @param retry_policy [::Google::Cloud::PubSub::V1::RetryPolicy, ::Hash]
392
+ # A policy that specifies how Pub/Sub retries message delivery for this
393
+ # subscription.
394
+ #
395
+ # If not set, the default retry policy is applied. This generally implies
396
+ # that messages will be retried as soon as possible for healthy subscribers.
397
+ # RetryPolicy will be triggered on NACKs or acknowledgement deadline
398
+ # exceeded events for a given message.
399
+ # @param detached [::Boolean]
400
+ # Indicates whether the subscription is detached from its topic. Detached
401
+ # subscriptions don't receive messages from their topic and don't retain any
402
+ # backlog. `Pull` and `StreamingPull` requests will return
403
+ # FAILED_PRECONDITION. If the subscription is a push subscription, pushes to
404
+ # the endpoint will not be made.
405
+ #
406
+ # @yield [response, operation] Access the result along with the RPC operation
407
+ # @yieldparam response [::Google::Cloud::PubSub::V1::Subscription]
408
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
409
+ #
410
+ # @return [::Google::Cloud::PubSub::V1::Subscription]
411
+ #
412
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
413
+ #
414
+ def create_subscription request, options = nil
415
+ raise ::ArgumentError, "request must be provided" if request.nil?
416
+
417
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::Subscription
418
+
419
+ # Converts hash and nil to an options object
420
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
421
+
422
+ # Customize the options with defaults
423
+ metadata = @config.rpcs.create_subscription.metadata.to_h
424
+
425
+ # Set x-goog-api-client and x-goog-user-project headers
426
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
427
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
428
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
429
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
430
+
431
+ header_params = {
432
+ "name" => request.name
433
+ }
434
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
435
+ metadata[:"x-goog-request-params"] ||= request_params_header
436
+
437
+ options.apply_defaults timeout: @config.rpcs.create_subscription.timeout,
438
+ metadata: metadata,
439
+ retry_policy: @config.rpcs.create_subscription.retry_policy
440
+ options.apply_defaults metadata: @config.metadata,
441
+ retry_policy: @config.retry_policy
442
+
443
+ @subscriber_stub.call_rpc :create_subscription, request, options: options do |response, operation|
444
+ yield response, operation if block_given?
445
+ return response
446
+ end
447
+ rescue ::GRPC::BadStatus => e
448
+ raise ::Google::Cloud::Error.from_error(e)
449
+ end
450
+
451
+ ##
452
+ # Gets the configuration details of a subscription.
453
+ #
454
+ # @overload get_subscription(request, options = nil)
455
+ # Pass arguments to `get_subscription` via a request object, either of type
456
+ # {::Google::Cloud::PubSub::V1::GetSubscriptionRequest} or an equivalent Hash.
457
+ #
458
+ # @param request [::Google::Cloud::PubSub::V1::GetSubscriptionRequest, ::Hash]
459
+ # A request object representing the call parameters. Required. To specify no
460
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
461
+ # @param options [::Gapic::CallOptions, ::Hash]
462
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
463
+ #
464
+ # @overload get_subscription(subscription: nil)
465
+ # Pass arguments to `get_subscription` via keyword arguments. Note that at
466
+ # least one keyword argument is required. To specify no parameters, or to keep all
467
+ # the default parameter values, pass an empty Hash as a request object (see above).
468
+ #
469
+ # @param subscription [::String]
470
+ # Required. The name of the subscription to get.
471
+ # Format is `projects/{project}/subscriptions/{sub}`.
472
+ #
473
+ # @yield [response, operation] Access the result along with the RPC operation
474
+ # @yieldparam response [::Google::Cloud::PubSub::V1::Subscription]
475
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
476
+ #
477
+ # @return [::Google::Cloud::PubSub::V1::Subscription]
478
+ #
479
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
480
+ #
481
+ def get_subscription request, options = nil
482
+ raise ::ArgumentError, "request must be provided" if request.nil?
483
+
484
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::GetSubscriptionRequest
485
+
486
+ # Converts hash and nil to an options object
487
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
488
+
489
+ # Customize the options with defaults
490
+ metadata = @config.rpcs.get_subscription.metadata.to_h
491
+
492
+ # Set x-goog-api-client and x-goog-user-project headers
493
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
494
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
495
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
496
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
497
+
498
+ header_params = {
499
+ "subscription" => request.subscription
500
+ }
501
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
502
+ metadata[:"x-goog-request-params"] ||= request_params_header
503
+
504
+ options.apply_defaults timeout: @config.rpcs.get_subscription.timeout,
505
+ metadata: metadata,
506
+ retry_policy: @config.rpcs.get_subscription.retry_policy
507
+ options.apply_defaults metadata: @config.metadata,
508
+ retry_policy: @config.retry_policy
509
+
510
+ @subscriber_stub.call_rpc :get_subscription, request, options: options do |response, operation|
511
+ yield response, operation if block_given?
512
+ return response
513
+ end
514
+ rescue ::GRPC::BadStatus => e
515
+ raise ::Google::Cloud::Error.from_error(e)
516
+ end
517
+
518
+ ##
519
+ # Updates an existing subscription. Note that certain properties of a
520
+ # subscription, such as its topic, are not modifiable.
521
+ #
522
+ # @overload update_subscription(request, options = nil)
523
+ # Pass arguments to `update_subscription` via a request object, either of type
524
+ # {::Google::Cloud::PubSub::V1::UpdateSubscriptionRequest} or an equivalent Hash.
525
+ #
526
+ # @param request [::Google::Cloud::PubSub::V1::UpdateSubscriptionRequest, ::Hash]
527
+ # A request object representing the call parameters. Required. To specify no
528
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
529
+ # @param options [::Gapic::CallOptions, ::Hash]
530
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
531
+ #
532
+ # @overload update_subscription(subscription: nil, update_mask: nil)
533
+ # Pass arguments to `update_subscription` via keyword arguments. Note that at
534
+ # least one keyword argument is required. To specify no parameters, or to keep all
535
+ # the default parameter values, pass an empty Hash as a request object (see above).
536
+ #
537
+ # @param subscription [::Google::Cloud::PubSub::V1::Subscription, ::Hash]
538
+ # Required. The updated subscription object.
539
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
540
+ # Required. Indicates which fields in the provided subscription to update.
541
+ # Must be specified and non-empty.
542
+ #
543
+ # @yield [response, operation] Access the result along with the RPC operation
544
+ # @yieldparam response [::Google::Cloud::PubSub::V1::Subscription]
545
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
546
+ #
547
+ # @return [::Google::Cloud::PubSub::V1::Subscription]
548
+ #
549
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
550
+ #
551
+ def update_subscription request, options = nil
552
+ raise ::ArgumentError, "request must be provided" if request.nil?
553
+
554
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::UpdateSubscriptionRequest
555
+
556
+ # Converts hash and nil to an options object
557
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
558
+
559
+ # Customize the options with defaults
560
+ metadata = @config.rpcs.update_subscription.metadata.to_h
561
+
562
+ # Set x-goog-api-client and x-goog-user-project headers
563
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
564
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
565
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
566
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
567
+
568
+ header_params = {
569
+ "subscription.name" => request.subscription.name
570
+ }
571
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
572
+ metadata[:"x-goog-request-params"] ||= request_params_header
573
+
574
+ options.apply_defaults timeout: @config.rpcs.update_subscription.timeout,
575
+ metadata: metadata,
576
+ retry_policy: @config.rpcs.update_subscription.retry_policy
577
+ options.apply_defaults metadata: @config.metadata,
578
+ retry_policy: @config.retry_policy
579
+
580
+ @subscriber_stub.call_rpc :update_subscription, request, options: options do |response, operation|
581
+ yield response, operation if block_given?
582
+ return response
583
+ end
584
+ rescue ::GRPC::BadStatus => e
585
+ raise ::Google::Cloud::Error.from_error(e)
586
+ end
587
+
588
+ ##
589
+ # Lists matching subscriptions.
590
+ #
591
+ # @overload list_subscriptions(request, options = nil)
592
+ # Pass arguments to `list_subscriptions` via a request object, either of type
593
+ # {::Google::Cloud::PubSub::V1::ListSubscriptionsRequest} or an equivalent Hash.
594
+ #
595
+ # @param request [::Google::Cloud::PubSub::V1::ListSubscriptionsRequest, ::Hash]
596
+ # A request object representing the call parameters. Required. To specify no
597
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
598
+ # @param options [::Gapic::CallOptions, ::Hash]
599
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
600
+ #
601
+ # @overload list_subscriptions(project: nil, page_size: nil, page_token: nil)
602
+ # Pass arguments to `list_subscriptions` via keyword arguments. Note that at
603
+ # least one keyword argument is required. To specify no parameters, or to keep all
604
+ # the default parameter values, pass an empty Hash as a request object (see above).
605
+ #
606
+ # @param project [::String]
607
+ # Required. The name of the project in which to list subscriptions.
608
+ # Format is `projects/{project-id}`.
609
+ # @param page_size [::Integer]
610
+ # Maximum number of subscriptions to return.
611
+ # @param page_token [::String]
612
+ # The value returned by the last `ListSubscriptionsResponse`; indicates that
613
+ # this is a continuation of a prior `ListSubscriptions` call, and that the
614
+ # system should return the next page of data.
615
+ #
616
+ # @yield [response, operation] Access the result along with the RPC operation
617
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Subscription>]
618
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
619
+ #
620
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Subscription>]
621
+ #
622
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
623
+ #
624
+ def list_subscriptions request, options = nil
625
+ raise ::ArgumentError, "request must be provided" if request.nil?
626
+
627
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ListSubscriptionsRequest
628
+
629
+ # Converts hash and nil to an options object
630
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
631
+
632
+ # Customize the options with defaults
633
+ metadata = @config.rpcs.list_subscriptions.metadata.to_h
634
+
635
+ # Set x-goog-api-client and x-goog-user-project headers
636
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
637
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
638
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
639
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
640
+
641
+ header_params = {
642
+ "project" => request.project
643
+ }
644
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
645
+ metadata[:"x-goog-request-params"] ||= request_params_header
646
+
647
+ options.apply_defaults timeout: @config.rpcs.list_subscriptions.timeout,
648
+ metadata: metadata,
649
+ retry_policy: @config.rpcs.list_subscriptions.retry_policy
650
+ options.apply_defaults metadata: @config.metadata,
651
+ retry_policy: @config.retry_policy
652
+
653
+ @subscriber_stub.call_rpc :list_subscriptions, request, options: options do |response, operation|
654
+ response = ::Gapic::PagedEnumerable.new @subscriber_stub, :list_subscriptions, request, response, operation, options
655
+ yield response, operation if block_given?
656
+ return response
657
+ end
658
+ rescue ::GRPC::BadStatus => e
659
+ raise ::Google::Cloud::Error.from_error(e)
660
+ end
661
+
662
+ ##
663
+ # Deletes an existing subscription. All messages retained in the subscription
664
+ # are immediately dropped. Calls to `Pull` after deletion will return
665
+ # `NOT_FOUND`. After a subscription is deleted, a new one may be created with
666
+ # the same name, but the new one has no association with the old
667
+ # subscription or its topic unless the same topic is specified.
668
+ #
669
+ # @overload delete_subscription(request, options = nil)
670
+ # Pass arguments to `delete_subscription` via a request object, either of type
671
+ # {::Google::Cloud::PubSub::V1::DeleteSubscriptionRequest} or an equivalent Hash.
672
+ #
673
+ # @param request [::Google::Cloud::PubSub::V1::DeleteSubscriptionRequest, ::Hash]
674
+ # A request object representing the call parameters. Required. To specify no
675
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
676
+ # @param options [::Gapic::CallOptions, ::Hash]
677
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
678
+ #
679
+ # @overload delete_subscription(subscription: nil)
680
+ # Pass arguments to `delete_subscription` via keyword arguments. Note that at
681
+ # least one keyword argument is required. To specify no parameters, or to keep all
682
+ # the default parameter values, pass an empty Hash as a request object (see above).
683
+ #
684
+ # @param subscription [::String]
685
+ # Required. The subscription to delete.
686
+ # Format is `projects/{project}/subscriptions/{sub}`.
687
+ #
688
+ # @yield [response, operation] Access the result along with the RPC operation
689
+ # @yieldparam response [::Google::Protobuf::Empty]
690
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
691
+ #
692
+ # @return [::Google::Protobuf::Empty]
693
+ #
694
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
695
+ #
696
+ def delete_subscription request, options = nil
697
+ raise ::ArgumentError, "request must be provided" if request.nil?
698
+
699
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::DeleteSubscriptionRequest
700
+
701
+ # Converts hash and nil to an options object
702
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
703
+
704
+ # Customize the options with defaults
705
+ metadata = @config.rpcs.delete_subscription.metadata.to_h
706
+
707
+ # Set x-goog-api-client and x-goog-user-project headers
708
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
709
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
710
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
711
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
712
+
713
+ header_params = {
714
+ "subscription" => request.subscription
715
+ }
716
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
717
+ metadata[:"x-goog-request-params"] ||= request_params_header
718
+
719
+ options.apply_defaults timeout: @config.rpcs.delete_subscription.timeout,
720
+ metadata: metadata,
721
+ retry_policy: @config.rpcs.delete_subscription.retry_policy
722
+ options.apply_defaults metadata: @config.metadata,
723
+ retry_policy: @config.retry_policy
724
+
725
+ @subscriber_stub.call_rpc :delete_subscription, request, options: options do |response, operation|
726
+ yield response, operation if block_given?
727
+ return response
728
+ end
729
+ rescue ::GRPC::BadStatus => e
730
+ raise ::Google::Cloud::Error.from_error(e)
731
+ end
732
+
733
+ ##
734
+ # Modifies the ack deadline for a specific message. This method is useful
735
+ # to indicate that more time is needed to process a message by the
736
+ # subscriber, or to make the message available for redelivery if the
737
+ # processing was interrupted. Note that this does not modify the
738
+ # subscription-level `ackDeadlineSeconds` used for subsequent messages.
739
+ #
740
+ # @overload modify_ack_deadline(request, options = nil)
741
+ # Pass arguments to `modify_ack_deadline` via a request object, either of type
742
+ # {::Google::Cloud::PubSub::V1::ModifyAckDeadlineRequest} or an equivalent Hash.
743
+ #
744
+ # @param request [::Google::Cloud::PubSub::V1::ModifyAckDeadlineRequest, ::Hash]
745
+ # A request object representing the call parameters. Required. To specify no
746
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
747
+ # @param options [::Gapic::CallOptions, ::Hash]
748
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
749
+ #
750
+ # @overload modify_ack_deadline(subscription: nil, ack_ids: nil, ack_deadline_seconds: nil)
751
+ # Pass arguments to `modify_ack_deadline` via keyword arguments. Note that at
752
+ # least one keyword argument is required. To specify no parameters, or to keep all
753
+ # the default parameter values, pass an empty Hash as a request object (see above).
754
+ #
755
+ # @param subscription [::String]
756
+ # Required. The name of the subscription.
757
+ # Format is `projects/{project}/subscriptions/{sub}`.
758
+ # @param ack_ids [::Array<::String>]
759
+ # Required. List of acknowledgment IDs.
760
+ # @param ack_deadline_seconds [::Integer]
761
+ # Required. The new ack deadline with respect to the time this request was
762
+ # sent to the Pub/Sub system. For example, if the value is 10, the new ack
763
+ # deadline will expire 10 seconds after the `ModifyAckDeadline` call was
764
+ # made. Specifying zero might immediately make the message available for
765
+ # delivery to another subscriber client. This typically results in an
766
+ # increase in the rate of message redeliveries (that is, duplicates).
767
+ # The minimum deadline you can specify is 0 seconds.
768
+ # The maximum deadline you can specify is 600 seconds (10 minutes).
769
+ #
770
+ # @yield [response, operation] Access the result along with the RPC operation
771
+ # @yieldparam response [::Google::Protobuf::Empty]
772
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
773
+ #
774
+ # @return [::Google::Protobuf::Empty]
775
+ #
776
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
777
+ #
778
+ def modify_ack_deadline request, options = nil
779
+ raise ::ArgumentError, "request must be provided" if request.nil?
780
+
781
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ModifyAckDeadlineRequest
782
+
783
+ # Converts hash and nil to an options object
784
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
785
+
786
+ # Customize the options with defaults
787
+ metadata = @config.rpcs.modify_ack_deadline.metadata.to_h
788
+
789
+ # Set x-goog-api-client and x-goog-user-project headers
790
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
791
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
792
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
793
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
794
+
795
+ header_params = {
796
+ "subscription" => request.subscription
797
+ }
798
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
799
+ metadata[:"x-goog-request-params"] ||= request_params_header
800
+
801
+ options.apply_defaults timeout: @config.rpcs.modify_ack_deadline.timeout,
802
+ metadata: metadata,
803
+ retry_policy: @config.rpcs.modify_ack_deadline.retry_policy
804
+ options.apply_defaults metadata: @config.metadata,
805
+ retry_policy: @config.retry_policy
806
+
807
+ @subscriber_stub.call_rpc :modify_ack_deadline, request, options: options do |response, operation|
808
+ yield response, operation if block_given?
809
+ return response
810
+ end
811
+ rescue ::GRPC::BadStatus => e
812
+ raise ::Google::Cloud::Error.from_error(e)
813
+ end
814
+
815
+ ##
816
+ # Acknowledges the messages associated with the `ack_ids` in the
817
+ # `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages
818
+ # from the subscription.
819
+ #
820
+ # Acknowledging a message whose ack deadline has expired may succeed,
821
+ # but such a message may be redelivered later. Acknowledging a message more
822
+ # than once will not result in an error.
823
+ #
824
+ # @overload acknowledge(request, options = nil)
825
+ # Pass arguments to `acknowledge` via a request object, either of type
826
+ # {::Google::Cloud::PubSub::V1::AcknowledgeRequest} or an equivalent Hash.
827
+ #
828
+ # @param request [::Google::Cloud::PubSub::V1::AcknowledgeRequest, ::Hash]
829
+ # A request object representing the call parameters. Required. To specify no
830
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
831
+ # @param options [::Gapic::CallOptions, ::Hash]
832
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
833
+ #
834
+ # @overload acknowledge(subscription: nil, ack_ids: nil)
835
+ # Pass arguments to `acknowledge` via keyword arguments. Note that at
836
+ # least one keyword argument is required. To specify no parameters, or to keep all
837
+ # the default parameter values, pass an empty Hash as a request object (see above).
838
+ #
839
+ # @param subscription [::String]
840
+ # Required. The subscription whose message is being acknowledged.
841
+ # Format is `projects/{project}/subscriptions/{sub}`.
842
+ # @param ack_ids [::Array<::String>]
843
+ # Required. The acknowledgment ID for the messages being acknowledged that
844
+ # was returned by the Pub/Sub system in the `Pull` response. Must not be
845
+ # empty.
846
+ #
847
+ # @yield [response, operation] Access the result along with the RPC operation
848
+ # @yieldparam response [::Google::Protobuf::Empty]
849
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
850
+ #
851
+ # @return [::Google::Protobuf::Empty]
852
+ #
853
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
854
+ #
855
+ def acknowledge request, options = nil
856
+ raise ::ArgumentError, "request must be provided" if request.nil?
857
+
858
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::AcknowledgeRequest
859
+
860
+ # Converts hash and nil to an options object
861
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
862
+
863
+ # Customize the options with defaults
864
+ metadata = @config.rpcs.acknowledge.metadata.to_h
865
+
866
+ # Set x-goog-api-client and x-goog-user-project headers
867
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
868
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
869
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
870
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
871
+
872
+ header_params = {
873
+ "subscription" => request.subscription
874
+ }
875
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
876
+ metadata[:"x-goog-request-params"] ||= request_params_header
877
+
878
+ options.apply_defaults timeout: @config.rpcs.acknowledge.timeout,
879
+ metadata: metadata,
880
+ retry_policy: @config.rpcs.acknowledge.retry_policy
881
+ options.apply_defaults metadata: @config.metadata,
882
+ retry_policy: @config.retry_policy
883
+
884
+ @subscriber_stub.call_rpc :acknowledge, request, options: options do |response, operation|
885
+ yield response, operation if block_given?
886
+ return response
887
+ end
888
+ rescue ::GRPC::BadStatus => e
889
+ raise ::Google::Cloud::Error.from_error(e)
890
+ end
891
+
892
+ ##
893
+ # Pulls messages from the server. The server may return `UNAVAILABLE` if
894
+ # there are too many concurrent pull requests pending for the given
895
+ # subscription.
896
+ #
897
+ # @overload pull(request, options = nil)
898
+ # Pass arguments to `pull` via a request object, either of type
899
+ # {::Google::Cloud::PubSub::V1::PullRequest} or an equivalent Hash.
900
+ #
901
+ # @param request [::Google::Cloud::PubSub::V1::PullRequest, ::Hash]
902
+ # A request object representing the call parameters. Required. To specify no
903
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
904
+ # @param options [::Gapic::CallOptions, ::Hash]
905
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
906
+ #
907
+ # @overload pull(subscription: nil, return_immediately: nil, max_messages: nil)
908
+ # Pass arguments to `pull` via keyword arguments. Note that at
909
+ # least one keyword argument is required. To specify no parameters, or to keep all
910
+ # the default parameter values, pass an empty Hash as a request object (see above).
911
+ #
912
+ # @param subscription [::String]
913
+ # Required. The subscription from which messages should be pulled.
914
+ # Format is `projects/{project}/subscriptions/{sub}`.
915
+ # @param return_immediately [::Boolean]
916
+ # Optional. If this field set to true, the system will respond immediately
917
+ # even if it there are no messages available to return in the `Pull`
918
+ # response. Otherwise, the system may wait (for a bounded amount of time)
919
+ # until at least one message is available, rather than returning no messages.
920
+ # Warning: setting this field to `true` is discouraged because it adversely
921
+ # impacts the performance of `Pull` operations. We recommend that users do
922
+ # not set this field.
923
+ # @param max_messages [::Integer]
924
+ # Required. The maximum number of messages to return for this request. Must
925
+ # be a positive integer. The Pub/Sub system may return fewer than the number
926
+ # specified.
927
+ #
928
+ # @yield [response, operation] Access the result along with the RPC operation
929
+ # @yieldparam response [::Google::Cloud::PubSub::V1::PullResponse]
930
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
931
+ #
932
+ # @return [::Google::Cloud::PubSub::V1::PullResponse]
933
+ #
934
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
935
+ #
936
+ def pull request, options = nil
937
+ raise ::ArgumentError, "request must be provided" if request.nil?
938
+
939
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::PullRequest
940
+
941
+ # Converts hash and nil to an options object
942
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
943
+
944
+ # Customize the options with defaults
945
+ metadata = @config.rpcs.pull.metadata.to_h
946
+
947
+ # Set x-goog-api-client and x-goog-user-project headers
948
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
949
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
950
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
951
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
952
+
953
+ header_params = {
954
+ "subscription" => request.subscription
955
+ }
956
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
957
+ metadata[:"x-goog-request-params"] ||= request_params_header
958
+
959
+ options.apply_defaults timeout: @config.rpcs.pull.timeout,
960
+ metadata: metadata,
961
+ retry_policy: @config.rpcs.pull.retry_policy
962
+ options.apply_defaults metadata: @config.metadata,
963
+ retry_policy: @config.retry_policy
964
+
965
+ @subscriber_stub.call_rpc :pull, request, options: options do |response, operation|
966
+ yield response, operation if block_given?
967
+ return response
968
+ end
969
+ rescue ::GRPC::BadStatus => e
970
+ raise ::Google::Cloud::Error.from_error(e)
971
+ end
972
+
973
+ ##
974
+ # Establishes a stream with the server, which sends messages down to the
975
+ # client. The client streams acknowledgements and ack deadline modifications
976
+ # back to the server. The server will close the stream and return the status
977
+ # on any error. The server may close the stream with status `UNAVAILABLE` to
978
+ # reassign server-side resources, in which case, the client should
979
+ # re-establish the stream. Flow control can be achieved by configuring the
980
+ # underlying RPC channel.
981
+ #
982
+ # @param request [::Gapic::StreamInput, ::Enumerable<::Google::Cloud::PubSub::V1::StreamingPullRequest, ::Hash>]
983
+ # An enumerable of {::Google::Cloud::PubSub::V1::StreamingPullRequest} instances.
984
+ # @param options [::Gapic::CallOptions, ::Hash]
985
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
986
+ #
987
+ # @yield [response, operation] Access the result along with the RPC operation
988
+ # @yieldparam response [::Enumerable<::Google::Cloud::PubSub::V1::StreamingPullResponse>]
989
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
990
+ #
991
+ # @return [::Enumerable<::Google::Cloud::PubSub::V1::StreamingPullResponse>]
992
+ #
993
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
994
+ #
995
+ def streaming_pull request, options = nil
996
+ unless request.is_a? ::Enumerable
997
+ raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
998
+ request = request.to_enum
999
+ end
1000
+
1001
+ request = request.lazy.map do |req|
1002
+ ::Gapic::Protobuf.coerce req, to: ::Google::Cloud::PubSub::V1::StreamingPullRequest
1003
+ end
1004
+
1005
+ # Converts hash and nil to an options object
1006
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1007
+
1008
+ # Customize the options with defaults
1009
+ metadata = @config.rpcs.streaming_pull.metadata.to_h
1010
+
1011
+ # Set x-goog-api-client and x-goog-user-project headers
1012
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1013
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1014
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
1015
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1016
+
1017
+ options.apply_defaults timeout: @config.rpcs.streaming_pull.timeout,
1018
+ metadata: metadata,
1019
+ retry_policy: @config.rpcs.streaming_pull.retry_policy
1020
+ options.apply_defaults metadata: @config.metadata,
1021
+ retry_policy: @config.retry_policy
1022
+
1023
+ @subscriber_stub.call_rpc :streaming_pull, request, options: options do |response, operation|
1024
+ yield response, operation if block_given?
1025
+ return response
1026
+ end
1027
+ rescue ::GRPC::BadStatus => e
1028
+ raise ::Google::Cloud::Error.from_error(e)
1029
+ end
1030
+
1031
+ ##
1032
+ # Modifies the `PushConfig` for a specified subscription.
1033
+ #
1034
+ # This may be used to change a push subscription to a pull one (signified by
1035
+ # an empty `PushConfig`) or vice versa, or change the endpoint URL and other
1036
+ # attributes of a push subscription. Messages will accumulate for delivery
1037
+ # continuously through the call regardless of changes to the `PushConfig`.
1038
+ #
1039
+ # @overload modify_push_config(request, options = nil)
1040
+ # Pass arguments to `modify_push_config` via a request object, either of type
1041
+ # {::Google::Cloud::PubSub::V1::ModifyPushConfigRequest} or an equivalent Hash.
1042
+ #
1043
+ # @param request [::Google::Cloud::PubSub::V1::ModifyPushConfigRequest, ::Hash]
1044
+ # A request object representing the call parameters. Required. To specify no
1045
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1046
+ # @param options [::Gapic::CallOptions, ::Hash]
1047
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1048
+ #
1049
+ # @overload modify_push_config(subscription: nil, push_config: nil)
1050
+ # Pass arguments to `modify_push_config` via keyword arguments. Note that at
1051
+ # least one keyword argument is required. To specify no parameters, or to keep all
1052
+ # the default parameter values, pass an empty Hash as a request object (see above).
1053
+ #
1054
+ # @param subscription [::String]
1055
+ # Required. The name of the subscription.
1056
+ # Format is `projects/{project}/subscriptions/{sub}`.
1057
+ # @param push_config [::Google::Cloud::PubSub::V1::PushConfig, ::Hash]
1058
+ # Required. The push configuration for future deliveries.
1059
+ #
1060
+ # An empty `pushConfig` indicates that the Pub/Sub system should
1061
+ # stop pushing messages from the given subscription and allow
1062
+ # messages to be pulled and acknowledged - effectively pausing
1063
+ # the subscription if `Pull` or `StreamingPull` is not called.
1064
+ #
1065
+ # @yield [response, operation] Access the result along with the RPC operation
1066
+ # @yieldparam response [::Google::Protobuf::Empty]
1067
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1068
+ #
1069
+ # @return [::Google::Protobuf::Empty]
1070
+ #
1071
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1072
+ #
1073
+ def modify_push_config request, options = nil
1074
+ raise ::ArgumentError, "request must be provided" if request.nil?
1075
+
1076
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ModifyPushConfigRequest
1077
+
1078
+ # Converts hash and nil to an options object
1079
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1080
+
1081
+ # Customize the options with defaults
1082
+ metadata = @config.rpcs.modify_push_config.metadata.to_h
1083
+
1084
+ # Set x-goog-api-client and x-goog-user-project headers
1085
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1086
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1087
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
1088
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1089
+
1090
+ header_params = {
1091
+ "subscription" => request.subscription
1092
+ }
1093
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1094
+ metadata[:"x-goog-request-params"] ||= request_params_header
1095
+
1096
+ options.apply_defaults timeout: @config.rpcs.modify_push_config.timeout,
1097
+ metadata: metadata,
1098
+ retry_policy: @config.rpcs.modify_push_config.retry_policy
1099
+ options.apply_defaults metadata: @config.metadata,
1100
+ retry_policy: @config.retry_policy
1101
+
1102
+ @subscriber_stub.call_rpc :modify_push_config, request, options: options do |response, operation|
1103
+ yield response, operation if block_given?
1104
+ return response
1105
+ end
1106
+ rescue ::GRPC::BadStatus => e
1107
+ raise ::Google::Cloud::Error.from_error(e)
1108
+ end
1109
+
1110
+ ##
1111
+ # Gets the configuration details of a snapshot. Snapshots are used in
1112
+ # <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
1113
+ # operations, which allow you to manage message acknowledgments in bulk. That
1114
+ # is, you can set the acknowledgment state of messages in an existing
1115
+ # subscription to the state captured by a snapshot.
1116
+ #
1117
+ # @overload get_snapshot(request, options = nil)
1118
+ # Pass arguments to `get_snapshot` via a request object, either of type
1119
+ # {::Google::Cloud::PubSub::V1::GetSnapshotRequest} or an equivalent Hash.
1120
+ #
1121
+ # @param request [::Google::Cloud::PubSub::V1::GetSnapshotRequest, ::Hash]
1122
+ # A request object representing the call parameters. Required. To specify no
1123
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1124
+ # @param options [::Gapic::CallOptions, ::Hash]
1125
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1126
+ #
1127
+ # @overload get_snapshot(snapshot: nil)
1128
+ # Pass arguments to `get_snapshot` via keyword arguments. Note that at
1129
+ # least one keyword argument is required. To specify no parameters, or to keep all
1130
+ # the default parameter values, pass an empty Hash as a request object (see above).
1131
+ #
1132
+ # @param snapshot [::String]
1133
+ # Required. The name of the snapshot to get.
1134
+ # Format is `projects/{project}/snapshots/{snap}`.
1135
+ #
1136
+ # @yield [response, operation] Access the result along with the RPC operation
1137
+ # @yieldparam response [::Google::Cloud::PubSub::V1::Snapshot]
1138
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1139
+ #
1140
+ # @return [::Google::Cloud::PubSub::V1::Snapshot]
1141
+ #
1142
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1143
+ #
1144
+ def get_snapshot request, options = nil
1145
+ raise ::ArgumentError, "request must be provided" if request.nil?
1146
+
1147
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::GetSnapshotRequest
1148
+
1149
+ # Converts hash and nil to an options object
1150
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1151
+
1152
+ # Customize the options with defaults
1153
+ metadata = @config.rpcs.get_snapshot.metadata.to_h
1154
+
1155
+ # Set x-goog-api-client and x-goog-user-project headers
1156
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1157
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1158
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
1159
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1160
+
1161
+ header_params = {
1162
+ "snapshot" => request.snapshot
1163
+ }
1164
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1165
+ metadata[:"x-goog-request-params"] ||= request_params_header
1166
+
1167
+ options.apply_defaults timeout: @config.rpcs.get_snapshot.timeout,
1168
+ metadata: metadata,
1169
+ retry_policy: @config.rpcs.get_snapshot.retry_policy
1170
+ options.apply_defaults metadata: @config.metadata,
1171
+ retry_policy: @config.retry_policy
1172
+
1173
+ @subscriber_stub.call_rpc :get_snapshot, request, options: options do |response, operation|
1174
+ yield response, operation if block_given?
1175
+ return response
1176
+ end
1177
+ rescue ::GRPC::BadStatus => e
1178
+ raise ::Google::Cloud::Error.from_error(e)
1179
+ end
1180
+
1181
+ ##
1182
+ # Lists the existing snapshots. Snapshots are used in
1183
+ # <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
1184
+ # operations, which allow
1185
+ # you to manage message acknowledgments in bulk. That is, you can set the
1186
+ # acknowledgment state of messages in an existing subscription to the state
1187
+ # captured by a snapshot.
1188
+ #
1189
+ # @overload list_snapshots(request, options = nil)
1190
+ # Pass arguments to `list_snapshots` via a request object, either of type
1191
+ # {::Google::Cloud::PubSub::V1::ListSnapshotsRequest} or an equivalent Hash.
1192
+ #
1193
+ # @param request [::Google::Cloud::PubSub::V1::ListSnapshotsRequest, ::Hash]
1194
+ # A request object representing the call parameters. Required. To specify no
1195
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1196
+ # @param options [::Gapic::CallOptions, ::Hash]
1197
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1198
+ #
1199
+ # @overload list_snapshots(project: nil, page_size: nil, page_token: nil)
1200
+ # Pass arguments to `list_snapshots` via keyword arguments. Note that at
1201
+ # least one keyword argument is required. To specify no parameters, or to keep all
1202
+ # the default parameter values, pass an empty Hash as a request object (see above).
1203
+ #
1204
+ # @param project [::String]
1205
+ # Required. The name of the project in which to list snapshots.
1206
+ # Format is `projects/{project-id}`.
1207
+ # @param page_size [::Integer]
1208
+ # Maximum number of snapshots to return.
1209
+ # @param page_token [::String]
1210
+ # The value returned by the last `ListSnapshotsResponse`; indicates that this
1211
+ # is a continuation of a prior `ListSnapshots` call, and that the system
1212
+ # should return the next page of data.
1213
+ #
1214
+ # @yield [response, operation] Access the result along with the RPC operation
1215
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Snapshot>]
1216
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1217
+ #
1218
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Snapshot>]
1219
+ #
1220
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1221
+ #
1222
+ def list_snapshots request, options = nil
1223
+ raise ::ArgumentError, "request must be provided" if request.nil?
1224
+
1225
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ListSnapshotsRequest
1226
+
1227
+ # Converts hash and nil to an options object
1228
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1229
+
1230
+ # Customize the options with defaults
1231
+ metadata = @config.rpcs.list_snapshots.metadata.to_h
1232
+
1233
+ # Set x-goog-api-client and x-goog-user-project headers
1234
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1235
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1236
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
1237
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1238
+
1239
+ header_params = {
1240
+ "project" => request.project
1241
+ }
1242
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1243
+ metadata[:"x-goog-request-params"] ||= request_params_header
1244
+
1245
+ options.apply_defaults timeout: @config.rpcs.list_snapshots.timeout,
1246
+ metadata: metadata,
1247
+ retry_policy: @config.rpcs.list_snapshots.retry_policy
1248
+ options.apply_defaults metadata: @config.metadata,
1249
+ retry_policy: @config.retry_policy
1250
+
1251
+ @subscriber_stub.call_rpc :list_snapshots, request, options: options do |response, operation|
1252
+ response = ::Gapic::PagedEnumerable.new @subscriber_stub, :list_snapshots, request, response, operation, options
1253
+ yield response, operation if block_given?
1254
+ return response
1255
+ end
1256
+ rescue ::GRPC::BadStatus => e
1257
+ raise ::Google::Cloud::Error.from_error(e)
1258
+ end
1259
+
1260
+ ##
1261
+ # Creates a snapshot from the requested subscription. Snapshots are used in
1262
+ # <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
1263
+ # operations, which allow
1264
+ # you to manage message acknowledgments in bulk. That is, you can set the
1265
+ # acknowledgment state of messages in an existing subscription to the state
1266
+ # captured by a snapshot.
1267
+ # <br><br>If the snapshot already exists, returns `ALREADY_EXISTS`.
1268
+ # If the requested subscription doesn't exist, returns `NOT_FOUND`.
1269
+ # If the backlog in the subscription is too old -- and the resulting snapshot
1270
+ # would expire in less than 1 hour -- then `FAILED_PRECONDITION` is returned.
1271
+ # See also the `Snapshot.expire_time` field. If the name is not provided in
1272
+ # the request, the server will assign a random
1273
+ # name for this snapshot on the same project as the subscription, conforming
1274
+ # to the
1275
+ # [resource name
1276
+ # format](https://cloud.google.com/pubsub/docs/admin#resource_names). The
1277
+ # generated name is populated in the returned Snapshot object. Note that for
1278
+ # REST API requests, you must specify a name in the request.
1279
+ #
1280
+ # @overload create_snapshot(request, options = nil)
1281
+ # Pass arguments to `create_snapshot` via a request object, either of type
1282
+ # {::Google::Cloud::PubSub::V1::CreateSnapshotRequest} or an equivalent Hash.
1283
+ #
1284
+ # @param request [::Google::Cloud::PubSub::V1::CreateSnapshotRequest, ::Hash]
1285
+ # A request object representing the call parameters. Required. To specify no
1286
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1287
+ # @param options [::Gapic::CallOptions, ::Hash]
1288
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1289
+ #
1290
+ # @overload create_snapshot(name: nil, subscription: nil, labels: nil)
1291
+ # Pass arguments to `create_snapshot` via keyword arguments. Note that at
1292
+ # least one keyword argument is required. To specify no parameters, or to keep all
1293
+ # the default parameter values, pass an empty Hash as a request object (see above).
1294
+ #
1295
+ # @param name [::String]
1296
+ # Required. User-provided name for this snapshot. If the name is not provided
1297
+ # in the request, the server will assign a random name for this snapshot on
1298
+ # the same project as the subscription. Note that for REST API requests, you
1299
+ # must specify a name. See the <a
1300
+ # href="https://cloud.google.com/pubsub/docs/admin#resource_names"> resource
1301
+ # name rules</a>. Format is `projects/{project}/snapshots/{snap}`.
1302
+ # @param subscription [::String]
1303
+ # Required. The subscription whose backlog the snapshot retains.
1304
+ # Specifically, the created snapshot is guaranteed to retain:
1305
+ # (a) The existing backlog on the subscription. More precisely, this is
1306
+ # defined as the messages in the subscription's backlog that are
1307
+ # unacknowledged upon the successful completion of the
1308
+ # `CreateSnapshot` request; as well as:
1309
+ # (b) Any messages published to the subscription's topic following the
1310
+ # successful completion of the CreateSnapshot request.
1311
+ # Format is `projects/{project}/subscriptions/{sub}`.
1312
+ # @param labels [::Hash{::String => ::String}]
1313
+ # See <a href="https://cloud.google.com/pubsub/docs/labels"> Creating and
1314
+ # managing labels</a>.
1315
+ #
1316
+ # @yield [response, operation] Access the result along with the RPC operation
1317
+ # @yieldparam response [::Google::Cloud::PubSub::V1::Snapshot]
1318
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1319
+ #
1320
+ # @return [::Google::Cloud::PubSub::V1::Snapshot]
1321
+ #
1322
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1323
+ #
1324
+ def create_snapshot request, options = nil
1325
+ raise ::ArgumentError, "request must be provided" if request.nil?
1326
+
1327
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::CreateSnapshotRequest
1328
+
1329
+ # Converts hash and nil to an options object
1330
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1331
+
1332
+ # Customize the options with defaults
1333
+ metadata = @config.rpcs.create_snapshot.metadata.to_h
1334
+
1335
+ # Set x-goog-api-client and x-goog-user-project headers
1336
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1337
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1338
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
1339
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1340
+
1341
+ header_params = {
1342
+ "name" => request.name
1343
+ }
1344
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1345
+ metadata[:"x-goog-request-params"] ||= request_params_header
1346
+
1347
+ options.apply_defaults timeout: @config.rpcs.create_snapshot.timeout,
1348
+ metadata: metadata,
1349
+ retry_policy: @config.rpcs.create_snapshot.retry_policy
1350
+ options.apply_defaults metadata: @config.metadata,
1351
+ retry_policy: @config.retry_policy
1352
+
1353
+ @subscriber_stub.call_rpc :create_snapshot, request, options: options do |response, operation|
1354
+ yield response, operation if block_given?
1355
+ return response
1356
+ end
1357
+ rescue ::GRPC::BadStatus => e
1358
+ raise ::Google::Cloud::Error.from_error(e)
1359
+ end
1360
+
1361
+ ##
1362
+ # Updates an existing snapshot. Snapshots are used in
1363
+ # <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
1364
+ # operations, which allow
1365
+ # you to manage message acknowledgments in bulk. That is, you can set the
1366
+ # acknowledgment state of messages in an existing subscription to the state
1367
+ # captured by a snapshot.
1368
+ #
1369
+ # @overload update_snapshot(request, options = nil)
1370
+ # Pass arguments to `update_snapshot` via a request object, either of type
1371
+ # {::Google::Cloud::PubSub::V1::UpdateSnapshotRequest} or an equivalent Hash.
1372
+ #
1373
+ # @param request [::Google::Cloud::PubSub::V1::UpdateSnapshotRequest, ::Hash]
1374
+ # A request object representing the call parameters. Required. To specify no
1375
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1376
+ # @param options [::Gapic::CallOptions, ::Hash]
1377
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1378
+ #
1379
+ # @overload update_snapshot(snapshot: nil, update_mask: nil)
1380
+ # Pass arguments to `update_snapshot` via keyword arguments. Note that at
1381
+ # least one keyword argument is required. To specify no parameters, or to keep all
1382
+ # the default parameter values, pass an empty Hash as a request object (see above).
1383
+ #
1384
+ # @param snapshot [::Google::Cloud::PubSub::V1::Snapshot, ::Hash]
1385
+ # Required. The updated snapshot object.
1386
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
1387
+ # Required. Indicates which fields in the provided snapshot to update.
1388
+ # Must be specified and non-empty.
1389
+ #
1390
+ # @yield [response, operation] Access the result along with the RPC operation
1391
+ # @yieldparam response [::Google::Cloud::PubSub::V1::Snapshot]
1392
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1393
+ #
1394
+ # @return [::Google::Cloud::PubSub::V1::Snapshot]
1395
+ #
1396
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1397
+ #
1398
+ def update_snapshot request, options = nil
1399
+ raise ::ArgumentError, "request must be provided" if request.nil?
1400
+
1401
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::UpdateSnapshotRequest
1402
+
1403
+ # Converts hash and nil to an options object
1404
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1405
+
1406
+ # Customize the options with defaults
1407
+ metadata = @config.rpcs.update_snapshot.metadata.to_h
1408
+
1409
+ # Set x-goog-api-client and x-goog-user-project headers
1410
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1411
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1412
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
1413
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1414
+
1415
+ header_params = {
1416
+ "snapshot.name" => request.snapshot.name
1417
+ }
1418
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1419
+ metadata[:"x-goog-request-params"] ||= request_params_header
1420
+
1421
+ options.apply_defaults timeout: @config.rpcs.update_snapshot.timeout,
1422
+ metadata: metadata,
1423
+ retry_policy: @config.rpcs.update_snapshot.retry_policy
1424
+ options.apply_defaults metadata: @config.metadata,
1425
+ retry_policy: @config.retry_policy
1426
+
1427
+ @subscriber_stub.call_rpc :update_snapshot, request, options: options do |response, operation|
1428
+ yield response, operation if block_given?
1429
+ return response
1430
+ end
1431
+ rescue ::GRPC::BadStatus => e
1432
+ raise ::Google::Cloud::Error.from_error(e)
1433
+ end
1434
+
1435
+ ##
1436
+ # Removes an existing snapshot. Snapshots are used in
1437
+ # <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
1438
+ # operations, which allow
1439
+ # you to manage message acknowledgments in bulk. That is, you can set the
1440
+ # acknowledgment state of messages in an existing subscription to the state
1441
+ # captured by a snapshot.<br><br>
1442
+ # When the snapshot is deleted, all messages retained in the snapshot
1443
+ # are immediately dropped. After a snapshot is deleted, a new one may be
1444
+ # created with the same name, but the new one has no association with the old
1445
+ # snapshot or its subscription, unless the same subscription is specified.
1446
+ #
1447
+ # @overload delete_snapshot(request, options = nil)
1448
+ # Pass arguments to `delete_snapshot` via a request object, either of type
1449
+ # {::Google::Cloud::PubSub::V1::DeleteSnapshotRequest} or an equivalent Hash.
1450
+ #
1451
+ # @param request [::Google::Cloud::PubSub::V1::DeleteSnapshotRequest, ::Hash]
1452
+ # A request object representing the call parameters. Required. To specify no
1453
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1454
+ # @param options [::Gapic::CallOptions, ::Hash]
1455
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1456
+ #
1457
+ # @overload delete_snapshot(snapshot: nil)
1458
+ # Pass arguments to `delete_snapshot` via keyword arguments. Note that at
1459
+ # least one keyword argument is required. To specify no parameters, or to keep all
1460
+ # the default parameter values, pass an empty Hash as a request object (see above).
1461
+ #
1462
+ # @param snapshot [::String]
1463
+ # Required. The name of the snapshot to delete.
1464
+ # Format is `projects/{project}/snapshots/{snap}`.
1465
+ #
1466
+ # @yield [response, operation] Access the result along with the RPC operation
1467
+ # @yieldparam response [::Google::Protobuf::Empty]
1468
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1469
+ #
1470
+ # @return [::Google::Protobuf::Empty]
1471
+ #
1472
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1473
+ #
1474
+ def delete_snapshot request, options = nil
1475
+ raise ::ArgumentError, "request must be provided" if request.nil?
1476
+
1477
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::DeleteSnapshotRequest
1478
+
1479
+ # Converts hash and nil to an options object
1480
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1481
+
1482
+ # Customize the options with defaults
1483
+ metadata = @config.rpcs.delete_snapshot.metadata.to_h
1484
+
1485
+ # Set x-goog-api-client and x-goog-user-project headers
1486
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1487
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1488
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
1489
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1490
+
1491
+ header_params = {
1492
+ "snapshot" => request.snapshot
1493
+ }
1494
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1495
+ metadata[:"x-goog-request-params"] ||= request_params_header
1496
+
1497
+ options.apply_defaults timeout: @config.rpcs.delete_snapshot.timeout,
1498
+ metadata: metadata,
1499
+ retry_policy: @config.rpcs.delete_snapshot.retry_policy
1500
+ options.apply_defaults metadata: @config.metadata,
1501
+ retry_policy: @config.retry_policy
1502
+
1503
+ @subscriber_stub.call_rpc :delete_snapshot, request, options: options do |response, operation|
1504
+ yield response, operation if block_given?
1505
+ return response
1506
+ end
1507
+ rescue ::GRPC::BadStatus => e
1508
+ raise ::Google::Cloud::Error.from_error(e)
1509
+ end
1510
+
1511
+ ##
1512
+ # Seeks an existing subscription to a point in time or to a given snapshot,
1513
+ # whichever is provided in the request. Snapshots are used in
1514
+ # <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
1515
+ # operations, which allow
1516
+ # you to manage message acknowledgments in bulk. That is, you can set the
1517
+ # acknowledgment state of messages in an existing subscription to the state
1518
+ # captured by a snapshot. Note that both the subscription and the snapshot
1519
+ # must be on the same topic.
1520
+ #
1521
+ # @overload seek(request, options = nil)
1522
+ # Pass arguments to `seek` via a request object, either of type
1523
+ # {::Google::Cloud::PubSub::V1::SeekRequest} or an equivalent Hash.
1524
+ #
1525
+ # @param request [::Google::Cloud::PubSub::V1::SeekRequest, ::Hash]
1526
+ # A request object representing the call parameters. Required. To specify no
1527
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1528
+ # @param options [::Gapic::CallOptions, ::Hash]
1529
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1530
+ #
1531
+ # @overload seek(subscription: nil, time: nil, snapshot: nil)
1532
+ # Pass arguments to `seek` via keyword arguments. Note that at
1533
+ # least one keyword argument is required. To specify no parameters, or to keep all
1534
+ # the default parameter values, pass an empty Hash as a request object (see above).
1535
+ #
1536
+ # @param subscription [::String]
1537
+ # Required. The subscription to affect.
1538
+ # @param time [::Google::Protobuf::Timestamp, ::Hash]
1539
+ # The time to seek to.
1540
+ # Messages retained in the subscription that were published before this
1541
+ # time are marked as acknowledged, and messages retained in the
1542
+ # subscription that were published after this time are marked as
1543
+ # unacknowledged. Note that this operation affects only those messages
1544
+ # retained in the subscription (configured by the combination of
1545
+ # `message_retention_duration` and `retain_acked_messages`). For example,
1546
+ # if `time` corresponds to a point before the message retention
1547
+ # window (or to a point before the system's notion of the subscription
1548
+ # creation time), only retained messages will be marked as unacknowledged,
1549
+ # and already-expunged messages will not be restored.
1550
+ # @param snapshot [::String]
1551
+ # The snapshot to seek to. The snapshot's topic must be the same as that of
1552
+ # the provided subscription.
1553
+ # Format is `projects/{project}/snapshots/{snap}`.
1554
+ #
1555
+ # @yield [response, operation] Access the result along with the RPC operation
1556
+ # @yieldparam response [::Google::Cloud::PubSub::V1::SeekResponse]
1557
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1558
+ #
1559
+ # @return [::Google::Cloud::PubSub::V1::SeekResponse]
1560
+ #
1561
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1562
+ #
1563
+ def seek request, options = nil
1564
+ raise ::ArgumentError, "request must be provided" if request.nil?
1565
+
1566
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::SeekRequest
1567
+
1568
+ # Converts hash and nil to an options object
1569
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1570
+
1571
+ # Customize the options with defaults
1572
+ metadata = @config.rpcs.seek.metadata.to_h
1573
+
1574
+ # Set x-goog-api-client and x-goog-user-project headers
1575
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1576
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1577
+ gapic_version: ::Google::Cloud::PubSub::V1::VERSION
1578
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1579
+
1580
+ header_params = {
1581
+ "subscription" => request.subscription
1582
+ }
1583
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1584
+ metadata[:"x-goog-request-params"] ||= request_params_header
1585
+
1586
+ options.apply_defaults timeout: @config.rpcs.seek.timeout,
1587
+ metadata: metadata,
1588
+ retry_policy: @config.rpcs.seek.retry_policy
1589
+ options.apply_defaults metadata: @config.metadata,
1590
+ retry_policy: @config.retry_policy
1591
+
1592
+ @subscriber_stub.call_rpc :seek, request, options: options do |response, operation|
1593
+ yield response, operation if block_given?
1594
+ return response
1595
+ end
1596
+ rescue ::GRPC::BadStatus => e
1597
+ raise ::Google::Cloud::Error.from_error(e)
1598
+ end
1599
+
1600
+ ##
1601
+ # Configuration class for the Subscriber API.
1602
+ #
1603
+ # This class represents the configuration for Subscriber,
1604
+ # providing control over timeouts, retry behavior, logging, transport
1605
+ # parameters, and other low-level controls. Certain parameters can also be
1606
+ # applied individually to specific RPCs. See
1607
+ # {::Google::Cloud::PubSub::V1::Subscriber::Client::Configuration::Rpcs}
1608
+ # for a list of RPCs that can be configured independently.
1609
+ #
1610
+ # Configuration can be applied globally to all clients, or to a single client
1611
+ # on construction.
1612
+ #
1613
+ # # Examples
1614
+ #
1615
+ # To modify the global config, setting the timeout for create_subscription
1616
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
1617
+ #
1618
+ # ::Google::Cloud::PubSub::V1::Subscriber::Client.configure do |config|
1619
+ # config.timeout = 10.0
1620
+ # config.rpcs.create_subscription.timeout = 20.0
1621
+ # end
1622
+ #
1623
+ # To apply the above configuration only to a new client:
1624
+ #
1625
+ # client = ::Google::Cloud::PubSub::V1::Subscriber::Client.new do |config|
1626
+ # config.timeout = 10.0
1627
+ # config.rpcs.create_subscription.timeout = 20.0
1628
+ # end
1629
+ #
1630
+ # @!attribute [rw] endpoint
1631
+ # The hostname or hostname:port of the service endpoint.
1632
+ # Defaults to `"pubsub.googleapis.com"`.
1633
+ # @return [::String]
1634
+ # @!attribute [rw] credentials
1635
+ # Credentials to send with calls. You may provide any of the following types:
1636
+ # * (`String`) The path to a service account key file in JSON format
1637
+ # * (`Hash`) A service account key as a Hash
1638
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
1639
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
1640
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
1641
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
1642
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
1643
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
1644
+ # * (`nil`) indicating no credentials
1645
+ # @return [::Object]
1646
+ # @!attribute [rw] scope
1647
+ # The OAuth scopes
1648
+ # @return [::Array<::String>]
1649
+ # @!attribute [rw] lib_name
1650
+ # The library name as recorded in instrumentation and logging
1651
+ # @return [::String]
1652
+ # @!attribute [rw] lib_version
1653
+ # The library version as recorded in instrumentation and logging
1654
+ # @return [::String]
1655
+ # @!attribute [rw] channel_args
1656
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
1657
+ # `GRPC::Core::Channel` object is provided as the credential.
1658
+ # @return [::Hash]
1659
+ # @!attribute [rw] interceptors
1660
+ # An array of interceptors that are run before calls are executed.
1661
+ # @return [::Array<::GRPC::ClientInterceptor>]
1662
+ # @!attribute [rw] timeout
1663
+ # The call timeout in seconds.
1664
+ # @return [::Numeric]
1665
+ # @!attribute [rw] metadata
1666
+ # Additional gRPC headers to be sent with the call.
1667
+ # @return [::Hash{::Symbol=>::String}]
1668
+ # @!attribute [rw] retry_policy
1669
+ # The retry policy. The value is a hash with the following keys:
1670
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1671
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1672
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1673
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1674
+ # trigger a retry.
1675
+ # @return [::Hash]
1676
+ # @!attribute [rw] quota_project
1677
+ # A separate project against which to charge quota.
1678
+ # @return [::String]
1679
+ #
1680
+ class Configuration
1681
+ extend ::Gapic::Config
1682
+
1683
+ config_attr :endpoint, "pubsub.googleapis.com", ::String
1684
+ config_attr :credentials, nil do |value|
1685
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1686
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
1687
+ allowed.any? { |klass| klass === value }
1688
+ end
1689
+ config_attr :scope, nil, ::String, ::Array, nil
1690
+ config_attr :lib_name, nil, ::String, nil
1691
+ config_attr :lib_version, nil, ::String, nil
1692
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
1693
+ config_attr :interceptors, nil, ::Array, nil
1694
+ config_attr :timeout, nil, ::Numeric, nil
1695
+ config_attr :metadata, nil, ::Hash, nil
1696
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1697
+ config_attr :quota_project, nil, ::String, nil
1698
+
1699
+ # @private
1700
+ def initialize parent_config = nil
1701
+ @parent_config = parent_config unless parent_config.nil?
1702
+
1703
+ yield self if block_given?
1704
+ end
1705
+
1706
+ ##
1707
+ # Configurations for individual RPCs
1708
+ # @return [Rpcs]
1709
+ #
1710
+ def rpcs
1711
+ @rpcs ||= begin
1712
+ parent_rpcs = nil
1713
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
1714
+ Rpcs.new parent_rpcs
1715
+ end
1716
+ end
1717
+
1718
+ ##
1719
+ # Configuration RPC class for the Subscriber API.
1720
+ #
1721
+ # Includes fields providing the configuration for each RPC in this service.
1722
+ # Each configuration object is of type `Gapic::Config::Method` and includes
1723
+ # the following configuration fields:
1724
+ #
1725
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
1726
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
1727
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1728
+ # include the following keys:
1729
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1730
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1731
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1732
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1733
+ # trigger a retry.
1734
+ #
1735
+ class Rpcs
1736
+ ##
1737
+ # RPC-specific configuration for `create_subscription`
1738
+ # @return [::Gapic::Config::Method]
1739
+ #
1740
+ attr_reader :create_subscription
1741
+ ##
1742
+ # RPC-specific configuration for `get_subscription`
1743
+ # @return [::Gapic::Config::Method]
1744
+ #
1745
+ attr_reader :get_subscription
1746
+ ##
1747
+ # RPC-specific configuration for `update_subscription`
1748
+ # @return [::Gapic::Config::Method]
1749
+ #
1750
+ attr_reader :update_subscription
1751
+ ##
1752
+ # RPC-specific configuration for `list_subscriptions`
1753
+ # @return [::Gapic::Config::Method]
1754
+ #
1755
+ attr_reader :list_subscriptions
1756
+ ##
1757
+ # RPC-specific configuration for `delete_subscription`
1758
+ # @return [::Gapic::Config::Method]
1759
+ #
1760
+ attr_reader :delete_subscription
1761
+ ##
1762
+ # RPC-specific configuration for `modify_ack_deadline`
1763
+ # @return [::Gapic::Config::Method]
1764
+ #
1765
+ attr_reader :modify_ack_deadline
1766
+ ##
1767
+ # RPC-specific configuration for `acknowledge`
1768
+ # @return [::Gapic::Config::Method]
1769
+ #
1770
+ attr_reader :acknowledge
1771
+ ##
1772
+ # RPC-specific configuration for `pull`
1773
+ # @return [::Gapic::Config::Method]
1774
+ #
1775
+ attr_reader :pull
1776
+ ##
1777
+ # RPC-specific configuration for `streaming_pull`
1778
+ # @return [::Gapic::Config::Method]
1779
+ #
1780
+ attr_reader :streaming_pull
1781
+ ##
1782
+ # RPC-specific configuration for `modify_push_config`
1783
+ # @return [::Gapic::Config::Method]
1784
+ #
1785
+ attr_reader :modify_push_config
1786
+ ##
1787
+ # RPC-specific configuration for `get_snapshot`
1788
+ # @return [::Gapic::Config::Method]
1789
+ #
1790
+ attr_reader :get_snapshot
1791
+ ##
1792
+ # RPC-specific configuration for `list_snapshots`
1793
+ # @return [::Gapic::Config::Method]
1794
+ #
1795
+ attr_reader :list_snapshots
1796
+ ##
1797
+ # RPC-specific configuration for `create_snapshot`
1798
+ # @return [::Gapic::Config::Method]
1799
+ #
1800
+ attr_reader :create_snapshot
1801
+ ##
1802
+ # RPC-specific configuration for `update_snapshot`
1803
+ # @return [::Gapic::Config::Method]
1804
+ #
1805
+ attr_reader :update_snapshot
1806
+ ##
1807
+ # RPC-specific configuration for `delete_snapshot`
1808
+ # @return [::Gapic::Config::Method]
1809
+ #
1810
+ attr_reader :delete_snapshot
1811
+ ##
1812
+ # RPC-specific configuration for `seek`
1813
+ # @return [::Gapic::Config::Method]
1814
+ #
1815
+ attr_reader :seek
1816
+
1817
+ # @private
1818
+ def initialize parent_rpcs = nil
1819
+ create_subscription_config = parent_rpcs&.create_subscription if parent_rpcs&.respond_to? :create_subscription
1820
+ @create_subscription = ::Gapic::Config::Method.new create_subscription_config
1821
+ get_subscription_config = parent_rpcs&.get_subscription if parent_rpcs&.respond_to? :get_subscription
1822
+ @get_subscription = ::Gapic::Config::Method.new get_subscription_config
1823
+ update_subscription_config = parent_rpcs&.update_subscription if parent_rpcs&.respond_to? :update_subscription
1824
+ @update_subscription = ::Gapic::Config::Method.new update_subscription_config
1825
+ list_subscriptions_config = parent_rpcs&.list_subscriptions if parent_rpcs&.respond_to? :list_subscriptions
1826
+ @list_subscriptions = ::Gapic::Config::Method.new list_subscriptions_config
1827
+ delete_subscription_config = parent_rpcs&.delete_subscription if parent_rpcs&.respond_to? :delete_subscription
1828
+ @delete_subscription = ::Gapic::Config::Method.new delete_subscription_config
1829
+ modify_ack_deadline_config = parent_rpcs&.modify_ack_deadline if parent_rpcs&.respond_to? :modify_ack_deadline
1830
+ @modify_ack_deadline = ::Gapic::Config::Method.new modify_ack_deadline_config
1831
+ acknowledge_config = parent_rpcs&.acknowledge if parent_rpcs&.respond_to? :acknowledge
1832
+ @acknowledge = ::Gapic::Config::Method.new acknowledge_config
1833
+ pull_config = parent_rpcs&.pull if parent_rpcs&.respond_to? :pull
1834
+ @pull = ::Gapic::Config::Method.new pull_config
1835
+ streaming_pull_config = parent_rpcs&.streaming_pull if parent_rpcs&.respond_to? :streaming_pull
1836
+ @streaming_pull = ::Gapic::Config::Method.new streaming_pull_config
1837
+ modify_push_config_config = parent_rpcs&.modify_push_config if parent_rpcs&.respond_to? :modify_push_config
1838
+ @modify_push_config = ::Gapic::Config::Method.new modify_push_config_config
1839
+ get_snapshot_config = parent_rpcs&.get_snapshot if parent_rpcs&.respond_to? :get_snapshot
1840
+ @get_snapshot = ::Gapic::Config::Method.new get_snapshot_config
1841
+ list_snapshots_config = parent_rpcs&.list_snapshots if parent_rpcs&.respond_to? :list_snapshots
1842
+ @list_snapshots = ::Gapic::Config::Method.new list_snapshots_config
1843
+ create_snapshot_config = parent_rpcs&.create_snapshot if parent_rpcs&.respond_to? :create_snapshot
1844
+ @create_snapshot = ::Gapic::Config::Method.new create_snapshot_config
1845
+ update_snapshot_config = parent_rpcs&.update_snapshot if parent_rpcs&.respond_to? :update_snapshot
1846
+ @update_snapshot = ::Gapic::Config::Method.new update_snapshot_config
1847
+ delete_snapshot_config = parent_rpcs&.delete_snapshot if parent_rpcs&.respond_to? :delete_snapshot
1848
+ @delete_snapshot = ::Gapic::Config::Method.new delete_snapshot_config
1849
+ seek_config = parent_rpcs&.seek if parent_rpcs&.respond_to? :seek
1850
+ @seek = ::Gapic::Config::Method.new seek_config
1851
+
1852
+ yield self if block_given?
1853
+ end
1854
+ end
1855
+ end
1856
+ end
1857
+ end
1858
+ end
1859
+ end
1860
+ end
1861
+ end