google-cloud-vision 1.5.1 → 2.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d958fc6a23b30613efb43207e30dcb6e23c95d24c4903be7b30081c5395b78cd
4
- data.tar.gz: d0aaeb843ffc9eae20af804fabb9074adee3e7cefdf627ebf4ee39320cc67189
3
+ metadata.gz: b1129130bd2c66d16a27b2b777d83077bdb67807b64d8ce719aea58b14f500e1
4
+ data.tar.gz: 950ff11ab47c8499e057508f0f173e24c41a027869f3fca7217b9a87c0c49715
5
5
  SHA512:
6
- metadata.gz: d143ebbb960c2e14dea53fcf77916162dfc15429cd9aea03d5313a3bbacc552e40913d9d7b7a9f4dd2666b8965cc4a70864de3a47c1fbd2dbf5521cad0299da1
7
- data.tar.gz: 15a41b5d9d61da023080a7ecf96d86110fe0d3c5d385a277f4539f6db08722ead7a56506afa8d1c917a25c8110d65a81db0cb03224d66b369396d4a3de61a47c
6
+ metadata.gz: b6ec715c05f0ca86057266483660a6ef5259110819daea1ba187a60a9e8b9f61a6de5dbd2f5b0a65c170fe4270c3729419ab110169b63c19d9007e1553075cb0
7
+ data.tar.gz: 5b90a4df63e34147243ccee14a1b9dac063bf8f4f7d62e93c3645c17a94dacb48ca94aa60214631af9bd3b763b778ff779335f6ba4f557f2758060999e669675
data/.yardopts CHANGED
@@ -8,5 +8,4 @@
8
8
  -
9
9
  README.md
10
10
  AUTHENTICATION.md
11
- MIGRATING.md
12
11
  LICENSE.md
data/README.md CHANGED
@@ -16,8 +16,7 @@ for this library, google-cloud-vision, to see the convenience methods for
16
16
  constructing client objects. Reference documentation for the client objects
17
17
  themselves can be found in the client library documentation for the versioned
18
18
  client gems:
19
- [google-cloud-vision-v1](https://cloud.google.com/ruby/docs/reference/google-cloud-vision-v1/latest),
20
- [google-cloud-vision-v1p3beta1](https://cloud.google.com/ruby/docs/reference/google-cloud-vision-v1p3beta1/latest).
19
+ [google-cloud-vision-v1](https://cloud.google.com/ruby/docs/reference/google-cloud-vision-v1/latest).
21
20
 
22
21
  See also the [Product Documentation](https://cloud.google.com/vision)
23
22
  for more usage information.
@@ -35,17 +34,39 @@ In order to use this library, you first need to go through the following steps:
35
34
  1. [Enable the API.](https://console.cloud.google.com/apis/library/vision.googleapis.com)
36
35
  1. {file:AUTHENTICATION.md Set up authentication.}
37
36
 
38
- ## Migrating from 0.x versions
39
-
40
- The 1.0 release of the google-cloud-vision client is a significant upgrade
41
- based on a [next-gen code generator](https://github.com/googleapis/gapic-generator-ruby),
42
- and includes substantial interface changes. Existing code written for earlier
43
- versions of this library will likely require updates to use this version.
44
- See the {file:MIGRATING.md MIGRATING.md} document for more information.
37
+ ## Debug Logging
38
+
39
+ This library comes with opt-in Debug Logging that can help you troubleshoot
40
+ your application's integration with the API. When logging is activated, key
41
+ events such as requests and responses, along with data payloads and metadata
42
+ such as headers and client configuration, are logged to the standard error
43
+ stream.
44
+
45
+ **WARNING:** Client Library Debug Logging includes your data payloads in
46
+ plaintext, which could include sensitive data such as PII for yourself or your
47
+ customers, private keys, or other security data that could be compromising if
48
+ leaked. Always practice good data hygiene with your application logs, and follow
49
+ the principle of least access. Google also recommends that Client Library Debug
50
+ Logging be enabled only temporarily during active debugging, and not used
51
+ permanently in production.
52
+
53
+ To enable logging, set the environment variable `GOOGLE_SDK_RUBY_LOGGING_GEMS`
54
+ to the value `all`. Alternatively, you can set the value to a comma-delimited
55
+ list of client library gem names. This will select the default logging behavior,
56
+ which writes logs to the standard error stream. On a local workstation, this may
57
+ result in logs appearing on the console. When running on a Google Cloud hosting
58
+ service such as [Google Cloud Run](https://cloud.google.com/run), this generally
59
+ results in logs appearing alongside your application logs in the
60
+ [Google Cloud Logging](https://cloud.google.com/logging/) service.
61
+
62
+ Debug logging also requires that the versioned clients for this service be
63
+ sufficiently recent, released after about Dec 10, 2024. If logging is not
64
+ working, try updating the versioned clients in your bundle or installed gems:
65
+ [google-cloud-vision-v1](https://cloud.google.com/ruby/docs/reference/google-cloud-vision-v1/latest).
45
66
 
46
67
  ## Supported Ruby Versions
47
68
 
48
- This library is supported on Ruby 2.7+.
69
+ This library is supported on Ruby 3.0+.
49
70
 
50
71
  Google provides official support for Ruby versions that are actively supported
51
72
  by Ruby Core—that is, Ruby versions that are either in normal maintenance or
@@ -20,7 +20,7 @@
20
20
  module Google
21
21
  module Cloud
22
22
  module Vision
23
- VERSION = "1.5.1"
23
+ VERSION = "2.0.0"
24
24
  end
25
25
  end
26
26
  end
@@ -58,6 +58,11 @@ module Google
58
58
  # You can also specify a different transport by passing `:rest` or `:grpc` in
59
59
  # the `transport` parameter.
60
60
  #
61
+ # Raises an exception if the currently installed versioned client gem for the
62
+ # given API version does not support the given transport of the ProductSearch service.
63
+ # You can determine whether the method will succeed by calling
64
+ # {Google::Cloud::Vision.product_search_available?}.
65
+ #
61
66
  # ## About ProductSearch
62
67
  #
63
68
  # Manages Products and ProductSets of reference images for use in product
@@ -94,6 +99,37 @@ module Google
94
99
  service_module.const_get(:Client).new(&block)
95
100
  end
96
101
 
102
+ ##
103
+ # Determines whether the ProductSearch service is supported by the current client.
104
+ # If true, you can retrieve a client object by calling {Google::Cloud::Vision.product_search}.
105
+ # If false, that method will raise an exception. This could happen if the given
106
+ # API version does not exist or does not support the ProductSearch service,
107
+ # or if the versioned client gem needs an update to support the ProductSearch service.
108
+ #
109
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
110
+ # Defaults to `:v1`.
111
+ # @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
112
+ # @return [boolean] Whether the service is available.
113
+ #
114
+ def self.product_search_available? version: :v1, transport: :grpc
115
+ require "google/cloud/vision/#{version.to_s.downcase}"
116
+ package_name = Google::Cloud::Vision
117
+ .constants
118
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
119
+ .first
120
+ return false unless package_name
121
+ service_module = Google::Cloud::Vision.const_get package_name
122
+ return false unless service_module.const_defined? :ProductSearch
123
+ service_module = service_module.const_get :ProductSearch
124
+ if transport == :rest
125
+ return false unless service_module.const_defined? :Rest
126
+ service_module = service_module.const_get :Rest
127
+ end
128
+ service_module.const_defined? :Client
129
+ rescue ::LoadError
130
+ false
131
+ end
132
+
97
133
  ##
98
134
  # Create a new client object for ImageAnnotator.
99
135
  #
@@ -107,6 +143,11 @@ module Google
107
143
  # You can also specify a different transport by passing `:rest` or `:grpc` in
108
144
  # the `transport` parameter.
109
145
  #
146
+ # Raises an exception if the currently installed versioned client gem for the
147
+ # given API version does not support the given transport of the ImageAnnotator service.
148
+ # You can determine whether the method will succeed by calling
149
+ # {Google::Cloud::Vision.image_annotator_available?}.
150
+ #
110
151
  # ## About ImageAnnotator
111
152
  #
112
153
  # Service that performs Google Cloud Vision API detection tasks over client
@@ -130,6 +171,37 @@ module Google
130
171
  service_module.const_get(:Client).new(&block)
131
172
  end
132
173
 
174
+ ##
175
+ # Determines whether the ImageAnnotator service is supported by the current client.
176
+ # If true, you can retrieve a client object by calling {Google::Cloud::Vision.image_annotator}.
177
+ # If false, that method will raise an exception. This could happen if the given
178
+ # API version does not exist or does not support the ImageAnnotator service,
179
+ # or if the versioned client gem needs an update to support the ImageAnnotator service.
180
+ #
181
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
182
+ # Defaults to `:v1`.
183
+ # @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
184
+ # @return [boolean] Whether the service is available.
185
+ #
186
+ def self.image_annotator_available? version: :v1, transport: :grpc
187
+ require "google/cloud/vision/#{version.to_s.downcase}"
188
+ package_name = Google::Cloud::Vision
189
+ .constants
190
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
191
+ .first
192
+ return false unless package_name
193
+ service_module = Google::Cloud::Vision.const_get package_name
194
+ return false unless service_module.const_defined? :ImageAnnotator
195
+ service_module = service_module.const_get :ImageAnnotator
196
+ if transport == :rest
197
+ return false unless service_module.const_defined? :Rest
198
+ service_module = service_module.const_get :Rest
199
+ end
200
+ service_module.const_defined? :Client
201
+ rescue ::LoadError
202
+ false
203
+ end
204
+
133
205
  ##
134
206
  # Configure the google-cloud-vision library.
135
207
  #
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-vision
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google LLC
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-08-08 00:00:00.000000000 Z
10
+ date: 2025-02-13 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: google-cloud-core
@@ -28,42 +27,16 @@ dependencies:
28
27
  name: google-cloud-vision-v1
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0.13'
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: 2.a
37
- type: :runtime
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: '0.13'
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: 2.a
47
- - !ruby/object:Gem::Dependency
48
- name: google-cloud-vision-v1p3beta1
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '0.12'
54
- - - "<"
30
+ - - "~>"
55
31
  - !ruby/object:Gem::Version
56
- version: 2.a
32
+ version: '1.2'
57
33
  type: :runtime
58
34
  prerelease: false
59
35
  version_requirements: !ruby/object:Gem::Requirement
60
36
  requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: '0.12'
64
- - - "<"
37
+ - - "~>"
65
38
  - !ruby/object:Gem::Version
66
- version: 2.a
39
+ version: '1.2'
67
40
  description: Cloud Vision API allows developers to easily integrate vision detection
68
41
  features within applications, including image labeling, face and landmark detection,
69
42
  optical character recognition (OCR), and tagging of explicit content.
@@ -75,7 +48,6 @@ files:
75
48
  - ".yardopts"
76
49
  - AUTHENTICATION.md
77
50
  - LICENSE.md
78
- - MIGRATING.md
79
51
  - README.md
80
52
  - lib/google-cloud-vision.rb
81
53
  - lib/google/cloud/vision.rb
@@ -84,7 +56,6 @@ homepage: https://github.com/googleapis/google-cloud-ruby
84
56
  licenses:
85
57
  - Apache-2.0
86
58
  metadata: {}
87
- post_install_message:
88
59
  rdoc_options: []
89
60
  require_paths:
90
61
  - lib
@@ -92,15 +63,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
63
  requirements:
93
64
  - - ">="
94
65
  - !ruby/object:Gem::Version
95
- version: '2.7'
66
+ version: '3.0'
96
67
  required_rubygems_version: !ruby/object:Gem::Requirement
97
68
  requirements:
98
69
  - - ">="
99
70
  - !ruby/object:Gem::Version
100
71
  version: '0'
101
72
  requirements: []
102
- rubygems_version: 3.5.6
103
- signing_key:
73
+ rubygems_version: 3.6.3
104
74
  specification_version: 4
105
75
  summary: API Client library for the Cloud Vision API
106
76
  test_files: []
data/MIGRATING.md DELETED
@@ -1,343 +0,0 @@
1
- ## Migrating to google-cloud-vision 1.0
2
-
3
- The 1.0 release of the google-cloud-vision client is a significant upgrade
4
- based on a [next-gen code generator](https://github.com/googleapis/gapic-generator-ruby),
5
- and includes substantial interface changes. Existing code written for earlier
6
- versions of this library will likely require updates to use this version.
7
- This document describes the changes that have been made, and what you need to
8
- do to update your usage.
9
-
10
- To summarize:
11
-
12
- * The library has been broken out into multiple libraries. The new gems
13
- `google-cloud-vision-v1` and `google-cloud-vision-v1p3beta1` contain the
14
- actual client classes for versions V1 and V1p3beta1 of the Vision service,
15
- and the gem `google-cloud-vision` now simply provides a convenience wrapper.
16
- See [Library Structure](#library-structure) for more info.
17
- * The library uses a new configuration mechanism giving you closer control
18
- over endpoint address, network timeouts, and retry. See
19
- [Client Configuration](#client-configuration) for more info. Furthermore,
20
- when creating a client object, you can customize its configuration in a
21
- block rather than passing arguments to the constructor. See
22
- [Creating Clients](#creating-clients) for more info.
23
- * Previously, positional arguments were used to indicate required arguments.
24
- Now, all method arguments are keyword arguments, with documentation that
25
- specifies whether they are required or optional. Additionally, you can pass
26
- a proto request object instead of separate arguments. See
27
- [Passing Arguments](#passing-arguments) for more info.
28
- * Previously, some client classes included class methods for constructing
29
- resource paths. These paths are now instance methods on the client objects,
30
- and are also available in a separate paths module. See
31
- [Resource Path Helpers](#resource-path-helpers) for more info.
32
- * Previously, the client included a number of high-level convenience methods,
33
- such as `face_detection`, for detecting particular types of features. These
34
- methods are still present, but a few of the parameter types (relating to
35
- call configuration) have changed. See
36
- [High Level Detection Methods](#high-level-detection-methods) for more info.
37
- * Previously, clients reported RPC errors by raising instances of
38
- `Google::Gax::GaxError` and its subclasses. Now, RPC exceptions are of type
39
- `Google::Cloud::Error` and its subclasses. See
40
- [Handling Errors](#handling-errors) for more info.
41
- * Some classes have moved into different namespaces. See
42
- [Class Namespaces](#class-namespaces) for more info.
43
-
44
- ### Library Structure
45
-
46
- Older 0.x releases of the `google-cloud-vision` gem were all-in-one gems
47
- that included potentially multiple clients for multiple versions of the Vision
48
- service. Factory methods such as `Google::Cloud::Vision::ImageAnnotator.new`
49
- would return you instances of client classes such as
50
- `Google::Cloud::Vision::V1::ImageAnnotatorClient` or
51
- `Google::Cloud::Vision::V1p3beta1::ImageAnnotatorClient`, depending on which
52
- version of the API requested. These classes were all defined in the same gem.
53
-
54
- With the 1.0 release, the `google-cloud-vision` gem still provides factory
55
- methods for obtaining clients. (The method signatures will have changed. See
56
- [Creating Clients](#creating-clients) for details.) However, the actual client
57
- classes have been moved into separate gems, one per service version. The
58
- `Google::Cloud::Vision::V1::ImageAnnotator::Client` class, along with its
59
- helpers and data types, is now part of the `google-cloud-vision-v1` gem.
60
- Similarly, the `Google::Cloud::Vision::V1p3beta1::ImageAnnotator::Client`
61
- class is part of the `google-cloud-vision-v1p3beta1` gem.
62
-
63
- For normal usage, you can continue to install the `google-cloud-vision` gem
64
- (which will bring in the versioned client gems as dependencies) and continue to
65
- use factory methods to create clients. However, you may alternatively choose to
66
- install only one of the versioned gems. For example, if you know you will only
67
- use `V1` of the service, you can install `google-cloud-vision-v1` by
68
- itself, and construct instances of the
69
- `Google::Cloud::Vision::V1::ImageAnnotator::Client` client class directly.
70
-
71
- ### Client Configuration
72
-
73
- In older releases, if you wanted to customize performance parameters or
74
- low-level behavior of the client (such as credentials, timeouts, or
75
- instrumentation), you would pass a variety of keyword arguments to the client
76
- constructor. It was also extremely difficult to customize the default settings.
77
-
78
- With the 1.0 release, a configuration interface provides control over these
79
- parameters, including defaults for all instances of a client, and settings for
80
- each specific client instance. For example, to set default credentials and
81
- timeout for all Vision V1 image annotator clients:
82
-
83
- ```
84
- Google::Cloud::Vision::V1::ImageAnnotator::Client.configure do |config|
85
- config.credentials = "/path/to/credentials.json"
86
- config.timeout = 10.0
87
- end
88
- ```
89
-
90
- Individual RPCs can also be configured independently. For example, to set the
91
- timeout for the `batch_annotate_images` call:
92
-
93
- ```
94
- Google::Cloud::Vision::V1::ImageAnnotator::Client.configure do |config|
95
- config.rpcs.batch_annotate_images.timeout = 20.0
96
- end
97
- ```
98
-
99
- Defaults for certain configurations can be set for all Vision versions and
100
- services globally:
101
-
102
- ```
103
- Google::Cloud::Vision.configure do |config|
104
- config.credentials = "/path/to/credentials.json"
105
- config.timeout = 10.0
106
- end
107
- ```
108
-
109
- Finally, you can override the configuration for each client instance. See the
110
- next section on [Creating Clients](#creating-clients) for details.
111
-
112
- ### Creating Clients
113
-
114
- In older releases, to create a client object, you would use the `new` method
115
- of modules under `Google::Cloud::Vision`. For example, you might call
116
- `Google::Cloud::Vision::ImageAnnotator.new`. Keyword arguments were available to
117
- select a service version and to configure parameters such as credentials and
118
- timeouts.
119
-
120
- With the 1.0 release, use named class methods of `Google::Cloud::Vision` to
121
- create a client object. For example, `Google::Cloud::Vision.image_annotator`.
122
- You may select a service version using the `:version` keyword argument.
123
- However, other configuration parameters should be set in a configuration block
124
- when you create the client.
125
-
126
- Old:
127
- ```
128
- client = Google::Cloud::Vision::ImageAnnotator.new credentials: "/path/to/credentials.json"
129
- ```
130
-
131
- New:
132
- ```
133
- client = Google::Cloud::Vision.image_annotator do |config|
134
- config.credentials = "/path/to/credentials.json"
135
- end
136
- ```
137
-
138
- The configuration block is optional. If you do not provide it, or you do not
139
- set some configuration parameters, then the default configuration is used. See
140
- [Client Configuration](#client-configuration).
141
-
142
- ### Passing Arguments
143
-
144
- In older releases, required arguments would be passed as positional method
145
- arguments, while most optional arguments would be passed as keyword arguments.
146
-
147
- With the 1.0 release, all RPC arguments are passed as keyword arguments,
148
- regardless of whether they are required or optional. For example:
149
-
150
- Old:
151
- ```
152
- client = Google::Cloud::Vision::ImageAnnotator.new
153
-
154
- requests = my_create_requests
155
-
156
- # requests is a positional argument
157
- response = client.batch_annotate_images requests
158
- ```
159
-
160
- New:
161
- ```
162
- client = Google::Cloud::Vision.image_annotator
163
-
164
- requests = my_create_requests
165
-
166
- # requests is a keyword argument
167
- response = client.batch_annotate_images requests: requests
168
- ```
169
-
170
- In the 1.0 release, it is also possible to pass a request object, either
171
- as a hash or as a protocol buffer.
172
-
173
- New:
174
- ```
175
- client = Google::Cloud::Vision.image_annotator
176
-
177
- request_object = Google::Cloud::Vision::V1::BatchAnnotateImagesRequest.new(
178
- requests: my_create_requests
179
- )
180
-
181
- # Pass a request object as a positional argument:
182
- response = client.batch_annotate_images request_object
183
- ```
184
-
185
- Finally, in older releases, to provide call options, you would pass a
186
- `Google::Gax::CallOptions` object with the `:options` keyword argument. In the
187
- 1.0 release, pass call options using a _second set_ of keyword arguments.
188
-
189
- Old:
190
- ```
191
- client = Google::Cloud::Vision::ImageAnnotator.new
192
-
193
- requests = my_create_requests
194
-
195
- options = Google::Gax::CallOptions.new timeout: 10.0
196
-
197
- response = client.batch_annotate_images requests, options: options
198
- ```
199
-
200
- New:
201
- ```
202
- client = Google::Cloud::Vision.image_annotator
203
-
204
- requests = my_create_requests
205
-
206
- # Use a hash to wrap the normal call arguments (or pass a request object), and
207
- # then add further keyword arguments for the call options.
208
- response = client.batch_annotate_images({ requests: requests }, timeout: 10.0)
209
- ```
210
-
211
- ### Resource Path Helpers
212
-
213
- The client library includes helper methods for generating the resource path
214
- strings passed to many calls. These helpers have changed in two ways:
215
-
216
- * In older releases, they are _class_ methods on the client class. In the 1.0
217
- release, they are _instance_ methods on the client. They are also available
218
- on a separate paths module that you can include elsewhere for convenience.
219
- * In older releases, arguments to a resource path helper are passed as
220
- _positional_ arguments. In the 1.0 release, they are passed as named _keyword_
221
- arguments.
222
-
223
- Following is an example involving using a resource path helper.
224
-
225
- Old:
226
- ```
227
- client = Google::Cloud::Vision::ProductSearch.new
228
-
229
- # Call the helper on the client class
230
- location = Google::Cloud::Vision::V1::ProductSearchClient.location_path(
231
- "my-project", "my-location"
232
- )
233
-
234
- product = my_build_product
235
- response = client.create_product location, product
236
- ```
237
-
238
- New:
239
- ```
240
- client = Google::Cloud::Vision.product_search
241
-
242
- # Call the helper on the client instance, and use keyword arguments
243
- location = client.location_path project: "my-project", location: "my-location"
244
-
245
- product = my_build_product
246
- response = client.create_product parent: location, product: product
247
- ```
248
-
249
- In the 1.0 client, you can also use the paths module as a convenience module.
250
-
251
- New:
252
- ```
253
- # Bring the path helper methods into the current class
254
- include Google::Cloud::Vision::V1::ProductSearch::Paths
255
-
256
- def foo
257
- client = Google::Cloud::Vision.product_search
258
-
259
- # Call the included helper method
260
- location = location_path project: "my-project", location: "my-location"
261
-
262
- product = my_build_product
263
- response = client.create_product parent: location, product: product
264
-
265
- # Do something with response...
266
- end
267
- ```
268
-
269
- ### High Level Detection Methods
270
-
271
- The client library includes some high-level convenience methods, with names
272
- such as `face_detection`, for detecting certain types of features. These
273
- methods are still present, but a few of the argument types have changed.
274
-
275
- * The `options` keyword argument is used to pass call options such as timeout
276
- and retry. Older versions of the library took an object of type
277
- `Google::Gax::CallOptions`. Version 1.0 takes an object of type
278
- `Gapic::CallOptions`, which is defined in the `gapic-common` gem. Note that
279
- you can also pass a hash with the same keys that the older library accepted.
280
- * If `async` is set to `true`, older versions of the library returned an
281
- object of type `Google::Gax::Operation`. Version 1.0 returns an object of
282
- type `Gapic::Operation`, which is defined in the `gapic-common` gem. Most
283
- methods on this object are the same as the older object.
284
-
285
- ### Handling Errors
286
-
287
- The client reports standard
288
- [gRPC error codes](https://github.com/grpc/grpc/blob/master/doc/statuscodes.md)
289
- by raising exceptions. In older releases, these exceptions were located in the
290
- `Google::Gax` namespace and were subclasses of the `Google::Gax::GaxError` base
291
- exception class, defined in the `google-gax` gem. However, these classes were
292
- different from the standard exceptions (subclasses of `Google::Cloud::Error`)
293
- thrown by other client libraries such as `google-cloud-storage`.
294
-
295
- The 1.0 client library now uses the `Google::Cloud::Error` exception hierarchy,
296
- for consistency across all the Google Cloud client libraries. In general, these
297
- exceptions have the same name as their counterparts from older releases, but
298
- are located in the `Google::Cloud` namespace rather than the `Google::Gax`
299
- namespace.
300
-
301
- Old:
302
- ```
303
- client = Google::Cloud::Vision::ImageAnnotator.new
304
-
305
- requests = my_create_requests
306
-
307
- begin
308
- response = client.batch_annotate_images requests
309
- rescue Google::Gax::Error => e
310
- # Handle exceptions that subclass Google::Gax::Error
311
- end
312
- ```
313
-
314
- New:
315
- ```
316
- client = Google::Cloud::Vision.image_annotator
317
-
318
- requests = my_create_requests
319
-
320
- begin
321
- response = client.batch_annotate_images requests: requests
322
- rescue Google::Cloud::Error => e
323
- # Handle exceptions that subclass Google::Cloud::Error
324
- end
325
- ```
326
-
327
- ### Class Namespaces
328
-
329
- In older releases, the client object was of classes with names like:
330
- `Google::Cloud::Vision::V1::ProductSearchClient`.
331
- In the 1.0 release, the client object is of a different class:
332
- `Google::Cloud::Vision::V1::ProductSearch::Client`.
333
- Note that most users will use the factory methods such as
334
- `Google::Cloud::Vision.product_search` to create instances of the client object,
335
- so you may not need to reference the actual class directly.
336
- See [Creating Clients](#creating-clients).
337
-
338
- In older releases, the credentials object was of class
339
- `Google::Cloud::Vision::V1::Credentials`.
340
- In the 1.0 release, each service has its own credentials class, e.g.
341
- `Google::Cloud::Vision::V1::ProductSearch::Credentials`.
342
- Again, most users will not need to reference this class directly.
343
- See [Client Configuration](#client-configuration).