google-cloud-vision 0.37.1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +2 -1
- data/AUTHENTICATION.md +51 -59
- data/LICENSE.md +203 -0
- data/MIGRATING.md +343 -0
- data/README.md +35 -49
- data/lib/{google/cloud/vision/v1/doc/google/protobuf/wrappers.rb → google-cloud-vision.rb} +5 -12
- data/lib/google/cloud/vision.rb +132 -215
- data/lib/google/cloud/vision/version.rb +6 -2
- metadata +74 -102
- data/LICENSE +0 -201
- data/lib/google/cloud/vision/v1.rb +0 -249
- data/lib/google/cloud/vision/v1/credentials.rb +0 -42
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/geometry.rb +0 -66
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/image_annotator.rb +0 -923
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/product_search.rb +0 -115
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/product_search_service.rb +0 -569
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/text_annotation.rb +0 -254
- data/lib/google/cloud/vision/v1/doc/google/cloud/vision/v1/web_detection.rb +0 -102
- data/lib/google/cloud/vision/v1/doc/google/longrunning/operations.rb +0 -51
- data/lib/google/cloud/vision/v1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/vision/v1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/vision/v1/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/vision/v1/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/vision/v1/doc/google/rpc/status.rb +0 -87
- data/lib/google/cloud/vision/v1/doc/google/type/color.rb +0 -161
- data/lib/google/cloud/vision/v1/doc/google/type/latlng.rb +0 -31
- data/lib/google/cloud/vision/v1/geometry_pb.rb +0 -39
- data/lib/google/cloud/vision/v1/helpers.rb +0 -1154
- data/lib/google/cloud/vision/v1/image_annotator_client.rb +0 -516
- data/lib/google/cloud/vision/v1/image_annotator_client_config.json +0 -46
- data/lib/google/cloud/vision/v1/image_annotator_pb.rb +0 -344
- data/lib/google/cloud/vision/v1/image_annotator_services_pb.rb +0 -74
- data/lib/google/cloud/vision/v1/product_search_client.rb +0 -1490
- data/lib/google/cloud/vision/v1/product_search_client_config.json +0 -121
- data/lib/google/cloud/vision/v1/product_search_pb.rb +0 -54
- data/lib/google/cloud/vision/v1/product_search_service_pb.rb +0 -207
- data/lib/google/cloud/vision/v1/product_search_service_services_pb.rb +0 -233
- data/lib/google/cloud/vision/v1/text_annotation_pb.rb +0 -94
- data/lib/google/cloud/vision/v1/web_detection_pb.rb +0 -51
- data/lib/google/cloud/vision/v1p3beta1.rb +0 -253
- data/lib/google/cloud/vision/v1p3beta1/credentials.rb +0 -42
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/geometry.rb +0 -72
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/image_annotator.rb +0 -763
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/product_search.rb +0 -156
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/product_search_service.rb +0 -538
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/text_annotation.rb +0 -255
- data/lib/google/cloud/vision/v1p3beta1/doc/google/cloud/vision/v1p3beta1/web_detection.rb +0 -101
- data/lib/google/cloud/vision/v1p3beta1/doc/google/longrunning/operations.rb +0 -51
- data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/any.rb +0 -131
- data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/empty.rb +0 -29
- data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/field_mask.rb +0 -222
- data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/timestamp.rb +0 -113
- data/lib/google/cloud/vision/v1p3beta1/doc/google/protobuf/wrappers.rb +0 -26
- data/lib/google/cloud/vision/v1p3beta1/doc/google/rpc/status.rb +0 -87
- data/lib/google/cloud/vision/v1p3beta1/doc/google/type/color.rb +0 -161
- data/lib/google/cloud/vision/v1p3beta1/doc/google/type/latlng.rb +0 -31
- data/lib/google/cloud/vision/v1p3beta1/geometry_pb.rb +0 -43
- data/lib/google/cloud/vision/v1p3beta1/helpers.rb +0 -1154
- data/lib/google/cloud/vision/v1p3beta1/image_annotator_client.rb +0 -312
- data/lib/google/cloud/vision/v1p3beta1/image_annotator_client_config.json +0 -36
- data/lib/google/cloud/vision/v1p3beta1/image_annotator_pb.rb +0 -304
- data/lib/google/cloud/vision/v1p3beta1/image_annotator_services_pb.rb +0 -55
- data/lib/google/cloud/vision/v1p3beta1/product_search_client.rb +0 -1419
- data/lib/google/cloud/vision/v1p3beta1/product_search_client_config.json +0 -116
- data/lib/google/cloud/vision/v1p3beta1/product_search_pb.rb +0 -64
- data/lib/google/cloud/vision/v1p3beta1/product_search_service_pb.rb +0 -191
- data/lib/google/cloud/vision/v1p3beta1/product_search_service_services_pb.rb +0 -226
- data/lib/google/cloud/vision/v1p3beta1/text_annotation_pb.rb +0 -94
- data/lib/google/cloud/vision/v1p3beta1/web_detection_pb.rb +0 -51
data/README.md
CHANGED
@@ -1,67 +1,53 @@
|
|
1
|
-
# Ruby Client for Cloud Vision API
|
1
|
+
# Ruby Client for the Cloud Vision API
|
2
2
|
|
3
|
-
|
4
|
-
Integrates Google Vision features, including image labeling, face, logo,
|
5
|
-
and landmark detection, optical character recognition (OCR), and detection
|
6
|
-
of explicit content, into applications.
|
7
|
-
- [Client Library Documentation][]
|
8
|
-
- [Product Documentation][]
|
3
|
+
API Client library for the Cloud Vision API
|
9
4
|
|
10
|
-
|
11
|
-
In order to use this library, you first need to go through the following
|
12
|
-
steps:
|
5
|
+
Cloud Vision API allows developers to easily integrate vision detection features within applications, including image labeling, face and landmark detection, optical character recognition (OCR), and tagging of explicit content.
|
13
6
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
7
|
+
Actual client classes for the various versions of this API are defined in
|
8
|
+
_versioned_ client gems, with names of the form `google-cloud-vision-v*`.
|
9
|
+
The gem `google-cloud-vision` is a convenience wrapper library that brings the
|
10
|
+
verisoned gems in as dependencies, and provides high-level methods for
|
11
|
+
constructing clients.
|
12
|
+
|
13
|
+
View the [Client Library Documentation](https://googleapis.dev/ruby/google-cloud-vision/latest)
|
14
|
+
for this library, google-cloud-vision, to see the convenience methods for
|
15
|
+
constructing client objects. Reference documentation for the client objects
|
16
|
+
themselves can be found in the client library documentation for the versioned
|
17
|
+
client gems:
|
18
|
+
[google-cloud-vision-v1](https://googleapis.dev/ruby/google-cloud-vision-v1/latest),
|
19
|
+
[google-cloud-vision-v1p3beta1](https://googleapis.dev/ruby/google-cloud-vision-v1p3beta1/latest).
|
20
|
+
|
21
|
+
See also the [Product Documentation](https://cloud.google.com/vision)
|
22
|
+
for more usage information.
|
23
|
+
|
24
|
+
## Quick Start
|
18
25
|
|
19
|
-
### Installation
|
20
26
|
```
|
21
27
|
$ gem install google-cloud-vision
|
22
28
|
```
|
23
29
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
[
|
29
|
-
|
30
|
-
|
31
|
-
### Preview
|
32
|
-
#### ImageAnnotatorClient
|
33
|
-
```rb
|
34
|
-
require "google/cloud/vision"
|
35
|
-
|
36
|
-
image_annotator_client = Google::Cloud::Vision::ImageAnnotator.new
|
37
|
-
gcs_image_uri = "gs://cloud-samples-data/vision/face_detection/celebrity_recognition/sergey.jpg"
|
38
|
-
source = { gcs_image_uri: gcs_image_uri }
|
39
|
-
image = { source: source }
|
40
|
-
type = :FACE_DETECTION
|
41
|
-
features_element = { type: type }
|
42
|
-
features = [features_element]
|
43
|
-
requests_element = { image: image, features: features }
|
44
|
-
requests = [requests_element]
|
45
|
-
response = image_annotator_client.batch_annotate_images(requests)
|
46
|
-
```
|
30
|
+
In order to use this library, you first need to go through the following steps:
|
31
|
+
|
32
|
+
1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
33
|
+
1. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
|
34
|
+
1. [Enable the API.](https://console.cloud.google.com/apis/library/vision.googleapis.com)
|
35
|
+
1. {file:AUTHENTICATION.md Set up authentication.}
|
47
36
|
|
48
|
-
|
49
|
-
- Read the [Client Library Documentation][] for Cloud Vision API
|
50
|
-
to see other available methods on the client.
|
51
|
-
- Read the [Cloud Vision API Product documentation][Product Documentation]
|
52
|
-
to learn more about the product and see How-to Guides.
|
53
|
-
- View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
|
54
|
-
to see the full list of Cloud APIs that we cover.
|
37
|
+
## Migrating from 0.x versions
|
55
38
|
|
56
|
-
|
57
|
-
[
|
39
|
+
The 1.0 release of the google-cloud-vision client is a significant upgrade
|
40
|
+
based on a [next-gen code generator](https://github.com/googleapis/gapic-generator-ruby),
|
41
|
+
and includes substantial interface changes. Existing code written for earlier
|
42
|
+
versions of this library will likely require updates to use this version.
|
43
|
+
See the {file:MIGRATING.md MIGRATING.md} document for more information.
|
58
44
|
|
59
45
|
## Enabling Logging
|
60
46
|
|
61
47
|
To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
62
|
-
The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib
|
48
|
+
The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) as shown below,
|
63
49
|
or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
|
64
|
-
that will write logs to [
|
50
|
+
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)
|
65
51
|
and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
66
52
|
|
67
53
|
Configuring a Ruby stdlib logger:
|
@@ -1,4 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 Google LLC
|
2
4
|
#
|
3
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
6
|
# you may not use this file except in compliance with the License.
|
@@ -12,15 +14,6 @@
|
|
12
14
|
# See the License for the specific language governing permissions and
|
13
15
|
# limitations under the License.
|
14
16
|
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
15
18
|
|
16
|
-
|
17
|
-
module Protobuf
|
18
|
-
# Wrapper message for `float`.
|
19
|
-
#
|
20
|
-
# The JSON representation for `FloatValue` is JSON number.
|
21
|
-
# @!attribute [rw] value
|
22
|
-
# @return [Float]
|
23
|
-
# The float value.
|
24
|
-
class FloatValue; end
|
25
|
-
end
|
26
|
-
end
|
19
|
+
require "google/cloud/vision" unless defined? Google::Cloud::Vision::VERSION
|
data/lib/google/cloud/vision.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 Google LLC
|
2
4
|
#
|
3
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
6
|
# you may not use this file except in compliance with the License.
|
@@ -12,232 +14,147 @@
|
|
12
14
|
# See the License for the specific language governing permissions and
|
13
15
|
# limitations under the License.
|
14
16
|
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
# Require this file early so that the version constant gets defined before
|
20
|
+
# requiring "google/cloud". This is because google-cloud-core will load the
|
21
|
+
# entrypoint (gem name) file, which in turn re-requires this file (hence
|
22
|
+
# causing a require cycle) unless the version constant is already defined.
|
23
|
+
require "google/cloud/vision/version"
|
15
24
|
|
16
|
-
require "
|
17
|
-
|
25
|
+
require "googleauth"
|
26
|
+
gem "google-cloud-core"
|
27
|
+
require "google/cloud" unless defined? ::Google::Cloud.new
|
28
|
+
require "google/cloud/config"
|
29
|
+
|
30
|
+
# Set the default configuration
|
31
|
+
::Google::Cloud.configure.add_config! :vision do |config|
|
32
|
+
config.add_field! :endpoint, "vision.googleapis.com", match: ::String
|
33
|
+
config.add_field! :credentials, nil, match: [::String, ::Hash, ::Google::Auth::Credentials]
|
34
|
+
config.add_field! :scope, nil, match: [::Array, ::String]
|
35
|
+
config.add_field! :lib_name, nil, match: ::String
|
36
|
+
config.add_field! :lib_version, nil, match: ::String
|
37
|
+
config.add_field! :interceptors, nil, match: ::Array
|
38
|
+
config.add_field! :timeout, nil, match: ::Numeric
|
39
|
+
config.add_field! :metadata, nil, match: ::Hash
|
40
|
+
config.add_field! :retry_policy, nil, match: [::Hash, ::Proc]
|
41
|
+
config.add_field! :quota_project, nil, match: ::String
|
42
|
+
end
|
18
43
|
|
19
44
|
module Google
|
20
45
|
module Cloud
|
21
|
-
# rubocop:disable LineLength
|
22
|
-
|
23
|
-
##
|
24
|
-
# # Ruby Client for Cloud Vision API ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
|
25
|
-
#
|
26
|
-
# [Cloud Vision API][Product Documentation]:
|
27
|
-
# Integrates Google Vision features, including image labeling, face, logo,
|
28
|
-
# and landmark detection, optical character recognition (OCR), and detection
|
29
|
-
# of explicit content, into applications.
|
30
|
-
# - [Product Documentation][]
|
31
|
-
#
|
32
|
-
# ## Quick Start
|
33
|
-
# In order to use this library, you first need to go through the following
|
34
|
-
# steps:
|
35
|
-
#
|
36
|
-
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
37
|
-
# 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
|
38
|
-
# 3. [Enable the Cloud Vision API.](https://console.cloud.google.com/apis/library/vision.googleapis.com)
|
39
|
-
# 4. [Setup Authentication.](https://googleapis.dev/ruby/google-cloud-vision/latest/file.AUTHENTICATION.html)
|
40
|
-
#
|
41
|
-
# ### Installation
|
42
|
-
# ```
|
43
|
-
# $ gem install google-cloud-vision
|
44
|
-
# ```
|
45
|
-
#
|
46
|
-
# ### Migration Guide
|
47
|
-
#
|
48
|
-
# The 0.32.0 release introduced breaking changes relative to the previous
|
49
|
-
# release, 0.31.0. For more details and instructions to migrate your code,
|
50
|
-
# please visit the [migration
|
51
|
-
# guide](https://cloud.google.com/vision/docs/ruby-client-migration).
|
52
|
-
#
|
53
|
-
# ### Preview
|
54
|
-
# #### ImageAnnotatorClient
|
55
|
-
# ```rb
|
56
|
-
# require "google/cloud/vision"
|
57
|
-
#
|
58
|
-
# image_annotator_client = Google::Cloud::Vision::ImageAnnotator.new
|
59
|
-
# gcs_image_uri = "gs://cloud-samples-data/vision/face_detection/celebrity_recognition/sergey.jpg"
|
60
|
-
# source = { gcs_image_uri: gcs_image_uri }
|
61
|
-
# image = { source: source }
|
62
|
-
# type = :FACE_DETECTION
|
63
|
-
# features_element = { type: type }
|
64
|
-
# features = [features_element]
|
65
|
-
# requests_element = { image: image, features: features }
|
66
|
-
# requests = [requests_element]
|
67
|
-
# response = image_annotator_client.batch_annotate_images(requests)
|
68
|
-
# ```
|
69
|
-
#
|
70
|
-
# ### Next Steps
|
71
|
-
# - Read the [Cloud Vision API Product documentation][Product Documentation]
|
72
|
-
# to learn more about the product and see How-to Guides.
|
73
|
-
# - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
|
74
|
-
# to see the full list of Cloud APIs that we cover.
|
75
|
-
#
|
76
|
-
# [Product Documentation]: https://cloud.google.com/vision
|
77
|
-
#
|
78
|
-
# ## Enabling Logging
|
79
|
-
#
|
80
|
-
# To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
81
|
-
# The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
|
82
|
-
# or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
|
83
|
-
# that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
|
84
|
-
# and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
85
|
-
#
|
86
|
-
# Configuring a Ruby stdlib logger:
|
87
|
-
#
|
88
|
-
# ```ruby
|
89
|
-
# require "logger"
|
90
|
-
#
|
91
|
-
# module MyLogger
|
92
|
-
# LOGGER = Logger.new $stderr, level: Logger::WARN
|
93
|
-
# def logger
|
94
|
-
# LOGGER
|
95
|
-
# end
|
96
|
-
# end
|
97
|
-
#
|
98
|
-
# # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
99
|
-
# module GRPC
|
100
|
-
# extend MyLogger
|
101
|
-
# end
|
102
|
-
# ```
|
103
|
-
#
|
104
46
|
module Vision
|
105
|
-
|
106
|
-
|
107
|
-
|
47
|
+
##
|
48
|
+
# Create a new client object for ProductSearch.
|
49
|
+
#
|
50
|
+
# By default, this returns an instance of
|
51
|
+
# [Google::Cloud::Vision::V1::ProductSearch::Client](https://googleapis.dev/ruby/google-cloud-vision-v1/latest/Google/Cloud/Vision/V1/ProductSearch/Client.html)
|
52
|
+
# for version V1 of the API.
|
53
|
+
# However, you can specify specify a different API version by passing it in the
|
54
|
+
# `version` parameter. If the ProductSearch service is
|
55
|
+
# supported by that API version, and the corresponding gem is available, the
|
56
|
+
# appropriate versioned client will be returned.
|
57
|
+
#
|
58
|
+
# ## About ProductSearch
|
59
|
+
#
|
60
|
+
# Manages Products and ProductSets of reference images for use in product
|
61
|
+
# search. It uses the following resource model:
|
62
|
+
#
|
63
|
+
# - The API has a collection of ProductSet resources, named
|
64
|
+
# `projects/*/locations/*/productSets/*`, which acts as a way to put different
|
65
|
+
# products into groups to limit identification.
|
66
|
+
#
|
67
|
+
# In parallel,
|
68
|
+
#
|
69
|
+
# - The API has a collection of Product resources, named
|
70
|
+
# `projects/*/locations/*/products/*`
|
71
|
+
#
|
72
|
+
# - Each Product has a collection of ReferenceImage resources, named
|
73
|
+
# `projects/*/locations/*/products/*/referenceImages/*`
|
74
|
+
#
|
75
|
+
# @param version [::String, ::Symbol] The API version to connect to. Optional.
|
76
|
+
# Defaults to `:v1`.
|
77
|
+
# @return [ProductSearch::Client] A client object for the specified version.
|
78
|
+
#
|
79
|
+
def self.product_search version: :v1, &block
|
80
|
+
require "google/cloud/vision/#{version.to_s.downcase}"
|
108
81
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
82
|
+
package_name = Google::Cloud::Vision
|
83
|
+
.constants
|
84
|
+
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
|
85
|
+
.first
|
86
|
+
package_module = Google::Cloud::Vision.const_get package_name
|
87
|
+
package_module.const_get(:ProductSearch).const_get(:Client).new(&block)
|
88
|
+
end
|
114
89
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
# metadata for requests, generally, to give OAuth credentials.
|
139
|
-
# @param scopes [Array<String>]
|
140
|
-
# The OAuth scopes for this service. This parameter is ignored if
|
141
|
-
# an updater_proc is supplied.
|
142
|
-
# @param client_config [Hash]
|
143
|
-
# A Hash for call options for each method. See
|
144
|
-
# Google::Gax#construct_settings for the structure of
|
145
|
-
# this data. Falls back to the default config if not specified
|
146
|
-
# or the specified config is missing data points.
|
147
|
-
# @param timeout [Numeric]
|
148
|
-
# The default timeout, in seconds, for calls made through this client.
|
149
|
-
# @param metadata [Hash]
|
150
|
-
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
151
|
-
# @param service_address [String]
|
152
|
-
# Override for the service hostname, or `nil` to leave as the default.
|
153
|
-
# @param service_port [Integer]
|
154
|
-
# Override for the service port, or `nil` to leave as the default.
|
155
|
-
# @param exception_transformer [Proc]
|
156
|
-
# An optional proc that intercepts any exceptions raised during an API call to inject
|
157
|
-
# custom error handling.
|
158
|
-
def self.new(*args, version: :v1, **kwargs)
|
159
|
-
unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
|
160
|
-
raise "The version: #{version} is not available. The available versions " \
|
161
|
-
"are: [#{AVAILABLE_VERSIONS.join(", ")}]"
|
162
|
-
end
|
90
|
+
##
|
91
|
+
# Create a new client object for ImageAnnotator.
|
92
|
+
#
|
93
|
+
# By default, this returns an instance of
|
94
|
+
# [Google::Cloud::Vision::V1::ImageAnnotator::Client](https://googleapis.dev/ruby/google-cloud-vision-v1/latest/Google/Cloud/Vision/V1/ImageAnnotator/Client.html)
|
95
|
+
# for version V1 of the API.
|
96
|
+
# However, you can specify specify a different API version by passing it in the
|
97
|
+
# `version` parameter. If the ImageAnnotator service is
|
98
|
+
# supported by that API version, and the corresponding gem is available, the
|
99
|
+
# appropriate versioned client will be returned.
|
100
|
+
#
|
101
|
+
# ## About ImageAnnotator
|
102
|
+
#
|
103
|
+
# Service that performs Google Cloud Vision API detection tasks over client
|
104
|
+
# images, such as face, landmark, logo, label, and text detection. The
|
105
|
+
# ImageAnnotator service returns detected entities from the images.
|
106
|
+
#
|
107
|
+
# @param version [::String, ::Symbol] The API version to connect to. Optional.
|
108
|
+
# Defaults to `:v1`.
|
109
|
+
# @return [ImageAnnotator::Client] A client object for the specified version.
|
110
|
+
#
|
111
|
+
def self.image_annotator version: :v1, &block
|
112
|
+
require "google/cloud/vision/#{version.to_s.downcase}"
|
163
113
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
end
|
114
|
+
package_name = Google::Cloud::Vision
|
115
|
+
.constants
|
116
|
+
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
|
117
|
+
.first
|
118
|
+
package_module = Google::Cloud::Vision.const_get package_name
|
119
|
+
package_module.const_get(:ImageAnnotator).const_get(:Client).new(&block)
|
171
120
|
end
|
172
121
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
# A `GRPC::Core::Channel` will be used to make calls through.
|
204
|
-
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
205
|
-
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
206
|
-
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
207
|
-
# metadata for requests, generally, to give OAuth credentials.
|
208
|
-
# @param scopes [Array<String>]
|
209
|
-
# The OAuth scopes for this service. This parameter is ignored if
|
210
|
-
# an updater_proc is supplied.
|
211
|
-
# @param client_config [Hash]
|
212
|
-
# A Hash for call options for each method. See
|
213
|
-
# Google::Gax#construct_settings for the structure of
|
214
|
-
# this data. Falls back to the default config if not specified
|
215
|
-
# or the specified config is missing data points.
|
216
|
-
# @param timeout [Numeric]
|
217
|
-
# The default timeout, in seconds, for calls made through this client.
|
218
|
-
# @param metadata [Hash]
|
219
|
-
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
220
|
-
# @param service_address [String]
|
221
|
-
# Override for the service hostname, or `nil` to leave as the default.
|
222
|
-
# @param service_port [Integer]
|
223
|
-
# Override for the service port, or `nil` to leave as the default.
|
224
|
-
# @param exception_transformer [Proc]
|
225
|
-
# An optional proc that intercepts any exceptions raised during an API call to inject
|
226
|
-
# custom error handling.
|
227
|
-
def self.new(*args, version: :v1, **kwargs)
|
228
|
-
unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
|
229
|
-
raise "The version: #{version} is not available. The available versions " \
|
230
|
-
"are: [#{AVAILABLE_VERSIONS.join(", ")}]"
|
231
|
-
end
|
122
|
+
##
|
123
|
+
# Configure the google-cloud-vision library.
|
124
|
+
#
|
125
|
+
# The following configuration parameters are supported:
|
126
|
+
#
|
127
|
+
# * `credentials` (*type:* `String, Hash, Google::Auth::Credentials`) -
|
128
|
+
# The path to the keyfile as a String, the contents of the keyfile as a
|
129
|
+
# Hash, or a Google::Auth::Credentials object.
|
130
|
+
# * `lib_name` (*type:* `String`) -
|
131
|
+
# The library name as recorded in instrumentation and logging.
|
132
|
+
# * `lib_version` (*type:* `String`) -
|
133
|
+
# The library version as recorded in instrumentation and logging.
|
134
|
+
# * `interceptors` (*type:* `Array<GRPC::ClientInterceptor>`) -
|
135
|
+
# An array of interceptors that are run before calls are executed.
|
136
|
+
# * `timeout` (*type:* `Numeric`) -
|
137
|
+
# Default timeout in seconds.
|
138
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) -
|
139
|
+
# Additional gRPC headers to be sent with the call.
|
140
|
+
# * `retry_policy` (*type:* `Hash`) -
|
141
|
+
# The retry policy. The value is a hash with the following keys:
|
142
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
143
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
144
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
145
|
+
# * `:retry_codes` (*type:* `Array<String>`) -
|
146
|
+
# The error codes that should trigger a retry.
|
147
|
+
#
|
148
|
+
# @return [::Google::Cloud::Config] The default configuration used by this library
|
149
|
+
#
|
150
|
+
def self.configure
|
151
|
+
yield ::Google::Cloud.configure.vision if block_given?
|
232
152
|
|
233
|
-
|
234
|
-
version_module = Google::Cloud::Vision
|
235
|
-
.constants
|
236
|
-
.select {|sym| sym.to_s.downcase == version.to_s.downcase}
|
237
|
-
.first
|
238
|
-
Google::Cloud::Vision.const_get(version_module)::ProductSearch.new(*args, **kwargs)
|
239
|
-
end
|
153
|
+
::Google::Cloud.configure.vision
|
240
154
|
end
|
241
155
|
end
|
242
156
|
end
|
243
157
|
end
|
158
|
+
|
159
|
+
helper_path = ::File.join __dir__, "vision", "helpers.rb"
|
160
|
+
require "google/cloud/vision/helpers" if ::File.file? helper_path
|