google-cloud-vision 0.37.1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/AUTHENTICATION.md +51 -59
  4. data/LICENSE.md +203 -0
  5. data/MIGRATING.md +343 -0
  6. data/README.md +35 -49
  7. data/lib/{google/cloud/vision/v1/doc/google/protobuf/wrappers.rb → google-cloud-vision.rb} +5 -12
  8. data/lib/google/cloud/vision.rb +132 -215
  9. data/lib/google/cloud/vision/version.rb +6 -2
  10. metadata +74 -102
  11. data/LICENSE +0 -201
  12. data/lib/google/cloud/vision/v1.rb +0 -249
  13. data/lib/google/cloud/vision/v1/credentials.rb +0 -42
  14. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/geometry.rb +0 -66
  15. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/image_annotator.rb +0 -923
  16. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/product_search.rb +0 -115
  17. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/product_search_service.rb +0 -569
  18. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/text_annotation.rb +0 -254
  19. data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/web_detection.rb +0 -102
  20. data/lib/google/cloud/vision/v1/doc/google/longrunning/operations.rb +0 -51
  21. data/lib/google/cloud/vision/v1/doc/google/protobuf/any.rb +0 -131
  22. data/lib/google/cloud/vision/v1/doc/google/protobuf/empty.rb +0 -29
  23. data/lib/google/cloud/vision/v1/doc/google/protobuf/field_mask.rb +0 -222
  24. data/lib/google/cloud/vision/v1/doc/google/protobuf/timestamp.rb +0 -113
  25. data/lib/google/cloud/vision/v1/doc/google/rpc/status.rb +0 -87
  26. data/lib/google/cloud/vision/v1/doc/google/type/color.rb +0 -161
  27. data/lib/google/cloud/vision/v1/doc/google/type/latlng.rb +0 -31
  28. data/lib/google/cloud/vision/v1/geometry_pb.rb +0 -39
  29. data/lib/google/cloud/vision/v1/helpers.rb +0 -1154
  30. data/lib/google/cloud/vision/v1/image_annotator_client.rb +0 -516
  31. data/lib/google/cloud/vision/v1/image_annotator_client_config.json +0 -46
  32. data/lib/google/cloud/vision/v1/image_annotator_pb.rb +0 -344
  33. data/lib/google/cloud/vision/v1/image_annotator_services_pb.rb +0 -74
  34. data/lib/google/cloud/vision/v1/product_search_client.rb +0 -1490
  35. data/lib/google/cloud/vision/v1/product_search_client_config.json +0 -121
  36. data/lib/google/cloud/vision/v1/product_search_pb.rb +0 -54
  37. data/lib/google/cloud/vision/v1/product_search_service_pb.rb +0 -207
  38. data/lib/google/cloud/vision/v1/product_search_service_services_pb.rb +0 -233
  39. data/lib/google/cloud/vision/v1/text_annotation_pb.rb +0 -94
  40. data/lib/google/cloud/vision/v1/web_detection_pb.rb +0 -51
  41. data/lib/google/cloud/vision/v1p3beta1.rb +0 -253
  42. data/lib/google/cloud/vision/v1p3beta1/credentials.rb +0 -42
  43. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/geometry.rb +0 -72
  44. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/image_annotator.rb +0 -763
  45. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/product_search.rb +0 -156
  46. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/product_search_service.rb +0 -538
  47. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/text_annotation.rb +0 -255
  48. data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/web_detection.rb +0 -101
  49. data/lib/google/cloud/vision/v1p3beta1/doc/google/longrunning/operations.rb +0 -51
  50. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/any.rb +0 -131
  51. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/empty.rb +0 -29
  52. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/field_mask.rb +0 -222
  53. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/timestamp.rb +0 -113
  54. data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/wrappers.rb +0 -26
  55. data/lib/google/cloud/vision/v1p3beta1/doc/google/rpc/status.rb +0 -87
  56. data/lib/google/cloud/vision/v1p3beta1/doc/google/type/color.rb +0 -161
  57. data/lib/google/cloud/vision/v1p3beta1/doc/google/type/latlng.rb +0 -31
  58. data/lib/google/cloud/vision/v1p3beta1/geometry_pb.rb +0 -43
  59. data/lib/google/cloud/vision/v1p3beta1/helpers.rb +0 -1154
  60. data/lib/google/cloud/vision/v1p3beta1/image_annotator_client.rb +0 -312
  61. data/lib/google/cloud/vision/v1p3beta1/image_annotator_client_config.json +0 -36
  62. data/lib/google/cloud/vision/v1p3beta1/image_annotator_pb.rb +0 -304
  63. data/lib/google/cloud/vision/v1p3beta1/image_annotator_services_pb.rb +0 -55
  64. data/lib/google/cloud/vision/v1p3beta1/product_search_client.rb +0 -1419
  65. data/lib/google/cloud/vision/v1p3beta1/product_search_client_config.json +0 -116
  66. data/lib/google/cloud/vision/v1p3beta1/product_search_pb.rb +0 -64
  67. data/lib/google/cloud/vision/v1p3beta1/product_search_service_pb.rb +0 -191
  68. data/lib/google/cloud/vision/v1p3beta1/product_search_service_services_pb.rb +0 -226
  69. data/lib/google/cloud/vision/v1p3beta1/text_annotation_pb.rb +0 -94
  70. data/lib/google/cloud/vision/v1p3beta1/web_detection_pb.rb +0 -51
@@ -1,516 +0,0 @@
1
- # Copyright 2019 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
- # EDITING INSTRUCTIONS
16
- # This file was generated from the file
17
- # https://github.com/googleapis/googleapis/blob/master/google/cloud/vision/v1/image_annotator.proto,
18
- # and updates to that file get reflected here through a refresh process.
19
- # For the short term, the refresh process will only be runnable by Google
20
- # engineers.
21
-
22
-
23
- require "json"
24
- require "pathname"
25
-
26
- require "google/gax"
27
- require "google/gax/operation"
28
- require "google/longrunning/operations_client"
29
-
30
- require "google/cloud/vision/v1/image_annotator_pb"
31
- require "google/cloud/vision/v1/credentials"
32
- require "google/cloud/vision/version"
33
-
34
- module Google
35
- module Cloud
36
- module Vision
37
- module V1
38
- # Service that performs Google Cloud Vision API detection tasks over client
39
- # images, such as face, landmark, logo, label, and text detection. The
40
- # ImageAnnotator service returns detected entities from the images.
41
- #
42
- # @!attribute [r] image_annotator_stub
43
- # @return [Google::Cloud::Vision::V1::ImageAnnotator::Stub]
44
- class ImageAnnotatorClient
45
- # @private
46
- attr_reader :image_annotator_stub
47
-
48
- # The default address of the service.
49
- SERVICE_ADDRESS = "vision.googleapis.com".freeze
50
-
51
- # The default port of the service.
52
- DEFAULT_SERVICE_PORT = 443
53
-
54
- # The default set of gRPC interceptors.
55
- GRPC_INTERCEPTORS = []
56
-
57
- DEFAULT_TIMEOUT = 30
58
-
59
- # The scopes needed to make gRPC calls to all of the methods defined in
60
- # this service.
61
- ALL_SCOPES = [
62
- "https://www.googleapis.com/auth/cloud-platform",
63
- "https://www.googleapis.com/auth/cloud-vision"
64
- ].freeze
65
-
66
- # @private
67
- class OperationsClient < Google::Longrunning::OperationsClient
68
- self::SERVICE_ADDRESS = ImageAnnotatorClient::SERVICE_ADDRESS
69
- self::GRPC_INTERCEPTORS = ImageAnnotatorClient::GRPC_INTERCEPTORS
70
- end
71
-
72
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
73
- # Provides the means for authenticating requests made by the client. This parameter can
74
- # be many types.
75
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
76
- # authenticating requests made by this client.
77
- # A `String` will be treated as the path to the keyfile to be used for the construction of
78
- # credentials for this client.
79
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
80
- # credentials for this client.
81
- # A `GRPC::Core::Channel` will be used to make calls through.
82
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
83
- # should already be composed with a `GRPC::Core::CallCredentials` object.
84
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
85
- # metadata for requests, generally, to give OAuth credentials.
86
- # @param scopes [Array<String>]
87
- # The OAuth scopes for this service. This parameter is ignored if
88
- # an updater_proc is supplied.
89
- # @param client_config [Hash]
90
- # A Hash for call options for each method. See
91
- # Google::Gax#construct_settings for the structure of
92
- # this data. Falls back to the default config if not specified
93
- # or the specified config is missing data points.
94
- # @param timeout [Numeric]
95
- # The default timeout, in seconds, for calls made through this client.
96
- # @param metadata [Hash]
97
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
98
- # @param service_address [String]
99
- # Override for the service hostname, or `nil` to leave as the default.
100
- # @param service_port [Integer]
101
- # Override for the service port, or `nil` to leave as the default.
102
- # @param exception_transformer [Proc]
103
- # An optional proc that intercepts any exceptions raised during an API call to inject
104
- # custom error handling.
105
- def initialize \
106
- credentials: nil,
107
- scopes: ALL_SCOPES,
108
- client_config: {},
109
- timeout: DEFAULT_TIMEOUT,
110
- metadata: nil,
111
- service_address: nil,
112
- service_port: nil,
113
- exception_transformer: nil,
114
- lib_name: nil,
115
- lib_version: ""
116
- # These require statements are intentionally placed here to initialize
117
- # the gRPC module only when it's required.
118
- # See https://github.com/googleapis/toolkit/issues/446
119
- require "google/gax/grpc"
120
- require "google/cloud/vision/v1/image_annotator_services_pb"
121
-
122
- credentials ||= Google::Cloud::Vision::V1::Credentials.default
123
-
124
- @operations_client = OperationsClient.new(
125
- credentials: credentials,
126
- scopes: scopes,
127
- client_config: client_config,
128
- timeout: timeout,
129
- lib_name: lib_name,
130
- service_address: service_address,
131
- service_port: service_port,
132
- lib_version: lib_version,
133
- metadata: metadata,
134
- )
135
-
136
- if credentials.is_a?(String) || credentials.is_a?(Hash)
137
- updater_proc = Google::Cloud::Vision::V1::Credentials.new(credentials).updater_proc
138
- end
139
- if credentials.is_a?(GRPC::Core::Channel)
140
- channel = credentials
141
- end
142
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
143
- chan_creds = credentials
144
- end
145
- if credentials.is_a?(Proc)
146
- updater_proc = credentials
147
- end
148
- if credentials.is_a?(Google::Auth::Credentials)
149
- updater_proc = credentials.updater_proc
150
- end
151
-
152
- package_version = Google::Cloud::Vision::VERSION
153
-
154
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
155
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
156
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
157
- google_api_client << " grpc/#{GRPC::VERSION}"
158
- google_api_client.freeze
159
-
160
- headers = { :"x-goog-api-client" => google_api_client }
161
- headers.merge!(metadata) unless metadata.nil?
162
- client_config_file = Pathname.new(__dir__).join(
163
- "image_annotator_client_config.json"
164
- )
165
- defaults = client_config_file.open do |f|
166
- Google::Gax.construct_settings(
167
- "google.cloud.vision.v1.ImageAnnotator",
168
- JSON.parse(f.read),
169
- client_config,
170
- Google::Gax::Grpc::STATUS_CODE_NAMES,
171
- timeout,
172
- errors: Google::Gax::Grpc::API_ERRORS,
173
- metadata: headers
174
- )
175
- end
176
-
177
- # Allow overriding the service path/port in subclasses.
178
- service_path = service_address || self.class::SERVICE_ADDRESS
179
- port = service_port || self.class::DEFAULT_SERVICE_PORT
180
- interceptors = self.class::GRPC_INTERCEPTORS
181
- @image_annotator_stub = Google::Gax::Grpc.create_stub(
182
- service_path,
183
- port,
184
- chan_creds: chan_creds,
185
- channel: channel,
186
- updater_proc: updater_proc,
187
- scopes: scopes,
188
- interceptors: interceptors,
189
- &Google::Cloud::Vision::V1::ImageAnnotator::Stub.method(:new)
190
- )
191
-
192
- @batch_annotate_images = Google::Gax.create_api_call(
193
- @image_annotator_stub.method(:batch_annotate_images),
194
- defaults["batch_annotate_images"],
195
- exception_transformer: exception_transformer,
196
- params_extractor: proc do |request|
197
- {'parent' => request.parent}
198
- end
199
- )
200
- @batch_annotate_files = Google::Gax.create_api_call(
201
- @image_annotator_stub.method(:batch_annotate_files),
202
- defaults["batch_annotate_files"],
203
- exception_transformer: exception_transformer,
204
- params_extractor: proc do |request|
205
- {'parent' => request.parent}
206
- end
207
- )
208
- @async_batch_annotate_images = Google::Gax.create_api_call(
209
- @image_annotator_stub.method(:async_batch_annotate_images),
210
- defaults["async_batch_annotate_images"],
211
- exception_transformer: exception_transformer,
212
- params_extractor: proc do |request|
213
- {'parent' => request.parent}
214
- end
215
- )
216
- @async_batch_annotate_files = Google::Gax.create_api_call(
217
- @image_annotator_stub.method(:async_batch_annotate_files),
218
- defaults["async_batch_annotate_files"],
219
- exception_transformer: exception_transformer,
220
- params_extractor: proc do |request|
221
- {'parent' => request.parent}
222
- end
223
- )
224
- end
225
-
226
- # Service calls
227
-
228
- # Run image detection and annotation for a batch of images.
229
- #
230
- # @param requests [Array<Google::Cloud::Vision::V1::AnnotateImageRequest | Hash>]
231
- # Required. Individual image annotation requests for this batch.
232
- # A hash of the same form as `Google::Cloud::Vision::V1::AnnotateImageRequest`
233
- # can also be provided.
234
- # @param parent [String]
235
- # Optional. Target project and location to make a call.
236
- #
237
- # Format: `projects/{project-id}/locations/{location-id}`.
238
- #
239
- # If no parent is specified, a region will be chosen automatically.
240
- #
241
- # Supported location-ids:
242
- # `us`: USA country only,
243
- # `asia`: East asia areas, like Japan, Taiwan,
244
- # `eu`: The European Union.
245
- #
246
- # Example: `projects/project-A/locations/eu`.
247
- # @param options [Google::Gax::CallOptions]
248
- # Overrides the default settings for this call, e.g, timeout,
249
- # retries, etc.
250
- # @yield [result, operation] Access the result along with the RPC operation
251
- # @yieldparam result [Google::Cloud::Vision::V1::BatchAnnotateImagesResponse]
252
- # @yieldparam operation [GRPC::ActiveCall::Operation]
253
- # @return [Google::Cloud::Vision::V1::BatchAnnotateImagesResponse]
254
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
255
- # @example
256
- # require "google/cloud/vision"
257
- #
258
- # image_annotator_client = Google::Cloud::Vision::ImageAnnotator.new(version: :v1)
259
- #
260
- # # TODO: Initialize `requests`:
261
- # requests = []
262
- # response = image_annotator_client.batch_annotate_images(requests)
263
-
264
- def batch_annotate_images \
265
- requests,
266
- parent: nil,
267
- options: nil,
268
- &block
269
- req = {
270
- requests: requests,
271
- parent: parent
272
- }.delete_if { |_, v| v.nil? }
273
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::BatchAnnotateImagesRequest)
274
- @batch_annotate_images.call(req, options, &block)
275
- end
276
-
277
- # Service that performs image detection and annotation for a batch of files.
278
- # Now only "application/pdf", "image/tiff" and "image/gif" are supported.
279
- #
280
- # This service will extract at most 5 (customers can specify which 5 in
281
- # AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each
282
- # file provided and perform detection and annotation for each image
283
- # extracted.
284
- #
285
- # @param requests [Array<Google::Cloud::Vision::V1::AnnotateFileRequest | Hash>]
286
- # Required. The list of file annotation requests. Right now we support only one
287
- # AnnotateFileRequest in BatchAnnotateFilesRequest.
288
- # A hash of the same form as `Google::Cloud::Vision::V1::AnnotateFileRequest`
289
- # can also be provided.
290
- # @param parent [String]
291
- # Optional. Target project and location to make a call.
292
- #
293
- # Format: `projects/{project-id}/locations/{location-id}`.
294
- #
295
- # If no parent is specified, a region will be chosen automatically.
296
- #
297
- # Supported location-ids:
298
- # `us`: USA country only,
299
- # `asia`: East asia areas, like Japan, Taiwan,
300
- # `eu`: The European Union.
301
- #
302
- # Example: `projects/project-A/locations/eu`.
303
- # @param options [Google::Gax::CallOptions]
304
- # Overrides the default settings for this call, e.g, timeout,
305
- # retries, etc.
306
- # @yield [result, operation] Access the result along with the RPC operation
307
- # @yieldparam result [Google::Cloud::Vision::V1::BatchAnnotateFilesResponse]
308
- # @yieldparam operation [GRPC::ActiveCall::Operation]
309
- # @return [Google::Cloud::Vision::V1::BatchAnnotateFilesResponse]
310
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
311
- # @example
312
- # require "google/cloud/vision"
313
- #
314
- # image_annotator_client = Google::Cloud::Vision::ImageAnnotator.new(version: :v1)
315
- #
316
- # # TODO: Initialize `requests`:
317
- # requests = []
318
- # response = image_annotator_client.batch_annotate_files(requests)
319
-
320
- def batch_annotate_files \
321
- requests,
322
- parent: nil,
323
- options: nil,
324
- &block
325
- req = {
326
- requests: requests,
327
- parent: parent
328
- }.delete_if { |_, v| v.nil? }
329
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::BatchAnnotateFilesRequest)
330
- @batch_annotate_files.call(req, options, &block)
331
- end
332
-
333
- # Run asynchronous image detection and annotation for a list of images.
334
- #
335
- # Progress and results can be retrieved through the
336
- # `google.longrunning.Operations` interface.
337
- # `Operation.metadata` contains `OperationMetadata` (metadata).
338
- # `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results).
339
- #
340
- # This service will write image annotation outputs to json files in customer
341
- # GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
342
- #
343
- # @param requests [Array<Google::Cloud::Vision::V1::AnnotateImageRequest | Hash>]
344
- # Required. Individual image annotation requests for this batch.
345
- # A hash of the same form as `Google::Cloud::Vision::V1::AnnotateImageRequest`
346
- # can also be provided.
347
- # @param output_config [Google::Cloud::Vision::V1::OutputConfig | Hash]
348
- # Required. The desired output location and metadata (e.g. format).
349
- # A hash of the same form as `Google::Cloud::Vision::V1::OutputConfig`
350
- # can also be provided.
351
- # @param parent [String]
352
- # Optional. Target project and location to make a call.
353
- #
354
- # Format: `projects/{project-id}/locations/{location-id}`.
355
- #
356
- # If no parent is specified, a region will be chosen automatically.
357
- #
358
- # Supported location-ids:
359
- # `us`: USA country only,
360
- # `asia`: East asia areas, like Japan, Taiwan,
361
- # `eu`: The European Union.
362
- #
363
- # Example: `projects/project-A/locations/eu`.
364
- # @param options [Google::Gax::CallOptions]
365
- # Overrides the default settings for this call, e.g, timeout,
366
- # retries, etc.
367
- # @return [Google::Gax::Operation]
368
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
369
- # @example
370
- # require "google/cloud/vision"
371
- #
372
- # image_annotator_client = Google::Cloud::Vision::ImageAnnotator.new(version: :v1)
373
- #
374
- # # TODO: Initialize `requests`:
375
- # requests = []
376
- #
377
- # # TODO: Initialize `output_config`:
378
- # output_config = {}
379
- #
380
- # # Register a callback during the method call.
381
- # operation = image_annotator_client.async_batch_annotate_images(requests, output_config) do |op|
382
- # raise op.results.message if op.error?
383
- # op_results = op.results
384
- # # Process the results.
385
- #
386
- # metadata = op.metadata
387
- # # Process the metadata.
388
- # end
389
- #
390
- # # Or use the return value to register a callback.
391
- # operation.on_done do |op|
392
- # raise op.results.message if op.error?
393
- # op_results = op.results
394
- # # Process the results.
395
- #
396
- # metadata = op.metadata
397
- # # Process the metadata.
398
- # end
399
- #
400
- # # Manually reload the operation.
401
- # operation.reload!
402
- #
403
- # # Or block until the operation completes, triggering callbacks on
404
- # # completion.
405
- # operation.wait_until_done!
406
-
407
- def async_batch_annotate_images \
408
- requests,
409
- output_config,
410
- parent: nil,
411
- options: nil
412
- req = {
413
- requests: requests,
414
- output_config: output_config,
415
- parent: parent
416
- }.delete_if { |_, v| v.nil? }
417
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::AsyncBatchAnnotateImagesRequest)
418
- operation = Google::Gax::Operation.new(
419
- @async_batch_annotate_images.call(req, options),
420
- @operations_client,
421
- Google::Cloud::Vision::V1::AsyncBatchAnnotateImagesResponse,
422
- Google::Cloud::Vision::V1::OperationMetadata,
423
- call_options: options
424
- )
425
- operation.on_done { |operation| yield(operation) } if block_given?
426
- operation
427
- end
428
-
429
- # Run asynchronous image detection and annotation for a list of generic
430
- # files, such as PDF files, which may contain multiple pages and multiple
431
- # images per page. Progress and results can be retrieved through the
432
- # `google.longrunning.Operations` interface.
433
- # `Operation.metadata` contains `OperationMetadata` (metadata).
434
- # `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
435
- #
436
- # @param requests [Array<Google::Cloud::Vision::V1::AsyncAnnotateFileRequest | Hash>]
437
- # Required. Individual async file annotation requests for this batch.
438
- # A hash of the same form as `Google::Cloud::Vision::V1::AsyncAnnotateFileRequest`
439
- # can also be provided.
440
- # @param parent [String]
441
- # Optional. Target project and location to make a call.
442
- #
443
- # Format: `projects/{project-id}/locations/{location-id}`.
444
- #
445
- # If no parent is specified, a region will be chosen automatically.
446
- #
447
- # Supported location-ids:
448
- # `us`: USA country only,
449
- # `asia`: East asia areas, like Japan, Taiwan,
450
- # `eu`: The European Union.
451
- #
452
- # Example: `projects/project-A/locations/eu`.
453
- # @param options [Google::Gax::CallOptions]
454
- # Overrides the default settings for this call, e.g, timeout,
455
- # retries, etc.
456
- # @return [Google::Gax::Operation]
457
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
458
- # @example
459
- # require "google/cloud/vision"
460
- #
461
- # image_annotator_client = Google::Cloud::Vision::ImageAnnotator.new(version: :v1)
462
- #
463
- # # TODO: Initialize `requests`:
464
- # requests = []
465
- #
466
- # # Register a callback during the method call.
467
- # operation = image_annotator_client.async_batch_annotate_files(requests) do |op|
468
- # raise op.results.message if op.error?
469
- # op_results = op.results
470
- # # Process the results.
471
- #
472
- # metadata = op.metadata
473
- # # Process the metadata.
474
- # end
475
- #
476
- # # Or use the return value to register a callback.
477
- # operation.on_done do |op|
478
- # raise op.results.message if op.error?
479
- # op_results = op.results
480
- # # Process the results.
481
- #
482
- # metadata = op.metadata
483
- # # Process the metadata.
484
- # end
485
- #
486
- # # Manually reload the operation.
487
- # operation.reload!
488
- #
489
- # # Or block until the operation completes, triggering callbacks on
490
- # # completion.
491
- # operation.wait_until_done!
492
-
493
- def async_batch_annotate_files \
494
- requests,
495
- parent: nil,
496
- options: nil
497
- req = {
498
- requests: requests,
499
- parent: parent
500
- }.delete_if { |_, v| v.nil? }
501
- req = Google::Gax::to_proto(req, Google::Cloud::Vision::V1::AsyncBatchAnnotateFilesRequest)
502
- operation = Google::Gax::Operation.new(
503
- @async_batch_annotate_files.call(req, options),
504
- @operations_client,
505
- Google::Cloud::Vision::V1::AsyncBatchAnnotateFilesResponse,
506
- Google::Cloud::Vision::V1::OperationMetadata,
507
- call_options: options
508
- )
509
- operation.on_done { |operation| yield(operation) } if block_given?
510
- operation
511
- end
512
- end
513
- end
514
- end
515
- end
516
- end