google-cloud-automl-v1beta1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +169 -0
  4. data/LICENSE.md +203 -0
  5. data/README.md +71 -0
  6. data/lib/google-cloud-automl-v1beta1.rb +21 -0
  7. data/lib/google/cloud/automl/v1beta1.rb +36 -0
  8. data/lib/google/cloud/automl/v1beta1/annotation_payload_pb.rb +41 -0
  9. data/lib/google/cloud/automl/v1beta1/annotation_spec_pb.rb +26 -0
  10. data/lib/google/cloud/automl/v1beta1/automl.rb +63 -0
  11. data/lib/google/cloud/automl/v1beta1/automl/client.rb +2368 -0
  12. data/lib/google/cloud/automl/v1beta1/automl/credentials.rb +51 -0
  13. data/lib/google/cloud/automl/v1beta1/automl/operations.rb +564 -0
  14. data/lib/google/cloud/automl/v1beta1/automl/paths.rb +174 -0
  15. data/lib/google/cloud/automl/v1beta1/classification_pb.rb +73 -0
  16. data/lib/google/cloud/automl/v1beta1/column_spec_pb.rb +36 -0
  17. data/lib/google/cloud/automl/v1beta1/data_items_pb.rb +95 -0
  18. data/lib/google/cloud/automl/v1beta1/data_stats_pb.rb +84 -0
  19. data/lib/google/cloud/automl/v1beta1/data_types_pb.rb +43 -0
  20. data/lib/google/cloud/automl/v1beta1/dataset_pb.rb +46 -0
  21. data/lib/google/cloud/automl/v1beta1/detection_pb.rb +59 -0
  22. data/lib/google/cloud/automl/v1beta1/geometry_pb.rb +28 -0
  23. data/lib/google/cloud/automl/v1beta1/image_pb.rb +57 -0
  24. data/lib/google/cloud/automl/v1beta1/io_pb.rb +87 -0
  25. data/lib/google/cloud/automl/v1beta1/model_evaluation_pb.rb +45 -0
  26. data/lib/google/cloud/automl/v1beta1/model_pb.rb +52 -0
  27. data/lib/google/cloud/automl/v1beta1/operations_pb.rb +97 -0
  28. data/lib/google/cloud/automl/v1beta1/prediction_service.rb +53 -0
  29. data/lib/google/cloud/automl/v1beta1/prediction_service/client.rb +586 -0
  30. data/lib/google/cloud/automl/v1beta1/prediction_service/credentials.rb +51 -0
  31. data/lib/google/cloud/automl/v1beta1/prediction_service/operations.rb +564 -0
  32. data/lib/google/cloud/automl/v1beta1/prediction_service/paths.rb +52 -0
  33. data/lib/google/cloud/automl/v1beta1/prediction_service_pb.rb +50 -0
  34. data/lib/google/cloud/automl/v1beta1/prediction_service_services_pb.rb +79 -0
  35. data/lib/google/cloud/automl/v1beta1/ranges_pb.rb +24 -0
  36. data/lib/google/cloud/automl/v1beta1/regression_pb.rb +27 -0
  37. data/lib/google/cloud/automl/v1beta1/service_pb.rb +187 -0
  38. data/lib/google/cloud/automl/v1beta1/service_services_pb.rb +163 -0
  39. data/lib/google/cloud/automl/v1beta1/table_spec_pb.rb +31 -0
  40. data/lib/google/cloud/automl/v1beta1/tables_pb.rb +65 -0
  41. data/lib/google/cloud/automl/v1beta1/temporal_pb.rb +25 -0
  42. data/lib/google/cloud/automl/v1beta1/text_extraction_pb.rb +39 -0
  43. data/lib/google/cloud/automl/v1beta1/text_pb.rb +41 -0
  44. data/lib/google/cloud/automl/v1beta1/text_segment_pb.rb +25 -0
  45. data/lib/google/cloud/automl/v1beta1/text_sentiment_pb.rb +36 -0
  46. data/lib/google/cloud/automl/v1beta1/translation_pb.rb +41 -0
  47. data/lib/google/cloud/automl/v1beta1/version.rb +28 -0
  48. data/lib/google/cloud/automl/v1beta1/video_pb.rb +32 -0
  49. data/lib/google/cloud/common_resources_pb.rb +15 -0
  50. data/proto_docs/README.md +4 -0
  51. data/proto_docs/google/api/field_behavior.rb +59 -0
  52. data/proto_docs/google/api/resource.rb +247 -0
  53. data/proto_docs/google/cloud/automl/v1beta1/annotation_payload.rb +70 -0
  54. data/proto_docs/google/cloud/automl/v1beta1/annotation_spec.rb +46 -0
  55. data/proto_docs/google/cloud/automl/v1beta1/classification.rb +234 -0
  56. data/proto_docs/google/cloud/automl/v1beta1/column_spec.rb +77 -0
  57. data/proto_docs/google/cloud/automl/v1beta1/data_items.rb +227 -0
  58. data/proto_docs/google/cloud/automl/v1beta1/data_stats.rb +227 -0
  59. data/proto_docs/google/cloud/automl/v1beta1/data_types.rb +118 -0
  60. data/proto_docs/google/cloud/automl/v1beta1/dataset.rb +84 -0
  61. data/proto_docs/google/cloud/automl/v1beta1/detection.rb +152 -0
  62. data/proto_docs/google/cloud/automl/v1beta1/geometry.rb +53 -0
  63. data/proto_docs/google/cloud/automl/v1beta1/image.rb +205 -0
  64. data/proto_docs/google/cloud/automl/v1beta1/io.rb +1168 -0
  65. data/proto_docs/google/cloud/automl/v1beta1/model.rb +95 -0
  66. data/proto_docs/google/cloud/automl/v1beta1/model_evaluation.rb +103 -0
  67. data/proto_docs/google/cloud/automl/v1beta1/operations.rb +206 -0
  68. data/proto_docs/google/cloud/automl/v1beta1/prediction_service.rb +238 -0
  69. data/proto_docs/google/cloud/automl/v1beta1/ranges.rb +38 -0
  70. data/proto_docs/google/cloud/automl/v1beta1/regression.rb +48 -0
  71. data/proto_docs/google/cloud/automl/v1beta1/service.rb +447 -0
  72. data/proto_docs/google/cloud/automl/v1beta1/table_spec.rb +75 -0
  73. data/proto_docs/google/cloud/automl/v1beta1/tables.rb +300 -0
  74. data/proto_docs/google/cloud/automl/v1beta1/temporal.rb +40 -0
  75. data/proto_docs/google/cloud/automl/v1beta1/text.rb +76 -0
  76. data/proto_docs/google/cloud/automl/v1beta1/text_extraction.rb +73 -0
  77. data/proto_docs/google/cloud/automl/v1beta1/text_segment.rb +44 -0
  78. data/proto_docs/google/cloud/automl/v1beta1/text_sentiment.rb +86 -0
  79. data/proto_docs/google/cloud/automl/v1beta1/translation.rb +79 -0
  80. data/proto_docs/google/cloud/automl/v1beta1/video.rb +51 -0
  81. data/proto_docs/google/longrunning/operations.rb +150 -0
  82. data/proto_docs/google/protobuf/any.rb +138 -0
  83. data/proto_docs/google/protobuf/duration.rb +98 -0
  84. data/proto_docs/google/protobuf/empty.rb +36 -0
  85. data/proto_docs/google/protobuf/field_mask.rb +229 -0
  86. data/proto_docs/google/protobuf/struct.rb +96 -0
  87. data/proto_docs/google/protobuf/timestamp.rb +120 -0
  88. data/proto_docs/google/rpc/status.rb +46 -0
  89. metadata +245 -0
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/automl/v1beta1/version"
24
+
25
+ require "google/cloud/automl/v1beta1/prediction_service/credentials"
26
+ require "google/cloud/automl/v1beta1/prediction_service/paths"
27
+ require "google/cloud/automl/v1beta1/prediction_service/operations"
28
+ require "google/cloud/automl/v1beta1/prediction_service/client"
29
+
30
+ module Google
31
+ module Cloud
32
+ module AutoML
33
+ module V1beta1
34
+ ##
35
+ # AutoML Prediction API.
36
+ #
37
+ # On any input that is documented to expect a string parameter in
38
+ # snake_case or kebab-case, either of those cases is accepted.
39
+ #
40
+ # To load this service and instantiate a client:
41
+ #
42
+ # require "google/cloud/automl/v1beta1/prediction_service"
43
+ # client = Google::Cloud::AutoML::V1beta1::PredictionService::Client.new
44
+ #
45
+ module PredictionService
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ helper_path = ::File.join __dir__, "prediction_service", "helpers.rb"
53
+ require "google/cloud/automl/v1beta1/prediction_service/helpers" if ::File.file? helper_path
@@ -0,0 +1,586 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/cloud/automl/v1beta1/prediction_service_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module AutoML
25
+ module V1beta1
26
+ module PredictionService
27
+ ##
28
+ # Client for the PredictionService service.
29
+ #
30
+ # AutoML Prediction API.
31
+ #
32
+ # On any input that is documented to expect a string parameter in
33
+ # snake_case or kebab-case, either of those cases is accepted.
34
+ #
35
+ class Client
36
+ include Paths
37
+
38
+ # @private
39
+ attr_reader :prediction_service_stub
40
+
41
+ ##
42
+ # Configure the PredictionService Client class.
43
+ #
44
+ # See {Google::Cloud::AutoML::V1beta1::PredictionService::Client::Configuration}
45
+ # for a description of the configuration fields.
46
+ #
47
+ # ## Example
48
+ #
49
+ # To modify the configuration for all PredictionService clients:
50
+ #
51
+ # Google::Cloud::AutoML::V1beta1::PredictionService::Client.configure do |config|
52
+ # config.timeout = 10_000
53
+ # end
54
+ #
55
+ # @yield [config] Configure the Client client.
56
+ # @yieldparam config [Client::Configuration]
57
+ #
58
+ # @return [Client::Configuration]
59
+ #
60
+ def self.configure
61
+ @configure ||= begin
62
+ namespace = ["Google", "Cloud", "AutoML", "V1beta1"]
63
+ parent_config = while namespace.any?
64
+ parent_name = namespace.join "::"
65
+ parent_const = const_get parent_name
66
+ break parent_const.configure if parent_const&.respond_to? :configure
67
+ namespace.pop
68
+ end
69
+ default_config = Client::Configuration.new parent_config
70
+
71
+ default_config.rpcs.predict.timeout = 60.0
72
+
73
+ default_config.rpcs.batch_predict.timeout = 60.0
74
+
75
+ default_config
76
+ end
77
+ yield @configure if block_given?
78
+ @configure
79
+ end
80
+
81
+ ##
82
+ # Configure the PredictionService Client instance.
83
+ #
84
+ # The configuration is set to the derived mode, meaning that values can be changed,
85
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
86
+ # should be made on {Client.configure}.
87
+ #
88
+ # See {Google::Cloud::AutoML::V1beta1::PredictionService::Client::Configuration}
89
+ # for a description of the configuration fields.
90
+ #
91
+ # @yield [config] Configure the Client client.
92
+ # @yieldparam config [Client::Configuration]
93
+ #
94
+ # @return [Client::Configuration]
95
+ #
96
+ def configure
97
+ yield @config if block_given?
98
+ @config
99
+ end
100
+
101
+ ##
102
+ # Create a new PredictionService client object.
103
+ #
104
+ # ## Examples
105
+ #
106
+ # To create a new PredictionService client with the default
107
+ # configuration:
108
+ #
109
+ # client = Google::Cloud::AutoML::V1beta1::PredictionService::Client.new
110
+ #
111
+ # To create a new PredictionService client with a custom
112
+ # configuration:
113
+ #
114
+ # client = Google::Cloud::AutoML::V1beta1::PredictionService::Client.new do |config|
115
+ # config.timeout = 10_000
116
+ # end
117
+ #
118
+ # @yield [config] Configure the PredictionService client.
119
+ # @yieldparam config [Client::Configuration]
120
+ #
121
+ def initialize
122
+ # These require statements are intentionally placed here to initialize
123
+ # the gRPC module only when it's required.
124
+ # See https://github.com/googleapis/toolkit/issues/446
125
+ require "gapic/grpc"
126
+ require "google/cloud/automl/v1beta1/prediction_service_services_pb"
127
+
128
+ # Create the configuration object
129
+ @config = Configuration.new Client.configure
130
+
131
+ # Yield the configuration if needed
132
+ yield @config if block_given?
133
+
134
+ # Create credentials
135
+ credentials = @config.credentials
136
+ credentials ||= Credentials.default scope: @config.scope
137
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
138
+ credentials = Credentials.new credentials, scope: @config.scope
139
+ end
140
+ @quota_project_id = credentials.respond_to?(:quota_project_id) ? credentials.quota_project_id : nil
141
+
142
+ @operations_client = Operations.new do |config|
143
+ config.credentials = credentials
144
+ config.endpoint = @config.endpoint
145
+ end
146
+
147
+ @prediction_service_stub = Gapic::ServiceStub.new(
148
+ Google::Cloud::AutoML::V1beta1::PredictionService::Stub,
149
+ credentials: credentials,
150
+ endpoint: @config.endpoint,
151
+ channel_args: @config.channel_args,
152
+ interceptors: @config.interceptors
153
+ )
154
+ end
155
+
156
+ ##
157
+ # Get the associated client for long-running operations.
158
+ #
159
+ # @return [Google::Cloud::AutoML::V1beta1::PredictionService::Operations]
160
+ #
161
+ attr_reader :operations_client
162
+
163
+ # Service calls
164
+
165
+ ##
166
+ # Perform an online prediction. The prediction result will be directly
167
+ # returned in the response.
168
+ # Available for following ML problems, and their expected request payloads:
169
+ # * Image Classification - Image in .JPEG, .GIF or .PNG format, image_bytes
170
+ # up to 30MB.
171
+ # * Image Object Detection - Image in .JPEG, .GIF or .PNG format, image_bytes
172
+ # up to 30MB.
173
+ # * Text Classification - TextSnippet, content up to 60,000 characters,
174
+ # UTF-8 encoded.
175
+ # * Text Extraction - TextSnippet, content up to 30,000 characters,
176
+ # UTF-8 NFC encoded.
177
+ # * Translation - TextSnippet, content up to 25,000 characters, UTF-8
178
+ # encoded.
179
+ # * Tables - Row, with column values matching the columns of the model,
180
+ # up to 5MB. Not available for FORECASTING
181
+ #
182
+ # [prediction_type][google.cloud.automl.v1beta1.TablesModelMetadata.prediction_type].
183
+ # * Text Sentiment - TextSnippet, content up 500 characters, UTF-8
184
+ # encoded.
185
+ #
186
+ # @overload predict(request, options = nil)
187
+ # Pass arguments to `predict` via a request object, either of type
188
+ # {Google::Cloud::AutoML::V1beta1::PredictRequest} or an equivalent Hash.
189
+ #
190
+ # @param request [Google::Cloud::AutoML::V1beta1::PredictRequest, Hash]
191
+ # A request object representing the call parameters. Required. To specify no
192
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
193
+ # @param options [Gapic::CallOptions, Hash]
194
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
195
+ #
196
+ # @overload predict(name: nil, payload: nil, params: nil)
197
+ # Pass arguments to `predict` via keyword arguments. Note that at
198
+ # least one keyword argument is required. To specify no parameters, or to keep all
199
+ # the default parameter values, pass an empty Hash as a request object (see above).
200
+ #
201
+ # @param name [String]
202
+ # Required. Name of the model requested to serve the prediction.
203
+ # @param payload [Google::Cloud::AutoML::V1beta1::ExamplePayload, Hash]
204
+ # Required. Payload to perform a prediction on. The payload must match the
205
+ # problem type that the model was trained to solve.
206
+ # @param params [Hash{String => String}]
207
+ # Additional domain-specific parameters, any string must be up to 25000
208
+ # characters long.
209
+ #
210
+ # * For Image Classification:
211
+ #
212
+ # `score_threshold` - (float) A value from 0.0 to 1.0. When the model
213
+ # makes predictions for an image, it will only produce results that have
214
+ # at least this confidence score. The default is 0.5.
215
+ #
216
+ # * For Image Object Detection:
217
+ # `score_threshold` - (float) When Model detects objects on the image,
218
+ # it will only produce bounding boxes which have at least this
219
+ # confidence score. Value in 0 to 1 range, default is 0.5.
220
+ # `max_bounding_box_count` - (int64) No more than this number of bounding
221
+ # boxes will be returned in the response. Default is 100, the
222
+ # requested value may be limited by server.
223
+ # * For Tables:
224
+ # feature_imp<span>ortan</span>ce - (boolean) Whether feature importance
225
+ # should be populated in the returned TablesAnnotation.
226
+ # The default is false.
227
+ #
228
+ # @yield [response, operation] Access the result along with the RPC operation
229
+ # @yieldparam response [Google::Cloud::AutoML::V1beta1::PredictResponse]
230
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
231
+ #
232
+ # @return [Google::Cloud::AutoML::V1beta1::PredictResponse]
233
+ #
234
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
235
+ #
236
+ def predict request, options = nil
237
+ raise ArgumentError, "request must be provided" if request.nil?
238
+
239
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::AutoML::V1beta1::PredictRequest
240
+
241
+ # Converts hash and nil to an options object
242
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
243
+
244
+ # Customize the options with defaults
245
+ metadata = @config.rpcs.predict.metadata.to_h
246
+
247
+ # Set x-goog-api-client and x-goog-user-project headers
248
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
249
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
250
+ gapic_version: ::Google::Cloud::Automl::V1beta1::VERSION
251
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
252
+
253
+ header_params = {
254
+ "name" => request.name
255
+ }
256
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
257
+ metadata[:"x-goog-request-params"] ||= request_params_header
258
+
259
+ options.apply_defaults timeout: @config.rpcs.predict.timeout,
260
+ metadata: metadata,
261
+ retry_policy: @config.rpcs.predict.retry_policy
262
+ options.apply_defaults metadata: @config.metadata,
263
+ retry_policy: @config.retry_policy
264
+
265
+ @prediction_service_stub.call_rpc :predict, request, options: options do |response, operation|
266
+ yield response, operation if block_given?
267
+ return response
268
+ end
269
+ rescue GRPC::BadStatus => e
270
+ raise Google::Cloud::Error.from_error(e)
271
+ end
272
+
273
+ ##
274
+ # Perform a batch prediction. Unlike the online {Google::Cloud::AutoML::V1beta1::PredictionService::Client#predict Predict}, batch
275
+ # prediction result won't be immediately available in the response. Instead,
276
+ # a long running operation object is returned. User can poll the operation
277
+ # result via GetOperation
278
+ # method. Once the operation is done, {Google::Cloud::AutoML::V1beta1::BatchPredictResult BatchPredictResult} is returned in
279
+ # the {Google::Longrunning::Operation#response response} field.
280
+ # Available for following ML problems:
281
+ # * Image Classification
282
+ # * Image Object Detection
283
+ # * Video Classification
284
+ # * Video Object Tracking * Text Extraction
285
+ # * Tables
286
+ #
287
+ # @overload batch_predict(request, options = nil)
288
+ # Pass arguments to `batch_predict` via a request object, either of type
289
+ # {Google::Cloud::AutoML::V1beta1::BatchPredictRequest} or an equivalent Hash.
290
+ #
291
+ # @param request [Google::Cloud::AutoML::V1beta1::BatchPredictRequest, Hash]
292
+ # A request object representing the call parameters. Required. To specify no
293
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
294
+ # @param options [Gapic::CallOptions, Hash]
295
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
296
+ #
297
+ # @overload batch_predict(name: nil, input_config: nil, output_config: nil, params: nil)
298
+ # Pass arguments to `batch_predict` via keyword arguments. Note that at
299
+ # least one keyword argument is required. To specify no parameters, or to keep all
300
+ # the default parameter values, pass an empty Hash as a request object (see above).
301
+ #
302
+ # @param name [String]
303
+ # Required. Name of the model requested to serve the batch prediction.
304
+ # @param input_config [Google::Cloud::AutoML::V1beta1::BatchPredictInputConfig, Hash]
305
+ # Required. The input configuration for batch prediction.
306
+ # @param output_config [Google::Cloud::AutoML::V1beta1::BatchPredictOutputConfig, Hash]
307
+ # Required. The Configuration specifying where output predictions should
308
+ # be written.
309
+ # @param params [Hash{String => String}]
310
+ # Required. Additional domain-specific parameters for the predictions, any string must
311
+ # be up to 25000 characters long.
312
+ #
313
+ # * For Text Classification:
314
+ #
315
+ # `score_threshold` - (float) A value from 0.0 to 1.0. When the model
316
+ # makes predictions for a text snippet, it will only produce results
317
+ # that have at least this confidence score. The default is 0.5.
318
+ #
319
+ # * For Image Classification:
320
+ #
321
+ # `score_threshold` - (float) A value from 0.0 to 1.0. When the model
322
+ # makes predictions for an image, it will only produce results that
323
+ # have at least this confidence score. The default is 0.5.
324
+ #
325
+ # * For Image Object Detection:
326
+ #
327
+ # `score_threshold` - (float) When Model detects objects on the image,
328
+ # it will only produce bounding boxes which have at least this
329
+ # confidence score. Value in 0 to 1 range, default is 0.5.
330
+ # `max_bounding_box_count` - (int64) No more than this number of bounding
331
+ # boxes will be produced per image. Default is 100, the
332
+ # requested value may be limited by server.
333
+ #
334
+ # * For Video Classification :
335
+ #
336
+ # `score_threshold` - (float) A value from 0.0 to 1.0. When the model
337
+ # makes predictions for a video, it will only produce results that
338
+ # have at least this confidence score. The default is 0.5.
339
+ # `segment_classification` - (boolean) Set to true to request
340
+ # segment-level classification. AutoML Video Intelligence returns
341
+ # labels and their confidence scores for the entire segment of the
342
+ # video that user specified in the request configuration.
343
+ # The default is "true".
344
+ # `shot_classification` - (boolean) Set to true to request shot-level
345
+ # classification. AutoML Video Intelligence determines the boundaries
346
+ # for each camera shot in the entire segment of the video that user
347
+ # specified in the request configuration. AutoML Video Intelligence
348
+ # then returns labels and their confidence scores for each detected
349
+ # shot, along with the start and end time of the shot.
350
+ # WARNING: Model evaluation is not done for this classification type,
351
+ # the quality of it depends on training data, but there are no metrics
352
+ # provided to describe that quality. The default is "false".
353
+ # `1s_interval_classification` - (boolean) Set to true to request
354
+ # classification for a video at one-second intervals. AutoML Video
355
+ # Intelligence returns labels and their confidence scores for each
356
+ # second of the entire segment of the video that user specified in the
357
+ # request configuration.
358
+ # WARNING: Model evaluation is not done for this classification
359
+ # type, the quality of it depends on training data, but there are no
360
+ # metrics provided to describe that quality. The default is
361
+ # "false".
362
+ #
363
+ # * For Tables:
364
+ #
365
+ # feature_imp<span>ortan</span>ce - (boolean) Whether feature importance
366
+ # should be populated in the returned TablesAnnotations. The
367
+ # default is false.
368
+ #
369
+ # * For Video Object Tracking:
370
+ #
371
+ # `score_threshold` - (float) When Model detects objects on video frames,
372
+ # it will only produce bounding boxes which have at least this
373
+ # confidence score. Value in 0 to 1 range, default is 0.5.
374
+ # `max_bounding_box_count` - (int64) No more than this number of bounding
375
+ # boxes will be returned per frame. Default is 100, the requested
376
+ # value may be limited by server.
377
+ # `min_bounding_box_size` - (float) Only bounding boxes with shortest edge
378
+ # at least that long as a relative value of video frame size will be
379
+ # returned. Value in 0 to 1 range. Default is 0.
380
+ #
381
+ # @yield [response, operation] Access the result along with the RPC operation
382
+ # @yieldparam response [Gapic::Operation]
383
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
384
+ #
385
+ # @return [Gapic::Operation]
386
+ #
387
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
388
+ #
389
+ def batch_predict request, options = nil
390
+ raise ArgumentError, "request must be provided" if request.nil?
391
+
392
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::AutoML::V1beta1::BatchPredictRequest
393
+
394
+ # Converts hash and nil to an options object
395
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
396
+
397
+ # Customize the options with defaults
398
+ metadata = @config.rpcs.batch_predict.metadata.to_h
399
+
400
+ # Set x-goog-api-client and x-goog-user-project headers
401
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
402
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
403
+ gapic_version: ::Google::Cloud::Automl::V1beta1::VERSION
404
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
405
+
406
+ header_params = {
407
+ "name" => request.name
408
+ }
409
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
410
+ metadata[:"x-goog-request-params"] ||= request_params_header
411
+
412
+ options.apply_defaults timeout: @config.rpcs.batch_predict.timeout,
413
+ metadata: metadata,
414
+ retry_policy: @config.rpcs.batch_predict.retry_policy
415
+ options.apply_defaults metadata: @config.metadata,
416
+ retry_policy: @config.retry_policy
417
+
418
+ @prediction_service_stub.call_rpc :batch_predict, request, options: options do |response, operation|
419
+ response = Gapic::Operation.new response, @operations_client, options: options
420
+ yield response, operation if block_given?
421
+ return response
422
+ end
423
+ rescue GRPC::BadStatus => e
424
+ raise Google::Cloud::Error.from_error(e)
425
+ end
426
+
427
+ ##
428
+ # Configuration class for the PredictionService API.
429
+ #
430
+ # This class represents the configuration for PredictionService,
431
+ # providing control over timeouts, retry behavior, logging, transport
432
+ # parameters, and other low-level controls. Certain parameters can also be
433
+ # applied individually to specific RPCs. See
434
+ # {Google::Cloud::AutoML::V1beta1::PredictionService::Client::Configuration::Rpcs}
435
+ # for a list of RPCs that can be configured independently.
436
+ #
437
+ # Configuration can be applied globally to all clients, or to a single client
438
+ # on construction.
439
+ #
440
+ # # Examples
441
+ #
442
+ # To modify the global config, setting the timeout for predict
443
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
444
+ #
445
+ # Google::Cloud::AutoML::V1beta1::PredictionService::Client.configure do |config|
446
+ # config.timeout = 10_000
447
+ # config.rpcs.predict.timeout = 20_000
448
+ # end
449
+ #
450
+ # To apply the above configuration only to a new client:
451
+ #
452
+ # client = Google::Cloud::AutoML::V1beta1::PredictionService::Client.new do |config|
453
+ # config.timeout = 10_000
454
+ # config.rpcs.predict.timeout = 20_000
455
+ # end
456
+ #
457
+ # @!attribute [rw] endpoint
458
+ # The hostname or hostname:port of the service endpoint.
459
+ # Defaults to `"automl.googleapis.com"`.
460
+ # @return [String]
461
+ # @!attribute [rw] credentials
462
+ # Credentials to send with calls. You may provide any of the following types:
463
+ # * (`String`) The path to a service account key file in JSON format
464
+ # * (`Hash`) A service account key as a Hash
465
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
466
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
467
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
468
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
469
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
470
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
471
+ # * (`nil`) indicating no credentials
472
+ # @return [Object]
473
+ # @!attribute [rw] scope
474
+ # The OAuth scopes
475
+ # @return [Array<String>]
476
+ # @!attribute [rw] lib_name
477
+ # The library name as recorded in instrumentation and logging
478
+ # @return [String]
479
+ # @!attribute [rw] lib_version
480
+ # The library version as recorded in instrumentation and logging
481
+ # @return [String]
482
+ # @!attribute [rw] channel_args
483
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
484
+ # `GRPC::Core::Channel` object is provided as the credential.
485
+ # @return [Hash]
486
+ # @!attribute [rw] interceptors
487
+ # An array of interceptors that are run before calls are executed.
488
+ # @return [Array<GRPC::ClientInterceptor>]
489
+ # @!attribute [rw] timeout
490
+ # The call timeout in milliseconds.
491
+ # @return [Numeric]
492
+ # @!attribute [rw] metadata
493
+ # Additional gRPC headers to be sent with the call.
494
+ # @return [Hash{Symbol=>String}]
495
+ # @!attribute [rw] retry_policy
496
+ # The retry policy. The value is a hash with the following keys:
497
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
498
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
499
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
500
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
501
+ # trigger a retry.
502
+ # @return [Hash]
503
+ #
504
+ class Configuration
505
+ extend Gapic::Config
506
+
507
+ config_attr :endpoint, "automl.googleapis.com", String
508
+ config_attr :credentials, nil do |value|
509
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
510
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
511
+ allowed.any? { |klass| klass === value }
512
+ end
513
+ config_attr :scope, nil, String, Array, nil
514
+ config_attr :lib_name, nil, String, nil
515
+ config_attr :lib_version, nil, String, nil
516
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, Hash, nil)
517
+ config_attr :interceptors, nil, Array, nil
518
+ config_attr :timeout, nil, Numeric, nil
519
+ config_attr :metadata, nil, Hash, nil
520
+ config_attr :retry_policy, nil, Hash, Proc, nil
521
+
522
+ # @private
523
+ def initialize parent_config = nil
524
+ @parent_config = parent_config unless parent_config.nil?
525
+
526
+ yield self if block_given?
527
+ end
528
+
529
+ ##
530
+ # Configurations for individual RPCs
531
+ # @return [Rpcs]
532
+ #
533
+ def rpcs
534
+ @rpcs ||= begin
535
+ parent_rpcs = nil
536
+ parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
537
+ Rpcs.new parent_rpcs
538
+ end
539
+ end
540
+
541
+ ##
542
+ # Configuration RPC class for the PredictionService API.
543
+ #
544
+ # Includes fields providing the configuration for each RPC in this service.
545
+ # Each configuration object is of type `Gapic::Config::Method` and includes
546
+ # the following configuration fields:
547
+ #
548
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
549
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
550
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
551
+ # include the following keys:
552
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
553
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
554
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
555
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
556
+ # trigger a retry.
557
+ #
558
+ class Rpcs
559
+ ##
560
+ # RPC-specific configuration for `predict`
561
+ # @return [Gapic::Config::Method]
562
+ #
563
+ attr_reader :predict
564
+ ##
565
+ # RPC-specific configuration for `batch_predict`
566
+ # @return [Gapic::Config::Method]
567
+ #
568
+ attr_reader :batch_predict
569
+
570
+ # @private
571
+ def initialize parent_rpcs = nil
572
+ predict_config = parent_rpcs&.predict if parent_rpcs&.respond_to? :predict
573
+ @predict = Gapic::Config::Method.new predict_config
574
+ batch_predict_config = parent_rpcs&.batch_predict if parent_rpcs&.respond_to? :batch_predict
575
+ @batch_predict = Gapic::Config::Method.new batch_predict_config
576
+
577
+ yield self if block_given?
578
+ end
579
+ end
580
+ end
581
+ end
582
+ end
583
+ end
584
+ end
585
+ end
586
+ end