google-cloud-network_management-v1 1.4.0 → 1.5.0

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