google-cloud-pubsub 0.20.0 → 0.20.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 835dfba62f6801603cf98ecfccd798ba59a575a8
4
- data.tar.gz: 3c5f2bf501c861ce2fe0e42f6625707df7c54e5b
3
+ metadata.gz: 1ed97e68a23ababe3268559effcac9c99bfcd390
4
+ data.tar.gz: 35e382342f920445a7b58e13e9c32ba0c96b0cc4
5
5
  SHA512:
6
- metadata.gz: 7c8a41c01358952bfb9e567ff295ba6f3626d9e5602de29df9d5463346d594b0b54eb8b756c7dcbc45d4464adfb5410401b3d984da327cf9f170e78d5a9ef1ee
7
- data.tar.gz: 59186803d87e2873ea085bdbff9000f6e8eec623d076c6074ca52eac494cef2ba7c961d43fe91a0c49d13cb49970c5fbf0a9f3ded3ddede2538b6f1a2e21fe74
6
+ metadata.gz: a3799ef6da67d6870fb2054da570540ebef4d51f0ea56932d35a6d5bd7404a4777e87002420a68f6f2c2dd3e17973f8c6e2a45a6b672e3e77c5573b26d1851fb
7
+ data.tar.gz: 3a51da97b7c25e7c9819a7f56e1836f6e8fbe61d953cdb4e74bf407148514923f69437d03df899e1505b27c32f4bfa4131713f7ae4c856398f0993c17d494f4b
@@ -15,8 +15,8 @@
15
15
 
16
16
  require "google/cloud/errors"
17
17
  require "google/cloud/core/grpc_backoff"
18
- require "google/pubsub/v1/pubsub_services_pb"
19
- require "google/iam/v1/iam_policy_services"
18
+ require "google/pubsub/v1/pubsub_pb"
19
+ require "google/iam/v1/iam_policy"
20
20
  require "google/cloud/core/grpc_utils"
21
21
  require "json"
22
22
 
@@ -48,22 +48,34 @@ module Google
48
48
 
49
49
  def subscriber
50
50
  return mocked_subscriber if mocked_subscriber
51
- @subscriber ||= Google::Pubsub::V1::Subscriber::Stub.new(
52
- host, creds, timeout: timeout)
51
+ @subscriber ||= begin
52
+ require "google/pubsub/v1/pubsub_services_pb"
53
+
54
+ Google::Pubsub::V1::Subscriber::Stub.new(
55
+ host, creds, timeout: timeout)
56
+ end
53
57
  end
54
58
  attr_accessor :mocked_subscriber
55
59
 
56
60
  def publisher
57
61
  return mocked_publisher if mocked_publisher
58
- @publisher ||= Google::Pubsub::V1::Publisher::Stub.new(
59
- host, creds, timeout: timeout)
62
+ @publisher ||= begin
63
+ require "google/pubsub/v1/pubsub_services_pb"
64
+
65
+ Google::Pubsub::V1::Publisher::Stub.new(
66
+ host, creds, timeout: timeout)
67
+ end
60
68
  end
61
69
  attr_accessor :mocked_publisher
62
70
 
63
71
  def iam
64
72
  return mocked_iam if mocked_iam
65
- @iam ||= Google::Iam::V1::IAMPolicy::Stub.new(
66
- host, creds, timeout: timeout)
73
+ @iam ||= begin
74
+ require "google/iam/v1/iam_policy_services"
75
+
76
+ Google::Iam::V1::IAMPolicy::Stub.new(
77
+ host, creds, timeout: timeout)
78
+ end
67
79
  end
68
80
  attr_accessor :mocked_iam
69
81
 
@@ -0,0 +1,17 @@
1
+ # Copyright 2015 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
+
16
+ require "google/cloud/pubsub/v1/publisher_api"
17
+ require "google/cloud/pubsub/v1/subscriber_api"
@@ -0,0 +1,371 @@
1
+ # Copyright 2016 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
+ require "google/pubsub/v1/pubsub_services_pb"
30
+
31
+ module Google
32
+ module Cloud
33
+ module Pubsub
34
+ module V1
35
+ # The service that an application uses to manipulate topics, and to send
36
+ # messages to a topic.
37
+ #
38
+ # @!attribute [r] stub
39
+ # @return [Google::Pubsub::V1::Publisher::Stub]
40
+ class PublisherApi
41
+ attr_reader :stub
42
+
43
+ # The default address of the service.
44
+ SERVICE_ADDRESS = "pubsub.googleapis.com".freeze
45
+
46
+ # The default port of the service.
47
+ DEFAULT_SERVICE_PORT = 443
48
+
49
+ CODE_GEN_NAME_VERSION = "gapic/0.1.0".freeze
50
+
51
+ DEFAULT_TIMEOUT = 30
52
+
53
+ PAGE_DESCRIPTORS = {
54
+ "list_topics" => Google::Gax::PageDescriptor.new(
55
+ "page_token",
56
+ "next_page_token",
57
+ "topics"),
58
+ "list_topic_subscriptions" => Google::Gax::PageDescriptor.new(
59
+ "page_token",
60
+ "next_page_token",
61
+ "subscriptions")
62
+ }.freeze
63
+
64
+ private_constant :PAGE_DESCRIPTORS
65
+
66
+ BUNDLE_DESCRIPTORS = {
67
+ "publish" => Google::Gax::BundleDescriptor.new(
68
+ "messages",
69
+ [
70
+ "topic"
71
+ ],
72
+ subresponse_field: "message_ids")
73
+ }.freeze
74
+
75
+ private_constant :BUNDLE_DESCRIPTORS
76
+
77
+ # The scopes needed to make gRPC calls to all of the methods defined in
78
+ # this service.
79
+ ALL_SCOPES = [
80
+ "https://www.googleapis.com/auth/cloud-platform",
81
+ "https://www.googleapis.com/auth/pubsub"
82
+ ].freeze
83
+
84
+ PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
85
+ "projects/{project}"
86
+ )
87
+
88
+ private_constant :PROJECT_PATH_TEMPLATE
89
+
90
+ TOPIC_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
91
+ "projects/{project}/topics/{topic}"
92
+ )
93
+
94
+ private_constant :TOPIC_PATH_TEMPLATE
95
+
96
+ # Returns a fully-qualified project resource name string.
97
+ # @param project [String]
98
+ # @return [String]
99
+ def self.project_path project
100
+ PROJECT_PATH_TEMPLATE.render(
101
+ :"project" => project
102
+ )
103
+ end
104
+
105
+ # Returns a fully-qualified topic resource name string.
106
+ # @param project [String]
107
+ # @param topic [String]
108
+ # @return [String]
109
+ def self.topic_path project, topic
110
+ TOPIC_PATH_TEMPLATE.render(
111
+ :"project" => project,
112
+ :"topic" => topic
113
+ )
114
+ end
115
+
116
+ # Parses the project from a project resource.
117
+ # @param project_name [String]
118
+ # @return [String]
119
+ def self.match_project_from_project_name project_name
120
+ PROJECT_PATH_TEMPLATE.match(project_name)["project"]
121
+ end
122
+
123
+ # Parses the project from a topic resource.
124
+ # @param topic_name [String]
125
+ # @return [String]
126
+ def self.match_project_from_topic_name topic_name
127
+ TOPIC_PATH_TEMPLATE.match(topic_name)["project"]
128
+ end
129
+
130
+ # Parses the topic from a topic resource.
131
+ # @param topic_name [String]
132
+ # @return [String]
133
+ def self.match_topic_from_topic_name topic_name
134
+ TOPIC_PATH_TEMPLATE.match(topic_name)["topic"]
135
+ end
136
+
137
+ # @param service_path [String]
138
+ # The domain name of the API remote host.
139
+ # @param port [Integer]
140
+ # The port on which to connect to the remote host.
141
+ # @param channel [Channel]
142
+ # A Channel object through which to make calls.
143
+ # @param chan_creds [Grpc::ChannelCredentials]
144
+ # A ChannelCredentials for the setting up the RPC client.
145
+ # @param client_config[Hash]
146
+ # A Hash for call options for each method. See
147
+ # Google::Gax#construct_settings for the structure of
148
+ # this data. Falls back to the default config if not specified
149
+ # or the specified config is missing data points.
150
+ # @param timeout [Numeric]
151
+ # The default timeout, in seconds, for calls made through this client.
152
+ # @param app_name [String]
153
+ # The codename of the calling service.
154
+ # @param app_version [String]
155
+ # The version of the calling service.
156
+ def initialize \
157
+ service_path: SERVICE_ADDRESS,
158
+ port: DEFAULT_SERVICE_PORT,
159
+ channel: nil,
160
+ chan_creds: nil,
161
+ scopes: ALL_SCOPES,
162
+ client_config: {},
163
+ timeout: DEFAULT_TIMEOUT,
164
+ app_name: "gax",
165
+ app_version: Google::Gax::VERSION
166
+ google_api_client = "#{app_name}/#{app_version} " \
167
+ "#{CODE_GEN_NAME_VERSION} ruby/#{RUBY_VERSION}".freeze
168
+ headers = { :"x-goog-api-client" => google_api_client }
169
+ client_config_file = Pathname.new(__dir__).join(
170
+ "publisher_client_config.json"
171
+ )
172
+ defaults = client_config_file.open do |f|
173
+ Google::Gax.construct_settings(
174
+ "google.pubsub.v1.Publisher",
175
+ JSON.parse(f.read),
176
+ client_config,
177
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
178
+ timeout,
179
+ bundle_descriptors: BUNDLE_DESCRIPTORS,
180
+ page_descriptors: PAGE_DESCRIPTORS,
181
+ errors: Google::Gax::Grpc::API_ERRORS,
182
+ kwargs: headers
183
+ )
184
+ end
185
+ @stub = Google::Gax::Grpc.create_stub(
186
+ service_path,
187
+ port,
188
+ chan_creds: chan_creds,
189
+ channel: channel,
190
+ scopes: scopes,
191
+ &Google::Pubsub::V1::Publisher::Stub.method(:new)
192
+ )
193
+
194
+ @create_topic = Google::Gax.create_api_call(
195
+ @stub.method(:create_topic),
196
+ defaults["create_topic"]
197
+ )
198
+ @publish = Google::Gax.create_api_call(
199
+ @stub.method(:publish),
200
+ defaults["publish"]
201
+ )
202
+ @get_topic = Google::Gax.create_api_call(
203
+ @stub.method(:get_topic),
204
+ defaults["get_topic"]
205
+ )
206
+ @list_topics = Google::Gax.create_api_call(
207
+ @stub.method(:list_topics),
208
+ defaults["list_topics"]
209
+ )
210
+ @list_topic_subscriptions = Google::Gax.create_api_call(
211
+ @stub.method(:list_topic_subscriptions),
212
+ defaults["list_topic_subscriptions"]
213
+ )
214
+ @delete_topic = Google::Gax.create_api_call(
215
+ @stub.method(:delete_topic),
216
+ defaults["delete_topic"]
217
+ )
218
+ end
219
+
220
+ # Service calls
221
+
222
+ # Creates the given topic with the given name.
223
+ #
224
+ # @param name [String]
225
+ # The name of the topic. It must have the format
226
+ # +"projects/{project}/topics/{topic}"+. +{topic}+ must start with a letter,
227
+ # and contain only letters (+[A-Za-z]+), numbers (+[0-9]+), dashes (+-+),
228
+ # underscores (+_+), periods (+.+), tildes (+~+), plus (+++) or percent
229
+ # signs (+%+). It must be between 3 and 255 characters in length, and it
230
+ # must not start with +"goog"+.
231
+ # @param options [Google::Gax::CallOptions]
232
+ # Overrides the default settings for this call, e.g, timeout,
233
+ # retries, etc.
234
+ # @return [Google::Pubsub::V1::Topic]
235
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
236
+ def create_topic \
237
+ name,
238
+ options: nil
239
+ req = Google::Pubsub::V1::Topic.new(
240
+ name: name
241
+ )
242
+ @create_topic.call(req, options)
243
+ end
244
+
245
+ # Adds one or more messages to the topic. Returns +NOT_FOUND+ if the topic
246
+ # does not exist. The message payload must not be empty; it must contain
247
+ # either a non-empty data field, or at least one attribute.
248
+ #
249
+ # @param topic [String]
250
+ # The messages in the request will be published on this topic.
251
+ # @param messages [Array<Google::Pubsub::V1::PubsubMessage>]
252
+ # The messages to publish.
253
+ # @param options [Google::Gax::CallOptions]
254
+ # Overrides the default settings for this call, e.g, timeout,
255
+ # retries, etc.
256
+ # @return [Google::Pubsub::V1::PublishResponse]
257
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
258
+ def publish \
259
+ topic,
260
+ messages,
261
+ options: nil
262
+ req = Google::Pubsub::V1::PublishRequest.new(
263
+ topic: topic,
264
+ messages: messages
265
+ )
266
+ @publish.call(req, options)
267
+ end
268
+
269
+ # Gets the configuration of a topic.
270
+ #
271
+ # @param topic [String]
272
+ # The name of the topic to get.
273
+ # @param options [Google::Gax::CallOptions]
274
+ # Overrides the default settings for this call, e.g, timeout,
275
+ # retries, etc.
276
+ # @return [Google::Pubsub::V1::Topic]
277
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
278
+ def get_topic \
279
+ topic,
280
+ options: nil
281
+ req = Google::Pubsub::V1::GetTopicRequest.new(
282
+ topic: topic
283
+ )
284
+ @get_topic.call(req, options)
285
+ end
286
+
287
+ # Lists matching topics.
288
+ #
289
+ # @param project [String]
290
+ # The name of the cloud project that topics belong to.
291
+ # @param page_size [Integer]
292
+ # The maximum number of resources contained in the underlying API
293
+ # response. If page streaming is performed per-resource, this
294
+ # parameter does not affect the return value. If page streaming is
295
+ # performed per-page, this determines the maximum number of
296
+ # resources in a page.
297
+ # @param options [Google::Gax::CallOptions]
298
+ # Overrides the default settings for this call, e.g, timeout,
299
+ # retries, etc.
300
+ # @return [Google::Gax::PagedEnumerable<Google::Pubsub::V1::Topic>]
301
+ # An enumerable of Google::Pubsub::V1::Topic instances.
302
+ # See Google::Gax::PagedEnumerable documentation for other
303
+ # operations such as per-page iteration or access to the response
304
+ # object.
305
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
306
+ def list_topics \
307
+ project,
308
+ page_size: nil,
309
+ options: nil
310
+ req = Google::Pubsub::V1::ListTopicsRequest.new(
311
+ project: project
312
+ )
313
+ req.page_size = page_size unless page_size.nil?
314
+ @list_topics.call(req, options)
315
+ end
316
+
317
+ # Lists the name of the subscriptions for this topic.
318
+ #
319
+ # @param topic [String]
320
+ # The name of the topic that subscriptions are attached to.
321
+ # @param page_size [Integer]
322
+ # The maximum number of resources contained in the underlying API
323
+ # response. If page streaming is performed per-resource, this
324
+ # parameter does not affect the return value. If page streaming is
325
+ # performed per-page, this determines the maximum number of
326
+ # resources in a page.
327
+ # @param options [Google::Gax::CallOptions]
328
+ # Overrides the default settings for this call, e.g, timeout,
329
+ # retries, etc.
330
+ # @return [Google::Gax::PagedEnumerable<String>]
331
+ # An enumerable of String instances.
332
+ # See Google::Gax::PagedEnumerable documentation for other
333
+ # operations such as per-page iteration or access to the response
334
+ # object.
335
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
336
+ def list_topic_subscriptions \
337
+ topic,
338
+ page_size: nil,
339
+ options: nil
340
+ req = Google::Pubsub::V1::ListTopicSubscriptionsRequest.new(
341
+ topic: topic
342
+ )
343
+ req.page_size = page_size unless page_size.nil?
344
+ @list_topic_subscriptions.call(req, options)
345
+ end
346
+
347
+ # Deletes the topic with the given name. Returns +NOT_FOUND+ if the topic
348
+ # does not exist. After a topic is deleted, a new topic may be created with
349
+ # the same name; this is an entirely new topic with none of the old
350
+ # configuration or subscriptions. Existing subscriptions to this topic are
351
+ # not deleted, but their +topic+ field is set to +_deleted-topic_+.
352
+ #
353
+ # @param topic [String]
354
+ # Name of the topic to delete.
355
+ # @param options [Google::Gax::CallOptions]
356
+ # Overrides the default settings for this call, e.g, timeout,
357
+ # retries, etc.
358
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
359
+ def delete_topic \
360
+ topic,
361
+ options: nil
362
+ req = Google::Pubsub::V1::DeleteTopicRequest.new(
363
+ topic: topic
364
+ )
365
+ @delete_topic.call(req, options)
366
+ end
367
+ end
368
+ end
369
+ end
370
+ end
371
+ end
@@ -0,0 +1,78 @@
1
+ {
2
+ "interfaces": {
3
+ "google.pubsub.v1.Publisher": {
4
+ "retry_codes": {
5
+ "retry_codes_def": {
6
+ "idempotent": [
7
+ "DEADLINE_EXCEEDED",
8
+ "UNAVAILABLE"
9
+ ],
10
+ "one_plus_delivery": [
11
+ "DEADLINE_EXCEEDED",
12
+ "UNAVAILABLE"
13
+ ],
14
+ "non_idempotent": []
15
+ }
16
+ },
17
+ "retry_params": {
18
+ "default": {
19
+ "initial_retry_delay_millis": 100,
20
+ "retry_delay_multiplier": 1.3,
21
+ "max_retry_delay_millis": 60000,
22
+ "initial_rpc_timeout_millis": 60000,
23
+ "rpc_timeout_multiplier": 1.0,
24
+ "max_rpc_timeout_millis": 60000,
25
+ "total_timeout_millis": 600000
26
+ },
27
+ "messaging": {
28
+ "initial_retry_delay_millis": 100,
29
+ "retry_delay_multiplier": 1.3,
30
+ "max_retry_delay_millis": 60000,
31
+ "initial_rpc_timeout_millis": 12000,
32
+ "rpc_timeout_multiplier": 1.0,
33
+ "max_rpc_timeout_millis": 12000,
34
+ "total_timeout_millis": 600000
35
+ }
36
+ },
37
+ "methods": {
38
+ "CreateTopic": {
39
+ "timeout_millis": 60000,
40
+ "retry_codes_name": "idempotent",
41
+ "retry_params_name": "default"
42
+ },
43
+ "Publish": {
44
+ "timeout_millis": 60000,
45
+ "retry_codes_name": "one_plus_delivery",
46
+ "retry_params_name": "messaging",
47
+ "bundling": {
48
+ "element_count_threshold": 10,
49
+ "element_count_limit": 1000,
50
+ "request_byte_threshold": 1024,
51
+ "request_byte_limit": 10485760,
52
+ "delay_threshold_millis": 10
53
+ }
54
+ },
55
+ "GetTopic": {
56
+ "timeout_millis": 60000,
57
+ "retry_codes_name": "idempotent",
58
+ "retry_params_name": "default"
59
+ },
60
+ "ListTopics": {
61
+ "timeout_millis": 60000,
62
+ "retry_codes_name": "idempotent",
63
+ "retry_params_name": "default"
64
+ },
65
+ "ListTopicSubscriptions": {
66
+ "timeout_millis": 60000,
67
+ "retry_codes_name": "idempotent",
68
+ "retry_params_name": "default"
69
+ },
70
+ "DeleteTopic": {
71
+ "timeout_millis": 60000,
72
+ "retry_codes_name": "idempotent",
73
+ "retry_params_name": "default"
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
@@ -0,0 +1,503 @@
1
+ # Copyright 2016 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
+ require "google/pubsub/v1/pubsub_services_pb"
30
+
31
+ module Google
32
+ module Cloud
33
+ module Pubsub
34
+ module V1
35
+ # The service that an application uses to manipulate subscriptions and to
36
+ # consume messages from a subscription via the +Pull+ method.
37
+ #
38
+ # @!attribute [r] stub
39
+ # @return [Google::Pubsub::V1::Subscriber::Stub]
40
+ class SubscriberApi
41
+ attr_reader :stub
42
+
43
+ # The default address of the service.
44
+ SERVICE_ADDRESS = "pubsub.googleapis.com".freeze
45
+
46
+ # The default port of the service.
47
+ DEFAULT_SERVICE_PORT = 443
48
+
49
+ CODE_GEN_NAME_VERSION = "gapic/0.1.0".freeze
50
+
51
+ DEFAULT_TIMEOUT = 30
52
+
53
+ PAGE_DESCRIPTORS = {
54
+ "list_subscriptions" => Google::Gax::PageDescriptor.new(
55
+ "page_token",
56
+ "next_page_token",
57
+ "subscriptions")
58
+ }.freeze
59
+
60
+ private_constant :PAGE_DESCRIPTORS
61
+
62
+ # The scopes needed to make gRPC calls to all of the methods defined in
63
+ # this service.
64
+ ALL_SCOPES = [
65
+ "https://www.googleapis.com/auth/cloud-platform",
66
+ "https://www.googleapis.com/auth/pubsub"
67
+ ].freeze
68
+
69
+ PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
70
+ "projects/{project}"
71
+ )
72
+
73
+ private_constant :PROJECT_PATH_TEMPLATE
74
+
75
+ SUBSCRIPTION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
76
+ "projects/{project}/subscriptions/{subscription}"
77
+ )
78
+
79
+ private_constant :SUBSCRIPTION_PATH_TEMPLATE
80
+
81
+ TOPIC_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
82
+ "projects/{project}/topics/{topic}"
83
+ )
84
+
85
+ private_constant :TOPIC_PATH_TEMPLATE
86
+
87
+ # Returns a fully-qualified project resource name string.
88
+ # @param project [String]
89
+ # @return [String]
90
+ def self.project_path project
91
+ PROJECT_PATH_TEMPLATE.render(
92
+ :"project" => project
93
+ )
94
+ end
95
+
96
+ # Returns a fully-qualified subscription resource name string.
97
+ # @param project [String]
98
+ # @param subscription [String]
99
+ # @return [String]
100
+ def self.subscription_path project, subscription
101
+ SUBSCRIPTION_PATH_TEMPLATE.render(
102
+ :"project" => project,
103
+ :"subscription" => subscription
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 subscription resource.
126
+ # @param subscription_name [String]
127
+ # @return [String]
128
+ def self.match_project_from_subscription_name subscription_name
129
+ SUBSCRIPTION_PATH_TEMPLATE.match(subscription_name)["project"]
130
+ end
131
+
132
+ # Parses the subscription from a subscription resource.
133
+ # @param subscription_name [String]
134
+ # @return [String]
135
+ def self.match_subscription_from_subscription_name subscription_name
136
+ SUBSCRIPTION_PATH_TEMPLATE.match(subscription_name)["subscription"]
137
+ end
138
+
139
+ # Parses the project from a topic resource.
140
+ # @param topic_name [String]
141
+ # @return [String]
142
+ def self.match_project_from_topic_name topic_name
143
+ TOPIC_PATH_TEMPLATE.match(topic_name)["project"]
144
+ end
145
+
146
+ # Parses the topic from a topic resource.
147
+ # @param topic_name [String]
148
+ # @return [String]
149
+ def self.match_topic_from_topic_name topic_name
150
+ TOPIC_PATH_TEMPLATE.match(topic_name)["topic"]
151
+ end
152
+
153
+ # @param service_path [String]
154
+ # The domain name of the API remote host.
155
+ # @param port [Integer]
156
+ # The port on which to connect to the remote host.
157
+ # @param channel [Channel]
158
+ # A Channel object through which to make calls.
159
+ # @param chan_creds [Grpc::ChannelCredentials]
160
+ # A ChannelCredentials for the setting up the RPC client.
161
+ # @param client_config[Hash]
162
+ # A Hash for call options for each method. See
163
+ # Google::Gax#construct_settings for the structure of
164
+ # this data. Falls back to the default config if not specified
165
+ # or the specified config is missing data points.
166
+ # @param timeout [Numeric]
167
+ # The default timeout, in seconds, for calls made through this client.
168
+ # @param app_name [String]
169
+ # The codename of the calling service.
170
+ # @param app_version [String]
171
+ # The version of the calling service.
172
+ def initialize \
173
+ service_path: SERVICE_ADDRESS,
174
+ port: DEFAULT_SERVICE_PORT,
175
+ channel: nil,
176
+ chan_creds: nil,
177
+ scopes: ALL_SCOPES,
178
+ client_config: {},
179
+ timeout: DEFAULT_TIMEOUT,
180
+ app_name: "gax",
181
+ app_version: Google::Gax::VERSION
182
+ google_api_client = "#{app_name}/#{app_version} " \
183
+ "#{CODE_GEN_NAME_VERSION} ruby/#{RUBY_VERSION}".freeze
184
+ headers = { :"x-goog-api-client" => google_api_client }
185
+ client_config_file = Pathname.new(__dir__).join(
186
+ "subscriber_client_config.json"
187
+ )
188
+ defaults = client_config_file.open do |f|
189
+ Google::Gax.construct_settings(
190
+ "google.pubsub.v1.Subscriber",
191
+ JSON.parse(f.read),
192
+ client_config,
193
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
194
+ timeout,
195
+ page_descriptors: PAGE_DESCRIPTORS,
196
+ errors: Google::Gax::Grpc::API_ERRORS,
197
+ kwargs: headers
198
+ )
199
+ end
200
+ @stub = Google::Gax::Grpc.create_stub(
201
+ service_path,
202
+ port,
203
+ chan_creds: chan_creds,
204
+ channel: channel,
205
+ scopes: scopes,
206
+ &Google::Pubsub::V1::Subscriber::Stub.method(:new)
207
+ )
208
+
209
+ @create_subscription = Google::Gax.create_api_call(
210
+ @stub.method(:create_subscription),
211
+ defaults["create_subscription"]
212
+ )
213
+ @get_subscription = Google::Gax.create_api_call(
214
+ @stub.method(:get_subscription),
215
+ defaults["get_subscription"]
216
+ )
217
+ @list_subscriptions = Google::Gax.create_api_call(
218
+ @stub.method(:list_subscriptions),
219
+ defaults["list_subscriptions"]
220
+ )
221
+ @delete_subscription = Google::Gax.create_api_call(
222
+ @stub.method(:delete_subscription),
223
+ defaults["delete_subscription"]
224
+ )
225
+ @modify_ack_deadline = Google::Gax.create_api_call(
226
+ @stub.method(:modify_ack_deadline),
227
+ defaults["modify_ack_deadline"]
228
+ )
229
+ @acknowledge = Google::Gax.create_api_call(
230
+ @stub.method(:acknowledge),
231
+ defaults["acknowledge"]
232
+ )
233
+ @pull = Google::Gax.create_api_call(
234
+ @stub.method(:pull),
235
+ defaults["pull"]
236
+ )
237
+ @modify_push_config = Google::Gax.create_api_call(
238
+ @stub.method(:modify_push_config),
239
+ defaults["modify_push_config"]
240
+ )
241
+ end
242
+
243
+ # Service calls
244
+
245
+ # Creates a subscription to a given topic for a given subscriber.
246
+ # If the subscription already exists, returns +ALREADY_EXISTS+.
247
+ # If the corresponding topic doesn't exist, returns +NOT_FOUND+.
248
+ #
249
+ # If the name is not provided in the request, the server will assign a random
250
+ # name for this subscription on the same project as the topic.
251
+ #
252
+ # @param name [String]
253
+ # The name of the subscription. It must have the format
254
+ # +"projects/{project}/subscriptions/{subscription}"+. +{subscription}+ must
255
+ # start with a letter, and contain only letters (+[A-Za-z]+), numbers
256
+ # (+[0-9]+), dashes (+-+), underscores (+_+), periods (+.+), tildes (+~+),
257
+ # plus (+++) or percent signs (+%+). It must be between 3 and 255 characters
258
+ # in length, and it must not start with +"goog"+.
259
+ # @param topic [String]
260
+ # The name of the topic from which this subscription is receiving messages.
261
+ # The value of this field will be +_deleted-topic_+ if the topic has been
262
+ # deleted.
263
+ # @param push_config [Google::Pubsub::V1::PushConfig]
264
+ # If push delivery is used with this subscription, this field is
265
+ # used to configure it. An empty +pushConfig+ signifies that the subscriber
266
+ # will pull and ack messages using API methods.
267
+ # @param ack_deadline_seconds [Integer]
268
+ # This value is the maximum time after a subscriber receives a message
269
+ # before the subscriber should acknowledge the message. After message
270
+ # delivery but before the ack deadline expires and before the message is
271
+ # acknowledged, it is an outstanding message and will not be delivered
272
+ # again during that time (on a best-effort basis).
273
+ #
274
+ # For pull subscriptions, this value is used as the initial value for the ack
275
+ # deadline. To override this value for a given message, call
276
+ # +ModifyAckDeadline+ with the corresponding +ack_id+ if using
277
+ # pull.
278
+ #
279
+ # For push delivery, this value is also used to set the request timeout for
280
+ # the call to the push endpoint.
281
+ #
282
+ # If the subscriber never acknowledges the message, the Pub/Sub
283
+ # system will eventually redeliver the message.
284
+ #
285
+ # If this parameter is not set, the default value of 10 seconds is used.
286
+ # @param options [Google::Gax::CallOptions]
287
+ # Overrides the default settings for this call, e.g, timeout,
288
+ # retries, etc.
289
+ # @return [Google::Pubsub::V1::Subscription]
290
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
291
+ def create_subscription \
292
+ name,
293
+ topic,
294
+ push_config: nil,
295
+ ack_deadline_seconds: nil,
296
+ options: nil
297
+ req = Google::Pubsub::V1::Subscription.new(
298
+ name: name,
299
+ topic: topic
300
+ )
301
+ req.push_config = push_config unless push_config.nil?
302
+ req.ack_deadline_seconds = ack_deadline_seconds unless ack_deadline_seconds.nil?
303
+ @create_subscription.call(req, options)
304
+ end
305
+
306
+ # Gets the configuration details of a subscription.
307
+ #
308
+ # @param subscription [String]
309
+ # The name of the subscription to get.
310
+ # @param options [Google::Gax::CallOptions]
311
+ # Overrides the default settings for this call, e.g, timeout,
312
+ # retries, etc.
313
+ # @return [Google::Pubsub::V1::Subscription]
314
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
315
+ def get_subscription \
316
+ subscription,
317
+ options: nil
318
+ req = Google::Pubsub::V1::GetSubscriptionRequest.new(
319
+ subscription: subscription
320
+ )
321
+ @get_subscription.call(req, options)
322
+ end
323
+
324
+ # Lists matching subscriptions.
325
+ #
326
+ # @param project [String]
327
+ # The name of the cloud project that subscriptions belong to.
328
+ # @param page_size [Integer]
329
+ # The maximum number of resources contained in the underlying API
330
+ # response. If page streaming is performed per-resource, this
331
+ # parameter does not affect the return value. If page streaming is
332
+ # performed per-page, this determines the maximum number of
333
+ # resources in a page.
334
+ # @param options [Google::Gax::CallOptions]
335
+ # Overrides the default settings for this call, e.g, timeout,
336
+ # retries, etc.
337
+ # @return [Google::Gax::PagedEnumerable<Google::Pubsub::V1::Subscription>]
338
+ # An enumerable of Google::Pubsub::V1::Subscription instances.
339
+ # See Google::Gax::PagedEnumerable documentation for other
340
+ # operations such as per-page iteration or access to the response
341
+ # object.
342
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
343
+ def list_subscriptions \
344
+ project,
345
+ page_size: nil,
346
+ options: nil
347
+ req = Google::Pubsub::V1::ListSubscriptionsRequest.new(
348
+ project: project
349
+ )
350
+ req.page_size = page_size unless page_size.nil?
351
+ @list_subscriptions.call(req, options)
352
+ end
353
+
354
+ # Deletes an existing subscription. All pending messages in the subscription
355
+ # are immediately dropped. Calls to +Pull+ after deletion will return
356
+ # +NOT_FOUND+. After a subscription is deleted, a new one may be created with
357
+ # the same name, but the new one has no association with the old
358
+ # subscription, or its topic unless the same topic is specified.
359
+ #
360
+ # @param subscription [String]
361
+ # The subscription to delete.
362
+ # @param options [Google::Gax::CallOptions]
363
+ # Overrides the default settings for this call, e.g, timeout,
364
+ # retries, etc.
365
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
366
+ def delete_subscription \
367
+ subscription,
368
+ options: nil
369
+ req = Google::Pubsub::V1::DeleteSubscriptionRequest.new(
370
+ subscription: subscription
371
+ )
372
+ @delete_subscription.call(req, options)
373
+ end
374
+
375
+ # Modifies the ack deadline for a specific message. This method is useful
376
+ # to indicate that more time is needed to process a message by the
377
+ # subscriber, or to make the message available for redelivery if the
378
+ # processing was interrupted.
379
+ #
380
+ # @param subscription [String]
381
+ # The name of the subscription.
382
+ # @param ack_ids [Array<String>]
383
+ # List of acknowledgment IDs.
384
+ # @param ack_deadline_seconds [Integer]
385
+ # The new ack deadline with respect to the time this request was sent to
386
+ # the Pub/Sub system. Must be >= 0. For example, if the value is 10, the new
387
+ # ack deadline will expire 10 seconds after the +ModifyAckDeadline+ call
388
+ # was made. Specifying zero may immediately make the message available for
389
+ # another pull request.
390
+ # @param options [Google::Gax::CallOptions]
391
+ # Overrides the default settings for this call, e.g, timeout,
392
+ # retries, etc.
393
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
394
+ def modify_ack_deadline \
395
+ subscription,
396
+ ack_ids,
397
+ ack_deadline_seconds,
398
+ options: nil
399
+ req = Google::Pubsub::V1::ModifyAckDeadlineRequest.new(
400
+ subscription: subscription,
401
+ ack_ids: ack_ids,
402
+ ack_deadline_seconds: ack_deadline_seconds
403
+ )
404
+ @modify_ack_deadline.call(req, options)
405
+ end
406
+
407
+ # Acknowledges the messages associated with the +ack_ids+ in the
408
+ # +AcknowledgeRequest+. The Pub/Sub system can remove the relevant messages
409
+ # from the subscription.
410
+ #
411
+ # Acknowledging a message whose ack deadline has expired may succeed,
412
+ # but such a message may be redelivered later. Acknowledging a message more
413
+ # than once will not result in an error.
414
+ #
415
+ # @param subscription [String]
416
+ # The subscription whose message is being acknowledged.
417
+ # @param ack_ids [Array<String>]
418
+ # The acknowledgment ID for the messages being acknowledged that was returned
419
+ # by the Pub/Sub system in the +Pull+ response. Must not be empty.
420
+ # @param options [Google::Gax::CallOptions]
421
+ # Overrides the default settings for this call, e.g, timeout,
422
+ # retries, etc.
423
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
424
+ def acknowledge \
425
+ subscription,
426
+ ack_ids,
427
+ options: nil
428
+ req = Google::Pubsub::V1::AcknowledgeRequest.new(
429
+ subscription: subscription,
430
+ ack_ids: ack_ids
431
+ )
432
+ @acknowledge.call(req, options)
433
+ end
434
+
435
+ # Pulls messages from the server. Returns an empty list if there are no
436
+ # messages available in the backlog. The server may return +UNAVAILABLE+ if
437
+ # there are too many concurrent pull requests pending for the given
438
+ # subscription.
439
+ #
440
+ # @param subscription [String]
441
+ # The subscription from which messages should be pulled.
442
+ # @param return_immediately [true, false]
443
+ # If this is specified as true the system will respond immediately even if
444
+ # it is not able to return a message in the +Pull+ response. Otherwise the
445
+ # system is allowed to wait until at least one message is available rather
446
+ # than returning no messages. The client may cancel the request if it does
447
+ # not wish to wait any longer for the response.
448
+ # @param max_messages [Integer]
449
+ # The maximum number of messages returned for this request. The Pub/Sub
450
+ # system may return fewer than the number specified.
451
+ # @param options [Google::Gax::CallOptions]
452
+ # Overrides the default settings for this call, e.g, timeout,
453
+ # retries, etc.
454
+ # @return [Google::Pubsub::V1::PullResponse]
455
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
456
+ def pull \
457
+ subscription,
458
+ max_messages,
459
+ return_immediately: nil,
460
+ options: nil
461
+ req = Google::Pubsub::V1::PullRequest.new(
462
+ subscription: subscription,
463
+ max_messages: max_messages
464
+ )
465
+ req.return_immediately = return_immediately unless return_immediately.nil?
466
+ @pull.call(req, options)
467
+ end
468
+
469
+ # Modifies the +PushConfig+ for a specified subscription.
470
+ #
471
+ # This may be used to change a push subscription to a pull one (signified by
472
+ # an empty +PushConfig+) or vice versa, or change the endpoint URL and other
473
+ # attributes of a push subscription. Messages will accumulate for delivery
474
+ # continuously through the call regardless of changes to the +PushConfig+.
475
+ #
476
+ # @param subscription [String]
477
+ # The name of the subscription.
478
+ # @param push_config [Google::Pubsub::V1::PushConfig]
479
+ # The push configuration for future deliveries.
480
+ #
481
+ # An empty +pushConfig+ indicates that the Pub/Sub system should
482
+ # stop pushing messages from the given subscription and allow
483
+ # messages to be pulled and acknowledged - effectively pausing
484
+ # the subscription if +Pull+ is not called.
485
+ # @param options [Google::Gax::CallOptions]
486
+ # Overrides the default settings for this call, e.g, timeout,
487
+ # retries, etc.
488
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
489
+ def modify_push_config \
490
+ subscription,
491
+ push_config,
492
+ options: nil
493
+ req = Google::Pubsub::V1::ModifyPushConfigRequest.new(
494
+ subscription: subscription,
495
+ push_config: push_config
496
+ )
497
+ @modify_push_config.call(req, options)
498
+ end
499
+ end
500
+ end
501
+ end
502
+ end
503
+ end
@@ -0,0 +1,77 @@
1
+ {
2
+ "interfaces": {
3
+ "google.pubsub.v1.Subscriber": {
4
+ "retry_codes": {
5
+ "retry_codes_def": {
6
+ "idempotent": [
7
+ "DEADLINE_EXCEEDED",
8
+ "UNAVAILABLE"
9
+ ],
10
+ "non_idempotent": []
11
+ }
12
+ },
13
+ "retry_params": {
14
+ "default": {
15
+ "initial_retry_delay_millis": 100,
16
+ "retry_delay_multiplier": 1.3,
17
+ "max_retry_delay_millis": 60000,
18
+ "initial_rpc_timeout_millis": 60000,
19
+ "rpc_timeout_multiplier": 1.0,
20
+ "max_rpc_timeout_millis": 60000,
21
+ "total_timeout_millis": 600000
22
+ },
23
+ "messaging": {
24
+ "initial_retry_delay_millis": 100,
25
+ "retry_delay_multiplier": 1.3,
26
+ "max_retry_delay_millis": 60000,
27
+ "initial_rpc_timeout_millis": 12000,
28
+ "rpc_timeout_multiplier": 1.0,
29
+ "max_rpc_timeout_millis": 12000,
30
+ "total_timeout_millis": 600000
31
+ }
32
+ },
33
+ "methods": {
34
+ "CreateSubscription": {
35
+ "timeout_millis": 60000,
36
+ "retry_codes_name": "idempotent",
37
+ "retry_params_name": "default"
38
+ },
39
+ "GetSubscription": {
40
+ "timeout_millis": 60000,
41
+ "retry_codes_name": "idempotent",
42
+ "retry_params_name": "default"
43
+ },
44
+ "ListSubscriptions": {
45
+ "timeout_millis": 60000,
46
+ "retry_codes_name": "idempotent",
47
+ "retry_params_name": "default"
48
+ },
49
+ "DeleteSubscription": {
50
+ "timeout_millis": 60000,
51
+ "retry_codes_name": "idempotent",
52
+ "retry_params_name": "default"
53
+ },
54
+ "ModifyAckDeadline": {
55
+ "timeout_millis": 60000,
56
+ "retry_codes_name": "non_idempotent",
57
+ "retry_params_name": "default"
58
+ },
59
+ "Acknowledge": {
60
+ "timeout_millis": 60000,
61
+ "retry_codes_name": "non_idempotent",
62
+ "retry_params_name": "messaging"
63
+ },
64
+ "Pull": {
65
+ "timeout_millis": 60000,
66
+ "retry_codes_name": "non_idempotent",
67
+ "retry_params_name": "messaging"
68
+ },
69
+ "ModifyPushConfig": {
70
+ "timeout_millis": 60000,
71
+ "retry_codes_name": "non_idempotent",
72
+ "retry_params_name": "default"
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Pubsub
19
- VERSION = "0.20.0"
19
+ VERSION = "0.20.1"
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-pubsub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-27 00:00:00.000000000 Z
12
+ date: 2016-09-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -67,6 +67,20 @@ dependencies:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '1.2'
70
+ - !ruby/object:Gem::Dependency
71
+ name: google-gax
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: 0.4.4
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: 0.4.4
70
84
  - !ruby/object:Gem::Dependency
71
85
  name: minitest
72
86
  requirement: !ruby/object:Gem::Requirement
@@ -200,6 +214,11 @@ files:
200
214
  - lib/google/cloud/pubsub/topic.rb
201
215
  - lib/google/cloud/pubsub/topic/list.rb
202
216
  - lib/google/cloud/pubsub/topic/publisher.rb
217
+ - lib/google/cloud/pubsub/v1.rb
218
+ - lib/google/cloud/pubsub/v1/publisher_api.rb
219
+ - lib/google/cloud/pubsub/v1/publisher_client_config.json
220
+ - lib/google/cloud/pubsub/v1/subscriber_api.rb
221
+ - lib/google/cloud/pubsub/v1/subscriber_client_config.json
203
222
  - lib/google/cloud/pubsub/version.rb
204
223
  - lib/google/iam/v1/iam_policy.rb
205
224
  - lib/google/iam/v1/iam_policy_services.rb