google-cloud-vision-v1p3beta1 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 +203 -0
- data/README.md +24 -0
- data/lib/google-cloud-vision-v1p3beta1.rb +1 -0
- data/lib/google/cloud/common_resources_pb.rb +15 -0
- data/lib/google/cloud/vision/v1p3beta1.rb +20 -0
- data/lib/google/cloud/vision/v1p3beta1/geometry_pb.rb +44 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator.rb +21 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator/client.rb +462 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator/credentials.rb +52 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator/helpers.rb +1228 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator/operations.rb +558 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator/paths.rb +52 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator_pb.rb +307 -0
- data/lib/google/cloud/vision/v1p3beta1/image_annotator_services_pb.rb +55 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search.rb +21 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search/client.rb +2033 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search/credentials.rb +52 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search/operations.rb +558 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search/paths.rb +109 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search_pb.rb +66 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search_service_pb.rb +195 -0
- data/lib/google/cloud/vision/v1p3beta1/product_search_service_services_pb.rb +222 -0
- data/lib/google/cloud/vision/v1p3beta1/text_annotation_pb.rb +95 -0
- data/lib/google/cloud/vision/v1p3beta1/version.rb +28 -0
- data/lib/google/cloud/vision/v1p3beta1/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/v1p3beta1/geometry.rb +91 -0
- data/proto_docs/google/cloud/vision/v1p3beta1/image_annotator.rb +869 -0
- data/proto_docs/google/cloud/vision/v1p3beta1/product_search.rb +172 -0
- data/proto_docs/google/cloud/vision/v1p3beta1/product_search_service.rb +630 -0
- data/proto_docs/google/cloud/vision/v1p3beta1/text_annotation.rb +286 -0
- data/proto_docs/google/cloud/vision/v1p3beta1/web_detection.rb +120 -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,44 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: google/cloud/vision/v1p3beta1/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/v1p3beta1/geometry.proto", :syntax => :proto3) do
|
9
|
+
add_message "google.cloud.vision.v1p3beta1.Vertex" do
|
10
|
+
optional :x, :int32, 1
|
11
|
+
optional :y, :int32, 2
|
12
|
+
end
|
13
|
+
add_message "google.cloud.vision.v1p3beta1.NormalizedVertex" do
|
14
|
+
optional :x, :float, 1
|
15
|
+
optional :y, :float, 2
|
16
|
+
end
|
17
|
+
add_message "google.cloud.vision.v1p3beta1.BoundingPoly" do
|
18
|
+
repeated :vertices, :message, 1, "google.cloud.vision.v1p3beta1.Vertex"
|
19
|
+
repeated :normalized_vertices, :message, 2, "google.cloud.vision.v1p3beta1.NormalizedVertex"
|
20
|
+
end
|
21
|
+
add_message "google.cloud.vision.v1p3beta1.NormalizedBoundingPoly" do
|
22
|
+
repeated :vertices, :message, 1, "google.cloud.vision.v1p3beta1.NormalizedVertex"
|
23
|
+
end
|
24
|
+
add_message "google.cloud.vision.v1p3beta1.Position" do
|
25
|
+
optional :x, :float, 1
|
26
|
+
optional :y, :float, 2
|
27
|
+
optional :z, :float, 3
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
module Google
|
33
|
+
module Cloud
|
34
|
+
module Vision
|
35
|
+
module V1p3beta1
|
36
|
+
Vertex = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.vision.v1p3beta1.Vertex").msgclass
|
37
|
+
NormalizedVertex = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.vision.v1p3beta1.NormalizedVertex").msgclass
|
38
|
+
BoundingPoly = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.vision.v1p3beta1.BoundingPoly").msgclass
|
39
|
+
NormalizedBoundingPoly = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.vision.v1p3beta1.NormalizedBoundingPoly").msgclass
|
40
|
+
Position = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.vision.v1p3beta1.Position").msgclass
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
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/v1p3beta1/image_annotator/client"
|
20
|
+
require "google/cloud/vision/v1p3beta1/image_annotator/operations"
|
21
|
+
require "google/cloud/vision/v1p3beta1/image_annotator/credentials"
|
@@ -0,0 +1,462 @@
|
|
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/v1p3beta1/version"
|
25
|
+
require "google/cloud/vision/v1p3beta1/image_annotator_pb"
|
26
|
+
require "google/cloud/vision/v1p3beta1/image_annotator/credentials"
|
27
|
+
require "google/cloud/vision/v1p3beta1/image_annotator/paths"
|
28
|
+
require "google/cloud/vision/v1p3beta1/image_annotator/operations"
|
29
|
+
|
30
|
+
module Google
|
31
|
+
module Cloud
|
32
|
+
module Vision
|
33
|
+
module V1p3beta1
|
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::V1p3beta1::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::V1p3beta1::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", "V1p3beta1"]
|
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: ["UNAVAILABLE", "DEADLINE_EXCEEDED"]
|
84
|
+
}
|
85
|
+
|
86
|
+
default_config.rpcs.async_batch_annotate_files.timeout = 600.0
|
87
|
+
default_config.rpcs.async_batch_annotate_files.retry_policy = {
|
88
|
+
initial_delay: 0.1,
|
89
|
+
max_delay: 60.0,
|
90
|
+
multiplier: 1.3,
|
91
|
+
retry_codes: []
|
92
|
+
}
|
93
|
+
|
94
|
+
default_config
|
95
|
+
end
|
96
|
+
yield @configure if block_given?
|
97
|
+
@configure
|
98
|
+
end
|
99
|
+
|
100
|
+
##
|
101
|
+
# Configure the ImageAnnotator Client instance.
|
102
|
+
#
|
103
|
+
# The configuration is set to the derived mode, meaning that values can be changed,
|
104
|
+
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
|
105
|
+
# should be made on {Client.configure}.
|
106
|
+
#
|
107
|
+
# See {Google::Cloud::Vision::V1p3beta1::ImageAnnotator::Client::Configuration}
|
108
|
+
# for a description of the configuration fields.
|
109
|
+
#
|
110
|
+
# @yield [config] Configure the Client client.
|
111
|
+
# @yieldparam config [Client::Configuration]
|
112
|
+
#
|
113
|
+
# @return [Client::Configuration]
|
114
|
+
#
|
115
|
+
def configure
|
116
|
+
yield @config if block_given?
|
117
|
+
@config
|
118
|
+
end
|
119
|
+
|
120
|
+
##
|
121
|
+
# Create a new ImageAnnotator client object.
|
122
|
+
#
|
123
|
+
# ## Examples
|
124
|
+
#
|
125
|
+
# To create a new ImageAnnotator client with the default
|
126
|
+
# configuration:
|
127
|
+
#
|
128
|
+
# client = Google::Cloud::Vision::V1p3beta1::ImageAnnotator::Client.new
|
129
|
+
#
|
130
|
+
# To create a new ImageAnnotator client with a custom
|
131
|
+
# configuration:
|
132
|
+
#
|
133
|
+
# client = Google::Cloud::Vision::V1p3beta1::ImageAnnotator::Client.new do |config|
|
134
|
+
# config.timeout = 10_000
|
135
|
+
# end
|
136
|
+
#
|
137
|
+
# @yield [config] Configure the ImageAnnotator client.
|
138
|
+
# @yieldparam config [Client::Configuration]
|
139
|
+
#
|
140
|
+
def initialize
|
141
|
+
# These require statements are intentionally placed here to initialize
|
142
|
+
# the gRPC module only when it's required.
|
143
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
144
|
+
require "gapic/grpc"
|
145
|
+
require "google/cloud/vision/v1p3beta1/image_annotator_services_pb"
|
146
|
+
|
147
|
+
# Create the configuration object
|
148
|
+
@config = Configuration.new Client.configure
|
149
|
+
|
150
|
+
# Yield the configuration if needed
|
151
|
+
yield @config if block_given?
|
152
|
+
|
153
|
+
# Create credentials
|
154
|
+
credentials = @config.credentials
|
155
|
+
credentials ||= Credentials.default scope: @config.scope
|
156
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
157
|
+
credentials = Credentials.new credentials, scope: @config.scope
|
158
|
+
end
|
159
|
+
@quota_project_id = credentials.respond_to?(:quota_project_id) ? credentials.quota_project_id : nil
|
160
|
+
|
161
|
+
@operations_client = Operations.new do |config|
|
162
|
+
config.credentials = credentials
|
163
|
+
end
|
164
|
+
|
165
|
+
@image_annotator_stub = Gapic::ServiceStub.new(
|
166
|
+
Google::Cloud::Vision::V1p3beta1::ImageAnnotator::Stub,
|
167
|
+
credentials: credentials,
|
168
|
+
endpoint: @config.endpoint,
|
169
|
+
channel_args: @config.channel_args,
|
170
|
+
interceptors: @config.interceptors
|
171
|
+
)
|
172
|
+
end
|
173
|
+
|
174
|
+
# Service calls
|
175
|
+
|
176
|
+
##
|
177
|
+
# Run image detection and annotation for a batch of images.
|
178
|
+
#
|
179
|
+
# @overload batch_annotate_images(request, options = nil)
|
180
|
+
# @param request [Google::Cloud::Vision::V1p3beta1::BatchAnnotateImagesRequest | Hash]
|
181
|
+
# Run image detection and annotation for a batch of images.
|
182
|
+
# @param options [Gapic::CallOptions, Hash]
|
183
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
184
|
+
#
|
185
|
+
# @overload batch_annotate_images(requests: nil)
|
186
|
+
# @param requests [Array<Google::Cloud::Vision::V1p3beta1::AnnotateImageRequest | Hash>]
|
187
|
+
# Individual image annotation requests for this batch.
|
188
|
+
#
|
189
|
+
#
|
190
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
191
|
+
# @yieldparam response [Google::Cloud::Vision::V1p3beta1::BatchAnnotateImagesResponse]
|
192
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
193
|
+
#
|
194
|
+
# @return [Google::Cloud::Vision::V1p3beta1::BatchAnnotateImagesResponse]
|
195
|
+
#
|
196
|
+
# @raise [Google::Cloud::Error] if the RPC is aborted.
|
197
|
+
#
|
198
|
+
def batch_annotate_images request, options = nil
|
199
|
+
raise ArgumentError, "request must be provided" if request.nil?
|
200
|
+
|
201
|
+
request = Gapic::Protobuf.coerce request, to: Google::Cloud::Vision::V1p3beta1::BatchAnnotateImagesRequest
|
202
|
+
|
203
|
+
# Converts hash and nil to an options object
|
204
|
+
options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
205
|
+
|
206
|
+
# Customize the options with defaults
|
207
|
+
metadata = @config.rpcs.batch_annotate_images.metadata.to_h
|
208
|
+
|
209
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
210
|
+
metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
|
211
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
212
|
+
gapic_version: ::Google::Cloud::Vision::V1p3beta1::VERSION
|
213
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
214
|
+
|
215
|
+
options.apply_defaults timeout: @config.rpcs.batch_annotate_images.timeout,
|
216
|
+
metadata: metadata,
|
217
|
+
retry_policy: @config.rpcs.batch_annotate_images.retry_policy
|
218
|
+
options.apply_defaults metadata: @config.metadata,
|
219
|
+
retry_policy: @config.retry_policy
|
220
|
+
|
221
|
+
@image_annotator_stub.call_rpc :batch_annotate_images, request, options: options do |response, operation|
|
222
|
+
yield response, operation if block_given?
|
223
|
+
return response
|
224
|
+
end
|
225
|
+
rescue GRPC::BadStatus => e
|
226
|
+
raise Google::Cloud::Error.from_error(e)
|
227
|
+
end
|
228
|
+
|
229
|
+
##
|
230
|
+
# Run asynchronous image detection and annotation for a list of generic
|
231
|
+
# files, such as PDF files, which may contain multiple pages and multiple
|
232
|
+
# images per page. Progress and results can be retrieved through the
|
233
|
+
# `google.longrunning.Operations` interface.
|
234
|
+
# `Operation.metadata` contains `OperationMetadata` (metadata).
|
235
|
+
# `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
|
236
|
+
#
|
237
|
+
# @overload async_batch_annotate_files(request, options = nil)
|
238
|
+
# @param request [Google::Cloud::Vision::V1p3beta1::AsyncBatchAnnotateFilesRequest | Hash]
|
239
|
+
# Run asynchronous image detection and annotation for a list of generic
|
240
|
+
# files, such as PDF files, which may contain multiple pages and multiple
|
241
|
+
# images per page. Progress and results can be retrieved through the
|
242
|
+
# `google.longrunning.Operations` interface.
|
243
|
+
# `Operation.metadata` contains `OperationMetadata` (metadata).
|
244
|
+
# `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
|
245
|
+
# @param options [Gapic::CallOptions, Hash]
|
246
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
247
|
+
#
|
248
|
+
# @overload async_batch_annotate_files(requests: nil)
|
249
|
+
# @param requests [Array<Google::Cloud::Vision::V1p3beta1::AsyncAnnotateFileRequest | Hash>]
|
250
|
+
# Required. Individual async file annotation requests for this batch.
|
251
|
+
#
|
252
|
+
#
|
253
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
254
|
+
# @yieldparam response [Gapic::Operation]
|
255
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
256
|
+
#
|
257
|
+
# @return [Gapic::Operation]
|
258
|
+
#
|
259
|
+
# @raise [Google::Cloud::Error] if the RPC is aborted.
|
260
|
+
#
|
261
|
+
def async_batch_annotate_files request, options = nil
|
262
|
+
raise ArgumentError, "request must be provided" if request.nil?
|
263
|
+
|
264
|
+
request = Gapic::Protobuf.coerce request, to: Google::Cloud::Vision::V1p3beta1::AsyncBatchAnnotateFilesRequest
|
265
|
+
|
266
|
+
# Converts hash and nil to an options object
|
267
|
+
options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
268
|
+
|
269
|
+
# Customize the options with defaults
|
270
|
+
metadata = @config.rpcs.async_batch_annotate_files.metadata.to_h
|
271
|
+
|
272
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
273
|
+
metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
|
274
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
275
|
+
gapic_version: ::Google::Cloud::Vision::V1p3beta1::VERSION
|
276
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
277
|
+
|
278
|
+
options.apply_defaults timeout: @config.rpcs.async_batch_annotate_files.timeout,
|
279
|
+
metadata: metadata,
|
280
|
+
retry_policy: @config.rpcs.async_batch_annotate_files.retry_policy
|
281
|
+
options.apply_defaults metadata: @config.metadata,
|
282
|
+
retry_policy: @config.retry_policy
|
283
|
+
|
284
|
+
@image_annotator_stub.call_rpc :async_batch_annotate_files, request, options: options do |response, operation|
|
285
|
+
response = Gapic::Operation.new response, @operations_client, options: options
|
286
|
+
yield response, operation if block_given?
|
287
|
+
return response
|
288
|
+
end
|
289
|
+
rescue GRPC::BadStatus => e
|
290
|
+
raise Google::Cloud::Error.from_error(e)
|
291
|
+
end
|
292
|
+
|
293
|
+
##
|
294
|
+
# Configuration class for the ImageAnnotator API.
|
295
|
+
#
|
296
|
+
# This class represents the configuration for ImageAnnotator,
|
297
|
+
# providing control over timeouts, retry behavior, logging, transport
|
298
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
299
|
+
# applied individually to specific RPCs. See
|
300
|
+
# {Google::Cloud::Vision::V1p3beta1::ImageAnnotator::Client::Configuration::Rpcs}
|
301
|
+
# for a list of RPCs that can be configured independently.
|
302
|
+
#
|
303
|
+
# Configuration can be applied globally to all clients, or to a single client
|
304
|
+
# on construction.
|
305
|
+
#
|
306
|
+
# # Examples
|
307
|
+
#
|
308
|
+
# To modify the global config, setting the timeout for batch_annotate_images
|
309
|
+
# to 20 seconds, and all remaining timeouts to 10 seconds:
|
310
|
+
#
|
311
|
+
# Google::Cloud::Vision::V1p3beta1::ImageAnnotator::Client.configure do |config|
|
312
|
+
# config.timeout = 10_000
|
313
|
+
# config.rpcs.batch_annotate_images.timeout = 20_000
|
314
|
+
# end
|
315
|
+
#
|
316
|
+
# To apply the above configuration only to a new client:
|
317
|
+
#
|
318
|
+
# client = Google::Cloud::Vision::V1p3beta1::ImageAnnotator::Client.new do |config|
|
319
|
+
# config.timeout = 10_000
|
320
|
+
# config.rpcs.batch_annotate_images.timeout = 20_000
|
321
|
+
# end
|
322
|
+
#
|
323
|
+
# @!attribute [rw] endpoint
|
324
|
+
# The hostname or hostname:port of the service endpoint.
|
325
|
+
# Defaults to `"vision.googleapis.com"`.
|
326
|
+
# @return [String]
|
327
|
+
# @!attribute [rw] credentials
|
328
|
+
# Credentials to send with calls. You may provide any of the following types:
|
329
|
+
# * (`String`) The path to a service account key file in JSON format
|
330
|
+
# * (`Hash`) A service account key as a Hash
|
331
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
332
|
+
# (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
|
333
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
334
|
+
# (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
|
335
|
+
# * (`GRPC::Core::Channel`) a gRPC channel with included credentials
|
336
|
+
# * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
|
337
|
+
# * (`nil`) indicating no credentials
|
338
|
+
# @return [Object]
|
339
|
+
# @!attribute [rw] scope
|
340
|
+
# The OAuth scopes
|
341
|
+
# @return [Array<String>]
|
342
|
+
# @!attribute [rw] lib_name
|
343
|
+
# The library name as recorded in instrumentation and logging
|
344
|
+
# @return [String]
|
345
|
+
# @!attribute [rw] lib_version
|
346
|
+
# The library version as recorded in instrumentation and logging
|
347
|
+
# @return [String]
|
348
|
+
# @!attribute [rw] channel_args
|
349
|
+
# Extra parameters passed to the gRPC channel. Note: this is ignored if a
|
350
|
+
# `GRPC::Core::Channel` object is provided as the credential.
|
351
|
+
# @return [Hash]
|
352
|
+
# @!attribute [rw] interceptors
|
353
|
+
# An array of interceptors that are run before calls are executed.
|
354
|
+
# @return [Array<GRPC::ClientInterceptor>]
|
355
|
+
# @!attribute [rw] timeout
|
356
|
+
# The call timeout in milliseconds.
|
357
|
+
# @return [Numeric]
|
358
|
+
# @!attribute [rw] metadata
|
359
|
+
# Additional gRPC headers to be sent with the call.
|
360
|
+
# @return [Hash{Symbol=>String}]
|
361
|
+
# @!attribute [rw] retry_policy
|
362
|
+
# The retry policy. The value is a hash with the following keys:
|
363
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
364
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
365
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
366
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
367
|
+
# trigger a retry.
|
368
|
+
# @return [Hash]
|
369
|
+
#
|
370
|
+
class Configuration
|
371
|
+
extend Gapic::Config
|
372
|
+
|
373
|
+
config_attr :endpoint, "vision.googleapis.com", String
|
374
|
+
config_attr :credentials, nil do |value|
|
375
|
+
allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
376
|
+
allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
|
377
|
+
allowed.any? { |klass| klass === value }
|
378
|
+
end
|
379
|
+
config_attr :scope, nil, String, Array, nil
|
380
|
+
config_attr :lib_name, nil, String, nil
|
381
|
+
config_attr :lib_version, nil, String, nil
|
382
|
+
config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, Hash, nil)
|
383
|
+
config_attr :interceptors, nil, Array, nil
|
384
|
+
config_attr :timeout, nil, Numeric, nil
|
385
|
+
config_attr :metadata, nil, Hash, nil
|
386
|
+
config_attr :retry_policy, nil, Hash, Proc, nil
|
387
|
+
|
388
|
+
# @private
|
389
|
+
def initialize parent_config = nil
|
390
|
+
@parent_config = parent_config unless parent_config.nil?
|
391
|
+
|
392
|
+
yield self if block_given?
|
393
|
+
end
|
394
|
+
|
395
|
+
##
|
396
|
+
# Configurations for individual RPCs
|
397
|
+
# @return [Rpcs]
|
398
|
+
#
|
399
|
+
def rpcs
|
400
|
+
@rpcs ||= begin
|
401
|
+
parent_rpcs = nil
|
402
|
+
parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
|
403
|
+
Rpcs.new parent_rpcs
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
##
|
408
|
+
# Configuration RPC class for the ImageAnnotator API.
|
409
|
+
#
|
410
|
+
# Includes fields providing the configuration for each RPC in this service.
|
411
|
+
# Each configuration object is of type `Gapic::Config::Method` and includes
|
412
|
+
# the following configuration fields:
|
413
|
+
#
|
414
|
+
# * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
|
415
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
|
416
|
+
# * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
|
417
|
+
# include the following keys:
|
418
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
419
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
420
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
421
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
422
|
+
# trigger a retry.
|
423
|
+
#
|
424
|
+
class Rpcs
|
425
|
+
##
|
426
|
+
# RPC-specific configuration for `batch_annotate_images`
|
427
|
+
# @return [Gapic::Config::Method]
|
428
|
+
#
|
429
|
+
attr_reader :batch_annotate_images
|
430
|
+
##
|
431
|
+
# RPC-specific configuration for `async_batch_annotate_files`
|
432
|
+
# @return [Gapic::Config::Method]
|
433
|
+
#
|
434
|
+
attr_reader :async_batch_annotate_files
|
435
|
+
|
436
|
+
# @private
|
437
|
+
def initialize parent_rpcs = nil
|
438
|
+
batch_annotate_images_config = parent_rpcs&.batch_annotate_images if parent_rpcs&.respond_to? :batch_annotate_images
|
439
|
+
@batch_annotate_images = Gapic::Config::Method.new batch_annotate_images_config
|
440
|
+
async_batch_annotate_files_config = parent_rpcs&.async_batch_annotate_files if parent_rpcs&.respond_to? :async_batch_annotate_files
|
441
|
+
@async_batch_annotate_files = Gapic::Config::Method.new async_batch_annotate_files_config
|
442
|
+
|
443
|
+
yield self if block_given?
|
444
|
+
end
|
445
|
+
end
|
446
|
+
end
|
447
|
+
end
|
448
|
+
end
|
449
|
+
end
|
450
|
+
end
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
# rubocop:disable Lint/HandleExceptions
|
455
|
+
|
456
|
+
# Once client is loaded, load helpers.rb if it exists.
|
457
|
+
begin
|
458
|
+
require "google/cloud/vision/v1p3beta1/image_annotator/helpers"
|
459
|
+
rescue LoadError
|
460
|
+
end
|
461
|
+
|
462
|
+
# rubocop:enable Lint/HandleExceptions
|