google-cloud-vision 1.3.0 → 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 +4 -4
- data/.yardopts +0 -1
- data/AUTHENTICATION.md +72 -101
- data/README.md +31 -10
- data/lib/google/cloud/vision/version.rb +1 -1
- data/lib/google/cloud/vision.rb +83 -8
- metadata +7 -149
- data/MIGRATING.md +0 -343
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1129130bd2c66d16a27b2b777d83077bdb67807b64d8ce719aea58b14f500e1
|
4
|
+
data.tar.gz: 950ff11ab47c8499e057508f0f173e24c41a027869f3fca7217b9a87c0c49715
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6ec715c05f0ca86057266483660a6ef5259110819daea1ba187a60a9e8b9f61a6de5dbd2f5b0a65c170fe4270c3729419ab110169b63c19d9007e1553075cb0
|
7
|
+
data.tar.gz: 5b90a4df63e34147243ccee14a1b9dac063bf8f4f7d62e93c3645c17a94dacb48ca94aa60214631af9bd3b763b778ff779335f6ba4f557f2758060999e669675
|
data/.yardopts
CHANGED
data/AUTHENTICATION.md
CHANGED
@@ -1,151 +1,122 @@
|
|
1
1
|
# Authentication
|
2
2
|
|
3
|
-
|
4
|
-
[
|
5
|
-
|
6
|
-
[Google Cloud Platform environments](#google-cloud-platform-environments) the
|
7
|
-
credentials will be discovered automatically. When running on other
|
8
|
-
environments, the Service Account credentials can be specified by providing the
|
9
|
-
path to the
|
10
|
-
[JSON keyfile](https://cloud.google.com/iam/docs/managing-service-account-keys)
|
11
|
-
for the account (or the JSON itself) in
|
12
|
-
[environment variables](#environment-variables). Additionally, Cloud SDK
|
13
|
-
credentials can also be discovered automatically, but this is only recommended
|
14
|
-
during development.
|
3
|
+
The recommended way to authenticate to the google-cloud-vision library is to use
|
4
|
+
[Application Default Credentials (ADC)](https://cloud.google.com/docs/authentication/application-default-credentials).
|
5
|
+
To review all of your authentication options, see [Credentials lookup](#credential-lookup).
|
15
6
|
|
16
7
|
## Quickstart
|
17
8
|
|
18
|
-
|
19
|
-
|
9
|
+
The following example shows how to set up authentication for a local development
|
10
|
+
environment with your user credentials.
|
20
11
|
|
21
|
-
|
22
|
-
|
23
|
-
```
|
24
|
-
|
25
|
-
3. Initialize the client.
|
12
|
+
**NOTE:** This method is _not_ recommended for running in production. User credentials
|
13
|
+
should be used only during development.
|
26
14
|
|
27
|
-
|
28
|
-
|
15
|
+
1. [Download and install the Google Cloud CLI](https://cloud.google.com/sdk).
|
16
|
+
2. Set up a local ADC file with your user credentials:
|
29
17
|
|
30
|
-
|
18
|
+
```sh
|
19
|
+
gcloud auth application-default login
|
31
20
|
```
|
32
21
|
|
33
|
-
|
34
|
-
|
35
|
-
The google-cloud-vision library aims to make authentication
|
36
|
-
as simple as possible, and provides several mechanisms to configure your system
|
37
|
-
without requiring **Service Account Credentials** directly in code.
|
38
|
-
|
39
|
-
**Credentials** are discovered in the following order:
|
40
|
-
|
41
|
-
1. Specify credentials in method arguments
|
42
|
-
2. Specify credentials in configuration
|
43
|
-
3. Discover credentials path in environment variables
|
44
|
-
4. Discover credentials JSON in environment variables
|
45
|
-
5. Discover credentials file in the Cloud SDK's path
|
46
|
-
6. Discover GCP credentials
|
47
|
-
|
48
|
-
### Google Cloud Platform environments
|
22
|
+
3. Write code as if already authenticated.
|
49
23
|
|
50
|
-
|
51
|
-
|
52
|
-
Functions (GCF) and Cloud Run, **Credentials** are discovered automatically.
|
53
|
-
Code should be written as if already authenticated.
|
24
|
+
For more information about setting up authentication for a local development environment, see
|
25
|
+
[Set up Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc#local-dev).
|
54
26
|
|
55
|
-
|
27
|
+
## Credential Lookup
|
56
28
|
|
57
|
-
The
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
**Credentials JSON** file can be stored in the environment variable, or the
|
62
|
-
**Credentials JSON** itself can be stored for environments such as Docker
|
63
|
-
containers where writing files is difficult or not encouraged.
|
29
|
+
The google-cloud-vision library provides several mechanisms to configure your system.
|
30
|
+
Generally, using Application Default Credentials to facilitate automatic
|
31
|
+
credentials discovery is the easist method. But if you need to explicitly specify
|
32
|
+
credentials, there are several methods available to you.
|
64
33
|
|
65
|
-
|
66
|
-
checks for credentials are configured on the service Credentials class (such as
|
67
|
-
`::Google::Cloud::Vision::V1::ProductSearch::Credentials`):
|
34
|
+
Credentials are accepted in the following ways, in the following order or precedence:
|
68
35
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
36
|
+
1. Credentials specified in method arguments
|
37
|
+
2. Credentials specified in configuration
|
38
|
+
3. Credentials pointed to or included in environment variables
|
39
|
+
4. Credentials found in local ADC file
|
40
|
+
5. Credentials returned by the metadata server for the attached service account (GCP)
|
74
41
|
|
75
|
-
|
76
|
-
require "google/cloud/vision"
|
77
|
-
|
78
|
-
ENV["VISION_CREDENTIALS"] = "path/to/keyfile.json"
|
42
|
+
### Configuration
|
79
43
|
|
80
|
-
client
|
81
|
-
|
44
|
+
You can configure a path to a JSON credentials file, either for an individual client object or
|
45
|
+
globally, for all client objects. The JSON file can contain credentials created for
|
46
|
+
[workload identity federation](https://cloud.google.com/iam/docs/workload-identity-federation),
|
47
|
+
[workforce identity federation](https://cloud.google.com/iam/docs/workforce-identity-federation), or a
|
48
|
+
[service account key](https://cloud.google.com/docs/authentication/provide-credentials-adc#local-key).
|
82
49
|
|
83
|
-
|
50
|
+
Note: Service account keys are a security risk if not managed correctly. You should
|
51
|
+
[choose a more secure alternative to service account keys](https://cloud.google.com/docs/authentication#auth-decision-tree)
|
52
|
+
whenever possible.
|
84
53
|
|
85
|
-
|
86
|
-
it in an environment variable. Either on an individual client initialization:
|
54
|
+
To configure a credentials file for an individual client initialization:
|
87
55
|
|
88
56
|
```ruby
|
89
57
|
require "google/cloud/vision"
|
90
58
|
|
91
59
|
client = Google::Cloud::Vision.product_search do |config|
|
92
|
-
config.credentials = "path/to/
|
60
|
+
config.credentials = "path/to/credentialfile.json"
|
93
61
|
end
|
94
62
|
```
|
95
63
|
|
96
|
-
|
64
|
+
To configure a credentials file globally for all clients:
|
97
65
|
|
98
66
|
```ruby
|
99
67
|
require "google/cloud/vision"
|
100
68
|
|
101
69
|
Google::Cloud::Vision.configure do |config|
|
102
|
-
config.credentials = "path/to/
|
70
|
+
config.credentials = "path/to/credentialfile.json"
|
103
71
|
end
|
104
72
|
|
105
73
|
client = Google::Cloud::Vision.product_search
|
106
74
|
```
|
107
75
|
|
108
|
-
###
|
76
|
+
### Environment Variables
|
109
77
|
|
110
|
-
|
111
|
-
|
112
|
-
|
78
|
+
You can also use an environment variable to provide a JSON credentials file.
|
79
|
+
The environment variable can contain a path to the credentials file or, for
|
80
|
+
environments such as Docker containers where writing files is not encouraged,
|
81
|
+
you can include the credentials file itself.
|
113
82
|
|
114
|
-
|
83
|
+
The JSON file can contain credentials created for
|
84
|
+
[workload identity federation](https://cloud.google.com/iam/docs/workload-identity-federation),
|
85
|
+
[workforce identity federation](https://cloud.google.com/iam/docs/workforce-identity-federation), or a
|
86
|
+
[service account key](https://cloud.google.com/docs/authentication/provide-credentials-adc#local-key).
|
115
87
|
|
116
|
-
|
117
|
-
|
118
|
-
|
88
|
+
Note: Service account keys are a security risk if not managed correctly. You should
|
89
|
+
[choose a more secure alternative to service account keys](https://cloud.google.com/docs/authentication#auth-decision-tree)
|
90
|
+
whenever possible.
|
91
|
+
|
92
|
+
The environment variables that google-cloud-vision
|
93
|
+
checks for credentials are:
|
119
94
|
|
120
|
-
|
121
|
-
*
|
95
|
+
* `GOOGLE_CLOUD_CREDENTIALS` - Path to JSON file, or JSON contents
|
96
|
+
* `GOOGLE_APPLICATION_CREDENTIALS` - Path to JSON file
|
122
97
|
|
123
|
-
|
98
|
+
```ruby
|
99
|
+
require "google/cloud/vision"
|
124
100
|
|
125
|
-
|
126
|
-
connect to the APIs. You will use the **JSON key file** to
|
127
|
-
connect to most services with google-cloud-vision.
|
101
|
+
ENV["GOOGLE_APPLICATION_CREDENTIALS"] = "path/to/credentialfile.json"
|
128
102
|
|
129
|
-
|
130
|
-
|
131
|
-
need a Google Developers service account.
|
103
|
+
client = Google::Cloud::Vision.product_search
|
104
|
+
```
|
132
105
|
|
133
|
-
|
134
|
-
2. Create a new project or click on an existing project.
|
135
|
-
3. Activate the menu in the upper left and select **APIs & Services**. From
|
136
|
-
here, you will enable the APIs that your application requires.
|
106
|
+
### Local ADC file
|
137
107
|
|
138
|
-
|
108
|
+
You can set up a local ADC file with your user credentials for authentication during
|
109
|
+
development. If credentials are not provided in code or in environment variables,
|
110
|
+
then the local ADC credentials are discovered.
|
139
111
|
|
140
|
-
|
112
|
+
Follow the steps in [Quickstart](#quickstart) to set up a local ADC file.
|
141
113
|
|
142
|
-
|
143
|
-
"Service account" to be guided through downloading a new JSON key file.
|
114
|
+
### Google Cloud Platform environments
|
144
115
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
116
|
+
When running on Google Cloud Platform (GCP), including Google Compute Engine
|
117
|
+
(GCE), Google Kubernetes Engine (GKE), Google App Engine (GAE), Google Cloud
|
118
|
+
Functions (GCF) and Cloud Run, credentials are retrieved from the attached
|
119
|
+
service account automatically. Code should be written as if already authenticated.
|
149
120
|
|
150
|
-
|
151
|
-
|
121
|
+
For more information, see
|
122
|
+
[Set up ADC for Google Cloud services](https://cloud.google.com/docs/authentication/provide-credentials-adc#attached-sa).
|
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://
|
20
|
-
[google-cloud-vision-v1p3beta1](https://googleapis.dev/ruby/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
|
-
##
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
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
|
data/lib/google/cloud/vision.rb
CHANGED
@@ -29,7 +29,7 @@ require "google/cloud/config"
|
|
29
29
|
|
30
30
|
# Set the default configuration
|
31
31
|
::Google::Cloud.configure.add_config! :vision do |config|
|
32
|
-
config.add_field! :endpoint,
|
32
|
+
config.add_field! :endpoint, nil, match: ::String
|
33
33
|
config.add_field! :credentials, nil, match: [::String, ::Hash, ::Google::Auth::Credentials]
|
34
34
|
config.add_field! :scope, nil, match: [::Array, ::String]
|
35
35
|
config.add_field! :lib_name, nil, match: ::String
|
@@ -39,6 +39,7 @@ require "google/cloud/config"
|
|
39
39
|
config.add_field! :metadata, nil, match: ::Hash
|
40
40
|
config.add_field! :retry_policy, nil, match: [::Hash, ::Proc]
|
41
41
|
config.add_field! :quota_project, nil, match: ::String
|
42
|
+
config.add_field! :universe_domain, nil, match: ::String
|
42
43
|
end
|
43
44
|
|
44
45
|
module Google
|
@@ -48,7 +49,7 @@ module Google
|
|
48
49
|
# Create a new client object for ProductSearch.
|
49
50
|
#
|
50
51
|
# By default, this returns an instance of
|
51
|
-
# [Google::Cloud::Vision::V1::ProductSearch::Client](https://
|
52
|
+
# [Google::Cloud::Vision::V1::ProductSearch::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-vision-v1/latest/Google-Cloud-Vision-V1-ProductSearch-Client)
|
52
53
|
# for a gRPC client for version V1 of the API.
|
53
54
|
# However, you can specify a different API version by passing it in the
|
54
55
|
# `version` parameter. If the ProductSearch service is
|
@@ -57,21 +58,28 @@ module Google
|
|
57
58
|
# You can also specify a different transport by passing `:rest` or `:grpc` in
|
58
59
|
# the `transport` parameter.
|
59
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
|
+
#
|
60
66
|
# ## About ProductSearch
|
61
67
|
#
|
62
68
|
# Manages Products and ProductSets of reference images for use in product
|
63
69
|
# search. It uses the following resource model:
|
64
70
|
#
|
65
|
-
# - The API has a collection of ProductSet
|
66
|
-
# `projects/*/locations/*/productSets/*`, which acts as a way
|
67
|
-
# products into groups to limit identification.
|
71
|
+
# - The API has a collection of ProductSet
|
72
|
+
# resources, named `projects/*/locations/*/productSets/*`, which acts as a way
|
73
|
+
# to put different products into groups to limit identification.
|
68
74
|
#
|
69
75
|
# In parallel,
|
70
76
|
#
|
71
|
-
# - The API has a collection of Product
|
77
|
+
# - The API has a collection of Product
|
78
|
+
# resources, named
|
72
79
|
# `projects/*/locations/*/products/*`
|
73
80
|
#
|
74
|
-
# - Each Product has a collection of
|
81
|
+
# - Each Product has a collection of
|
82
|
+
# ReferenceImage resources, named
|
75
83
|
# `projects/*/locations/*/products/*/referenceImages/*`
|
76
84
|
#
|
77
85
|
# @param version [::String, ::Symbol] The API version to connect to. Optional.
|
@@ -91,11 +99,42 @@ module Google
|
|
91
99
|
service_module.const_get(:Client).new(&block)
|
92
100
|
end
|
93
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
|
+
|
94
133
|
##
|
95
134
|
# Create a new client object for ImageAnnotator.
|
96
135
|
#
|
97
136
|
# By default, this returns an instance of
|
98
|
-
# [Google::Cloud::Vision::V1::ImageAnnotator::Client](https://
|
137
|
+
# [Google::Cloud::Vision::V1::ImageAnnotator::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-vision-v1/latest/Google-Cloud-Vision-V1-ImageAnnotator-Client)
|
99
138
|
# for a gRPC client for version V1 of the API.
|
100
139
|
# However, you can specify a different API version by passing it in the
|
101
140
|
# `version` parameter. If the ImageAnnotator service is
|
@@ -104,6 +143,11 @@ module Google
|
|
104
143
|
# You can also specify a different transport by passing `:rest` or `:grpc` in
|
105
144
|
# the `transport` parameter.
|
106
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
|
+
#
|
107
151
|
# ## About ImageAnnotator
|
108
152
|
#
|
109
153
|
# Service that performs Google Cloud Vision API detection tasks over client
|
@@ -127,6 +171,37 @@ module Google
|
|
127
171
|
service_module.const_get(:Client).new(&block)
|
128
172
|
end
|
129
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
|
+
|
130
205
|
##
|
131
206
|
# Configure the google-cloud-vision library.
|
132
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:
|
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:
|
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
|
@@ -26,156 +25,18 @@ dependencies:
|
|
26
25
|
version: '1.6'
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: google-cloud-vision-v1
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.10'
|
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.10'
|
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.9'
|
54
|
-
- - "<"
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 2.a
|
57
|
-
type: :runtime
|
58
|
-
prerelease: false
|
59
|
-
version_requirements: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - ">="
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '0.9'
|
64
|
-
- - "<"
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: 2.a
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: google-style
|
69
|
-
requirement: !ruby/object:Gem::Requirement
|
70
|
-
requirements:
|
71
|
-
- - "~>"
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: 1.26.1
|
74
|
-
type: :development
|
75
|
-
prerelease: false
|
76
|
-
version_requirements: !ruby/object:Gem::Requirement
|
77
|
-
requirements:
|
78
|
-
- - "~>"
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: 1.26.1
|
81
|
-
- !ruby/object:Gem::Dependency
|
82
|
-
name: minitest
|
83
28
|
requirement: !ruby/object:Gem::Requirement
|
84
29
|
requirements:
|
85
30
|
- - "~>"
|
86
31
|
- !ruby/object:Gem::Version
|
87
|
-
version: '
|
88
|
-
type: :
|
89
|
-
prerelease: false
|
90
|
-
version_requirements: !ruby/object:Gem::Requirement
|
91
|
-
requirements:
|
92
|
-
- - "~>"
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
version: '5.16'
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
|
-
name: minitest-focus
|
97
|
-
requirement: !ruby/object:Gem::Requirement
|
98
|
-
requirements:
|
99
|
-
- - "~>"
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '1.1'
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
requirements:
|
106
|
-
- - "~>"
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
version: '1.1'
|
109
|
-
- !ruby/object:Gem::Dependency
|
110
|
-
name: minitest-rg
|
111
|
-
requirement: !ruby/object:Gem::Requirement
|
112
|
-
requirements:
|
113
|
-
- - "~>"
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
version: '5.2'
|
116
|
-
type: :development
|
117
|
-
prerelease: false
|
118
|
-
version_requirements: !ruby/object:Gem::Requirement
|
119
|
-
requirements:
|
120
|
-
- - "~>"
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
version: '5.2'
|
123
|
-
- !ruby/object:Gem::Dependency
|
124
|
-
name: rake
|
125
|
-
requirement: !ruby/object:Gem::Requirement
|
126
|
-
requirements:
|
127
|
-
- - ">="
|
128
|
-
- !ruby/object:Gem::Version
|
129
|
-
version: '13.0'
|
130
|
-
type: :development
|
131
|
-
prerelease: false
|
132
|
-
version_requirements: !ruby/object:Gem::Requirement
|
133
|
-
requirements:
|
134
|
-
- - ">="
|
135
|
-
- !ruby/object:Gem::Version
|
136
|
-
version: '13.0'
|
137
|
-
- !ruby/object:Gem::Dependency
|
138
|
-
name: redcarpet
|
139
|
-
requirement: !ruby/object:Gem::Requirement
|
140
|
-
requirements:
|
141
|
-
- - "~>"
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
version: '3.0'
|
144
|
-
type: :development
|
145
|
-
prerelease: false
|
146
|
-
version_requirements: !ruby/object:Gem::Requirement
|
147
|
-
requirements:
|
148
|
-
- - "~>"
|
149
|
-
- !ruby/object:Gem::Version
|
150
|
-
version: '3.0'
|
151
|
-
- !ruby/object:Gem::Dependency
|
152
|
-
name: simplecov
|
153
|
-
requirement: !ruby/object:Gem::Requirement
|
154
|
-
requirements:
|
155
|
-
- - "~>"
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '0.9'
|
158
|
-
type: :development
|
159
|
-
prerelease: false
|
160
|
-
version_requirements: !ruby/object:Gem::Requirement
|
161
|
-
requirements:
|
162
|
-
- - "~>"
|
163
|
-
- !ruby/object:Gem::Version
|
164
|
-
version: '0.9'
|
165
|
-
- !ruby/object:Gem::Dependency
|
166
|
-
name: yard
|
167
|
-
requirement: !ruby/object:Gem::Requirement
|
168
|
-
requirements:
|
169
|
-
- - "~>"
|
170
|
-
- !ruby/object:Gem::Version
|
171
|
-
version: '0.9'
|
172
|
-
type: :development
|
32
|
+
version: '1.2'
|
33
|
+
type: :runtime
|
173
34
|
prerelease: false
|
174
35
|
version_requirements: !ruby/object:Gem::Requirement
|
175
36
|
requirements:
|
176
37
|
- - "~>"
|
177
38
|
- !ruby/object:Gem::Version
|
178
|
-
version: '
|
39
|
+
version: '1.2'
|
179
40
|
description: Cloud Vision API allows developers to easily integrate vision detection
|
180
41
|
features within applications, including image labeling, face and landmark detection,
|
181
42
|
optical character recognition (OCR), and tagging of explicit content.
|
@@ -187,7 +48,6 @@ files:
|
|
187
48
|
- ".yardopts"
|
188
49
|
- AUTHENTICATION.md
|
189
50
|
- LICENSE.md
|
190
|
-
- MIGRATING.md
|
191
51
|
- README.md
|
192
52
|
- lib/google-cloud-vision.rb
|
193
53
|
- lib/google/cloud/vision.rb
|
@@ -196,7 +56,6 @@ homepage: https://github.com/googleapis/google-cloud-ruby
|
|
196
56
|
licenses:
|
197
57
|
- Apache-2.0
|
198
58
|
metadata: {}
|
199
|
-
post_install_message:
|
200
59
|
rdoc_options: []
|
201
60
|
require_paths:
|
202
61
|
- lib
|
@@ -204,15 +63,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
204
63
|
requirements:
|
205
64
|
- - ">="
|
206
65
|
- !ruby/object:Gem::Version
|
207
|
-
version: '
|
66
|
+
version: '3.0'
|
208
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
68
|
requirements:
|
210
69
|
- - ">="
|
211
70
|
- !ruby/object:Gem::Version
|
212
71
|
version: '0'
|
213
72
|
requirements: []
|
214
|
-
rubygems_version: 3.
|
215
|
-
signing_key:
|
73
|
+
rubygems_version: 3.6.3
|
216
74
|
specification_version: 4
|
217
75
|
summary: API Client library for the Cloud Vision API
|
218
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).
|