google-cloud-run-v2 0.6.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/google/cloud/run/v2/condition_pb.rb +1 -0
  4. data/lib/google/cloud/run/v2/execution_pb.rb +1 -0
  5. data/lib/google/cloud/run/v2/executions/client.rb +10 -12
  6. data/lib/google/cloud/run/v2/executions/operations.rb +14 -16
  7. data/lib/google/cloud/run/v2/executions/rest/client.rb +533 -0
  8. data/lib/google/cloud/run/v2/executions/rest/operations.rb +935 -0
  9. data/lib/google/cloud/run/v2/executions/rest/service_stub.rb +225 -0
  10. data/lib/google/cloud/run/v2/executions/rest.rb +53 -0
  11. data/lib/google/cloud/run/v2/executions.rb +6 -0
  12. data/lib/google/cloud/run/v2/job_pb.rb +2 -1
  13. data/lib/google/cloud/run/v2/jobs/client.rb +22 -24
  14. data/lib/google/cloud/run/v2/jobs/operations.rb +14 -16
  15. data/lib/google/cloud/run/v2/jobs/rest/client.rb +998 -0
  16. data/lib/google/cloud/run/v2/jobs/rest/operations.rb +935 -0
  17. data/lib/google/cloud/run/v2/jobs/rest/service_stub.rb +584 -0
  18. data/lib/google/cloud/run/v2/jobs/rest.rb +53 -0
  19. data/lib/google/cloud/run/v2/jobs.rb +6 -0
  20. data/lib/google/cloud/run/v2/k8s.min_pb.rb +2 -0
  21. data/lib/google/cloud/run/v2/rest.rb +41 -0
  22. data/lib/google/cloud/run/v2/revision_pb.rb +2 -0
  23. data/lib/google/cloud/run/v2/revision_template_pb.rb +1 -0
  24. data/lib/google/cloud/run/v2/revisions/client.rb +10 -12
  25. data/lib/google/cloud/run/v2/revisions/operations.rb +14 -16
  26. data/lib/google/cloud/run/v2/revisions/rest/client.rb +531 -0
  27. data/lib/google/cloud/run/v2/revisions/rest/operations.rb +935 -0
  28. data/lib/google/cloud/run/v2/revisions/rest/service_stub.rb +225 -0
  29. data/lib/google/cloud/run/v2/revisions/rest.rb +53 -0
  30. data/lib/google/cloud/run/v2/revisions.rb +6 -0
  31. data/lib/google/cloud/run/v2/service_pb.rb +1 -0
  32. data/lib/google/cloud/run/v2/services/client.rb +20 -22
  33. data/lib/google/cloud/run/v2/services/operations.rb +14 -16
  34. data/lib/google/cloud/run/v2/services/rest/client.rb +940 -0
  35. data/lib/google/cloud/run/v2/services/rest/operations.rb +935 -0
  36. data/lib/google/cloud/run/v2/services/rest/service_stub.rb +524 -0
  37. data/lib/google/cloud/run/v2/services/rest.rb +53 -0
  38. data/lib/google/cloud/run/v2/services.rb +6 -0
  39. data/lib/google/cloud/run/v2/task_pb.rb +1 -0
  40. data/lib/google/cloud/run/v2/tasks/client.rb +6 -8
  41. data/lib/google/cloud/run/v2/tasks/rest/client.rb +440 -0
  42. data/lib/google/cloud/run/v2/tasks/rest/service_stub.rb +166 -0
  43. data/lib/google/cloud/run/v2/tasks/rest.rb +52 -0
  44. data/lib/google/cloud/run/v2/tasks.rb +6 -0
  45. data/lib/google/cloud/run/v2/version.rb +1 -1
  46. data/lib/google/cloud/run/v2.rb +5 -0
  47. data/proto_docs/google/api/client.rb +67 -4
  48. data/proto_docs/google/cloud/run/v2/condition.rb +3 -0
  49. data/proto_docs/google/cloud/run/v2/execution.rb +22 -15
  50. data/proto_docs/google/cloud/run/v2/execution_template.rb +14 -5
  51. data/proto_docs/google/cloud/run/v2/job.rb +16 -6
  52. data/proto_docs/google/cloud/run/v2/k8s.min.rb +23 -34
  53. data/proto_docs/google/cloud/run/v2/revision.rb +25 -12
  54. data/proto_docs/google/cloud/run/v2/revision_template.rb +16 -2
  55. data/proto_docs/google/cloud/run/v2/service.rb +16 -8
  56. data/proto_docs/google/cloud/run/v2/task.rb +13 -7
  57. data/proto_docs/google/cloud/run/v2/task_template.rb +2 -0
  58. data/proto_docs/google/iam/v1/policy.rb +8 -4
  59. metadata +32 -9
@@ -0,0 +1,935 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/operation"
20
+
21
+ module Google
22
+ module Cloud
23
+ module Run
24
+ module V2
25
+ module Executions
26
+ module Rest
27
+ # Service that implements Longrunning Operations API.
28
+ class Operations
29
+ # @private
30
+ attr_reader :operations_stub
31
+
32
+ ##
33
+ # Configuration for the Executions Operations API.
34
+ #
35
+ # @yield [config] Configure the Operations client.
36
+ # @yieldparam config [Operations::Configuration]
37
+ #
38
+ # @return [Operations::Configuration]
39
+ #
40
+ def self.configure
41
+ @configure ||= Operations::Configuration.new
42
+ yield @configure if block_given?
43
+ @configure
44
+ end
45
+
46
+ ##
47
+ # Configure the Executions Operations instance.
48
+ #
49
+ # The configuration is set to the derived mode, meaning that values can be changed,
50
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
51
+ # should be made on {Operations.configure}.
52
+ #
53
+ # @yield [config] Configure the Operations client.
54
+ # @yieldparam config [Operations::Configuration]
55
+ #
56
+ # @return [Operations::Configuration]
57
+ #
58
+ def configure
59
+ yield @config if block_given?
60
+ @config
61
+ end
62
+
63
+ ##
64
+ # Create a new Operations client object.
65
+ #
66
+ # @yield [config] Configure the Client client.
67
+ # @yieldparam config [Operations::Configuration]
68
+ #
69
+ def initialize
70
+ # Create the configuration object
71
+ @config = Configuration.new Operations.configure
72
+
73
+ # Yield the configuration if needed
74
+ yield @config if block_given?
75
+
76
+ # Create credentials
77
+ credentials = @config.credentials
78
+ credentials ||= Credentials.default scope: @config.scope
79
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
80
+ credentials = Credentials.new credentials, scope: @config.scope
81
+ end
82
+
83
+ @quota_project_id = @config.quota_project
84
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
85
+
86
+ @operations_stub = OperationsServiceStub.new(
87
+ endpoint: @config.endpoint,
88
+ credentials: credentials
89
+ )
90
+
91
+ # Used by an LRO wrapper for some methods of this service
92
+ @operations_client = self
93
+ end
94
+
95
+ # Service calls
96
+
97
+ ##
98
+ # Lists operations that match the specified filter in the request. If the
99
+ # server doesn't support this method, it returns `UNIMPLEMENTED`.
100
+ #
101
+ # NOTE: the `name` binding allows API services to override the binding
102
+ # to use different resource name schemes, such as `users/*/operations`. To
103
+ # override the binding, API services can add a binding such as
104
+ # `"/v1/{name=users/*}/operations"` to their service configuration.
105
+ # For backwards compatibility, the default name includes the operations
106
+ # collection id, however overriding users must ensure the name binding
107
+ # is the parent resource, without the operations collection id.
108
+ #
109
+ # @overload list_operations(request, options = nil)
110
+ # Pass arguments to `list_operations` via a request object, either of type
111
+ # {::Google::Longrunning::ListOperationsRequest} or an equivalent Hash.
112
+ #
113
+ # @param request [::Google::Longrunning::ListOperationsRequest, ::Hash]
114
+ # A request object representing the call parameters. Required. To specify no
115
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
116
+ # @param options [::Gapic::CallOptions, ::Hash]
117
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
118
+ #
119
+ # @overload list_operations(name: nil, filter: nil, page_size: nil, page_token: nil)
120
+ # Pass arguments to `list_operations` via keyword arguments. Note that at
121
+ # least one keyword argument is required. To specify no parameters, or to keep all
122
+ # the default parameter values, pass an empty Hash as a request object (see above).
123
+ #
124
+ # @param name [::String]
125
+ # The name of the operation's parent resource.
126
+ # @param filter [::String]
127
+ # The standard list filter.
128
+ # @param page_size [::Integer]
129
+ # The standard list page size.
130
+ # @param page_token [::String]
131
+ # The standard list page token.
132
+ # @yield [result, operation] Access the result along with the TransportOperation object
133
+ # @yieldparam result [::Gapic::Operation]
134
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
135
+ #
136
+ # @return [::Gapic::Operation]
137
+ #
138
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
139
+ def list_operations request, options = nil
140
+ raise ::ArgumentError, "request must be provided" if request.nil?
141
+
142
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::ListOperationsRequest
143
+
144
+ # Converts hash and nil to an options object
145
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
146
+
147
+ # Customize the options with defaults
148
+ call_metadata = @config.rpcs.list_operations.metadata.to_h
149
+
150
+ # Set x-goog-api-client and x-goog-user-project headers
151
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
152
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
153
+ gapic_version: ::Google::Cloud::Run::V2::VERSION,
154
+ transports_version_send: [:rest]
155
+
156
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
157
+
158
+ options.apply_defaults timeout: @config.rpcs.list_operations.timeout,
159
+ metadata: call_metadata,
160
+ retry_policy: @config.rpcs.list_operations.retry_policy
161
+
162
+ options.apply_defaults timeout: @config.timeout,
163
+ metadata: @config.metadata,
164
+ retry_policy: @config.retry_policy
165
+
166
+ @operations_stub.list_operations request, options do |result, operation|
167
+ result = ::Gapic::Rest::PagedEnumerable.new @operations_stub, :list_operations, "operations", request, result, options
168
+ yield result, operation if block_given?
169
+ return result
170
+ end
171
+ rescue ::Gapic::Rest::Error => e
172
+ raise ::Google::Cloud::Error.from_error(e)
173
+ end
174
+
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
+ # @overload get_operation(request, options = nil)
181
+ # Pass arguments to `get_operation` via a request object, either of type
182
+ # {::Google::Longrunning::GetOperationRequest} or an equivalent Hash.
183
+ #
184
+ # @param request [::Google::Longrunning::GetOperationRequest, ::Hash]
185
+ # A request object representing the call parameters. Required. To specify no
186
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
187
+ # @param options [::Gapic::CallOptions, ::Hash]
188
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
189
+ #
190
+ # @overload get_operation(name: nil)
191
+ # Pass arguments to `get_operation` via keyword arguments. Note that at
192
+ # least one keyword argument is required. To specify no parameters, or to keep all
193
+ # the default parameter values, pass an empty Hash as a request object (see above).
194
+ #
195
+ # @param name [::String]
196
+ # The name of the operation resource.
197
+ # @yield [result, operation] Access the result along with the TransportOperation object
198
+ # @yieldparam result [::Gapic::Operation]
199
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
200
+ #
201
+ # @return [::Gapic::Operation]
202
+ #
203
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
204
+ def get_operation request, options = nil
205
+ raise ::ArgumentError, "request must be provided" if request.nil?
206
+
207
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::GetOperationRequest
208
+
209
+ # Converts hash and nil to an options object
210
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
211
+
212
+ # Customize the options with defaults
213
+ call_metadata = @config.rpcs.get_operation.metadata.to_h
214
+
215
+ # Set x-goog-api-client and x-goog-user-project headers
216
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
217
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
218
+ gapic_version: ::Google::Cloud::Run::V2::VERSION,
219
+ transports_version_send: [:rest]
220
+
221
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
222
+
223
+ options.apply_defaults timeout: @config.rpcs.get_operation.timeout,
224
+ metadata: call_metadata,
225
+ retry_policy: @config.rpcs.get_operation.retry_policy
226
+
227
+ options.apply_defaults timeout: @config.timeout,
228
+ metadata: @config.metadata,
229
+ retry_policy: @config.retry_policy
230
+
231
+ @operations_stub.get_operation request, options do |result, operation|
232
+ result = ::Gapic::Operation.new result, @operations_client, options: options
233
+ yield result, operation if block_given?
234
+ return result
235
+ end
236
+ rescue ::Gapic::Rest::Error => e
237
+ raise ::Google::Cloud::Error.from_error(e)
238
+ end
239
+
240
+ ##
241
+ # Deletes a long-running operation. This method indicates that the client is
242
+ # no longer interested in the operation result. It does not cancel the
243
+ # operation. If the server doesn't support this method, it returns
244
+ # `google.rpc.Code.UNIMPLEMENTED`.
245
+ #
246
+ # @overload delete_operation(request, options = nil)
247
+ # Pass arguments to `delete_operation` via a request object, either of type
248
+ # {::Google::Longrunning::DeleteOperationRequest} or an equivalent Hash.
249
+ #
250
+ # @param request [::Google::Longrunning::DeleteOperationRequest, ::Hash]
251
+ # A request object representing the call parameters. Required. To specify no
252
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
253
+ # @param options [::Gapic::CallOptions, ::Hash]
254
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
255
+ #
256
+ # @overload delete_operation(name: nil)
257
+ # Pass arguments to `delete_operation` via keyword arguments. Note that at
258
+ # least one keyword argument is required. To specify no parameters, or to keep all
259
+ # the default parameter values, pass an empty Hash as a request object (see above).
260
+ #
261
+ # @param name [::String]
262
+ # The name of the operation resource to be deleted.
263
+ # @yield [result, operation] Access the result along with the TransportOperation object
264
+ # @yieldparam result [::Google::Protobuf::Empty]
265
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
266
+ #
267
+ # @return [::Google::Protobuf::Empty]
268
+ #
269
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
270
+ def delete_operation request, options = nil
271
+ raise ::ArgumentError, "request must be provided" if request.nil?
272
+
273
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::DeleteOperationRequest
274
+
275
+ # Converts hash and nil to an options object
276
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
277
+
278
+ # Customize the options with defaults
279
+ call_metadata = @config.rpcs.delete_operation.metadata.to_h
280
+
281
+ # Set x-goog-api-client and x-goog-user-project headers
282
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
283
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
284
+ gapic_version: ::Google::Cloud::Run::V2::VERSION,
285
+ transports_version_send: [:rest]
286
+
287
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
288
+
289
+ options.apply_defaults timeout: @config.rpcs.delete_operation.timeout,
290
+ metadata: call_metadata,
291
+ retry_policy: @config.rpcs.delete_operation.retry_policy
292
+
293
+ options.apply_defaults timeout: @config.timeout,
294
+ metadata: @config.metadata,
295
+ retry_policy: @config.retry_policy
296
+
297
+ @operations_stub.delete_operation request, options do |result, operation|
298
+ yield result, operation if block_given?
299
+ return result
300
+ end
301
+ rescue ::Gapic::Rest::Error => e
302
+ raise ::Google::Cloud::Error.from_error(e)
303
+ end
304
+
305
+ ##
306
+ # Starts asynchronous cancellation on a long-running operation. The server
307
+ # makes a best effort to cancel the operation, but success is not
308
+ # guaranteed. If the server doesn't support this method, it returns
309
+ # `google.rpc.Code.UNIMPLEMENTED`. Clients can use
310
+ # Operations.GetOperation or
311
+ # other methods to check whether the cancellation succeeded or whether the
312
+ # operation completed despite cancellation. On successful cancellation,
313
+ # the operation is not deleted; instead, it becomes an operation with
314
+ # an {::Google::Longrunning::Operation#error Operation.error} value with a {::Google::Rpc::Status#code google.rpc.Status.code} of 1,
315
+ # corresponding to `Code.CANCELLED`.
316
+ #
317
+ # @overload cancel_operation(request, options = nil)
318
+ # Pass arguments to `cancel_operation` via a request object, either of type
319
+ # {::Google::Longrunning::CancelOperationRequest} or an equivalent Hash.
320
+ #
321
+ # @param request [::Google::Longrunning::CancelOperationRequest, ::Hash]
322
+ # A request object representing the call parameters. Required. To specify no
323
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
324
+ # @param options [::Gapic::CallOptions, ::Hash]
325
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
326
+ #
327
+ # @overload cancel_operation(name: nil)
328
+ # Pass arguments to `cancel_operation` via keyword arguments. Note that at
329
+ # least one keyword argument is required. To specify no parameters, or to keep all
330
+ # the default parameter values, pass an empty Hash as a request object (see above).
331
+ #
332
+ # @param name [::String]
333
+ # The name of the operation resource to be cancelled.
334
+ # @yield [result, operation] Access the result along with the TransportOperation object
335
+ # @yieldparam result [::Google::Protobuf::Empty]
336
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
337
+ #
338
+ # @return [::Google::Protobuf::Empty]
339
+ #
340
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
341
+ def cancel_operation request, options = nil
342
+ raise ::ArgumentError, "request must be provided" if request.nil?
343
+
344
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::CancelOperationRequest
345
+
346
+ # Converts hash and nil to an options object
347
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
348
+
349
+ # Customize the options with defaults
350
+ call_metadata = @config.rpcs.cancel_operation.metadata.to_h
351
+
352
+ # Set x-goog-api-client and x-goog-user-project headers
353
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
354
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
355
+ gapic_version: ::Google::Cloud::Run::V2::VERSION,
356
+ transports_version_send: [:rest]
357
+
358
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
359
+
360
+ options.apply_defaults timeout: @config.rpcs.cancel_operation.timeout,
361
+ metadata: call_metadata,
362
+ retry_policy: @config.rpcs.cancel_operation.retry_policy
363
+
364
+ options.apply_defaults timeout: @config.timeout,
365
+ metadata: @config.metadata,
366
+ retry_policy: @config.retry_policy
367
+
368
+ @operations_stub.cancel_operation request, options do |result, operation|
369
+ yield result, operation if block_given?
370
+ return result
371
+ end
372
+ rescue ::Gapic::Rest::Error => e
373
+ raise ::Google::Cloud::Error.from_error(e)
374
+ end
375
+
376
+ ##
377
+ # Waits until the specified long-running operation is done or reaches at most
378
+ # a specified timeout, returning the latest state. If the operation is
379
+ # already done, the latest state is immediately returned. If the timeout
380
+ # specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
381
+ # timeout is used. If the server does not support this method, it returns
382
+ # `google.rpc.Code.UNIMPLEMENTED`.
383
+ # Note that this method is on a best-effort basis. It may return the latest
384
+ # state before the specified timeout (including immediately), meaning even an
385
+ # immediate response is no guarantee that the operation is done.
386
+ #
387
+ # @overload wait_operation(request, options = nil)
388
+ # Pass arguments to `wait_operation` via a request object, either of type
389
+ # {::Google::Longrunning::WaitOperationRequest} or an equivalent Hash.
390
+ #
391
+ # @param request [::Google::Longrunning::WaitOperationRequest, ::Hash]
392
+ # A request object representing the call parameters. Required. To specify no
393
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
394
+ # @param options [::Gapic::CallOptions, ::Hash]
395
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
396
+ #
397
+ # @overload wait_operation(name: nil, timeout: nil)
398
+ # Pass arguments to `wait_operation` via keyword arguments. Note that at
399
+ # least one keyword argument is required. To specify no parameters, or to keep all
400
+ # the default parameter values, pass an empty Hash as a request object (see above).
401
+ #
402
+ # @param name [::String]
403
+ # The name of the operation resource to wait on.
404
+ # @param timeout [::Google::Protobuf::Duration, ::Hash]
405
+ # The maximum duration to wait before timing out. If left blank, the wait
406
+ # will be at most the time permitted by the underlying HTTP/RPC protocol.
407
+ # If RPC context deadline is also specified, the shorter one will be used.
408
+ # @yield [result, operation] Access the result along with the TransportOperation object
409
+ # @yieldparam result [::Gapic::Operation]
410
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
411
+ #
412
+ # @return [::Gapic::Operation]
413
+ #
414
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
415
+ def wait_operation request, options = nil
416
+ raise ::ArgumentError, "request must be provided" if request.nil?
417
+
418
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::WaitOperationRequest
419
+
420
+ # Converts hash and nil to an options object
421
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
422
+
423
+ # Customize the options with defaults
424
+ call_metadata = @config.rpcs.wait_operation.metadata.to_h
425
+
426
+ # Set x-goog-api-client and x-goog-user-project headers
427
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
428
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
429
+ gapic_version: ::Google::Cloud::Run::V2::VERSION,
430
+ transports_version_send: [:rest]
431
+
432
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
433
+
434
+ options.apply_defaults timeout: @config.rpcs.wait_operation.timeout,
435
+ metadata: call_metadata,
436
+ retry_policy: @config.rpcs.wait_operation.retry_policy
437
+
438
+ options.apply_defaults timeout: @config.timeout,
439
+ metadata: @config.metadata,
440
+ retry_policy: @config.retry_policy
441
+
442
+ @operations_stub.wait_operation request, options do |result, operation|
443
+ result = ::Gapic::Operation.new result, @operations_client, options: options
444
+ yield result, operation if block_given?
445
+ return result
446
+ end
447
+ rescue ::Gapic::Rest::Error => e
448
+ raise ::Google::Cloud::Error.from_error(e)
449
+ end
450
+
451
+ ##
452
+ # Configuration class for the Operations REST API.
453
+ #
454
+ # This class represents the configuration for Operations REST,
455
+ # providing control over timeouts, retry behavior, logging, transport
456
+ # parameters, and other low-level controls. Certain parameters can also be
457
+ # applied individually to specific RPCs. See
458
+ # {::Google::Longrunning::Operations::Rest::Client::Configuration::Rpcs}
459
+ # for a list of RPCs that can be configured independently.
460
+ #
461
+ # Configuration can be applied globally to all clients, or to a single client
462
+ # on construction.
463
+ #
464
+ # @example
465
+ #
466
+ # # Modify the global config, setting the timeout for
467
+ # # list_operations to 20 seconds,
468
+ # # and all remaining timeouts to 10 seconds.
469
+ # ::Google::Longrunning::Operations::Rest::Client.configure do |config|
470
+ # config.timeout = 10.0
471
+ # config.rpcs.list_operations.timeout = 20.0
472
+ # end
473
+ #
474
+ # # Apply the above configuration only to a new client.
475
+ # client = ::Google::Longrunning::Operations::Rest::Client.new do |config|
476
+ # config.timeout = 10.0
477
+ # config.rpcs.list_operations.timeout = 20.0
478
+ # end
479
+ #
480
+ # @!attribute [rw] endpoint
481
+ # The hostname or hostname:port of the service endpoint.
482
+ # Defaults to `"run.googleapis.com"`.
483
+ # @return [::String]
484
+ # @!attribute [rw] credentials
485
+ # Credentials to send with calls. You may provide any of the following types:
486
+ # * (`String`) The path to a service account key file in JSON format
487
+ # * (`Hash`) A service account key as a Hash
488
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
489
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
490
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
491
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
492
+ # * (`nil`) indicating no credentials
493
+ # @return [::Object]
494
+ # @!attribute [rw] scope
495
+ # The OAuth scopes
496
+ # @return [::Array<::String>]
497
+ # @!attribute [rw] lib_name
498
+ # The library name as recorded in instrumentation and logging
499
+ # @return [::String]
500
+ # @!attribute [rw] lib_version
501
+ # The library version as recorded in instrumentation and logging
502
+ # @return [::String]
503
+ # @!attribute [rw] timeout
504
+ # The call timeout in seconds.
505
+ # @return [::Numeric]
506
+ # @!attribute [rw] metadata
507
+ # Additional headers to be sent with the call.
508
+ # @return [::Hash{::Symbol=>::String}]
509
+ # @!attribute [rw] retry_policy
510
+ # The retry policy. The value is a hash with the following keys:
511
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
512
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
513
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
514
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
515
+ # trigger a retry.
516
+ # @return [::Hash]
517
+ # @!attribute [rw] quota_project
518
+ # A separate project against which to charge quota.
519
+ # @return [::String]
520
+ #
521
+ class Configuration
522
+ extend ::Gapic::Config
523
+
524
+ config_attr :endpoint, "run.googleapis.com", ::String
525
+ config_attr :credentials, nil do |value|
526
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
527
+ allowed.any? { |klass| klass === value }
528
+ end
529
+ config_attr :scope, nil, ::String, ::Array, nil
530
+ config_attr :lib_name, nil, ::String, nil
531
+ config_attr :lib_version, nil, ::String, nil
532
+ config_attr :timeout, nil, ::Numeric, nil
533
+ config_attr :metadata, nil, ::Hash, nil
534
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
535
+ config_attr :quota_project, nil, ::String, nil
536
+
537
+ # @private
538
+ def initialize parent_config = nil
539
+ @parent_config = parent_config unless parent_config.nil?
540
+
541
+ yield self if block_given?
542
+ end
543
+
544
+ ##
545
+ # Configurations for individual RPCs
546
+ # @return [Rpcs]
547
+ #
548
+ def rpcs
549
+ @rpcs ||= begin
550
+ parent_rpcs = nil
551
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
552
+ Rpcs.new parent_rpcs
553
+ end
554
+ end
555
+
556
+ ##
557
+ # Configuration RPC class for the Operations API.
558
+ #
559
+ # Includes fields providing the configuration for each RPC in this service.
560
+ # Each configuration object is of type `Gapic::Config::Method` and includes
561
+ # the following configuration fields:
562
+ #
563
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
564
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
565
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
566
+ # include the following keys:
567
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
568
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
569
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
570
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
571
+ # trigger a retry.
572
+ #
573
+ class Rpcs
574
+ ##
575
+ # RPC-specific configuration for `list_operations`
576
+ # @return [::Gapic::Config::Method]
577
+ #
578
+ attr_reader :list_operations
579
+ ##
580
+ # RPC-specific configuration for `get_operation`
581
+ # @return [::Gapic::Config::Method]
582
+ #
583
+ attr_reader :get_operation
584
+ ##
585
+ # RPC-specific configuration for `delete_operation`
586
+ # @return [::Gapic::Config::Method]
587
+ #
588
+ attr_reader :delete_operation
589
+ ##
590
+ # RPC-specific configuration for `cancel_operation`
591
+ # @return [::Gapic::Config::Method]
592
+ #
593
+ attr_reader :cancel_operation
594
+ ##
595
+ # RPC-specific configuration for `wait_operation`
596
+ # @return [::Gapic::Config::Method]
597
+ #
598
+ attr_reader :wait_operation
599
+
600
+ # @private
601
+ def initialize parent_rpcs = nil
602
+ list_operations_config = parent_rpcs.list_operations if parent_rpcs.respond_to? :list_operations
603
+ @list_operations = ::Gapic::Config::Method.new list_operations_config
604
+ get_operation_config = parent_rpcs.get_operation if parent_rpcs.respond_to? :get_operation
605
+ @get_operation = ::Gapic::Config::Method.new get_operation_config
606
+ delete_operation_config = parent_rpcs.delete_operation if parent_rpcs.respond_to? :delete_operation
607
+ @delete_operation = ::Gapic::Config::Method.new delete_operation_config
608
+ cancel_operation_config = parent_rpcs.cancel_operation if parent_rpcs.respond_to? :cancel_operation
609
+ @cancel_operation = ::Gapic::Config::Method.new cancel_operation_config
610
+ wait_operation_config = parent_rpcs.wait_operation if parent_rpcs.respond_to? :wait_operation
611
+ @wait_operation = ::Gapic::Config::Method.new wait_operation_config
612
+
613
+ yield self if block_given?
614
+ end
615
+ end
616
+ end
617
+ end
618
+
619
+ ##
620
+ # @private
621
+ # REST service stub for the Longrunning Operations API.
622
+ # Service stub contains baseline method implementations
623
+ # including transcoding, making the REST call, and deserialing the response.
624
+ class OperationsServiceStub
625
+ def initialize endpoint:, credentials:
626
+ # These require statements are intentionally placed here to initialize
627
+ # the REST modules only when it's required.
628
+ require "gapic/rest"
629
+
630
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials
631
+ end
632
+
633
+ ##
634
+ # Baseline implementation for the list_operations REST call
635
+ #
636
+ # @param request_pb [::Google::Longrunning::ListOperationsRequest]
637
+ # A request object representing the call parameters. Required.
638
+ # @param options [::Gapic::CallOptions]
639
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
640
+ #
641
+ # @yield [result, operation] Access the result along with the TransportOperation object
642
+ # @yieldparam result [::Google::Longrunning::ListOperationsResponse]
643
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
644
+ #
645
+ # @return [::Google::Longrunning::ListOperationsResponse]
646
+ # A result object deserialized from the server's reply
647
+ def list_operations request_pb, options = nil
648
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
649
+
650
+ verb, uri, query_string_params, body = OperationsServiceStub.transcode_list_operations_request request_pb
651
+ query_string_params = if query_string_params.any?
652
+ query_string_params.to_h { |p| p.split("=", 2) }
653
+ else
654
+ {}
655
+ end
656
+
657
+ response = @client_stub.make_http_request(
658
+ verb,
659
+ uri: uri,
660
+ body: body || "",
661
+ params: query_string_params,
662
+ options: options
663
+ )
664
+ operation = ::Gapic::Rest::TransportOperation.new response
665
+ result = ::Google::Longrunning::ListOperationsResponse.decode_json response.body, ignore_unknown_fields: true
666
+
667
+ yield result, operation if block_given?
668
+ result
669
+ end
670
+
671
+ ##
672
+ # Baseline implementation for the get_operation REST call
673
+ #
674
+ # @param request_pb [::Google::Longrunning::GetOperationRequest]
675
+ # A request object representing the call parameters. Required.
676
+ # @param options [::Gapic::CallOptions]
677
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
678
+ #
679
+ # @yield [result, operation] Access the result along with the TransportOperation object
680
+ # @yieldparam result [::Google::Longrunning::Operation]
681
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
682
+ #
683
+ # @return [::Google::Longrunning::Operation]
684
+ # A result object deserialized from the server's reply
685
+ def get_operation request_pb, options = nil
686
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
687
+
688
+ verb, uri, query_string_params, body = OperationsServiceStub.transcode_get_operation_request request_pb
689
+ query_string_params = if query_string_params.any?
690
+ query_string_params.to_h { |p| p.split("=", 2) }
691
+ else
692
+ {}
693
+ end
694
+
695
+ response = @client_stub.make_http_request(
696
+ verb,
697
+ uri: uri,
698
+ body: body || "",
699
+ params: query_string_params,
700
+ options: options
701
+ )
702
+ operation = ::Gapic::Rest::TransportOperation.new response
703
+ result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
704
+
705
+ yield result, operation if block_given?
706
+ result
707
+ end
708
+
709
+ ##
710
+ # Baseline implementation for the delete_operation REST call
711
+ #
712
+ # @param request_pb [::Google::Longrunning::DeleteOperationRequest]
713
+ # A request object representing the call parameters. Required.
714
+ # @param options [::Gapic::CallOptions]
715
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
716
+ #
717
+ # @yield [result, operation] Access the result along with the TransportOperation object
718
+ # @yieldparam result [::Google::Protobuf::Empty]
719
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
720
+ #
721
+ # @return [::Google::Protobuf::Empty]
722
+ # A result object deserialized from the server's reply
723
+ def delete_operation request_pb, options = nil
724
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
725
+
726
+ verb, uri, query_string_params, body = OperationsServiceStub.transcode_delete_operation_request request_pb
727
+ query_string_params = if query_string_params.any?
728
+ query_string_params.to_h { |p| p.split("=", 2) }
729
+ else
730
+ {}
731
+ end
732
+
733
+ response = @client_stub.make_http_request(
734
+ verb,
735
+ uri: uri,
736
+ body: body || "",
737
+ params: query_string_params,
738
+ options: options
739
+ )
740
+ operation = ::Gapic::Rest::TransportOperation.new response
741
+ result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
742
+
743
+ yield result, operation if block_given?
744
+ result
745
+ end
746
+
747
+ ##
748
+ # Baseline implementation for the cancel_operation REST call
749
+ #
750
+ # @param request_pb [::Google::Longrunning::CancelOperationRequest]
751
+ # A request object representing the call parameters. Required.
752
+ # @param options [::Gapic::CallOptions]
753
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
754
+ #
755
+ # @yield [result, operation] Access the result along with the TransportOperation object
756
+ # @yieldparam result [::Google::Protobuf::Empty]
757
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
758
+ #
759
+ # @return [::Google::Protobuf::Empty]
760
+ # A result object deserialized from the server's reply
761
+ def cancel_operation request_pb, options = nil
762
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
763
+
764
+ verb, uri, query_string_params, body = OperationsServiceStub.transcode_cancel_operation_request request_pb
765
+ query_string_params = if query_string_params.any?
766
+ query_string_params.to_h { |p| p.split("=", 2) }
767
+ else
768
+ {}
769
+ end
770
+
771
+ response = @client_stub.make_http_request(
772
+ verb,
773
+ uri: uri,
774
+ body: body || "",
775
+ params: query_string_params,
776
+ options: options
777
+ )
778
+ operation = ::Gapic::Rest::TransportOperation.new response
779
+ result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
780
+
781
+ yield result, operation if block_given?
782
+ result
783
+ end
784
+
785
+ ##
786
+ # Baseline implementation for the wait_operation REST call
787
+ #
788
+ # @param request_pb [::Google::Longrunning::WaitOperationRequest]
789
+ # A request object representing the call parameters. Required.
790
+ # @param options [::Gapic::CallOptions]
791
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
792
+ #
793
+ # @yield [result, operation] Access the result along with the TransportOperation object
794
+ # @yieldparam result [::Google::Longrunning::Operation]
795
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
796
+ #
797
+ # @return [::Google::Longrunning::Operation]
798
+ # A result object deserialized from the server's reply
799
+ def wait_operation request_pb, options = nil
800
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
801
+
802
+ verb, uri, query_string_params, body = OperationsServiceStub.transcode_wait_operation_request request_pb
803
+ query_string_params = if query_string_params.any?
804
+ query_string_params.to_h { |p| p.split("=", 2) }
805
+ else
806
+ {}
807
+ end
808
+
809
+ response = @client_stub.make_http_request(
810
+ verb,
811
+ uri: uri,
812
+ body: body || "",
813
+ params: query_string_params,
814
+ options: options
815
+ )
816
+ operation = ::Gapic::Rest::TransportOperation.new response
817
+ result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
818
+
819
+ yield result, operation if block_given?
820
+ result
821
+ end
822
+
823
+ ##
824
+ # @private
825
+ #
826
+ # GRPC transcoding helper method for the list_operations REST call
827
+ #
828
+ # @param request_pb [::Google::Longrunning::ListOperationsRequest]
829
+ # A request object representing the call parameters. Required.
830
+ # @return [Array(String, [String, nil], Hash{String => String})]
831
+ # Uri, Body, Query string parameters
832
+ def self.transcode_list_operations_request request_pb
833
+ transcoder = Gapic::Rest::GrpcTranscoder.new
834
+ .with_bindings(
835
+ uri_method: :get,
836
+ uri_template: "/v2/{name}/operations",
837
+ matches: [
838
+ ["name", %r{^projects/[^/]+/locations/[^/]+/?$}, false]
839
+ ]
840
+ )
841
+ transcoder.transcode request_pb
842
+ end
843
+
844
+ ##
845
+ # @private
846
+ #
847
+ # GRPC transcoding helper method for the get_operation REST call
848
+ #
849
+ # @param request_pb [::Google::Longrunning::GetOperationRequest]
850
+ # A request object representing the call parameters. Required.
851
+ # @return [Array(String, [String, nil], Hash{String => String})]
852
+ # Uri, Body, Query string parameters
853
+ def self.transcode_get_operation_request request_pb
854
+ transcoder = Gapic::Rest::GrpcTranscoder.new
855
+ .with_bindings(
856
+ uri_method: :get,
857
+ uri_template: "/v2/{name}",
858
+ matches: [
859
+ ["name", %r{^projects/[^/]+/locations/[^/]+/operations/[^/]+/?$}, false]
860
+ ]
861
+ )
862
+ transcoder.transcode request_pb
863
+ end
864
+
865
+ ##
866
+ # @private
867
+ #
868
+ # GRPC transcoding helper method for the delete_operation REST call
869
+ #
870
+ # @param request_pb [::Google::Longrunning::DeleteOperationRequest]
871
+ # A request object representing the call parameters. Required.
872
+ # @return [Array(String, [String, nil], Hash{String => String})]
873
+ # Uri, Body, Query string parameters
874
+ def self.transcode_delete_operation_request request_pb
875
+ transcoder = Gapic::Rest::GrpcTranscoder.new
876
+ .with_bindings(
877
+ uri_method: :delete,
878
+ uri_template: "/v2/{name}",
879
+ matches: [
880
+ ["name", %r{^projects/[^/]+/locations/[^/]+/operations/[^/]+/?$}, false]
881
+ ]
882
+ )
883
+ transcoder.transcode request_pb
884
+ end
885
+
886
+ ##
887
+ # @private
888
+ #
889
+ # GRPC transcoding helper method for the cancel_operation REST call
890
+ #
891
+ # @param request_pb [::Google::Longrunning::CancelOperationRequest]
892
+ # A request object representing the call parameters. Required.
893
+ # @return [Array(String, [String, nil], Hash{String => String})]
894
+ # Uri, Body, Query string parameters
895
+ def self.transcode_cancel_operation_request request_pb
896
+ transcoder = Gapic::Rest::GrpcTranscoder.new
897
+ .with_bindings(
898
+ uri_method: :post,
899
+ uri_template: "/v1/{name}:cancel",
900
+ body: "*",
901
+ matches: [
902
+ ["name", %r{^operations(?:/.*)?$}, true]
903
+ ]
904
+ )
905
+ transcoder.transcode request_pb
906
+ end
907
+
908
+ ##
909
+ # @private
910
+ #
911
+ # GRPC transcoding helper method for the wait_operation REST call
912
+ #
913
+ # @param request_pb [::Google::Longrunning::WaitOperationRequest]
914
+ # A request object representing the call parameters. Required.
915
+ # @return [Array(String, [String, nil], Hash{String => String})]
916
+ # Uri, Body, Query string parameters
917
+ def self.transcode_wait_operation_request request_pb
918
+ transcoder = Gapic::Rest::GrpcTranscoder.new
919
+ .with_bindings(
920
+ uri_method: :post,
921
+ uri_template: "/v2/{name}:wait",
922
+ body: "*",
923
+ matches: [
924
+ ["name", %r{^projects/[^/]+/locations/[^/]+/operations/[^/]+/?$}, false]
925
+ ]
926
+ )
927
+ transcoder.transcode request_pb
928
+ end
929
+ end
930
+ end
931
+ end
932
+ end
933
+ end
934
+ end
935
+ end