google-cloud-pubsub 1.7.0 → 2.0.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 (31) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +2 -1
  3. data/CHANGELOG.md +47 -0
  4. data/TROUBLESHOOTING.md +2 -8
  5. data/lib/google-cloud-pubsub.rb +13 -13
  6. data/lib/google/cloud/pubsub.rb +15 -18
  7. data/lib/google/cloud/pubsub/async_publisher.rb +1 -2
  8. data/lib/google/cloud/pubsub/credentials.rb +2 -2
  9. data/lib/google/cloud/pubsub/service.rb +110 -255
  10. data/lib/google/cloud/pubsub/subscriber/stream.rb +3 -2
  11. data/lib/google/cloud/pubsub/subscription.rb +70 -3
  12. data/lib/google/cloud/pubsub/topic.rb +7 -3
  13. data/lib/google/cloud/pubsub/version.rb +1 -1
  14. metadata +8 -79
  15. data/lib/google/cloud/pubsub/v1.rb +0 -17
  16. data/lib/google/cloud/pubsub/v1/credentials.rb +0 -41
  17. data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/iam_policy.rb +0 -21
  18. data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/options.rb +0 -21
  19. data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/policy.rb +0 -21
  20. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/duration.rb +0 -91
  21. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/empty.rb +0 -29
  22. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/field_mask.rb +0 -222
  23. data/lib/google/cloud/pubsub/v1/doc/google/protobuf/timestamp.rb +0 -113
  24. data/lib/google/cloud/pubsub/v1/doc/google/pubsub/v1/pubsub.rb +0 -796
  25. data/lib/google/cloud/pubsub/v1/doc/google/type/expr.rb +0 -19
  26. data/lib/google/cloud/pubsub/v1/publisher_client.rb +0 -869
  27. data/lib/google/cloud/pubsub/v1/publisher_client_config.json +0 -114
  28. data/lib/google/cloud/pubsub/v1/subscriber_client.rb +0 -1463
  29. data/lib/google/cloud/pubsub/v1/subscriber_client_config.json +0 -153
  30. data/lib/google/pubsub/v1/pubsub_pb.rb +0 -259
  31. data/lib/google/pubsub/v1/pubsub_services_pb.rb +0 -210
@@ -1,19 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Type
18
- end
19
- end
@@ -1,869 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
- # EDITING INSTRUCTIONS
16
- # This file was generated from the file
17
- # https://github.com/googleapis/googleapis/blob/master/google/pubsub/v1/pubsub.proto,
18
- # and updates to that file get reflected here through a refresh process.
19
- # For the short term, the refresh process will only be runnable by Google
20
- # engineers.
21
-
22
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
-
28
- require "google/iam/v1/iam_policy_pb"
29
- require "google/pubsub/v1/pubsub_pb"
30
- require "google/cloud/pubsub/v1/credentials"
31
- require "google/cloud/pubsub/version"
32
-
33
- module Google
34
- module Cloud
35
- module PubSub
36
- module V1
37
- # The service that an application uses to manipulate topics, and to send
38
- # messages to a topic.
39
- #
40
- # @!attribute [r] iam_policy_stub
41
- # @return [Google::Iam::V1::IAMPolicy::Stub]
42
- # @!attribute [r] publisher_stub
43
- # @return [Google::Cloud::PubSub::V1::Publisher::Stub]
44
- class PublisherClient
45
- # @private
46
- attr_reader :iam_policy_stub, :publisher_stub
47
-
48
- # The default address of the service.
49
- SERVICE_ADDRESS = "pubsub.googleapis.com".freeze
50
-
51
- # The default port of the service.
52
- DEFAULT_SERVICE_PORT = 443
53
-
54
- # The default set of gRPC interceptors.
55
- GRPC_INTERCEPTORS = []
56
-
57
- DEFAULT_TIMEOUT = 30
58
-
59
- PAGE_DESCRIPTORS = {
60
- "list_topics" => Google::Gax::PageDescriptor.new(
61
- "page_token",
62
- "next_page_token",
63
- "topics"),
64
- "list_topic_subscriptions" => Google::Gax::PageDescriptor.new(
65
- "page_token",
66
- "next_page_token",
67
- "subscriptions"),
68
- "list_topic_snapshots" => Google::Gax::PageDescriptor.new(
69
- "page_token",
70
- "next_page_token",
71
- "snapshots")
72
- }.freeze
73
-
74
- private_constant :PAGE_DESCRIPTORS
75
-
76
- BUNDLE_DESCRIPTORS = {
77
- "publish" => Google::Gax::BundleDescriptor.new(
78
- "messages",
79
- [
80
- "topic"
81
- ],
82
- subresponse_field: "message_ids")
83
- }.freeze
84
-
85
- private_constant :BUNDLE_DESCRIPTORS
86
-
87
- # The scopes needed to make gRPC calls to all of the methods defined in
88
- # this service.
89
- ALL_SCOPES = [
90
- "https://www.googleapis.com/auth/cloud-platform",
91
- "https://www.googleapis.com/auth/pubsub"
92
- ].freeze
93
-
94
-
95
- PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
96
- "projects/{project}"
97
- )
98
-
99
- private_constant :PROJECT_PATH_TEMPLATE
100
-
101
- TOPIC_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
102
- "projects/{project}/topics/{topic}"
103
- )
104
-
105
- private_constant :TOPIC_PATH_TEMPLATE
106
-
107
- # Returns a fully-qualified project resource name string.
108
- # @param project [String]
109
- # @return [String]
110
- def self.project_path project
111
- PROJECT_PATH_TEMPLATE.render(
112
- :"project" => project
113
- )
114
- end
115
-
116
- # Returns a fully-qualified topic resource name string.
117
- # @param project [String]
118
- # @param topic [String]
119
- # @return [String]
120
- def self.topic_path project, topic
121
- TOPIC_PATH_TEMPLATE.render(
122
- :"project" => project,
123
- :"topic" => topic
124
- )
125
- end
126
-
127
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
128
- # Provides the means for authenticating requests made by the client. This parameter can
129
- # be many types.
130
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
131
- # authenticating requests made by this client.
132
- # A `String` will be treated as the path to the keyfile to be used for the construction of
133
- # credentials for this client.
134
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
135
- # credentials for this client.
136
- # A `GRPC::Core::Channel` will be used to make calls through.
137
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
138
- # should already be composed with a `GRPC::Core::CallCredentials` object.
139
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
140
- # metadata for requests, generally, to give OAuth credentials.
141
- # @param scopes [Array<String>]
142
- # The OAuth scopes for this service. This parameter is ignored if
143
- # an updater_proc is supplied.
144
- # @param client_config [Hash]
145
- # A Hash for call options for each method. See
146
- # Google::Gax#construct_settings for the structure of
147
- # this data. Falls back to the default config if not specified
148
- # or the specified config is missing data points.
149
- # @param timeout [Numeric]
150
- # The default timeout, in seconds, for calls made through this client.
151
- # @param metadata [Hash]
152
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
153
- # @param service_address [String]
154
- # Override for the service hostname, or `nil` to leave as the default.
155
- # @param service_port [Integer]
156
- # Override for the service port, or `nil` to leave as the default.
157
- # @param exception_transformer [Proc]
158
- # An optional proc that intercepts any exceptions raised during an API call to inject
159
- # custom error handling.
160
- def initialize \
161
- credentials: nil,
162
- scopes: ALL_SCOPES,
163
- client_config: {},
164
- timeout: DEFAULT_TIMEOUT,
165
- metadata: nil,
166
- service_address: nil,
167
- service_port: nil,
168
- exception_transformer: nil,
169
- lib_name: nil,
170
- lib_version: ""
171
- # These require statements are intentionally placed here to initialize
172
- # the gRPC module only when it's required.
173
- # See https://github.com/googleapis/toolkit/issues/446
174
- require "google/gax/grpc"
175
- require "google/iam/v1/iam_policy_services_pb"
176
- require "google/pubsub/v1/pubsub_services_pb"
177
-
178
- credentials ||= Google::Cloud::PubSub::V1::Credentials.default
179
-
180
- if credentials.is_a?(String) || credentials.is_a?(Hash)
181
- updater_proc = Google::Cloud::PubSub::V1::Credentials.new(credentials).updater_proc
182
- end
183
- if credentials.is_a?(GRPC::Core::Channel)
184
- channel = credentials
185
- end
186
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
187
- chan_creds = credentials
188
- end
189
- if credentials.is_a?(Proc)
190
- updater_proc = credentials
191
- end
192
- if credentials.is_a?(Google::Auth::Credentials)
193
- updater_proc = credentials.updater_proc
194
- end
195
-
196
- package_version = Google::Cloud::PubSub::VERSION
197
-
198
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
199
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
200
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
201
- google_api_client << " grpc/#{GRPC::VERSION}"
202
- google_api_client.freeze
203
-
204
- headers = { :"x-goog-api-client" => google_api_client }
205
- if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
206
- headers[:"x-goog-user-project"] = credentials.quota_project_id
207
- end
208
- headers.merge!(metadata) unless metadata.nil?
209
- client_config_file = Pathname.new(__dir__).join(
210
- "publisher_client_config.json"
211
- )
212
- defaults = client_config_file.open do |f|
213
- Google::Gax.construct_settings(
214
- "google.pubsub.v1.Publisher",
215
- JSON.parse(f.read),
216
- client_config,
217
- Google::Gax::Grpc::STATUS_CODE_NAMES,
218
- timeout,
219
- bundle_descriptors: BUNDLE_DESCRIPTORS,
220
- page_descriptors: PAGE_DESCRIPTORS,
221
- errors: Google::Gax::Grpc::API_ERRORS,
222
- metadata: headers
223
- )
224
- end
225
-
226
- # Allow overriding the service path/port in subclasses.
227
- service_path = service_address || self.class::SERVICE_ADDRESS
228
- port = service_port || self.class::DEFAULT_SERVICE_PORT
229
- interceptors = self.class::GRPC_INTERCEPTORS
230
- @iam_policy_stub = Google::Gax::Grpc.create_stub(
231
- service_path,
232
- port,
233
- chan_creds: chan_creds,
234
- channel: channel,
235
- updater_proc: updater_proc,
236
- scopes: scopes,
237
- interceptors: interceptors,
238
- &Google::Iam::V1::IAMPolicy::Stub.method(:new)
239
- )
240
- @publisher_stub = Google::Gax::Grpc.create_stub(
241
- service_path,
242
- port,
243
- chan_creds: chan_creds,
244
- channel: channel,
245
- updater_proc: updater_proc,
246
- scopes: scopes,
247
- interceptors: interceptors,
248
- &Google::Cloud::PubSub::V1::Publisher::Stub.method(:new)
249
- )
250
-
251
- @create_topic = Google::Gax.create_api_call(
252
- @publisher_stub.method(:create_topic),
253
- defaults["create_topic"],
254
- exception_transformer: exception_transformer,
255
- params_extractor: proc do |request|
256
- {'name' => request.name}
257
- end
258
- )
259
- @update_topic = Google::Gax.create_api_call(
260
- @publisher_stub.method(:update_topic),
261
- defaults["update_topic"],
262
- exception_transformer: exception_transformer,
263
- params_extractor: proc do |request|
264
- {'topic.name' => request.topic.name}
265
- end
266
- )
267
- @publish = Google::Gax.create_api_call(
268
- @publisher_stub.method(:publish),
269
- defaults["publish"],
270
- exception_transformer: exception_transformer,
271
- params_extractor: proc do |request|
272
- {'topic' => request.topic}
273
- end
274
- )
275
- @get_topic = Google::Gax.create_api_call(
276
- @publisher_stub.method(:get_topic),
277
- defaults["get_topic"],
278
- exception_transformer: exception_transformer,
279
- params_extractor: proc do |request|
280
- {'topic' => request.topic}
281
- end
282
- )
283
- @list_topics = Google::Gax.create_api_call(
284
- @publisher_stub.method(:list_topics),
285
- defaults["list_topics"],
286
- exception_transformer: exception_transformer,
287
- params_extractor: proc do |request|
288
- {'project' => request.project}
289
- end
290
- )
291
- @list_topic_subscriptions = Google::Gax.create_api_call(
292
- @publisher_stub.method(:list_topic_subscriptions),
293
- defaults["list_topic_subscriptions"],
294
- exception_transformer: exception_transformer,
295
- params_extractor: proc do |request|
296
- {'topic' => request.topic}
297
- end
298
- )
299
- @list_topic_snapshots = Google::Gax.create_api_call(
300
- @publisher_stub.method(:list_topic_snapshots),
301
- defaults["list_topic_snapshots"],
302
- exception_transformer: exception_transformer,
303
- params_extractor: proc do |request|
304
- {'topic' => request.topic}
305
- end
306
- )
307
- @delete_topic = Google::Gax.create_api_call(
308
- @publisher_stub.method(:delete_topic),
309
- defaults["delete_topic"],
310
- exception_transformer: exception_transformer,
311
- params_extractor: proc do |request|
312
- {'topic' => request.topic}
313
- end
314
- )
315
- @set_iam_policy = Google::Gax.create_api_call(
316
- @iam_policy_stub.method(:set_iam_policy),
317
- defaults["set_iam_policy"],
318
- exception_transformer: exception_transformer,
319
- params_extractor: proc do |request|
320
- {'resource' => request.resource}
321
- end
322
- )
323
- @get_iam_policy = Google::Gax.create_api_call(
324
- @iam_policy_stub.method(:get_iam_policy),
325
- defaults["get_iam_policy"],
326
- exception_transformer: exception_transformer,
327
- params_extractor: proc do |request|
328
- {'resource' => request.resource}
329
- end
330
- )
331
- @test_iam_permissions = Google::Gax.create_api_call(
332
- @iam_policy_stub.method(:test_iam_permissions),
333
- defaults["test_iam_permissions"],
334
- exception_transformer: exception_transformer,
335
- params_extractor: proc do |request|
336
- {'resource' => request.resource}
337
- end
338
- )
339
- end
340
-
341
- # Service calls
342
-
343
- # Creates the given topic with the given name. See the
344
- # <a href="https://cloud.google.com/pubsub/docs/admin#resource_names">
345
- # resource name rules</a>.
346
- #
347
- # @param name [String]
348
- # Required. The name of the topic. It must have the format
349
- # `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
350
- # and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
351
- # underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
352
- # signs (`%`). It must be between 3 and 255 characters in length, and it
353
- # must not start with `"goog"`.
354
- # @param labels [Hash{String => String}]
355
- # See <a href="https://cloud.google.com/pubsub/docs/labels"> Creating and
356
- # managing labels</a>.
357
- # @param message_storage_policy [Google::Cloud::PubSub::V1::MessageStoragePolicy | Hash]
358
- # Policy constraining the set of Google Cloud Platform regions where messages
359
- # published to the topic may be stored. If not present, then no constraints
360
- # are in effect.
361
- # A hash of the same form as `Google::Cloud::PubSub::V1::MessageStoragePolicy`
362
- # can also be provided.
363
- # @param kms_key_name [String]
364
- # The resource name of the Cloud KMS CryptoKey to be used to protect access
365
- # to messages published on this topic.
366
- #
367
- # The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
368
- # @param options [Google::Gax::CallOptions]
369
- # Overrides the default settings for this call, e.g, timeout,
370
- # retries, etc.
371
- # @yield [result, operation] Access the result along with the RPC operation
372
- # @yieldparam result [Google::Cloud::PubSub::V1::Topic]
373
- # @yieldparam operation [GRPC::ActiveCall::Operation]
374
- # @return [Google::Cloud::PubSub::V1::Topic]
375
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
376
- # @example
377
- # require "google/cloud/pubsub"
378
- #
379
- # publisher_client = Google::Cloud::PubSub::Publisher.new(version: :v1)
380
- # formatted_name = Google::Cloud::PubSub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
381
- # response = publisher_client.create_topic(formatted_name)
382
-
383
- def create_topic \
384
- name,
385
- labels: nil,
386
- message_storage_policy: nil,
387
- kms_key_name: nil,
388
- options: nil,
389
- &block
390
- req = {
391
- name: name,
392
- labels: labels,
393
- message_storage_policy: message_storage_policy,
394
- kms_key_name: kms_key_name
395
- }.delete_if { |_, v| v.nil? }
396
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::Topic)
397
- @create_topic.call(req, options, &block)
398
- end
399
-
400
- # Updates an existing topic. Note that certain properties of a
401
- # topic are not modifiable.
402
- #
403
- # @param topic [Google::Cloud::PubSub::V1::Topic | Hash]
404
- # Required. The updated topic object.
405
- # A hash of the same form as `Google::Cloud::PubSub::V1::Topic`
406
- # can also be provided.
407
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
408
- # Required. Indicates which fields in the provided topic to update. Must be
409
- # specified and non-empty. Note that if `update_mask` contains
410
- # "message_storage_policy" but the `message_storage_policy` is not set in
411
- # the `topic` provided above, then the updated value is determined by the
412
- # policy configured at the project or organization level.
413
- # A hash of the same form as `Google::Protobuf::FieldMask`
414
- # can also be provided.
415
- # @param options [Google::Gax::CallOptions]
416
- # Overrides the default settings for this call, e.g, timeout,
417
- # retries, etc.
418
- # @yield [result, operation] Access the result along with the RPC operation
419
- # @yieldparam result [Google::Cloud::PubSub::V1::Topic]
420
- # @yieldparam operation [GRPC::ActiveCall::Operation]
421
- # @return [Google::Cloud::PubSub::V1::Topic]
422
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
423
- # @example
424
- # require "google/cloud/pubsub"
425
- #
426
- # publisher_client = Google::Cloud::PubSub::Publisher.new(version: :v1)
427
- #
428
- # # TODO: Initialize `topic`:
429
- # topic = {}
430
- #
431
- # # TODO: Initialize `update_mask`:
432
- # update_mask = {}
433
- # response = publisher_client.update_topic(topic, update_mask)
434
-
435
- def update_topic \
436
- topic,
437
- update_mask,
438
- options: nil,
439
- &block
440
- req = {
441
- topic: topic,
442
- update_mask: update_mask
443
- }.delete_if { |_, v| v.nil? }
444
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::UpdateTopicRequest)
445
- @update_topic.call(req, options, &block)
446
- end
447
-
448
- # Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic
449
- # does not exist.
450
- #
451
- # @param topic [String]
452
- # Required. The messages in the request will be published on this topic.
453
- # Format is `projects/{project}/topics/{topic}`.
454
- # @param messages [Array<Google::Cloud::PubSub::V1::PubsubMessage | Hash>]
455
- # Required. The messages to publish.
456
- # A hash of the same form as `Google::Cloud::PubSub::V1::PubsubMessage`
457
- # can also be provided.
458
- # @param options [Google::Gax::CallOptions]
459
- # Overrides the default settings for this call, e.g, timeout,
460
- # retries, etc.
461
- # @yield [result, operation] Access the result along with the RPC operation
462
- # @yieldparam result [Google::Cloud::PubSub::V1::PublishResponse]
463
- # @yieldparam operation [GRPC::ActiveCall::Operation]
464
- # @return [Google::Cloud::PubSub::V1::PublishResponse]
465
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
466
- # @example
467
- # require "google/cloud/pubsub"
468
- #
469
- # publisher_client = Google::Cloud::PubSub::Publisher.new(version: :v1)
470
- # formatted_topic = Google::Cloud::PubSub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
471
- # data = ''
472
- # messages_element = { data: data }
473
- # messages = [messages_element]
474
- # response = publisher_client.publish(formatted_topic, messages)
475
-
476
- def publish \
477
- topic,
478
- messages,
479
- options: nil,
480
- &block
481
- req = {
482
- topic: topic,
483
- messages: messages
484
- }.delete_if { |_, v| v.nil? }
485
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::PublishRequest)
486
- @publish.call(req, options, &block)
487
- end
488
-
489
- # Gets the configuration of a topic.
490
- #
491
- # @param topic [String]
492
- # Required. The name of the topic to get.
493
- # Format is `projects/{project}/topics/{topic}`.
494
- # @param options [Google::Gax::CallOptions]
495
- # Overrides the default settings for this call, e.g, timeout,
496
- # retries, etc.
497
- # @yield [result, operation] Access the result along with the RPC operation
498
- # @yieldparam result [Google::Cloud::PubSub::V1::Topic]
499
- # @yieldparam operation [GRPC::ActiveCall::Operation]
500
- # @return [Google::Cloud::PubSub::V1::Topic]
501
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
502
- # @example
503
- # require "google/cloud/pubsub"
504
- #
505
- # publisher_client = Google::Cloud::PubSub::Publisher.new(version: :v1)
506
- # formatted_topic = Google::Cloud::PubSub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
507
- # response = publisher_client.get_topic(formatted_topic)
508
-
509
- def get_topic \
510
- topic,
511
- options: nil,
512
- &block
513
- req = {
514
- topic: topic
515
- }.delete_if { |_, v| v.nil? }
516
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::GetTopicRequest)
517
- @get_topic.call(req, options, &block)
518
- end
519
-
520
- # Lists matching topics.
521
- #
522
- # @param project [String]
523
- # Required. The name of the project in which to list topics.
524
- # Format is `projects/{project-id}`.
525
- # @param page_size [Integer]
526
- # The maximum number of resources contained in the underlying API
527
- # response. If page streaming is performed per-resource, this
528
- # parameter does not affect the return value. If page streaming is
529
- # performed per-page, this determines the maximum number of
530
- # resources in a page.
531
- # @param options [Google::Gax::CallOptions]
532
- # Overrides the default settings for this call, e.g, timeout,
533
- # retries, etc.
534
- # @yield [result, operation] Access the result along with the RPC operation
535
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::PubSub::V1::Topic>]
536
- # @yieldparam operation [GRPC::ActiveCall::Operation]
537
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::PubSub::V1::Topic>]
538
- # An enumerable of Google::Cloud::PubSub::V1::Topic instances.
539
- # See Google::Gax::PagedEnumerable documentation for other
540
- # operations such as per-page iteration or access to the response
541
- # object.
542
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
543
- # @example
544
- # require "google/cloud/pubsub"
545
- #
546
- # publisher_client = Google::Cloud::PubSub::Publisher.new(version: :v1)
547
- # formatted_project = Google::Cloud::PubSub::V1::PublisherClient.project_path("[PROJECT]")
548
- #
549
- # # Iterate over all results.
550
- # publisher_client.list_topics(formatted_project).each do |element|
551
- # # Process element.
552
- # end
553
- #
554
- # # Or iterate over results one page at a time.
555
- # publisher_client.list_topics(formatted_project).each_page do |page|
556
- # # Process each page at a time.
557
- # page.each do |element|
558
- # # Process element.
559
- # end
560
- # end
561
-
562
- def list_topics \
563
- project,
564
- page_size: nil,
565
- options: nil,
566
- &block
567
- req = {
568
- project: project,
569
- page_size: page_size
570
- }.delete_if { |_, v| v.nil? }
571
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::ListTopicsRequest)
572
- @list_topics.call(req, options, &block)
573
- end
574
-
575
- # Lists the names of the subscriptions on this topic.
576
- #
577
- # @param topic [String]
578
- # Required. The name of the topic that subscriptions are attached to.
579
- # Format is `projects/{project}/topics/{topic}`.
580
- # @param page_size [Integer]
581
- # The maximum number of resources contained in the underlying API
582
- # response. If page streaming is performed per-resource, this
583
- # parameter does not affect the return value. If page streaming is
584
- # performed per-page, this determines the maximum number of
585
- # resources in a page.
586
- # @param options [Google::Gax::CallOptions]
587
- # Overrides the default settings for this call, e.g, timeout,
588
- # retries, etc.
589
- # @yield [result, operation] Access the result along with the RPC operation
590
- # @yieldparam result [Google::Gax::PagedEnumerable<String>]
591
- # @yieldparam operation [GRPC::ActiveCall::Operation]
592
- # @return [Google::Gax::PagedEnumerable<String>]
593
- # An enumerable of String instances.
594
- # See Google::Gax::PagedEnumerable documentation for other
595
- # operations such as per-page iteration or access to the response
596
- # object.
597
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
598
- # @example
599
- # require "google/cloud/pubsub"
600
- #
601
- # publisher_client = Google::Cloud::PubSub::Publisher.new(version: :v1)
602
- # formatted_topic = Google::Cloud::PubSub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
603
- #
604
- # # Iterate over all results.
605
- # publisher_client.list_topic_subscriptions(formatted_topic).each do |element|
606
- # # Process element.
607
- # end
608
- #
609
- # # Or iterate over results one page at a time.
610
- # publisher_client.list_topic_subscriptions(formatted_topic).each_page do |page|
611
- # # Process each page at a time.
612
- # page.each do |element|
613
- # # Process element.
614
- # end
615
- # end
616
-
617
- def list_topic_subscriptions \
618
- topic,
619
- page_size: nil,
620
- options: nil,
621
- &block
622
- req = {
623
- topic: topic,
624
- page_size: page_size
625
- }.delete_if { |_, v| v.nil? }
626
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::ListTopicSubscriptionsRequest)
627
- @list_topic_subscriptions.call(req, options, &block)
628
- end
629
-
630
- # Lists the names of the snapshots on this topic. Snapshots are used in
631
- # <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
632
- # operations, which allow
633
- # you to manage message acknowledgments in bulk. That is, you can set the
634
- # acknowledgment state of messages in an existing subscription to the state
635
- # captured by a snapshot.
636
- #
637
- # @param topic [String]
638
- # Required. The name of the topic that snapshots are attached to.
639
- # Format is `projects/{project}/topics/{topic}`.
640
- # @param page_size [Integer]
641
- # The maximum number of resources contained in the underlying API
642
- # response. If page streaming is performed per-resource, this
643
- # parameter does not affect the return value. If page streaming is
644
- # performed per-page, this determines the maximum number of
645
- # resources in a page.
646
- # @param options [Google::Gax::CallOptions]
647
- # Overrides the default settings for this call, e.g, timeout,
648
- # retries, etc.
649
- # @yield [result, operation] Access the result along with the RPC operation
650
- # @yieldparam result [Google::Gax::PagedEnumerable<String>]
651
- # @yieldparam operation [GRPC::ActiveCall::Operation]
652
- # @return [Google::Gax::PagedEnumerable<String>]
653
- # An enumerable of String instances.
654
- # See Google::Gax::PagedEnumerable documentation for other
655
- # operations such as per-page iteration or access to the response
656
- # object.
657
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
658
- # @example
659
- # require "google/cloud/pubsub"
660
- #
661
- # publisher_client = Google::Cloud::PubSub::Publisher.new(version: :v1)
662
- # formatted_topic = Google::Cloud::PubSub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
663
- #
664
- # # Iterate over all results.
665
- # publisher_client.list_topic_snapshots(formatted_topic).each do |element|
666
- # # Process element.
667
- # end
668
- #
669
- # # Or iterate over results one page at a time.
670
- # publisher_client.list_topic_snapshots(formatted_topic).each_page do |page|
671
- # # Process each page at a time.
672
- # page.each do |element|
673
- # # Process element.
674
- # end
675
- # end
676
-
677
- def list_topic_snapshots \
678
- topic,
679
- page_size: nil,
680
- options: nil,
681
- &block
682
- req = {
683
- topic: topic,
684
- page_size: page_size
685
- }.delete_if { |_, v| v.nil? }
686
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::ListTopicSnapshotsRequest)
687
- @list_topic_snapshots.call(req, options, &block)
688
- end
689
-
690
- # Deletes the topic with the given name. Returns `NOT_FOUND` if the topic
691
- # does not exist. After a topic is deleted, a new topic may be created with
692
- # the same name; this is an entirely new topic with none of the old
693
- # configuration or subscriptions. Existing subscriptions to this topic are
694
- # not deleted, but their `topic` field is set to `_deleted-topic_`.
695
- #
696
- # @param topic [String]
697
- # Required. Name of the topic to delete.
698
- # Format is `projects/{project}/topics/{topic}`.
699
- # @param options [Google::Gax::CallOptions]
700
- # Overrides the default settings for this call, e.g, timeout,
701
- # retries, etc.
702
- # @yield [result, operation] Access the result along with the RPC operation
703
- # @yieldparam result []
704
- # @yieldparam operation [GRPC::ActiveCall::Operation]
705
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
706
- # @example
707
- # require "google/cloud/pubsub"
708
- #
709
- # publisher_client = Google::Cloud::PubSub::Publisher.new(version: :v1)
710
- # formatted_topic = Google::Cloud::PubSub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
711
- # publisher_client.delete_topic(formatted_topic)
712
-
713
- def delete_topic \
714
- topic,
715
- options: nil,
716
- &block
717
- req = {
718
- topic: topic
719
- }.delete_if { |_, v| v.nil? }
720
- req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::DeleteTopicRequest)
721
- @delete_topic.call(req, options, &block)
722
- nil
723
- end
724
-
725
- # Sets the access control policy on the specified resource. Replaces
726
- # any existing policy.
727
- #
728
- # Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
729
- # errors.
730
- #
731
- # @param resource [String]
732
- # REQUIRED: The resource for which the policy is being specified.
733
- # See the operation documentation for the appropriate value for this field.
734
- # @param policy [Google::Iam::V1::Policy | Hash]
735
- # REQUIRED: The complete policy to be applied to the `resource`. The size of
736
- # the policy is limited to a few 10s of KB. An empty policy is a
737
- # valid policy but certain Cloud Platform services (such as Projects)
738
- # might reject them.
739
- # A hash of the same form as `Google::Iam::V1::Policy`
740
- # can also be provided.
741
- # @param options [Google::Gax::CallOptions]
742
- # Overrides the default settings for this call, e.g, timeout,
743
- # retries, etc.
744
- # @yield [result, operation] Access the result along with the RPC operation
745
- # @yieldparam result [Google::Iam::V1::Policy]
746
- # @yieldparam operation [GRPC::ActiveCall::Operation]
747
- # @return [Google::Iam::V1::Policy]
748
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
749
- # @example
750
- # require "google/cloud/pubsub"
751
- #
752
- # publisher_client = Google::Cloud::PubSub::Publisher.new(version: :v1)
753
- #
754
- # # TODO: Initialize `resource`:
755
- # resource = ''
756
- #
757
- # # TODO: Initialize `policy`:
758
- # policy = {}
759
- # response = publisher_client.set_iam_policy(resource, policy)
760
-
761
- def set_iam_policy \
762
- resource,
763
- policy,
764
- options: nil,
765
- &block
766
- req = {
767
- resource: resource,
768
- policy: policy
769
- }.delete_if { |_, v| v.nil? }
770
- req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
771
- @set_iam_policy.call(req, options, &block)
772
- end
773
-
774
- # Gets the access control policy for a resource. Returns an empty policy
775
- # if the resource exists and does not have a policy set.
776
- #
777
- # @param resource [String]
778
- # REQUIRED: The resource for which the policy is being requested.
779
- # See the operation documentation for the appropriate value for this field.
780
- # @param options_ [Google::Iam::V1::GetPolicyOptions | Hash]
781
- # OPTIONAL: A `GetPolicyOptions` object for specifying options to
782
- # `GetIamPolicy`. This field is only used by Cloud IAM.
783
- # A hash of the same form as `Google::Iam::V1::GetPolicyOptions`
784
- # can also be provided.
785
- # @param options [Google::Gax::CallOptions]
786
- # Overrides the default settings for this call, e.g, timeout,
787
- # retries, etc.
788
- # @yield [result, operation] Access the result along with the RPC operation
789
- # @yieldparam result [Google::Iam::V1::Policy]
790
- # @yieldparam operation [GRPC::ActiveCall::Operation]
791
- # @return [Google::Iam::V1::Policy]
792
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
793
- # @example
794
- # require "google/cloud/pubsub"
795
- #
796
- # publisher_client = Google::Cloud::PubSub::Publisher.new(version: :v1)
797
- #
798
- # # TODO: Initialize `resource`:
799
- # resource = ''
800
- # response = publisher_client.get_iam_policy(resource)
801
-
802
- def get_iam_policy \
803
- resource,
804
- options_: nil,
805
- options: nil,
806
- &block
807
- req = {
808
- resource: resource,
809
- options: options_
810
- }.delete_if { |_, v| v.nil? }
811
- req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
812
- @get_iam_policy.call(req, options, &block)
813
- end
814
-
815
- # Returns permissions that a caller has on the specified resource. If the
816
- # resource does not exist, this will return an empty set of
817
- # permissions, not a `NOT_FOUND` error.
818
- #
819
- # Note: This operation is designed to be used for building
820
- # permission-aware UIs and command-line tools, not for authorization
821
- # checking. This operation may "fail open" without warning.
822
- #
823
- # @param resource [String]
824
- # REQUIRED: The resource for which the policy detail is being requested.
825
- # See the operation documentation for the appropriate value for this field.
826
- # @param permissions [Array<String>]
827
- # The set of permissions to check for the `resource`. Permissions with
828
- # wildcards (such as '*' or 'storage.*') are not allowed. For more
829
- # information see
830
- # [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
831
- # @param options [Google::Gax::CallOptions]
832
- # Overrides the default settings for this call, e.g, timeout,
833
- # retries, etc.
834
- # @yield [result, operation] Access the result along with the RPC operation
835
- # @yieldparam result [Google::Iam::V1::TestIamPermissionsResponse]
836
- # @yieldparam operation [GRPC::ActiveCall::Operation]
837
- # @return [Google::Iam::V1::TestIamPermissionsResponse]
838
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
839
- # @example
840
- # require "google/cloud/pubsub"
841
- #
842
- # publisher_client = Google::Cloud::PubSub::Publisher.new(version: :v1)
843
- #
844
- # # TODO: Initialize `resource`:
845
- # resource = ''
846
- #
847
- # # TODO: Initialize `permissions`:
848
- # permissions = []
849
- # response = publisher_client.test_iam_permissions(resource, permissions)
850
-
851
- def test_iam_permissions \
852
- resource,
853
- permissions,
854
- options: nil,
855
- &block
856
- req = {
857
- resource: resource,
858
- permissions: permissions
859
- }.delete_if { |_, v| v.nil? }
860
- req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
861
- @test_iam_permissions.call(req, options, &block)
862
- end
863
- end
864
- end
865
- end
866
-
867
- Pubsub = PubSub unless const_defined? :Pubsub
868
- end
869
- end