google-cloud-speech-v2 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2099 @@
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/speech/v2/cloud_speech_pb"
21
+ require "google/cloud/speech/v2/speech/rest/service_stub"
22
+ require "google/cloud/location/rest"
23
+
24
+ module Google
25
+ module Cloud
26
+ module Speech
27
+ module V2
28
+ module Speech
29
+ module Rest
30
+ ##
31
+ # REST client for the Speech service.
32
+ #
33
+ # Enables speech transcription and resource management.
34
+ #
35
+ class Client
36
+ include Paths
37
+
38
+ # @private
39
+ attr_reader :speech_stub
40
+
41
+ ##
42
+ # Configure the Speech Client class.
43
+ #
44
+ # See {::Google::Cloud::Speech::V2::Speech::Rest::Client::Configuration}
45
+ # for a description of the configuration fields.
46
+ #
47
+ # @example
48
+ #
49
+ # # Modify the configuration for all Speech clients
50
+ # ::Google::Cloud::Speech::V2::Speech::Rest::Client.configure do |config|
51
+ # config.timeout = 10.0
52
+ # end
53
+ #
54
+ # @yield [config] Configure the Client client.
55
+ # @yieldparam config [Client::Configuration]
56
+ #
57
+ # @return [Client::Configuration]
58
+ #
59
+ def self.configure
60
+ @configure ||= begin
61
+ namespace = ["Google", "Cloud", "Speech", "V2"]
62
+ parent_config = while namespace.any?
63
+ parent_name = namespace.join "::"
64
+ parent_const = const_get parent_name
65
+ break parent_const.configure if parent_const.respond_to? :configure
66
+ namespace.pop
67
+ end
68
+ default_config = Client::Configuration.new parent_config
69
+
70
+ default_config.timeout = 5000.0
71
+ default_config.retry_policy = {
72
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
73
+ }
74
+
75
+ default_config
76
+ end
77
+ yield @configure if block_given?
78
+ @configure
79
+ end
80
+
81
+ ##
82
+ # Configure the Speech 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::Speech::V2::Speech::Rest::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 Speech REST client object.
103
+ #
104
+ # @example
105
+ #
106
+ # # Create a client using the default configuration
107
+ # client = ::Google::Cloud::Speech::V2::Speech::Rest::Client.new
108
+ #
109
+ # # Create a client using a custom configuration
110
+ # client = ::Google::Cloud::Speech::V2::Speech::Rest::Client.new do |config|
111
+ # config.timeout = 10.0
112
+ # end
113
+ #
114
+ # @yield [config] Configure the Speech client.
115
+ # @yieldparam config [Client::Configuration]
116
+ #
117
+ def initialize
118
+ # Create the configuration object
119
+ @config = Configuration.new Client.configure
120
+
121
+ # Yield the configuration if needed
122
+ yield @config if block_given?
123
+
124
+ # Create credentials
125
+ credentials = @config.credentials
126
+ # Use self-signed JWT if the endpoint is unchanged from default,
127
+ # but only if the default endpoint does not have a region prefix.
128
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
129
+ !@config.endpoint.split(".").first.include?("-")
130
+ credentials ||= Credentials.default scope: @config.scope,
131
+ enable_self_signed_jwt: enable_self_signed_jwt
132
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
133
+ credentials = Credentials.new credentials, scope: @config.scope
134
+ end
135
+
136
+ @quota_project_id = @config.quota_project
137
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
138
+
139
+ @operations_client = ::Google::Cloud::Speech::V2::Speech::Rest::Operations.new do |config|
140
+ config.credentials = credentials
141
+ config.quota_project = @quota_project_id
142
+ config.endpoint = @config.endpoint
143
+ end
144
+
145
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
146
+ config.credentials = credentials
147
+ config.quota_project = @quota_project_id
148
+ config.endpoint = @config.endpoint
149
+ config.bindings_override = @config.bindings_override
150
+ end
151
+
152
+ @speech_stub = ::Google::Cloud::Speech::V2::Speech::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
153
+ end
154
+
155
+ ##
156
+ # Get the associated client for long-running operations.
157
+ #
158
+ # @return [::Google::Cloud::Speech::V2::Speech::Rest::Operations]
159
+ #
160
+ attr_reader :operations_client
161
+
162
+ ##
163
+ # Get the associated client for mix-in of the Locations.
164
+ #
165
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
166
+ #
167
+ attr_reader :location_client
168
+
169
+ # Service calls
170
+
171
+ ##
172
+ # Creates a {::Google::Cloud::Speech::V2::Recognizer Recognizer}.
173
+ #
174
+ # @overload create_recognizer(request, options = nil)
175
+ # Pass arguments to `create_recognizer` via a request object, either of type
176
+ # {::Google::Cloud::Speech::V2::CreateRecognizerRequest} or an equivalent Hash.
177
+ #
178
+ # @param request [::Google::Cloud::Speech::V2::CreateRecognizerRequest, ::Hash]
179
+ # A request object representing the call parameters. Required. To specify no
180
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
181
+ # @param options [::Gapic::CallOptions, ::Hash]
182
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
183
+ #
184
+ # @overload create_recognizer(recognizer: nil, validate_only: nil, recognizer_id: nil, parent: nil)
185
+ # Pass arguments to `create_recognizer` via keyword arguments. Note that at
186
+ # least one keyword argument is required. To specify no parameters, or to keep all
187
+ # the default parameter values, pass an empty Hash as a request object (see above).
188
+ #
189
+ # @param recognizer [::Google::Cloud::Speech::V2::Recognizer, ::Hash]
190
+ # Required. The Recognizer to create.
191
+ # @param validate_only [::Boolean]
192
+ # If set, validate the request and preview the Recognizer, but do not
193
+ # actually create it.
194
+ # @param recognizer_id [::String]
195
+ # The ID to use for the Recognizer, which will become the final component of
196
+ # the Recognizer's resource name.
197
+ #
198
+ # This value should be 4-63 characters, and valid characters
199
+ # are /[a-z][0-9]-/.
200
+ # @param parent [::String]
201
+ # Required. The project and location where this Recognizer will be created.
202
+ # The expected format is `projects/{project}/locations/{location}`.
203
+ # @yield [result, operation] Access the result along with the TransportOperation object
204
+ # @yieldparam result [::Gapic::Operation]
205
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
206
+ #
207
+ # @return [::Gapic::Operation]
208
+ #
209
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
210
+ def create_recognizer request, options = nil
211
+ raise ::ArgumentError, "request must be provided" if request.nil?
212
+
213
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::CreateRecognizerRequest
214
+
215
+ # Converts hash and nil to an options object
216
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
217
+
218
+ # Customize the options with defaults
219
+ call_metadata = @config.rpcs.create_recognizer.metadata.to_h
220
+
221
+ # Set x-goog-api-client and x-goog-user-project headers
222
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
223
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
224
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
225
+ transports_version_send: [:rest]
226
+
227
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
228
+
229
+ options.apply_defaults timeout: @config.rpcs.create_recognizer.timeout,
230
+ metadata: call_metadata,
231
+ retry_policy: @config.rpcs.create_recognizer.retry_policy
232
+
233
+ options.apply_defaults timeout: @config.timeout,
234
+ metadata: @config.metadata,
235
+ retry_policy: @config.retry_policy
236
+
237
+ @speech_stub.create_recognizer request, options do |result, operation|
238
+ result = ::Gapic::Operation.new result, @operations_client, options: options
239
+ yield result, operation if block_given?
240
+ return result
241
+ end
242
+ rescue ::Gapic::Rest::Error => e
243
+ raise ::Google::Cloud::Error.from_error(e)
244
+ end
245
+
246
+ ##
247
+ # Lists Recognizers.
248
+ #
249
+ # @overload list_recognizers(request, options = nil)
250
+ # Pass arguments to `list_recognizers` via a request object, either of type
251
+ # {::Google::Cloud::Speech::V2::ListRecognizersRequest} or an equivalent Hash.
252
+ #
253
+ # @param request [::Google::Cloud::Speech::V2::ListRecognizersRequest, ::Hash]
254
+ # A request object representing the call parameters. Required. To specify no
255
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
256
+ # @param options [::Gapic::CallOptions, ::Hash]
257
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
258
+ #
259
+ # @overload list_recognizers(parent: nil, page_size: nil, page_token: nil, show_deleted: nil)
260
+ # Pass arguments to `list_recognizers` via keyword arguments. Note that at
261
+ # least one keyword argument is required. To specify no parameters, or to keep all
262
+ # the default parameter values, pass an empty Hash as a request object (see above).
263
+ #
264
+ # @param parent [::String]
265
+ # Required. The project and location of Recognizers to list. The expected
266
+ # format is `projects/{project}/locations/{location}`.
267
+ # @param page_size [::Integer]
268
+ # The maximum number of Recognizers to return. The service may return fewer
269
+ # than this value. If unspecified, at most 20 Recognizers will be returned.
270
+ # The maximum value is 20; values above 20 will be coerced to 20.
271
+ # @param page_token [::String]
272
+ # A page token, received from a previous
273
+ # {::Google::Cloud::Speech::V2::Speech::Rest::Client#list_recognizers ListRecognizers} call.
274
+ # Provide this to retrieve the subsequent page.
275
+ #
276
+ # When paginating, all other parameters provided to
277
+ # {::Google::Cloud::Speech::V2::Speech::Rest::Client#list_recognizers ListRecognizers} must match
278
+ # the call that provided the page token.
279
+ # @param show_deleted [::Boolean]
280
+ # Whether, or not, to show resources that have been deleted.
281
+ # @yield [result, operation] Access the result along with the TransportOperation object
282
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::Recognizer>]
283
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
284
+ #
285
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::Recognizer>]
286
+ #
287
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
288
+ def list_recognizers request, options = nil
289
+ raise ::ArgumentError, "request must be provided" if request.nil?
290
+
291
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::ListRecognizersRequest
292
+
293
+ # Converts hash and nil to an options object
294
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
295
+
296
+ # Customize the options with defaults
297
+ call_metadata = @config.rpcs.list_recognizers.metadata.to_h
298
+
299
+ # Set x-goog-api-client and x-goog-user-project headers
300
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
301
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
302
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
303
+ transports_version_send: [:rest]
304
+
305
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
306
+
307
+ options.apply_defaults timeout: @config.rpcs.list_recognizers.timeout,
308
+ metadata: call_metadata,
309
+ retry_policy: @config.rpcs.list_recognizers.retry_policy
310
+
311
+ options.apply_defaults timeout: @config.timeout,
312
+ metadata: @config.metadata,
313
+ retry_policy: @config.retry_policy
314
+
315
+ @speech_stub.list_recognizers request, options do |result, operation|
316
+ result = ::Gapic::Rest::PagedEnumerable.new @speech_stub, :list_recognizers, "recognizers", request, result, options
317
+ yield result, operation if block_given?
318
+ return result
319
+ end
320
+ rescue ::Gapic::Rest::Error => e
321
+ raise ::Google::Cloud::Error.from_error(e)
322
+ end
323
+
324
+ ##
325
+ # Returns the requested
326
+ # {::Google::Cloud::Speech::V2::Recognizer Recognizer}. Fails with
327
+ # [NOT_FOUND][google.rpc.Code.NOT_FOUND] if the requested Recognizer doesn't
328
+ # exist.
329
+ #
330
+ # @overload get_recognizer(request, options = nil)
331
+ # Pass arguments to `get_recognizer` via a request object, either of type
332
+ # {::Google::Cloud::Speech::V2::GetRecognizerRequest} or an equivalent Hash.
333
+ #
334
+ # @param request [::Google::Cloud::Speech::V2::GetRecognizerRequest, ::Hash]
335
+ # A request object representing the call parameters. Required. To specify no
336
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
337
+ # @param options [::Gapic::CallOptions, ::Hash]
338
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
339
+ #
340
+ # @overload get_recognizer(name: nil)
341
+ # Pass arguments to `get_recognizer` via keyword arguments. Note that at
342
+ # least one keyword argument is required. To specify no parameters, or to keep all
343
+ # the default parameter values, pass an empty Hash as a request object (see above).
344
+ #
345
+ # @param name [::String]
346
+ # Required. The name of the Recognizer to retrieve. The expected format is
347
+ # `projects/{project}/locations/{location}/recognizers/{recognizer}`.
348
+ # @yield [result, operation] Access the result along with the TransportOperation object
349
+ # @yieldparam result [::Google::Cloud::Speech::V2::Recognizer]
350
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
351
+ #
352
+ # @return [::Google::Cloud::Speech::V2::Recognizer]
353
+ #
354
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
355
+ def get_recognizer request, options = nil
356
+ raise ::ArgumentError, "request must be provided" if request.nil?
357
+
358
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::GetRecognizerRequest
359
+
360
+ # Converts hash and nil to an options object
361
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
362
+
363
+ # Customize the options with defaults
364
+ call_metadata = @config.rpcs.get_recognizer.metadata.to_h
365
+
366
+ # Set x-goog-api-client and x-goog-user-project headers
367
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
368
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
369
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
370
+ transports_version_send: [:rest]
371
+
372
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
373
+
374
+ options.apply_defaults timeout: @config.rpcs.get_recognizer.timeout,
375
+ metadata: call_metadata,
376
+ retry_policy: @config.rpcs.get_recognizer.retry_policy
377
+
378
+ options.apply_defaults timeout: @config.timeout,
379
+ metadata: @config.metadata,
380
+ retry_policy: @config.retry_policy
381
+
382
+ @speech_stub.get_recognizer request, options do |result, operation|
383
+ yield result, operation if block_given?
384
+ return result
385
+ end
386
+ rescue ::Gapic::Rest::Error => e
387
+ raise ::Google::Cloud::Error.from_error(e)
388
+ end
389
+
390
+ ##
391
+ # Updates the {::Google::Cloud::Speech::V2::Recognizer Recognizer}.
392
+ #
393
+ # @overload update_recognizer(request, options = nil)
394
+ # Pass arguments to `update_recognizer` via a request object, either of type
395
+ # {::Google::Cloud::Speech::V2::UpdateRecognizerRequest} or an equivalent Hash.
396
+ #
397
+ # @param request [::Google::Cloud::Speech::V2::UpdateRecognizerRequest, ::Hash]
398
+ # A request object representing the call parameters. Required. To specify no
399
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
400
+ # @param options [::Gapic::CallOptions, ::Hash]
401
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
402
+ #
403
+ # @overload update_recognizer(recognizer: nil, update_mask: nil, validate_only: nil)
404
+ # Pass arguments to `update_recognizer` via keyword arguments. Note that at
405
+ # least one keyword argument is required. To specify no parameters, or to keep all
406
+ # the default parameter values, pass an empty Hash as a request object (see above).
407
+ #
408
+ # @param recognizer [::Google::Cloud::Speech::V2::Recognizer, ::Hash]
409
+ # Required. The Recognizer to update.
410
+ #
411
+ # The Recognizer's `name` field is used to identify the Recognizer to update.
412
+ # Format: `projects/{project}/locations/{location}/recognizers/{recognizer}`.
413
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
414
+ # The list of fields to update. If empty, all non-default valued fields are
415
+ # considered for update. Use `*` to update the entire Recognizer resource.
416
+ # @param validate_only [::Boolean]
417
+ # If set, validate the request and preview the updated Recognizer, but do not
418
+ # actually update it.
419
+ # @yield [result, operation] Access the result along with the TransportOperation object
420
+ # @yieldparam result [::Gapic::Operation]
421
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
422
+ #
423
+ # @return [::Gapic::Operation]
424
+ #
425
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
426
+ def update_recognizer request, options = nil
427
+ raise ::ArgumentError, "request must be provided" if request.nil?
428
+
429
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UpdateRecognizerRequest
430
+
431
+ # Converts hash and nil to an options object
432
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
433
+
434
+ # Customize the options with defaults
435
+ call_metadata = @config.rpcs.update_recognizer.metadata.to_h
436
+
437
+ # Set x-goog-api-client and x-goog-user-project headers
438
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
439
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
440
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
441
+ transports_version_send: [:rest]
442
+
443
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
444
+
445
+ options.apply_defaults timeout: @config.rpcs.update_recognizer.timeout,
446
+ metadata: call_metadata,
447
+ retry_policy: @config.rpcs.update_recognizer.retry_policy
448
+
449
+ options.apply_defaults timeout: @config.timeout,
450
+ metadata: @config.metadata,
451
+ retry_policy: @config.retry_policy
452
+
453
+ @speech_stub.update_recognizer request, options do |result, operation|
454
+ result = ::Gapic::Operation.new result, @operations_client, options: options
455
+ yield result, operation if block_given?
456
+ return result
457
+ end
458
+ rescue ::Gapic::Rest::Error => e
459
+ raise ::Google::Cloud::Error.from_error(e)
460
+ end
461
+
462
+ ##
463
+ # Deletes the {::Google::Cloud::Speech::V2::Recognizer Recognizer}.
464
+ #
465
+ # @overload delete_recognizer(request, options = nil)
466
+ # Pass arguments to `delete_recognizer` via a request object, either of type
467
+ # {::Google::Cloud::Speech::V2::DeleteRecognizerRequest} or an equivalent Hash.
468
+ #
469
+ # @param request [::Google::Cloud::Speech::V2::DeleteRecognizerRequest, ::Hash]
470
+ # A request object representing the call parameters. Required. To specify no
471
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
472
+ # @param options [::Gapic::CallOptions, ::Hash]
473
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
474
+ #
475
+ # @overload delete_recognizer(name: nil, validate_only: nil, allow_missing: nil, etag: nil)
476
+ # Pass arguments to `delete_recognizer` via keyword arguments. Note that at
477
+ # least one keyword argument is required. To specify no parameters, or to keep all
478
+ # the default parameter values, pass an empty Hash as a request object (see above).
479
+ #
480
+ # @param name [::String]
481
+ # Required. The name of the Recognizer to delete.
482
+ # Format: `projects/{project}/locations/{location}/recognizers/{recognizer}`
483
+ # @param validate_only [::Boolean]
484
+ # If set, validate the request and preview the deleted Recognizer, but do not
485
+ # actually delete it.
486
+ # @param allow_missing [::Boolean]
487
+ # If set to true, and the Recognizer is not found, the request will succeed
488
+ # and be a no-op (no Operation is recorded in this case).
489
+ # @param etag [::String]
490
+ # This checksum is computed by the server based on the value of other
491
+ # fields. This may be sent on update, undelete, and delete requests to ensure
492
+ # the client has an up-to-date value before proceeding.
493
+ # @yield [result, operation] Access the result along with the TransportOperation object
494
+ # @yieldparam result [::Gapic::Operation]
495
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
496
+ #
497
+ # @return [::Gapic::Operation]
498
+ #
499
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
500
+ def delete_recognizer request, options = nil
501
+ raise ::ArgumentError, "request must be provided" if request.nil?
502
+
503
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::DeleteRecognizerRequest
504
+
505
+ # Converts hash and nil to an options object
506
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
507
+
508
+ # Customize the options with defaults
509
+ call_metadata = @config.rpcs.delete_recognizer.metadata.to_h
510
+
511
+ # Set x-goog-api-client and x-goog-user-project headers
512
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
513
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
514
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
515
+ transports_version_send: [:rest]
516
+
517
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
518
+
519
+ options.apply_defaults timeout: @config.rpcs.delete_recognizer.timeout,
520
+ metadata: call_metadata,
521
+ retry_policy: @config.rpcs.delete_recognizer.retry_policy
522
+
523
+ options.apply_defaults timeout: @config.timeout,
524
+ metadata: @config.metadata,
525
+ retry_policy: @config.retry_policy
526
+
527
+ @speech_stub.delete_recognizer request, options do |result, operation|
528
+ result = ::Gapic::Operation.new result, @operations_client, options: options
529
+ yield result, operation if block_given?
530
+ return result
531
+ end
532
+ rescue ::Gapic::Rest::Error => e
533
+ raise ::Google::Cloud::Error.from_error(e)
534
+ end
535
+
536
+ ##
537
+ # Undeletes the {::Google::Cloud::Speech::V2::Recognizer Recognizer}.
538
+ #
539
+ # @overload undelete_recognizer(request, options = nil)
540
+ # Pass arguments to `undelete_recognizer` via a request object, either of type
541
+ # {::Google::Cloud::Speech::V2::UndeleteRecognizerRequest} or an equivalent Hash.
542
+ #
543
+ # @param request [::Google::Cloud::Speech::V2::UndeleteRecognizerRequest, ::Hash]
544
+ # A request object representing the call parameters. Required. To specify no
545
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
546
+ # @param options [::Gapic::CallOptions, ::Hash]
547
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
548
+ #
549
+ # @overload undelete_recognizer(name: nil, validate_only: nil, etag: nil)
550
+ # Pass arguments to `undelete_recognizer` via keyword arguments. Note that at
551
+ # least one keyword argument is required. To specify no parameters, or to keep all
552
+ # the default parameter values, pass an empty Hash as a request object (see above).
553
+ #
554
+ # @param name [::String]
555
+ # Required. The name of the Recognizer to undelete.
556
+ # Format: `projects/{project}/locations/{location}/recognizers/{recognizer}`
557
+ # @param validate_only [::Boolean]
558
+ # If set, validate the request and preview the undeleted Recognizer, but do
559
+ # not actually undelete it.
560
+ # @param etag [::String]
561
+ # This checksum is computed by the server based on the value of other
562
+ # fields. This may be sent on update, undelete, and delete requests to ensure
563
+ # the client has an up-to-date value before proceeding.
564
+ # @yield [result, operation] Access the result along with the TransportOperation object
565
+ # @yieldparam result [::Gapic::Operation]
566
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
567
+ #
568
+ # @return [::Gapic::Operation]
569
+ #
570
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
571
+ def undelete_recognizer request, options = nil
572
+ raise ::ArgumentError, "request must be provided" if request.nil?
573
+
574
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UndeleteRecognizerRequest
575
+
576
+ # Converts hash and nil to an options object
577
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
578
+
579
+ # Customize the options with defaults
580
+ call_metadata = @config.rpcs.undelete_recognizer.metadata.to_h
581
+
582
+ # Set x-goog-api-client and x-goog-user-project headers
583
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
584
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
585
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
586
+ transports_version_send: [:rest]
587
+
588
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
589
+
590
+ options.apply_defaults timeout: @config.rpcs.undelete_recognizer.timeout,
591
+ metadata: call_metadata,
592
+ retry_policy: @config.rpcs.undelete_recognizer.retry_policy
593
+
594
+ options.apply_defaults timeout: @config.timeout,
595
+ metadata: @config.metadata,
596
+ retry_policy: @config.retry_policy
597
+
598
+ @speech_stub.undelete_recognizer request, options do |result, operation|
599
+ result = ::Gapic::Operation.new result, @operations_client, options: options
600
+ yield result, operation if block_given?
601
+ return result
602
+ end
603
+ rescue ::Gapic::Rest::Error => e
604
+ raise ::Google::Cloud::Error.from_error(e)
605
+ end
606
+
607
+ ##
608
+ # Performs synchronous Speech recognition: receive results after all audio
609
+ # has been sent and processed.
610
+ #
611
+ # @overload recognize(request, options = nil)
612
+ # Pass arguments to `recognize` via a request object, either of type
613
+ # {::Google::Cloud::Speech::V2::RecognizeRequest} or an equivalent Hash.
614
+ #
615
+ # @param request [::Google::Cloud::Speech::V2::RecognizeRequest, ::Hash]
616
+ # A request object representing the call parameters. Required. To specify no
617
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
618
+ # @param options [::Gapic::CallOptions, ::Hash]
619
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
620
+ #
621
+ # @overload recognize(recognizer: nil, config: nil, config_mask: nil, content: nil, uri: nil)
622
+ # Pass arguments to `recognize` via keyword arguments. Note that at
623
+ # least one keyword argument is required. To specify no parameters, or to keep all
624
+ # the default parameter values, pass an empty Hash as a request object (see above).
625
+ #
626
+ # @param recognizer [::String]
627
+ # Required. The name of the Recognizer to use during recognition. The
628
+ # expected format is
629
+ # `projects/{project}/locations/{location}/recognizers/{recognizer}`.
630
+ # @param config [::Google::Cloud::Speech::V2::RecognitionConfig, ::Hash]
631
+ # Features and audio metadata to use for the Automatic Speech Recognition.
632
+ # This field in combination with the
633
+ # {::Google::Cloud::Speech::V2::RecognizeRequest#config_mask config_mask} field
634
+ # can be used to override parts of the
635
+ # {::Google::Cloud::Speech::V2::Recognizer#default_recognition_config default_recognition_config}
636
+ # of the Recognizer resource.
637
+ # @param config_mask [::Google::Protobuf::FieldMask, ::Hash]
638
+ # The list of fields in
639
+ # {::Google::Cloud::Speech::V2::RecognizeRequest#config config} that override the
640
+ # values in the
641
+ # {::Google::Cloud::Speech::V2::Recognizer#default_recognition_config default_recognition_config}
642
+ # of the recognizer during this recognition request. If no mask is provided,
643
+ # all non-default valued fields in
644
+ # {::Google::Cloud::Speech::V2::RecognizeRequest#config config} override the
645
+ # values in the recognizer for this recognition request. If a mask is
646
+ # provided, only the fields listed in the mask override the config in the
647
+ # recognizer for this recognition request. If a wildcard (`*`) is provided,
648
+ # {::Google::Cloud::Speech::V2::RecognizeRequest#config config} completely
649
+ # overrides and replaces the config in the recognizer for this recognition
650
+ # request.
651
+ # @param content [::String]
652
+ # The audio data bytes encoded as specified in
653
+ # {::Google::Cloud::Speech::V2::RecognitionConfig RecognitionConfig}. As
654
+ # with all bytes fields, proto buffers use a pure binary representation,
655
+ # whereas JSON representations use base64.
656
+ # @param uri [::String]
657
+ # URI that points to a file that contains audio data bytes as specified in
658
+ # {::Google::Cloud::Speech::V2::RecognitionConfig RecognitionConfig}. The file
659
+ # must not be compressed (for example, gzip). Currently, only Google Cloud
660
+ # Storage URIs are supported, which must be specified in the following
661
+ # format: `gs://bucket_name/object_name` (other URI formats return
662
+ # [INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more
663
+ # information, see [Request
664
+ # URIs](https://cloud.google.com/storage/docs/reference-uris).
665
+ # @yield [result, operation] Access the result along with the TransportOperation object
666
+ # @yieldparam result [::Google::Cloud::Speech::V2::RecognizeResponse]
667
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
668
+ #
669
+ # @return [::Google::Cloud::Speech::V2::RecognizeResponse]
670
+ #
671
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
672
+ def recognize request, options = nil
673
+ raise ::ArgumentError, "request must be provided" if request.nil?
674
+
675
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::RecognizeRequest
676
+
677
+ # Converts hash and nil to an options object
678
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
679
+
680
+ # Customize the options with defaults
681
+ call_metadata = @config.rpcs.recognize.metadata.to_h
682
+
683
+ # Set x-goog-api-client and x-goog-user-project headers
684
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
685
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
686
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
687
+ transports_version_send: [:rest]
688
+
689
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
690
+
691
+ options.apply_defaults timeout: @config.rpcs.recognize.timeout,
692
+ metadata: call_metadata,
693
+ retry_policy: @config.rpcs.recognize.retry_policy
694
+
695
+ options.apply_defaults timeout: @config.timeout,
696
+ metadata: @config.metadata,
697
+ retry_policy: @config.retry_policy
698
+
699
+ @speech_stub.recognize request, options do |result, operation|
700
+ yield result, operation if block_given?
701
+ return result
702
+ end
703
+ rescue ::Gapic::Rest::Error => e
704
+ raise ::Google::Cloud::Error.from_error(e)
705
+ end
706
+
707
+ ##
708
+ # Performs batch asynchronous speech recognition: send a request with N
709
+ # audio files and receive a long running operation that can be polled to see
710
+ # when the transcriptions are finished.
711
+ #
712
+ # @overload batch_recognize(request, options = nil)
713
+ # Pass arguments to `batch_recognize` via a request object, either of type
714
+ # {::Google::Cloud::Speech::V2::BatchRecognizeRequest} or an equivalent Hash.
715
+ #
716
+ # @param request [::Google::Cloud::Speech::V2::BatchRecognizeRequest, ::Hash]
717
+ # A request object representing the call parameters. Required. To specify no
718
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
719
+ # @param options [::Gapic::CallOptions, ::Hash]
720
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
721
+ #
722
+ # @overload batch_recognize(recognizer: nil, config: nil, config_mask: nil, files: nil, recognition_output_config: nil)
723
+ # Pass arguments to `batch_recognize` via keyword arguments. Note that at
724
+ # least one keyword argument is required. To specify no parameters, or to keep all
725
+ # the default parameter values, pass an empty Hash as a request object (see above).
726
+ #
727
+ # @param recognizer [::String]
728
+ # Required. Resource name of the recognizer to be used for ASR.
729
+ # @param config [::Google::Cloud::Speech::V2::RecognitionConfig, ::Hash]
730
+ # Features and audio metadata to use for the Automatic Speech Recognition.
731
+ # This field in combination with the
732
+ # {::Google::Cloud::Speech::V2::BatchRecognizeRequest#config_mask config_mask}
733
+ # field can be used to override parts of the
734
+ # {::Google::Cloud::Speech::V2::Recognizer#default_recognition_config default_recognition_config}
735
+ # of the Recognizer resource.
736
+ # @param config_mask [::Google::Protobuf::FieldMask, ::Hash]
737
+ # The list of fields in
738
+ # {::Google::Cloud::Speech::V2::BatchRecognizeRequest#config config} that override
739
+ # the values in the
740
+ # {::Google::Cloud::Speech::V2::Recognizer#default_recognition_config default_recognition_config}
741
+ # of the recognizer during this recognition request. If no mask is provided,
742
+ # all given fields in
743
+ # {::Google::Cloud::Speech::V2::BatchRecognizeRequest#config config} override the
744
+ # values in the recognizer for this recognition request. If a mask is
745
+ # provided, only the fields listed in the mask override the config in the
746
+ # recognizer for this recognition request. If a wildcard (`*`) is provided,
747
+ # {::Google::Cloud::Speech::V2::BatchRecognizeRequest#config config} completely
748
+ # overrides and replaces the config in the recognizer for this recognition
749
+ # request.
750
+ # @param files [::Array<::Google::Cloud::Speech::V2::BatchRecognizeFileMetadata, ::Hash>]
751
+ # Audio files with file metadata for ASR.
752
+ # The maximum number of files allowed to be specified is 5.
753
+ # @param recognition_output_config [::Google::Cloud::Speech::V2::RecognitionOutputConfig, ::Hash]
754
+ # Configuration options for where to output the transcripts of each file.
755
+ # @yield [result, operation] Access the result along with the TransportOperation object
756
+ # @yieldparam result [::Gapic::Operation]
757
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
758
+ #
759
+ # @return [::Gapic::Operation]
760
+ #
761
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
762
+ def batch_recognize request, options = nil
763
+ raise ::ArgumentError, "request must be provided" if request.nil?
764
+
765
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::BatchRecognizeRequest
766
+
767
+ # Converts hash and nil to an options object
768
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
769
+
770
+ # Customize the options with defaults
771
+ call_metadata = @config.rpcs.batch_recognize.metadata.to_h
772
+
773
+ # Set x-goog-api-client and x-goog-user-project headers
774
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
775
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
776
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
777
+ transports_version_send: [:rest]
778
+
779
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
780
+
781
+ options.apply_defaults timeout: @config.rpcs.batch_recognize.timeout,
782
+ metadata: call_metadata,
783
+ retry_policy: @config.rpcs.batch_recognize.retry_policy
784
+
785
+ options.apply_defaults timeout: @config.timeout,
786
+ metadata: @config.metadata,
787
+ retry_policy: @config.retry_policy
788
+
789
+ @speech_stub.batch_recognize request, options do |result, operation|
790
+ result = ::Gapic::Operation.new result, @operations_client, options: options
791
+ yield result, operation if block_given?
792
+ return result
793
+ end
794
+ rescue ::Gapic::Rest::Error => e
795
+ raise ::Google::Cloud::Error.from_error(e)
796
+ end
797
+
798
+ ##
799
+ # Returns the requested {::Google::Cloud::Speech::V2::Config Config}.
800
+ #
801
+ # @overload get_config(request, options = nil)
802
+ # Pass arguments to `get_config` via a request object, either of type
803
+ # {::Google::Cloud::Speech::V2::GetConfigRequest} or an equivalent Hash.
804
+ #
805
+ # @param request [::Google::Cloud::Speech::V2::GetConfigRequest, ::Hash]
806
+ # A request object representing the call parameters. Required. To specify no
807
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
808
+ # @param options [::Gapic::CallOptions, ::Hash]
809
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
810
+ #
811
+ # @overload get_config(name: nil)
812
+ # Pass arguments to `get_config` via keyword arguments. Note that at
813
+ # least one keyword argument is required. To specify no parameters, or to keep all
814
+ # the default parameter values, pass an empty Hash as a request object (see above).
815
+ #
816
+ # @param name [::String]
817
+ # Required. The name of the config to retrieve. There is exactly one config
818
+ # resource per project per location. The expected format is
819
+ # `projects/{project}/locations/{location}/config`.
820
+ # @yield [result, operation] Access the result along with the TransportOperation object
821
+ # @yieldparam result [::Google::Cloud::Speech::V2::Config]
822
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
823
+ #
824
+ # @return [::Google::Cloud::Speech::V2::Config]
825
+ #
826
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
827
+ def get_config request, options = nil
828
+ raise ::ArgumentError, "request must be provided" if request.nil?
829
+
830
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::GetConfigRequest
831
+
832
+ # Converts hash and nil to an options object
833
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
834
+
835
+ # Customize the options with defaults
836
+ call_metadata = @config.rpcs.get_config.metadata.to_h
837
+
838
+ # Set x-goog-api-client and x-goog-user-project headers
839
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
840
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
841
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
842
+ transports_version_send: [:rest]
843
+
844
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
845
+
846
+ options.apply_defaults timeout: @config.rpcs.get_config.timeout,
847
+ metadata: call_metadata,
848
+ retry_policy: @config.rpcs.get_config.retry_policy
849
+
850
+ options.apply_defaults timeout: @config.timeout,
851
+ metadata: @config.metadata,
852
+ retry_policy: @config.retry_policy
853
+
854
+ @speech_stub.get_config request, options do |result, operation|
855
+ yield result, operation if block_given?
856
+ return result
857
+ end
858
+ rescue ::Gapic::Rest::Error => e
859
+ raise ::Google::Cloud::Error.from_error(e)
860
+ end
861
+
862
+ ##
863
+ # Updates the {::Google::Cloud::Speech::V2::Config Config}.
864
+ #
865
+ # @overload update_config(request, options = nil)
866
+ # Pass arguments to `update_config` via a request object, either of type
867
+ # {::Google::Cloud::Speech::V2::UpdateConfigRequest} or an equivalent Hash.
868
+ #
869
+ # @param request [::Google::Cloud::Speech::V2::UpdateConfigRequest, ::Hash]
870
+ # A request object representing the call parameters. Required. To specify no
871
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
872
+ # @param options [::Gapic::CallOptions, ::Hash]
873
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
874
+ #
875
+ # @overload update_config(config: nil, update_mask: nil)
876
+ # Pass arguments to `update_config` via keyword arguments. Note that at
877
+ # least one keyword argument is required. To specify no parameters, or to keep all
878
+ # the default parameter values, pass an empty Hash as a request object (see above).
879
+ #
880
+ # @param config [::Google::Cloud::Speech::V2::Config, ::Hash]
881
+ # Required. The config to update.
882
+ #
883
+ # The config's `name` field is used to identify the config to be updated.
884
+ # The expected format is `projects/{project}/locations/{location}/config`.
885
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
886
+ # The list of fields to be updated.
887
+ # @yield [result, operation] Access the result along with the TransportOperation object
888
+ # @yieldparam result [::Google::Cloud::Speech::V2::Config]
889
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
890
+ #
891
+ # @return [::Google::Cloud::Speech::V2::Config]
892
+ #
893
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
894
+ def update_config request, options = nil
895
+ raise ::ArgumentError, "request must be provided" if request.nil?
896
+
897
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UpdateConfigRequest
898
+
899
+ # Converts hash and nil to an options object
900
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
901
+
902
+ # Customize the options with defaults
903
+ call_metadata = @config.rpcs.update_config.metadata.to_h
904
+
905
+ # Set x-goog-api-client and x-goog-user-project headers
906
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
907
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
908
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
909
+ transports_version_send: [:rest]
910
+
911
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
912
+
913
+ options.apply_defaults timeout: @config.rpcs.update_config.timeout,
914
+ metadata: call_metadata,
915
+ retry_policy: @config.rpcs.update_config.retry_policy
916
+
917
+ options.apply_defaults timeout: @config.timeout,
918
+ metadata: @config.metadata,
919
+ retry_policy: @config.retry_policy
920
+
921
+ @speech_stub.update_config request, options do |result, operation|
922
+ yield result, operation if block_given?
923
+ return result
924
+ end
925
+ rescue ::Gapic::Rest::Error => e
926
+ raise ::Google::Cloud::Error.from_error(e)
927
+ end
928
+
929
+ ##
930
+ # Creates a {::Google::Cloud::Speech::V2::CustomClass CustomClass}.
931
+ #
932
+ # @overload create_custom_class(request, options = nil)
933
+ # Pass arguments to `create_custom_class` via a request object, either of type
934
+ # {::Google::Cloud::Speech::V2::CreateCustomClassRequest} or an equivalent Hash.
935
+ #
936
+ # @param request [::Google::Cloud::Speech::V2::CreateCustomClassRequest, ::Hash]
937
+ # A request object representing the call parameters. Required. To specify no
938
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
939
+ # @param options [::Gapic::CallOptions, ::Hash]
940
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
941
+ #
942
+ # @overload create_custom_class(custom_class: nil, validate_only: nil, custom_class_id: nil, parent: nil)
943
+ # Pass arguments to `create_custom_class` via keyword arguments. Note that at
944
+ # least one keyword argument is required. To specify no parameters, or to keep all
945
+ # the default parameter values, pass an empty Hash as a request object (see above).
946
+ #
947
+ # @param custom_class [::Google::Cloud::Speech::V2::CustomClass, ::Hash]
948
+ # Required. The CustomClass to create.
949
+ # @param validate_only [::Boolean]
950
+ # If set, validate the request and preview the CustomClass, but do not
951
+ # actually create it.
952
+ # @param custom_class_id [::String]
953
+ # The ID to use for the CustomClass, which will become the final component of
954
+ # the CustomClass's resource name.
955
+ #
956
+ # This value should be 4-63 characters, and valid characters
957
+ # are /[a-z][0-9]-/.
958
+ # @param parent [::String]
959
+ # Required. The project and location where this CustomClass will be created.
960
+ # The expected format is `projects/{project}/locations/{location}`.
961
+ # @yield [result, operation] Access the result along with the TransportOperation object
962
+ # @yieldparam result [::Gapic::Operation]
963
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
964
+ #
965
+ # @return [::Gapic::Operation]
966
+ #
967
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
968
+ def create_custom_class request, options = nil
969
+ raise ::ArgumentError, "request must be provided" if request.nil?
970
+
971
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::CreateCustomClassRequest
972
+
973
+ # Converts hash and nil to an options object
974
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
975
+
976
+ # Customize the options with defaults
977
+ call_metadata = @config.rpcs.create_custom_class.metadata.to_h
978
+
979
+ # Set x-goog-api-client and x-goog-user-project headers
980
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
981
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
982
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
983
+ transports_version_send: [:rest]
984
+
985
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
986
+
987
+ options.apply_defaults timeout: @config.rpcs.create_custom_class.timeout,
988
+ metadata: call_metadata,
989
+ retry_policy: @config.rpcs.create_custom_class.retry_policy
990
+
991
+ options.apply_defaults timeout: @config.timeout,
992
+ metadata: @config.metadata,
993
+ retry_policy: @config.retry_policy
994
+
995
+ @speech_stub.create_custom_class request, options do |result, operation|
996
+ result = ::Gapic::Operation.new result, @operations_client, options: options
997
+ yield result, operation if block_given?
998
+ return result
999
+ end
1000
+ rescue ::Gapic::Rest::Error => e
1001
+ raise ::Google::Cloud::Error.from_error(e)
1002
+ end
1003
+
1004
+ ##
1005
+ # Lists CustomClasses.
1006
+ #
1007
+ # @overload list_custom_classes(request, options = nil)
1008
+ # Pass arguments to `list_custom_classes` via a request object, either of type
1009
+ # {::Google::Cloud::Speech::V2::ListCustomClassesRequest} or an equivalent Hash.
1010
+ #
1011
+ # @param request [::Google::Cloud::Speech::V2::ListCustomClassesRequest, ::Hash]
1012
+ # A request object representing the call parameters. Required. To specify no
1013
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1014
+ # @param options [::Gapic::CallOptions, ::Hash]
1015
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1016
+ #
1017
+ # @overload list_custom_classes(parent: nil, page_size: nil, page_token: nil, show_deleted: nil)
1018
+ # Pass arguments to `list_custom_classes` via keyword arguments. Note that at
1019
+ # least one keyword argument is required. To specify no parameters, or to keep all
1020
+ # the default parameter values, pass an empty Hash as a request object (see above).
1021
+ #
1022
+ # @param parent [::String]
1023
+ # Required. The project and location of CustomClass resources to list. The
1024
+ # expected format is `projects/{project}/locations/{location}`.
1025
+ # @param page_size [::Integer]
1026
+ # Number of results per requests. A valid page_size ranges from 0 to 20
1027
+ # inclusive. If the page_size is zero or unspecified, a page size of 5 will
1028
+ # be chosen. If the page size exceeds 20, it will be coerced down to 20. Note
1029
+ # that a call might return fewer results than the requested page size.
1030
+ # @param page_token [::String]
1031
+ # A page token, received from a previous
1032
+ # {::Google::Cloud::Speech::V2::Speech::Rest::Client#list_custom_classes ListCustomClasses} call.
1033
+ # Provide this to retrieve the subsequent page.
1034
+ #
1035
+ # When paginating, all other parameters provided to
1036
+ # {::Google::Cloud::Speech::V2::Speech::Rest::Client#list_custom_classes ListCustomClasses} must
1037
+ # match the call that provided the page token.
1038
+ # @param show_deleted [::Boolean]
1039
+ # Whether, or not, to show resources that have been deleted.
1040
+ # @yield [result, operation] Access the result along with the TransportOperation object
1041
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::CustomClass>]
1042
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1043
+ #
1044
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::CustomClass>]
1045
+ #
1046
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1047
+ def list_custom_classes request, options = nil
1048
+ raise ::ArgumentError, "request must be provided" if request.nil?
1049
+
1050
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::ListCustomClassesRequest
1051
+
1052
+ # Converts hash and nil to an options object
1053
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1054
+
1055
+ # Customize the options with defaults
1056
+ call_metadata = @config.rpcs.list_custom_classes.metadata.to_h
1057
+
1058
+ # Set x-goog-api-client and x-goog-user-project headers
1059
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1060
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1061
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
1062
+ transports_version_send: [:rest]
1063
+
1064
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1065
+
1066
+ options.apply_defaults timeout: @config.rpcs.list_custom_classes.timeout,
1067
+ metadata: call_metadata,
1068
+ retry_policy: @config.rpcs.list_custom_classes.retry_policy
1069
+
1070
+ options.apply_defaults timeout: @config.timeout,
1071
+ metadata: @config.metadata,
1072
+ retry_policy: @config.retry_policy
1073
+
1074
+ @speech_stub.list_custom_classes request, options do |result, operation|
1075
+ result = ::Gapic::Rest::PagedEnumerable.new @speech_stub, :list_custom_classes, "custom_classes", request, result, options
1076
+ yield result, operation if block_given?
1077
+ return result
1078
+ end
1079
+ rescue ::Gapic::Rest::Error => e
1080
+ raise ::Google::Cloud::Error.from_error(e)
1081
+ end
1082
+
1083
+ ##
1084
+ # Returns the requested
1085
+ # {::Google::Cloud::Speech::V2::CustomClass CustomClass}.
1086
+ #
1087
+ # @overload get_custom_class(request, options = nil)
1088
+ # Pass arguments to `get_custom_class` via a request object, either of type
1089
+ # {::Google::Cloud::Speech::V2::GetCustomClassRequest} or an equivalent Hash.
1090
+ #
1091
+ # @param request [::Google::Cloud::Speech::V2::GetCustomClassRequest, ::Hash]
1092
+ # A request object representing the call parameters. Required. To specify no
1093
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1094
+ # @param options [::Gapic::CallOptions, ::Hash]
1095
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1096
+ #
1097
+ # @overload get_custom_class(name: nil)
1098
+ # Pass arguments to `get_custom_class` via keyword arguments. Note that at
1099
+ # least one keyword argument is required. To specify no parameters, or to keep all
1100
+ # the default parameter values, pass an empty Hash as a request object (see above).
1101
+ #
1102
+ # @param name [::String]
1103
+ # Required. The name of the CustomClass to retrieve. The expected format is
1104
+ # `projects/{project}/locations/{location}/customClasses/{custom_class}`.
1105
+ # @yield [result, operation] Access the result along with the TransportOperation object
1106
+ # @yieldparam result [::Google::Cloud::Speech::V2::CustomClass]
1107
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1108
+ #
1109
+ # @return [::Google::Cloud::Speech::V2::CustomClass]
1110
+ #
1111
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1112
+ def get_custom_class request, options = nil
1113
+ raise ::ArgumentError, "request must be provided" if request.nil?
1114
+
1115
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::GetCustomClassRequest
1116
+
1117
+ # Converts hash and nil to an options object
1118
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1119
+
1120
+ # Customize the options with defaults
1121
+ call_metadata = @config.rpcs.get_custom_class.metadata.to_h
1122
+
1123
+ # Set x-goog-api-client and x-goog-user-project headers
1124
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1125
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1126
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
1127
+ transports_version_send: [:rest]
1128
+
1129
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1130
+
1131
+ options.apply_defaults timeout: @config.rpcs.get_custom_class.timeout,
1132
+ metadata: call_metadata,
1133
+ retry_policy: @config.rpcs.get_custom_class.retry_policy
1134
+
1135
+ options.apply_defaults timeout: @config.timeout,
1136
+ metadata: @config.metadata,
1137
+ retry_policy: @config.retry_policy
1138
+
1139
+ @speech_stub.get_custom_class request, options do |result, operation|
1140
+ yield result, operation if block_given?
1141
+ return result
1142
+ end
1143
+ rescue ::Gapic::Rest::Error => e
1144
+ raise ::Google::Cloud::Error.from_error(e)
1145
+ end
1146
+
1147
+ ##
1148
+ # Updates the {::Google::Cloud::Speech::V2::CustomClass CustomClass}.
1149
+ #
1150
+ # @overload update_custom_class(request, options = nil)
1151
+ # Pass arguments to `update_custom_class` via a request object, either of type
1152
+ # {::Google::Cloud::Speech::V2::UpdateCustomClassRequest} or an equivalent Hash.
1153
+ #
1154
+ # @param request [::Google::Cloud::Speech::V2::UpdateCustomClassRequest, ::Hash]
1155
+ # A request object representing the call parameters. Required. To specify no
1156
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1157
+ # @param options [::Gapic::CallOptions, ::Hash]
1158
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1159
+ #
1160
+ # @overload update_custom_class(custom_class: nil, update_mask: nil, validate_only: nil)
1161
+ # Pass arguments to `update_custom_class` via keyword arguments. Note that at
1162
+ # least one keyword argument is required. To specify no parameters, or to keep all
1163
+ # the default parameter values, pass an empty Hash as a request object (see above).
1164
+ #
1165
+ # @param custom_class [::Google::Cloud::Speech::V2::CustomClass, ::Hash]
1166
+ # Required. The CustomClass to update.
1167
+ #
1168
+ # The CustomClass's `name` field is used to identify the CustomClass to
1169
+ # update. Format:
1170
+ # `projects/{project}/locations/{location}/customClasses/{custom_class}`.
1171
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
1172
+ # The list of fields to be updated. If empty, all fields are considered for
1173
+ # update.
1174
+ # @param validate_only [::Boolean]
1175
+ # If set, validate the request and preview the updated CustomClass, but do
1176
+ # not actually update it.
1177
+ # @yield [result, operation] Access the result along with the TransportOperation object
1178
+ # @yieldparam result [::Gapic::Operation]
1179
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1180
+ #
1181
+ # @return [::Gapic::Operation]
1182
+ #
1183
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1184
+ def update_custom_class request, options = nil
1185
+ raise ::ArgumentError, "request must be provided" if request.nil?
1186
+
1187
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UpdateCustomClassRequest
1188
+
1189
+ # Converts hash and nil to an options object
1190
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1191
+
1192
+ # Customize the options with defaults
1193
+ call_metadata = @config.rpcs.update_custom_class.metadata.to_h
1194
+
1195
+ # Set x-goog-api-client and x-goog-user-project headers
1196
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1197
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1198
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
1199
+ transports_version_send: [:rest]
1200
+
1201
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1202
+
1203
+ options.apply_defaults timeout: @config.rpcs.update_custom_class.timeout,
1204
+ metadata: call_metadata,
1205
+ retry_policy: @config.rpcs.update_custom_class.retry_policy
1206
+
1207
+ options.apply_defaults timeout: @config.timeout,
1208
+ metadata: @config.metadata,
1209
+ retry_policy: @config.retry_policy
1210
+
1211
+ @speech_stub.update_custom_class request, options do |result, operation|
1212
+ result = ::Gapic::Operation.new result, @operations_client, options: options
1213
+ yield result, operation if block_given?
1214
+ return result
1215
+ end
1216
+ rescue ::Gapic::Rest::Error => e
1217
+ raise ::Google::Cloud::Error.from_error(e)
1218
+ end
1219
+
1220
+ ##
1221
+ # Deletes the {::Google::Cloud::Speech::V2::CustomClass CustomClass}.
1222
+ #
1223
+ # @overload delete_custom_class(request, options = nil)
1224
+ # Pass arguments to `delete_custom_class` via a request object, either of type
1225
+ # {::Google::Cloud::Speech::V2::DeleteCustomClassRequest} or an equivalent Hash.
1226
+ #
1227
+ # @param request [::Google::Cloud::Speech::V2::DeleteCustomClassRequest, ::Hash]
1228
+ # A request object representing the call parameters. Required. To specify no
1229
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1230
+ # @param options [::Gapic::CallOptions, ::Hash]
1231
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1232
+ #
1233
+ # @overload delete_custom_class(name: nil, validate_only: nil, allow_missing: nil, etag: nil)
1234
+ # Pass arguments to `delete_custom_class` via keyword arguments. Note that at
1235
+ # least one keyword argument is required. To specify no parameters, or to keep all
1236
+ # the default parameter values, pass an empty Hash as a request object (see above).
1237
+ #
1238
+ # @param name [::String]
1239
+ # Required. The name of the CustomClass to delete.
1240
+ # Format:
1241
+ # `projects/{project}/locations/{location}/customClasses/{custom_class}`
1242
+ # @param validate_only [::Boolean]
1243
+ # If set, validate the request and preview the deleted CustomClass, but do
1244
+ # not actually delete it.
1245
+ # @param allow_missing [::Boolean]
1246
+ # If set to true, and the CustomClass is not found, the request will succeed
1247
+ # and be a no-op (no Operation is recorded in this case).
1248
+ # @param etag [::String]
1249
+ # This checksum is computed by the server based on the value of other
1250
+ # fields. This may be sent on update, undelete, and delete requests to ensure
1251
+ # the client has an up-to-date value before proceeding.
1252
+ # @yield [result, operation] Access the result along with the TransportOperation object
1253
+ # @yieldparam result [::Gapic::Operation]
1254
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1255
+ #
1256
+ # @return [::Gapic::Operation]
1257
+ #
1258
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1259
+ def delete_custom_class request, options = nil
1260
+ raise ::ArgumentError, "request must be provided" if request.nil?
1261
+
1262
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::DeleteCustomClassRequest
1263
+
1264
+ # Converts hash and nil to an options object
1265
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1266
+
1267
+ # Customize the options with defaults
1268
+ call_metadata = @config.rpcs.delete_custom_class.metadata.to_h
1269
+
1270
+ # Set x-goog-api-client and x-goog-user-project headers
1271
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1272
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1273
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
1274
+ transports_version_send: [:rest]
1275
+
1276
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1277
+
1278
+ options.apply_defaults timeout: @config.rpcs.delete_custom_class.timeout,
1279
+ metadata: call_metadata,
1280
+ retry_policy: @config.rpcs.delete_custom_class.retry_policy
1281
+
1282
+ options.apply_defaults timeout: @config.timeout,
1283
+ metadata: @config.metadata,
1284
+ retry_policy: @config.retry_policy
1285
+
1286
+ @speech_stub.delete_custom_class request, options do |result, operation|
1287
+ result = ::Gapic::Operation.new result, @operations_client, options: options
1288
+ yield result, operation if block_given?
1289
+ return result
1290
+ end
1291
+ rescue ::Gapic::Rest::Error => e
1292
+ raise ::Google::Cloud::Error.from_error(e)
1293
+ end
1294
+
1295
+ ##
1296
+ # Undeletes the {::Google::Cloud::Speech::V2::CustomClass CustomClass}.
1297
+ #
1298
+ # @overload undelete_custom_class(request, options = nil)
1299
+ # Pass arguments to `undelete_custom_class` via a request object, either of type
1300
+ # {::Google::Cloud::Speech::V2::UndeleteCustomClassRequest} or an equivalent Hash.
1301
+ #
1302
+ # @param request [::Google::Cloud::Speech::V2::UndeleteCustomClassRequest, ::Hash]
1303
+ # A request object representing the call parameters. Required. To specify no
1304
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1305
+ # @param options [::Gapic::CallOptions, ::Hash]
1306
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1307
+ #
1308
+ # @overload undelete_custom_class(name: nil, validate_only: nil, etag: nil)
1309
+ # Pass arguments to `undelete_custom_class` via keyword arguments. Note that at
1310
+ # least one keyword argument is required. To specify no parameters, or to keep all
1311
+ # the default parameter values, pass an empty Hash as a request object (see above).
1312
+ #
1313
+ # @param name [::String]
1314
+ # Required. The name of the CustomClass to undelete.
1315
+ # Format:
1316
+ # `projects/{project}/locations/{location}/customClasses/{custom_class}`
1317
+ # @param validate_only [::Boolean]
1318
+ # If set, validate the request and preview the undeleted CustomClass, but do
1319
+ # not actually undelete it.
1320
+ # @param etag [::String]
1321
+ # This checksum is computed by the server based on the value of other
1322
+ # fields. This may be sent on update, undelete, and delete requests to ensure
1323
+ # the client has an up-to-date value before proceeding.
1324
+ # @yield [result, operation] Access the result along with the TransportOperation object
1325
+ # @yieldparam result [::Gapic::Operation]
1326
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1327
+ #
1328
+ # @return [::Gapic::Operation]
1329
+ #
1330
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1331
+ def undelete_custom_class request, options = nil
1332
+ raise ::ArgumentError, "request must be provided" if request.nil?
1333
+
1334
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UndeleteCustomClassRequest
1335
+
1336
+ # Converts hash and nil to an options object
1337
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1338
+
1339
+ # Customize the options with defaults
1340
+ call_metadata = @config.rpcs.undelete_custom_class.metadata.to_h
1341
+
1342
+ # Set x-goog-api-client and x-goog-user-project headers
1343
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1344
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1345
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
1346
+ transports_version_send: [:rest]
1347
+
1348
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1349
+
1350
+ options.apply_defaults timeout: @config.rpcs.undelete_custom_class.timeout,
1351
+ metadata: call_metadata,
1352
+ retry_policy: @config.rpcs.undelete_custom_class.retry_policy
1353
+
1354
+ options.apply_defaults timeout: @config.timeout,
1355
+ metadata: @config.metadata,
1356
+ retry_policy: @config.retry_policy
1357
+
1358
+ @speech_stub.undelete_custom_class request, options do |result, operation|
1359
+ result = ::Gapic::Operation.new result, @operations_client, options: options
1360
+ yield result, operation if block_given?
1361
+ return result
1362
+ end
1363
+ rescue ::Gapic::Rest::Error => e
1364
+ raise ::Google::Cloud::Error.from_error(e)
1365
+ end
1366
+
1367
+ ##
1368
+ # Creates a {::Google::Cloud::Speech::V2::PhraseSet PhraseSet}.
1369
+ #
1370
+ # @overload create_phrase_set(request, options = nil)
1371
+ # Pass arguments to `create_phrase_set` via a request object, either of type
1372
+ # {::Google::Cloud::Speech::V2::CreatePhraseSetRequest} or an equivalent Hash.
1373
+ #
1374
+ # @param request [::Google::Cloud::Speech::V2::CreatePhraseSetRequest, ::Hash]
1375
+ # A request object representing the call parameters. Required. To specify no
1376
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1377
+ # @param options [::Gapic::CallOptions, ::Hash]
1378
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1379
+ #
1380
+ # @overload create_phrase_set(phrase_set: nil, validate_only: nil, phrase_set_id: nil, parent: nil)
1381
+ # Pass arguments to `create_phrase_set` via keyword arguments. Note that at
1382
+ # least one keyword argument is required. To specify no parameters, or to keep all
1383
+ # the default parameter values, pass an empty Hash as a request object (see above).
1384
+ #
1385
+ # @param phrase_set [::Google::Cloud::Speech::V2::PhraseSet, ::Hash]
1386
+ # Required. The PhraseSet to create.
1387
+ # @param validate_only [::Boolean]
1388
+ # If set, validate the request and preview the PhraseSet, but do not
1389
+ # actually create it.
1390
+ # @param phrase_set_id [::String]
1391
+ # The ID to use for the PhraseSet, which will become the final component of
1392
+ # the PhraseSet's resource name.
1393
+ #
1394
+ # This value should be 4-63 characters, and valid characters
1395
+ # are /[a-z][0-9]-/.
1396
+ # @param parent [::String]
1397
+ # Required. The project and location where this PhraseSet will be created.
1398
+ # The expected format is `projects/{project}/locations/{location}`.
1399
+ # @yield [result, operation] Access the result along with the TransportOperation object
1400
+ # @yieldparam result [::Gapic::Operation]
1401
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1402
+ #
1403
+ # @return [::Gapic::Operation]
1404
+ #
1405
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1406
+ def create_phrase_set request, options = nil
1407
+ raise ::ArgumentError, "request must be provided" if request.nil?
1408
+
1409
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::CreatePhraseSetRequest
1410
+
1411
+ # Converts hash and nil to an options object
1412
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1413
+
1414
+ # Customize the options with defaults
1415
+ call_metadata = @config.rpcs.create_phrase_set.metadata.to_h
1416
+
1417
+ # Set x-goog-api-client and x-goog-user-project headers
1418
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1419
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1420
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
1421
+ transports_version_send: [:rest]
1422
+
1423
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1424
+
1425
+ options.apply_defaults timeout: @config.rpcs.create_phrase_set.timeout,
1426
+ metadata: call_metadata,
1427
+ retry_policy: @config.rpcs.create_phrase_set.retry_policy
1428
+
1429
+ options.apply_defaults timeout: @config.timeout,
1430
+ metadata: @config.metadata,
1431
+ retry_policy: @config.retry_policy
1432
+
1433
+ @speech_stub.create_phrase_set request, options do |result, operation|
1434
+ result = ::Gapic::Operation.new result, @operations_client, options: options
1435
+ yield result, operation if block_given?
1436
+ return result
1437
+ end
1438
+ rescue ::Gapic::Rest::Error => e
1439
+ raise ::Google::Cloud::Error.from_error(e)
1440
+ end
1441
+
1442
+ ##
1443
+ # Lists PhraseSets.
1444
+ #
1445
+ # @overload list_phrase_sets(request, options = nil)
1446
+ # Pass arguments to `list_phrase_sets` via a request object, either of type
1447
+ # {::Google::Cloud::Speech::V2::ListPhraseSetsRequest} or an equivalent Hash.
1448
+ #
1449
+ # @param request [::Google::Cloud::Speech::V2::ListPhraseSetsRequest, ::Hash]
1450
+ # A request object representing the call parameters. Required. To specify no
1451
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1452
+ # @param options [::Gapic::CallOptions, ::Hash]
1453
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1454
+ #
1455
+ # @overload list_phrase_sets(parent: nil, page_size: nil, page_token: nil, show_deleted: nil)
1456
+ # Pass arguments to `list_phrase_sets` via keyword arguments. Note that at
1457
+ # least one keyword argument is required. To specify no parameters, or to keep all
1458
+ # the default parameter values, pass an empty Hash as a request object (see above).
1459
+ #
1460
+ # @param parent [::String]
1461
+ # Required. The project and location of PhraseSet resources to list. The
1462
+ # expected format is `projects/{project}/locations/{location}`.
1463
+ # @param page_size [::Integer]
1464
+ # The maximum number of PhraseSets to return. The service may return fewer
1465
+ # than this value. If unspecified, at most 20 PhraseSets will be returned.
1466
+ # The maximum value is 20; values above 20 will be coerced to 20.
1467
+ # @param page_token [::String]
1468
+ # A page token, received from a previous
1469
+ # {::Google::Cloud::Speech::V2::Speech::Rest::Client#list_phrase_sets ListPhraseSets} call.
1470
+ # Provide this to retrieve the subsequent page.
1471
+ #
1472
+ # When paginating, all other parameters provided to
1473
+ # {::Google::Cloud::Speech::V2::Speech::Rest::Client#list_phrase_sets ListPhraseSets} must match
1474
+ # the call that provided the page token.
1475
+ # @param show_deleted [::Boolean]
1476
+ # Whether, or not, to show resources that have been deleted.
1477
+ # @yield [result, operation] Access the result along with the TransportOperation object
1478
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::PhraseSet>]
1479
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1480
+ #
1481
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Speech::V2::PhraseSet>]
1482
+ #
1483
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1484
+ def list_phrase_sets request, options = nil
1485
+ raise ::ArgumentError, "request must be provided" if request.nil?
1486
+
1487
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::ListPhraseSetsRequest
1488
+
1489
+ # Converts hash and nil to an options object
1490
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1491
+
1492
+ # Customize the options with defaults
1493
+ call_metadata = @config.rpcs.list_phrase_sets.metadata.to_h
1494
+
1495
+ # Set x-goog-api-client and x-goog-user-project headers
1496
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1497
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1498
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
1499
+ transports_version_send: [:rest]
1500
+
1501
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1502
+
1503
+ options.apply_defaults timeout: @config.rpcs.list_phrase_sets.timeout,
1504
+ metadata: call_metadata,
1505
+ retry_policy: @config.rpcs.list_phrase_sets.retry_policy
1506
+
1507
+ options.apply_defaults timeout: @config.timeout,
1508
+ metadata: @config.metadata,
1509
+ retry_policy: @config.retry_policy
1510
+
1511
+ @speech_stub.list_phrase_sets request, options do |result, operation|
1512
+ result = ::Gapic::Rest::PagedEnumerable.new @speech_stub, :list_phrase_sets, "phrase_sets", request, result, options
1513
+ yield result, operation if block_given?
1514
+ return result
1515
+ end
1516
+ rescue ::Gapic::Rest::Error => e
1517
+ raise ::Google::Cloud::Error.from_error(e)
1518
+ end
1519
+
1520
+ ##
1521
+ # Returns the requested
1522
+ # {::Google::Cloud::Speech::V2::PhraseSet PhraseSet}.
1523
+ #
1524
+ # @overload get_phrase_set(request, options = nil)
1525
+ # Pass arguments to `get_phrase_set` via a request object, either of type
1526
+ # {::Google::Cloud::Speech::V2::GetPhraseSetRequest} or an equivalent Hash.
1527
+ #
1528
+ # @param request [::Google::Cloud::Speech::V2::GetPhraseSetRequest, ::Hash]
1529
+ # A request object representing the call parameters. Required. To specify no
1530
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1531
+ # @param options [::Gapic::CallOptions, ::Hash]
1532
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1533
+ #
1534
+ # @overload get_phrase_set(name: nil)
1535
+ # Pass arguments to `get_phrase_set` via keyword arguments. Note that at
1536
+ # least one keyword argument is required. To specify no parameters, or to keep all
1537
+ # the default parameter values, pass an empty Hash as a request object (see above).
1538
+ #
1539
+ # @param name [::String]
1540
+ # Required. The name of the PhraseSet to retrieve. The expected format is
1541
+ # `projects/{project}/locations/{location}/phraseSets/{phrase_set}`.
1542
+ # @yield [result, operation] Access the result along with the TransportOperation object
1543
+ # @yieldparam result [::Google::Cloud::Speech::V2::PhraseSet]
1544
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1545
+ #
1546
+ # @return [::Google::Cloud::Speech::V2::PhraseSet]
1547
+ #
1548
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1549
+ def get_phrase_set request, options = nil
1550
+ raise ::ArgumentError, "request must be provided" if request.nil?
1551
+
1552
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::GetPhraseSetRequest
1553
+
1554
+ # Converts hash and nil to an options object
1555
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1556
+
1557
+ # Customize the options with defaults
1558
+ call_metadata = @config.rpcs.get_phrase_set.metadata.to_h
1559
+
1560
+ # Set x-goog-api-client and x-goog-user-project headers
1561
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1562
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1563
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
1564
+ transports_version_send: [:rest]
1565
+
1566
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1567
+
1568
+ options.apply_defaults timeout: @config.rpcs.get_phrase_set.timeout,
1569
+ metadata: call_metadata,
1570
+ retry_policy: @config.rpcs.get_phrase_set.retry_policy
1571
+
1572
+ options.apply_defaults timeout: @config.timeout,
1573
+ metadata: @config.metadata,
1574
+ retry_policy: @config.retry_policy
1575
+
1576
+ @speech_stub.get_phrase_set request, options do |result, operation|
1577
+ yield result, operation if block_given?
1578
+ return result
1579
+ end
1580
+ rescue ::Gapic::Rest::Error => e
1581
+ raise ::Google::Cloud::Error.from_error(e)
1582
+ end
1583
+
1584
+ ##
1585
+ # Updates the {::Google::Cloud::Speech::V2::PhraseSet PhraseSet}.
1586
+ #
1587
+ # @overload update_phrase_set(request, options = nil)
1588
+ # Pass arguments to `update_phrase_set` via a request object, either of type
1589
+ # {::Google::Cloud::Speech::V2::UpdatePhraseSetRequest} or an equivalent Hash.
1590
+ #
1591
+ # @param request [::Google::Cloud::Speech::V2::UpdatePhraseSetRequest, ::Hash]
1592
+ # A request object representing the call parameters. Required. To specify no
1593
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1594
+ # @param options [::Gapic::CallOptions, ::Hash]
1595
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1596
+ #
1597
+ # @overload update_phrase_set(phrase_set: nil, update_mask: nil, validate_only: nil)
1598
+ # Pass arguments to `update_phrase_set` via keyword arguments. Note that at
1599
+ # least one keyword argument is required. To specify no parameters, or to keep all
1600
+ # the default parameter values, pass an empty Hash as a request object (see above).
1601
+ #
1602
+ # @param phrase_set [::Google::Cloud::Speech::V2::PhraseSet, ::Hash]
1603
+ # Required. The PhraseSet to update.
1604
+ #
1605
+ # The PhraseSet's `name` field is used to identify the PhraseSet to update.
1606
+ # Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`.
1607
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
1608
+ # The list of fields to update. If empty, all non-default valued fields are
1609
+ # considered for update. Use `*` to update the entire PhraseSet resource.
1610
+ # @param validate_only [::Boolean]
1611
+ # If set, validate the request and preview the updated PhraseSet, but do not
1612
+ # actually update it.
1613
+ # @yield [result, operation] Access the result along with the TransportOperation object
1614
+ # @yieldparam result [::Gapic::Operation]
1615
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1616
+ #
1617
+ # @return [::Gapic::Operation]
1618
+ #
1619
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1620
+ def update_phrase_set request, options = nil
1621
+ raise ::ArgumentError, "request must be provided" if request.nil?
1622
+
1623
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UpdatePhraseSetRequest
1624
+
1625
+ # Converts hash and nil to an options object
1626
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1627
+
1628
+ # Customize the options with defaults
1629
+ call_metadata = @config.rpcs.update_phrase_set.metadata.to_h
1630
+
1631
+ # Set x-goog-api-client and x-goog-user-project headers
1632
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1633
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1634
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
1635
+ transports_version_send: [:rest]
1636
+
1637
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1638
+
1639
+ options.apply_defaults timeout: @config.rpcs.update_phrase_set.timeout,
1640
+ metadata: call_metadata,
1641
+ retry_policy: @config.rpcs.update_phrase_set.retry_policy
1642
+
1643
+ options.apply_defaults timeout: @config.timeout,
1644
+ metadata: @config.metadata,
1645
+ retry_policy: @config.retry_policy
1646
+
1647
+ @speech_stub.update_phrase_set request, options do |result, operation|
1648
+ result = ::Gapic::Operation.new result, @operations_client, options: options
1649
+ yield result, operation if block_given?
1650
+ return result
1651
+ end
1652
+ rescue ::Gapic::Rest::Error => e
1653
+ raise ::Google::Cloud::Error.from_error(e)
1654
+ end
1655
+
1656
+ ##
1657
+ # Deletes the {::Google::Cloud::Speech::V2::PhraseSet PhraseSet}.
1658
+ #
1659
+ # @overload delete_phrase_set(request, options = nil)
1660
+ # Pass arguments to `delete_phrase_set` via a request object, either of type
1661
+ # {::Google::Cloud::Speech::V2::DeletePhraseSetRequest} or an equivalent Hash.
1662
+ #
1663
+ # @param request [::Google::Cloud::Speech::V2::DeletePhraseSetRequest, ::Hash]
1664
+ # A request object representing the call parameters. Required. To specify no
1665
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1666
+ # @param options [::Gapic::CallOptions, ::Hash]
1667
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1668
+ #
1669
+ # @overload delete_phrase_set(name: nil, validate_only: nil, allow_missing: nil, etag: nil)
1670
+ # Pass arguments to `delete_phrase_set` via keyword arguments. Note that at
1671
+ # least one keyword argument is required. To specify no parameters, or to keep all
1672
+ # the default parameter values, pass an empty Hash as a request object (see above).
1673
+ #
1674
+ # @param name [::String]
1675
+ # Required. The name of the PhraseSet to delete.
1676
+ # Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`
1677
+ # @param validate_only [::Boolean]
1678
+ # If set, validate the request and preview the deleted PhraseSet, but do not
1679
+ # actually delete it.
1680
+ # @param allow_missing [::Boolean]
1681
+ # If set to true, and the PhraseSet is not found, the request will succeed
1682
+ # and be a no-op (no Operation is recorded in this case).
1683
+ # @param etag [::String]
1684
+ # This checksum is computed by the server based on the value of other
1685
+ # fields. This may be sent on update, undelete, and delete requests to ensure
1686
+ # the client has an up-to-date value before proceeding.
1687
+ # @yield [result, operation] Access the result along with the TransportOperation object
1688
+ # @yieldparam result [::Gapic::Operation]
1689
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1690
+ #
1691
+ # @return [::Gapic::Operation]
1692
+ #
1693
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1694
+ def delete_phrase_set request, options = nil
1695
+ raise ::ArgumentError, "request must be provided" if request.nil?
1696
+
1697
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::DeletePhraseSetRequest
1698
+
1699
+ # Converts hash and nil to an options object
1700
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1701
+
1702
+ # Customize the options with defaults
1703
+ call_metadata = @config.rpcs.delete_phrase_set.metadata.to_h
1704
+
1705
+ # Set x-goog-api-client and x-goog-user-project headers
1706
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1707
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1708
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
1709
+ transports_version_send: [:rest]
1710
+
1711
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1712
+
1713
+ options.apply_defaults timeout: @config.rpcs.delete_phrase_set.timeout,
1714
+ metadata: call_metadata,
1715
+ retry_policy: @config.rpcs.delete_phrase_set.retry_policy
1716
+
1717
+ options.apply_defaults timeout: @config.timeout,
1718
+ metadata: @config.metadata,
1719
+ retry_policy: @config.retry_policy
1720
+
1721
+ @speech_stub.delete_phrase_set request, options do |result, operation|
1722
+ result = ::Gapic::Operation.new result, @operations_client, options: options
1723
+ yield result, operation if block_given?
1724
+ return result
1725
+ end
1726
+ rescue ::Gapic::Rest::Error => e
1727
+ raise ::Google::Cloud::Error.from_error(e)
1728
+ end
1729
+
1730
+ ##
1731
+ # Undeletes the {::Google::Cloud::Speech::V2::PhraseSet PhraseSet}.
1732
+ #
1733
+ # @overload undelete_phrase_set(request, options = nil)
1734
+ # Pass arguments to `undelete_phrase_set` via a request object, either of type
1735
+ # {::Google::Cloud::Speech::V2::UndeletePhraseSetRequest} or an equivalent Hash.
1736
+ #
1737
+ # @param request [::Google::Cloud::Speech::V2::UndeletePhraseSetRequest, ::Hash]
1738
+ # A request object representing the call parameters. Required. To specify no
1739
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1740
+ # @param options [::Gapic::CallOptions, ::Hash]
1741
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1742
+ #
1743
+ # @overload undelete_phrase_set(name: nil, validate_only: nil, etag: nil)
1744
+ # Pass arguments to `undelete_phrase_set` via keyword arguments. Note that at
1745
+ # least one keyword argument is required. To specify no parameters, or to keep all
1746
+ # the default parameter values, pass an empty Hash as a request object (see above).
1747
+ #
1748
+ # @param name [::String]
1749
+ # Required. The name of the PhraseSet to undelete.
1750
+ # Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`
1751
+ # @param validate_only [::Boolean]
1752
+ # If set, validate the request and preview the undeleted PhraseSet, but do
1753
+ # not actually undelete it.
1754
+ # @param etag [::String]
1755
+ # This checksum is computed by the server based on the value of other
1756
+ # fields. This may be sent on update, undelete, and delete requests to ensure
1757
+ # the client has an up-to-date value before proceeding.
1758
+ # @yield [result, operation] Access the result along with the TransportOperation object
1759
+ # @yieldparam result [::Gapic::Operation]
1760
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1761
+ #
1762
+ # @return [::Gapic::Operation]
1763
+ #
1764
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1765
+ def undelete_phrase_set request, options = nil
1766
+ raise ::ArgumentError, "request must be provided" if request.nil?
1767
+
1768
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UndeletePhraseSetRequest
1769
+
1770
+ # Converts hash and nil to an options object
1771
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1772
+
1773
+ # Customize the options with defaults
1774
+ call_metadata = @config.rpcs.undelete_phrase_set.metadata.to_h
1775
+
1776
+ # Set x-goog-api-client and x-goog-user-project headers
1777
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1778
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1779
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION,
1780
+ transports_version_send: [:rest]
1781
+
1782
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1783
+
1784
+ options.apply_defaults timeout: @config.rpcs.undelete_phrase_set.timeout,
1785
+ metadata: call_metadata,
1786
+ retry_policy: @config.rpcs.undelete_phrase_set.retry_policy
1787
+
1788
+ options.apply_defaults timeout: @config.timeout,
1789
+ metadata: @config.metadata,
1790
+ retry_policy: @config.retry_policy
1791
+
1792
+ @speech_stub.undelete_phrase_set request, options do |result, operation|
1793
+ result = ::Gapic::Operation.new result, @operations_client, options: options
1794
+ yield result, operation if block_given?
1795
+ return result
1796
+ end
1797
+ rescue ::Gapic::Rest::Error => e
1798
+ raise ::Google::Cloud::Error.from_error(e)
1799
+ end
1800
+
1801
+ ##
1802
+ # Configuration class for the Speech REST API.
1803
+ #
1804
+ # This class represents the configuration for Speech REST,
1805
+ # providing control over timeouts, retry behavior, logging, transport
1806
+ # parameters, and other low-level controls. Certain parameters can also be
1807
+ # applied individually to specific RPCs. See
1808
+ # {::Google::Cloud::Speech::V2::Speech::Rest::Client::Configuration::Rpcs}
1809
+ # for a list of RPCs that can be configured independently.
1810
+ #
1811
+ # Configuration can be applied globally to all clients, or to a single client
1812
+ # on construction.
1813
+ #
1814
+ # @example
1815
+ #
1816
+ # # Modify the global config, setting the timeout for
1817
+ # # create_recognizer to 20 seconds,
1818
+ # # and all remaining timeouts to 10 seconds.
1819
+ # ::Google::Cloud::Speech::V2::Speech::Rest::Client.configure do |config|
1820
+ # config.timeout = 10.0
1821
+ # config.rpcs.create_recognizer.timeout = 20.0
1822
+ # end
1823
+ #
1824
+ # # Apply the above configuration only to a new client.
1825
+ # client = ::Google::Cloud::Speech::V2::Speech::Rest::Client.new do |config|
1826
+ # config.timeout = 10.0
1827
+ # config.rpcs.create_recognizer.timeout = 20.0
1828
+ # end
1829
+ #
1830
+ # @!attribute [rw] endpoint
1831
+ # The hostname or hostname:port of the service endpoint.
1832
+ # Defaults to `"speech.googleapis.com"`.
1833
+ # @return [::String]
1834
+ # @!attribute [rw] credentials
1835
+ # Credentials to send with calls. You may provide any of the following types:
1836
+ # * (`String`) The path to a service account key file in JSON format
1837
+ # * (`Hash`) A service account key as a Hash
1838
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
1839
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
1840
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
1841
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
1842
+ # * (`nil`) indicating no credentials
1843
+ # @return [::Object]
1844
+ # @!attribute [rw] scope
1845
+ # The OAuth scopes
1846
+ # @return [::Array<::String>]
1847
+ # @!attribute [rw] lib_name
1848
+ # The library name as recorded in instrumentation and logging
1849
+ # @return [::String]
1850
+ # @!attribute [rw] lib_version
1851
+ # The library version as recorded in instrumentation and logging
1852
+ # @return [::String]
1853
+ # @!attribute [rw] timeout
1854
+ # The call timeout in seconds.
1855
+ # @return [::Numeric]
1856
+ # @!attribute [rw] metadata
1857
+ # Additional headers to be sent with the call.
1858
+ # @return [::Hash{::Symbol=>::String}]
1859
+ # @!attribute [rw] retry_policy
1860
+ # The retry policy. The value is a hash with the following keys:
1861
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1862
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1863
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1864
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1865
+ # trigger a retry.
1866
+ # @return [::Hash]
1867
+ # @!attribute [rw] quota_project
1868
+ # A separate project against which to charge quota.
1869
+ # @return [::String]
1870
+ #
1871
+ class Configuration
1872
+ extend ::Gapic::Config
1873
+
1874
+ config_attr :endpoint, "speech.googleapis.com", ::String
1875
+ config_attr :credentials, nil do |value|
1876
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1877
+ allowed.any? { |klass| klass === value }
1878
+ end
1879
+ config_attr :scope, nil, ::String, ::Array, nil
1880
+ config_attr :lib_name, nil, ::String, nil
1881
+ config_attr :lib_version, nil, ::String, nil
1882
+ config_attr :timeout, nil, ::Numeric, nil
1883
+ config_attr :metadata, nil, ::Hash, nil
1884
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1885
+ config_attr :quota_project, nil, ::String, nil
1886
+
1887
+ # @private
1888
+ # Overrides for http bindings for the RPCs of this service
1889
+ # are only used when this service is used as mixin, and only
1890
+ # by the host service.
1891
+ # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
1892
+ config_attr :bindings_override, {}, ::Hash, nil
1893
+
1894
+ # @private
1895
+ def initialize parent_config = nil
1896
+ @parent_config = parent_config unless parent_config.nil?
1897
+
1898
+ yield self if block_given?
1899
+ end
1900
+
1901
+ ##
1902
+ # Configurations for individual RPCs
1903
+ # @return [Rpcs]
1904
+ #
1905
+ def rpcs
1906
+ @rpcs ||= begin
1907
+ parent_rpcs = nil
1908
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
1909
+ Rpcs.new parent_rpcs
1910
+ end
1911
+ end
1912
+
1913
+ ##
1914
+ # Configuration RPC class for the Speech API.
1915
+ #
1916
+ # Includes fields providing the configuration for each RPC in this service.
1917
+ # Each configuration object is of type `Gapic::Config::Method` and includes
1918
+ # the following configuration fields:
1919
+ #
1920
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
1921
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
1922
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1923
+ # include the following keys:
1924
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1925
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1926
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1927
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1928
+ # trigger a retry.
1929
+ #
1930
+ class Rpcs
1931
+ ##
1932
+ # RPC-specific configuration for `create_recognizer`
1933
+ # @return [::Gapic::Config::Method]
1934
+ #
1935
+ attr_reader :create_recognizer
1936
+ ##
1937
+ # RPC-specific configuration for `list_recognizers`
1938
+ # @return [::Gapic::Config::Method]
1939
+ #
1940
+ attr_reader :list_recognizers
1941
+ ##
1942
+ # RPC-specific configuration for `get_recognizer`
1943
+ # @return [::Gapic::Config::Method]
1944
+ #
1945
+ attr_reader :get_recognizer
1946
+ ##
1947
+ # RPC-specific configuration for `update_recognizer`
1948
+ # @return [::Gapic::Config::Method]
1949
+ #
1950
+ attr_reader :update_recognizer
1951
+ ##
1952
+ # RPC-specific configuration for `delete_recognizer`
1953
+ # @return [::Gapic::Config::Method]
1954
+ #
1955
+ attr_reader :delete_recognizer
1956
+ ##
1957
+ # RPC-specific configuration for `undelete_recognizer`
1958
+ # @return [::Gapic::Config::Method]
1959
+ #
1960
+ attr_reader :undelete_recognizer
1961
+ ##
1962
+ # RPC-specific configuration for `recognize`
1963
+ # @return [::Gapic::Config::Method]
1964
+ #
1965
+ attr_reader :recognize
1966
+ ##
1967
+ # RPC-specific configuration for `batch_recognize`
1968
+ # @return [::Gapic::Config::Method]
1969
+ #
1970
+ attr_reader :batch_recognize
1971
+ ##
1972
+ # RPC-specific configuration for `get_config`
1973
+ # @return [::Gapic::Config::Method]
1974
+ #
1975
+ attr_reader :get_config
1976
+ ##
1977
+ # RPC-specific configuration for `update_config`
1978
+ # @return [::Gapic::Config::Method]
1979
+ #
1980
+ attr_reader :update_config
1981
+ ##
1982
+ # RPC-specific configuration for `create_custom_class`
1983
+ # @return [::Gapic::Config::Method]
1984
+ #
1985
+ attr_reader :create_custom_class
1986
+ ##
1987
+ # RPC-specific configuration for `list_custom_classes`
1988
+ # @return [::Gapic::Config::Method]
1989
+ #
1990
+ attr_reader :list_custom_classes
1991
+ ##
1992
+ # RPC-specific configuration for `get_custom_class`
1993
+ # @return [::Gapic::Config::Method]
1994
+ #
1995
+ attr_reader :get_custom_class
1996
+ ##
1997
+ # RPC-specific configuration for `update_custom_class`
1998
+ # @return [::Gapic::Config::Method]
1999
+ #
2000
+ attr_reader :update_custom_class
2001
+ ##
2002
+ # RPC-specific configuration for `delete_custom_class`
2003
+ # @return [::Gapic::Config::Method]
2004
+ #
2005
+ attr_reader :delete_custom_class
2006
+ ##
2007
+ # RPC-specific configuration for `undelete_custom_class`
2008
+ # @return [::Gapic::Config::Method]
2009
+ #
2010
+ attr_reader :undelete_custom_class
2011
+ ##
2012
+ # RPC-specific configuration for `create_phrase_set`
2013
+ # @return [::Gapic::Config::Method]
2014
+ #
2015
+ attr_reader :create_phrase_set
2016
+ ##
2017
+ # RPC-specific configuration for `list_phrase_sets`
2018
+ # @return [::Gapic::Config::Method]
2019
+ #
2020
+ attr_reader :list_phrase_sets
2021
+ ##
2022
+ # RPC-specific configuration for `get_phrase_set`
2023
+ # @return [::Gapic::Config::Method]
2024
+ #
2025
+ attr_reader :get_phrase_set
2026
+ ##
2027
+ # RPC-specific configuration for `update_phrase_set`
2028
+ # @return [::Gapic::Config::Method]
2029
+ #
2030
+ attr_reader :update_phrase_set
2031
+ ##
2032
+ # RPC-specific configuration for `delete_phrase_set`
2033
+ # @return [::Gapic::Config::Method]
2034
+ #
2035
+ attr_reader :delete_phrase_set
2036
+ ##
2037
+ # RPC-specific configuration for `undelete_phrase_set`
2038
+ # @return [::Gapic::Config::Method]
2039
+ #
2040
+ attr_reader :undelete_phrase_set
2041
+
2042
+ # @private
2043
+ def initialize parent_rpcs = nil
2044
+ create_recognizer_config = parent_rpcs.create_recognizer if parent_rpcs.respond_to? :create_recognizer
2045
+ @create_recognizer = ::Gapic::Config::Method.new create_recognizer_config
2046
+ list_recognizers_config = parent_rpcs.list_recognizers if parent_rpcs.respond_to? :list_recognizers
2047
+ @list_recognizers = ::Gapic::Config::Method.new list_recognizers_config
2048
+ get_recognizer_config = parent_rpcs.get_recognizer if parent_rpcs.respond_to? :get_recognizer
2049
+ @get_recognizer = ::Gapic::Config::Method.new get_recognizer_config
2050
+ update_recognizer_config = parent_rpcs.update_recognizer if parent_rpcs.respond_to? :update_recognizer
2051
+ @update_recognizer = ::Gapic::Config::Method.new update_recognizer_config
2052
+ delete_recognizer_config = parent_rpcs.delete_recognizer if parent_rpcs.respond_to? :delete_recognizer
2053
+ @delete_recognizer = ::Gapic::Config::Method.new delete_recognizer_config
2054
+ undelete_recognizer_config = parent_rpcs.undelete_recognizer if parent_rpcs.respond_to? :undelete_recognizer
2055
+ @undelete_recognizer = ::Gapic::Config::Method.new undelete_recognizer_config
2056
+ recognize_config = parent_rpcs.recognize if parent_rpcs.respond_to? :recognize
2057
+ @recognize = ::Gapic::Config::Method.new recognize_config
2058
+ batch_recognize_config = parent_rpcs.batch_recognize if parent_rpcs.respond_to? :batch_recognize
2059
+ @batch_recognize = ::Gapic::Config::Method.new batch_recognize_config
2060
+ get_config_config = parent_rpcs.get_config if parent_rpcs.respond_to? :get_config
2061
+ @get_config = ::Gapic::Config::Method.new get_config_config
2062
+ update_config_config = parent_rpcs.update_config if parent_rpcs.respond_to? :update_config
2063
+ @update_config = ::Gapic::Config::Method.new update_config_config
2064
+ create_custom_class_config = parent_rpcs.create_custom_class if parent_rpcs.respond_to? :create_custom_class
2065
+ @create_custom_class = ::Gapic::Config::Method.new create_custom_class_config
2066
+ list_custom_classes_config = parent_rpcs.list_custom_classes if parent_rpcs.respond_to? :list_custom_classes
2067
+ @list_custom_classes = ::Gapic::Config::Method.new list_custom_classes_config
2068
+ get_custom_class_config = parent_rpcs.get_custom_class if parent_rpcs.respond_to? :get_custom_class
2069
+ @get_custom_class = ::Gapic::Config::Method.new get_custom_class_config
2070
+ update_custom_class_config = parent_rpcs.update_custom_class if parent_rpcs.respond_to? :update_custom_class
2071
+ @update_custom_class = ::Gapic::Config::Method.new update_custom_class_config
2072
+ delete_custom_class_config = parent_rpcs.delete_custom_class if parent_rpcs.respond_to? :delete_custom_class
2073
+ @delete_custom_class = ::Gapic::Config::Method.new delete_custom_class_config
2074
+ undelete_custom_class_config = parent_rpcs.undelete_custom_class if parent_rpcs.respond_to? :undelete_custom_class
2075
+ @undelete_custom_class = ::Gapic::Config::Method.new undelete_custom_class_config
2076
+ create_phrase_set_config = parent_rpcs.create_phrase_set if parent_rpcs.respond_to? :create_phrase_set
2077
+ @create_phrase_set = ::Gapic::Config::Method.new create_phrase_set_config
2078
+ list_phrase_sets_config = parent_rpcs.list_phrase_sets if parent_rpcs.respond_to? :list_phrase_sets
2079
+ @list_phrase_sets = ::Gapic::Config::Method.new list_phrase_sets_config
2080
+ get_phrase_set_config = parent_rpcs.get_phrase_set if parent_rpcs.respond_to? :get_phrase_set
2081
+ @get_phrase_set = ::Gapic::Config::Method.new get_phrase_set_config
2082
+ update_phrase_set_config = parent_rpcs.update_phrase_set if parent_rpcs.respond_to? :update_phrase_set
2083
+ @update_phrase_set = ::Gapic::Config::Method.new update_phrase_set_config
2084
+ delete_phrase_set_config = parent_rpcs.delete_phrase_set if parent_rpcs.respond_to? :delete_phrase_set
2085
+ @delete_phrase_set = ::Gapic::Config::Method.new delete_phrase_set_config
2086
+ undelete_phrase_set_config = parent_rpcs.undelete_phrase_set if parent_rpcs.respond_to? :undelete_phrase_set
2087
+ @undelete_phrase_set = ::Gapic::Config::Method.new undelete_phrase_set_config
2088
+
2089
+ yield self if block_given?
2090
+ end
2091
+ end
2092
+ end
2093
+ end
2094
+ end
2095
+ end
2096
+ end
2097
+ end
2098
+ end
2099
+ end