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.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +2 -1
- data/CHANGELOG.md +47 -0
- data/TROUBLESHOOTING.md +2 -8
- data/lib/google-cloud-pubsub.rb +13 -13
- data/lib/google/cloud/pubsub.rb +15 -18
- data/lib/google/cloud/pubsub/async_publisher.rb +1 -2
- data/lib/google/cloud/pubsub/credentials.rb +2 -2
- data/lib/google/cloud/pubsub/service.rb +110 -255
- data/lib/google/cloud/pubsub/subscriber/stream.rb +3 -2
- data/lib/google/cloud/pubsub/subscription.rb +70 -3
- data/lib/google/cloud/pubsub/topic.rb +7 -3
- data/lib/google/cloud/pubsub/version.rb +1 -1
- metadata +8 -79
- data/lib/google/cloud/pubsub/v1.rb +0 -17
- data/lib/google/cloud/pubsub/v1/credentials.rb +0 -41
- data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/iam_policy.rb +0 -21
- data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/options.rb +0 -21
- data/lib/google/cloud/pubsub/v1/doc/google/iam/v1/policy.rb +0 -21
- data/lib/google/cloud/pubsub/v1/doc/google/protobuf/duration.rb +0 -91
- data/lib/google/cloud/pubsub/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/pubsub/v1/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/pubsub/v1/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/pubsub/v1/doc/google/pubsub/v1/pubsub.rb +0 -796
- data/lib/google/cloud/pubsub/v1/doc/google/type/expr.rb +0 -19
- data/lib/google/cloud/pubsub/v1/publisher_client.rb +0 -869
- data/lib/google/cloud/pubsub/v1/publisher_client_config.json +0 -114
- data/lib/google/cloud/pubsub/v1/subscriber_client.rb +0 -1463
- data/lib/google/cloud/pubsub/v1/subscriber_client_config.json +0 -153
- data/lib/google/pubsub/v1/pubsub_pb.rb +0 -259
- data/lib/google/pubsub/v1/pubsub_services_pb.rb +0 -210
@@ -1,114 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"interfaces": {
|
3
|
-
"google.pubsub.v1.Publisher": {
|
4
|
-
"retry_codes": {
|
5
|
-
"idempotent": [
|
6
|
-
"ABORTED",
|
7
|
-
"UNAVAILABLE",
|
8
|
-
"UNKNOWN"
|
9
|
-
],
|
10
|
-
"non_idempotent": [
|
11
|
-
"UNAVAILABLE"
|
12
|
-
],
|
13
|
-
"idempotent2": [
|
14
|
-
"DEADLINE_EXCEEDED",
|
15
|
-
"UNAVAILABLE"
|
16
|
-
],
|
17
|
-
"none": [],
|
18
|
-
"publish": [
|
19
|
-
"ABORTED",
|
20
|
-
"CANCELLED",
|
21
|
-
"DEADLINE_EXCEEDED",
|
22
|
-
"INTERNAL",
|
23
|
-
"RESOURCE_EXHAUSTED",
|
24
|
-
"UNAVAILABLE",
|
25
|
-
"UNKNOWN"
|
26
|
-
]
|
27
|
-
},
|
28
|
-
"retry_params": {
|
29
|
-
"default": {
|
30
|
-
"initial_retry_delay_millis": 100,
|
31
|
-
"retry_delay_multiplier": 1.3,
|
32
|
-
"max_retry_delay_millis": 60000,
|
33
|
-
"initial_rpc_timeout_millis": 60000,
|
34
|
-
"rpc_timeout_multiplier": 1.0,
|
35
|
-
"max_rpc_timeout_millis": 60000,
|
36
|
-
"total_timeout_millis": 600000
|
37
|
-
},
|
38
|
-
"messaging": {
|
39
|
-
"initial_retry_delay_millis": 100,
|
40
|
-
"retry_delay_multiplier": 1.3,
|
41
|
-
"max_retry_delay_millis": 60000,
|
42
|
-
"initial_rpc_timeout_millis": 5000,
|
43
|
-
"rpc_timeout_multiplier": 1.3,
|
44
|
-
"max_rpc_timeout_millis": 60000,
|
45
|
-
"total_timeout_millis": 60000
|
46
|
-
}
|
47
|
-
},
|
48
|
-
"methods": {
|
49
|
-
"CreateTopic": {
|
50
|
-
"timeout_millis": 60000,
|
51
|
-
"retry_codes_name": "non_idempotent",
|
52
|
-
"retry_params_name": "default"
|
53
|
-
},
|
54
|
-
"UpdateTopic": {
|
55
|
-
"timeout_millis": 60000,
|
56
|
-
"retry_codes_name": "non_idempotent",
|
57
|
-
"retry_params_name": "default"
|
58
|
-
},
|
59
|
-
"Publish": {
|
60
|
-
"timeout_millis": 20000,
|
61
|
-
"retry_codes_name": "publish",
|
62
|
-
"retry_params_name": "messaging",
|
63
|
-
"bundling": {
|
64
|
-
"element_count_threshold": 100,
|
65
|
-
"element_count_limit": 1000,
|
66
|
-
"request_byte_threshold": 1048576,
|
67
|
-
"request_byte_limit": 10485760,
|
68
|
-
"delay_threshold_millis": 10
|
69
|
-
}
|
70
|
-
},
|
71
|
-
"GetTopic": {
|
72
|
-
"timeout_millis": 60000,
|
73
|
-
"retry_codes_name": "idempotent",
|
74
|
-
"retry_params_name": "default"
|
75
|
-
},
|
76
|
-
"ListTopics": {
|
77
|
-
"timeout_millis": 60000,
|
78
|
-
"retry_codes_name": "idempotent",
|
79
|
-
"retry_params_name": "default"
|
80
|
-
},
|
81
|
-
"ListTopicSubscriptions": {
|
82
|
-
"timeout_millis": 60000,
|
83
|
-
"retry_codes_name": "idempotent",
|
84
|
-
"retry_params_name": "default"
|
85
|
-
},
|
86
|
-
"ListTopicSnapshots": {
|
87
|
-
"timeout_millis": 60000,
|
88
|
-
"retry_codes_name": "idempotent2",
|
89
|
-
"retry_params_name": "default"
|
90
|
-
},
|
91
|
-
"DeleteTopic": {
|
92
|
-
"timeout_millis": 60000,
|
93
|
-
"retry_codes_name": "non_idempotent",
|
94
|
-
"retry_params_name": "default"
|
95
|
-
},
|
96
|
-
"SetIamPolicy": {
|
97
|
-
"timeout_millis": 60000,
|
98
|
-
"retry_codes_name": "non_idempotent",
|
99
|
-
"retry_params_name": "default"
|
100
|
-
},
|
101
|
-
"GetIamPolicy": {
|
102
|
-
"timeout_millis": 60000,
|
103
|
-
"retry_codes_name": "idempotent",
|
104
|
-
"retry_params_name": "default"
|
105
|
-
},
|
106
|
-
"TestIamPermissions": {
|
107
|
-
"timeout_millis": 60000,
|
108
|
-
"retry_codes_name": "non_idempotent",
|
109
|
-
"retry_params_name": "default"
|
110
|
-
}
|
111
|
-
}
|
112
|
-
}
|
113
|
-
}
|
114
|
-
}
|
@@ -1,1463 +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 subscriptions and to
|
38
|
-
# consume messages from a subscription via the `Pull` method or by
|
39
|
-
# establishing a bi-directional stream using the `StreamingPull` method.
|
40
|
-
#
|
41
|
-
# @!attribute [r] iam_policy_stub
|
42
|
-
# @return [Google::Iam::V1::IAMPolicy::Stub]
|
43
|
-
# @!attribute [r] subscriber_stub
|
44
|
-
# @return [Google::Cloud::PubSub::V1::Subscriber::Stub]
|
45
|
-
class SubscriberClient
|
46
|
-
# @private
|
47
|
-
attr_reader :iam_policy_stub, :subscriber_stub
|
48
|
-
|
49
|
-
# The default address of the service.
|
50
|
-
SERVICE_ADDRESS = "pubsub.googleapis.com".freeze
|
51
|
-
|
52
|
-
# The default port of the service.
|
53
|
-
DEFAULT_SERVICE_PORT = 443
|
54
|
-
|
55
|
-
# The default set of gRPC interceptors.
|
56
|
-
GRPC_INTERCEPTORS = []
|
57
|
-
|
58
|
-
DEFAULT_TIMEOUT = 30
|
59
|
-
|
60
|
-
PAGE_DESCRIPTORS = {
|
61
|
-
"list_subscriptions" => Google::Gax::PageDescriptor.new(
|
62
|
-
"page_token",
|
63
|
-
"next_page_token",
|
64
|
-
"subscriptions"),
|
65
|
-
"list_snapshots" => Google::Gax::PageDescriptor.new(
|
66
|
-
"page_token",
|
67
|
-
"next_page_token",
|
68
|
-
"snapshots")
|
69
|
-
}.freeze
|
70
|
-
|
71
|
-
private_constant :PAGE_DESCRIPTORS
|
72
|
-
|
73
|
-
# The scopes needed to make gRPC calls to all of the methods defined in
|
74
|
-
# this service.
|
75
|
-
ALL_SCOPES = [
|
76
|
-
"https://www.googleapis.com/auth/cloud-platform",
|
77
|
-
"https://www.googleapis.com/auth/pubsub"
|
78
|
-
].freeze
|
79
|
-
|
80
|
-
|
81
|
-
PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
82
|
-
"projects/{project}"
|
83
|
-
)
|
84
|
-
|
85
|
-
private_constant :PROJECT_PATH_TEMPLATE
|
86
|
-
|
87
|
-
SNAPSHOT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
88
|
-
"projects/{project}/snapshots/{snapshot}"
|
89
|
-
)
|
90
|
-
|
91
|
-
private_constant :SNAPSHOT_PATH_TEMPLATE
|
92
|
-
|
93
|
-
SUBSCRIPTION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
94
|
-
"projects/{project}/subscriptions/{subscription}"
|
95
|
-
)
|
96
|
-
|
97
|
-
private_constant :SUBSCRIPTION_PATH_TEMPLATE
|
98
|
-
|
99
|
-
TOPIC_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
100
|
-
"projects/{project}/topics/{topic}"
|
101
|
-
)
|
102
|
-
|
103
|
-
private_constant :TOPIC_PATH_TEMPLATE
|
104
|
-
|
105
|
-
# Returns a fully-qualified project resource name string.
|
106
|
-
# @param project [String]
|
107
|
-
# @return [String]
|
108
|
-
def self.project_path project
|
109
|
-
PROJECT_PATH_TEMPLATE.render(
|
110
|
-
:"project" => project
|
111
|
-
)
|
112
|
-
end
|
113
|
-
|
114
|
-
# Returns a fully-qualified snapshot resource name string.
|
115
|
-
# @param project [String]
|
116
|
-
# @param snapshot [String]
|
117
|
-
# @return [String]
|
118
|
-
def self.snapshot_path project, snapshot
|
119
|
-
SNAPSHOT_PATH_TEMPLATE.render(
|
120
|
-
:"project" => project,
|
121
|
-
:"snapshot" => snapshot
|
122
|
-
)
|
123
|
-
end
|
124
|
-
|
125
|
-
# Returns a fully-qualified subscription resource name string.
|
126
|
-
# @param project [String]
|
127
|
-
# @param subscription [String]
|
128
|
-
# @return [String]
|
129
|
-
def self.subscription_path project, subscription
|
130
|
-
SUBSCRIPTION_PATH_TEMPLATE.render(
|
131
|
-
:"project" => project,
|
132
|
-
:"subscription" => subscription
|
133
|
-
)
|
134
|
-
end
|
135
|
-
|
136
|
-
# Returns a fully-qualified topic resource name string.
|
137
|
-
# @param project [String]
|
138
|
-
# @param topic [String]
|
139
|
-
# @return [String]
|
140
|
-
def self.topic_path project, topic
|
141
|
-
TOPIC_PATH_TEMPLATE.render(
|
142
|
-
:"project" => project,
|
143
|
-
:"topic" => topic
|
144
|
-
)
|
145
|
-
end
|
146
|
-
|
147
|
-
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
148
|
-
# Provides the means for authenticating requests made by the client. This parameter can
|
149
|
-
# be many types.
|
150
|
-
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
151
|
-
# authenticating requests made by this client.
|
152
|
-
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
153
|
-
# credentials for this client.
|
154
|
-
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
155
|
-
# credentials for this client.
|
156
|
-
# A `GRPC::Core::Channel` will be used to make calls through.
|
157
|
-
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
158
|
-
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
159
|
-
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
160
|
-
# metadata for requests, generally, to give OAuth credentials.
|
161
|
-
# @param scopes [Array<String>]
|
162
|
-
# The OAuth scopes for this service. This parameter is ignored if
|
163
|
-
# an updater_proc is supplied.
|
164
|
-
# @param client_config [Hash]
|
165
|
-
# A Hash for call options for each method. See
|
166
|
-
# Google::Gax#construct_settings for the structure of
|
167
|
-
# this data. Falls back to the default config if not specified
|
168
|
-
# or the specified config is missing data points.
|
169
|
-
# @param timeout [Numeric]
|
170
|
-
# The default timeout, in seconds, for calls made through this client.
|
171
|
-
# @param metadata [Hash]
|
172
|
-
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
173
|
-
# @param service_address [String]
|
174
|
-
# Override for the service hostname, or `nil` to leave as the default.
|
175
|
-
# @param service_port [Integer]
|
176
|
-
# Override for the service port, or `nil` to leave as the default.
|
177
|
-
# @param exception_transformer [Proc]
|
178
|
-
# An optional proc that intercepts any exceptions raised during an API call to inject
|
179
|
-
# custom error handling.
|
180
|
-
def initialize \
|
181
|
-
credentials: nil,
|
182
|
-
scopes: ALL_SCOPES,
|
183
|
-
client_config: {},
|
184
|
-
timeout: DEFAULT_TIMEOUT,
|
185
|
-
metadata: nil,
|
186
|
-
service_address: nil,
|
187
|
-
service_port: nil,
|
188
|
-
exception_transformer: nil,
|
189
|
-
lib_name: nil,
|
190
|
-
lib_version: ""
|
191
|
-
# These require statements are intentionally placed here to initialize
|
192
|
-
# the gRPC module only when it's required.
|
193
|
-
# See https://github.com/googleapis/toolkit/issues/446
|
194
|
-
require "google/gax/grpc"
|
195
|
-
require "google/iam/v1/iam_policy_services_pb"
|
196
|
-
require "google/pubsub/v1/pubsub_services_pb"
|
197
|
-
|
198
|
-
credentials ||= Google::Cloud::PubSub::V1::Credentials.default
|
199
|
-
|
200
|
-
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
201
|
-
updater_proc = Google::Cloud::PubSub::V1::Credentials.new(credentials).updater_proc
|
202
|
-
end
|
203
|
-
if credentials.is_a?(GRPC::Core::Channel)
|
204
|
-
channel = credentials
|
205
|
-
end
|
206
|
-
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
207
|
-
chan_creds = credentials
|
208
|
-
end
|
209
|
-
if credentials.is_a?(Proc)
|
210
|
-
updater_proc = credentials
|
211
|
-
end
|
212
|
-
if credentials.is_a?(Google::Auth::Credentials)
|
213
|
-
updater_proc = credentials.updater_proc
|
214
|
-
end
|
215
|
-
|
216
|
-
package_version = Google::Cloud::PubSub::VERSION
|
217
|
-
|
218
|
-
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
219
|
-
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
220
|
-
google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
|
221
|
-
google_api_client << " grpc/#{GRPC::VERSION}"
|
222
|
-
google_api_client.freeze
|
223
|
-
|
224
|
-
headers = { :"x-goog-api-client" => google_api_client }
|
225
|
-
if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
|
226
|
-
headers[:"x-goog-user-project"] = credentials.quota_project_id
|
227
|
-
end
|
228
|
-
headers.merge!(metadata) unless metadata.nil?
|
229
|
-
client_config_file = Pathname.new(__dir__).join(
|
230
|
-
"subscriber_client_config.json"
|
231
|
-
)
|
232
|
-
defaults = client_config_file.open do |f|
|
233
|
-
Google::Gax.construct_settings(
|
234
|
-
"google.pubsub.v1.Subscriber",
|
235
|
-
JSON.parse(f.read),
|
236
|
-
client_config,
|
237
|
-
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
238
|
-
timeout,
|
239
|
-
page_descriptors: PAGE_DESCRIPTORS,
|
240
|
-
errors: Google::Gax::Grpc::API_ERRORS,
|
241
|
-
metadata: headers
|
242
|
-
)
|
243
|
-
end
|
244
|
-
|
245
|
-
# Allow overriding the service path/port in subclasses.
|
246
|
-
service_path = service_address || self.class::SERVICE_ADDRESS
|
247
|
-
port = service_port || self.class::DEFAULT_SERVICE_PORT
|
248
|
-
interceptors = self.class::GRPC_INTERCEPTORS
|
249
|
-
@iam_policy_stub = Google::Gax::Grpc.create_stub(
|
250
|
-
service_path,
|
251
|
-
port,
|
252
|
-
chan_creds: chan_creds,
|
253
|
-
channel: channel,
|
254
|
-
updater_proc: updater_proc,
|
255
|
-
scopes: scopes,
|
256
|
-
interceptors: interceptors,
|
257
|
-
&Google::Iam::V1::IAMPolicy::Stub.method(:new)
|
258
|
-
)
|
259
|
-
@subscriber_stub = Google::Gax::Grpc.create_stub(
|
260
|
-
service_path,
|
261
|
-
port,
|
262
|
-
chan_creds: chan_creds,
|
263
|
-
channel: channel,
|
264
|
-
updater_proc: updater_proc,
|
265
|
-
scopes: scopes,
|
266
|
-
interceptors: interceptors,
|
267
|
-
&Google::Cloud::PubSub::V1::Subscriber::Stub.method(:new)
|
268
|
-
)
|
269
|
-
|
270
|
-
@create_subscription = Google::Gax.create_api_call(
|
271
|
-
@subscriber_stub.method(:create_subscription),
|
272
|
-
defaults["create_subscription"],
|
273
|
-
exception_transformer: exception_transformer,
|
274
|
-
params_extractor: proc do |request|
|
275
|
-
{'name' => request.name}
|
276
|
-
end
|
277
|
-
)
|
278
|
-
@get_subscription = Google::Gax.create_api_call(
|
279
|
-
@subscriber_stub.method(:get_subscription),
|
280
|
-
defaults["get_subscription"],
|
281
|
-
exception_transformer: exception_transformer,
|
282
|
-
params_extractor: proc do |request|
|
283
|
-
{'subscription' => request.subscription}
|
284
|
-
end
|
285
|
-
)
|
286
|
-
@update_subscription = Google::Gax.create_api_call(
|
287
|
-
@subscriber_stub.method(:update_subscription),
|
288
|
-
defaults["update_subscription"],
|
289
|
-
exception_transformer: exception_transformer,
|
290
|
-
params_extractor: proc do |request|
|
291
|
-
{'subscription.name' => request.subscription.name}
|
292
|
-
end
|
293
|
-
)
|
294
|
-
@list_subscriptions = Google::Gax.create_api_call(
|
295
|
-
@subscriber_stub.method(:list_subscriptions),
|
296
|
-
defaults["list_subscriptions"],
|
297
|
-
exception_transformer: exception_transformer,
|
298
|
-
params_extractor: proc do |request|
|
299
|
-
{'project' => request.project}
|
300
|
-
end
|
301
|
-
)
|
302
|
-
@delete_subscription = Google::Gax.create_api_call(
|
303
|
-
@subscriber_stub.method(:delete_subscription),
|
304
|
-
defaults["delete_subscription"],
|
305
|
-
exception_transformer: exception_transformer,
|
306
|
-
params_extractor: proc do |request|
|
307
|
-
{'subscription' => request.subscription}
|
308
|
-
end
|
309
|
-
)
|
310
|
-
@get_snapshot = Google::Gax.create_api_call(
|
311
|
-
@subscriber_stub.method(:get_snapshot),
|
312
|
-
defaults["get_snapshot"],
|
313
|
-
exception_transformer: exception_transformer,
|
314
|
-
params_extractor: proc do |request|
|
315
|
-
{'snapshot' => request.snapshot}
|
316
|
-
end
|
317
|
-
)
|
318
|
-
@modify_ack_deadline = Google::Gax.create_api_call(
|
319
|
-
@subscriber_stub.method(:modify_ack_deadline),
|
320
|
-
defaults["modify_ack_deadline"],
|
321
|
-
exception_transformer: exception_transformer,
|
322
|
-
params_extractor: proc do |request|
|
323
|
-
{'subscription' => request.subscription}
|
324
|
-
end
|
325
|
-
)
|
326
|
-
@acknowledge = Google::Gax.create_api_call(
|
327
|
-
@subscriber_stub.method(:acknowledge),
|
328
|
-
defaults["acknowledge"],
|
329
|
-
exception_transformer: exception_transformer,
|
330
|
-
params_extractor: proc do |request|
|
331
|
-
{'subscription' => request.subscription}
|
332
|
-
end
|
333
|
-
)
|
334
|
-
@pull = Google::Gax.create_api_call(
|
335
|
-
@subscriber_stub.method(:pull),
|
336
|
-
defaults["pull"],
|
337
|
-
exception_transformer: exception_transformer,
|
338
|
-
params_extractor: proc do |request|
|
339
|
-
{'subscription' => request.subscription}
|
340
|
-
end
|
341
|
-
)
|
342
|
-
@streaming_pull = Google::Gax.create_api_call(
|
343
|
-
@subscriber_stub.method(:streaming_pull),
|
344
|
-
defaults["streaming_pull"],
|
345
|
-
exception_transformer: exception_transformer
|
346
|
-
)
|
347
|
-
@modify_push_config = Google::Gax.create_api_call(
|
348
|
-
@subscriber_stub.method(:modify_push_config),
|
349
|
-
defaults["modify_push_config"],
|
350
|
-
exception_transformer: exception_transformer,
|
351
|
-
params_extractor: proc do |request|
|
352
|
-
{'subscription' => request.subscription}
|
353
|
-
end
|
354
|
-
)
|
355
|
-
@list_snapshots = Google::Gax.create_api_call(
|
356
|
-
@subscriber_stub.method(:list_snapshots),
|
357
|
-
defaults["list_snapshots"],
|
358
|
-
exception_transformer: exception_transformer,
|
359
|
-
params_extractor: proc do |request|
|
360
|
-
{'project' => request.project}
|
361
|
-
end
|
362
|
-
)
|
363
|
-
@create_snapshot = Google::Gax.create_api_call(
|
364
|
-
@subscriber_stub.method(:create_snapshot),
|
365
|
-
defaults["create_snapshot"],
|
366
|
-
exception_transformer: exception_transformer,
|
367
|
-
params_extractor: proc do |request|
|
368
|
-
{'name' => request.name}
|
369
|
-
end
|
370
|
-
)
|
371
|
-
@update_snapshot = Google::Gax.create_api_call(
|
372
|
-
@subscriber_stub.method(:update_snapshot),
|
373
|
-
defaults["update_snapshot"],
|
374
|
-
exception_transformer: exception_transformer,
|
375
|
-
params_extractor: proc do |request|
|
376
|
-
{'snapshot.name' => request.snapshot.name}
|
377
|
-
end
|
378
|
-
)
|
379
|
-
@delete_snapshot = Google::Gax.create_api_call(
|
380
|
-
@subscriber_stub.method(:delete_snapshot),
|
381
|
-
defaults["delete_snapshot"],
|
382
|
-
exception_transformer: exception_transformer,
|
383
|
-
params_extractor: proc do |request|
|
384
|
-
{'snapshot' => request.snapshot}
|
385
|
-
end
|
386
|
-
)
|
387
|
-
@seek = Google::Gax.create_api_call(
|
388
|
-
@subscriber_stub.method(:seek),
|
389
|
-
defaults["seek"],
|
390
|
-
exception_transformer: exception_transformer,
|
391
|
-
params_extractor: proc do |request|
|
392
|
-
{'subscription' => request.subscription}
|
393
|
-
end
|
394
|
-
)
|
395
|
-
@set_iam_policy = Google::Gax.create_api_call(
|
396
|
-
@iam_policy_stub.method(:set_iam_policy),
|
397
|
-
defaults["set_iam_policy"],
|
398
|
-
exception_transformer: exception_transformer,
|
399
|
-
params_extractor: proc do |request|
|
400
|
-
{'resource' => request.resource}
|
401
|
-
end
|
402
|
-
)
|
403
|
-
@get_iam_policy = Google::Gax.create_api_call(
|
404
|
-
@iam_policy_stub.method(:get_iam_policy),
|
405
|
-
defaults["get_iam_policy"],
|
406
|
-
exception_transformer: exception_transformer,
|
407
|
-
params_extractor: proc do |request|
|
408
|
-
{'resource' => request.resource}
|
409
|
-
end
|
410
|
-
)
|
411
|
-
@test_iam_permissions = Google::Gax.create_api_call(
|
412
|
-
@iam_policy_stub.method(:test_iam_permissions),
|
413
|
-
defaults["test_iam_permissions"],
|
414
|
-
exception_transformer: exception_transformer,
|
415
|
-
params_extractor: proc do |request|
|
416
|
-
{'resource' => request.resource}
|
417
|
-
end
|
418
|
-
)
|
419
|
-
end
|
420
|
-
|
421
|
-
# Service calls
|
422
|
-
|
423
|
-
# Creates a subscription to a given topic. See the
|
424
|
-
# <a href="https://cloud.google.com/pubsub/docs/admin#resource_names">
|
425
|
-
# resource name rules</a>.
|
426
|
-
# If the subscription already exists, returns `ALREADY_EXISTS`.
|
427
|
-
# If the corresponding topic doesn't exist, returns `NOT_FOUND`.
|
428
|
-
#
|
429
|
-
# If the name is not provided in the request, the server will assign a random
|
430
|
-
# name for this subscription on the same project as the topic, conforming
|
431
|
-
# to the
|
432
|
-
# [resource name
|
433
|
-
# format](https://cloud.google.com/pubsub/docs/admin#resource_names). The
|
434
|
-
# generated name is populated in the returned Subscription object. Note that
|
435
|
-
# for REST API requests, you must specify a name in the request.
|
436
|
-
#
|
437
|
-
# @param name [String]
|
438
|
-
# Required. The name of the subscription. It must have the format
|
439
|
-
# `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
|
440
|
-
# start with a letter, and contain only letters (`[A-Za-z]`), numbers
|
441
|
-
# (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
|
442
|
-
# plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
|
443
|
-
# in length, and it must not start with `"goog"`.
|
444
|
-
# @param topic [String]
|
445
|
-
# Required. The name of the topic from which this subscription is receiving
|
446
|
-
# messages. Format is `projects/{project}/topics/{topic}`. The value of this
|
447
|
-
# field will be `_deleted-topic_` if the topic has been deleted.
|
448
|
-
# @param push_config [Google::Cloud::PubSub::V1::PushConfig | Hash]
|
449
|
-
# If push delivery is used with this subscription, this field is
|
450
|
-
# used to configure it. An empty `pushConfig` signifies that the subscriber
|
451
|
-
# will pull and ack messages using API methods.
|
452
|
-
# A hash of the same form as `Google::Cloud::PubSub::V1::PushConfig`
|
453
|
-
# can also be provided.
|
454
|
-
# @param ack_deadline_seconds [Integer]
|
455
|
-
# The approximate amount of time (on a best-effort basis) Pub/Sub waits for
|
456
|
-
# the subscriber to acknowledge receipt before resending the message. In the
|
457
|
-
# interval after the message is delivered and before it is acknowledged, it
|
458
|
-
# is considered to be <i>outstanding</i>. During that time period, the
|
459
|
-
# message will not be redelivered (on a best-effort basis).
|
460
|
-
#
|
461
|
-
# For pull subscriptions, this value is used as the initial value for the ack
|
462
|
-
# deadline. To override this value for a given message, call
|
463
|
-
# `ModifyAckDeadline` with the corresponding `ack_id` if using
|
464
|
-
# non-streaming pull or send the `ack_id` in a
|
465
|
-
# `StreamingModifyAckDeadlineRequest` if using streaming pull.
|
466
|
-
# The minimum custom deadline you can specify is 10 seconds.
|
467
|
-
# The maximum custom deadline you can specify is 600 seconds (10 minutes).
|
468
|
-
# If this parameter is 0, a default value of 10 seconds is used.
|
469
|
-
#
|
470
|
-
# For push delivery, this value is also used to set the request timeout for
|
471
|
-
# the call to the push endpoint.
|
472
|
-
#
|
473
|
-
# If the subscriber never acknowledges the message, the Pub/Sub
|
474
|
-
# system will eventually redeliver the message.
|
475
|
-
# @param retain_acked_messages [true, false]
|
476
|
-
# Indicates whether to retain acknowledged messages. If true, then
|
477
|
-
# messages are not expunged from the subscription's backlog, even if they are
|
478
|
-
# acknowledged, until they fall out of the `message_retention_duration`
|
479
|
-
# window. This must be true if you would like to
|
480
|
-
# <a
|
481
|
-
# href="https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time">
|
482
|
-
# Seek to a timestamp</a>.
|
483
|
-
# @param message_retention_duration [Google::Protobuf::Duration | Hash]
|
484
|
-
# How long to retain unacknowledged messages in the subscription's backlog,
|
485
|
-
# from the moment a message is published.
|
486
|
-
# If `retain_acked_messages` is true, then this also configures the retention
|
487
|
-
# of acknowledged messages, and thus configures how far back in time a `Seek`
|
488
|
-
# can be done. Defaults to 7 days. Cannot be more than 7 days or less than 10
|
489
|
-
# minutes.
|
490
|
-
# A hash of the same form as `Google::Protobuf::Duration`
|
491
|
-
# can also be provided.
|
492
|
-
# @param labels [Hash{String => String}]
|
493
|
-
# See <a href="https://cloud.google.com/pubsub/docs/labels"> Creating and
|
494
|
-
# managing labels</a>.
|
495
|
-
# @param enable_message_ordering [true, false]
|
496
|
-
# If true, messages published with the same `ordering_key` in `PubsubMessage`
|
497
|
-
# will be delivered to the subscribers in the order in which they
|
498
|
-
# are received by the Pub/Sub system. Otherwise, they may be delivered in
|
499
|
-
# any order.
|
500
|
-
# <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
|
501
|
-
# API might be changed in backward-incompatible ways and is not recommended
|
502
|
-
# for production use. It is not subject to any SLA or deprecation policy.
|
503
|
-
# @param expiration_policy [Google::Cloud::PubSub::V1::ExpirationPolicy | Hash]
|
504
|
-
# A policy that specifies the conditions for this subscription's expiration.
|
505
|
-
# A subscription is considered active as long as any connected subscriber is
|
506
|
-
# successfully consuming messages from the subscription or is issuing
|
507
|
-
# operations on the subscription. If `expiration_policy` is not set, a
|
508
|
-
# *default policy* with `ttl` of 31 days will be used. The minimum allowed
|
509
|
-
# value for `expiration_policy.ttl` is 1 day.
|
510
|
-
# A hash of the same form as `Google::Cloud::PubSub::V1::ExpirationPolicy`
|
511
|
-
# can also be provided.
|
512
|
-
# @param filter [String]
|
513
|
-
# An expression written in the Cloud Pub/Sub filter language. If non-empty,
|
514
|
-
# then only `PubsubMessage`s whose `attributes` field matches the filter are
|
515
|
-
# delivered on this subscription. If empty, then no messages are filtered
|
516
|
-
# out.
|
517
|
-
# <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
|
518
|
-
# API might be changed in backward-incompatible ways and is not recommended
|
519
|
-
# for production use. It is not subject to any SLA or deprecation policy.
|
520
|
-
# @param dead_letter_policy [Google::Cloud::PubSub::V1::DeadLetterPolicy | Hash]
|
521
|
-
# A policy that specifies the conditions for dead lettering messages in
|
522
|
-
# this subscription. If dead_letter_policy is not set, dead lettering
|
523
|
-
# is disabled.
|
524
|
-
#
|
525
|
-
# The Cloud Pub/Sub service account associated with this subscriptions's
|
526
|
-
# parent project (i.e.,
|
527
|
-
# service-\\{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have
|
528
|
-
# permission to Acknowledge() messages on this subscription.
|
529
|
-
# A hash of the same form as `Google::Cloud::PubSub::V1::DeadLetterPolicy`
|
530
|
-
# can also be provided.
|
531
|
-
# @param retry_policy [Google::Cloud::PubSub::V1::RetryPolicy | Hash]
|
532
|
-
# A policy that specifies how Cloud Pub/Sub retries message delivery for this
|
533
|
-
# subscription.
|
534
|
-
#
|
535
|
-
# If not set, the default retry policy is applied. This generally implies
|
536
|
-
# that messages will be retried as soon as possible for healthy subscribers.
|
537
|
-
# RetryPolicy will be triggered on NACKs or acknowledgement deadline
|
538
|
-
# exceeded events for a given message.
|
539
|
-
# <b>EXPERIMENTAL:</b> This API might be changed in backward-incompatible
|
540
|
-
# ways and is not recommended for production use. It is not subject to any
|
541
|
-
# SLA or deprecation policy.
|
542
|
-
# A hash of the same form as `Google::Cloud::PubSub::V1::RetryPolicy`
|
543
|
-
# can also be provided.
|
544
|
-
# @param options [Google::Gax::CallOptions]
|
545
|
-
# Overrides the default settings for this call, e.g, timeout,
|
546
|
-
# retries, etc.
|
547
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
548
|
-
# @yieldparam result [Google::Cloud::PubSub::V1::Subscription]
|
549
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
550
|
-
# @return [Google::Cloud::PubSub::V1::Subscription]
|
551
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
552
|
-
# @example
|
553
|
-
# require "google/cloud/pubsub"
|
554
|
-
#
|
555
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
556
|
-
# formatted_name = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
|
557
|
-
# formatted_topic = Google::Cloud::PubSub::V1::SubscriberClient.topic_path("[PROJECT]", "[TOPIC]")
|
558
|
-
# response = subscriber_client.create_subscription(formatted_name, formatted_topic)
|
559
|
-
|
560
|
-
def create_subscription \
|
561
|
-
name,
|
562
|
-
topic,
|
563
|
-
push_config: nil,
|
564
|
-
ack_deadline_seconds: nil,
|
565
|
-
retain_acked_messages: nil,
|
566
|
-
message_retention_duration: nil,
|
567
|
-
labels: nil,
|
568
|
-
enable_message_ordering: nil,
|
569
|
-
expiration_policy: nil,
|
570
|
-
filter: nil,
|
571
|
-
dead_letter_policy: nil,
|
572
|
-
retry_policy: nil,
|
573
|
-
options: nil,
|
574
|
-
&block
|
575
|
-
req = {
|
576
|
-
name: name,
|
577
|
-
topic: topic,
|
578
|
-
push_config: push_config,
|
579
|
-
ack_deadline_seconds: ack_deadline_seconds,
|
580
|
-
retain_acked_messages: retain_acked_messages,
|
581
|
-
message_retention_duration: message_retention_duration,
|
582
|
-
labels: labels,
|
583
|
-
enable_message_ordering: enable_message_ordering,
|
584
|
-
expiration_policy: expiration_policy,
|
585
|
-
filter: filter,
|
586
|
-
dead_letter_policy: dead_letter_policy,
|
587
|
-
retry_policy: retry_policy
|
588
|
-
}.delete_if { |_, v| v.nil? }
|
589
|
-
req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::Subscription)
|
590
|
-
@create_subscription.call(req, options, &block)
|
591
|
-
end
|
592
|
-
|
593
|
-
# Gets the configuration details of a subscription.
|
594
|
-
#
|
595
|
-
# @param subscription [String]
|
596
|
-
# Required. The name of the subscription to get.
|
597
|
-
# Format is `projects/{project}/subscriptions/{sub}`.
|
598
|
-
# @param options [Google::Gax::CallOptions]
|
599
|
-
# Overrides the default settings for this call, e.g, timeout,
|
600
|
-
# retries, etc.
|
601
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
602
|
-
# @yieldparam result [Google::Cloud::PubSub::V1::Subscription]
|
603
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
604
|
-
# @return [Google::Cloud::PubSub::V1::Subscription]
|
605
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
606
|
-
# @example
|
607
|
-
# require "google/cloud/pubsub"
|
608
|
-
#
|
609
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
610
|
-
# formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
|
611
|
-
# response = subscriber_client.get_subscription(formatted_subscription)
|
612
|
-
|
613
|
-
def get_subscription \
|
614
|
-
subscription,
|
615
|
-
options: nil,
|
616
|
-
&block
|
617
|
-
req = {
|
618
|
-
subscription: subscription
|
619
|
-
}.delete_if { |_, v| v.nil? }
|
620
|
-
req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::GetSubscriptionRequest)
|
621
|
-
@get_subscription.call(req, options, &block)
|
622
|
-
end
|
623
|
-
|
624
|
-
# Updates an existing subscription. Note that certain properties of a
|
625
|
-
# subscription, such as its topic, are not modifiable.
|
626
|
-
#
|
627
|
-
# @param subscription [Google::Cloud::PubSub::V1::Subscription | Hash]
|
628
|
-
# Required. The updated subscription object.
|
629
|
-
# A hash of the same form as `Google::Cloud::PubSub::V1::Subscription`
|
630
|
-
# can also be provided.
|
631
|
-
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
632
|
-
# Required. Indicates which fields in the provided subscription to update.
|
633
|
-
# Must be specified and non-empty.
|
634
|
-
# A hash of the same form as `Google::Protobuf::FieldMask`
|
635
|
-
# can also be provided.
|
636
|
-
# @param options [Google::Gax::CallOptions]
|
637
|
-
# Overrides the default settings for this call, e.g, timeout,
|
638
|
-
# retries, etc.
|
639
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
640
|
-
# @yieldparam result [Google::Cloud::PubSub::V1::Subscription]
|
641
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
642
|
-
# @return [Google::Cloud::PubSub::V1::Subscription]
|
643
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
644
|
-
# @example
|
645
|
-
# require "google/cloud/pubsub"
|
646
|
-
#
|
647
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
648
|
-
# ack_deadline_seconds = 42
|
649
|
-
# subscription = { ack_deadline_seconds: ack_deadline_seconds }
|
650
|
-
# paths_element = "ack_deadline_seconds"
|
651
|
-
# paths = [paths_element]
|
652
|
-
# update_mask = { paths: paths }
|
653
|
-
# response = subscriber_client.update_subscription(subscription, update_mask)
|
654
|
-
|
655
|
-
def update_subscription \
|
656
|
-
subscription,
|
657
|
-
update_mask,
|
658
|
-
options: nil,
|
659
|
-
&block
|
660
|
-
req = {
|
661
|
-
subscription: subscription,
|
662
|
-
update_mask: update_mask
|
663
|
-
}.delete_if { |_, v| v.nil? }
|
664
|
-
req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::UpdateSubscriptionRequest)
|
665
|
-
@update_subscription.call(req, options, &block)
|
666
|
-
end
|
667
|
-
|
668
|
-
# Lists matching subscriptions.
|
669
|
-
#
|
670
|
-
# @param project [String]
|
671
|
-
# Required. The name of the project in which to list subscriptions.
|
672
|
-
# Format is `projects/{project-id}`.
|
673
|
-
# @param page_size [Integer]
|
674
|
-
# The maximum number of resources contained in the underlying API
|
675
|
-
# response. If page streaming is performed per-resource, this
|
676
|
-
# parameter does not affect the return value. If page streaming is
|
677
|
-
# performed per-page, this determines the maximum number of
|
678
|
-
# resources in a page.
|
679
|
-
# @param options [Google::Gax::CallOptions]
|
680
|
-
# Overrides the default settings for this call, e.g, timeout,
|
681
|
-
# retries, etc.
|
682
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
683
|
-
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::PubSub::V1::Subscription>]
|
684
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
685
|
-
# @return [Google::Gax::PagedEnumerable<Google::Cloud::PubSub::V1::Subscription>]
|
686
|
-
# An enumerable of Google::Cloud::PubSub::V1::Subscription instances.
|
687
|
-
# See Google::Gax::PagedEnumerable documentation for other
|
688
|
-
# operations such as per-page iteration or access to the response
|
689
|
-
# object.
|
690
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
691
|
-
# @example
|
692
|
-
# require "google/cloud/pubsub"
|
693
|
-
#
|
694
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
695
|
-
# formatted_project = Google::Cloud::PubSub::V1::SubscriberClient.project_path("[PROJECT]")
|
696
|
-
#
|
697
|
-
# # Iterate over all results.
|
698
|
-
# subscriber_client.list_subscriptions(formatted_project).each do |element|
|
699
|
-
# # Process element.
|
700
|
-
# end
|
701
|
-
#
|
702
|
-
# # Or iterate over results one page at a time.
|
703
|
-
# subscriber_client.list_subscriptions(formatted_project).each_page do |page|
|
704
|
-
# # Process each page at a time.
|
705
|
-
# page.each do |element|
|
706
|
-
# # Process element.
|
707
|
-
# end
|
708
|
-
# end
|
709
|
-
|
710
|
-
def list_subscriptions \
|
711
|
-
project,
|
712
|
-
page_size: nil,
|
713
|
-
options: nil,
|
714
|
-
&block
|
715
|
-
req = {
|
716
|
-
project: project,
|
717
|
-
page_size: page_size
|
718
|
-
}.delete_if { |_, v| v.nil? }
|
719
|
-
req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::ListSubscriptionsRequest)
|
720
|
-
@list_subscriptions.call(req, options, &block)
|
721
|
-
end
|
722
|
-
|
723
|
-
# Deletes an existing subscription. All messages retained in the subscription
|
724
|
-
# are immediately dropped. Calls to `Pull` after deletion will return
|
725
|
-
# `NOT_FOUND`. After a subscription is deleted, a new one may be created with
|
726
|
-
# the same name, but the new one has no association with the old
|
727
|
-
# subscription or its topic unless the same topic is specified.
|
728
|
-
#
|
729
|
-
# @param subscription [String]
|
730
|
-
# Required. The subscription to delete.
|
731
|
-
# Format is `projects/{project}/subscriptions/{sub}`.
|
732
|
-
# @param options [Google::Gax::CallOptions]
|
733
|
-
# Overrides the default settings for this call, e.g, timeout,
|
734
|
-
# retries, etc.
|
735
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
736
|
-
# @yieldparam result []
|
737
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
738
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
739
|
-
# @example
|
740
|
-
# require "google/cloud/pubsub"
|
741
|
-
#
|
742
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
743
|
-
# formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
|
744
|
-
# subscriber_client.delete_subscription(formatted_subscription)
|
745
|
-
|
746
|
-
def delete_subscription \
|
747
|
-
subscription,
|
748
|
-
options: nil,
|
749
|
-
&block
|
750
|
-
req = {
|
751
|
-
subscription: subscription
|
752
|
-
}.delete_if { |_, v| v.nil? }
|
753
|
-
req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::DeleteSubscriptionRequest)
|
754
|
-
@delete_subscription.call(req, options, &block)
|
755
|
-
nil
|
756
|
-
end
|
757
|
-
|
758
|
-
# Gets the configuration details of a snapshot. Snapshots are used in
|
759
|
-
# <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
|
760
|
-
# operations, which allow you to manage message acknowledgments in bulk. That
|
761
|
-
# is, you can set the acknowledgment state of messages in an existing
|
762
|
-
# subscription to the state captured by a snapshot.
|
763
|
-
#
|
764
|
-
# @param snapshot [String]
|
765
|
-
# Required. The name of the snapshot to get.
|
766
|
-
# Format is `projects/{project}/snapshots/{snap}`.
|
767
|
-
# @param options [Google::Gax::CallOptions]
|
768
|
-
# Overrides the default settings for this call, e.g, timeout,
|
769
|
-
# retries, etc.
|
770
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
771
|
-
# @yieldparam result [Google::Cloud::PubSub::V1::Snapshot]
|
772
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
773
|
-
# @return [Google::Cloud::PubSub::V1::Snapshot]
|
774
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
775
|
-
# @example
|
776
|
-
# require "google/cloud/pubsub"
|
777
|
-
#
|
778
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
779
|
-
# formatted_snapshot = Google::Cloud::PubSub::V1::SubscriberClient.snapshot_path("[PROJECT]", "[SNAPSHOT]")
|
780
|
-
# response = subscriber_client.get_snapshot(formatted_snapshot)
|
781
|
-
|
782
|
-
def get_snapshot \
|
783
|
-
snapshot,
|
784
|
-
options: nil,
|
785
|
-
&block
|
786
|
-
req = {
|
787
|
-
snapshot: snapshot
|
788
|
-
}.delete_if { |_, v| v.nil? }
|
789
|
-
req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::GetSnapshotRequest)
|
790
|
-
@get_snapshot.call(req, options, &block)
|
791
|
-
end
|
792
|
-
|
793
|
-
# Modifies the ack deadline for a specific message. This method is useful
|
794
|
-
# to indicate that more time is needed to process a message by the
|
795
|
-
# subscriber, or to make the message available for redelivery if the
|
796
|
-
# processing was interrupted. Note that this does not modify the
|
797
|
-
# subscription-level `ackDeadlineSeconds` used for subsequent messages.
|
798
|
-
#
|
799
|
-
# @param subscription [String]
|
800
|
-
# Required. The name of the subscription.
|
801
|
-
# Format is `projects/{project}/subscriptions/{sub}`.
|
802
|
-
# @param ack_ids [Array<String>]
|
803
|
-
# Required. List of acknowledgment IDs.
|
804
|
-
# @param ack_deadline_seconds [Integer]
|
805
|
-
# Required. The new ack deadline with respect to the time this request was
|
806
|
-
# sent to the Pub/Sub system. For example, if the value is 10, the new ack
|
807
|
-
# deadline will expire 10 seconds after the `ModifyAckDeadline` call was
|
808
|
-
# made. Specifying zero might immediately make the message available for
|
809
|
-
# delivery to another subscriber client. This typically results in an
|
810
|
-
# increase in the rate of message redeliveries (that is, duplicates).
|
811
|
-
# The minimum deadline you can specify is 0 seconds.
|
812
|
-
# The maximum deadline you can specify is 600 seconds (10 minutes).
|
813
|
-
# @param options [Google::Gax::CallOptions]
|
814
|
-
# Overrides the default settings for this call, e.g, timeout,
|
815
|
-
# retries, etc.
|
816
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
817
|
-
# @yieldparam result []
|
818
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
819
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
820
|
-
# @example
|
821
|
-
# require "google/cloud/pubsub"
|
822
|
-
#
|
823
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
824
|
-
# formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
|
825
|
-
#
|
826
|
-
# # TODO: Initialize `ack_ids`:
|
827
|
-
# ack_ids = []
|
828
|
-
#
|
829
|
-
# # TODO: Initialize `ack_deadline_seconds`:
|
830
|
-
# ack_deadline_seconds = 0
|
831
|
-
# subscriber_client.modify_ack_deadline(formatted_subscription, ack_ids, ack_deadline_seconds)
|
832
|
-
|
833
|
-
def modify_ack_deadline \
|
834
|
-
subscription,
|
835
|
-
ack_ids,
|
836
|
-
ack_deadline_seconds,
|
837
|
-
options: nil,
|
838
|
-
&block
|
839
|
-
req = {
|
840
|
-
subscription: subscription,
|
841
|
-
ack_ids: ack_ids,
|
842
|
-
ack_deadline_seconds: ack_deadline_seconds
|
843
|
-
}.delete_if { |_, v| v.nil? }
|
844
|
-
req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::ModifyAckDeadlineRequest)
|
845
|
-
@modify_ack_deadline.call(req, options, &block)
|
846
|
-
nil
|
847
|
-
end
|
848
|
-
|
849
|
-
# Acknowledges the messages associated with the `ack_ids` in the
|
850
|
-
# `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages
|
851
|
-
# from the subscription.
|
852
|
-
#
|
853
|
-
# Acknowledging a message whose ack deadline has expired may succeed,
|
854
|
-
# but such a message may be redelivered later. Acknowledging a message more
|
855
|
-
# than once will not result in an error.
|
856
|
-
#
|
857
|
-
# @param subscription [String]
|
858
|
-
# Required. The subscription whose message is being acknowledged.
|
859
|
-
# Format is `projects/{project}/subscriptions/{sub}`.
|
860
|
-
# @param ack_ids [Array<String>]
|
861
|
-
# Required. The acknowledgment ID for the messages being acknowledged that
|
862
|
-
# was returned by the Pub/Sub system in the `Pull` response. Must not be
|
863
|
-
# empty.
|
864
|
-
# @param options [Google::Gax::CallOptions]
|
865
|
-
# Overrides the default settings for this call, e.g, timeout,
|
866
|
-
# retries, etc.
|
867
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
868
|
-
# @yieldparam result []
|
869
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
870
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
871
|
-
# @example
|
872
|
-
# require "google/cloud/pubsub"
|
873
|
-
#
|
874
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
875
|
-
# formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
|
876
|
-
#
|
877
|
-
# # TODO: Initialize `ack_ids`:
|
878
|
-
# ack_ids = []
|
879
|
-
# subscriber_client.acknowledge(formatted_subscription, ack_ids)
|
880
|
-
|
881
|
-
def acknowledge \
|
882
|
-
subscription,
|
883
|
-
ack_ids,
|
884
|
-
options: nil,
|
885
|
-
&block
|
886
|
-
req = {
|
887
|
-
subscription: subscription,
|
888
|
-
ack_ids: ack_ids
|
889
|
-
}.delete_if { |_, v| v.nil? }
|
890
|
-
req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::AcknowledgeRequest)
|
891
|
-
@acknowledge.call(req, options, &block)
|
892
|
-
nil
|
893
|
-
end
|
894
|
-
|
895
|
-
# Pulls messages from the server. The server may return `UNAVAILABLE` if
|
896
|
-
# there are too many concurrent pull requests pending for the given
|
897
|
-
# subscription.
|
898
|
-
#
|
899
|
-
# @param subscription [String]
|
900
|
-
# Required. The subscription from which messages should be pulled.
|
901
|
-
# Format is `projects/{project}/subscriptions/{sub}`.
|
902
|
-
# @param max_messages [Integer]
|
903
|
-
# Required. The maximum number of messages to return for this request. Must
|
904
|
-
# be a positive integer. The Pub/Sub system may return fewer than the number
|
905
|
-
# specified.
|
906
|
-
# @param return_immediately [true, false]
|
907
|
-
# Optional. If this field set to true, the system will respond immediately
|
908
|
-
# even if it there are no messages available to return in the `Pull`
|
909
|
-
# response. Otherwise, the system may wait (for a bounded amount of time)
|
910
|
-
# until at least one message is available, rather than returning no messages.
|
911
|
-
# Warning: setting this field to `true` is discouraged because it adversely
|
912
|
-
# impacts the performance of `Pull` operations. We recommend that users do
|
913
|
-
# not set this field.
|
914
|
-
# @param options [Google::Gax::CallOptions]
|
915
|
-
# Overrides the default settings for this call, e.g, timeout,
|
916
|
-
# retries, etc.
|
917
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
918
|
-
# @yieldparam result [Google::Cloud::PubSub::V1::PullResponse]
|
919
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
920
|
-
# @return [Google::Cloud::PubSub::V1::PullResponse]
|
921
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
922
|
-
# @example
|
923
|
-
# require "google/cloud/pubsub"
|
924
|
-
#
|
925
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
926
|
-
# formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
|
927
|
-
#
|
928
|
-
# # TODO: Initialize `max_messages`:
|
929
|
-
# max_messages = 0
|
930
|
-
# response = subscriber_client.pull(formatted_subscription, max_messages)
|
931
|
-
|
932
|
-
def pull \
|
933
|
-
subscription,
|
934
|
-
max_messages,
|
935
|
-
return_immediately: nil,
|
936
|
-
options: nil,
|
937
|
-
&block
|
938
|
-
req = {
|
939
|
-
subscription: subscription,
|
940
|
-
max_messages: max_messages,
|
941
|
-
return_immediately: return_immediately
|
942
|
-
}.delete_if { |_, v| v.nil? }
|
943
|
-
req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::PullRequest)
|
944
|
-
@pull.call(req, options, &block)
|
945
|
-
end
|
946
|
-
|
947
|
-
# Establishes a stream with the server, which sends messages down to the
|
948
|
-
# client. The client streams acknowledgements and ack deadline modifications
|
949
|
-
# back to the server. The server will close the stream and return the status
|
950
|
-
# on any error. The server may close the stream with status `UNAVAILABLE` to
|
951
|
-
# reassign server-side resources, in which case, the client should
|
952
|
-
# re-establish the stream. Flow control can be achieved by configuring the
|
953
|
-
# underlying RPC channel.
|
954
|
-
#
|
955
|
-
# @param reqs [Enumerable<Google::Cloud::PubSub::V1::StreamingPullRequest>]
|
956
|
-
# The input requests.
|
957
|
-
# @param options [Google::Gax::CallOptions]
|
958
|
-
# Overrides the default settings for this call, e.g, timeout,
|
959
|
-
# retries, etc.
|
960
|
-
# @return [Enumerable<Google::Cloud::PubSub::V1::StreamingPullResponse>]
|
961
|
-
# An enumerable of Google::Cloud::PubSub::V1::StreamingPullResponse instances.
|
962
|
-
#
|
963
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
964
|
-
#
|
965
|
-
# @note
|
966
|
-
# EXPERIMENTAL:
|
967
|
-
# Streaming requests are still undergoing review.
|
968
|
-
# This method interface might change in the future.
|
969
|
-
#
|
970
|
-
# @example
|
971
|
-
# require "google/cloud/pubsub"
|
972
|
-
#
|
973
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
974
|
-
# formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
|
975
|
-
#
|
976
|
-
# # TODO: Initialize `stream_ack_deadline_seconds`:
|
977
|
-
# stream_ack_deadline_seconds = 0
|
978
|
-
# request = { subscription: formatted_subscription, stream_ack_deadline_seconds: stream_ack_deadline_seconds }
|
979
|
-
# requests = [request]
|
980
|
-
# subscriber_client.streaming_pull(requests).each do |element|
|
981
|
-
# # Process element.
|
982
|
-
# end
|
983
|
-
|
984
|
-
def streaming_pull reqs, options: nil
|
985
|
-
request_protos = reqs.lazy.map do |req|
|
986
|
-
Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::StreamingPullRequest)
|
987
|
-
end
|
988
|
-
@streaming_pull.call(request_protos, options)
|
989
|
-
end
|
990
|
-
|
991
|
-
# Modifies the `PushConfig` for a specified subscription.
|
992
|
-
#
|
993
|
-
# This may be used to change a push subscription to a pull one (signified by
|
994
|
-
# an empty `PushConfig`) or vice versa, or change the endpoint URL and other
|
995
|
-
# attributes of a push subscription. Messages will accumulate for delivery
|
996
|
-
# continuously through the call regardless of changes to the `PushConfig`.
|
997
|
-
#
|
998
|
-
# @param subscription [String]
|
999
|
-
# Required. The name of the subscription.
|
1000
|
-
# Format is `projects/{project}/subscriptions/{sub}`.
|
1001
|
-
# @param push_config [Google::Cloud::PubSub::V1::PushConfig | Hash]
|
1002
|
-
# Required. The push configuration for future deliveries.
|
1003
|
-
#
|
1004
|
-
# An empty `pushConfig` indicates that the Pub/Sub system should
|
1005
|
-
# stop pushing messages from the given subscription and allow
|
1006
|
-
# messages to be pulled and acknowledged - effectively pausing
|
1007
|
-
# the subscription if `Pull` or `StreamingPull` is not called.
|
1008
|
-
# A hash of the same form as `Google::Cloud::PubSub::V1::PushConfig`
|
1009
|
-
# can also be provided.
|
1010
|
-
# @param options [Google::Gax::CallOptions]
|
1011
|
-
# Overrides the default settings for this call, e.g, timeout,
|
1012
|
-
# retries, etc.
|
1013
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
1014
|
-
# @yieldparam result []
|
1015
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1016
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1017
|
-
# @example
|
1018
|
-
# require "google/cloud/pubsub"
|
1019
|
-
#
|
1020
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
1021
|
-
# formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
|
1022
|
-
#
|
1023
|
-
# # TODO: Initialize `push_config`:
|
1024
|
-
# push_config = {}
|
1025
|
-
# subscriber_client.modify_push_config(formatted_subscription, push_config)
|
1026
|
-
|
1027
|
-
def modify_push_config \
|
1028
|
-
subscription,
|
1029
|
-
push_config,
|
1030
|
-
options: nil,
|
1031
|
-
&block
|
1032
|
-
req = {
|
1033
|
-
subscription: subscription,
|
1034
|
-
push_config: push_config
|
1035
|
-
}.delete_if { |_, v| v.nil? }
|
1036
|
-
req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::ModifyPushConfigRequest)
|
1037
|
-
@modify_push_config.call(req, options, &block)
|
1038
|
-
nil
|
1039
|
-
end
|
1040
|
-
|
1041
|
-
# Lists the existing snapshots. Snapshots are used in
|
1042
|
-
# <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
|
1043
|
-
# operations, which allow
|
1044
|
-
# you to manage message acknowledgments in bulk. That is, you can set the
|
1045
|
-
# acknowledgment state of messages in an existing subscription to the state
|
1046
|
-
# captured by a snapshot.
|
1047
|
-
#
|
1048
|
-
# @param project [String]
|
1049
|
-
# Required. The name of the project in which to list snapshots.
|
1050
|
-
# Format is `projects/{project-id}`.
|
1051
|
-
# @param page_size [Integer]
|
1052
|
-
# The maximum number of resources contained in the underlying API
|
1053
|
-
# response. If page streaming is performed per-resource, this
|
1054
|
-
# parameter does not affect the return value. If page streaming is
|
1055
|
-
# performed per-page, this determines the maximum number of
|
1056
|
-
# resources in a page.
|
1057
|
-
# @param options [Google::Gax::CallOptions]
|
1058
|
-
# Overrides the default settings for this call, e.g, timeout,
|
1059
|
-
# retries, etc.
|
1060
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
1061
|
-
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::PubSub::V1::Snapshot>]
|
1062
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1063
|
-
# @return [Google::Gax::PagedEnumerable<Google::Cloud::PubSub::V1::Snapshot>]
|
1064
|
-
# An enumerable of Google::Cloud::PubSub::V1::Snapshot instances.
|
1065
|
-
# See Google::Gax::PagedEnumerable documentation for other
|
1066
|
-
# operations such as per-page iteration or access to the response
|
1067
|
-
# object.
|
1068
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1069
|
-
# @example
|
1070
|
-
# require "google/cloud/pubsub"
|
1071
|
-
#
|
1072
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
1073
|
-
# formatted_project = Google::Cloud::PubSub::V1::SubscriberClient.project_path("[PROJECT]")
|
1074
|
-
#
|
1075
|
-
# # Iterate over all results.
|
1076
|
-
# subscriber_client.list_snapshots(formatted_project).each do |element|
|
1077
|
-
# # Process element.
|
1078
|
-
# end
|
1079
|
-
#
|
1080
|
-
# # Or iterate over results one page at a time.
|
1081
|
-
# subscriber_client.list_snapshots(formatted_project).each_page do |page|
|
1082
|
-
# # Process each page at a time.
|
1083
|
-
# page.each do |element|
|
1084
|
-
# # Process element.
|
1085
|
-
# end
|
1086
|
-
# end
|
1087
|
-
|
1088
|
-
def list_snapshots \
|
1089
|
-
project,
|
1090
|
-
page_size: nil,
|
1091
|
-
options: nil,
|
1092
|
-
&block
|
1093
|
-
req = {
|
1094
|
-
project: project,
|
1095
|
-
page_size: page_size
|
1096
|
-
}.delete_if { |_, v| v.nil? }
|
1097
|
-
req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::ListSnapshotsRequest)
|
1098
|
-
@list_snapshots.call(req, options, &block)
|
1099
|
-
end
|
1100
|
-
|
1101
|
-
# Creates a snapshot from the requested subscription. Snapshots are used in
|
1102
|
-
# <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
|
1103
|
-
# operations, which allow
|
1104
|
-
# you to manage message acknowledgments in bulk. That is, you can set the
|
1105
|
-
# acknowledgment state of messages in an existing subscription to the state
|
1106
|
-
# captured by a snapshot.
|
1107
|
-
# <br><br>If the snapshot already exists, returns `ALREADY_EXISTS`.
|
1108
|
-
# If the requested subscription doesn't exist, returns `NOT_FOUND`.
|
1109
|
-
# If the backlog in the subscription is too old -- and the resulting snapshot
|
1110
|
-
# would expire in less than 1 hour -- then `FAILED_PRECONDITION` is returned.
|
1111
|
-
# See also the `Snapshot.expire_time` field. If the name is not provided in
|
1112
|
-
# the request, the server will assign a random
|
1113
|
-
# name for this snapshot on the same project as the subscription, conforming
|
1114
|
-
# to the
|
1115
|
-
# [resource name
|
1116
|
-
# format](https://cloud.google.com/pubsub/docs/admin#resource_names). The
|
1117
|
-
# generated name is populated in the returned Snapshot object. Note that for
|
1118
|
-
# REST API requests, you must specify a name in the request.
|
1119
|
-
#
|
1120
|
-
# @param name [String]
|
1121
|
-
# Required. User-provided name for this snapshot. If the name is not provided
|
1122
|
-
# in the request, the server will assign a random name for this snapshot on
|
1123
|
-
# the same project as the subscription. Note that for REST API requests, you
|
1124
|
-
# must specify a name. See the <a
|
1125
|
-
# href="https://cloud.google.com/pubsub/docs/admin#resource_names"> resource
|
1126
|
-
# name rules</a>. Format is `projects/{project}/snapshots/{snap}`.
|
1127
|
-
# @param subscription [String]
|
1128
|
-
# Required. The subscription whose backlog the snapshot retains.
|
1129
|
-
# Specifically, the created snapshot is guaranteed to retain:
|
1130
|
-
# (a) The existing backlog on the subscription. More precisely, this is
|
1131
|
-
# defined as the messages in the subscription's backlog that are
|
1132
|
-
# unacknowledged upon the successful completion of the
|
1133
|
-
# `CreateSnapshot` request; as well as:
|
1134
|
-
# (b) Any messages published to the subscription's topic following the
|
1135
|
-
# successful completion of the CreateSnapshot request.
|
1136
|
-
# Format is `projects/{project}/subscriptions/{sub}`.
|
1137
|
-
# @param labels [Hash{String => String}]
|
1138
|
-
# See <a href="https://cloud.google.com/pubsub/docs/labels"> Creating and
|
1139
|
-
# managing labels</a>.
|
1140
|
-
# @param options [Google::Gax::CallOptions]
|
1141
|
-
# Overrides the default settings for this call, e.g, timeout,
|
1142
|
-
# retries, etc.
|
1143
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
1144
|
-
# @yieldparam result [Google::Cloud::PubSub::V1::Snapshot]
|
1145
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1146
|
-
# @return [Google::Cloud::PubSub::V1::Snapshot]
|
1147
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1148
|
-
# @example
|
1149
|
-
# require "google/cloud/pubsub"
|
1150
|
-
#
|
1151
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
1152
|
-
# formatted_name = Google::Cloud::PubSub::V1::SubscriberClient.snapshot_path("[PROJECT]", "[SNAPSHOT]")
|
1153
|
-
# formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
|
1154
|
-
# response = subscriber_client.create_snapshot(formatted_name, formatted_subscription)
|
1155
|
-
|
1156
|
-
def create_snapshot \
|
1157
|
-
name,
|
1158
|
-
subscription,
|
1159
|
-
labels: nil,
|
1160
|
-
options: nil,
|
1161
|
-
&block
|
1162
|
-
req = {
|
1163
|
-
name: name,
|
1164
|
-
subscription: subscription,
|
1165
|
-
labels: labels
|
1166
|
-
}.delete_if { |_, v| v.nil? }
|
1167
|
-
req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::CreateSnapshotRequest)
|
1168
|
-
@create_snapshot.call(req, options, &block)
|
1169
|
-
end
|
1170
|
-
|
1171
|
-
# Updates an existing snapshot. Snapshots are used in
|
1172
|
-
# <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
|
1173
|
-
# operations, which allow
|
1174
|
-
# you to manage message acknowledgments in bulk. That is, you can set the
|
1175
|
-
# acknowledgment state of messages in an existing subscription to the state
|
1176
|
-
# captured by a snapshot.
|
1177
|
-
#
|
1178
|
-
# @param snapshot [Google::Cloud::PubSub::V1::Snapshot | Hash]
|
1179
|
-
# Required. The updated snapshot object.
|
1180
|
-
# A hash of the same form as `Google::Cloud::PubSub::V1::Snapshot`
|
1181
|
-
# can also be provided.
|
1182
|
-
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
1183
|
-
# Required. Indicates which fields in the provided snapshot to update.
|
1184
|
-
# Must be specified and non-empty.
|
1185
|
-
# A hash of the same form as `Google::Protobuf::FieldMask`
|
1186
|
-
# can also be provided.
|
1187
|
-
# @param options [Google::Gax::CallOptions]
|
1188
|
-
# Overrides the default settings for this call, e.g, timeout,
|
1189
|
-
# retries, etc.
|
1190
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
1191
|
-
# @yieldparam result [Google::Cloud::PubSub::V1::Snapshot]
|
1192
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1193
|
-
# @return [Google::Cloud::PubSub::V1::Snapshot]
|
1194
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1195
|
-
# @example
|
1196
|
-
# require "google/cloud/pubsub"
|
1197
|
-
#
|
1198
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
1199
|
-
# seconds = 123456
|
1200
|
-
# expire_time = { seconds: seconds }
|
1201
|
-
# snapshot = { expire_time: expire_time }
|
1202
|
-
# paths_element = "expire_time"
|
1203
|
-
# paths = [paths_element]
|
1204
|
-
# update_mask = { paths: paths }
|
1205
|
-
# response = subscriber_client.update_snapshot(snapshot, update_mask)
|
1206
|
-
|
1207
|
-
def update_snapshot \
|
1208
|
-
snapshot,
|
1209
|
-
update_mask,
|
1210
|
-
options: nil,
|
1211
|
-
&block
|
1212
|
-
req = {
|
1213
|
-
snapshot: snapshot,
|
1214
|
-
update_mask: update_mask
|
1215
|
-
}.delete_if { |_, v| v.nil? }
|
1216
|
-
req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::UpdateSnapshotRequest)
|
1217
|
-
@update_snapshot.call(req, options, &block)
|
1218
|
-
end
|
1219
|
-
|
1220
|
-
# Removes an existing snapshot. Snapshots are used in
|
1221
|
-
# <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
|
1222
|
-
# operations, which allow
|
1223
|
-
# you to manage message acknowledgments in bulk. That is, you can set the
|
1224
|
-
# acknowledgment state of messages in an existing subscription to the state
|
1225
|
-
# captured by a snapshot.<br><br>
|
1226
|
-
# When the snapshot is deleted, all messages retained in the snapshot
|
1227
|
-
# are immediately dropped. After a snapshot is deleted, a new one may be
|
1228
|
-
# created with the same name, but the new one has no association with the old
|
1229
|
-
# snapshot or its subscription, unless the same subscription is specified.
|
1230
|
-
#
|
1231
|
-
# @param snapshot [String]
|
1232
|
-
# Required. The name of the snapshot to delete.
|
1233
|
-
# Format is `projects/{project}/snapshots/{snap}`.
|
1234
|
-
# @param options [Google::Gax::CallOptions]
|
1235
|
-
# Overrides the default settings for this call, e.g, timeout,
|
1236
|
-
# retries, etc.
|
1237
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
1238
|
-
# @yieldparam result []
|
1239
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1240
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1241
|
-
# @example
|
1242
|
-
# require "google/cloud/pubsub"
|
1243
|
-
#
|
1244
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
1245
|
-
# formatted_snapshot = Google::Cloud::PubSub::V1::SubscriberClient.snapshot_path("[PROJECT]", "[SNAPSHOT]")
|
1246
|
-
# subscriber_client.delete_snapshot(formatted_snapshot)
|
1247
|
-
|
1248
|
-
def delete_snapshot \
|
1249
|
-
snapshot,
|
1250
|
-
options: nil,
|
1251
|
-
&block
|
1252
|
-
req = {
|
1253
|
-
snapshot: snapshot
|
1254
|
-
}.delete_if { |_, v| v.nil? }
|
1255
|
-
req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::DeleteSnapshotRequest)
|
1256
|
-
@delete_snapshot.call(req, options, &block)
|
1257
|
-
nil
|
1258
|
-
end
|
1259
|
-
|
1260
|
-
# Seeks an existing subscription to a point in time or to a given snapshot,
|
1261
|
-
# whichever is provided in the request. Snapshots are used in
|
1262
|
-
# <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
|
1263
|
-
# operations, which allow
|
1264
|
-
# you to manage message acknowledgments in bulk. That is, you can set the
|
1265
|
-
# acknowledgment state of messages in an existing subscription to the state
|
1266
|
-
# captured by a snapshot. Note that both the subscription and the snapshot
|
1267
|
-
# must be on the same topic.
|
1268
|
-
#
|
1269
|
-
# @param subscription [String]
|
1270
|
-
# Required. The subscription to affect.
|
1271
|
-
# @param time [Google::Protobuf::Timestamp | Hash]
|
1272
|
-
# The time to seek to.
|
1273
|
-
# Messages retained in the subscription that were published before this
|
1274
|
-
# time are marked as acknowledged, and messages retained in the
|
1275
|
-
# subscription that were published after this time are marked as
|
1276
|
-
# unacknowledged. Note that this operation affects only those messages
|
1277
|
-
# retained in the subscription (configured by the combination of
|
1278
|
-
# `message_retention_duration` and `retain_acked_messages`). For example,
|
1279
|
-
# if `time` corresponds to a point before the message retention
|
1280
|
-
# window (or to a point before the system's notion of the subscription
|
1281
|
-
# creation time), only retained messages will be marked as unacknowledged,
|
1282
|
-
# and already-expunged messages will not be restored.
|
1283
|
-
# A hash of the same form as `Google::Protobuf::Timestamp`
|
1284
|
-
# can also be provided.
|
1285
|
-
# @param snapshot [String]
|
1286
|
-
# The snapshot to seek to. The snapshot's topic must be the same as that of
|
1287
|
-
# the provided subscription.
|
1288
|
-
# Format is `projects/{project}/snapshots/{snap}`.
|
1289
|
-
# @param options [Google::Gax::CallOptions]
|
1290
|
-
# Overrides the default settings for this call, e.g, timeout,
|
1291
|
-
# retries, etc.
|
1292
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
1293
|
-
# @yieldparam result [Google::Cloud::PubSub::V1::SeekResponse]
|
1294
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1295
|
-
# @return [Google::Cloud::PubSub::V1::SeekResponse]
|
1296
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1297
|
-
# @example
|
1298
|
-
# require "google/cloud/pubsub"
|
1299
|
-
#
|
1300
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
1301
|
-
# formatted_subscription = Google::Cloud::PubSub::V1::SubscriberClient.subscription_path("[PROJECT]", "[SUBSCRIPTION]")
|
1302
|
-
# response = subscriber_client.seek(formatted_subscription)
|
1303
|
-
|
1304
|
-
def seek \
|
1305
|
-
subscription,
|
1306
|
-
time: nil,
|
1307
|
-
snapshot: nil,
|
1308
|
-
options: nil,
|
1309
|
-
&block
|
1310
|
-
req = {
|
1311
|
-
subscription: subscription,
|
1312
|
-
time: time,
|
1313
|
-
snapshot: snapshot
|
1314
|
-
}.delete_if { |_, v| v.nil? }
|
1315
|
-
req = Google::Gax::to_proto(req, Google::Cloud::PubSub::V1::SeekRequest)
|
1316
|
-
@seek.call(req, options, &block)
|
1317
|
-
end
|
1318
|
-
|
1319
|
-
# Sets the access control policy on the specified resource. Replaces
|
1320
|
-
# any existing policy.
|
1321
|
-
#
|
1322
|
-
# Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
|
1323
|
-
# errors.
|
1324
|
-
#
|
1325
|
-
# @param resource [String]
|
1326
|
-
# REQUIRED: The resource for which the policy is being specified.
|
1327
|
-
# See the operation documentation for the appropriate value for this field.
|
1328
|
-
# @param policy [Google::Iam::V1::Policy | Hash]
|
1329
|
-
# REQUIRED: The complete policy to be applied to the `resource`. The size of
|
1330
|
-
# the policy is limited to a few 10s of KB. An empty policy is a
|
1331
|
-
# valid policy but certain Cloud Platform services (such as Projects)
|
1332
|
-
# might reject them.
|
1333
|
-
# A hash of the same form as `Google::Iam::V1::Policy`
|
1334
|
-
# can also be provided.
|
1335
|
-
# @param options [Google::Gax::CallOptions]
|
1336
|
-
# Overrides the default settings for this call, e.g, timeout,
|
1337
|
-
# retries, etc.
|
1338
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
1339
|
-
# @yieldparam result [Google::Iam::V1::Policy]
|
1340
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1341
|
-
# @return [Google::Iam::V1::Policy]
|
1342
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1343
|
-
# @example
|
1344
|
-
# require "google/cloud/pubsub"
|
1345
|
-
#
|
1346
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
1347
|
-
#
|
1348
|
-
# # TODO: Initialize `resource`:
|
1349
|
-
# resource = ''
|
1350
|
-
#
|
1351
|
-
# # TODO: Initialize `policy`:
|
1352
|
-
# policy = {}
|
1353
|
-
# response = subscriber_client.set_iam_policy(resource, policy)
|
1354
|
-
|
1355
|
-
def set_iam_policy \
|
1356
|
-
resource,
|
1357
|
-
policy,
|
1358
|
-
options: nil,
|
1359
|
-
&block
|
1360
|
-
req = {
|
1361
|
-
resource: resource,
|
1362
|
-
policy: policy
|
1363
|
-
}.delete_if { |_, v| v.nil? }
|
1364
|
-
req = Google::Gax::to_proto(req, Google::Iam::V1::SetIamPolicyRequest)
|
1365
|
-
@set_iam_policy.call(req, options, &block)
|
1366
|
-
end
|
1367
|
-
|
1368
|
-
# Gets the access control policy for a resource. Returns an empty policy
|
1369
|
-
# if the resource exists and does not have a policy set.
|
1370
|
-
#
|
1371
|
-
# @param resource [String]
|
1372
|
-
# REQUIRED: The resource for which the policy is being requested.
|
1373
|
-
# See the operation documentation for the appropriate value for this field.
|
1374
|
-
# @param options_ [Google::Iam::V1::GetPolicyOptions | Hash]
|
1375
|
-
# OPTIONAL: A `GetPolicyOptions` object for specifying options to
|
1376
|
-
# `GetIamPolicy`. This field is only used by Cloud IAM.
|
1377
|
-
# A hash of the same form as `Google::Iam::V1::GetPolicyOptions`
|
1378
|
-
# can also be provided.
|
1379
|
-
# @param options [Google::Gax::CallOptions]
|
1380
|
-
# Overrides the default settings for this call, e.g, timeout,
|
1381
|
-
# retries, etc.
|
1382
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
1383
|
-
# @yieldparam result [Google::Iam::V1::Policy]
|
1384
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1385
|
-
# @return [Google::Iam::V1::Policy]
|
1386
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1387
|
-
# @example
|
1388
|
-
# require "google/cloud/pubsub"
|
1389
|
-
#
|
1390
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
1391
|
-
#
|
1392
|
-
# # TODO: Initialize `resource`:
|
1393
|
-
# resource = ''
|
1394
|
-
# response = subscriber_client.get_iam_policy(resource)
|
1395
|
-
|
1396
|
-
def get_iam_policy \
|
1397
|
-
resource,
|
1398
|
-
options_: nil,
|
1399
|
-
options: nil,
|
1400
|
-
&block
|
1401
|
-
req = {
|
1402
|
-
resource: resource,
|
1403
|
-
options: options_
|
1404
|
-
}.delete_if { |_, v| v.nil? }
|
1405
|
-
req = Google::Gax::to_proto(req, Google::Iam::V1::GetIamPolicyRequest)
|
1406
|
-
@get_iam_policy.call(req, options, &block)
|
1407
|
-
end
|
1408
|
-
|
1409
|
-
# Returns permissions that a caller has on the specified resource. If the
|
1410
|
-
# resource does not exist, this will return an empty set of
|
1411
|
-
# permissions, not a `NOT_FOUND` error.
|
1412
|
-
#
|
1413
|
-
# Note: This operation is designed to be used for building
|
1414
|
-
# permission-aware UIs and command-line tools, not for authorization
|
1415
|
-
# checking. This operation may "fail open" without warning.
|
1416
|
-
#
|
1417
|
-
# @param resource [String]
|
1418
|
-
# REQUIRED: The resource for which the policy detail is being requested.
|
1419
|
-
# See the operation documentation for the appropriate value for this field.
|
1420
|
-
# @param permissions [Array<String>]
|
1421
|
-
# The set of permissions to check for the `resource`. Permissions with
|
1422
|
-
# wildcards (such as '*' or 'storage.*') are not allowed. For more
|
1423
|
-
# information see
|
1424
|
-
# [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
|
1425
|
-
# @param options [Google::Gax::CallOptions]
|
1426
|
-
# Overrides the default settings for this call, e.g, timeout,
|
1427
|
-
# retries, etc.
|
1428
|
-
# @yield [result, operation] Access the result along with the RPC operation
|
1429
|
-
# @yieldparam result [Google::Iam::V1::TestIamPermissionsResponse]
|
1430
|
-
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
1431
|
-
# @return [Google::Iam::V1::TestIamPermissionsResponse]
|
1432
|
-
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
1433
|
-
# @example
|
1434
|
-
# require "google/cloud/pubsub"
|
1435
|
-
#
|
1436
|
-
# subscriber_client = Google::Cloud::PubSub::Subscriber.new(version: :v1)
|
1437
|
-
#
|
1438
|
-
# # TODO: Initialize `resource`:
|
1439
|
-
# resource = ''
|
1440
|
-
#
|
1441
|
-
# # TODO: Initialize `permissions`:
|
1442
|
-
# permissions = []
|
1443
|
-
# response = subscriber_client.test_iam_permissions(resource, permissions)
|
1444
|
-
|
1445
|
-
def test_iam_permissions \
|
1446
|
-
resource,
|
1447
|
-
permissions,
|
1448
|
-
options: nil,
|
1449
|
-
&block
|
1450
|
-
req = {
|
1451
|
-
resource: resource,
|
1452
|
-
permissions: permissions
|
1453
|
-
}.delete_if { |_, v| v.nil? }
|
1454
|
-
req = Google::Gax::to_proto(req, Google::Iam::V1::TestIamPermissionsRequest)
|
1455
|
-
@test_iam_permissions.call(req, options, &block)
|
1456
|
-
end
|
1457
|
-
end
|
1458
|
-
end
|
1459
|
-
end
|
1460
|
-
|
1461
|
-
Pubsub = PubSub unless const_defined? :Pubsub
|
1462
|
-
end
|
1463
|
-
end
|