google-cloud-channel-v1 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,770 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2022 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
+ require "google/longrunning/operations_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Channel
25
+ module V1
26
+ module CloudChannelReportsService
27
+ # Service that implements Longrunning Operations API.
28
+ class Operations
29
+ # @private
30
+ attr_reader :operations_stub
31
+
32
+ ##
33
+ # Configuration for the CloudChannelReportsService 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 CloudChannelReportsService 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
+ # These require statements are intentionally placed here to initialize
71
+ # the gRPC module only when it's required.
72
+ # See https://github.com/googleapis/toolkit/issues/446
73
+ require "gapic/grpc"
74
+ require "google/longrunning/operations_services_pb"
75
+
76
+ # Create the configuration object
77
+ @config = Configuration.new Operations.configure
78
+
79
+ # Yield the configuration if needed
80
+ yield @config if block_given?
81
+
82
+ # Create credentials
83
+ credentials = @config.credentials
84
+ credentials ||= Credentials.default scope: @config.scope
85
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
86
+ credentials = Credentials.new credentials, scope: @config.scope
87
+ end
88
+ @quota_project_id = @config.quota_project
89
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
90
+
91
+ @operations_stub = ::Gapic::ServiceStub.new(
92
+ ::Google::Longrunning::Operations::Stub,
93
+ credentials: credentials,
94
+ endpoint: @config.endpoint,
95
+ channel_args: @config.channel_args,
96
+ interceptors: @config.interceptors
97
+ )
98
+
99
+ # Used by an LRO wrapper for some methods of this service
100
+ @operations_client = self
101
+ end
102
+
103
+ # Service calls
104
+
105
+ ##
106
+ # Lists operations that match the specified filter in the request. If the
107
+ # server doesn't support this method, it returns `UNIMPLEMENTED`.
108
+ #
109
+ # NOTE: the `name` binding allows API services to override the binding
110
+ # to use different resource name schemes, such as `users/*/operations`. To
111
+ # override the binding, API services can add a binding such as
112
+ # `"/v1/{name=users/*}/operations"` to their service configuration.
113
+ # For backwards compatibility, the default name includes the operations
114
+ # collection id, however overriding users must ensure the name binding
115
+ # is the parent resource, without the operations collection id.
116
+ #
117
+ # @overload list_operations(request, options = nil)
118
+ # Pass arguments to `list_operations` via a request object, either of type
119
+ # {::Google::Longrunning::ListOperationsRequest} or an equivalent Hash.
120
+ #
121
+ # @param request [::Google::Longrunning::ListOperationsRequest, ::Hash]
122
+ # A request object representing the call parameters. Required. To specify no
123
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
124
+ # @param options [::Gapic::CallOptions, ::Hash]
125
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
126
+ #
127
+ # @overload list_operations(name: nil, filter: nil, page_size: nil, page_token: nil)
128
+ # Pass arguments to `list_operations` via keyword arguments. Note that at
129
+ # least one keyword argument is required. To specify no parameters, or to keep all
130
+ # the default parameter values, pass an empty Hash as a request object (see above).
131
+ #
132
+ # @param name [::String]
133
+ # The name of the operation's parent resource.
134
+ # @param filter [::String]
135
+ # The standard list filter.
136
+ # @param page_size [::Integer]
137
+ # The standard list page size.
138
+ # @param page_token [::String]
139
+ # The standard list page token.
140
+ #
141
+ # @yield [response, operation] Access the result along with the RPC operation
142
+ # @yieldparam response [::Gapic::PagedEnumerable<::Gapic::Operation>]
143
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
144
+ #
145
+ # @return [::Gapic::PagedEnumerable<::Gapic::Operation>]
146
+ #
147
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
148
+ #
149
+ # @example Basic example
150
+ # require "google/longrunning"
151
+ #
152
+ # # Create a client object. The client can be reused for multiple calls.
153
+ # client = Google::Longrunning::Operations::Client.new
154
+ #
155
+ # # Create a request. To set request fields, pass in keyword arguments.
156
+ # request = Google::Longrunning::ListOperationsRequest.new
157
+ #
158
+ # # Call the list_operations method.
159
+ # result = client.list_operations request
160
+ #
161
+ # # The returned object is of type Gapic::PagedEnumerable. You can
162
+ # # iterate over all elements by calling #each, and the enumerable
163
+ # # will lazily make API calls to fetch subsequent pages. Other
164
+ # # methods are also available for managing paging directly.
165
+ # result.each do |response|
166
+ # # Each element is of type ::Google::Longrunning::Operation.
167
+ # p response
168
+ # end
169
+ #
170
+ def list_operations request, options = nil
171
+ raise ::ArgumentError, "request must be provided" if request.nil?
172
+
173
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::ListOperationsRequest
174
+
175
+ # Converts hash and nil to an options object
176
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
177
+
178
+ # Customize the options with defaults
179
+ metadata = @config.rpcs.list_operations.metadata.to_h
180
+
181
+ # Set x-goog-api-client and x-goog-user-project headers
182
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
183
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
184
+ gapic_version: ::Google::Cloud::Channel::V1::VERSION
185
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
186
+
187
+ header_params = {}
188
+ if request.name
189
+ header_params["name"] = request.name
190
+ end
191
+
192
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
193
+ metadata[:"x-goog-request-params"] ||= request_params_header
194
+
195
+ options.apply_defaults timeout: @config.rpcs.list_operations.timeout,
196
+ metadata: metadata,
197
+ retry_policy: @config.rpcs.list_operations.retry_policy
198
+
199
+ options.apply_defaults timeout: @config.timeout,
200
+ metadata: @config.metadata,
201
+ retry_policy: @config.retry_policy
202
+
203
+ @operations_stub.call_rpc :list_operations, request, options: options do |response, operation|
204
+ wrap_lro_operation = ->(op_response) { ::Gapic::Operation.new op_response, @operations_client }
205
+ response = ::Gapic::PagedEnumerable.new @operations_stub, :list_operations, request, response, operation, options, format_resource: wrap_lro_operation
206
+ yield response, operation if block_given?
207
+ return response
208
+ end
209
+ rescue ::GRPC::BadStatus => e
210
+ raise ::Google::Cloud::Error.from_error(e)
211
+ end
212
+
213
+ ##
214
+ # Gets the latest state of a long-running operation. Clients can use this
215
+ # method to poll the operation result at intervals as recommended by the API
216
+ # service.
217
+ #
218
+ # @overload get_operation(request, options = nil)
219
+ # Pass arguments to `get_operation` via a request object, either of type
220
+ # {::Google::Longrunning::GetOperationRequest} or an equivalent Hash.
221
+ #
222
+ # @param request [::Google::Longrunning::GetOperationRequest, ::Hash]
223
+ # A request object representing the call parameters. Required. To specify no
224
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
225
+ # @param options [::Gapic::CallOptions, ::Hash]
226
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
227
+ #
228
+ # @overload get_operation(name: nil)
229
+ # Pass arguments to `get_operation` via keyword arguments. Note that at
230
+ # least one keyword argument is required. To specify no parameters, or to keep all
231
+ # the default parameter values, pass an empty Hash as a request object (see above).
232
+ #
233
+ # @param name [::String]
234
+ # The name of the operation resource.
235
+ #
236
+ # @yield [response, operation] Access the result along with the RPC operation
237
+ # @yieldparam response [::Gapic::Operation]
238
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
239
+ #
240
+ # @return [::Gapic::Operation]
241
+ #
242
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
243
+ #
244
+ # @example Basic example
245
+ # require "google/longrunning"
246
+ #
247
+ # # Create a client object. The client can be reused for multiple calls.
248
+ # client = Google::Longrunning::Operations::Client.new
249
+ #
250
+ # # Create a request. To set request fields, pass in keyword arguments.
251
+ # request = Google::Longrunning::GetOperationRequest.new
252
+ #
253
+ # # Call the get_operation method.
254
+ # result = client.get_operation request
255
+ #
256
+ # # The returned object is of type Gapic::Operation. You can use this
257
+ # # object to check the status of an operation, cancel it, or wait
258
+ # # for results. Here is how to block until completion:
259
+ # result.wait_until_done! timeout: 60
260
+ # if result.response?
261
+ # p result.response
262
+ # else
263
+ # puts "Error!"
264
+ # end
265
+ #
266
+ def get_operation request, options = nil
267
+ raise ::ArgumentError, "request must be provided" if request.nil?
268
+
269
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::GetOperationRequest
270
+
271
+ # Converts hash and nil to an options object
272
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
273
+
274
+ # Customize the options with defaults
275
+ metadata = @config.rpcs.get_operation.metadata.to_h
276
+
277
+ # Set x-goog-api-client and x-goog-user-project headers
278
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
279
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
280
+ gapic_version: ::Google::Cloud::Channel::V1::VERSION
281
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
282
+
283
+ header_params = {}
284
+ if request.name
285
+ header_params["name"] = request.name
286
+ end
287
+
288
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
289
+ metadata[:"x-goog-request-params"] ||= request_params_header
290
+
291
+ options.apply_defaults timeout: @config.rpcs.get_operation.timeout,
292
+ metadata: metadata,
293
+ retry_policy: @config.rpcs.get_operation.retry_policy
294
+
295
+ options.apply_defaults timeout: @config.timeout,
296
+ metadata: @config.metadata,
297
+ retry_policy: @config.retry_policy
298
+
299
+ @operations_stub.call_rpc :get_operation, request, options: options do |response, operation|
300
+ response = ::Gapic::Operation.new response, @operations_client, options: options
301
+ yield response, operation if block_given?
302
+ return response
303
+ end
304
+ rescue ::GRPC::BadStatus => e
305
+ raise ::Google::Cloud::Error.from_error(e)
306
+ end
307
+
308
+ ##
309
+ # Deletes a long-running operation. This method indicates that the client is
310
+ # no longer interested in the operation result. It does not cancel the
311
+ # operation. If the server doesn't support this method, it returns
312
+ # `google.rpc.Code.UNIMPLEMENTED`.
313
+ #
314
+ # @overload delete_operation(request, options = nil)
315
+ # Pass arguments to `delete_operation` via a request object, either of type
316
+ # {::Google::Longrunning::DeleteOperationRequest} or an equivalent Hash.
317
+ #
318
+ # @param request [::Google::Longrunning::DeleteOperationRequest, ::Hash]
319
+ # A request object representing the call parameters. Required. To specify no
320
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
321
+ # @param options [::Gapic::CallOptions, ::Hash]
322
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
323
+ #
324
+ # @overload delete_operation(name: nil)
325
+ # Pass arguments to `delete_operation` via keyword arguments. Note that at
326
+ # least one keyword argument is required. To specify no parameters, or to keep all
327
+ # the default parameter values, pass an empty Hash as a request object (see above).
328
+ #
329
+ # @param name [::String]
330
+ # The name of the operation resource to be deleted.
331
+ #
332
+ # @yield [response, operation] Access the result along with the RPC operation
333
+ # @yieldparam response [::Google::Protobuf::Empty]
334
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
335
+ #
336
+ # @return [::Google::Protobuf::Empty]
337
+ #
338
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
339
+ #
340
+ # @example Basic example
341
+ # require "google/longrunning"
342
+ #
343
+ # # Create a client object. The client can be reused for multiple calls.
344
+ # client = Google::Longrunning::Operations::Client.new
345
+ #
346
+ # # Create a request. To set request fields, pass in keyword arguments.
347
+ # request = Google::Longrunning::DeleteOperationRequest.new
348
+ #
349
+ # # Call the delete_operation method.
350
+ # result = client.delete_operation request
351
+ #
352
+ # # The returned object is of type Google::Protobuf::Empty.
353
+ # p result
354
+ #
355
+ def delete_operation request, options = nil
356
+ raise ::ArgumentError, "request must be provided" if request.nil?
357
+
358
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::DeleteOperationRequest
359
+
360
+ # Converts hash and nil to an options object
361
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
362
+
363
+ # Customize the options with defaults
364
+ metadata = @config.rpcs.delete_operation.metadata.to_h
365
+
366
+ # Set x-goog-api-client and x-goog-user-project headers
367
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
368
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
369
+ gapic_version: ::Google::Cloud::Channel::V1::VERSION
370
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
371
+
372
+ header_params = {}
373
+ if request.name
374
+ header_params["name"] = request.name
375
+ end
376
+
377
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
378
+ metadata[:"x-goog-request-params"] ||= request_params_header
379
+
380
+ options.apply_defaults timeout: @config.rpcs.delete_operation.timeout,
381
+ metadata: metadata,
382
+ retry_policy: @config.rpcs.delete_operation.retry_policy
383
+
384
+ options.apply_defaults timeout: @config.timeout,
385
+ metadata: @config.metadata,
386
+ retry_policy: @config.retry_policy
387
+
388
+ @operations_stub.call_rpc :delete_operation, request, options: options do |response, operation|
389
+ yield response, operation if block_given?
390
+ return response
391
+ end
392
+ rescue ::GRPC::BadStatus => e
393
+ raise ::Google::Cloud::Error.from_error(e)
394
+ end
395
+
396
+ ##
397
+ # Starts asynchronous cancellation on a long-running operation. The server
398
+ # makes a best effort to cancel the operation, but success is not
399
+ # guaranteed. If the server doesn't support this method, it returns
400
+ # `google.rpc.Code.UNIMPLEMENTED`. Clients can use
401
+ # Operations.GetOperation or
402
+ # other methods to check whether the cancellation succeeded or whether the
403
+ # operation completed despite cancellation. On successful cancellation,
404
+ # the operation is not deleted; instead, it becomes an operation with
405
+ # an {::Google::Longrunning::Operation#error Operation.error} value with a {::Google::Rpc::Status#code google.rpc.Status.code} of 1,
406
+ # corresponding to `Code.CANCELLED`.
407
+ #
408
+ # @overload cancel_operation(request, options = nil)
409
+ # Pass arguments to `cancel_operation` via a request object, either of type
410
+ # {::Google::Longrunning::CancelOperationRequest} or an equivalent Hash.
411
+ #
412
+ # @param request [::Google::Longrunning::CancelOperationRequest, ::Hash]
413
+ # A request object representing the call parameters. Required. To specify no
414
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
415
+ # @param options [::Gapic::CallOptions, ::Hash]
416
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
417
+ #
418
+ # @overload cancel_operation(name: nil)
419
+ # Pass arguments to `cancel_operation` via keyword arguments. Note that at
420
+ # least one keyword argument is required. To specify no parameters, or to keep all
421
+ # the default parameter values, pass an empty Hash as a request object (see above).
422
+ #
423
+ # @param name [::String]
424
+ # The name of the operation resource to be cancelled.
425
+ #
426
+ # @yield [response, operation] Access the result along with the RPC operation
427
+ # @yieldparam response [::Google::Protobuf::Empty]
428
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
429
+ #
430
+ # @return [::Google::Protobuf::Empty]
431
+ #
432
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
433
+ #
434
+ # @example Basic example
435
+ # require "google/longrunning"
436
+ #
437
+ # # Create a client object. The client can be reused for multiple calls.
438
+ # client = Google::Longrunning::Operations::Client.new
439
+ #
440
+ # # Create a request. To set request fields, pass in keyword arguments.
441
+ # request = Google::Longrunning::CancelOperationRequest.new
442
+ #
443
+ # # Call the cancel_operation method.
444
+ # result = client.cancel_operation request
445
+ #
446
+ # # The returned object is of type Google::Protobuf::Empty.
447
+ # p result
448
+ #
449
+ def cancel_operation request, options = nil
450
+ raise ::ArgumentError, "request must be provided" if request.nil?
451
+
452
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::CancelOperationRequest
453
+
454
+ # Converts hash and nil to an options object
455
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
456
+
457
+ # Customize the options with defaults
458
+ metadata = @config.rpcs.cancel_operation.metadata.to_h
459
+
460
+ # Set x-goog-api-client and x-goog-user-project headers
461
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
462
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
463
+ gapic_version: ::Google::Cloud::Channel::V1::VERSION
464
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
465
+
466
+ header_params = {}
467
+ if request.name
468
+ header_params["name"] = request.name
469
+ end
470
+
471
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
472
+ metadata[:"x-goog-request-params"] ||= request_params_header
473
+
474
+ options.apply_defaults timeout: @config.rpcs.cancel_operation.timeout,
475
+ metadata: metadata,
476
+ retry_policy: @config.rpcs.cancel_operation.retry_policy
477
+
478
+ options.apply_defaults timeout: @config.timeout,
479
+ metadata: @config.metadata,
480
+ retry_policy: @config.retry_policy
481
+
482
+ @operations_stub.call_rpc :cancel_operation, request, options: options do |response, operation|
483
+ yield response, operation if block_given?
484
+ return response
485
+ end
486
+ rescue ::GRPC::BadStatus => e
487
+ raise ::Google::Cloud::Error.from_error(e)
488
+ end
489
+
490
+ ##
491
+ # Waits until the specified long-running operation is done or reaches at most
492
+ # a specified timeout, returning the latest state. If the operation is
493
+ # already done, the latest state is immediately returned. If the timeout
494
+ # specified is greater than the default HTTP/RPC timeout, the HTTP/RPC
495
+ # timeout is used. If the server does not support this method, it returns
496
+ # `google.rpc.Code.UNIMPLEMENTED`.
497
+ # Note that this method is on a best-effort basis. It may return the latest
498
+ # state before the specified timeout (including immediately), meaning even an
499
+ # immediate response is no guarantee that the operation is done.
500
+ #
501
+ # @overload wait_operation(request, options = nil)
502
+ # Pass arguments to `wait_operation` via a request object, either of type
503
+ # {::Google::Longrunning::WaitOperationRequest} or an equivalent Hash.
504
+ #
505
+ # @param request [::Google::Longrunning::WaitOperationRequest, ::Hash]
506
+ # A request object representing the call parameters. Required. To specify no
507
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
508
+ # @param options [::Gapic::CallOptions, ::Hash]
509
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
510
+ #
511
+ # @overload wait_operation(name: nil, timeout: nil)
512
+ # Pass arguments to `wait_operation` via keyword arguments. Note that at
513
+ # least one keyword argument is required. To specify no parameters, or to keep all
514
+ # the default parameter values, pass an empty Hash as a request object (see above).
515
+ #
516
+ # @param name [::String]
517
+ # The name of the operation resource to wait on.
518
+ # @param timeout [::Google::Protobuf::Duration, ::Hash]
519
+ # The maximum duration to wait before timing out. If left blank, the wait
520
+ # will be at most the time permitted by the underlying HTTP/RPC protocol.
521
+ # If RPC context deadline is also specified, the shorter one will be used.
522
+ #
523
+ # @yield [response, operation] Access the result along with the RPC operation
524
+ # @yieldparam response [::Gapic::Operation]
525
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
526
+ #
527
+ # @return [::Gapic::Operation]
528
+ #
529
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
530
+ #
531
+ # @example Basic example
532
+ # require "google/longrunning"
533
+ #
534
+ # # Create a client object. The client can be reused for multiple calls.
535
+ # client = Google::Longrunning::Operations::Client.new
536
+ #
537
+ # # Create a request. To set request fields, pass in keyword arguments.
538
+ # request = Google::Longrunning::WaitOperationRequest.new
539
+ #
540
+ # # Call the wait_operation method.
541
+ # result = client.wait_operation request
542
+ #
543
+ # # The returned object is of type Gapic::Operation. You can use this
544
+ # # object to check the status of an operation, cancel it, or wait
545
+ # # for results. Here is how to block until completion:
546
+ # result.wait_until_done! timeout: 60
547
+ # if result.response?
548
+ # p result.response
549
+ # else
550
+ # puts "Error!"
551
+ # end
552
+ #
553
+ def wait_operation request, options = nil
554
+ raise ::ArgumentError, "request must be provided" if request.nil?
555
+
556
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Longrunning::WaitOperationRequest
557
+
558
+ # Converts hash and nil to an options object
559
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
560
+
561
+ # Customize the options with defaults
562
+ metadata = @config.rpcs.wait_operation.metadata.to_h
563
+
564
+ # Set x-goog-api-client and x-goog-user-project headers
565
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
566
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
567
+ gapic_version: ::Google::Cloud::Channel::V1::VERSION
568
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
569
+
570
+ options.apply_defaults timeout: @config.rpcs.wait_operation.timeout,
571
+ metadata: metadata,
572
+ retry_policy: @config.rpcs.wait_operation.retry_policy
573
+
574
+ options.apply_defaults timeout: @config.timeout,
575
+ metadata: @config.metadata,
576
+ retry_policy: @config.retry_policy
577
+
578
+ @operations_stub.call_rpc :wait_operation, request, options: options do |response, operation|
579
+ response = ::Gapic::Operation.new response, @operations_client, options: options
580
+ yield response, operation if block_given?
581
+ return response
582
+ end
583
+ rescue ::GRPC::BadStatus => e
584
+ raise ::Google::Cloud::Error.from_error(e)
585
+ end
586
+
587
+ ##
588
+ # Configuration class for the Operations API.
589
+ #
590
+ # This class represents the configuration for Operations,
591
+ # providing control over timeouts, retry behavior, logging, transport
592
+ # parameters, and other low-level controls. Certain parameters can also be
593
+ # applied individually to specific RPCs. See
594
+ # {::Google::Longrunning::Operations::Client::Configuration::Rpcs}
595
+ # for a list of RPCs that can be configured independently.
596
+ #
597
+ # Configuration can be applied globally to all clients, or to a single client
598
+ # on construction.
599
+ #
600
+ # @example
601
+ #
602
+ # # Modify the global config, setting the timeout for
603
+ # # list_operations to 20 seconds,
604
+ # # and all remaining timeouts to 10 seconds.
605
+ # ::Google::Longrunning::Operations::Client.configure do |config|
606
+ # config.timeout = 10.0
607
+ # config.rpcs.list_operations.timeout = 20.0
608
+ # end
609
+ #
610
+ # # Apply the above configuration only to a new client.
611
+ # client = ::Google::Longrunning::Operations::Client.new do |config|
612
+ # config.timeout = 10.0
613
+ # config.rpcs.list_operations.timeout = 20.0
614
+ # end
615
+ #
616
+ # @!attribute [rw] endpoint
617
+ # The hostname or hostname:port of the service endpoint.
618
+ # Defaults to `"cloudchannel.googleapis.com"`.
619
+ # @return [::String]
620
+ # @!attribute [rw] credentials
621
+ # Credentials to send with calls. You may provide any of the following types:
622
+ # * (`String`) The path to a service account key file in JSON format
623
+ # * (`Hash`) A service account key as a Hash
624
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
625
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
626
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
627
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
628
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
629
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
630
+ # * (`nil`) indicating no credentials
631
+ # @return [::Object]
632
+ # @!attribute [rw] scope
633
+ # The OAuth scopes
634
+ # @return [::Array<::String>]
635
+ # @!attribute [rw] lib_name
636
+ # The library name as recorded in instrumentation and logging
637
+ # @return [::String]
638
+ # @!attribute [rw] lib_version
639
+ # The library version as recorded in instrumentation and logging
640
+ # @return [::String]
641
+ # @!attribute [rw] channel_args
642
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
643
+ # `GRPC::Core::Channel` object is provided as the credential.
644
+ # @return [::Hash]
645
+ # @!attribute [rw] interceptors
646
+ # An array of interceptors that are run before calls are executed.
647
+ # @return [::Array<::GRPC::ClientInterceptor>]
648
+ # @!attribute [rw] timeout
649
+ # The call timeout in seconds.
650
+ # @return [::Numeric]
651
+ # @!attribute [rw] metadata
652
+ # Additional gRPC headers to be sent with the call.
653
+ # @return [::Hash{::Symbol=>::String}]
654
+ # @!attribute [rw] retry_policy
655
+ # The retry policy. The value is a hash with the following keys:
656
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
657
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
658
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
659
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
660
+ # trigger a retry.
661
+ # @return [::Hash]
662
+ # @!attribute [rw] quota_project
663
+ # A separate project against which to charge quota.
664
+ # @return [::String]
665
+ #
666
+ class Configuration
667
+ extend ::Gapic::Config
668
+
669
+ config_attr :endpoint, "cloudchannel.googleapis.com", ::String
670
+ config_attr :credentials, nil do |value|
671
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
672
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
673
+ allowed.any? { |klass| klass === value }
674
+ end
675
+ config_attr :scope, nil, ::String, ::Array, nil
676
+ config_attr :lib_name, nil, ::String, nil
677
+ config_attr :lib_version, nil, ::String, nil
678
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
679
+ config_attr :interceptors, nil, ::Array, nil
680
+ config_attr :timeout, nil, ::Numeric, nil
681
+ config_attr :metadata, nil, ::Hash, nil
682
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
683
+ config_attr :quota_project, nil, ::String, nil
684
+
685
+ # @private
686
+ def initialize parent_config = nil
687
+ @parent_config = parent_config unless parent_config.nil?
688
+
689
+ yield self if block_given?
690
+ end
691
+
692
+ ##
693
+ # Configurations for individual RPCs
694
+ # @return [Rpcs]
695
+ #
696
+ def rpcs
697
+ @rpcs ||= begin
698
+ parent_rpcs = nil
699
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
700
+ Rpcs.new parent_rpcs
701
+ end
702
+ end
703
+
704
+ ##
705
+ # Configuration RPC class for the Operations API.
706
+ #
707
+ # Includes fields providing the configuration for each RPC in this service.
708
+ # Each configuration object is of type `Gapic::Config::Method` and includes
709
+ # the following configuration fields:
710
+ #
711
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
712
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
713
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
714
+ # include the following keys:
715
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
716
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
717
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
718
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
719
+ # trigger a retry.
720
+ #
721
+ class Rpcs
722
+ ##
723
+ # RPC-specific configuration for `list_operations`
724
+ # @return [::Gapic::Config::Method]
725
+ #
726
+ attr_reader :list_operations
727
+ ##
728
+ # RPC-specific configuration for `get_operation`
729
+ # @return [::Gapic::Config::Method]
730
+ #
731
+ attr_reader :get_operation
732
+ ##
733
+ # RPC-specific configuration for `delete_operation`
734
+ # @return [::Gapic::Config::Method]
735
+ #
736
+ attr_reader :delete_operation
737
+ ##
738
+ # RPC-specific configuration for `cancel_operation`
739
+ # @return [::Gapic::Config::Method]
740
+ #
741
+ attr_reader :cancel_operation
742
+ ##
743
+ # RPC-specific configuration for `wait_operation`
744
+ # @return [::Gapic::Config::Method]
745
+ #
746
+ attr_reader :wait_operation
747
+
748
+ # @private
749
+ def initialize parent_rpcs = nil
750
+ list_operations_config = parent_rpcs.list_operations if parent_rpcs.respond_to? :list_operations
751
+ @list_operations = ::Gapic::Config::Method.new list_operations_config
752
+ get_operation_config = parent_rpcs.get_operation if parent_rpcs.respond_to? :get_operation
753
+ @get_operation = ::Gapic::Config::Method.new get_operation_config
754
+ delete_operation_config = parent_rpcs.delete_operation if parent_rpcs.respond_to? :delete_operation
755
+ @delete_operation = ::Gapic::Config::Method.new delete_operation_config
756
+ cancel_operation_config = parent_rpcs.cancel_operation if parent_rpcs.respond_to? :cancel_operation
757
+ @cancel_operation = ::Gapic::Config::Method.new cancel_operation_config
758
+ wait_operation_config = parent_rpcs.wait_operation if parent_rpcs.respond_to? :wait_operation
759
+ @wait_operation = ::Gapic::Config::Method.new wait_operation_config
760
+
761
+ yield self if block_given?
762
+ end
763
+ end
764
+ end
765
+ end
766
+ end
767
+ end
768
+ end
769
+ end
770
+ end