google-cloud-automl-v1 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,606 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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/v1/prediction_service_pb"
21
+ require "google/cloud/automl/v1/prediction_service/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module AutoML
26
+ module V1
27
+ module PredictionService
28
+ module Rest
29
+ ##
30
+ # REST client for the PredictionService service.
31
+ #
32
+ # AutoML Prediction API.
33
+ #
34
+ # On any input that is documented to expect a string parameter in
35
+ # snake_case or dash-case, either of those cases is accepted.
36
+ #
37
+ class Client
38
+ include Paths
39
+
40
+ # @private
41
+ attr_reader :prediction_service_stub
42
+
43
+ ##
44
+ # Configure the PredictionService Client class.
45
+ #
46
+ # See {::Google::Cloud::AutoML::V1::PredictionService::Rest::Client::Configuration}
47
+ # for a description of the configuration fields.
48
+ #
49
+ # @example
50
+ #
51
+ # # Modify the configuration for all PredictionService clients
52
+ # ::Google::Cloud::AutoML::V1::PredictionService::Rest::Client.configure do |config|
53
+ # config.timeout = 10.0
54
+ # end
55
+ #
56
+ # @yield [config] Configure the Client client.
57
+ # @yieldparam config [Client::Configuration]
58
+ #
59
+ # @return [Client::Configuration]
60
+ #
61
+ def self.configure
62
+ @configure ||= begin
63
+ namespace = ["Google", "Cloud", "AutoML", "V1"]
64
+ parent_config = while namespace.any?
65
+ parent_name = namespace.join "::"
66
+ parent_const = const_get parent_name
67
+ break parent_const.configure if parent_const.respond_to? :configure
68
+ namespace.pop
69
+ end
70
+ default_config = Client::Configuration.new parent_config
71
+
72
+ default_config.rpcs.predict.timeout = 60.0
73
+
74
+ default_config.rpcs.batch_predict.timeout = 60.0
75
+
76
+ default_config
77
+ end
78
+ yield @configure if block_given?
79
+ @configure
80
+ end
81
+
82
+ ##
83
+ # Configure the PredictionService Client instance.
84
+ #
85
+ # The configuration is set to the derived mode, meaning that values can be changed,
86
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
87
+ # should be made on {Client.configure}.
88
+ #
89
+ # See {::Google::Cloud::AutoML::V1::PredictionService::Rest::Client::Configuration}
90
+ # for a description of the configuration fields.
91
+ #
92
+ # @yield [config] Configure the Client client.
93
+ # @yieldparam config [Client::Configuration]
94
+ #
95
+ # @return [Client::Configuration]
96
+ #
97
+ def configure
98
+ yield @config if block_given?
99
+ @config
100
+ end
101
+
102
+ ##
103
+ # Create a new PredictionService REST client object.
104
+ #
105
+ # @example
106
+ #
107
+ # # Create a client using the default configuration
108
+ # client = ::Google::Cloud::AutoML::V1::PredictionService::Rest::Client.new
109
+ #
110
+ # # Create a client using a custom configuration
111
+ # client = ::Google::Cloud::AutoML::V1::PredictionService::Rest::Client.new do |config|
112
+ # config.timeout = 10.0
113
+ # end
114
+ #
115
+ # @yield [config] Configure the PredictionService client.
116
+ # @yieldparam config [Client::Configuration]
117
+ #
118
+ def initialize
119
+ # Create the configuration object
120
+ @config = Configuration.new Client.configure
121
+
122
+ # Yield the configuration if needed
123
+ yield @config if block_given?
124
+
125
+ # Create credentials
126
+ credentials = @config.credentials
127
+ # Use self-signed JWT if the endpoint is unchanged from default,
128
+ # but only if the default endpoint does not have a region prefix.
129
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
130
+ !@config.endpoint.split(".").first.include?("-")
131
+ credentials ||= Credentials.default scope: @config.scope,
132
+ enable_self_signed_jwt: enable_self_signed_jwt
133
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
134
+ credentials = Credentials.new credentials, scope: @config.scope
135
+ end
136
+
137
+ @quota_project_id = @config.quota_project
138
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
139
+
140
+ @operations_client = ::Google::Cloud::AutoML::V1::PredictionService::Rest::Operations.new do |config|
141
+ config.credentials = credentials
142
+ config.quota_project = @quota_project_id
143
+ config.endpoint = @config.endpoint
144
+ end
145
+
146
+ @prediction_service_stub = ::Google::Cloud::AutoML::V1::PredictionService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
147
+ end
148
+
149
+ ##
150
+ # Get the associated client for long-running operations.
151
+ #
152
+ # @return [::Google::Cloud::AutoML::V1::PredictionService::Rest::Operations]
153
+ #
154
+ attr_reader :operations_client
155
+
156
+ # Service calls
157
+
158
+ ##
159
+ # Perform an online prediction. The prediction result is directly
160
+ # returned in the response.
161
+ # Available for following ML scenarios, and their expected request payloads:
162
+ #
163
+ # AutoML Vision Classification
164
+ #
165
+ # * An image in .JPEG, .GIF or .PNG format, image_bytes up to 30MB.
166
+ #
167
+ # AutoML Vision Object Detection
168
+ #
169
+ # * An image in .JPEG, .GIF or .PNG format, image_bytes up to 30MB.
170
+ #
171
+ # AutoML Natural Language Classification
172
+ #
173
+ # * A TextSnippet up to 60,000 characters, UTF-8 encoded or a document in
174
+ # .PDF, .TIF or .TIFF format with size upto 2MB.
175
+ #
176
+ # AutoML Natural Language Entity Extraction
177
+ #
178
+ # * A TextSnippet up to 10,000 characters, UTF-8 NFC encoded or a document
179
+ # in .PDF, .TIF or .TIFF format with size upto 20MB.
180
+ #
181
+ # AutoML Natural Language Sentiment Analysis
182
+ #
183
+ # * A TextSnippet up to 60,000 characters, UTF-8 encoded or a document in
184
+ # .PDF, .TIF or .TIFF format with size upto 2MB.
185
+ #
186
+ # AutoML Translation
187
+ #
188
+ # * A TextSnippet up to 25,000 characters, UTF-8 encoded.
189
+ #
190
+ # AutoML Tables
191
+ #
192
+ # * A row with column values matching
193
+ # the columns of the model, up to 5MB. Not available for FORECASTING
194
+ # `prediction_type`.
195
+ #
196
+ # @overload predict(request, options = nil)
197
+ # Pass arguments to `predict` via a request object, either of type
198
+ # {::Google::Cloud::AutoML::V1::PredictRequest} or an equivalent Hash.
199
+ #
200
+ # @param request [::Google::Cloud::AutoML::V1::PredictRequest, ::Hash]
201
+ # A request object representing the call parameters. Required. To specify no
202
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
203
+ # @param options [::Gapic::CallOptions, ::Hash]
204
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
205
+ #
206
+ # @overload predict(name: nil, payload: nil, params: nil)
207
+ # Pass arguments to `predict` via keyword arguments. Note that at
208
+ # least one keyword argument is required. To specify no parameters, or to keep all
209
+ # the default parameter values, pass an empty Hash as a request object (see above).
210
+ #
211
+ # @param name [::String]
212
+ # Required. Name of the model requested to serve the prediction.
213
+ # @param payload [::Google::Cloud::AutoML::V1::ExamplePayload, ::Hash]
214
+ # Required. Payload to perform a prediction on. The payload must match the
215
+ # problem type that the model was trained to solve.
216
+ # @param params [::Hash{::String => ::String}]
217
+ # Additional domain-specific parameters, any string must be up to 25000
218
+ # characters long.
219
+ #
220
+ # AutoML Vision Classification
221
+ #
222
+ # `score_threshold`
223
+ # : (float) A value from 0.0 to 1.0. When the model
224
+ # makes predictions for an image, it will only produce results that have
225
+ # at least this confidence score. The default is 0.5.
226
+ #
227
+ # AutoML Vision Object Detection
228
+ #
229
+ # `score_threshold`
230
+ # : (float) When Model detects objects on the image,
231
+ # it will only produce bounding boxes which have at least this
232
+ # confidence score. Value in 0 to 1 range, default is 0.5.
233
+ #
234
+ # `max_bounding_box_count`
235
+ # : (int64) The maximum number of bounding
236
+ # boxes returned. The default is 100. The
237
+ # number of returned bounding boxes might be limited by the server.
238
+ #
239
+ # AutoML Tables
240
+ #
241
+ # `feature_importance`
242
+ # : (boolean) Whether
243
+ # [feature_importance][google.cloud.automl.v1.TablesModelColumnInfo.feature_importance]
244
+ # is populated in the returned list of
245
+ # [TablesAnnotation][google.cloud.automl.v1.TablesAnnotation]
246
+ # objects. The default is false.
247
+ # @yield [result, operation] Access the result along with the TransportOperation object
248
+ # @yieldparam result [::Google::Cloud::AutoML::V1::PredictResponse]
249
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
250
+ #
251
+ # @return [::Google::Cloud::AutoML::V1::PredictResponse]
252
+ #
253
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
254
+ def predict request, options = nil
255
+ raise ::ArgumentError, "request must be provided" if request.nil?
256
+
257
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AutoML::V1::PredictRequest
258
+
259
+ # Converts hash and nil to an options object
260
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
261
+
262
+ # Customize the options with defaults
263
+ call_metadata = @config.rpcs.predict.metadata.to_h
264
+
265
+ # Set x-goog-api-client and x-goog-user-project headers
266
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
267
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
268
+ gapic_version: ::Google::Cloud::AutoML::V1::VERSION,
269
+ transports_version_send: [:rest]
270
+
271
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
272
+
273
+ options.apply_defaults timeout: @config.rpcs.predict.timeout,
274
+ metadata: call_metadata,
275
+ retry_policy: @config.rpcs.predict.retry_policy
276
+
277
+ options.apply_defaults timeout: @config.timeout,
278
+ metadata: @config.metadata,
279
+ retry_policy: @config.retry_policy
280
+
281
+ @prediction_service_stub.predict request, options do |result, operation|
282
+ yield result, operation if block_given?
283
+ return result
284
+ end
285
+ rescue ::Gapic::Rest::Error => e
286
+ raise ::Google::Cloud::Error.from_error(e)
287
+ end
288
+
289
+ ##
290
+ # Perform a batch prediction. Unlike the online {::Google::Cloud::AutoML::V1::PredictionService::Rest::Client#predict Predict}, batch
291
+ # prediction result won't be immediately available in the response. Instead,
292
+ # a long running operation object is returned. User can poll the operation
293
+ # result via GetOperation
294
+ # method. Once the operation is done, {::Google::Cloud::AutoML::V1::BatchPredictResult BatchPredictResult} is returned in
295
+ # the {::Google::Longrunning::Operation#response response} field.
296
+ # Available for following ML scenarios:
297
+ #
298
+ # * AutoML Vision Classification
299
+ # * AutoML Vision Object Detection
300
+ # * AutoML Video Intelligence Classification
301
+ # * AutoML Video Intelligence Object Tracking * AutoML Natural Language Classification
302
+ # * AutoML Natural Language Entity Extraction
303
+ # * AutoML Natural Language Sentiment Analysis
304
+ # * AutoML Tables
305
+ #
306
+ # @overload batch_predict(request, options = nil)
307
+ # Pass arguments to `batch_predict` via a request object, either of type
308
+ # {::Google::Cloud::AutoML::V1::BatchPredictRequest} or an equivalent Hash.
309
+ #
310
+ # @param request [::Google::Cloud::AutoML::V1::BatchPredictRequest, ::Hash]
311
+ # A request object representing the call parameters. Required. To specify no
312
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
313
+ # @param options [::Gapic::CallOptions, ::Hash]
314
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
315
+ #
316
+ # @overload batch_predict(name: nil, input_config: nil, output_config: nil, params: nil)
317
+ # Pass arguments to `batch_predict` via keyword arguments. Note that at
318
+ # least one keyword argument is required. To specify no parameters, or to keep all
319
+ # the default parameter values, pass an empty Hash as a request object (see above).
320
+ #
321
+ # @param name [::String]
322
+ # Required. Name of the model requested to serve the batch prediction.
323
+ # @param input_config [::Google::Cloud::AutoML::V1::BatchPredictInputConfig, ::Hash]
324
+ # Required. The input configuration for batch prediction.
325
+ # @param output_config [::Google::Cloud::AutoML::V1::BatchPredictOutputConfig, ::Hash]
326
+ # Required. The Configuration specifying where output predictions should
327
+ # be written.
328
+ # @param params [::Hash{::String => ::String}]
329
+ # Additional domain-specific parameters for the predictions, any string must
330
+ # be up to 25000 characters long.
331
+ #
332
+ # AutoML Natural Language Classification
333
+ #
334
+ # `score_threshold`
335
+ # : (float) A value from 0.0 to 1.0. When the model
336
+ # makes predictions for a text snippet, it will only produce results
337
+ # that have at least this confidence score. The default is 0.5.
338
+ #
339
+ #
340
+ # AutoML Vision Classification
341
+ #
342
+ # `score_threshold`
343
+ # : (float) A value from 0.0 to 1.0. When the model
344
+ # makes predictions for an image, it will only produce results that
345
+ # have at least this confidence score. The default is 0.5.
346
+ #
347
+ # AutoML Vision Object Detection
348
+ #
349
+ # `score_threshold`
350
+ # : (float) When Model detects objects on the image,
351
+ # it will only produce bounding boxes which have at least this
352
+ # confidence score. Value in 0 to 1 range, default is 0.5.
353
+ #
354
+ # `max_bounding_box_count`
355
+ # : (int64) The maximum number of bounding
356
+ # boxes returned per image. The default is 100, the
357
+ # number of bounding boxes returned might be limited by the server.
358
+ # AutoML Video Intelligence Classification
359
+ #
360
+ # `score_threshold`
361
+ # : (float) A value from 0.0 to 1.0. When the model
362
+ # makes predictions for a video, it will only produce results that
363
+ # have at least this confidence score. The default is 0.5.
364
+ #
365
+ # `segment_classification`
366
+ # : (boolean) Set to true to request
367
+ # segment-level classification. AutoML Video Intelligence returns
368
+ # labels and their confidence scores for the entire segment of the
369
+ # video that user specified in the request configuration.
370
+ # The default is true.
371
+ #
372
+ # `shot_classification`
373
+ # : (boolean) Set to true to request shot-level
374
+ # classification. AutoML Video Intelligence determines the boundaries
375
+ # for each camera shot in the entire segment of the video that user
376
+ # specified in the request configuration. AutoML Video Intelligence
377
+ # then returns labels and their confidence scores for each detected
378
+ # shot, along with the start and end time of the shot.
379
+ # The default is false.
380
+ #
381
+ # WARNING: Model evaluation is not done for this classification type,
382
+ # the quality of it depends on training data, but there are no metrics
383
+ # provided to describe that quality.
384
+ #
385
+ # `1s_interval_classification`
386
+ # : (boolean) Set to true to request
387
+ # classification for a video at one-second intervals. AutoML Video
388
+ # Intelligence returns labels and their confidence scores for each
389
+ # second of the entire segment of the video that user specified in the
390
+ # request configuration. The default is false.
391
+ #
392
+ # WARNING: Model evaluation is not done for this classification
393
+ # type, the quality of it depends on training data, but there are no
394
+ # metrics provided to describe that quality.
395
+ #
396
+ # AutoML Video Intelligence Object Tracking
397
+ #
398
+ # `score_threshold`
399
+ # : (float) When Model detects objects on video frames,
400
+ # it will only produce bounding boxes which have at least this
401
+ # confidence score. Value in 0 to 1 range, default is 0.5.
402
+ #
403
+ # `max_bounding_box_count`
404
+ # : (int64) The maximum number of bounding
405
+ # boxes returned per image. The default is 100, the
406
+ # number of bounding boxes returned might be limited by the server.
407
+ #
408
+ # `min_bounding_box_size`
409
+ # : (float) Only bounding boxes with shortest edge
410
+ # at least that long as a relative value of video frame size are
411
+ # returned. Value in 0 to 1 range. Default is 0.
412
+ # @yield [result, operation] Access the result along with the TransportOperation object
413
+ # @yieldparam result [::Gapic::Operation]
414
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
415
+ #
416
+ # @return [::Gapic::Operation]
417
+ #
418
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
419
+ def batch_predict request, options = nil
420
+ raise ::ArgumentError, "request must be provided" if request.nil?
421
+
422
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AutoML::V1::BatchPredictRequest
423
+
424
+ # Converts hash and nil to an options object
425
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
426
+
427
+ # Customize the options with defaults
428
+ call_metadata = @config.rpcs.batch_predict.metadata.to_h
429
+
430
+ # Set x-goog-api-client and x-goog-user-project headers
431
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
432
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
433
+ gapic_version: ::Google::Cloud::AutoML::V1::VERSION,
434
+ transports_version_send: [:rest]
435
+
436
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
437
+
438
+ options.apply_defaults timeout: @config.rpcs.batch_predict.timeout,
439
+ metadata: call_metadata,
440
+ retry_policy: @config.rpcs.batch_predict.retry_policy
441
+
442
+ options.apply_defaults timeout: @config.timeout,
443
+ metadata: @config.metadata,
444
+ retry_policy: @config.retry_policy
445
+
446
+ @prediction_service_stub.batch_predict request, options do |result, operation|
447
+ result = ::Gapic::Operation.new result, @operations_client, options: options
448
+ yield result, operation if block_given?
449
+ return result
450
+ end
451
+ rescue ::Gapic::Rest::Error => e
452
+ raise ::Google::Cloud::Error.from_error(e)
453
+ end
454
+
455
+ ##
456
+ # Configuration class for the PredictionService REST API.
457
+ #
458
+ # This class represents the configuration for PredictionService REST,
459
+ # providing control over timeouts, retry behavior, logging, transport
460
+ # parameters, and other low-level controls. Certain parameters can also be
461
+ # applied individually to specific RPCs. See
462
+ # {::Google::Cloud::AutoML::V1::PredictionService::Rest::Client::Configuration::Rpcs}
463
+ # for a list of RPCs that can be configured independently.
464
+ #
465
+ # Configuration can be applied globally to all clients, or to a single client
466
+ # on construction.
467
+ #
468
+ # @example
469
+ #
470
+ # # Modify the global config, setting the timeout for
471
+ # # predict to 20 seconds,
472
+ # # and all remaining timeouts to 10 seconds.
473
+ # ::Google::Cloud::AutoML::V1::PredictionService::Rest::Client.configure do |config|
474
+ # config.timeout = 10.0
475
+ # config.rpcs.predict.timeout = 20.0
476
+ # end
477
+ #
478
+ # # Apply the above configuration only to a new client.
479
+ # client = ::Google::Cloud::AutoML::V1::PredictionService::Rest::Client.new do |config|
480
+ # config.timeout = 10.0
481
+ # config.rpcs.predict.timeout = 20.0
482
+ # end
483
+ #
484
+ # @!attribute [rw] endpoint
485
+ # The hostname or hostname:port of the service endpoint.
486
+ # Defaults to `"automl.googleapis.com"`.
487
+ # @return [::String]
488
+ # @!attribute [rw] credentials
489
+ # Credentials to send with calls. You may provide any of the following types:
490
+ # * (`String`) The path to a service account key file in JSON format
491
+ # * (`Hash`) A service account key as a Hash
492
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
493
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
494
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
495
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
496
+ # * (`nil`) indicating no credentials
497
+ # @return [::Object]
498
+ # @!attribute [rw] scope
499
+ # The OAuth scopes
500
+ # @return [::Array<::String>]
501
+ # @!attribute [rw] lib_name
502
+ # The library name as recorded in instrumentation and logging
503
+ # @return [::String]
504
+ # @!attribute [rw] lib_version
505
+ # The library version as recorded in instrumentation and logging
506
+ # @return [::String]
507
+ # @!attribute [rw] timeout
508
+ # The call timeout in seconds.
509
+ # @return [::Numeric]
510
+ # @!attribute [rw] metadata
511
+ # Additional headers to be sent with the call.
512
+ # @return [::Hash{::Symbol=>::String}]
513
+ # @!attribute [rw] retry_policy
514
+ # The retry policy. The value is a hash with the following keys:
515
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
516
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
517
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
518
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
519
+ # trigger a retry.
520
+ # @return [::Hash]
521
+ # @!attribute [rw] quota_project
522
+ # A separate project against which to charge quota.
523
+ # @return [::String]
524
+ #
525
+ class Configuration
526
+ extend ::Gapic::Config
527
+
528
+ config_attr :endpoint, "automl.googleapis.com", ::String
529
+ config_attr :credentials, nil do |value|
530
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
531
+ allowed.any? { |klass| klass === value }
532
+ end
533
+ config_attr :scope, nil, ::String, ::Array, nil
534
+ config_attr :lib_name, nil, ::String, nil
535
+ config_attr :lib_version, nil, ::String, nil
536
+ config_attr :timeout, nil, ::Numeric, nil
537
+ config_attr :metadata, nil, ::Hash, nil
538
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
539
+ config_attr :quota_project, nil, ::String, nil
540
+
541
+ # @private
542
+ def initialize parent_config = nil
543
+ @parent_config = parent_config unless parent_config.nil?
544
+
545
+ yield self if block_given?
546
+ end
547
+
548
+ ##
549
+ # Configurations for individual RPCs
550
+ # @return [Rpcs]
551
+ #
552
+ def rpcs
553
+ @rpcs ||= begin
554
+ parent_rpcs = nil
555
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
556
+ Rpcs.new parent_rpcs
557
+ end
558
+ end
559
+
560
+ ##
561
+ # Configuration RPC class for the PredictionService API.
562
+ #
563
+ # Includes fields providing the configuration for each RPC in this service.
564
+ # Each configuration object is of type `Gapic::Config::Method` and includes
565
+ # the following configuration fields:
566
+ #
567
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
568
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
569
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
570
+ # include the following keys:
571
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
572
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
573
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
574
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
575
+ # trigger a retry.
576
+ #
577
+ class Rpcs
578
+ ##
579
+ # RPC-specific configuration for `predict`
580
+ # @return [::Gapic::Config::Method]
581
+ #
582
+ attr_reader :predict
583
+ ##
584
+ # RPC-specific configuration for `batch_predict`
585
+ # @return [::Gapic::Config::Method]
586
+ #
587
+ attr_reader :batch_predict
588
+
589
+ # @private
590
+ def initialize parent_rpcs = nil
591
+ predict_config = parent_rpcs.predict if parent_rpcs.respond_to? :predict
592
+ @predict = ::Gapic::Config::Method.new predict_config
593
+ batch_predict_config = parent_rpcs.batch_predict if parent_rpcs.respond_to? :batch_predict
594
+ @batch_predict = ::Gapic::Config::Method.new batch_predict_config
595
+
596
+ yield self if block_given?
597
+ end
598
+ end
599
+ end
600
+ end
601
+ end
602
+ end
603
+ end
604
+ end
605
+ end
606
+ end