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