google-cloud-speech-v2 0.1.0 → 0.2.0

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