google-gax 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aeba7e008b2cfb90d91a6ac6152f7304e4650e61
|
4
|
+
data.tar.gz: a0acc832fe6182aacb394cb2c44ba6b257122a19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c703f3bc01fb85d6843736a279f072a20bdfa4f47edd54d1ae567ce1ee17538b4c972d15f1502c692fef94a601edc914351994eb2468eadeaa7bad984e6f707c
|
7
|
+
data.tar.gz: 3222c245b93925e212d8a75c27ce8f3bddcae520af1d8509eda226973bb28b435655ff34315fbbe0c2b8a32727ad3eaae1d3ccacd6e0cd7c880f0151c881a107
|
@@ -63,11 +63,9 @@ module Google
|
|
63
63
|
raise 'path template has no segments' if segments.nil?
|
64
64
|
segments.each do |s|
|
65
65
|
next unless s.kind == TERMINAL && s.literal == '**'
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
has_path_wildcard = true
|
70
|
-
end
|
66
|
+
raise 'path template cannot contain more than' \
|
67
|
+
'one path wildcard' if has_path_wildcard
|
68
|
+
has_path_wildcard = true
|
71
69
|
end
|
72
70
|
segments
|
73
71
|
end
|
data/lib/google/gax/settings.rb
CHANGED
@@ -40,15 +40,14 @@ module Google
|
|
40
40
|
# @return An Executor that configures bundling, or nil if this
|
41
41
|
# method should not bundle.
|
42
42
|
def construct_bundling(bundle_config, bundle_descriptor)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
48
|
-
# Bundling is currently not supported.
|
49
|
-
# Executor.new(options)
|
50
|
-
nil
|
43
|
+
return unless bundle_config && bundle_descriptor
|
44
|
+
options = BundleOptions.new
|
45
|
+
bundle_config.each_pair do |key, value|
|
46
|
+
options[key.intern] = value
|
51
47
|
end
|
48
|
+
# Bundling is currently not supported.
|
49
|
+
# Executor.new(options)
|
50
|
+
nil
|
52
51
|
end
|
53
52
|
|
54
53
|
# Helper for #construct_settings
|
data/lib/google/gax/version.rb
CHANGED
@@ -0,0 +1,330 @@
|
|
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/longrunning/operations.proto,
|
18
|
+
# and updates to that file get reflected here through a refresh process.
|
19
|
+
# For the short term, the refresh process will only be runnable by Google
|
20
|
+
# engineers.
|
21
|
+
#
|
22
|
+
# The only allowed edits are to method and file documentation. A 3-way
|
23
|
+
# merge preserves those additions if the generated source changes.
|
24
|
+
|
25
|
+
require "json"
|
26
|
+
require "pathname"
|
27
|
+
|
28
|
+
require "google/gax"
|
29
|
+
|
30
|
+
module Google
|
31
|
+
module Longrunning
|
32
|
+
# Manages long-running operations with an API service.
|
33
|
+
#
|
34
|
+
# When an API method normally takes long time to complete, it can be designed
|
35
|
+
# to return Operation to the client, and the client can use this
|
36
|
+
# interface to receive the real response asynchronously by polling the
|
37
|
+
# operation resource, or pass the operation resource to another API (such as
|
38
|
+
# Google Cloud Pub/Sub API) to receive the response. Any API service that
|
39
|
+
# returns long-running operations should implement the +Operations+ interface
|
40
|
+
# so developers can have a consistent client experience.
|
41
|
+
#
|
42
|
+
# @!attribute [r] operations_stub
|
43
|
+
# @return [Google::Longrunning::Operations::Stub]
|
44
|
+
class OperationsApi
|
45
|
+
attr_reader :operations_stub
|
46
|
+
|
47
|
+
# The default address of the service.
|
48
|
+
SERVICE_ADDRESS = "longrunning.googleapis.com".freeze
|
49
|
+
|
50
|
+
# The default port of the service.
|
51
|
+
DEFAULT_SERVICE_PORT = 443
|
52
|
+
|
53
|
+
CODE_GEN_NAME_VERSION = "gapic/0.1.0".freeze
|
54
|
+
|
55
|
+
DEFAULT_TIMEOUT = 30
|
56
|
+
|
57
|
+
PAGE_DESCRIPTORS = {
|
58
|
+
"list_operations" => Google::Gax::PageDescriptor.new(
|
59
|
+
"page_token",
|
60
|
+
"next_page_token",
|
61
|
+
"operations")
|
62
|
+
}.freeze
|
63
|
+
|
64
|
+
private_constant :PAGE_DESCRIPTORS
|
65
|
+
|
66
|
+
# The scopes needed to make gRPC calls to all of the methods defined in
|
67
|
+
# this service.
|
68
|
+
ALL_SCOPES = [
|
69
|
+
].freeze
|
70
|
+
|
71
|
+
OPERATION_PATH_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
72
|
+
"operations/{operation_path=**}"
|
73
|
+
)
|
74
|
+
|
75
|
+
private_constant :OPERATION_PATH_PATH_TEMPLATE
|
76
|
+
|
77
|
+
# Returns a fully-qualified operation_path resource name string.
|
78
|
+
# @param operation_path [String]
|
79
|
+
# @return [String]
|
80
|
+
def self.operation_path_path operation_path
|
81
|
+
OPERATION_PATH_PATH_TEMPLATE.render(
|
82
|
+
:"operation_path" => operation_path
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Parses the operation_path from a operation_path resource.
|
87
|
+
# @param operation_path_name [String]
|
88
|
+
# @return [String]
|
89
|
+
def self.match_operation_path_from_operation_path_name operation_path_name
|
90
|
+
OPERATION_PATH_PATH_TEMPLATE.match(operation_path_name)["operation_path"]
|
91
|
+
end
|
92
|
+
|
93
|
+
# @param service_path [String]
|
94
|
+
# The domain name of the API remote host.
|
95
|
+
# @param port [Integer]
|
96
|
+
# The port on which to connect to the remote host.
|
97
|
+
# @param channel [Channel]
|
98
|
+
# A Channel object through which to make calls.
|
99
|
+
# @param chan_creds [Grpc::ChannelCredentials]
|
100
|
+
# A ChannelCredentials for the setting up the RPC client.
|
101
|
+
# @param client_config[Hash]
|
102
|
+
# A Hash for call options for each method. See
|
103
|
+
# Google::Gax#construct_settings for the structure of
|
104
|
+
# this data. Falls back to the default config if not specified
|
105
|
+
# or the specified config is missing data points.
|
106
|
+
# @param timeout [Numeric]
|
107
|
+
# The default timeout, in seconds, for calls made through this client.
|
108
|
+
# @param app_name [String]
|
109
|
+
# The codename of the calling service.
|
110
|
+
# @param app_version [String]
|
111
|
+
# The version of the calling service.
|
112
|
+
def initialize \
|
113
|
+
service_path: SERVICE_ADDRESS,
|
114
|
+
port: DEFAULT_SERVICE_PORT,
|
115
|
+
channel: nil,
|
116
|
+
chan_creds: nil,
|
117
|
+
scopes: ALL_SCOPES,
|
118
|
+
client_config: {},
|
119
|
+
timeout: DEFAULT_TIMEOUT,
|
120
|
+
app_name: "gax",
|
121
|
+
app_version: Google::Gax::VERSION
|
122
|
+
# These require statements are intentionally placed here to initialize
|
123
|
+
# the gRPC module only when it's required.
|
124
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
125
|
+
require "google/gax/grpc"
|
126
|
+
require "google/longrunning/operations_services_pb"
|
127
|
+
|
128
|
+
google_api_client = "#{app_name}/#{app_version} " \
|
129
|
+
"#{CODE_GEN_NAME_VERSION} gax/#{Google::Gax::VERSION} " \
|
130
|
+
"ruby/#{RUBY_VERSION}".freeze
|
131
|
+
headers = { :"x-goog-api-client" => google_api_client }
|
132
|
+
client_config_file = Pathname.new(__dir__).join(
|
133
|
+
"operations_client_config.json"
|
134
|
+
)
|
135
|
+
defaults = client_config_file.open do |f|
|
136
|
+
Google::Gax.construct_settings(
|
137
|
+
"google.longrunning.Operations",
|
138
|
+
JSON.parse(f.read),
|
139
|
+
client_config,
|
140
|
+
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
141
|
+
timeout,
|
142
|
+
page_descriptors: PAGE_DESCRIPTORS,
|
143
|
+
errors: Google::Gax::Grpc::API_ERRORS,
|
144
|
+
kwargs: headers
|
145
|
+
)
|
146
|
+
end
|
147
|
+
@operations_stub = Google::Gax::Grpc.create_stub(
|
148
|
+
service_path,
|
149
|
+
port,
|
150
|
+
chan_creds: chan_creds,
|
151
|
+
channel: channel,
|
152
|
+
scopes: scopes,
|
153
|
+
&Google::Longrunning::Operations::Stub.method(:new)
|
154
|
+
)
|
155
|
+
|
156
|
+
@get_operation = Google::Gax.create_api_call(
|
157
|
+
@operations_stub.method(:get_operation),
|
158
|
+
defaults["get_operation"]
|
159
|
+
)
|
160
|
+
@list_operations = Google::Gax.create_api_call(
|
161
|
+
@operations_stub.method(:list_operations),
|
162
|
+
defaults["list_operations"]
|
163
|
+
)
|
164
|
+
@cancel_operation = Google::Gax.create_api_call(
|
165
|
+
@operations_stub.method(:cancel_operation),
|
166
|
+
defaults["cancel_operation"]
|
167
|
+
)
|
168
|
+
@delete_operation = Google::Gax.create_api_call(
|
169
|
+
@operations_stub.method(:delete_operation),
|
170
|
+
defaults["delete_operation"]
|
171
|
+
)
|
172
|
+
end
|
173
|
+
|
174
|
+
# Service calls
|
175
|
+
|
176
|
+
# Gets the latest state of a long-running operation. Clients can use this
|
177
|
+
# method to poll the operation result at intervals as recommended by the API
|
178
|
+
# service.
|
179
|
+
#
|
180
|
+
# @param name [String]
|
181
|
+
# The name of the operation resource.
|
182
|
+
# @param options [Google::Gax::CallOptions]
|
183
|
+
# Overrides the default settings for this call, e.g, timeout,
|
184
|
+
# retries, etc.
|
185
|
+
# @return [Google::Longrunning::Operation]
|
186
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
187
|
+
# @example
|
188
|
+
# require "google/longrunning/operations_api"
|
189
|
+
#
|
190
|
+
# OperationsApi = Google::Longrunning::OperationsApi
|
191
|
+
#
|
192
|
+
# operations_api = OperationsApi.new
|
193
|
+
# formatted_name = OperationsApi.operation_path_path("[OPERATION_PATH]")
|
194
|
+
# response = operations_api.get_operation(formatted_name)
|
195
|
+
|
196
|
+
def get_operation \
|
197
|
+
name,
|
198
|
+
options: nil
|
199
|
+
req = Google::Longrunning::GetOperationRequest.new(
|
200
|
+
name: name
|
201
|
+
)
|
202
|
+
@get_operation.call(req, options)
|
203
|
+
end
|
204
|
+
|
205
|
+
# Lists operations that match the specified filter in the request. If the
|
206
|
+
# server doesn't support this method, it returns +UNIMPLEMENTED+.
|
207
|
+
#
|
208
|
+
# NOTE: the +name+ binding below allows API services to override the binding
|
209
|
+
# to use different resource name schemes, such as +users/*/operations+.
|
210
|
+
#
|
211
|
+
# @param name [String]
|
212
|
+
# The name of the operation collection.
|
213
|
+
# @param filter [String]
|
214
|
+
# The standard list filter.
|
215
|
+
# @param page_size [Integer]
|
216
|
+
# The maximum number of resources contained in the underlying API
|
217
|
+
# response. If page streaming is performed per-resource, this
|
218
|
+
# parameter does not affect the return value. If page streaming is
|
219
|
+
# performed per-page, this determines the maximum number of
|
220
|
+
# resources in a page.
|
221
|
+
# @param options [Google::Gax::CallOptions]
|
222
|
+
# Overrides the default settings for this call, e.g, timeout,
|
223
|
+
# retries, etc.
|
224
|
+
# @return [Google::Gax::PagedEnumerable<Google::Longrunning::Operation>]
|
225
|
+
# An enumerable of Google::Longrunning::Operation instances.
|
226
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
227
|
+
# operations such as per-page iteration or access to the response
|
228
|
+
# object.
|
229
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
230
|
+
# @example
|
231
|
+
# require "google/longrunning/operations_api"
|
232
|
+
#
|
233
|
+
# OperationsApi = Google::Longrunning::OperationsApi
|
234
|
+
#
|
235
|
+
# operations_api = OperationsApi.new
|
236
|
+
# name = ''
|
237
|
+
# filter = ''
|
238
|
+
#
|
239
|
+
# # Iterate over all results.
|
240
|
+
# operations_api.list_operations(name, filter).each do |element|
|
241
|
+
# # Process element.
|
242
|
+
# end
|
243
|
+
#
|
244
|
+
# # Or iterate over results one page at a time.
|
245
|
+
# operations_api.list_operations(name, filter).each_page do |page|
|
246
|
+
# # Process each page at a time.
|
247
|
+
# page.each do |element|
|
248
|
+
# # Process element.
|
249
|
+
# end
|
250
|
+
# end
|
251
|
+
|
252
|
+
def list_operations \
|
253
|
+
name,
|
254
|
+
filter,
|
255
|
+
page_size: nil,
|
256
|
+
options: nil
|
257
|
+
req = Google::Longrunning::ListOperationsRequest.new(
|
258
|
+
name: name,
|
259
|
+
filter: filter
|
260
|
+
)
|
261
|
+
req.page_size = page_size unless page_size.nil?
|
262
|
+
@list_operations.call(req, options)
|
263
|
+
end
|
264
|
+
|
265
|
+
# Starts asynchronous cancellation on a long-running operation. The server
|
266
|
+
# makes a best effort to cancel the operation, but success is not
|
267
|
+
# guaranteed. If the server doesn't support this method, it returns
|
268
|
+
# +google.rpc.Code.UNIMPLEMENTED+. Clients can use
|
269
|
+
# Operations::GetOperation or
|
270
|
+
# other methods to check whether the cancellation succeeded or whether the
|
271
|
+
# operation completed despite cancellation. On successful cancellation,
|
272
|
+
# the operation is not deleted; instead, it becomes an operation with
|
273
|
+
# an Operation#error value with a Google::Rpc::Status#code of 1,
|
274
|
+
# corresponding to +Code.CANCELLED+.
|
275
|
+
#
|
276
|
+
# @param name [String]
|
277
|
+
# The name of the operation resource to be cancelled.
|
278
|
+
# @param options [Google::Gax::CallOptions]
|
279
|
+
# Overrides the default settings for this call, e.g, timeout,
|
280
|
+
# retries, etc.
|
281
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
282
|
+
# @example
|
283
|
+
# require "google/longrunning/operations_api"
|
284
|
+
#
|
285
|
+
# OperationsApi = Google::Longrunning::OperationsApi
|
286
|
+
#
|
287
|
+
# operations_api = OperationsApi.new
|
288
|
+
# formatted_name = OperationsApi.operation_path_path("[OPERATION_PATH]")
|
289
|
+
# operations_api.cancel_operation(formatted_name)
|
290
|
+
|
291
|
+
def cancel_operation \
|
292
|
+
name,
|
293
|
+
options: nil
|
294
|
+
req = Google::Longrunning::CancelOperationRequest.new(
|
295
|
+
name: name
|
296
|
+
)
|
297
|
+
@cancel_operation.call(req, options)
|
298
|
+
end
|
299
|
+
|
300
|
+
# Deletes a long-running operation. This method indicates that the client is
|
301
|
+
# no longer interested in the operation result. It does not cancel the
|
302
|
+
# operation. If the server doesn't support this method, it returns
|
303
|
+
# +google.rpc.Code.UNIMPLEMENTED+.
|
304
|
+
#
|
305
|
+
# @param name [String]
|
306
|
+
# The name of the operation resource to be deleted.
|
307
|
+
# @param options [Google::Gax::CallOptions]
|
308
|
+
# Overrides the default settings for this call, e.g, timeout,
|
309
|
+
# retries, etc.
|
310
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
311
|
+
# @example
|
312
|
+
# require "google/longrunning/operations_api"
|
313
|
+
#
|
314
|
+
# OperationsApi = Google::Longrunning::OperationsApi
|
315
|
+
#
|
316
|
+
# operations_api = OperationsApi.new
|
317
|
+
# formatted_name = OperationsApi.operation_path_path("[OPERATION_PATH]")
|
318
|
+
# operations_api.delete_operation(formatted_name)
|
319
|
+
|
320
|
+
def delete_operation \
|
321
|
+
name,
|
322
|
+
options: nil
|
323
|
+
req = Google::Longrunning::DeleteOperationRequest.new(
|
324
|
+
name: name
|
325
|
+
)
|
326
|
+
@delete_operation.call(req, options)
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
330
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
{
|
2
|
+
"interfaces": {
|
3
|
+
"google.longrunning.Operations": {
|
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": 20000,
|
19
|
+
"rpc_timeout_multiplier": 1.0,
|
20
|
+
"max_rpc_timeout_millis": 20000,
|
21
|
+
"total_timeout_millis": 600000
|
22
|
+
}
|
23
|
+
},
|
24
|
+
"methods": {
|
25
|
+
"GetOperation": {
|
26
|
+
"timeout_millis": 60000,
|
27
|
+
"retry_codes_name": "idempotent",
|
28
|
+
"retry_params_name": "default"
|
29
|
+
},
|
30
|
+
"ListOperations": {
|
31
|
+
"timeout_millis": 60000,
|
32
|
+
"retry_codes_name": "idempotent",
|
33
|
+
"retry_params_name": "default"
|
34
|
+
},
|
35
|
+
"CancelOperation": {
|
36
|
+
"timeout_millis": 60000,
|
37
|
+
"retry_codes_name": "idempotent",
|
38
|
+
"retry_params_name": "default"
|
39
|
+
},
|
40
|
+
"DeleteOperation": {
|
41
|
+
"timeout_millis": 60000,
|
42
|
+
"retry_codes_name": "idempotent",
|
43
|
+
"retry_params_name": "default"
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-gax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Google API Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: googleauth
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: googleapis-common-protos
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.3.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.1
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rly
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,6 +152,8 @@ files:
|
|
138
152
|
- lib/google/gax/path_template.rb
|
139
153
|
- lib/google/gax/settings.rb
|
140
154
|
- lib/google/gax/version.rb
|
155
|
+
- lib/google/longrunning/operations_api.rb
|
156
|
+
- lib/google/longrunning/operations_client_config.json
|
141
157
|
- spec/google/gax/api_callable_spec.rb
|
142
158
|
- spec/google/gax/bundling_spec.rb
|
143
159
|
- spec/google/gax/path_template_spec.rb
|
@@ -163,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
179
|
version: '0'
|
164
180
|
requirements: []
|
165
181
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.
|
182
|
+
rubygems_version: 2.5.1
|
167
183
|
signing_key:
|
168
184
|
specification_version: 4
|
169
185
|
summary: Aids the development of APIs for clients and servers based on GRPC and Google
|