google-cloud-automl 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +11 -0
- data/AUTHENTICATION.md +199 -0
- data/LICENSE +201 -0
- data/README.md +69 -0
- data/lib/google/cloud/automl/v1beta1/annotation_payload_pb.rb +34 -0
- data/lib/google/cloud/automl/v1beta1/annotation_spec_pb.rb +18 -0
- data/lib/google/cloud/automl/v1beta1/automl_client.rb +1914 -0
- data/lib/google/cloud/automl/v1beta1/automl_client_config.json +146 -0
- data/lib/google/cloud/automl/v1beta1/classification_pb.rb +65 -0
- data/lib/google/cloud/automl/v1beta1/column_spec_pb.rb +28 -0
- data/lib/google/cloud/automl/v1beta1/credentials.rb +41 -0
- data/lib/google/cloud/automl/v1beta1/data_items_pb.rb +48 -0
- data/lib/google/cloud/automl/v1beta1/data_stats_pb.rb +77 -0
- data/lib/google/cloud/automl/v1beta1/data_types_pb.rb +36 -0
- data/lib/google/cloud/automl/v1beta1/dataset_pb.rb +38 -0
- data/lib/google/cloud/automl/v1beta1/detection_pb.rb +52 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/annotation_payload.rb +63 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/annotation_spec.rb +41 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/classification.rb +203 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/column_spec.rb +72 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/data_items.rb +94 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/data_stats.rb +160 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/data_types.rb +107 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/dataset.rb +77 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/detection.rb +134 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/geometry.rb +43 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/image.rb +141 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/io.rb +975 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/model.rb +92 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/model_evaluation.rb +100 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/prediction_service.rb +136 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/ranges.rb +31 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/regression.rb +41 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/service.rb +368 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/table_spec.rb +64 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/tables.rb +261 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/temporal.rb +33 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/text.rb +53 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/text_extraction.rb +60 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/text_segment.rb +37 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/text_sentiment.rb +76 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/translation.rb +63 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/video.rb +35 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/longrunning/operations.rb +51 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/protobuf/any.rb +131 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/protobuf/duration.rb +91 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/protobuf/field_mask.rb +222 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/protobuf/struct.rb +74 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/protobuf/timestamp.rb +111 -0
- data/lib/google/cloud/automl/v1beta1/doc/google/rpc/status.rb +87 -0
- data/lib/google/cloud/automl/v1beta1/geometry_pb.rb +21 -0
- data/lib/google/cloud/automl/v1beta1/image_pb.rb +43 -0
- data/lib/google/cloud/automl/v1beta1/io_pb.rb +80 -0
- data/lib/google/cloud/automl/v1beta1/model_evaluation_pb.rb +37 -0
- data/lib/google/cloud/automl/v1beta1/model_pb.rb +44 -0
- data/lib/google/cloud/automl/v1beta1/operations_pb.rb +90 -0
- data/lib/google/cloud/automl/v1beta1/prediction_service_client.rb +442 -0
- data/lib/google/cloud/automl/v1beta1/prediction_service_client_config.json +36 -0
- data/lib/google/cloud/automl/v1beta1/prediction_service_pb.rb +39 -0
- data/lib/google/cloud/automl/v1beta1/prediction_service_services_pb.rb +72 -0
- data/lib/google/cloud/automl/v1beta1/ranges_pb.rb +17 -0
- data/lib/google/cloud/automl/v1beta1/regression_pb.rb +20 -0
- data/lib/google/cloud/automl/v1beta1/service_pb.rb +177 -0
- data/lib/google/cloud/automl/v1beta1/service_services_pb.rb +159 -0
- data/lib/google/cloud/automl/v1beta1/table_spec_pb.rb +22 -0
- data/lib/google/cloud/automl/v1beta1/tables_pb.rb +56 -0
- data/lib/google/cloud/automl/v1beta1/temporal_pb.rb +18 -0
- data/lib/google/cloud/automl/v1beta1/text_extraction_pb.rb +32 -0
- data/lib/google/cloud/automl/v1beta1/text_pb.rb +33 -0
- data/lib/google/cloud/automl/v1beta1/text_segment_pb.rb +18 -0
- data/lib/google/cloud/automl/v1beta1/text_sentiment_pb.rb +29 -0
- data/lib/google/cloud/automl/v1beta1/translation_pb.rb +33 -0
- data/lib/google/cloud/automl/v1beta1/video_pb.rb +25 -0
- data/lib/google/cloud/automl/v1beta1.rb +231 -0
- data/lib/google/cloud/automl/version.rb +22 -0
- data/lib/google/cloud/automl.rb +219 -0
- data/lib/google-cloud-automl.rb +15 -0
- metadata +203 -0
@@ -0,0 +1,231 @@
|
|
1
|
+
# Copyright 2019 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
require "google/cloud/automl/v1beta1/automl_client"
|
17
|
+
require "google/cloud/automl/v1beta1/prediction_service_client"
|
18
|
+
require "google/cloud/automl/v1beta1/prediction_service_pb"
|
19
|
+
require "google/cloud/automl/v1beta1/operations_pb"
|
20
|
+
|
21
|
+
module Google
|
22
|
+
module Cloud
|
23
|
+
module AutoML
|
24
|
+
# rubocop:disable LineLength
|
25
|
+
|
26
|
+
##
|
27
|
+
# # Ruby Client for Cloud AutoML API ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
|
28
|
+
#
|
29
|
+
# [Cloud AutoML API][Product Documentation]:
|
30
|
+
# Train high-quality custom machine learning models with minimum effort and
|
31
|
+
# machine learning expertise.
|
32
|
+
# - [Product Documentation][]
|
33
|
+
#
|
34
|
+
# ## Quick Start
|
35
|
+
# In order to use this library, you first need to go through the following
|
36
|
+
# steps:
|
37
|
+
#
|
38
|
+
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
39
|
+
# 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
|
40
|
+
# 3. [Enable the Cloud AutoML API.](https://console.cloud.google.com/apis/library/automl.googleapis.com)
|
41
|
+
# 4. [Setup Authentication.](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
42
|
+
#
|
43
|
+
# ### Installation
|
44
|
+
# ```
|
45
|
+
# $ gem install google-cloud-automl
|
46
|
+
# ```
|
47
|
+
#
|
48
|
+
# ### Next Steps
|
49
|
+
# - Read the [Cloud AutoML API Product documentation][Product Documentation]
|
50
|
+
# to learn more about the product and see How-to Guides.
|
51
|
+
# - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
|
52
|
+
# to see the full list of Cloud APIs that we cover.
|
53
|
+
#
|
54
|
+
# [Product Documentation]: https://cloud.google.com/automl
|
55
|
+
#
|
56
|
+
# ## Enabling Logging
|
57
|
+
#
|
58
|
+
# To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
59
|
+
# 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,
|
60
|
+
# or a [`Google::Cloud::Logging::Logger`](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
|
61
|
+
# 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)
|
62
|
+
# and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
63
|
+
#
|
64
|
+
# Configuring a Ruby stdlib logger:
|
65
|
+
#
|
66
|
+
# ```ruby
|
67
|
+
# require "logger"
|
68
|
+
#
|
69
|
+
# module MyLogger
|
70
|
+
# LOGGER = Logger.new $stderr, level: Logger::WARN
|
71
|
+
# def logger
|
72
|
+
# LOGGER
|
73
|
+
# end
|
74
|
+
# end
|
75
|
+
#
|
76
|
+
# # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
77
|
+
# module GRPC
|
78
|
+
# extend MyLogger
|
79
|
+
# end
|
80
|
+
# ```
|
81
|
+
#
|
82
|
+
module V1beta1
|
83
|
+
# rubocop:enable LineLength
|
84
|
+
|
85
|
+
module AutoML
|
86
|
+
##
|
87
|
+
# AutoML Server API.
|
88
|
+
#
|
89
|
+
# The resource names are assigned by the server.
|
90
|
+
# The server never reuses names that it has created after the resources with
|
91
|
+
# those names are deleted.
|
92
|
+
#
|
93
|
+
# An ID of a resource is the last element of the item's resource name. For
|
94
|
+
# `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`, then
|
95
|
+
# the id for the item is `{dataset_id}`.
|
96
|
+
#
|
97
|
+
# Currently the only supported `location_id` is "us-central1".
|
98
|
+
#
|
99
|
+
# On any input that is documented to expect a string parameter in
|
100
|
+
# snake_case or kebab-case, either of those cases is accepted.
|
101
|
+
#
|
102
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
103
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
104
|
+
# be many types.
|
105
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
106
|
+
# authenticating requests made by this client.
|
107
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
108
|
+
# credentials for this client.
|
109
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
110
|
+
# credentials for this client.
|
111
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
112
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
113
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
114
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
115
|
+
# metadata for requests, generally, to give OAuth credentials.
|
116
|
+
# @param scopes [Array<String>]
|
117
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
118
|
+
# an updater_proc is supplied.
|
119
|
+
# @param client_config [Hash]
|
120
|
+
# A Hash for call options for each method. See
|
121
|
+
# Google::Gax#construct_settings for the structure of
|
122
|
+
# this data. Falls back to the default config if not specified
|
123
|
+
# or the specified config is missing data points.
|
124
|
+
# @param timeout [Numeric]
|
125
|
+
# The default timeout, in seconds, for calls made through this client.
|
126
|
+
# @param metadata [Hash]
|
127
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
128
|
+
# @param service_address [String]
|
129
|
+
# Override for the service hostname, or `nil` to leave as the default.
|
130
|
+
# @param service_port [Integer]
|
131
|
+
# Override for the service port, or `nil` to leave as the default.
|
132
|
+
# @param exception_transformer [Proc]
|
133
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
134
|
+
# custom error handling.
|
135
|
+
def self.new \
|
136
|
+
credentials: nil,
|
137
|
+
scopes: nil,
|
138
|
+
client_config: nil,
|
139
|
+
timeout: nil,
|
140
|
+
metadata: nil,
|
141
|
+
service_address: nil,
|
142
|
+
service_port: nil,
|
143
|
+
exception_transformer: nil,
|
144
|
+
lib_name: nil,
|
145
|
+
lib_version: nil
|
146
|
+
kwargs = {
|
147
|
+
credentials: credentials,
|
148
|
+
scopes: scopes,
|
149
|
+
client_config: client_config,
|
150
|
+
timeout: timeout,
|
151
|
+
metadata: metadata,
|
152
|
+
exception_transformer: exception_transformer,
|
153
|
+
lib_name: lib_name,
|
154
|
+
service_address: service_address,
|
155
|
+
service_port: service_port,
|
156
|
+
lib_version: lib_version
|
157
|
+
}.select { |_, v| v != nil }
|
158
|
+
Google::Cloud::AutoML::V1beta1::AutoMLClient.new(**kwargs)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
module Prediction
|
163
|
+
##
|
164
|
+
# AutoML Prediction API.
|
165
|
+
#
|
166
|
+
# On any input that is documented to expect a string parameter in
|
167
|
+
# snake_case or kebab-case, either of those cases is accepted.
|
168
|
+
#
|
169
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
170
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
171
|
+
# be many types.
|
172
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
173
|
+
# authenticating requests made by this client.
|
174
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
175
|
+
# credentials for this client.
|
176
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
177
|
+
# credentials for this client.
|
178
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
179
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
180
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
181
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
182
|
+
# metadata for requests, generally, to give OAuth credentials.
|
183
|
+
# @param scopes [Array<String>]
|
184
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
185
|
+
# an updater_proc is supplied.
|
186
|
+
# @param client_config [Hash]
|
187
|
+
# A Hash for call options for each method. See
|
188
|
+
# Google::Gax#construct_settings for the structure of
|
189
|
+
# this data. Falls back to the default config if not specified
|
190
|
+
# or the specified config is missing data points.
|
191
|
+
# @param timeout [Numeric]
|
192
|
+
# The default timeout, in seconds, for calls made through this client.
|
193
|
+
# @param metadata [Hash]
|
194
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
195
|
+
# @param service_address [String]
|
196
|
+
# Override for the service hostname, or `nil` to leave as the default.
|
197
|
+
# @param service_port [Integer]
|
198
|
+
# Override for the service port, or `nil` to leave as the default.
|
199
|
+
# @param exception_transformer [Proc]
|
200
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
201
|
+
# custom error handling.
|
202
|
+
def self.new \
|
203
|
+
credentials: nil,
|
204
|
+
scopes: nil,
|
205
|
+
client_config: nil,
|
206
|
+
timeout: nil,
|
207
|
+
metadata: nil,
|
208
|
+
service_address: nil,
|
209
|
+
service_port: nil,
|
210
|
+
exception_transformer: nil,
|
211
|
+
lib_name: nil,
|
212
|
+
lib_version: nil
|
213
|
+
kwargs = {
|
214
|
+
credentials: credentials,
|
215
|
+
scopes: scopes,
|
216
|
+
client_config: client_config,
|
217
|
+
timeout: timeout,
|
218
|
+
metadata: metadata,
|
219
|
+
exception_transformer: exception_transformer,
|
220
|
+
lib_name: lib_name,
|
221
|
+
service_address: service_address,
|
222
|
+
service_port: service_port,
|
223
|
+
lib_version: lib_version
|
224
|
+
}.select { |_, v| v != nil }
|
225
|
+
Google::Cloud::AutoML::V1beta1::PredictionServiceClient.new(**kwargs)
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Copyright 2019 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
module Google
|
17
|
+
module Cloud
|
18
|
+
module AutoML
|
19
|
+
VERSION = "0.1.0".freeze
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,219 @@
|
|
1
|
+
# Copyright 2019 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
require "google/gax"
|
17
|
+
require "pathname"
|
18
|
+
|
19
|
+
module Google
|
20
|
+
module Cloud
|
21
|
+
# rubocop:disable LineLength
|
22
|
+
|
23
|
+
##
|
24
|
+
# # Ruby Client for Cloud AutoML API ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
|
25
|
+
#
|
26
|
+
# [Cloud AutoML API][Product Documentation]:
|
27
|
+
# Train high-quality custom machine learning models with minimum effort and
|
28
|
+
# machine learning expertise.
|
29
|
+
# - [Product Documentation][]
|
30
|
+
#
|
31
|
+
# ## Quick Start
|
32
|
+
# In order to use this library, you first need to go through the following
|
33
|
+
# steps:
|
34
|
+
#
|
35
|
+
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
36
|
+
# 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
|
37
|
+
# 3. [Enable the Cloud AutoML API.](https://console.cloud.google.com/apis/library/automl.googleapis.com)
|
38
|
+
# 4. [Setup Authentication.](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
39
|
+
#
|
40
|
+
# ### Installation
|
41
|
+
# ```
|
42
|
+
# $ gem install google-cloud-automl
|
43
|
+
# ```
|
44
|
+
#
|
45
|
+
# ### Next Steps
|
46
|
+
# - Read the [Cloud AutoML API Product documentation][Product Documentation]
|
47
|
+
# to learn more about the product and see How-to Guides.
|
48
|
+
# - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
|
49
|
+
# to see the full list of Cloud APIs that we cover.
|
50
|
+
#
|
51
|
+
# [Product Documentation]: https://cloud.google.com/automl
|
52
|
+
#
|
53
|
+
# ## Enabling Logging
|
54
|
+
#
|
55
|
+
# To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
56
|
+
# 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,
|
57
|
+
# or a [`Google::Cloud::Logging::Logger`](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
|
58
|
+
# 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)
|
59
|
+
# and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
60
|
+
#
|
61
|
+
# Configuring a Ruby stdlib logger:
|
62
|
+
#
|
63
|
+
# ```ruby
|
64
|
+
# require "logger"
|
65
|
+
#
|
66
|
+
# module MyLogger
|
67
|
+
# LOGGER = Logger.new $stderr, level: Logger::WARN
|
68
|
+
# def logger
|
69
|
+
# LOGGER
|
70
|
+
# end
|
71
|
+
# end
|
72
|
+
#
|
73
|
+
# # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
74
|
+
# module GRPC
|
75
|
+
# extend MyLogger
|
76
|
+
# end
|
77
|
+
# ```
|
78
|
+
#
|
79
|
+
module AutoML
|
80
|
+
# rubocop:enable LineLength
|
81
|
+
|
82
|
+
FILE_DIR = File.realdirpath(Pathname.new(__FILE__).join("..").join("automl"))
|
83
|
+
|
84
|
+
AVAILABLE_VERSIONS = Dir["#{FILE_DIR}/*"]
|
85
|
+
.select { |file| File.directory?(file) }
|
86
|
+
.select { |dir| Google::Gax::VERSION_MATCHER.match(File.basename(dir)) }
|
87
|
+
.select { |dir| File.exist?(dir + ".rb") }
|
88
|
+
.map { |dir| File.basename(dir) }
|
89
|
+
|
90
|
+
module AutoML
|
91
|
+
##
|
92
|
+
# AutoML Server API.
|
93
|
+
#
|
94
|
+
# The resource names are assigned by the server.
|
95
|
+
# The server never reuses names that it has created after the resources with
|
96
|
+
# those names are deleted.
|
97
|
+
#
|
98
|
+
# An ID of a resource is the last element of the item's resource name. For
|
99
|
+
# `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`, then
|
100
|
+
# the id for the item is `{dataset_id}`.
|
101
|
+
#
|
102
|
+
# Currently the only supported `location_id` is "us-central1".
|
103
|
+
#
|
104
|
+
# On any input that is documented to expect a string parameter in
|
105
|
+
# snake_case or kebab-case, either of those cases is accepted.
|
106
|
+
#
|
107
|
+
# @param version [Symbol, String]
|
108
|
+
# The major version of the service to be used. By default :v1beta1
|
109
|
+
# is used.
|
110
|
+
# @overload new(version:, credentials:, scopes:, client_config:, timeout:)
|
111
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
112
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
113
|
+
# be many types.
|
114
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
115
|
+
# authenticating requests made by this client.
|
116
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
117
|
+
# credentials for this client.
|
118
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
119
|
+
# credentials for this client.
|
120
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
121
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
122
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
123
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
124
|
+
# metadata for requests, generally, to give OAuth credentials.
|
125
|
+
# @param scopes [Array<String>]
|
126
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
127
|
+
# an updater_proc is supplied.
|
128
|
+
# @param client_config [Hash]
|
129
|
+
# A Hash for call options for each method. See
|
130
|
+
# Google::Gax#construct_settings for the structure of
|
131
|
+
# this data. Falls back to the default config if not specified
|
132
|
+
# or the specified config is missing data points.
|
133
|
+
# @param timeout [Numeric]
|
134
|
+
# The default timeout, in seconds, for calls made through this client.
|
135
|
+
# @param metadata [Hash]
|
136
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
137
|
+
# @param service_address [String]
|
138
|
+
# Override for the service hostname, or `nil` to leave as the default.
|
139
|
+
# @param service_port [Integer]
|
140
|
+
# Override for the service port, or `nil` to leave as the default.
|
141
|
+
# @param exception_transformer [Proc]
|
142
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
143
|
+
# custom error handling.
|
144
|
+
def self.new(*args, version: :v1beta1, **kwargs)
|
145
|
+
unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
|
146
|
+
raise "The version: #{version} is not available. The available versions " \
|
147
|
+
"are: [#{AVAILABLE_VERSIONS.join(", ")}]"
|
148
|
+
end
|
149
|
+
|
150
|
+
require "#{FILE_DIR}/#{version.to_s.downcase}"
|
151
|
+
version_module = Google::Cloud::AutoML
|
152
|
+
.constants
|
153
|
+
.select {|sym| sym.to_s.downcase == version.to_s.downcase}
|
154
|
+
.first
|
155
|
+
Google::Cloud::AutoML.const_get(version_module)::AutoML.new(*args, **kwargs)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
module Prediction
|
160
|
+
##
|
161
|
+
# AutoML Prediction API.
|
162
|
+
#
|
163
|
+
# On any input that is documented to expect a string parameter in
|
164
|
+
# snake_case or kebab-case, either of those cases is accepted.
|
165
|
+
#
|
166
|
+
# @param version [Symbol, String]
|
167
|
+
# The major version of the service to be used. By default :v1beta1
|
168
|
+
# is used.
|
169
|
+
# @overload new(version:, credentials:, scopes:, client_config:, timeout:)
|
170
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
171
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
172
|
+
# be many types.
|
173
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
174
|
+
# authenticating requests made by this client.
|
175
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
176
|
+
# credentials for this client.
|
177
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
178
|
+
# credentials for this client.
|
179
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
180
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
181
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
182
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
183
|
+
# metadata for requests, generally, to give OAuth credentials.
|
184
|
+
# @param scopes [Array<String>]
|
185
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
186
|
+
# an updater_proc is supplied.
|
187
|
+
# @param client_config [Hash]
|
188
|
+
# A Hash for call options for each method. See
|
189
|
+
# Google::Gax#construct_settings for the structure of
|
190
|
+
# this data. Falls back to the default config if not specified
|
191
|
+
# or the specified config is missing data points.
|
192
|
+
# @param timeout [Numeric]
|
193
|
+
# The default timeout, in seconds, for calls made through this client.
|
194
|
+
# @param metadata [Hash]
|
195
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
196
|
+
# @param service_address [String]
|
197
|
+
# Override for the service hostname, or `nil` to leave as the default.
|
198
|
+
# @param service_port [Integer]
|
199
|
+
# Override for the service port, or `nil` to leave as the default.
|
200
|
+
# @param exception_transformer [Proc]
|
201
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
202
|
+
# custom error handling.
|
203
|
+
def self.new(*args, version: :v1beta1, **kwargs)
|
204
|
+
unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
|
205
|
+
raise "The version: #{version} is not available. The available versions " \
|
206
|
+
"are: [#{AVAILABLE_VERSIONS.join(", ")}]"
|
207
|
+
end
|
208
|
+
|
209
|
+
require "#{FILE_DIR}/#{version.to_s.downcase}"
|
210
|
+
version_module = Google::Cloud::AutoML
|
211
|
+
.constants
|
212
|
+
.select {|sym| sym.to_s.downcase == version.to_s.downcase}
|
213
|
+
.first
|
214
|
+
Google::Cloud::AutoML.const_get(version_module)::Prediction.new(*args, **kwargs)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Copyright 2019 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require "google/cloud/automl"
|