google-cloud-vision-v1 0.1.2 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +6 -6
  3. data/README.md +48 -1
  4. data/lib/google-cloud-vision-v1.rb +21 -1
  5. data/lib/google/cloud/vision/v1.rb +16 -0
  6. data/lib/google/cloud/vision/v1/image_annotator.rb +33 -2
  7. data/lib/google/cloud/vision/v1/image_annotator/client.rb +154 -150
  8. data/lib/google/cloud/vision/v1/image_annotator/credentials.rb +1 -1
  9. data/lib/google/cloud/vision/v1/image_annotator/operations.rb +139 -127
  10. data/lib/google/cloud/vision/v1/image_annotator/paths.rb +3 -3
  11. data/lib/google/cloud/vision/v1/product_search.rb +44 -2
  12. data/lib/google/cloud/vision/v1/product_search/client.rb +530 -539
  13. data/lib/google/cloud/vision/v1/product_search/credentials.rb +1 -1
  14. data/lib/google/cloud/vision/v1/product_search/operations.rb +139 -127
  15. data/lib/google/cloud/vision/v1/product_search/paths.rb +12 -12
  16. data/lib/google/cloud/vision/v1/version.rb +1 -1
  17. data/proto_docs/google/api/resource.rb +12 -12
  18. data/proto_docs/google/cloud/vision/v1/geometry.rb +17 -17
  19. data/proto_docs/google/cloud/vision/v1/image_annotator.rb +204 -204
  20. data/proto_docs/google/cloud/vision/v1/product_search.rb +28 -28
  21. data/proto_docs/google/cloud/vision/v1/product_search_service.rb +144 -144
  22. data/proto_docs/google/cloud/vision/v1/text_annotation.rb +49 -49
  23. data/proto_docs/google/cloud/vision/v1/web_detection.rb +28 -28
  24. data/proto_docs/google/longrunning/operations.rb +30 -30
  25. data/proto_docs/google/protobuf/any.rb +4 -4
  26. data/proto_docs/google/protobuf/empty.rb +2 -2
  27. data/proto_docs/google/protobuf/field_mask.rb +3 -3
  28. data/proto_docs/google/protobuf/timestamp.rb +4 -4
  29. data/proto_docs/google/protobuf/wrappers.rb +27 -27
  30. data/proto_docs/google/rpc/status.rb +6 -6
  31. data/proto_docs/google/type/color.rb +6 -6
  32. data/proto_docs/google/type/latlng.rb +4 -4
  33. metadata +32 -5
  34. data/lib/google/cloud/common_resources_pb.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc9d94836585d64ad1377a90ae263d9ac16a139d33d719f9fd15d7e9d2ef9246
4
- data.tar.gz: 5db3da602b2082277f85132aa413beb38133f309292039bf5976d17f2fafbaa5
3
+ metadata.gz: 5c2fc098b59128d6350a0b3a2cd4aa6290511de5046a344ccb7399ffaa043724
4
+ data.tar.gz: dd3245d8a4797d6b346506d24315fec0e96bb1254376edb3ec26e1ff682467e8
5
5
  SHA512:
6
- metadata.gz: 1451c949d6fdeeca39d8f65fb368dc6041cd9002a8220978cc9443f04b6e818967ea4003f9392072e037d2a2e6f7aaa2eef0c6c4979a0c1d0ee9549764a127b6
7
- data.tar.gz: c1ed9fa01aa29a65a65e9f376352304e589d356f857680fb23fbac46f1b45dd4d9a1921b9ae439e28cb2c7a43a38973b5f7b24d4fb557f26dbf2c5717dbecf7b
6
+ metadata.gz: 48c9ed82a393767a376fc93ac192c87bdeb7b95b1566b8e6e93c35a24bf394218782e44135a337cb0f34ef4a54b8bcf1dc42941784446457bc16eed47945d204
7
+ data.tar.gz: 118c6a52e7ec72452c838171210b5c82e01d39d4c8632884bee2b1702c8f1125431c608fd07643fdb833957038e35cc70f7a8f804fe6fe28dfa051027cd54537
@@ -27,7 +27,7 @@ export VISION_CREDENTIALS=path/to/keyfile.json
27
27
  ```ruby
28
28
  require "google/cloud/vision/v1"
29
29
 
30
- client = Google::Cloud::Vision::V1::ProductSearch::Client.new
30
+ client = ::Google::Cloud::Vision::V1::ProductSearch::Client.new
31
31
  ```
32
32
 
33
33
  ## Credential Lookup
@@ -64,7 +64,7 @@ containers where writing files is difficult or not encouraged.
64
64
 
65
65
  The environment variables that google-cloud-vision-v1
66
66
  checks for credentials are configured on the service Credentials class (such as
67
- {Google::Cloud::Vision::V1::ProductSearch::Credentials}):
67
+ {::Google::Cloud::Vision::V1::ProductSearch::Credentials}):
68
68
 
69
69
  1. `VISION_CREDENTIALS` - Path to JSON file, or JSON contents
70
70
  2. `VISION_KEYFILE` - Path to JSON file, or JSON contents
@@ -77,7 +77,7 @@ require "google/cloud/vision/v1"
77
77
 
78
78
  ENV["VISION_CREDENTIALS"] = "path/to/keyfile.json"
79
79
 
80
- client = Google::Cloud::Vision::V1::ProductSearch::Client.new
80
+ client = ::Google::Cloud::Vision::V1::ProductSearch::Client.new
81
81
  ```
82
82
 
83
83
  ### Configuration
@@ -88,7 +88,7 @@ environment variables. Either on an individual client initialization:
88
88
  ```ruby
89
89
  require "google/cloud/vision/v1"
90
90
 
91
- client = Google::Cloud::Vision::V1::ProductSearch::Client.new do |config|
91
+ client = ::Google::Cloud::Vision::V1::ProductSearch::Client.new do |config|
92
92
  config.credentials = "path/to/keyfile.json"
93
93
  end
94
94
  ```
@@ -98,11 +98,11 @@ Or configured globally for all clients:
98
98
  ```ruby
99
99
  require "google/cloud/vision/v1"
100
100
 
101
- Google::Cloud::Vision::V1::ProductSearch::Client.configure do |config|
101
+ ::Google::Cloud::Vision::V1::ProductSearch::Client.configure do |config|
102
102
  config.credentials = "path/to/keyfile.json"
103
103
  end
104
104
 
105
- client = Google::Cloud::Vision::V1::ProductSearch::Client.new
105
+ client = ::Google::Cloud::Vision::V1::ProductSearch::Client.new
106
106
  ```
107
107
 
108
108
  ### Cloud SDK
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Cloud Vision V1
1
+ # Ruby Client for the Cloud Vision V1 API
2
2
 
3
3
  API Client library for the Cloud Vision V1 API
4
4
 
@@ -12,6 +12,53 @@ https://github.com/googleapis/google-cloud-ruby
12
12
  $ gem install google-cloud-vision-v1
13
13
  ```
14
14
 
15
+ ## Before You Begin
16
+
17
+ In order to use this library, you first need to go through the following steps:
18
+
19
+ 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
20
+ 1. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
21
+ 1. {file:AUTHENTICATION.md Set up authentication.}
22
+
23
+ ## Quick Start
24
+
25
+ ```ruby
26
+ require "google/cloud/vision/v1"
27
+
28
+ client = ::Google::Cloud::Vision::V1::ProductSearch::Client.new
29
+ request = my_create_request
30
+ response = client.create_product_set request
31
+ ```
32
+
33
+ View the [Client Library Documentation](https://googleapis.dev/ruby/google-cloud-vision-v1/latest)
34
+ for class and method documentation.
35
+
36
+ ## Enabling Logging
37
+
38
+ To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
39
+ The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) as shown below,
40
+ or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
41
+ that will write logs to [Cloud Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
42
+ and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
43
+
44
+ Configuring a Ruby stdlib logger:
45
+
46
+ ```ruby
47
+ require "logger"
48
+
49
+ module MyLogger
50
+ LOGGER = Logger.new $stderr, level: Logger::WARN
51
+ def logger
52
+ LOGGER
53
+ end
54
+ end
55
+
56
+ # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
57
+ module GRPC
58
+ extend MyLogger
59
+ end
60
+ ```
61
+
15
62
  ## Supported Ruby Versions
16
63
 
17
64
  This library is supported on Ruby 2.4+.
@@ -1 +1,21 @@
1
- require "google/cloud/vision/v1/version"
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
+ # This gem does not autoload during Bundler.require. To load this gem,
20
+ # issue explicit require statements for the packages desired, e.g.:
21
+ # require "google/cloud/vision/v1"
@@ -18,3 +18,19 @@
18
18
 
19
19
  require "google/cloud/vision/v1/product_search"
20
20
  require "google/cloud/vision/v1/image_annotator"
21
+ require "google/cloud/vision/v1/version"
22
+
23
+ module Google
24
+ module Cloud
25
+ module Vision
26
+ ##
27
+ # To load this package, including all its services, and instantiate a client:
28
+ #
29
+ # require "google/cloud/vision/v1"
30
+ # client = ::Google::Cloud::Vision::V1::ProductSearch::Client.new
31
+ #
32
+ module V1
33
+ end
34
+ end
35
+ end
36
+ end
@@ -16,6 +16,37 @@
16
16
 
17
17
  # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
18
 
19
- require "google/cloud/vision/v1/image_annotator/client"
20
- require "google/cloud/vision/v1/image_annotator/operations"
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/vision/v1/version"
24
+
21
25
  require "google/cloud/vision/v1/image_annotator/credentials"
26
+ require "google/cloud/vision/v1/image_annotator/paths"
27
+ require "google/cloud/vision/v1/image_annotator/operations"
28
+ require "google/cloud/vision/v1/image_annotator/client"
29
+
30
+ module Google
31
+ module Cloud
32
+ module Vision
33
+ module V1
34
+ ##
35
+ # Service that performs Google Cloud Vision API detection tasks over client
36
+ # images, such as face, landmark, logo, label, and text detection. The
37
+ # ImageAnnotator service returns detected entities from the images.
38
+ #
39
+ # To load this service and instantiate a client:
40
+ #
41
+ # require "google/cloud/vision/v1/image_annotator"
42
+ # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Client.new
43
+ #
44
+ module ImageAnnotator
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ helper_path = ::File.join __dir__, "image_annotator", "helpers.rb"
52
+ require "google/cloud/vision/v1/image_annotator/helpers" if ::File.file? helper_path
@@ -16,16 +16,8 @@
16
16
 
17
17
  # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
18
 
19
- require "gapic/common"
20
- require "gapic/config"
21
- require "gapic/config/method"
22
-
23
19
  require "google/cloud/errors"
24
- require "google/cloud/vision/v1/version"
25
20
  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
21
 
30
22
  module Google
31
23
  module Cloud
@@ -48,15 +40,15 @@ module Google
48
40
  ##
49
41
  # Configure the ImageAnnotator Client class.
50
42
  #
51
- # See {Google::Cloud::Vision::V1::ImageAnnotator::Client::Configuration}
43
+ # See {::Google::Cloud::Vision::V1::ImageAnnotator::Client::Configuration}
52
44
  # for a description of the configuration fields.
53
45
  #
54
46
  # ## Example
55
47
  #
56
48
  # To modify the configuration for all ImageAnnotator clients:
57
49
  #
58
- # Google::Cloud::Vision::V1::ImageAnnotator::Client.configure do |config|
59
- # config.timeout = 10_000
50
+ # ::Google::Cloud::Vision::V1::ImageAnnotator::Client.configure do |config|
51
+ # config.timeout = 10.0
60
52
  # end
61
53
  #
62
54
  # @yield [config] Configure the Client client.
@@ -120,7 +112,7 @@ module Google
120
112
  # but structural changes (adding new fields, etc.) are not allowed. Structural changes
121
113
  # should be made on {Client.configure}.
122
114
  #
123
- # See {Google::Cloud::Vision::V1::ImageAnnotator::Client::Configuration}
115
+ # See {::Google::Cloud::Vision::V1::ImageAnnotator::Client::Configuration}
124
116
  # for a description of the configuration fields.
125
117
  #
126
118
  # @yield [config] Configure the Client client.
@@ -141,13 +133,13 @@ module Google
141
133
  # To create a new ImageAnnotator client with the default
142
134
  # configuration:
143
135
  #
144
- # client = Google::Cloud::Vision::V1::ImageAnnotator::Client.new
136
+ # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Client.new
145
137
  #
146
138
  # To create a new ImageAnnotator client with a custom
147
139
  # configuration:
148
140
  #
149
- # client = Google::Cloud::Vision::V1::ImageAnnotator::Client.new do |config|
150
- # config.timeout = 10_000
141
+ # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Client.new do |config|
142
+ # config.timeout = 10.0
151
143
  # end
152
144
  #
153
145
  # @yield [config] Configure the ImageAnnotator client.
@@ -172,14 +164,16 @@ module Google
172
164
  if credentials.is_a?(String) || credentials.is_a?(Hash)
173
165
  credentials = Credentials.new credentials, scope: @config.scope
174
166
  end
175
- @quota_project_id = credentials.respond_to?(:quota_project_id) ? credentials.quota_project_id : nil
167
+ @quota_project_id = @config.quota_project
168
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
176
169
 
177
170
  @operations_client = Operations.new do |config|
178
171
  config.credentials = credentials
172
+ config.endpoint = @config.endpoint
179
173
  end
180
174
 
181
- @image_annotator_stub = Gapic::ServiceStub.new(
182
- Google::Cloud::Vision::V1::ImageAnnotator::Stub,
175
+ @image_annotator_stub = ::Gapic::ServiceStub.new(
176
+ ::Google::Cloud::Vision::V1::ImageAnnotator::Stub,
183
177
  credentials: credentials,
184
178
  endpoint: @config.endpoint,
185
179
  channel_args: @config.channel_args,
@@ -187,21 +181,36 @@ module Google
187
181
  )
188
182
  end
189
183
 
184
+ ##
185
+ # Get the associated client for long-running operations.
186
+ #
187
+ # @return [::Google::Cloud::Vision::V1::ImageAnnotator::Operations]
188
+ #
189
+ attr_reader :operations_client
190
+
190
191
  # Service calls
191
192
 
192
193
  ##
193
194
  # Run image detection and annotation for a batch of images.
194
195
  #
195
196
  # @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]
197
+ # Pass arguments to `batch_annotate_images` via a request object, either of type
198
+ # {::Google::Cloud::Vision::V1::BatchAnnotateImagesRequest} or an equivalent Hash.
199
+ #
200
+ # @param request [::Google::Cloud::Vision::V1::BatchAnnotateImagesRequest, ::Hash]
201
+ # A request object representing the call parameters. Required. To specify no
202
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
203
+ # @param options [::Gapic::CallOptions, ::Hash]
199
204
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
200
205
  #
201
206
  # @overload batch_annotate_images(requests: nil, parent: nil)
202
- # @param requests [Array<Google::Cloud::Vision::V1::AnnotateImageRequest | Hash>]
207
+ # Pass arguments to `batch_annotate_images` via keyword arguments. Note that at
208
+ # least one keyword argument is required. To specify no parameters, or to keep all
209
+ # the default parameter values, pass an empty Hash as a request object (see above).
210
+ #
211
+ # @param requests [::Array<::Google::Cloud::Vision::V1::AnnotateImageRequest, ::Hash>]
203
212
  # Required. Individual image annotation requests for this batch.
204
- # @param parent [String]
213
+ # @param parent [::String]
205
214
  # Optional. Target project and location to make a call.
206
215
  #
207
216
  # Format: `projects/{project-id}/locations/{location-id}`.
@@ -215,28 +224,27 @@ module Google
215
224
  #
216
225
  # Example: `projects/project-A/locations/eu`.
217
226
  #
218
- #
219
227
  # @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]
228
+ # @yieldparam response [::Google::Cloud::Vision::V1::BatchAnnotateImagesResponse]
229
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
222
230
  #
223
- # @return [Google::Cloud::Vision::V1::BatchAnnotateImagesResponse]
231
+ # @return [::Google::Cloud::Vision::V1::BatchAnnotateImagesResponse]
224
232
  #
225
- # @raise [Google::Cloud::Error] if the RPC is aborted.
233
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
226
234
  #
227
235
  def batch_annotate_images request, options = nil
228
- raise ArgumentError, "request must be provided" if request.nil?
236
+ raise ::ArgumentError, "request must be provided" if request.nil?
229
237
 
230
- request = Gapic::Protobuf.coerce request, to: Google::Cloud::Vision::V1::BatchAnnotateImagesRequest
238
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::BatchAnnotateImagesRequest
231
239
 
232
240
  # Converts hash and nil to an options object
233
- options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
241
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
234
242
 
235
243
  # Customize the options with defaults
236
244
  metadata = @config.rpcs.batch_annotate_images.metadata.to_h
237
245
 
238
246
  # Set x-goog-api-client and x-goog-user-project headers
239
- metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
247
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
240
248
  lib_name: @config.lib_name, lib_version: @config.lib_version,
241
249
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
242
250
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
@@ -251,8 +259,8 @@ module Google
251
259
  yield response, operation if block_given?
252
260
  return response
253
261
  end
254
- rescue GRPC::BadStatus => e
255
- raise Google::Cloud::Error.from_error(e)
262
+ rescue ::GRPC::BadStatus => e
263
+ raise ::Google::Cloud::Error.from_error(e)
256
264
  end
257
265
 
258
266
  ##
@@ -265,22 +273,24 @@ module Google
265
273
  # extracted.
266
274
  #
267
275
  # @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]
276
+ # Pass arguments to `batch_annotate_files` via a request object, either of type
277
+ # {::Google::Cloud::Vision::V1::BatchAnnotateFilesRequest} or an equivalent Hash.
278
+ #
279
+ # @param request [::Google::Cloud::Vision::V1::BatchAnnotateFilesRequest, ::Hash]
280
+ # A request object representing the call parameters. Required. To specify no
281
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
282
+ # @param options [::Gapic::CallOptions, ::Hash]
277
283
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
278
284
  #
279
285
  # @overload batch_annotate_files(requests: nil, parent: nil)
280
- # @param requests [Array<Google::Cloud::Vision::V1::AnnotateFileRequest | Hash>]
286
+ # Pass arguments to `batch_annotate_files` via keyword arguments. Note that at
287
+ # least one keyword argument is required. To specify no parameters, or to keep all
288
+ # the default parameter values, pass an empty Hash as a request object (see above).
289
+ #
290
+ # @param requests [::Array<::Google::Cloud::Vision::V1::AnnotateFileRequest, ::Hash>]
281
291
  # Required. The list of file annotation requests. Right now we support only one
282
292
  # AnnotateFileRequest in BatchAnnotateFilesRequest.
283
- # @param parent [String]
293
+ # @param parent [::String]
284
294
  # Optional. Target project and location to make a call.
285
295
  #
286
296
  # Format: `projects/{project-id}/locations/{location-id}`.
@@ -294,28 +304,27 @@ module Google
294
304
  #
295
305
  # Example: `projects/project-A/locations/eu`.
296
306
  #
297
- #
298
307
  # @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]
308
+ # @yieldparam response [::Google::Cloud::Vision::V1::BatchAnnotateFilesResponse]
309
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
301
310
  #
302
- # @return [Google::Cloud::Vision::V1::BatchAnnotateFilesResponse]
311
+ # @return [::Google::Cloud::Vision::V1::BatchAnnotateFilesResponse]
303
312
  #
304
- # @raise [Google::Cloud::Error] if the RPC is aborted.
313
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
305
314
  #
306
315
  def batch_annotate_files request, options = nil
307
- raise ArgumentError, "request must be provided" if request.nil?
316
+ raise ::ArgumentError, "request must be provided" if request.nil?
308
317
 
309
- request = Gapic::Protobuf.coerce request, to: Google::Cloud::Vision::V1::BatchAnnotateFilesRequest
318
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::BatchAnnotateFilesRequest
310
319
 
311
320
  # Converts hash and nil to an options object
312
- options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
321
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
313
322
 
314
323
  # Customize the options with defaults
315
324
  metadata = @config.rpcs.batch_annotate_files.metadata.to_h
316
325
 
317
326
  # Set x-goog-api-client and x-goog-user-project headers
318
- metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
327
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
319
328
  lib_name: @config.lib_name, lib_version: @config.lib_version,
320
329
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
321
330
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
@@ -330,8 +339,8 @@ module Google
330
339
  yield response, operation if block_given?
331
340
  return response
332
341
  end
333
- rescue GRPC::BadStatus => e
334
- raise Google::Cloud::Error.from_error(e)
342
+ rescue ::GRPC::BadStatus => e
343
+ raise ::Google::Cloud::Error.from_error(e)
335
344
  end
336
345
 
337
346
  ##
@@ -346,25 +355,25 @@ module Google
346
355
  # GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
347
356
  #
348
357
  # @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.
358
+ # Pass arguments to `async_batch_annotate_images` via a request object, either of type
359
+ # {::Google::Cloud::Vision::V1::AsyncBatchAnnotateImagesRequest} or an equivalent Hash.
351
360
  #
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]
361
+ # @param request [::Google::Cloud::Vision::V1::AsyncBatchAnnotateImagesRequest, ::Hash]
362
+ # A request object representing the call parameters. Required. To specify no
363
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
364
+ # @param options [::Gapic::CallOptions, ::Hash]
360
365
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
361
366
  #
362
367
  # @overload async_batch_annotate_images(requests: nil, output_config: nil, parent: nil)
363
- # @param requests [Array<Google::Cloud::Vision::V1::AnnotateImageRequest | Hash>]
368
+ # Pass arguments to `async_batch_annotate_images` via keyword arguments. Note that at
369
+ # least one keyword argument is required. To specify no parameters, or to keep all
370
+ # the default parameter values, pass an empty Hash as a request object (see above).
371
+ #
372
+ # @param requests [::Array<::Google::Cloud::Vision::V1::AnnotateImageRequest, ::Hash>]
364
373
  # Required. Individual image annotation requests for this batch.
365
- # @param output_config [Google::Cloud::Vision::V1::OutputConfig | Hash]
374
+ # @param output_config [::Google::Cloud::Vision::V1::OutputConfig, ::Hash]
366
375
  # Required. The desired output location and metadata (e.g. format).
367
- # @param parent [String]
376
+ # @param parent [::String]
368
377
  # Optional. Target project and location to make a call.
369
378
  #
370
379
  # Format: `projects/{project-id}/locations/{location-id}`.
@@ -378,28 +387,27 @@ module Google
378
387
  #
379
388
  # Example: `projects/project-A/locations/eu`.
380
389
  #
381
- #
382
390
  # @yield [response, operation] Access the result along with the RPC operation
383
- # @yieldparam response [Gapic::Operation]
384
- # @yieldparam operation [GRPC::ActiveCall::Operation]
391
+ # @yieldparam response [::Gapic::Operation]
392
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
385
393
  #
386
- # @return [Gapic::Operation]
394
+ # @return [::Gapic::Operation]
387
395
  #
388
- # @raise [Google::Cloud::Error] if the RPC is aborted.
396
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
389
397
  #
390
398
  def async_batch_annotate_images request, options = nil
391
- raise ArgumentError, "request must be provided" if request.nil?
399
+ raise ::ArgumentError, "request must be provided" if request.nil?
392
400
 
393
- request = Gapic::Protobuf.coerce request, to: Google::Cloud::Vision::V1::AsyncBatchAnnotateImagesRequest
401
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::AsyncBatchAnnotateImagesRequest
394
402
 
395
403
  # Converts hash and nil to an options object
396
- options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
404
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
397
405
 
398
406
  # Customize the options with defaults
399
407
  metadata = @config.rpcs.async_batch_annotate_images.metadata.to_h
400
408
 
401
409
  # Set x-goog-api-client and x-goog-user-project headers
402
- metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
410
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
403
411
  lib_name: @config.lib_name, lib_version: @config.lib_version,
404
412
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
405
413
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
@@ -411,12 +419,12 @@ module Google
411
419
  retry_policy: @config.retry_policy
412
420
 
413
421
  @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
422
+ response = ::Gapic::Operation.new response, @operations_client, options: options
415
423
  yield response, operation if block_given?
416
424
  return response
417
425
  end
418
- rescue GRPC::BadStatus => e
419
- raise Google::Cloud::Error.from_error(e)
426
+ rescue ::GRPC::BadStatus => e
427
+ raise ::Google::Cloud::Error.from_error(e)
420
428
  end
421
429
 
422
430
  ##
@@ -428,20 +436,23 @@ module Google
428
436
  # `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
429
437
  #
430
438
  # @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
+ # Pass arguments to `async_batch_annotate_files` via a request object, either of type
440
+ # {::Google::Cloud::Vision::V1::AsyncBatchAnnotateFilesRequest} or an equivalent Hash.
441
+ #
442
+ # @param request [::Google::Cloud::Vision::V1::AsyncBatchAnnotateFilesRequest, ::Hash]
443
+ # A request object representing the call parameters. Required. To specify no
444
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
445
+ # @param options [::Gapic::CallOptions, ::Hash]
439
446
  # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
440
447
  #
441
448
  # @overload async_batch_annotate_files(requests: nil, parent: nil)
442
- # @param requests [Array<Google::Cloud::Vision::V1::AsyncAnnotateFileRequest | Hash>]
449
+ # Pass arguments to `async_batch_annotate_files` via keyword arguments. Note that at
450
+ # least one keyword argument is required. To specify no parameters, or to keep all
451
+ # the default parameter values, pass an empty Hash as a request object (see above).
452
+ #
453
+ # @param requests [::Array<::Google::Cloud::Vision::V1::AsyncAnnotateFileRequest, ::Hash>]
443
454
  # Required. Individual async file annotation requests for this batch.
444
- # @param parent [String]
455
+ # @param parent [::String]
445
456
  # Optional. Target project and location to make a call.
446
457
  #
447
458
  # Format: `projects/{project-id}/locations/{location-id}`.
@@ -455,28 +466,27 @@ module Google
455
466
  #
456
467
  # Example: `projects/project-A/locations/eu`.
457
468
  #
458
- #
459
469
  # @yield [response, operation] Access the result along with the RPC operation
460
- # @yieldparam response [Gapic::Operation]
461
- # @yieldparam operation [GRPC::ActiveCall::Operation]
470
+ # @yieldparam response [::Gapic::Operation]
471
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
462
472
  #
463
- # @return [Gapic::Operation]
473
+ # @return [::Gapic::Operation]
464
474
  #
465
- # @raise [Google::Cloud::Error] if the RPC is aborted.
475
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
466
476
  #
467
477
  def async_batch_annotate_files request, options = nil
468
- raise ArgumentError, "request must be provided" if request.nil?
478
+ raise ::ArgumentError, "request must be provided" if request.nil?
469
479
 
470
- request = Gapic::Protobuf.coerce request, to: Google::Cloud::Vision::V1::AsyncBatchAnnotateFilesRequest
480
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Vision::V1::AsyncBatchAnnotateFilesRequest
471
481
 
472
482
  # Converts hash and nil to an options object
473
- options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
483
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
474
484
 
475
485
  # Customize the options with defaults
476
486
  metadata = @config.rpcs.async_batch_annotate_files.metadata.to_h
477
487
 
478
488
  # Set x-goog-api-client and x-goog-user-project headers
479
- metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
489
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
480
490
  lib_name: @config.lib_name, lib_version: @config.lib_version,
481
491
  gapic_version: ::Google::Cloud::Vision::V1::VERSION
482
492
  metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
@@ -488,12 +498,12 @@ module Google
488
498
  retry_policy: @config.retry_policy
489
499
 
490
500
  @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
501
+ response = ::Gapic::Operation.new response, @operations_client, options: options
492
502
  yield response, operation if block_given?
493
503
  return response
494
504
  end
495
- rescue GRPC::BadStatus => e
496
- raise Google::Cloud::Error.from_error(e)
505
+ rescue ::GRPC::BadStatus => e
506
+ raise ::Google::Cloud::Error.from_error(e)
497
507
  end
498
508
 
499
509
  ##
@@ -503,7 +513,7 @@ module Google
503
513
  # providing control over timeouts, retry behavior, logging, transport
504
514
  # parameters, and other low-level controls. Certain parameters can also be
505
515
  # applied individually to specific RPCs. See
506
- # {Google::Cloud::Vision::V1::ImageAnnotator::Client::Configuration::Rpcs}
516
+ # {::Google::Cloud::Vision::V1::ImageAnnotator::Client::Configuration::Rpcs}
507
517
  # for a list of RPCs that can be configured independently.
508
518
  #
509
519
  # Configuration can be applied globally to all clients, or to a single client
@@ -514,22 +524,22 @@ module Google
514
524
  # To modify the global config, setting the timeout for batch_annotate_images
515
525
  # to 20 seconds, and all remaining timeouts to 10 seconds:
516
526
  #
517
- # Google::Cloud::Vision::V1::ImageAnnotator::Client.configure do |config|
518
- # config.timeout = 10_000
519
- # config.rpcs.batch_annotate_images.timeout = 20_000
527
+ # ::Google::Cloud::Vision::V1::ImageAnnotator::Client.configure do |config|
528
+ # config.timeout = 10.0
529
+ # config.rpcs.batch_annotate_images.timeout = 20.0
520
530
  # end
521
531
  #
522
532
  # To apply the above configuration only to a new client:
523
533
  #
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
534
+ # client = ::Google::Cloud::Vision::V1::ImageAnnotator::Client.new do |config|
535
+ # config.timeout = 10.0
536
+ # config.rpcs.batch_annotate_images.timeout = 20.0
527
537
  # end
528
538
  #
529
539
  # @!attribute [rw] endpoint
530
540
  # The hostname or hostname:port of the service endpoint.
531
541
  # Defaults to `"vision.googleapis.com"`.
532
- # @return [String]
542
+ # @return [::String]
533
543
  # @!attribute [rw] credentials
534
544
  # Credentials to send with calls. You may provide any of the following types:
535
545
  # * (`String`) The path to a service account key file in JSON format
@@ -541,29 +551,29 @@ module Google
541
551
  # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
542
552
  # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
543
553
  # * (`nil`) indicating no credentials
544
- # @return [Object]
554
+ # @return [::Object]
545
555
  # @!attribute [rw] scope
546
556
  # The OAuth scopes
547
- # @return [Array<String>]
557
+ # @return [::Array<::String>]
548
558
  # @!attribute [rw] lib_name
549
559
  # The library name as recorded in instrumentation and logging
550
- # @return [String]
560
+ # @return [::String]
551
561
  # @!attribute [rw] lib_version
552
562
  # The library version as recorded in instrumentation and logging
553
- # @return [String]
563
+ # @return [::String]
554
564
  # @!attribute [rw] channel_args
555
565
  # Extra parameters passed to the gRPC channel. Note: this is ignored if a
556
566
  # `GRPC::Core::Channel` object is provided as the credential.
557
- # @return [Hash]
567
+ # @return [::Hash]
558
568
  # @!attribute [rw] interceptors
559
569
  # An array of interceptors that are run before calls are executed.
560
- # @return [Array<GRPC::ClientInterceptor>]
570
+ # @return [::Array<::GRPC::ClientInterceptor>]
561
571
  # @!attribute [rw] timeout
562
- # The call timeout in milliseconds.
563
- # @return [Numeric]
572
+ # The call timeout in seconds.
573
+ # @return [::Numeric]
564
574
  # @!attribute [rw] metadata
565
575
  # Additional gRPC headers to be sent with the call.
566
- # @return [Hash{Symbol=>String}]
576
+ # @return [::Hash{::Symbol=>::String}]
567
577
  # @!attribute [rw] retry_policy
568
578
  # The retry policy. The value is a hash with the following keys:
569
579
  # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
@@ -571,25 +581,29 @@ module Google
571
581
  # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
572
582
  # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
573
583
  # trigger a retry.
574
- # @return [Hash]
584
+ # @return [::Hash]
585
+ # @!attribute [rw] quota_project
586
+ # A separate project against which to charge quota.
587
+ # @return [::String]
575
588
  #
576
589
  class Configuration
577
- extend Gapic::Config
590
+ extend ::Gapic::Config
578
591
 
579
- config_attr :endpoint, "vision.googleapis.com", String
580
- config_attr :credentials, nil do |value|
592
+ config_attr :endpoint, "vision.googleapis.com", ::String
593
+ config_attr :credentials, nil do |value|
581
594
  allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
582
595
  allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
583
596
  allowed.any? { |klass| klass === value }
584
597
  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
598
+ config_attr :scope, nil, ::String, ::Array, nil
599
+ config_attr :lib_name, nil, ::String, nil
600
+ config_attr :lib_version, nil, ::String, nil
601
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
602
+ config_attr :interceptors, nil, ::Array, nil
603
+ config_attr :timeout, nil, ::Numeric, nil
604
+ config_attr :metadata, nil, ::Hash, nil
605
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
606
+ config_attr :quota_project, nil, ::String, nil
593
607
 
594
608
  # @private
595
609
  def initialize parent_config = nil
@@ -630,35 +644,35 @@ module Google
630
644
  class Rpcs
631
645
  ##
632
646
  # RPC-specific configuration for `batch_annotate_images`
633
- # @return [Gapic::Config::Method]
647
+ # @return [::Gapic::Config::Method]
634
648
  #
635
649
  attr_reader :batch_annotate_images
636
650
  ##
637
651
  # RPC-specific configuration for `batch_annotate_files`
638
- # @return [Gapic::Config::Method]
652
+ # @return [::Gapic::Config::Method]
639
653
  #
640
654
  attr_reader :batch_annotate_files
641
655
  ##
642
656
  # RPC-specific configuration for `async_batch_annotate_images`
643
- # @return [Gapic::Config::Method]
657
+ # @return [::Gapic::Config::Method]
644
658
  #
645
659
  attr_reader :async_batch_annotate_images
646
660
  ##
647
661
  # RPC-specific configuration for `async_batch_annotate_files`
648
- # @return [Gapic::Config::Method]
662
+ # @return [::Gapic::Config::Method]
649
663
  #
650
664
  attr_reader :async_batch_annotate_files
651
665
 
652
666
  # @private
653
667
  def initialize parent_rpcs = nil
654
668
  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
669
+ @batch_annotate_images = ::Gapic::Config::Method.new batch_annotate_images_config
656
670
  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
671
+ @batch_annotate_files = ::Gapic::Config::Method.new batch_annotate_files_config
658
672
  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
673
+ @async_batch_annotate_images = ::Gapic::Config::Method.new async_batch_annotate_images_config
660
674
  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
675
+ @async_batch_annotate_files = ::Gapic::Config::Method.new async_batch_annotate_files_config
662
676
 
663
677
  yield self if block_given?
664
678
  end
@@ -670,13 +684,3 @@ module Google
670
684
  end
671
685
  end
672
686
  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