google-cloud-pubsub 0.27.2 → 0.28.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.
- checksums.yaml +5 -5
- data/README.md +2 -2
- data/lib/google-cloud-pubsub.rb +13 -10
- data/lib/google/cloud/pubsub.rb +31 -33
- data/lib/google/cloud/pubsub/credentials.rb +31 -5
- data/lib/google/cloud/pubsub/project.rb +6 -5
- data/lib/google/cloud/pubsub/service.rb +2 -2
- data/lib/google/cloud/pubsub/snapshot.rb +1 -1
- data/lib/google/cloud/pubsub/v1/doc/google/protobuf/duration.rb +14 -1
- data/lib/google/cloud/pubsub/v1/doc/google/protobuf/timestamp.rb +26 -1
- data/lib/google/cloud/pubsub/v1/doc/google/pubsub/v1/pubsub.rb +43 -1
- data/lib/google/cloud/pubsub/v1/doc/overview.rb +75 -0
- data/lib/google/cloud/pubsub/v1/publisher_client.rb +163 -107
- data/lib/google/cloud/pubsub/v1/publisher_client_config.json +9 -4
- data/lib/google/cloud/pubsub/v1/subscriber_client.rb +237 -205
- data/lib/google/cloud/pubsub/v1/subscriber_client_config.json +6 -1
- data/lib/google/cloud/pubsub/version.rb +1 -1
- data/lib/google/pubsub/v1/pubsub_pb.rb +14 -1
- data/lib/google/pubsub/v1/pubsub_services_pb.rb +18 -0
- metadata +10 -23
@@ -0,0 +1,75 @@
|
|
1
|
+
# Copyright 2017, Google Inc. All rights reserved.
|
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
|
+
# http://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
|
+
module Google
|
16
|
+
module Cloud
|
17
|
+
# rubocop:disable LineLength
|
18
|
+
|
19
|
+
##
|
20
|
+
# # Ruby Client for Google Cloud Pub/Sub API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-ruby#versioning))
|
21
|
+
#
|
22
|
+
# [Google Cloud Pub/Sub API][Product Documentation]:
|
23
|
+
# Provides reliable, many-to-many, asynchronous messaging between applications.
|
24
|
+
# - [Product Documentation][]
|
25
|
+
#
|
26
|
+
# ## Quick Start
|
27
|
+
# In order to use this library, you first need to go through the following
|
28
|
+
# steps:
|
29
|
+
#
|
30
|
+
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
31
|
+
# 2. [Enable the Google Cloud Pub/Sub API.](https://console.cloud.google.com/apis/api/pubsub)
|
32
|
+
# 3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
33
|
+
#
|
34
|
+
# ### Installation
|
35
|
+
# ```
|
36
|
+
# $ gem install google-cloud-pubsub
|
37
|
+
# ```
|
38
|
+
#
|
39
|
+
# ### Preview
|
40
|
+
# #### PublisherClient
|
41
|
+
# ```rb
|
42
|
+
# require "google/cloud/pubsub"
|
43
|
+
#
|
44
|
+
# publisher_client = Google::Cloud::Pubsub::Publisher.new
|
45
|
+
# formatted_project = Google::Cloud::Pubsub::V1::PublisherClient.project_path(project_id)
|
46
|
+
#
|
47
|
+
# # Iterate over all results.
|
48
|
+
# publisher_client.list_topics(formatted_project).each do |element|
|
49
|
+
# # Process element.
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# # Or iterate over results one page at a time.
|
53
|
+
# publisher_client.list_topics(formatted_project).each_page do |page|
|
54
|
+
# # Process each page at a time.
|
55
|
+
# page.each do |element|
|
56
|
+
# # Process element.
|
57
|
+
# end
|
58
|
+
# end
|
59
|
+
# ```
|
60
|
+
#
|
61
|
+
# ### Next Steps
|
62
|
+
# - Read the [Google Cloud Pub/Sub API Product documentation][Product Documentation]
|
63
|
+
# to learn more about the product and see How-to Guides.
|
64
|
+
# - View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/README.md)
|
65
|
+
# to see the full list of Cloud APIs that we cover.
|
66
|
+
#
|
67
|
+
# [Product Documentation]: https://cloud.google.com/pubsub
|
68
|
+
#
|
69
|
+
#
|
70
|
+
module Pubsub
|
71
|
+
module V1
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -29,6 +29,7 @@ require "google/gax"
|
|
29
29
|
|
30
30
|
require "google/iam/v1/iam_policy_pb"
|
31
31
|
require "google/pubsub/v1/pubsub_pb"
|
32
|
+
require "google/cloud/pubsub/credentials"
|
32
33
|
|
33
34
|
module Google
|
34
35
|
module Cloud
|
@@ -115,36 +116,24 @@ module Google
|
|
115
116
|
)
|
116
117
|
end
|
117
118
|
|
118
|
-
#
|
119
|
-
#
|
120
|
-
#
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
#
|
133
|
-
#
|
134
|
-
#
|
135
|
-
|
136
|
-
TOPIC_PATH_TEMPLATE.match(topic_name)["topic"]
|
137
|
-
end
|
138
|
-
|
139
|
-
# @param service_path [String]
|
140
|
-
# The domain name of the API remote host.
|
141
|
-
# @param port [Integer]
|
142
|
-
# The port on which to connect to the remote host.
|
143
|
-
# @param channel [Channel]
|
144
|
-
# A Channel object through which to make calls.
|
145
|
-
# @param chan_creds [Grpc::ChannelCredentials]
|
146
|
-
# A ChannelCredentials for the setting up the RPC client.
|
147
|
-
# @param client_config[Hash]
|
119
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
120
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
121
|
+
# be many types.
|
122
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
123
|
+
# authenticating requests made by this client.
|
124
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
125
|
+
# credentials for this client.
|
126
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
127
|
+
# credentials for this client.
|
128
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
129
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
130
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
131
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
132
|
+
# metadata for requests, generally, to give OAuth credentials.
|
133
|
+
# @param scopes [Array<String>]
|
134
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
135
|
+
# an updater_proc is supplied.
|
136
|
+
# @param client_config [Hash]
|
148
137
|
# A Hash for call options for each method. See
|
149
138
|
# Google::Gax#construct_settings for the structure of
|
150
139
|
# this data. Falls back to the default config if not specified
|
@@ -156,11 +145,11 @@ module Google
|
|
156
145
|
port: DEFAULT_SERVICE_PORT,
|
157
146
|
channel: nil,
|
158
147
|
chan_creds: nil,
|
148
|
+
updater_proc: nil,
|
149
|
+
credentials: nil,
|
159
150
|
scopes: ALL_SCOPES,
|
160
151
|
client_config: {},
|
161
152
|
timeout: DEFAULT_TIMEOUT,
|
162
|
-
app_name: nil,
|
163
|
-
app_version: nil,
|
164
153
|
lib_name: nil,
|
165
154
|
lib_version: ""
|
166
155
|
# These require statements are intentionally placed here to initialize
|
@@ -170,14 +159,38 @@ module Google
|
|
170
159
|
require "google/iam/v1/iam_policy_services_pb"
|
171
160
|
require "google/pubsub/v1/pubsub_services_pb"
|
172
161
|
|
162
|
+
if channel || chan_creds || updater_proc
|
163
|
+
warn "The `channel`, `chan_creds`, and `updater_proc` parameters will be removed " \
|
164
|
+
"on 2017/09/08"
|
165
|
+
credentials ||= channel
|
166
|
+
credentials ||= chan_creds
|
167
|
+
credentials ||= updater_proc
|
168
|
+
end
|
169
|
+
if service_path != SERVICE_ADDRESS || port != DEFAULT_SERVICE_PORT
|
170
|
+
warn "`service_path` and `port` parameters are deprecated and will be removed"
|
171
|
+
end
|
172
|
+
|
173
|
+
credentials ||= Google::Cloud::Pubsub::Credentials.default
|
173
174
|
|
174
|
-
if
|
175
|
-
|
175
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
176
|
+
updater_proc = Google::Cloud::Pubsub::Credentials.new(credentials).updater_proc
|
177
|
+
end
|
178
|
+
if credentials.is_a?(GRPC::Core::Channel)
|
179
|
+
channel = credentials
|
180
|
+
end
|
181
|
+
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
182
|
+
chan_creds = credentials
|
183
|
+
end
|
184
|
+
if credentials.is_a?(Proc)
|
185
|
+
updater_proc = credentials
|
186
|
+
end
|
187
|
+
if credentials.is_a?(Google::Auth::Credentials)
|
188
|
+
updater_proc = credentials.updater_proc
|
176
189
|
end
|
177
190
|
|
178
191
|
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
179
192
|
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
180
|
-
google_api_client << " gapic/0.
|
193
|
+
google_api_client << " gapic/0.1.0 gax/#{Google::Gax::VERSION}"
|
181
194
|
google_api_client << " grpc/#{GRPC::VERSION}"
|
182
195
|
google_api_client.freeze
|
183
196
|
|
@@ -203,6 +216,7 @@ module Google
|
|
203
216
|
port,
|
204
217
|
chan_creds: chan_creds,
|
205
218
|
channel: channel,
|
219
|
+
updater_proc: updater_proc,
|
206
220
|
scopes: scopes,
|
207
221
|
&Google::Iam::V1::IAMPolicy::Stub.method(:new)
|
208
222
|
)
|
@@ -211,6 +225,7 @@ module Google
|
|
211
225
|
port,
|
212
226
|
chan_creds: chan_creds,
|
213
227
|
channel: channel,
|
228
|
+
updater_proc: updater_proc,
|
214
229
|
scopes: scopes,
|
215
230
|
&Google::Pubsub::V1::Publisher::Stub.method(:new)
|
216
231
|
)
|
@@ -231,6 +246,10 @@ module Google
|
|
231
246
|
@publisher_stub.method(:create_topic),
|
232
247
|
defaults["create_topic"]
|
233
248
|
)
|
249
|
+
@update_topic = Google::Gax.create_api_call(
|
250
|
+
@publisher_stub.method(:update_topic),
|
251
|
+
defaults["update_topic"]
|
252
|
+
)
|
234
253
|
@publish = Google::Gax.create_api_call(
|
235
254
|
@publisher_stub.method(:publish),
|
236
255
|
defaults["publish"]
|
@@ -264,29 +283,73 @@ module Google
|
|
264
283
|
# underscores (+_+), periods (+.+), tildes (+~+), plus (+++) or percent
|
265
284
|
# signs (+%+). It must be between 3 and 255 characters in length, and it
|
266
285
|
# must not start with +"goog"+.
|
286
|
+
# @param labels [Hash{String => String}]
|
287
|
+
# User labels.
|
267
288
|
# @param options [Google::Gax::CallOptions]
|
268
289
|
# Overrides the default settings for this call, e.g, timeout,
|
269
290
|
# retries, etc.
|
270
291
|
# @return [Google::Pubsub::V1::Topic]
|
271
292
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
272
293
|
# @example
|
273
|
-
# require "google/cloud/pubsub/v1
|
274
|
-
#
|
275
|
-
# PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
|
294
|
+
# require "google/cloud/pubsub/v1"
|
276
295
|
#
|
277
|
-
# publisher_client =
|
278
|
-
# formatted_name = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
296
|
+
# publisher_client = Google::Cloud::Pubsub::V1::Publisher.new
|
297
|
+
# formatted_name = Google::Cloud::Pubsub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
279
298
|
# response = publisher_client.create_topic(formatted_name)
|
280
299
|
|
281
300
|
def create_topic \
|
282
301
|
name,
|
302
|
+
labels: nil,
|
283
303
|
options: nil
|
284
|
-
req =
|
285
|
-
name: name
|
286
|
-
|
304
|
+
req = {
|
305
|
+
name: name,
|
306
|
+
labels: labels
|
307
|
+
}.delete_if { |_, v| v.nil? }
|
308
|
+
req = Google::Gax::to_proto(req, Google::Pubsub::V1::Topic)
|
287
309
|
@create_topic.call(req, options)
|
288
310
|
end
|
289
311
|
|
312
|
+
# Updates an existing topic. Note that certain properties of a topic are not
|
313
|
+
# modifiable. Options settings follow the style guide:
|
314
|
+
# NOTE: The style guide requires body: "topic" instead of body: "*".
|
315
|
+
# Keeping the latter for internal consistency in V1, however it should be
|
316
|
+
# corrected in V2. See
|
317
|
+
# https://cloud.google.com/apis/design/standard_methods#update for details.
|
318
|
+
#
|
319
|
+
# @param topic [Google::Pubsub::V1::Topic | Hash]
|
320
|
+
# The topic to update.
|
321
|
+
# A hash of the same form as `Google::Pubsub::V1::Topic`
|
322
|
+
# can also be provided.
|
323
|
+
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
324
|
+
# Indicates which fields in the provided topic to update.
|
325
|
+
# Must be specified and non-empty.
|
326
|
+
# A hash of the same form as `Google::Protobuf::FieldMask`
|
327
|
+
# can also be provided.
|
328
|
+
# @param options [Google::Gax::CallOptions]
|
329
|
+
# Overrides the default settings for this call, e.g, timeout,
|
330
|
+
# retries, etc.
|
331
|
+
# @return [Google::Pubsub::V1::Topic]
|
332
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
333
|
+
# @example
|
334
|
+
# require "google/cloud/pubsub/v1"
|
335
|
+
#
|
336
|
+
# publisher_client = Google::Cloud::Pubsub::V1::Publisher.new
|
337
|
+
# topic = {}
|
338
|
+
# update_mask = {}
|
339
|
+
# response = publisher_client.update_topic(topic, update_mask)
|
340
|
+
|
341
|
+
def update_topic \
|
342
|
+
topic,
|
343
|
+
update_mask,
|
344
|
+
options: nil
|
345
|
+
req = {
|
346
|
+
topic: topic,
|
347
|
+
update_mask: update_mask
|
348
|
+
}.delete_if { |_, v| v.nil? }
|
349
|
+
req = Google::Gax::to_proto(req, Google::Pubsub::V1::UpdateTopicRequest)
|
350
|
+
@update_topic.call(req, options)
|
351
|
+
end
|
352
|
+
|
290
353
|
# Adds one or more messages to the topic. Returns +NOT_FOUND+ if the topic
|
291
354
|
# does not exist. The message payload must not be empty; it must contain
|
292
355
|
# either a non-empty data field, or at least one attribute.
|
@@ -294,24 +357,22 @@ module Google
|
|
294
357
|
# @param topic [String]
|
295
358
|
# The messages in the request will be published on this topic.
|
296
359
|
# Format is +projects/{project}/topics/{topic}+.
|
297
|
-
# @param messages [Array<Google::Pubsub::V1::PubsubMessage>]
|
360
|
+
# @param messages [Array<Google::Pubsub::V1::PubsubMessage | Hash>]
|
298
361
|
# The messages to publish.
|
362
|
+
# A hash of the same form as `Google::Pubsub::V1::PubsubMessage`
|
363
|
+
# can also be provided.
|
299
364
|
# @param options [Google::Gax::CallOptions]
|
300
365
|
# Overrides the default settings for this call, e.g, timeout,
|
301
366
|
# retries, etc.
|
302
367
|
# @return [Google::Pubsub::V1::PublishResponse]
|
303
368
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
304
369
|
# @example
|
305
|
-
# require "google/cloud/pubsub/v1
|
306
|
-
#
|
307
|
-
# PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
|
308
|
-
# PubsubMessage = Google::Pubsub::V1::PubsubMessage
|
370
|
+
# require "google/cloud/pubsub/v1"
|
309
371
|
#
|
310
|
-
# publisher_client =
|
311
|
-
# formatted_topic = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
372
|
+
# publisher_client = Google::Cloud::Pubsub::V1::Publisher.new
|
373
|
+
# formatted_topic = Google::Cloud::Pubsub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
312
374
|
# data = ''
|
313
|
-
# messages_element =
|
314
|
-
# messages_element.data = data
|
375
|
+
# messages_element = { data: data }
|
315
376
|
# messages = [messages_element]
|
316
377
|
# response = publisher_client.publish(formatted_topic, messages)
|
317
378
|
|
@@ -319,10 +380,11 @@ module Google
|
|
319
380
|
topic,
|
320
381
|
messages,
|
321
382
|
options: nil
|
322
|
-
req =
|
383
|
+
req = {
|
323
384
|
topic: topic,
|
324
385
|
messages: messages
|
325
|
-
}.delete_if { |_, v| v.nil? }
|
386
|
+
}.delete_if { |_, v| v.nil? }
|
387
|
+
req = Google::Gax::to_proto(req, Google::Pubsub::V1::PublishRequest)
|
326
388
|
@publish.call(req, options)
|
327
389
|
end
|
328
390
|
|
@@ -337,20 +399,19 @@ module Google
|
|
337
399
|
# @return [Google::Pubsub::V1::Topic]
|
338
400
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
339
401
|
# @example
|
340
|
-
# require "google/cloud/pubsub/v1
|
402
|
+
# require "google/cloud/pubsub/v1"
|
341
403
|
#
|
342
|
-
#
|
343
|
-
#
|
344
|
-
# publisher_client = PublisherClient.new
|
345
|
-
# formatted_topic = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
404
|
+
# publisher_client = Google::Cloud::Pubsub::V1::Publisher.new
|
405
|
+
# formatted_topic = Google::Cloud::Pubsub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
346
406
|
# response = publisher_client.get_topic(formatted_topic)
|
347
407
|
|
348
408
|
def get_topic \
|
349
409
|
topic,
|
350
410
|
options: nil
|
351
|
-
req =
|
411
|
+
req = {
|
352
412
|
topic: topic
|
353
|
-
}.delete_if { |_, v| v.nil? }
|
413
|
+
}.delete_if { |_, v| v.nil? }
|
414
|
+
req = Google::Gax::to_proto(req, Google::Pubsub::V1::GetTopicRequest)
|
354
415
|
@get_topic.call(req, options)
|
355
416
|
end
|
356
417
|
|
@@ -375,12 +436,10 @@ module Google
|
|
375
436
|
# object.
|
376
437
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
377
438
|
# @example
|
378
|
-
# require "google/cloud/pubsub/v1
|
379
|
-
#
|
380
|
-
# PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
|
439
|
+
# require "google/cloud/pubsub/v1"
|
381
440
|
#
|
382
|
-
# publisher_client =
|
383
|
-
# formatted_project = PublisherClient.project_path("[PROJECT]")
|
441
|
+
# publisher_client = Google::Cloud::Pubsub::V1::Publisher.new
|
442
|
+
# formatted_project = Google::Cloud::Pubsub::V1::PublisherClient.project_path("[PROJECT]")
|
384
443
|
#
|
385
444
|
# # Iterate over all results.
|
386
445
|
# publisher_client.list_topics(formatted_project).each do |element|
|
@@ -399,10 +458,11 @@ module Google
|
|
399
458
|
project,
|
400
459
|
page_size: nil,
|
401
460
|
options: nil
|
402
|
-
req =
|
461
|
+
req = {
|
403
462
|
project: project,
|
404
463
|
page_size: page_size
|
405
|
-
}.delete_if { |_, v| v.nil? }
|
464
|
+
}.delete_if { |_, v| v.nil? }
|
465
|
+
req = Google::Gax::to_proto(req, Google::Pubsub::V1::ListTopicsRequest)
|
406
466
|
@list_topics.call(req, options)
|
407
467
|
end
|
408
468
|
|
@@ -427,12 +487,10 @@ module Google
|
|
427
487
|
# object.
|
428
488
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
429
489
|
# @example
|
430
|
-
# require "google/cloud/pubsub/v1
|
490
|
+
# require "google/cloud/pubsub/v1"
|
431
491
|
#
|
432
|
-
#
|
433
|
-
#
|
434
|
-
# publisher_client = PublisherClient.new
|
435
|
-
# formatted_topic = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
492
|
+
# publisher_client = Google::Cloud::Pubsub::V1::Publisher.new
|
493
|
+
# formatted_topic = Google::Cloud::Pubsub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
436
494
|
#
|
437
495
|
# # Iterate over all results.
|
438
496
|
# publisher_client.list_topic_subscriptions(formatted_topic).each do |element|
|
@@ -451,10 +509,11 @@ module Google
|
|
451
509
|
topic,
|
452
510
|
page_size: nil,
|
453
511
|
options: nil
|
454
|
-
req =
|
512
|
+
req = {
|
455
513
|
topic: topic,
|
456
514
|
page_size: page_size
|
457
|
-
}.delete_if { |_, v| v.nil? }
|
515
|
+
}.delete_if { |_, v| v.nil? }
|
516
|
+
req = Google::Gax::to_proto(req, Google::Pubsub::V1::ListTopicSubscriptionsRequest)
|
458
517
|
@list_topic_subscriptions.call(req, options)
|
459
518
|
end
|
460
519
|
|
@@ -472,20 +531,19 @@ module Google
|
|
472
531
|
# retries, etc.
|
473
532
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
474
533
|
# @example
|
475
|
-
# require "google/cloud/pubsub/v1
|
476
|
-
#
|
477
|
-
# PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
|
534
|
+
# require "google/cloud/pubsub/v1"
|
478
535
|
#
|
479
|
-
# publisher_client =
|
480
|
-
# formatted_topic = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
536
|
+
# publisher_client = Google::Cloud::Pubsub::V1::Publisher.new
|
537
|
+
# formatted_topic = Google::Cloud::Pubsub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
481
538
|
# publisher_client.delete_topic(formatted_topic)
|
482
539
|
|
483
540
|
def delete_topic \
|
484
541
|
topic,
|
485
542
|
options: nil
|
486
|
-
req =
|
543
|
+
req = {
|
487
544
|
topic: topic
|
488
|
-
}.delete_if { |_, v| v.nil? }
|
545
|
+
}.delete_if { |_, v| v.nil? }
|
546
|
+
req = Google::Gax::to_proto(req, Google::Pubsub::V1::DeleteTopicRequest)
|
489
547
|
@delete_topic.call(req, options)
|
490
548
|
nil
|
491
549
|
end
|
@@ -497,35 +555,35 @@ module Google
|
|
497
555
|
# REQUIRED: The resource for which the policy is being specified.
|
498
556
|
# +resource+ is usually specified as a path. For example, a Project
|
499
557
|
# resource is specified as +projects/{project}+.
|
500
|
-
# @param policy [Google::Iam::V1::Policy]
|
558
|
+
# @param policy [Google::Iam::V1::Policy | Hash]
|
501
559
|
# REQUIRED: The complete policy to be applied to the +resource+. The size of
|
502
560
|
# the policy is limited to a few 10s of KB. An empty policy is a
|
503
561
|
# valid policy but certain Cloud Platform services (such as Projects)
|
504
562
|
# might reject them.
|
563
|
+
# A hash of the same form as `Google::Iam::V1::Policy`
|
564
|
+
# can also be provided.
|
505
565
|
# @param options [Google::Gax::CallOptions]
|
506
566
|
# Overrides the default settings for this call, e.g, timeout,
|
507
567
|
# retries, etc.
|
508
568
|
# @return [Google::Iam::V1::Policy]
|
509
569
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
510
570
|
# @example
|
511
|
-
# require "google/cloud/pubsub/v1
|
512
|
-
#
|
513
|
-
# Policy = Google::Iam::V1::Policy
|
514
|
-
# PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
|
571
|
+
# require "google/cloud/pubsub/v1"
|
515
572
|
#
|
516
|
-
# publisher_client =
|
517
|
-
# formatted_resource = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
518
|
-
# policy =
|
573
|
+
# publisher_client = Google::Cloud::Pubsub::V1::Publisher.new
|
574
|
+
# formatted_resource = Google::Cloud::Pubsub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
575
|
+
# policy = {}
|
519
576
|
# response = publisher_client.set_iam_policy(formatted_resource, policy)
|
520
577
|
|
521
578
|
def set_iam_policy \
|
522
579
|
resource,
|
523
580
|
policy,
|
524
581
|
options: nil
|
525
|
-
req =
|
582
|
+
req = {
|
526
583
|
resource: resource,
|
527
584
|
policy: policy
|
528
|
-
}.delete_if { |_, v| v.nil? }
|
585
|
+
}.delete_if { |_, v| v.nil? }
|
586
|
+
req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
|
529
587
|
@set_iam_policy.call(req, options)
|
530
588
|
end
|
531
589
|
|
@@ -543,20 +601,19 @@ module Google
|
|
543
601
|
# @return [Google::Iam::V1::Policy]
|
544
602
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
545
603
|
# @example
|
546
|
-
# require "google/cloud/pubsub/v1
|
604
|
+
# require "google/cloud/pubsub/v1"
|
547
605
|
#
|
548
|
-
#
|
549
|
-
#
|
550
|
-
# publisher_client = PublisherClient.new
|
551
|
-
# formatted_resource = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
606
|
+
# publisher_client = Google::Cloud::Pubsub::V1::Publisher.new
|
607
|
+
# formatted_resource = Google::Cloud::Pubsub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
552
608
|
# response = publisher_client.get_iam_policy(formatted_resource)
|
553
609
|
|
554
610
|
def get_iam_policy \
|
555
611
|
resource,
|
556
612
|
options: nil
|
557
|
-
req =
|
613
|
+
req = {
|
558
614
|
resource: resource
|
559
|
-
}.delete_if { |_, v| v.nil? }
|
615
|
+
}.delete_if { |_, v| v.nil? }
|
616
|
+
req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
|
560
617
|
@get_iam_policy.call(req, options)
|
561
618
|
end
|
562
619
|
|
@@ -572,19 +629,17 @@ module Google
|
|
572
629
|
# The set of permissions to check for the +resource+. Permissions with
|
573
630
|
# wildcards (such as '*' or 'storage.*') are not allowed. For more
|
574
631
|
# information see
|
575
|
-
#
|
632
|
+
# [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
|
576
633
|
# @param options [Google::Gax::CallOptions]
|
577
634
|
# Overrides the default settings for this call, e.g, timeout,
|
578
635
|
# retries, etc.
|
579
636
|
# @return [Google::Iam::V1::TestIamPermissionsResponse]
|
580
637
|
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
581
638
|
# @example
|
582
|
-
# require "google/cloud/pubsub/v1
|
583
|
-
#
|
584
|
-
# PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
|
639
|
+
# require "google/cloud/pubsub/v1"
|
585
640
|
#
|
586
|
-
# publisher_client =
|
587
|
-
# formatted_resource = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
641
|
+
# publisher_client = Google::Cloud::Pubsub::V1::Publisher.new
|
642
|
+
# formatted_resource = Google::Cloud::Pubsub::V1::PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
588
643
|
# permissions = []
|
589
644
|
# response = publisher_client.test_iam_permissions(formatted_resource, permissions)
|
590
645
|
|
@@ -592,10 +647,11 @@ module Google
|
|
592
647
|
resource,
|
593
648
|
permissions,
|
594
649
|
options: nil
|
595
|
-
req =
|
650
|
+
req = {
|
596
651
|
resource: resource,
|
597
652
|
permissions: permissions
|
598
|
-
}.delete_if { |_, v| v.nil? }
|
653
|
+
}.delete_if { |_, v| v.nil? }
|
654
|
+
req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
|
599
655
|
@test_iam_permissions.call(req, options)
|
600
656
|
end
|
601
657
|
end
|