google-cloud-pubsub 0.33.1 → 2.15.1

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