google-cloud-ai_platform-v1 0.52.0 → 0.53.0

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