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