google-cloud-ai_platform-v1 0.26.0 → 0.28.0

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