google-cloud-pubsub 0.26.0 → 2.6.1
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/.yardopts +12 -2
- data/AUTHENTICATION.md +178 -0
- data/CHANGELOG.md +659 -0
- data/CODE_OF_CONDUCT.md +40 -0
- data/CONTRIBUTING.md +187 -0
- data/EMULATOR.md +37 -0
- data/LICENSE +2 -2
- data/LOGGING.md +32 -0
- data/OVERVIEW.md +528 -0
- data/TROUBLESHOOTING.md +31 -0
- data/lib/google/cloud/pubsub/async_publisher/batch.rb +310 -0
- data/lib/google/cloud/pubsub/async_publisher.rb +402 -0
- data/lib/google/cloud/pubsub/batch_publisher.rb +100 -0
- data/lib/google/cloud/pubsub/convert.rb +91 -0
- data/lib/google/cloud/pubsub/credentials.rb +26 -10
- data/lib/google/cloud/pubsub/errors.rb +85 -0
- data/lib/google/cloud/pubsub/message.rb +80 -17
- data/lib/google/cloud/pubsub/policy.rb +17 -14
- data/lib/google/cloud/pubsub/project.rb +364 -250
- data/lib/google/cloud/pubsub/publish_result.rb +103 -0
- data/lib/google/cloud/pubsub/received_message.rb +162 -24
- data/lib/google/cloud/pubsub/retry_policy.rb +88 -0
- data/lib/google/cloud/pubsub/schema/list.rb +180 -0
- data/lib/google/cloud/pubsub/schema.rb +310 -0
- data/lib/google/cloud/pubsub/service.rb +281 -265
- data/lib/google/cloud/pubsub/snapshot/list.rb +21 -21
- data/lib/google/cloud/pubsub/snapshot.rb +55 -15
- data/lib/google/cloud/pubsub/subscriber/enumerator_queue.rb +54 -0
- data/lib/google/cloud/pubsub/subscriber/inventory.rb +173 -0
- data/lib/google/cloud/pubsub/subscriber/sequencer.rb +115 -0
- data/lib/google/cloud/pubsub/subscriber/stream.rb +400 -0
- data/lib/google/cloud/pubsub/subscriber/timed_unary_buffer.rb +230 -0
- data/lib/google/cloud/pubsub/subscriber.rb +417 -0
- data/lib/google/cloud/pubsub/subscription/list.rb +28 -28
- data/lib/google/cloud/pubsub/subscription/push_config.rb +268 -0
- data/lib/google/cloud/pubsub/subscription.rb +900 -172
- data/lib/google/cloud/pubsub/topic/list.rb +21 -21
- data/lib/google/cloud/pubsub/topic.rb +674 -95
- data/lib/google/cloud/pubsub/version.rb +6 -4
- data/lib/google/cloud/pubsub.rb +104 -439
- data/lib/google-cloud-pubsub.rb +60 -29
- metadata +88 -50
- data/README.md +0 -69
- data/lib/google/cloud/pubsub/topic/publisher.rb +0 -86
- data/lib/google/cloud/pubsub/v1/doc/google/protobuf/duration.rb +0 -77
- data/lib/google/cloud/pubsub/v1/doc/google/protobuf/field_mask.rb +0 -223
- data/lib/google/cloud/pubsub/v1/doc/google/protobuf/timestamp.rb +0 -81
- data/lib/google/cloud/pubsub/v1/doc/google/pubsub/v1/pubsub.rb +0 -503
- data/lib/google/cloud/pubsub/v1/publisher_client.rb +0 -605
- data/lib/google/cloud/pubsub/v1/publisher_client_config.json +0 -96
- data/lib/google/cloud/pubsub/v1/subscriber_client.rb +0 -1104
- data/lib/google/cloud/pubsub/v1/subscriber_client_config.json +0 -127
- data/lib/google/cloud/pubsub/v1.rb +0 -17
- data/lib/google/pubsub/v1/pubsub_pb.rb +0 -187
- data/lib/google/pubsub/v1/pubsub_services_pb.rb +0 -159
@@ -1,605 +0,0 @@
|
|
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
|
-
# 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
|
-
# The only allowed edits are to method and file documentation. A 3-way
|
23
|
-
# merge preserves those additions if the generated source changes.
|
24
|
-
|
25
|
-
require "json"
|
26
|
-
require "pathname"
|
27
|
-
|
28
|
-
require "google/gax"
|
29
|
-
|
30
|
-
require "google/iam/v1/iam_policy_pb"
|
31
|
-
require "google/pubsub/v1/pubsub_pb"
|
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::Pubsub::V1::Publisher::Stub]
|
44
|
-
class PublisherClient
|
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
|
-
DEFAULT_TIMEOUT = 30
|
54
|
-
|
55
|
-
PAGE_DESCRIPTORS = {
|
56
|
-
"list_topics" => Google::Gax::PageDescriptor.new(
|
57
|
-
"page_token",
|
58
|
-
"next_page_token",
|
59
|
-
"topics"),
|
60
|
-
"list_topic_subscriptions" => Google::Gax::PageDescriptor.new(
|
61
|
-
"page_token",
|
62
|
-
"next_page_token",
|
63
|
-
"subscriptions")
|
64
|
-
}.freeze
|
65
|
-
|
66
|
-
private_constant :PAGE_DESCRIPTORS
|
67
|
-
|
68
|
-
BUNDLE_DESCRIPTORS = {
|
69
|
-
"publish" => Google::Gax::BundleDescriptor.new(
|
70
|
-
"messages",
|
71
|
-
[
|
72
|
-
"topic"
|
73
|
-
],
|
74
|
-
subresponse_field: "message_ids")
|
75
|
-
}.freeze
|
76
|
-
|
77
|
-
private_constant :BUNDLE_DESCRIPTORS
|
78
|
-
|
79
|
-
# The scopes needed to make gRPC calls to all of the methods defined in
|
80
|
-
# this service.
|
81
|
-
ALL_SCOPES = [
|
82
|
-
"https://www.googleapis.com/auth/cloud-platform",
|
83
|
-
"https://www.googleapis.com/auth/pubsub"
|
84
|
-
].freeze
|
85
|
-
|
86
|
-
PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
87
|
-
"projects/{project}"
|
88
|
-
)
|
89
|
-
|
90
|
-
private_constant :PROJECT_PATH_TEMPLATE
|
91
|
-
|
92
|
-
TOPIC_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
93
|
-
"projects/{project}/topics/{topic}"
|
94
|
-
)
|
95
|
-
|
96
|
-
private_constant :TOPIC_PATH_TEMPLATE
|
97
|
-
|
98
|
-
# Returns a fully-qualified project resource name string.
|
99
|
-
# @param project [String]
|
100
|
-
# @return [String]
|
101
|
-
def self.project_path project
|
102
|
-
PROJECT_PATH_TEMPLATE.render(
|
103
|
-
:"project" => project
|
104
|
-
)
|
105
|
-
end
|
106
|
-
|
107
|
-
# Returns a fully-qualified topic resource name string.
|
108
|
-
# @param project [String]
|
109
|
-
# @param topic [String]
|
110
|
-
# @return [String]
|
111
|
-
def self.topic_path project, topic
|
112
|
-
TOPIC_PATH_TEMPLATE.render(
|
113
|
-
:"project" => project,
|
114
|
-
:"topic" => topic
|
115
|
-
)
|
116
|
-
end
|
117
|
-
|
118
|
-
# Parses the project from a project resource.
|
119
|
-
# @param project_name [String]
|
120
|
-
# @return [String]
|
121
|
-
def self.match_project_from_project_name project_name
|
122
|
-
PROJECT_PATH_TEMPLATE.match(project_name)["project"]
|
123
|
-
end
|
124
|
-
|
125
|
-
# Parses the project from a topic resource.
|
126
|
-
# @param topic_name [String]
|
127
|
-
# @return [String]
|
128
|
-
def self.match_project_from_topic_name topic_name
|
129
|
-
TOPIC_PATH_TEMPLATE.match(topic_name)["project"]
|
130
|
-
end
|
131
|
-
|
132
|
-
# Parses the topic from a topic resource.
|
133
|
-
# @param topic_name [String]
|
134
|
-
# @return [String]
|
135
|
-
def self.match_topic_from_topic_name topic_name
|
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]
|
148
|
-
# A Hash for call options for each method. See
|
149
|
-
# Google::Gax#construct_settings for the structure of
|
150
|
-
# this data. Falls back to the default config if not specified
|
151
|
-
# or the specified config is missing data points.
|
152
|
-
# @param timeout [Numeric]
|
153
|
-
# The default timeout, in seconds, for calls made through this client.
|
154
|
-
def initialize \
|
155
|
-
service_path: SERVICE_ADDRESS,
|
156
|
-
port: DEFAULT_SERVICE_PORT,
|
157
|
-
channel: nil,
|
158
|
-
chan_creds: nil,
|
159
|
-
scopes: ALL_SCOPES,
|
160
|
-
client_config: {},
|
161
|
-
timeout: DEFAULT_TIMEOUT,
|
162
|
-
app_name: nil,
|
163
|
-
app_version: nil,
|
164
|
-
lib_name: nil,
|
165
|
-
lib_version: ""
|
166
|
-
# These require statements are intentionally placed here to initialize
|
167
|
-
# the gRPC module only when it's required.
|
168
|
-
# See https://github.com/googleapis/toolkit/issues/446
|
169
|
-
require "google/gax/grpc"
|
170
|
-
require "google/iam/v1/iam_policy_services_pb"
|
171
|
-
require "google/pubsub/v1/pubsub_services_pb"
|
172
|
-
|
173
|
-
|
174
|
-
if app_name || app_version
|
175
|
-
warn "`app_name` and `app_version` are no longer being used in the request headers."
|
176
|
-
end
|
177
|
-
|
178
|
-
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
179
|
-
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
180
|
-
google_api_client << " gapic/0.6.8 gax/#{Google::Gax::VERSION}"
|
181
|
-
google_api_client << " grpc/#{GRPC::VERSION}"
|
182
|
-
google_api_client.freeze
|
183
|
-
|
184
|
-
headers = { :"x-goog-api-client" => google_api_client }
|
185
|
-
client_config_file = Pathname.new(__dir__).join(
|
186
|
-
"publisher_client_config.json"
|
187
|
-
)
|
188
|
-
defaults = client_config_file.open do |f|
|
189
|
-
Google::Gax.construct_settings(
|
190
|
-
"google.pubsub.v1.Publisher",
|
191
|
-
JSON.parse(f.read),
|
192
|
-
client_config,
|
193
|
-
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
194
|
-
timeout,
|
195
|
-
bundle_descriptors: BUNDLE_DESCRIPTORS,
|
196
|
-
page_descriptors: PAGE_DESCRIPTORS,
|
197
|
-
errors: Google::Gax::Grpc::API_ERRORS,
|
198
|
-
kwargs: headers
|
199
|
-
)
|
200
|
-
end
|
201
|
-
@iam_policy_stub = Google::Gax::Grpc.create_stub(
|
202
|
-
service_path,
|
203
|
-
port,
|
204
|
-
chan_creds: chan_creds,
|
205
|
-
channel: channel,
|
206
|
-
scopes: scopes,
|
207
|
-
&Google::Iam::V1::IAMPolicy::Stub.method(:new)
|
208
|
-
)
|
209
|
-
@publisher_stub = Google::Gax::Grpc.create_stub(
|
210
|
-
service_path,
|
211
|
-
port,
|
212
|
-
chan_creds: chan_creds,
|
213
|
-
channel: channel,
|
214
|
-
scopes: scopes,
|
215
|
-
&Google::Pubsub::V1::Publisher::Stub.method(:new)
|
216
|
-
)
|
217
|
-
|
218
|
-
@set_iam_policy = Google::Gax.create_api_call(
|
219
|
-
@iam_policy_stub.method(:set_iam_policy),
|
220
|
-
defaults["set_iam_policy"]
|
221
|
-
)
|
222
|
-
@get_iam_policy = Google::Gax.create_api_call(
|
223
|
-
@iam_policy_stub.method(:get_iam_policy),
|
224
|
-
defaults["get_iam_policy"]
|
225
|
-
)
|
226
|
-
@test_iam_permissions = Google::Gax.create_api_call(
|
227
|
-
@iam_policy_stub.method(:test_iam_permissions),
|
228
|
-
defaults["test_iam_permissions"]
|
229
|
-
)
|
230
|
-
@create_topic = Google::Gax.create_api_call(
|
231
|
-
@publisher_stub.method(:create_topic),
|
232
|
-
defaults["create_topic"]
|
233
|
-
)
|
234
|
-
@publish = Google::Gax.create_api_call(
|
235
|
-
@publisher_stub.method(:publish),
|
236
|
-
defaults["publish"]
|
237
|
-
)
|
238
|
-
@get_topic = Google::Gax.create_api_call(
|
239
|
-
@publisher_stub.method(:get_topic),
|
240
|
-
defaults["get_topic"]
|
241
|
-
)
|
242
|
-
@list_topics = Google::Gax.create_api_call(
|
243
|
-
@publisher_stub.method(:list_topics),
|
244
|
-
defaults["list_topics"]
|
245
|
-
)
|
246
|
-
@list_topic_subscriptions = Google::Gax.create_api_call(
|
247
|
-
@publisher_stub.method(:list_topic_subscriptions),
|
248
|
-
defaults["list_topic_subscriptions"]
|
249
|
-
)
|
250
|
-
@delete_topic = Google::Gax.create_api_call(
|
251
|
-
@publisher_stub.method(:delete_topic),
|
252
|
-
defaults["delete_topic"]
|
253
|
-
)
|
254
|
-
end
|
255
|
-
|
256
|
-
# Service calls
|
257
|
-
|
258
|
-
# Creates the given topic with the given name.
|
259
|
-
#
|
260
|
-
# @param name [String]
|
261
|
-
# The name of the topic. It must have the format
|
262
|
-
# +"projects/{project}/topics/{topic}"+. +{topic}+ must start with a letter,
|
263
|
-
# and contain only letters (+[A-Za-z]+), numbers (+[0-9]+), dashes (+-+),
|
264
|
-
# underscores (+_+), periods (+.+), tildes (+~+), plus (+++) or percent
|
265
|
-
# signs (+%+). It must be between 3 and 255 characters in length, and it
|
266
|
-
# must not start with +"goog"+.
|
267
|
-
# @param options [Google::Gax::CallOptions]
|
268
|
-
# Overrides the default settings for this call, e.g, timeout,
|
269
|
-
# retries, etc.
|
270
|
-
# @return [Google::Pubsub::V1::Topic]
|
271
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
272
|
-
# @example
|
273
|
-
# require "google/cloud/pubsub/v1/publisher_client"
|
274
|
-
#
|
275
|
-
# PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
|
276
|
-
#
|
277
|
-
# publisher_client = PublisherClient.new
|
278
|
-
# formatted_name = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
279
|
-
# response = publisher_client.create_topic(formatted_name)
|
280
|
-
|
281
|
-
def create_topic \
|
282
|
-
name,
|
283
|
-
options: nil
|
284
|
-
req = Google::Pubsub::V1::Topic.new({
|
285
|
-
name: name
|
286
|
-
}.delete_if { |_, v| v.nil? })
|
287
|
-
@create_topic.call(req, options)
|
288
|
-
end
|
289
|
-
|
290
|
-
# Adds one or more messages to the topic. Returns +NOT_FOUND+ if the topic
|
291
|
-
# does not exist. The message payload must not be empty; it must contain
|
292
|
-
# either a non-empty data field, or at least one attribute.
|
293
|
-
#
|
294
|
-
# @param topic [String]
|
295
|
-
# The messages in the request will be published on this topic.
|
296
|
-
# Format is +projects/{project}/topics/{topic}+.
|
297
|
-
# @param messages [Array<Google::Pubsub::V1::PubsubMessage>]
|
298
|
-
# The messages to publish.
|
299
|
-
# @param options [Google::Gax::CallOptions]
|
300
|
-
# Overrides the default settings for this call, e.g, timeout,
|
301
|
-
# retries, etc.
|
302
|
-
# @return [Google::Pubsub::V1::PublishResponse]
|
303
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
304
|
-
# @example
|
305
|
-
# require "google/cloud/pubsub/v1/publisher_client"
|
306
|
-
#
|
307
|
-
# PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
|
308
|
-
# PubsubMessage = Google::Pubsub::V1::PubsubMessage
|
309
|
-
#
|
310
|
-
# publisher_client = PublisherClient.new
|
311
|
-
# formatted_topic = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
312
|
-
# data = ''
|
313
|
-
# messages_element = PubsubMessage.new
|
314
|
-
# messages_element.data = data
|
315
|
-
# messages = [messages_element]
|
316
|
-
# response = publisher_client.publish(formatted_topic, messages)
|
317
|
-
|
318
|
-
def publish \
|
319
|
-
topic,
|
320
|
-
messages,
|
321
|
-
options: nil
|
322
|
-
req = Google::Pubsub::V1::PublishRequest.new({
|
323
|
-
topic: topic,
|
324
|
-
messages: messages
|
325
|
-
}.delete_if { |_, v| v.nil? })
|
326
|
-
@publish.call(req, options)
|
327
|
-
end
|
328
|
-
|
329
|
-
# Gets the configuration of a topic.
|
330
|
-
#
|
331
|
-
# @param topic [String]
|
332
|
-
# The name of the topic to get.
|
333
|
-
# Format is +projects/{project}/topics/{topic}+.
|
334
|
-
# @param options [Google::Gax::CallOptions]
|
335
|
-
# Overrides the default settings for this call, e.g, timeout,
|
336
|
-
# retries, etc.
|
337
|
-
# @return [Google::Pubsub::V1::Topic]
|
338
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
339
|
-
# @example
|
340
|
-
# require "google/cloud/pubsub/v1/publisher_client"
|
341
|
-
#
|
342
|
-
# PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
|
343
|
-
#
|
344
|
-
# publisher_client = PublisherClient.new
|
345
|
-
# formatted_topic = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
346
|
-
# response = publisher_client.get_topic(formatted_topic)
|
347
|
-
|
348
|
-
def get_topic \
|
349
|
-
topic,
|
350
|
-
options: nil
|
351
|
-
req = Google::Pubsub::V1::GetTopicRequest.new({
|
352
|
-
topic: topic
|
353
|
-
}.delete_if { |_, v| v.nil? })
|
354
|
-
@get_topic.call(req, options)
|
355
|
-
end
|
356
|
-
|
357
|
-
# Lists matching topics.
|
358
|
-
#
|
359
|
-
# @param project [String]
|
360
|
-
# The name of the cloud project that topics belong to.
|
361
|
-
# Format is +projects/{project}+.
|
362
|
-
# @param page_size [Integer]
|
363
|
-
# The maximum number of resources contained in the underlying API
|
364
|
-
# response. If page streaming is performed per-resource, this
|
365
|
-
# parameter does not affect the return value. If page streaming is
|
366
|
-
# performed per-page, this determines the maximum number of
|
367
|
-
# resources in a page.
|
368
|
-
# @param options [Google::Gax::CallOptions]
|
369
|
-
# Overrides the default settings for this call, e.g, timeout,
|
370
|
-
# retries, etc.
|
371
|
-
# @return [Google::Gax::PagedEnumerable<Google::Pubsub::V1::Topic>]
|
372
|
-
# An enumerable of Google::Pubsub::V1::Topic instances.
|
373
|
-
# See Google::Gax::PagedEnumerable documentation for other
|
374
|
-
# operations such as per-page iteration or access to the response
|
375
|
-
# object.
|
376
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
377
|
-
# @example
|
378
|
-
# require "google/cloud/pubsub/v1/publisher_client"
|
379
|
-
#
|
380
|
-
# PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
|
381
|
-
#
|
382
|
-
# publisher_client = PublisherClient.new
|
383
|
-
# formatted_project = PublisherClient.project_path("[PROJECT]")
|
384
|
-
#
|
385
|
-
# # Iterate over all results.
|
386
|
-
# publisher_client.list_topics(formatted_project).each do |element|
|
387
|
-
# # Process element.
|
388
|
-
# end
|
389
|
-
#
|
390
|
-
# # Or iterate over results one page at a time.
|
391
|
-
# publisher_client.list_topics(formatted_project).each_page do |page|
|
392
|
-
# # Process each page at a time.
|
393
|
-
# page.each do |element|
|
394
|
-
# # Process element.
|
395
|
-
# end
|
396
|
-
# end
|
397
|
-
|
398
|
-
def list_topics \
|
399
|
-
project,
|
400
|
-
page_size: nil,
|
401
|
-
options: nil
|
402
|
-
req = Google::Pubsub::V1::ListTopicsRequest.new({
|
403
|
-
project: project,
|
404
|
-
page_size: page_size
|
405
|
-
}.delete_if { |_, v| v.nil? })
|
406
|
-
@list_topics.call(req, options)
|
407
|
-
end
|
408
|
-
|
409
|
-
# Lists the name of the subscriptions for this topic.
|
410
|
-
#
|
411
|
-
# @param topic [String]
|
412
|
-
# The name of the topic that subscriptions are attached to.
|
413
|
-
# Format is +projects/{project}/topics/{topic}+.
|
414
|
-
# @param page_size [Integer]
|
415
|
-
# The maximum number of resources contained in the underlying API
|
416
|
-
# response. If page streaming is performed per-resource, this
|
417
|
-
# parameter does not affect the return value. If page streaming is
|
418
|
-
# performed per-page, this determines the maximum number of
|
419
|
-
# resources in a page.
|
420
|
-
# @param options [Google::Gax::CallOptions]
|
421
|
-
# Overrides the default settings for this call, e.g, timeout,
|
422
|
-
# retries, etc.
|
423
|
-
# @return [Google::Gax::PagedEnumerable<String>]
|
424
|
-
# An enumerable of String instances.
|
425
|
-
# See Google::Gax::PagedEnumerable documentation for other
|
426
|
-
# operations such as per-page iteration or access to the response
|
427
|
-
# object.
|
428
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
429
|
-
# @example
|
430
|
-
# require "google/cloud/pubsub/v1/publisher_client"
|
431
|
-
#
|
432
|
-
# PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
|
433
|
-
#
|
434
|
-
# publisher_client = PublisherClient.new
|
435
|
-
# formatted_topic = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
436
|
-
#
|
437
|
-
# # Iterate over all results.
|
438
|
-
# publisher_client.list_topic_subscriptions(formatted_topic).each do |element|
|
439
|
-
# # Process element.
|
440
|
-
# end
|
441
|
-
#
|
442
|
-
# # Or iterate over results one page at a time.
|
443
|
-
# publisher_client.list_topic_subscriptions(formatted_topic).each_page do |page|
|
444
|
-
# # Process each page at a time.
|
445
|
-
# page.each do |element|
|
446
|
-
# # Process element.
|
447
|
-
# end
|
448
|
-
# end
|
449
|
-
|
450
|
-
def list_topic_subscriptions \
|
451
|
-
topic,
|
452
|
-
page_size: nil,
|
453
|
-
options: nil
|
454
|
-
req = Google::Pubsub::V1::ListTopicSubscriptionsRequest.new({
|
455
|
-
topic: topic,
|
456
|
-
page_size: page_size
|
457
|
-
}.delete_if { |_, v| v.nil? })
|
458
|
-
@list_topic_subscriptions.call(req, options)
|
459
|
-
end
|
460
|
-
|
461
|
-
# Deletes the topic with the given name. Returns +NOT_FOUND+ if the topic
|
462
|
-
# does not exist. After a topic is deleted, a new topic may be created with
|
463
|
-
# the same name; this is an entirely new topic with none of the old
|
464
|
-
# configuration or subscriptions. Existing subscriptions to this topic are
|
465
|
-
# not deleted, but their +topic+ field is set to +_deleted-topic_+.
|
466
|
-
#
|
467
|
-
# @param topic [String]
|
468
|
-
# Name of the topic to delete.
|
469
|
-
# Format is +projects/{project}/topics/{topic}+.
|
470
|
-
# @param options [Google::Gax::CallOptions]
|
471
|
-
# Overrides the default settings for this call, e.g, timeout,
|
472
|
-
# retries, etc.
|
473
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
474
|
-
# @example
|
475
|
-
# require "google/cloud/pubsub/v1/publisher_client"
|
476
|
-
#
|
477
|
-
# PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
|
478
|
-
#
|
479
|
-
# publisher_client = PublisherClient.new
|
480
|
-
# formatted_topic = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
481
|
-
# publisher_client.delete_topic(formatted_topic)
|
482
|
-
|
483
|
-
def delete_topic \
|
484
|
-
topic,
|
485
|
-
options: nil
|
486
|
-
req = Google::Pubsub::V1::DeleteTopicRequest.new({
|
487
|
-
topic: topic
|
488
|
-
}.delete_if { |_, v| v.nil? })
|
489
|
-
@delete_topic.call(req, options)
|
490
|
-
nil
|
491
|
-
end
|
492
|
-
|
493
|
-
# Sets the access control policy on the specified resource. Replaces any
|
494
|
-
# existing policy.
|
495
|
-
#
|
496
|
-
# @param resource [String]
|
497
|
-
# REQUIRED: The resource for which the policy is being specified.
|
498
|
-
# +resource+ is usually specified as a path. For example, a Project
|
499
|
-
# resource is specified as +projects/{project}+.
|
500
|
-
# @param policy [Google::Iam::V1::Policy]
|
501
|
-
# REQUIRED: The complete policy to be applied to the +resource+. The size of
|
502
|
-
# the policy is limited to a few 10s of KB. An empty policy is a
|
503
|
-
# valid policy but certain Cloud Platform services (such as Projects)
|
504
|
-
# might reject them.
|
505
|
-
# @param options [Google::Gax::CallOptions]
|
506
|
-
# Overrides the default settings for this call, e.g, timeout,
|
507
|
-
# retries, etc.
|
508
|
-
# @return [Google::Iam::V1::Policy]
|
509
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
510
|
-
# @example
|
511
|
-
# require "google/cloud/pubsub/v1/publisher_client"
|
512
|
-
#
|
513
|
-
# Policy = Google::Iam::V1::Policy
|
514
|
-
# PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
|
515
|
-
#
|
516
|
-
# publisher_client = PublisherClient.new
|
517
|
-
# formatted_resource = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
518
|
-
# policy = Policy.new
|
519
|
-
# response = publisher_client.set_iam_policy(formatted_resource, policy)
|
520
|
-
|
521
|
-
def set_iam_policy \
|
522
|
-
resource,
|
523
|
-
policy,
|
524
|
-
options: nil
|
525
|
-
req = Google::Iam::V1::SetIamPolicyRequest.new({
|
526
|
-
resource: resource,
|
527
|
-
policy: policy
|
528
|
-
}.delete_if { |_, v| v.nil? })
|
529
|
-
@set_iam_policy.call(req, options)
|
530
|
-
end
|
531
|
-
|
532
|
-
# Gets the access control policy for a resource.
|
533
|
-
# Returns an empty policy if the resource exists and does not have a policy
|
534
|
-
# set.
|
535
|
-
#
|
536
|
-
# @param resource [String]
|
537
|
-
# REQUIRED: The resource for which the policy is being requested.
|
538
|
-
# +resource+ is usually specified as a path. For example, a Project
|
539
|
-
# resource is specified as +projects/{project}+.
|
540
|
-
# @param options [Google::Gax::CallOptions]
|
541
|
-
# Overrides the default settings for this call, e.g, timeout,
|
542
|
-
# retries, etc.
|
543
|
-
# @return [Google::Iam::V1::Policy]
|
544
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
545
|
-
# @example
|
546
|
-
# require "google/cloud/pubsub/v1/publisher_client"
|
547
|
-
#
|
548
|
-
# PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
|
549
|
-
#
|
550
|
-
# publisher_client = PublisherClient.new
|
551
|
-
# formatted_resource = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
552
|
-
# response = publisher_client.get_iam_policy(formatted_resource)
|
553
|
-
|
554
|
-
def get_iam_policy \
|
555
|
-
resource,
|
556
|
-
options: nil
|
557
|
-
req = Google::Iam::V1::GetIamPolicyRequest.new({
|
558
|
-
resource: resource
|
559
|
-
}.delete_if { |_, v| v.nil? })
|
560
|
-
@get_iam_policy.call(req, options)
|
561
|
-
end
|
562
|
-
|
563
|
-
# Returns permissions that a caller has on the specified resource.
|
564
|
-
# If the resource does not exist, this will return an empty set of
|
565
|
-
# permissions, not a NOT_FOUND error.
|
566
|
-
#
|
567
|
-
# @param resource [String]
|
568
|
-
# REQUIRED: The resource for which the policy detail is being requested.
|
569
|
-
# +resource+ is usually specified as a path. For example, a Project
|
570
|
-
# resource is specified as +projects/{project}+.
|
571
|
-
# @param permissions [Array<String>]
|
572
|
-
# The set of permissions to check for the +resource+. Permissions with
|
573
|
-
# wildcards (such as '*' or 'storage.*') are not allowed. For more
|
574
|
-
# information see
|
575
|
-
# {IAM Overview}[https://cloud.google.com/iam/docs/overview#permissions].
|
576
|
-
# @param options [Google::Gax::CallOptions]
|
577
|
-
# Overrides the default settings for this call, e.g, timeout,
|
578
|
-
# retries, etc.
|
579
|
-
# @return [Google::Iam::V1::TestIamPermissionsResponse]
|
580
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
581
|
-
# @example
|
582
|
-
# require "google/cloud/pubsub/v1/publisher_client"
|
583
|
-
#
|
584
|
-
# PublisherClient = Google::Cloud::Pubsub::V1::PublisherClient
|
585
|
-
#
|
586
|
-
# publisher_client = PublisherClient.new
|
587
|
-
# formatted_resource = PublisherClient.topic_path("[PROJECT]", "[TOPIC]")
|
588
|
-
# permissions = []
|
589
|
-
# response = publisher_client.test_iam_permissions(formatted_resource, permissions)
|
590
|
-
|
591
|
-
def test_iam_permissions \
|
592
|
-
resource,
|
593
|
-
permissions,
|
594
|
-
options: nil
|
595
|
-
req = Google::Iam::V1::TestIamPermissionsRequest.new({
|
596
|
-
resource: resource,
|
597
|
-
permissions: permissions
|
598
|
-
}.delete_if { |_, v| v.nil? })
|
599
|
-
@test_iam_permissions.call(req, options)
|
600
|
-
end
|
601
|
-
end
|
602
|
-
end
|
603
|
-
end
|
604
|
-
end
|
605
|
-
end
|