google-cloud-vision-v1 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +1 -1
  3. data/README.md +1 -1
  4. data/lib/google/cloud/vision/v1/image_annotator/client.rb +8 -8
  5. data/lib/google/cloud/vision/v1/image_annotator/operations.rb +12 -14
  6. data/lib/google/cloud/vision/v1/image_annotator/rest/client.rb +662 -0
  7. data/lib/google/cloud/vision/v1/image_annotator/rest/operations.rb +814 -0
  8. data/lib/google/cloud/vision/v1/image_annotator/rest/service_stub.rb +344 -0
  9. data/lib/google/cloud/vision/v1/image_annotator/rest.rb +55 -0
  10. data/lib/google/cloud/vision/v1/image_annotator.rb +7 -1
  11. data/lib/google/cloud/vision/v1/image_annotator_pb.rb +1 -0
  12. data/lib/google/cloud/vision/v1/product_search/client.rb +24 -32
  13. data/lib/google/cloud/vision/v1/product_search/operations.rb +12 -14
  14. data/lib/google/cloud/vision/v1/product_search/rest/client.rb +1970 -0
  15. data/lib/google/cloud/vision/v1/product_search/rest/operations.rb +814 -0
  16. data/lib/google/cloud/vision/v1/product_search/rest/service_stub.rb +1178 -0
  17. data/lib/google/cloud/vision/v1/product_search/rest.rb +66 -0
  18. data/lib/google/cloud/vision/v1/product_search.rb +7 -1
  19. data/lib/google/cloud/vision/v1/rest.rb +38 -0
  20. data/lib/google/cloud/vision/v1/version.rb +1 -1
  21. data/lib/google/cloud/vision/v1.rb +7 -2
  22. data/proto_docs/google/api/client.rb +318 -0
  23. data/proto_docs/google/api/launch_stage.rb +71 -0
  24. data/proto_docs/google/cloud/vision/v1/image_annotator.rb +5 -1
  25. data/proto_docs/google/protobuf/empty.rb +0 -2
  26. data/proto_docs/google/rpc/status.rb +4 -2
  27. metadata +18 -7
@@ -0,0 +1,662 @@
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 "google/cloud/errors"
20
+ require "google/cloud/vision/v1/image_annotator_pb"
21
+ require "google/cloud/vision/v1/image_annotator/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module Vision
26
+ module V1
27
+ module ImageAnnotator
28
+ module Rest
29
+ ##
30
+ # REST client for the ImageAnnotator service.
31
+ #
32
+ # Service that performs Google Cloud Vision API detection tasks over client
33
+ # images, such as face, landmark, logo, label, and text detection. The
34
+ # ImageAnnotator service returns detected entities from the images.
35
+ #
36
+ class Client
37
+ include Paths
38
+
39
+ # @private
40
+ attr_reader :image_annotator_stub
41
+
42
+ ##
43
+ # Configure the ImageAnnotator Client class.
44
+ #
45
+ # See {::Google::Cloud::Vision::V1::ImageAnnotator::Rest::Client::Configuration}
46
+ # for a description of the configuration fields.
47
+ #
48
+ # @example
49
+ #
50
+ # # Modify the configuration for all ImageAnnotator clients
51
+ # ::Google::Cloud::Vision::V1::ImageAnnotator::Rest::Client.configure do |config|
52
+ # config.timeout = 10.0
53
+ # end
54
+ #
55
+ # @yield [config] Configure the Client client.
56
+ # @yieldparam config [Client::Configuration]
57
+ #
58
+ # @return [Client::Configuration]
59
+ #
60
+ def self.configure
61
+ @configure ||= begin
62
+ namespace = ["Google", "Cloud", "Vision", "V1"]
63
+ parent_config = while namespace.any?
64
+ parent_name = namespace.join "::"
65
+ parent_const = const_get parent_name
66
+ break parent_const.configure if parent_const.respond_to? :configure
67
+ namespace.pop
68
+ end
69
+ default_config = Client::Configuration.new parent_config
70
+
71
+ default_config.rpcs.batch_annotate_images.timeout = 600.0
72
+ default_config.rpcs.batch_annotate_images.retry_policy = {
73
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
74
+ }
75
+
76
+ default_config.rpcs.batch_annotate_files.timeout = 600.0
77
+ default_config.rpcs.batch_annotate_files.retry_policy = {
78
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
79
+ }
80
+
81
+ default_config.rpcs.async_batch_annotate_images.timeout = 600.0
82
+ default_config.rpcs.async_batch_annotate_images.retry_policy = {
83
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
84
+ }
85
+
86
+ default_config.rpcs.async_batch_annotate_files.timeout = 600.0
87
+ default_config.rpcs.async_batch_annotate_files.retry_policy = {
88
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
89
+ }
90
+
91
+ default_config
92
+ end
93
+ yield @configure if block_given?
94
+ @configure
95
+ end
96
+
97
+ ##
98
+ # Configure the ImageAnnotator Client instance.
99
+ #
100
+ # The configuration is set to the derived mode, meaning that values can be changed,
101
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
102
+ # should be made on {Client.configure}.
103
+ #
104
+ # See {::Google::Cloud::Vision::V1::ImageAnnotator::Rest::Client::Configuration}
105
+ # for a description of the configuration fields.
106
+ #
107
+ # @yield [config] Configure the Client client.
108
+ # @yieldparam config [Client::Configuration]
109
+ #
110
+ # @return [Client::Configuration]
111
+ #
112
+ def configure
113
+ yield @config if block_given?
114
+ @config
115
+ end
116
+
117
+ ##
118
+ # Create a new ImageAnnotator REST client object.
119
+ #
120
+ # @example
121
+ #
122
+ # # Create a client using the default configuration
123
+ # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Rest::Client.new
124
+ #
125
+ # # Create a client using a custom configuration
126
+ # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Rest::Client.new do |config|
127
+ # config.timeout = 10.0
128
+ # end
129
+ #
130
+ # @yield [config] Configure the ImageAnnotator client.
131
+ # @yieldparam config [Client::Configuration]
132
+ #
133
+ def initialize
134
+ # Create the configuration object
135
+ @config = Configuration.new Client.configure
136
+
137
+ # Yield the configuration if needed
138
+ yield @config if block_given?
139
+
140
+ # Create credentials
141
+ credentials = @config.credentials
142
+ # Use self-signed JWT if the endpoint is unchanged from default,
143
+ # but only if the default endpoint does not have a region prefix.
144
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
145
+ !@config.endpoint.split(".").first.include?("-")
146
+ credentials ||= Credentials.default scope: @config.scope,
147
+ enable_self_signed_jwt: enable_self_signed_jwt
148
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
149
+ credentials = Credentials.new credentials, scope: @config.scope
150
+ end
151
+
152
+ @quota_project_id = @config.quota_project
153
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
154
+
155
+ @operations_client = ::Google::Cloud::Vision::V1::ImageAnnotator::Rest::Operations.new do |config|
156
+ config.credentials = credentials
157
+ config.quota_project = @quota_project_id
158
+ config.endpoint = @config.endpoint
159
+ end
160
+
161
+ @image_annotator_stub = ::Google::Cloud::Vision::V1::ImageAnnotator::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
162
+ end
163
+
164
+ ##
165
+ # Get the associated client for long-running operations.
166
+ #
167
+ # @return [::Google::Cloud::Vision::V1::ImageAnnotator::Rest::Operations]
168
+ #
169
+ attr_reader :operations_client
170
+
171
+ # Service calls
172
+
173
+ ##
174
+ # Run image detection and annotation for a batch of images.
175
+ #
176
+ # @overload batch_annotate_images(request, options = nil)
177
+ # Pass arguments to `batch_annotate_images` via a request object, either of type
178
+ # {::Google::Cloud::Vision::V1::BatchAnnotateImagesRequest} or an equivalent Hash.
179
+ #
180
+ # @param request [::Google::Cloud::Vision::V1::BatchAnnotateImagesRequest, ::Hash]
181
+ # A request object representing the call parameters. Required. To specify no
182
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
183
+ # @param options [::Gapic::CallOptions, ::Hash]
184
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
185
+ #
186
+ # @overload batch_annotate_images(requests: nil, parent: nil)
187
+ # Pass arguments to `batch_annotate_images` via keyword arguments. Note that at
188
+ # least one keyword argument is required. To specify no parameters, or to keep all
189
+ # the default parameter values, pass an empty Hash as a request object (see above).
190
+ #
191
+ # @param requests [::Array<::Google::Cloud::Vision::V1::AnnotateImageRequest, ::Hash>]
192
+ # Required. Individual image annotation requests for this batch.
193
+ # @param parent [::String]
194
+ # Optional. Target project and location to make a call.
195
+ #
196
+ # Format: `projects/{project-id}/locations/{location-id}`.
197
+ #
198
+ # If no parent is specified, a region will be chosen automatically.
199
+ #
200
+ # Supported location-ids:
201
+ # `us`: USA country only,
202
+ # `asia`: East asia areas, like Japan, Taiwan,
203
+ # `eu`: The European Union.
204
+ #
205
+ # Example: `projects/project-A/locations/eu`.
206
+ # @yield [result, operation] Access the result along with the TransportOperation object
207
+ # @yieldparam result [::Google::Cloud::Vision::V1::BatchAnnotateImagesResponse]
208
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
209
+ #
210
+ # @return [::Google::Cloud::Vision::V1::BatchAnnotateImagesResponse]
211
+ #
212
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
213
+ def batch_annotate_images request, options = nil
214
+ raise ::ArgumentError, "request must be provided" if request.nil?
215
+
216
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::BatchAnnotateImagesRequest
217
+
218
+ # Converts hash and nil to an options object
219
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
220
+
221
+ # Customize the options with defaults
222
+ call_metadata = @config.rpcs.batch_annotate_images.metadata.to_h
223
+
224
+ # Set x-goog-api-client and x-goog-user-project headers
225
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
226
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
227
+ gapic_version: ::Google::Cloud::Vision::V1::VERSION,
228
+ transports_version_send: [:rest]
229
+
230
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
231
+
232
+ options.apply_defaults timeout: @config.rpcs.batch_annotate_images.timeout,
233
+ metadata: call_metadata,
234
+ retry_policy: @config.rpcs.batch_annotate_images.retry_policy
235
+
236
+ options.apply_defaults timeout: @config.timeout,
237
+ metadata: @config.metadata,
238
+ retry_policy: @config.retry_policy
239
+
240
+ @image_annotator_stub.batch_annotate_images request, options do |result, operation|
241
+ yield result, operation if block_given?
242
+ return result
243
+ end
244
+ rescue ::Gapic::Rest::Error => e
245
+ raise ::Google::Cloud::Error.from_error(e)
246
+ end
247
+
248
+ ##
249
+ # Service that performs image detection and annotation for a batch of files.
250
+ # Now only "application/pdf", "image/tiff" and "image/gif" are supported.
251
+ #
252
+ # This service will extract at most 5 (customers can specify which 5 in
253
+ # AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each
254
+ # file provided and perform detection and annotation for each image
255
+ # extracted.
256
+ #
257
+ # @overload batch_annotate_files(request, options = nil)
258
+ # Pass arguments to `batch_annotate_files` via a request object, either of type
259
+ # {::Google::Cloud::Vision::V1::BatchAnnotateFilesRequest} or an equivalent Hash.
260
+ #
261
+ # @param request [::Google::Cloud::Vision::V1::BatchAnnotateFilesRequest, ::Hash]
262
+ # A request object representing the call parameters. Required. To specify no
263
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
264
+ # @param options [::Gapic::CallOptions, ::Hash]
265
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
266
+ #
267
+ # @overload batch_annotate_files(requests: nil, parent: nil)
268
+ # Pass arguments to `batch_annotate_files` via keyword arguments. Note that at
269
+ # least one keyword argument is required. To specify no parameters, or to keep all
270
+ # the default parameter values, pass an empty Hash as a request object (see above).
271
+ #
272
+ # @param requests [::Array<::Google::Cloud::Vision::V1::AnnotateFileRequest, ::Hash>]
273
+ # Required. The list of file annotation requests. Right now we support only one
274
+ # AnnotateFileRequest in BatchAnnotateFilesRequest.
275
+ # @param parent [::String]
276
+ # Optional. Target project and location to make a call.
277
+ #
278
+ # Format: `projects/{project-id}/locations/{location-id}`.
279
+ #
280
+ # If no parent is specified, a region will be chosen automatically.
281
+ #
282
+ # Supported location-ids:
283
+ # `us`: USA country only,
284
+ # `asia`: East asia areas, like Japan, Taiwan,
285
+ # `eu`: The European Union.
286
+ #
287
+ # Example: `projects/project-A/locations/eu`.
288
+ # @yield [result, operation] Access the result along with the TransportOperation object
289
+ # @yieldparam result [::Google::Cloud::Vision::V1::BatchAnnotateFilesResponse]
290
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
291
+ #
292
+ # @return [::Google::Cloud::Vision::V1::BatchAnnotateFilesResponse]
293
+ #
294
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
295
+ def batch_annotate_files request, options = nil
296
+ raise ::ArgumentError, "request must be provided" if request.nil?
297
+
298
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::BatchAnnotateFilesRequest
299
+
300
+ # Converts hash and nil to an options object
301
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
302
+
303
+ # Customize the options with defaults
304
+ call_metadata = @config.rpcs.batch_annotate_files.metadata.to_h
305
+
306
+ # Set x-goog-api-client and x-goog-user-project headers
307
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
308
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
309
+ gapic_version: ::Google::Cloud::Vision::V1::VERSION,
310
+ transports_version_send: [:rest]
311
+
312
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
313
+
314
+ options.apply_defaults timeout: @config.rpcs.batch_annotate_files.timeout,
315
+ metadata: call_metadata,
316
+ retry_policy: @config.rpcs.batch_annotate_files.retry_policy
317
+
318
+ options.apply_defaults timeout: @config.timeout,
319
+ metadata: @config.metadata,
320
+ retry_policy: @config.retry_policy
321
+
322
+ @image_annotator_stub.batch_annotate_files request, options do |result, operation|
323
+ yield result, operation if block_given?
324
+ return result
325
+ end
326
+ rescue ::Gapic::Rest::Error => e
327
+ raise ::Google::Cloud::Error.from_error(e)
328
+ end
329
+
330
+ ##
331
+ # Run asynchronous image detection and annotation for a list of images.
332
+ #
333
+ # Progress and results can be retrieved through the
334
+ # `google.longrunning.Operations` interface.
335
+ # `Operation.metadata` contains `OperationMetadata` (metadata).
336
+ # `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results).
337
+ #
338
+ # This service will write image annotation outputs to json files in customer
339
+ # GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
340
+ #
341
+ # @overload async_batch_annotate_images(request, options = nil)
342
+ # Pass arguments to `async_batch_annotate_images` via a request object, either of type
343
+ # {::Google::Cloud::Vision::V1::AsyncBatchAnnotateImagesRequest} or an equivalent Hash.
344
+ #
345
+ # @param request [::Google::Cloud::Vision::V1::AsyncBatchAnnotateImagesRequest, ::Hash]
346
+ # A request object representing the call parameters. Required. To specify no
347
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
348
+ # @param options [::Gapic::CallOptions, ::Hash]
349
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
350
+ #
351
+ # @overload async_batch_annotate_images(requests: nil, output_config: nil, parent: nil)
352
+ # Pass arguments to `async_batch_annotate_images` via keyword arguments. Note that at
353
+ # least one keyword argument is required. To specify no parameters, or to keep all
354
+ # the default parameter values, pass an empty Hash as a request object (see above).
355
+ #
356
+ # @param requests [::Array<::Google::Cloud::Vision::V1::AnnotateImageRequest, ::Hash>]
357
+ # Required. Individual image annotation requests for this batch.
358
+ # @param output_config [::Google::Cloud::Vision::V1::OutputConfig, ::Hash]
359
+ # Required. The desired output location and metadata (e.g. format).
360
+ # @param parent [::String]
361
+ # Optional. Target project and location to make a call.
362
+ #
363
+ # Format: `projects/{project-id}/locations/{location-id}`.
364
+ #
365
+ # If no parent is specified, a region will be chosen automatically.
366
+ #
367
+ # Supported location-ids:
368
+ # `us`: USA country only,
369
+ # `asia`: East asia areas, like Japan, Taiwan,
370
+ # `eu`: The European Union.
371
+ #
372
+ # Example: `projects/project-A/locations/eu`.
373
+ # @yield [result, operation] Access the result along with the TransportOperation object
374
+ # @yieldparam result [::Gapic::Operation]
375
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
376
+ #
377
+ # @return [::Gapic::Operation]
378
+ #
379
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
380
+ def async_batch_annotate_images request, options = nil
381
+ raise ::ArgumentError, "request must be provided" if request.nil?
382
+
383
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::AsyncBatchAnnotateImagesRequest
384
+
385
+ # Converts hash and nil to an options object
386
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
387
+
388
+ # Customize the options with defaults
389
+ call_metadata = @config.rpcs.async_batch_annotate_images.metadata.to_h
390
+
391
+ # Set x-goog-api-client and x-goog-user-project headers
392
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
393
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
394
+ gapic_version: ::Google::Cloud::Vision::V1::VERSION,
395
+ transports_version_send: [:rest]
396
+
397
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
398
+
399
+ options.apply_defaults timeout: @config.rpcs.async_batch_annotate_images.timeout,
400
+ metadata: call_metadata,
401
+ retry_policy: @config.rpcs.async_batch_annotate_images.retry_policy
402
+
403
+ options.apply_defaults timeout: @config.timeout,
404
+ metadata: @config.metadata,
405
+ retry_policy: @config.retry_policy
406
+
407
+ @image_annotator_stub.async_batch_annotate_images request, options do |result, operation|
408
+ result = ::Gapic::Operation.new result, @operations_client, options: options
409
+ yield result, operation if block_given?
410
+ return result
411
+ end
412
+ rescue ::Gapic::Rest::Error => e
413
+ raise ::Google::Cloud::Error.from_error(e)
414
+ end
415
+
416
+ ##
417
+ # Run asynchronous image detection and annotation for a list of generic
418
+ # files, such as PDF files, which may contain multiple pages and multiple
419
+ # images per page. Progress and results can be retrieved through the
420
+ # `google.longrunning.Operations` interface.
421
+ # `Operation.metadata` contains `OperationMetadata` (metadata).
422
+ # `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
423
+ #
424
+ # @overload async_batch_annotate_files(request, options = nil)
425
+ # Pass arguments to `async_batch_annotate_files` via a request object, either of type
426
+ # {::Google::Cloud::Vision::V1::AsyncBatchAnnotateFilesRequest} or an equivalent Hash.
427
+ #
428
+ # @param request [::Google::Cloud::Vision::V1::AsyncBatchAnnotateFilesRequest, ::Hash]
429
+ # A request object representing the call parameters. Required. To specify no
430
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
431
+ # @param options [::Gapic::CallOptions, ::Hash]
432
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
433
+ #
434
+ # @overload async_batch_annotate_files(requests: nil, parent: nil)
435
+ # Pass arguments to `async_batch_annotate_files` via keyword arguments. Note that at
436
+ # least one keyword argument is required. To specify no parameters, or to keep all
437
+ # the default parameter values, pass an empty Hash as a request object (see above).
438
+ #
439
+ # @param requests [::Array<::Google::Cloud::Vision::V1::AsyncAnnotateFileRequest, ::Hash>]
440
+ # Required. Individual async file annotation requests for this batch.
441
+ # @param parent [::String]
442
+ # Optional. Target project and location to make a call.
443
+ #
444
+ # Format: `projects/{project-id}/locations/{location-id}`.
445
+ #
446
+ # If no parent is specified, a region will be chosen automatically.
447
+ #
448
+ # Supported location-ids:
449
+ # `us`: USA country only,
450
+ # `asia`: East asia areas, like Japan, Taiwan,
451
+ # `eu`: The European Union.
452
+ #
453
+ # Example: `projects/project-A/locations/eu`.
454
+ # @yield [result, operation] Access the result along with the TransportOperation object
455
+ # @yieldparam result [::Gapic::Operation]
456
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
457
+ #
458
+ # @return [::Gapic::Operation]
459
+ #
460
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
461
+ def async_batch_annotate_files request, options = nil
462
+ raise ::ArgumentError, "request must be provided" if request.nil?
463
+
464
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::AsyncBatchAnnotateFilesRequest
465
+
466
+ # Converts hash and nil to an options object
467
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
468
+
469
+ # Customize the options with defaults
470
+ call_metadata = @config.rpcs.async_batch_annotate_files.metadata.to_h
471
+
472
+ # Set x-goog-api-client and x-goog-user-project headers
473
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
474
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
475
+ gapic_version: ::Google::Cloud::Vision::V1::VERSION,
476
+ transports_version_send: [:rest]
477
+
478
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
479
+
480
+ options.apply_defaults timeout: @config.rpcs.async_batch_annotate_files.timeout,
481
+ metadata: call_metadata,
482
+ retry_policy: @config.rpcs.async_batch_annotate_files.retry_policy
483
+
484
+ options.apply_defaults timeout: @config.timeout,
485
+ metadata: @config.metadata,
486
+ retry_policy: @config.retry_policy
487
+
488
+ @image_annotator_stub.async_batch_annotate_files request, options do |result, operation|
489
+ result = ::Gapic::Operation.new result, @operations_client, options: options
490
+ yield result, operation if block_given?
491
+ return result
492
+ end
493
+ rescue ::Gapic::Rest::Error => e
494
+ raise ::Google::Cloud::Error.from_error(e)
495
+ end
496
+
497
+ ##
498
+ # Configuration class for the ImageAnnotator REST API.
499
+ #
500
+ # This class represents the configuration for ImageAnnotator REST,
501
+ # providing control over timeouts, retry behavior, logging, transport
502
+ # parameters, and other low-level controls. Certain parameters can also be
503
+ # applied individually to specific RPCs. See
504
+ # {::Google::Cloud::Vision::V1::ImageAnnotator::Rest::Client::Configuration::Rpcs}
505
+ # for a list of RPCs that can be configured independently.
506
+ #
507
+ # Configuration can be applied globally to all clients, or to a single client
508
+ # on construction.
509
+ #
510
+ # @example
511
+ #
512
+ # # Modify the global config, setting the timeout for
513
+ # # batch_annotate_images to 20 seconds,
514
+ # # and all remaining timeouts to 10 seconds.
515
+ # ::Google::Cloud::Vision::V1::ImageAnnotator::Rest::Client.configure do |config|
516
+ # config.timeout = 10.0
517
+ # config.rpcs.batch_annotate_images.timeout = 20.0
518
+ # end
519
+ #
520
+ # # Apply the above configuration only to a new client.
521
+ # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Rest::Client.new do |config|
522
+ # config.timeout = 10.0
523
+ # config.rpcs.batch_annotate_images.timeout = 20.0
524
+ # end
525
+ #
526
+ # @!attribute [rw] endpoint
527
+ # The hostname or hostname:port of the service endpoint.
528
+ # Defaults to `"vision.googleapis.com"`.
529
+ # @return [::String]
530
+ # @!attribute [rw] credentials
531
+ # Credentials to send with calls. You may provide any of the following types:
532
+ # * (`String`) The path to a service account key file in JSON format
533
+ # * (`Hash`) A service account key as a Hash
534
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
535
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
536
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
537
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
538
+ # * (`nil`) indicating no credentials
539
+ # @return [::Object]
540
+ # @!attribute [rw] scope
541
+ # The OAuth scopes
542
+ # @return [::Array<::String>]
543
+ # @!attribute [rw] lib_name
544
+ # The library name as recorded in instrumentation and logging
545
+ # @return [::String]
546
+ # @!attribute [rw] lib_version
547
+ # The library version as recorded in instrumentation and logging
548
+ # @return [::String]
549
+ # @!attribute [rw] timeout
550
+ # The call timeout in seconds.
551
+ # @return [::Numeric]
552
+ # @!attribute [rw] metadata
553
+ # Additional headers to be sent with the call.
554
+ # @return [::Hash{::Symbol=>::String}]
555
+ # @!attribute [rw] retry_policy
556
+ # The retry policy. The value is a hash with the following keys:
557
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
558
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
559
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
560
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
561
+ # trigger a retry.
562
+ # @return [::Hash]
563
+ # @!attribute [rw] quota_project
564
+ # A separate project against which to charge quota.
565
+ # @return [::String]
566
+ #
567
+ class Configuration
568
+ extend ::Gapic::Config
569
+
570
+ config_attr :endpoint, "vision.googleapis.com", ::String
571
+ config_attr :credentials, nil do |value|
572
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
573
+ allowed.any? { |klass| klass === value }
574
+ end
575
+ config_attr :scope, nil, ::String, ::Array, nil
576
+ config_attr :lib_name, nil, ::String, nil
577
+ config_attr :lib_version, nil, ::String, nil
578
+ config_attr :timeout, nil, ::Numeric, nil
579
+ config_attr :metadata, nil, ::Hash, nil
580
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
581
+ config_attr :quota_project, nil, ::String, nil
582
+
583
+ # @private
584
+ def initialize parent_config = nil
585
+ @parent_config = parent_config unless parent_config.nil?
586
+
587
+ yield self if block_given?
588
+ end
589
+
590
+ ##
591
+ # Configurations for individual RPCs
592
+ # @return [Rpcs]
593
+ #
594
+ def rpcs
595
+ @rpcs ||= begin
596
+ parent_rpcs = nil
597
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
598
+ Rpcs.new parent_rpcs
599
+ end
600
+ end
601
+
602
+ ##
603
+ # Configuration RPC class for the ImageAnnotator API.
604
+ #
605
+ # Includes fields providing the configuration for each RPC in this service.
606
+ # Each configuration object is of type `Gapic::Config::Method` and includes
607
+ # the following configuration fields:
608
+ #
609
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
610
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
611
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
612
+ # include the following keys:
613
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
614
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
615
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
616
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
617
+ # trigger a retry.
618
+ #
619
+ class Rpcs
620
+ ##
621
+ # RPC-specific configuration for `batch_annotate_images`
622
+ # @return [::Gapic::Config::Method]
623
+ #
624
+ attr_reader :batch_annotate_images
625
+ ##
626
+ # RPC-specific configuration for `batch_annotate_files`
627
+ # @return [::Gapic::Config::Method]
628
+ #
629
+ attr_reader :batch_annotate_files
630
+ ##
631
+ # RPC-specific configuration for `async_batch_annotate_images`
632
+ # @return [::Gapic::Config::Method]
633
+ #
634
+ attr_reader :async_batch_annotate_images
635
+ ##
636
+ # RPC-specific configuration for `async_batch_annotate_files`
637
+ # @return [::Gapic::Config::Method]
638
+ #
639
+ attr_reader :async_batch_annotate_files
640
+
641
+ # @private
642
+ def initialize parent_rpcs = nil
643
+ batch_annotate_images_config = parent_rpcs.batch_annotate_images if parent_rpcs.respond_to? :batch_annotate_images
644
+ @batch_annotate_images = ::Gapic::Config::Method.new batch_annotate_images_config
645
+ batch_annotate_files_config = parent_rpcs.batch_annotate_files if parent_rpcs.respond_to? :batch_annotate_files
646
+ @batch_annotate_files = ::Gapic::Config::Method.new batch_annotate_files_config
647
+ async_batch_annotate_images_config = parent_rpcs.async_batch_annotate_images if parent_rpcs.respond_to? :async_batch_annotate_images
648
+ @async_batch_annotate_images = ::Gapic::Config::Method.new async_batch_annotate_images_config
649
+ async_batch_annotate_files_config = parent_rpcs.async_batch_annotate_files if parent_rpcs.respond_to? :async_batch_annotate_files
650
+ @async_batch_annotate_files = ::Gapic::Config::Method.new async_batch_annotate_files_config
651
+
652
+ yield self if block_given?
653
+ end
654
+ end
655
+ end
656
+ end
657
+ end
658
+ end
659
+ end
660
+ end
661
+ end
662
+ end