google-cloud-automl-v1beta1 0.6.1 → 0.8.0

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