google-cloud-speech-v2 0.a → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2795 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2022 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
+
22
+ module Google
23
+ module Cloud
24
+ module Speech
25
+ module V2
26
+ module Speech
27
+ ##
28
+ # Client for the Speech service.
29
+ #
30
+ # Enables speech transcription and resource management.
31
+ #
32
+ class Client
33
+ include Paths
34
+
35
+ # @private
36
+ attr_reader :speech_stub
37
+
38
+ ##
39
+ # Configure the Speech Client class.
40
+ #
41
+ # See {::Google::Cloud::Speech::V2::Speech::Client::Configuration}
42
+ # for a description of the configuration fields.
43
+ #
44
+ # @example
45
+ #
46
+ # # Modify the configuration for all Speech clients
47
+ # ::Google::Cloud::Speech::V2::Speech::Client.configure do |config|
48
+ # config.timeout = 10.0
49
+ # end
50
+ #
51
+ # @yield [config] Configure the Client client.
52
+ # @yieldparam config [Client::Configuration]
53
+ #
54
+ # @return [Client::Configuration]
55
+ #
56
+ def self.configure
57
+ @configure ||= begin
58
+ namespace = ["Google", "Cloud", "Speech", "V2"]
59
+ parent_config = while namespace.any?
60
+ parent_name = namespace.join "::"
61
+ parent_const = const_get parent_name
62
+ break parent_const.configure if parent_const.respond_to? :configure
63
+ namespace.pop
64
+ end
65
+ default_config = Client::Configuration.new parent_config
66
+
67
+ default_config.timeout = 5000.0
68
+ default_config.retry_policy = {
69
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
70
+ }
71
+
72
+ default_config
73
+ end
74
+ yield @configure if block_given?
75
+ @configure
76
+ end
77
+
78
+ ##
79
+ # Configure the Speech Client instance.
80
+ #
81
+ # The configuration is set to the derived mode, meaning that values can be changed,
82
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
83
+ # should be made on {Client.configure}.
84
+ #
85
+ # See {::Google::Cloud::Speech::V2::Speech::Client::Configuration}
86
+ # for a description of the configuration fields.
87
+ #
88
+ # @yield [config] Configure the Client client.
89
+ # @yieldparam config [Client::Configuration]
90
+ #
91
+ # @return [Client::Configuration]
92
+ #
93
+ def configure
94
+ yield @config if block_given?
95
+ @config
96
+ end
97
+
98
+ ##
99
+ # Create a new Speech client object.
100
+ #
101
+ # @example
102
+ #
103
+ # # Create a client using the default configuration
104
+ # client = ::Google::Cloud::Speech::V2::Speech::Client.new
105
+ #
106
+ # # Create a client using a custom configuration
107
+ # client = ::Google::Cloud::Speech::V2::Speech::Client.new do |config|
108
+ # config.timeout = 10.0
109
+ # end
110
+ #
111
+ # @yield [config] Configure the Speech client.
112
+ # @yieldparam config [Client::Configuration]
113
+ #
114
+ def initialize
115
+ # These require statements are intentionally placed here to initialize
116
+ # the gRPC module only when it's required.
117
+ # See https://github.com/googleapis/toolkit/issues/446
118
+ require "gapic/grpc"
119
+ require "google/cloud/speech/v2/cloud_speech_services_pb"
120
+
121
+ # Create the configuration object
122
+ @config = Configuration.new Client.configure
123
+
124
+ # Yield the configuration if needed
125
+ yield @config if block_given?
126
+
127
+ # Create credentials
128
+ credentials = @config.credentials
129
+ # Use self-signed JWT if the endpoint is unchanged from default,
130
+ # but only if the default endpoint does not have a region prefix.
131
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
132
+ !@config.endpoint.split(".").first.include?("-")
133
+ credentials ||= Credentials.default scope: @config.scope,
134
+ enable_self_signed_jwt: enable_self_signed_jwt
135
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
136
+ credentials = Credentials.new credentials, scope: @config.scope
137
+ end
138
+ @quota_project_id = @config.quota_project
139
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
140
+
141
+ @operations_client = Operations.new do |config|
142
+ config.credentials = credentials
143
+ config.quota_project = @quota_project_id
144
+ config.endpoint = @config.endpoint
145
+ end
146
+
147
+ @speech_stub = ::Gapic::ServiceStub.new(
148
+ ::Google::Cloud::Speech::V2::Speech::Stub,
149
+ credentials: credentials,
150
+ endpoint: @config.endpoint,
151
+ channel_args: @config.channel_args,
152
+ interceptors: @config.interceptors
153
+ )
154
+ end
155
+
156
+ ##
157
+ # Get the associated client for long-running operations.
158
+ #
159
+ # @return [::Google::Cloud::Speech::V2::Speech::Operations]
160
+ #
161
+ attr_reader :operations_client
162
+
163
+ # Service calls
164
+
165
+ ##
166
+ # Creates a {::Google::Cloud::Speech::V2::Recognizer Recognizer}.
167
+ #
168
+ # @overload create_recognizer(request, options = nil)
169
+ # Pass arguments to `create_recognizer` via a request object, either of type
170
+ # {::Google::Cloud::Speech::V2::CreateRecognizerRequest} or an equivalent Hash.
171
+ #
172
+ # @param request [::Google::Cloud::Speech::V2::CreateRecognizerRequest, ::Hash]
173
+ # A request object representing the call parameters. Required. To specify no
174
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
175
+ # @param options [::Gapic::CallOptions, ::Hash]
176
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
177
+ #
178
+ # @overload create_recognizer(recognizer: nil, validate_only: nil, recognizer_id: nil, parent: nil)
179
+ # Pass arguments to `create_recognizer` via keyword arguments. Note that at
180
+ # least one keyword argument is required. To specify no parameters, or to keep all
181
+ # the default parameter values, pass an empty Hash as a request object (see above).
182
+ #
183
+ # @param recognizer [::Google::Cloud::Speech::V2::Recognizer, ::Hash]
184
+ # Required. The Recognizer to create.
185
+ # @param validate_only [::Boolean]
186
+ # If set, validate the request and preview the Recognizer, but do not
187
+ # actually create it.
188
+ # @param recognizer_id [::String]
189
+ # The ID to use for the Recognizer, which will become the final component of
190
+ # the Recognizer's resource name.
191
+ #
192
+ # This value should be 4-63 characters, and valid characters
193
+ # are /[a-z][0-9]-/.
194
+ # @param parent [::String]
195
+ # Required. The project and location where this Recognizer will be created.
196
+ # The expected format is `projects/{project}/locations/{location}`.
197
+ #
198
+ # @yield [response, operation] Access the result along with the RPC operation
199
+ # @yieldparam response [::Gapic::Operation]
200
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
201
+ #
202
+ # @return [::Gapic::Operation]
203
+ #
204
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
205
+ #
206
+ # @example Basic example
207
+ # require "google/cloud/speech/v2"
208
+ #
209
+ # # Create a client object. The client can be reused for multiple calls.
210
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
211
+ #
212
+ # # Create a request. To set request fields, pass in keyword arguments.
213
+ # request = Google::Cloud::Speech::V2::CreateRecognizerRequest.new
214
+ #
215
+ # # Call the create_recognizer method.
216
+ # result = client.create_recognizer request
217
+ #
218
+ # # The returned object is of type Gapic::Operation. You can use this
219
+ # # object to check the status of an operation, cancel it, or wait
220
+ # # for results. Here is how to block until completion:
221
+ # result.wait_until_done! timeout: 60
222
+ # if result.response?
223
+ # p result.response
224
+ # else
225
+ # puts "Error!"
226
+ # end
227
+ #
228
+ def create_recognizer request, options = nil
229
+ raise ::ArgumentError, "request must be provided" if request.nil?
230
+
231
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::CreateRecognizerRequest
232
+
233
+ # Converts hash and nil to an options object
234
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
235
+
236
+ # Customize the options with defaults
237
+ metadata = @config.rpcs.create_recognizer.metadata.to_h
238
+
239
+ # Set x-goog-api-client and x-goog-user-project headers
240
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
241
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
242
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
243
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
244
+
245
+ header_params = {}
246
+ if request.parent
247
+ header_params["parent"] = request.parent
248
+ end
249
+
250
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
251
+ metadata[:"x-goog-request-params"] ||= request_params_header
252
+
253
+ options.apply_defaults timeout: @config.rpcs.create_recognizer.timeout,
254
+ metadata: metadata,
255
+ retry_policy: @config.rpcs.create_recognizer.retry_policy
256
+
257
+ options.apply_defaults timeout: @config.timeout,
258
+ metadata: @config.metadata,
259
+ retry_policy: @config.retry_policy
260
+
261
+ @speech_stub.call_rpc :create_recognizer, request, options: options do |response, operation|
262
+ response = ::Gapic::Operation.new response, @operations_client, options: options
263
+ yield response, operation if block_given?
264
+ return response
265
+ end
266
+ rescue ::GRPC::BadStatus => e
267
+ raise ::Google::Cloud::Error.from_error(e)
268
+ end
269
+
270
+ ##
271
+ # Lists Recognizers.
272
+ #
273
+ # @overload list_recognizers(request, options = nil)
274
+ # Pass arguments to `list_recognizers` via a request object, either of type
275
+ # {::Google::Cloud::Speech::V2::ListRecognizersRequest} or an equivalent Hash.
276
+ #
277
+ # @param request [::Google::Cloud::Speech::V2::ListRecognizersRequest, ::Hash]
278
+ # A request object representing the call parameters. Required. To specify no
279
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
280
+ # @param options [::Gapic::CallOptions, ::Hash]
281
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
282
+ #
283
+ # @overload list_recognizers(parent: nil, page_size: nil, page_token: nil, show_deleted: nil)
284
+ # Pass arguments to `list_recognizers` via keyword arguments. Note that at
285
+ # least one keyword argument is required. To specify no parameters, or to keep all
286
+ # the default parameter values, pass an empty Hash as a request object (see above).
287
+ #
288
+ # @param parent [::String]
289
+ # Required. The project and location of Recognizers to list. The expected
290
+ # format is `projects/{project}/locations/{location}`.
291
+ # @param page_size [::Integer]
292
+ # The maximum number of Recognizers to return. The service may return fewer
293
+ # than this value. If unspecified, at most 20 Recognizers will be returned.
294
+ # The maximum value is 20; values above 20 will be coerced to 20.
295
+ # @param page_token [::String]
296
+ # A page token, received from a previous
297
+ # {::Google::Cloud::Speech::V2::Speech::Client#list_recognizers ListRecognizers} call.
298
+ # Provide this to retrieve the subsequent page.
299
+ #
300
+ # When paginating, all other parameters provided to
301
+ # {::Google::Cloud::Speech::V2::Speech::Client#list_recognizers ListRecognizers} must match
302
+ # the call that provided the page token.
303
+ # @param show_deleted [::Boolean]
304
+ # Whether, or not, to show resources that have been deleted.
305
+ #
306
+ # @yield [response, operation] Access the result along with the RPC operation
307
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Speech::V2::Recognizer>]
308
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
309
+ #
310
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Speech::V2::Recognizer>]
311
+ #
312
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
313
+ #
314
+ # @example Basic example
315
+ # require "google/cloud/speech/v2"
316
+ #
317
+ # # Create a client object. The client can be reused for multiple calls.
318
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
319
+ #
320
+ # # Create a request. To set request fields, pass in keyword arguments.
321
+ # request = Google::Cloud::Speech::V2::ListRecognizersRequest.new
322
+ #
323
+ # # Call the list_recognizers method.
324
+ # result = client.list_recognizers request
325
+ #
326
+ # # The returned object is of type Gapic::PagedEnumerable. You can
327
+ # # iterate over all elements by calling #each, and the enumerable
328
+ # # will lazily make API calls to fetch subsequent pages. Other
329
+ # # methods are also available for managing paging directly.
330
+ # result.each do |response|
331
+ # # Each element is of type ::Google::Cloud::Speech::V2::Recognizer.
332
+ # p response
333
+ # end
334
+ #
335
+ def list_recognizers request, options = nil
336
+ raise ::ArgumentError, "request must be provided" if request.nil?
337
+
338
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::ListRecognizersRequest
339
+
340
+ # Converts hash and nil to an options object
341
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
342
+
343
+ # Customize the options with defaults
344
+ metadata = @config.rpcs.list_recognizers.metadata.to_h
345
+
346
+ # Set x-goog-api-client and x-goog-user-project headers
347
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
348
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
349
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
350
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
351
+
352
+ header_params = {}
353
+ if request.parent
354
+ header_params["parent"] = request.parent
355
+ end
356
+
357
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
358
+ metadata[:"x-goog-request-params"] ||= request_params_header
359
+
360
+ options.apply_defaults timeout: @config.rpcs.list_recognizers.timeout,
361
+ metadata: metadata,
362
+ retry_policy: @config.rpcs.list_recognizers.retry_policy
363
+
364
+ options.apply_defaults timeout: @config.timeout,
365
+ metadata: @config.metadata,
366
+ retry_policy: @config.retry_policy
367
+
368
+ @speech_stub.call_rpc :list_recognizers, request, options: options do |response, operation|
369
+ response = ::Gapic::PagedEnumerable.new @speech_stub, :list_recognizers, request, response, operation, options
370
+ yield response, operation if block_given?
371
+ return response
372
+ end
373
+ rescue ::GRPC::BadStatus => e
374
+ raise ::Google::Cloud::Error.from_error(e)
375
+ end
376
+
377
+ ##
378
+ # Returns the requested
379
+ # {::Google::Cloud::Speech::V2::Recognizer Recognizer}. Fails with
380
+ # [NOT_FOUND][google.rpc.Code.NOT_FOUND] if the requested recognizer doesn't
381
+ # exist.
382
+ #
383
+ # @overload get_recognizer(request, options = nil)
384
+ # Pass arguments to `get_recognizer` via a request object, either of type
385
+ # {::Google::Cloud::Speech::V2::GetRecognizerRequest} or an equivalent Hash.
386
+ #
387
+ # @param request [::Google::Cloud::Speech::V2::GetRecognizerRequest, ::Hash]
388
+ # A request object representing the call parameters. Required. To specify no
389
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
390
+ # @param options [::Gapic::CallOptions, ::Hash]
391
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
392
+ #
393
+ # @overload get_recognizer(name: nil)
394
+ # Pass arguments to `get_recognizer` via keyword arguments. Note that at
395
+ # least one keyword argument is required. To specify no parameters, or to keep all
396
+ # the default parameter values, pass an empty Hash as a request object (see above).
397
+ #
398
+ # @param name [::String]
399
+ # Required. The name of the Recognizer to retrieve. The expected format is
400
+ # `projects/{project}/locations/{location}/recognizers/{recognizer}`.
401
+ #
402
+ # @yield [response, operation] Access the result along with the RPC operation
403
+ # @yieldparam response [::Google::Cloud::Speech::V2::Recognizer]
404
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
405
+ #
406
+ # @return [::Google::Cloud::Speech::V2::Recognizer]
407
+ #
408
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
409
+ #
410
+ # @example Basic example
411
+ # require "google/cloud/speech/v2"
412
+ #
413
+ # # Create a client object. The client can be reused for multiple calls.
414
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
415
+ #
416
+ # # Create a request. To set request fields, pass in keyword arguments.
417
+ # request = Google::Cloud::Speech::V2::GetRecognizerRequest.new
418
+ #
419
+ # # Call the get_recognizer method.
420
+ # result = client.get_recognizer request
421
+ #
422
+ # # The returned object is of type Google::Cloud::Speech::V2::Recognizer.
423
+ # p result
424
+ #
425
+ def get_recognizer request, options = nil
426
+ raise ::ArgumentError, "request must be provided" if request.nil?
427
+
428
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::GetRecognizerRequest
429
+
430
+ # Converts hash and nil to an options object
431
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
432
+
433
+ # Customize the options with defaults
434
+ metadata = @config.rpcs.get_recognizer.metadata.to_h
435
+
436
+ # Set x-goog-api-client and x-goog-user-project headers
437
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
438
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
439
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
440
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
441
+
442
+ header_params = {}
443
+ if request.name
444
+ header_params["name"] = request.name
445
+ end
446
+
447
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
448
+ metadata[:"x-goog-request-params"] ||= request_params_header
449
+
450
+ options.apply_defaults timeout: @config.rpcs.get_recognizer.timeout,
451
+ metadata: metadata,
452
+ retry_policy: @config.rpcs.get_recognizer.retry_policy
453
+
454
+ options.apply_defaults timeout: @config.timeout,
455
+ metadata: @config.metadata,
456
+ retry_policy: @config.retry_policy
457
+
458
+ @speech_stub.call_rpc :get_recognizer, request, options: options do |response, operation|
459
+ yield response, operation if block_given?
460
+ return response
461
+ end
462
+ rescue ::GRPC::BadStatus => e
463
+ raise ::Google::Cloud::Error.from_error(e)
464
+ end
465
+
466
+ ##
467
+ # Updates the {::Google::Cloud::Speech::V2::Recognizer Recognizer}.
468
+ #
469
+ # @overload update_recognizer(request, options = nil)
470
+ # Pass arguments to `update_recognizer` via a request object, either of type
471
+ # {::Google::Cloud::Speech::V2::UpdateRecognizerRequest} or an equivalent Hash.
472
+ #
473
+ # @param request [::Google::Cloud::Speech::V2::UpdateRecognizerRequest, ::Hash]
474
+ # A request object representing the call parameters. Required. To specify no
475
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
476
+ # @param options [::Gapic::CallOptions, ::Hash]
477
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
478
+ #
479
+ # @overload update_recognizer(recognizer: nil, update_mask: nil, validate_only: nil)
480
+ # Pass arguments to `update_recognizer` via keyword arguments. Note that at
481
+ # least one keyword argument is required. To specify no parameters, or to keep all
482
+ # the default parameter values, pass an empty Hash as a request object (see above).
483
+ #
484
+ # @param recognizer [::Google::Cloud::Speech::V2::Recognizer, ::Hash]
485
+ # Required. The Recognizer to update.
486
+ #
487
+ # The Recognizer's `name` field is used to identify the Recognizer to update.
488
+ # Format: `projects/{project}/locations/{location}/recognizers/{recognizer}`.
489
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
490
+ # The list of fields to update. If empty, all non-default valued fields are
491
+ # considered for update. Use `*` to update the entire Recognizer resource.
492
+ # @param validate_only [::Boolean]
493
+ # If set, validate the request and preview the updated Recognizer, but do not
494
+ # actually update it.
495
+ #
496
+ # @yield [response, operation] Access the result along with the RPC operation
497
+ # @yieldparam response [::Gapic::Operation]
498
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
499
+ #
500
+ # @return [::Gapic::Operation]
501
+ #
502
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
503
+ #
504
+ # @example Basic example
505
+ # require "google/cloud/speech/v2"
506
+ #
507
+ # # Create a client object. The client can be reused for multiple calls.
508
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
509
+ #
510
+ # # Create a request. To set request fields, pass in keyword arguments.
511
+ # request = Google::Cloud::Speech::V2::UpdateRecognizerRequest.new
512
+ #
513
+ # # Call the update_recognizer method.
514
+ # result = client.update_recognizer request
515
+ #
516
+ # # The returned object is of type Gapic::Operation. You can use this
517
+ # # object to check the status of an operation, cancel it, or wait
518
+ # # for results. Here is how to block until completion:
519
+ # result.wait_until_done! timeout: 60
520
+ # if result.response?
521
+ # p result.response
522
+ # else
523
+ # puts "Error!"
524
+ # end
525
+ #
526
+ def update_recognizer request, options = nil
527
+ raise ::ArgumentError, "request must be provided" if request.nil?
528
+
529
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UpdateRecognizerRequest
530
+
531
+ # Converts hash and nil to an options object
532
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
533
+
534
+ # Customize the options with defaults
535
+ metadata = @config.rpcs.update_recognizer.metadata.to_h
536
+
537
+ # Set x-goog-api-client and x-goog-user-project headers
538
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
539
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
540
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
541
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
542
+
543
+ header_params = {}
544
+ if request.recognizer&.name
545
+ header_params["recognizer.name"] = request.recognizer.name
546
+ end
547
+
548
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
549
+ metadata[:"x-goog-request-params"] ||= request_params_header
550
+
551
+ options.apply_defaults timeout: @config.rpcs.update_recognizer.timeout,
552
+ metadata: metadata,
553
+ retry_policy: @config.rpcs.update_recognizer.retry_policy
554
+
555
+ options.apply_defaults timeout: @config.timeout,
556
+ metadata: @config.metadata,
557
+ retry_policy: @config.retry_policy
558
+
559
+ @speech_stub.call_rpc :update_recognizer, request, options: options do |response, operation|
560
+ response = ::Gapic::Operation.new response, @operations_client, options: options
561
+ yield response, operation if block_given?
562
+ return response
563
+ end
564
+ rescue ::GRPC::BadStatus => e
565
+ raise ::Google::Cloud::Error.from_error(e)
566
+ end
567
+
568
+ ##
569
+ # Deletes the {::Google::Cloud::Speech::V2::Recognizer Recognizer}.
570
+ #
571
+ # @overload delete_recognizer(request, options = nil)
572
+ # Pass arguments to `delete_recognizer` via a request object, either of type
573
+ # {::Google::Cloud::Speech::V2::DeleteRecognizerRequest} or an equivalent Hash.
574
+ #
575
+ # @param request [::Google::Cloud::Speech::V2::DeleteRecognizerRequest, ::Hash]
576
+ # A request object representing the call parameters. Required. To specify no
577
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
578
+ # @param options [::Gapic::CallOptions, ::Hash]
579
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
580
+ #
581
+ # @overload delete_recognizer(name: nil, validate_only: nil, allow_missing: nil, etag: nil)
582
+ # Pass arguments to `delete_recognizer` via keyword arguments. Note that at
583
+ # least one keyword argument is required. To specify no parameters, or to keep all
584
+ # the default parameter values, pass an empty Hash as a request object (see above).
585
+ #
586
+ # @param name [::String]
587
+ # Required. The name of the Recognizer to delete.
588
+ # Format: `projects/{project}/locations/{location}/recognizers/{recognizer}`
589
+ # @param validate_only [::Boolean]
590
+ # If set, validate the request and preview the deleted Recognizer, but do not
591
+ # actually delete it.
592
+ # @param allow_missing [::Boolean]
593
+ # If set to true, and the Recognizer is not found, the request will succeed
594
+ # and be a no-op (no Operation is recorded in this case).
595
+ # @param etag [::String]
596
+ # This checksum is computed by the server based on the value of other
597
+ # fields. This may be sent on update, undelete, and delete requests to ensure
598
+ # the client has an up-to-date value before proceeding.
599
+ #
600
+ # @yield [response, operation] Access the result along with the RPC operation
601
+ # @yieldparam response [::Gapic::Operation]
602
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
603
+ #
604
+ # @return [::Gapic::Operation]
605
+ #
606
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
607
+ #
608
+ # @example Basic example
609
+ # require "google/cloud/speech/v2"
610
+ #
611
+ # # Create a client object. The client can be reused for multiple calls.
612
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
613
+ #
614
+ # # Create a request. To set request fields, pass in keyword arguments.
615
+ # request = Google::Cloud::Speech::V2::DeleteRecognizerRequest.new
616
+ #
617
+ # # Call the delete_recognizer method.
618
+ # result = client.delete_recognizer request
619
+ #
620
+ # # The returned object is of type Gapic::Operation. You can use this
621
+ # # object to check the status of an operation, cancel it, or wait
622
+ # # for results. Here is how to block until completion:
623
+ # result.wait_until_done! timeout: 60
624
+ # if result.response?
625
+ # p result.response
626
+ # else
627
+ # puts "Error!"
628
+ # end
629
+ #
630
+ def delete_recognizer request, options = nil
631
+ raise ::ArgumentError, "request must be provided" if request.nil?
632
+
633
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::DeleteRecognizerRequest
634
+
635
+ # Converts hash and nil to an options object
636
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
637
+
638
+ # Customize the options with defaults
639
+ metadata = @config.rpcs.delete_recognizer.metadata.to_h
640
+
641
+ # Set x-goog-api-client and x-goog-user-project headers
642
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
643
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
644
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
645
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
646
+
647
+ header_params = {}
648
+ if request.name
649
+ header_params["name"] = request.name
650
+ end
651
+
652
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
653
+ metadata[:"x-goog-request-params"] ||= request_params_header
654
+
655
+ options.apply_defaults timeout: @config.rpcs.delete_recognizer.timeout,
656
+ metadata: metadata,
657
+ retry_policy: @config.rpcs.delete_recognizer.retry_policy
658
+
659
+ options.apply_defaults timeout: @config.timeout,
660
+ metadata: @config.metadata,
661
+ retry_policy: @config.retry_policy
662
+
663
+ @speech_stub.call_rpc :delete_recognizer, request, options: options do |response, operation|
664
+ response = ::Gapic::Operation.new response, @operations_client, options: options
665
+ yield response, operation if block_given?
666
+ return response
667
+ end
668
+ rescue ::GRPC::BadStatus => e
669
+ raise ::Google::Cloud::Error.from_error(e)
670
+ end
671
+
672
+ ##
673
+ # Undeletes the {::Google::Cloud::Speech::V2::Recognizer Recognizer}.
674
+ #
675
+ # @overload undelete_recognizer(request, options = nil)
676
+ # Pass arguments to `undelete_recognizer` via a request object, either of type
677
+ # {::Google::Cloud::Speech::V2::UndeleteRecognizerRequest} or an equivalent Hash.
678
+ #
679
+ # @param request [::Google::Cloud::Speech::V2::UndeleteRecognizerRequest, ::Hash]
680
+ # A request object representing the call parameters. Required. To specify no
681
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
682
+ # @param options [::Gapic::CallOptions, ::Hash]
683
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
684
+ #
685
+ # @overload undelete_recognizer(name: nil, validate_only: nil, etag: nil)
686
+ # Pass arguments to `undelete_recognizer` via keyword arguments. Note that at
687
+ # least one keyword argument is required. To specify no parameters, or to keep all
688
+ # the default parameter values, pass an empty Hash as a request object (see above).
689
+ #
690
+ # @param name [::String]
691
+ # Required. The name of the Recognizer to undelete.
692
+ # Format: `projects/{project}/locations/{location}/recognizers/{recognizer}`
693
+ # @param validate_only [::Boolean]
694
+ # If set, validate the request and preview the undeleted Recognizer, but do
695
+ # not actually undelete it.
696
+ # @param etag [::String]
697
+ # This checksum is computed by the server based on the value of other
698
+ # fields. This may be sent on update, undelete, and delete requests to ensure
699
+ # the client has an up-to-date value before proceeding.
700
+ #
701
+ # @yield [response, operation] Access the result along with the RPC operation
702
+ # @yieldparam response [::Gapic::Operation]
703
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
704
+ #
705
+ # @return [::Gapic::Operation]
706
+ #
707
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
708
+ #
709
+ # @example Basic example
710
+ # require "google/cloud/speech/v2"
711
+ #
712
+ # # Create a client object. The client can be reused for multiple calls.
713
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
714
+ #
715
+ # # Create a request. To set request fields, pass in keyword arguments.
716
+ # request = Google::Cloud::Speech::V2::UndeleteRecognizerRequest.new
717
+ #
718
+ # # Call the undelete_recognizer method.
719
+ # result = client.undelete_recognizer request
720
+ #
721
+ # # The returned object is of type Gapic::Operation. You can use this
722
+ # # object to check the status of an operation, cancel it, or wait
723
+ # # for results. Here is how to block until completion:
724
+ # result.wait_until_done! timeout: 60
725
+ # if result.response?
726
+ # p result.response
727
+ # else
728
+ # puts "Error!"
729
+ # end
730
+ #
731
+ def undelete_recognizer request, options = nil
732
+ raise ::ArgumentError, "request must be provided" if request.nil?
733
+
734
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UndeleteRecognizerRequest
735
+
736
+ # Converts hash and nil to an options object
737
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
738
+
739
+ # Customize the options with defaults
740
+ metadata = @config.rpcs.undelete_recognizer.metadata.to_h
741
+
742
+ # Set x-goog-api-client and x-goog-user-project headers
743
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
744
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
745
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
746
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
747
+
748
+ header_params = {}
749
+ if request.name
750
+ header_params["name"] = request.name
751
+ end
752
+
753
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
754
+ metadata[:"x-goog-request-params"] ||= request_params_header
755
+
756
+ options.apply_defaults timeout: @config.rpcs.undelete_recognizer.timeout,
757
+ metadata: metadata,
758
+ retry_policy: @config.rpcs.undelete_recognizer.retry_policy
759
+
760
+ options.apply_defaults timeout: @config.timeout,
761
+ metadata: @config.metadata,
762
+ retry_policy: @config.retry_policy
763
+
764
+ @speech_stub.call_rpc :undelete_recognizer, request, options: options do |response, operation|
765
+ response = ::Gapic::Operation.new response, @operations_client, options: options
766
+ yield response, operation if block_given?
767
+ return response
768
+ end
769
+ rescue ::GRPC::BadStatus => e
770
+ raise ::Google::Cloud::Error.from_error(e)
771
+ end
772
+
773
+ ##
774
+ # Performs synchronous Speech recognition: receive results after all audio
775
+ # has been sent and processed.
776
+ #
777
+ # @overload recognize(request, options = nil)
778
+ # Pass arguments to `recognize` via a request object, either of type
779
+ # {::Google::Cloud::Speech::V2::RecognizeRequest} or an equivalent Hash.
780
+ #
781
+ # @param request [::Google::Cloud::Speech::V2::RecognizeRequest, ::Hash]
782
+ # A request object representing the call parameters. Required. To specify no
783
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
784
+ # @param options [::Gapic::CallOptions, ::Hash]
785
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
786
+ #
787
+ # @overload recognize(recognizer: nil, config: nil, config_mask: nil, content: nil, uri: nil)
788
+ # Pass arguments to `recognize` via keyword arguments. Note that at
789
+ # least one keyword argument is required. To specify no parameters, or to keep all
790
+ # the default parameter values, pass an empty Hash as a request object (see above).
791
+ #
792
+ # @param recognizer [::String]
793
+ # Required. The name of the Recognizer to use during recognition. The
794
+ # expected format is
795
+ # `projects/{project}/locations/{location}/recognizers/{recognizer}`.
796
+ # @param config [::Google::Cloud::Speech::V2::RecognitionConfig, ::Hash]
797
+ # Features and audio metadata to use for the Automatic Speech Recognition.
798
+ # This field in combination with the
799
+ # {::Google::Cloud::Speech::V2::RecognizeRequest#config_mask config_mask} field
800
+ # can be used to override parts of the
801
+ # {::Google::Cloud::Speech::V2::Recognizer#default_recognition_config default_recognition_config}
802
+ # of the Recognizer resource.
803
+ # @param config_mask [::Google::Protobuf::FieldMask, ::Hash]
804
+ # The list of fields in
805
+ # {::Google::Cloud::Speech::V2::RecognizeRequest#config config} that override the
806
+ # values in the
807
+ # {::Google::Cloud::Speech::V2::Recognizer#default_recognition_config default_recognition_config}
808
+ # of the recognizer during this recognition request. If no mask is provided,
809
+ # all non-default valued fields in
810
+ # {::Google::Cloud::Speech::V2::RecognizeRequest#config config} override the
811
+ # values in the recognizer for this recognition request. If a mask is
812
+ # provided, only the fields listed in the mask override the config in the
813
+ # recognizer for this recognition request. If a wildcard (`*`) is provided,
814
+ # {::Google::Cloud::Speech::V2::RecognizeRequest#config config} completely
815
+ # overrides and replaces the config in the recognizer for this recognition
816
+ # request.
817
+ # @param content [::String]
818
+ # The audio data bytes encoded as specified in
819
+ # {::Google::Cloud::Speech::V2::RecognitionConfig RecognitionConfig}. As
820
+ # with all bytes fields, proto buffers use a pure binary representation,
821
+ # whereas JSON representations use base64.
822
+ # @param uri [::String]
823
+ # URI that points to a file that contains audio data bytes as specified in
824
+ # {::Google::Cloud::Speech::V2::RecognitionConfig RecognitionConfig}. The file
825
+ # must not be compressed (for example, gzip). Currently, only Google Cloud
826
+ # Storage URIs are supported, which must be specified in the following
827
+ # format: `gs://bucket_name/object_name` (other URI formats return
828
+ # [INVALID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). For more
829
+ # information, see [Request
830
+ # URIs](https://cloud.google.com/storage/docs/reference-uris).
831
+ #
832
+ # @yield [response, operation] Access the result along with the RPC operation
833
+ # @yieldparam response [::Google::Cloud::Speech::V2::RecognizeResponse]
834
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
835
+ #
836
+ # @return [::Google::Cloud::Speech::V2::RecognizeResponse]
837
+ #
838
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
839
+ #
840
+ # @example Basic example
841
+ # require "google/cloud/speech/v2"
842
+ #
843
+ # # Create a client object. The client can be reused for multiple calls.
844
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
845
+ #
846
+ # # Create a request. To set request fields, pass in keyword arguments.
847
+ # request = Google::Cloud::Speech::V2::RecognizeRequest.new
848
+ #
849
+ # # Call the recognize method.
850
+ # result = client.recognize request
851
+ #
852
+ # # The returned object is of type Google::Cloud::Speech::V2::RecognizeResponse.
853
+ # p result
854
+ #
855
+ def recognize request, options = nil
856
+ raise ::ArgumentError, "request must be provided" if request.nil?
857
+
858
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::RecognizeRequest
859
+
860
+ # Converts hash and nil to an options object
861
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
862
+
863
+ # Customize the options with defaults
864
+ metadata = @config.rpcs.recognize.metadata.to_h
865
+
866
+ # Set x-goog-api-client and x-goog-user-project headers
867
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
868
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
869
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
870
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
871
+
872
+ header_params = {}
873
+ if request.recognizer
874
+ header_params["recognizer"] = request.recognizer
875
+ end
876
+
877
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
878
+ metadata[:"x-goog-request-params"] ||= request_params_header
879
+
880
+ options.apply_defaults timeout: @config.rpcs.recognize.timeout,
881
+ metadata: metadata,
882
+ retry_policy: @config.rpcs.recognize.retry_policy
883
+
884
+ options.apply_defaults timeout: @config.timeout,
885
+ metadata: @config.metadata,
886
+ retry_policy: @config.retry_policy
887
+
888
+ @speech_stub.call_rpc :recognize, request, options: options do |response, operation|
889
+ yield response, operation if block_given?
890
+ return response
891
+ end
892
+ rescue ::GRPC::BadStatus => e
893
+ raise ::Google::Cloud::Error.from_error(e)
894
+ end
895
+
896
+ ##
897
+ # Performs bidirectional streaming speech recognition: receive results while
898
+ # sending audio. This method is only available via the gRPC API (not REST).
899
+ #
900
+ # @param request [::Gapic::StreamInput, ::Enumerable<::Google::Cloud::Speech::V2::StreamingRecognizeRequest, ::Hash>]
901
+ # An enumerable of {::Google::Cloud::Speech::V2::StreamingRecognizeRequest} instances.
902
+ # @param options [::Gapic::CallOptions, ::Hash]
903
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
904
+ #
905
+ # @yield [response, operation] Access the result along with the RPC operation
906
+ # @yieldparam response [::Enumerable<::Google::Cloud::Speech::V2::StreamingRecognizeResponse>]
907
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
908
+ #
909
+ # @return [::Enumerable<::Google::Cloud::Speech::V2::StreamingRecognizeResponse>]
910
+ #
911
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
912
+ #
913
+ # @example Basic example
914
+ # require "google/cloud/speech/v2"
915
+ #
916
+ # # Create a client object. The client can be reused for multiple calls.
917
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
918
+ #
919
+ # # Create an input stream
920
+ # input = Gapic::StreamInput.new
921
+ #
922
+ # # Call the streaming_recognize method to start streaming.
923
+ # output = client.streaming_recognize input
924
+ #
925
+ # # Send requests on the stream. For each request, pass in keyword
926
+ # # arguments to set fields. Be sure to close the stream when done.
927
+ # input << Google::Cloud::Speech::V2::StreamingRecognizeRequest.new
928
+ # input << Google::Cloud::Speech::V2::StreamingRecognizeRequest.new
929
+ # input.close
930
+ #
931
+ # # Handle streamed responses. These may be interleaved with inputs.
932
+ # # Each response is of type ::Google::Cloud::Speech::V2::StreamingRecognizeResponse.
933
+ # output.each do |response|
934
+ # p response
935
+ # end
936
+ #
937
+ def streaming_recognize request, options = nil
938
+ unless request.is_a? ::Enumerable
939
+ raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
940
+ request = request.to_enum
941
+ end
942
+
943
+ request = request.lazy.map do |req|
944
+ ::Gapic::Protobuf.coerce req, to: ::Google::Cloud::Speech::V2::StreamingRecognizeRequest
945
+ end
946
+
947
+ # Converts hash and nil to an options object
948
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
949
+
950
+ # Customize the options with defaults
951
+ metadata = @config.rpcs.streaming_recognize.metadata.to_h
952
+
953
+ # Set x-goog-api-client and x-goog-user-project headers
954
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
955
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
956
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
957
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
958
+
959
+ options.apply_defaults timeout: @config.rpcs.streaming_recognize.timeout,
960
+ metadata: metadata,
961
+ retry_policy: @config.rpcs.streaming_recognize.retry_policy
962
+
963
+ options.apply_defaults timeout: @config.timeout,
964
+ metadata: @config.metadata,
965
+ retry_policy: @config.retry_policy
966
+
967
+ @speech_stub.call_rpc :streaming_recognize, request, options: options do |response, operation|
968
+ yield response, operation if block_given?
969
+ return response
970
+ end
971
+ rescue ::GRPC::BadStatus => e
972
+ raise ::Google::Cloud::Error.from_error(e)
973
+ end
974
+
975
+ ##
976
+ # Performs batch asynchronous speech recognition: send a request with N
977
+ # audio files and receive a long running operation that can be polled to see
978
+ # when the transcriptions are finished.
979
+ #
980
+ # @overload batch_recognize(request, options = nil)
981
+ # Pass arguments to `batch_recognize` via a request object, either of type
982
+ # {::Google::Cloud::Speech::V2::BatchRecognizeRequest} or an equivalent Hash.
983
+ #
984
+ # @param request [::Google::Cloud::Speech::V2::BatchRecognizeRequest, ::Hash]
985
+ # A request object representing the call parameters. Required. To specify no
986
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
987
+ # @param options [::Gapic::CallOptions, ::Hash]
988
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
989
+ #
990
+ # @overload batch_recognize(recognizer: nil, config: nil, config_mask: nil, files: nil)
991
+ # Pass arguments to `batch_recognize` via keyword arguments. Note that at
992
+ # least one keyword argument is required. To specify no parameters, or to keep all
993
+ # the default parameter values, pass an empty Hash as a request object (see above).
994
+ #
995
+ # @param recognizer [::String]
996
+ # Required. Resource name of the recognizer to be used for ASR.
997
+ # @param config [::Google::Cloud::Speech::V2::RecognitionConfig, ::Hash]
998
+ # Features and audio metadata to use for the Automatic Speech Recognition.
999
+ # This field in combination with the
1000
+ # {::Google::Cloud::Speech::V2::BatchRecognizeRequest#config_mask config_mask}
1001
+ # field can be used to override parts of the
1002
+ # {::Google::Cloud::Speech::V2::Recognizer#default_recognition_config default_recognition_config}
1003
+ # of the Recognizer resource.
1004
+ # @param config_mask [::Google::Protobuf::FieldMask, ::Hash]
1005
+ # The list of fields in
1006
+ # {::Google::Cloud::Speech::V2::BatchRecognizeRequest#config config} that override
1007
+ # the values in the
1008
+ # {::Google::Cloud::Speech::V2::Recognizer#default_recognition_config default_recognition_config}
1009
+ # of the recognizer during this recognition request. If no mask is provided,
1010
+ # all given fields in
1011
+ # {::Google::Cloud::Speech::V2::BatchRecognizeRequest#config config} override the
1012
+ # values in the recognizer for this recognition request. If a mask is
1013
+ # provided, only the fields listed in the mask override the config in the
1014
+ # recognizer for this recognition request. If a wildcard (`*`) is provided,
1015
+ # {::Google::Cloud::Speech::V2::BatchRecognizeRequest#config config} completely
1016
+ # overrides and replaces the config in the recognizer for this recognition
1017
+ # request.
1018
+ # @param files [::Array<::Google::Cloud::Speech::V2::BatchRecognizeFileMetadata, ::Hash>]
1019
+ # Audio files with file metadata for ASR.
1020
+ #
1021
+ # @yield [response, operation] Access the result along with the RPC operation
1022
+ # @yieldparam response [::Gapic::Operation]
1023
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1024
+ #
1025
+ # @return [::Gapic::Operation]
1026
+ #
1027
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1028
+ #
1029
+ # @example Basic example
1030
+ # require "google/cloud/speech/v2"
1031
+ #
1032
+ # # Create a client object. The client can be reused for multiple calls.
1033
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
1034
+ #
1035
+ # # Create a request. To set request fields, pass in keyword arguments.
1036
+ # request = Google::Cloud::Speech::V2::BatchRecognizeRequest.new
1037
+ #
1038
+ # # Call the batch_recognize method.
1039
+ # result = client.batch_recognize request
1040
+ #
1041
+ # # The returned object is of type Gapic::Operation. You can use this
1042
+ # # object to check the status of an operation, cancel it, or wait
1043
+ # # for results. Here is how to block until completion:
1044
+ # result.wait_until_done! timeout: 60
1045
+ # if result.response?
1046
+ # p result.response
1047
+ # else
1048
+ # puts "Error!"
1049
+ # end
1050
+ #
1051
+ def batch_recognize request, options = nil
1052
+ raise ::ArgumentError, "request must be provided" if request.nil?
1053
+
1054
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::BatchRecognizeRequest
1055
+
1056
+ # Converts hash and nil to an options object
1057
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1058
+
1059
+ # Customize the options with defaults
1060
+ metadata = @config.rpcs.batch_recognize.metadata.to_h
1061
+
1062
+ # Set x-goog-api-client and x-goog-user-project headers
1063
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1064
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1065
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
1066
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1067
+
1068
+ header_params = {}
1069
+ if request.recognizer
1070
+ header_params["recognizer"] = request.recognizer
1071
+ end
1072
+
1073
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1074
+ metadata[:"x-goog-request-params"] ||= request_params_header
1075
+
1076
+ options.apply_defaults timeout: @config.rpcs.batch_recognize.timeout,
1077
+ metadata: metadata,
1078
+ retry_policy: @config.rpcs.batch_recognize.retry_policy
1079
+
1080
+ options.apply_defaults timeout: @config.timeout,
1081
+ metadata: @config.metadata,
1082
+ retry_policy: @config.retry_policy
1083
+
1084
+ @speech_stub.call_rpc :batch_recognize, request, options: options do |response, operation|
1085
+ response = ::Gapic::Operation.new response, @operations_client, options: options
1086
+ yield response, operation if block_given?
1087
+ return response
1088
+ end
1089
+ rescue ::GRPC::BadStatus => e
1090
+ raise ::Google::Cloud::Error.from_error(e)
1091
+ end
1092
+
1093
+ ##
1094
+ # Returns the requested {::Google::Cloud::Speech::V2::Config Config}.
1095
+ #
1096
+ # @overload get_config(request, options = nil)
1097
+ # Pass arguments to `get_config` via a request object, either of type
1098
+ # {::Google::Cloud::Speech::V2::GetConfigRequest} or an equivalent Hash.
1099
+ #
1100
+ # @param request [::Google::Cloud::Speech::V2::GetConfigRequest, ::Hash]
1101
+ # A request object representing the call parameters. Required. To specify no
1102
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1103
+ # @param options [::Gapic::CallOptions, ::Hash]
1104
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1105
+ #
1106
+ # @overload get_config(name: nil)
1107
+ # Pass arguments to `get_config` via keyword arguments. Note that at
1108
+ # least one keyword argument is required. To specify no parameters, or to keep all
1109
+ # the default parameter values, pass an empty Hash as a request object (see above).
1110
+ #
1111
+ # @param name [::String]
1112
+ # Required. The name of the config to retrieve. There is exactly one config
1113
+ # resource per project per location. The expected format is
1114
+ # `projects/{project}/locations/{location}/config`.
1115
+ #
1116
+ # @yield [response, operation] Access the result along with the RPC operation
1117
+ # @yieldparam response [::Google::Cloud::Speech::V2::Config]
1118
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1119
+ #
1120
+ # @return [::Google::Cloud::Speech::V2::Config]
1121
+ #
1122
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1123
+ #
1124
+ # @example Basic example
1125
+ # require "google/cloud/speech/v2"
1126
+ #
1127
+ # # Create a client object. The client can be reused for multiple calls.
1128
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
1129
+ #
1130
+ # # Create a request. To set request fields, pass in keyword arguments.
1131
+ # request = Google::Cloud::Speech::V2::GetConfigRequest.new
1132
+ #
1133
+ # # Call the get_config method.
1134
+ # result = client.get_config request
1135
+ #
1136
+ # # The returned object is of type Google::Cloud::Speech::V2::Config.
1137
+ # p result
1138
+ #
1139
+ def get_config request, options = nil
1140
+ raise ::ArgumentError, "request must be provided" if request.nil?
1141
+
1142
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::GetConfigRequest
1143
+
1144
+ # Converts hash and nil to an options object
1145
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1146
+
1147
+ # Customize the options with defaults
1148
+ metadata = @config.rpcs.get_config.metadata.to_h
1149
+
1150
+ # Set x-goog-api-client and x-goog-user-project headers
1151
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1152
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1153
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
1154
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1155
+
1156
+ header_params = {}
1157
+ if request.name
1158
+ header_params["name"] = request.name
1159
+ end
1160
+
1161
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1162
+ metadata[:"x-goog-request-params"] ||= request_params_header
1163
+
1164
+ options.apply_defaults timeout: @config.rpcs.get_config.timeout,
1165
+ metadata: metadata,
1166
+ retry_policy: @config.rpcs.get_config.retry_policy
1167
+
1168
+ options.apply_defaults timeout: @config.timeout,
1169
+ metadata: @config.metadata,
1170
+ retry_policy: @config.retry_policy
1171
+
1172
+ @speech_stub.call_rpc :get_config, request, options: options do |response, operation|
1173
+ yield response, operation if block_given?
1174
+ return response
1175
+ end
1176
+ rescue ::GRPC::BadStatus => e
1177
+ raise ::Google::Cloud::Error.from_error(e)
1178
+ end
1179
+
1180
+ ##
1181
+ # Updates the {::Google::Cloud::Speech::V2::Config Config}.
1182
+ #
1183
+ # @overload update_config(request, options = nil)
1184
+ # Pass arguments to `update_config` via a request object, either of type
1185
+ # {::Google::Cloud::Speech::V2::UpdateConfigRequest} or an equivalent Hash.
1186
+ #
1187
+ # @param request [::Google::Cloud::Speech::V2::UpdateConfigRequest, ::Hash]
1188
+ # A request object representing the call parameters. Required. To specify no
1189
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1190
+ # @param options [::Gapic::CallOptions, ::Hash]
1191
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1192
+ #
1193
+ # @overload update_config(config: nil, update_mask: nil)
1194
+ # Pass arguments to `update_config` via keyword arguments. Note that at
1195
+ # least one keyword argument is required. To specify no parameters, or to keep all
1196
+ # the default parameter values, pass an empty Hash as a request object (see above).
1197
+ #
1198
+ # @param config [::Google::Cloud::Speech::V2::Config, ::Hash]
1199
+ # Required. The config to update.
1200
+ #
1201
+ # The config's `name` field is used to identify the config to be updated.
1202
+ # The expected format is `projects/{project}/locations/{location}/config`.
1203
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
1204
+ # The list of fields to be updated.
1205
+ #
1206
+ # @yield [response, operation] Access the result along with the RPC operation
1207
+ # @yieldparam response [::Google::Cloud::Speech::V2::Config]
1208
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1209
+ #
1210
+ # @return [::Google::Cloud::Speech::V2::Config]
1211
+ #
1212
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1213
+ #
1214
+ # @example Basic example
1215
+ # require "google/cloud/speech/v2"
1216
+ #
1217
+ # # Create a client object. The client can be reused for multiple calls.
1218
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
1219
+ #
1220
+ # # Create a request. To set request fields, pass in keyword arguments.
1221
+ # request = Google::Cloud::Speech::V2::UpdateConfigRequest.new
1222
+ #
1223
+ # # Call the update_config method.
1224
+ # result = client.update_config request
1225
+ #
1226
+ # # The returned object is of type Google::Cloud::Speech::V2::Config.
1227
+ # p result
1228
+ #
1229
+ def update_config request, options = nil
1230
+ raise ::ArgumentError, "request must be provided" if request.nil?
1231
+
1232
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UpdateConfigRequest
1233
+
1234
+ # Converts hash and nil to an options object
1235
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1236
+
1237
+ # Customize the options with defaults
1238
+ metadata = @config.rpcs.update_config.metadata.to_h
1239
+
1240
+ # Set x-goog-api-client and x-goog-user-project headers
1241
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1242
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1243
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
1244
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1245
+
1246
+ header_params = {}
1247
+ if request.config&.name
1248
+ header_params["config.name"] = request.config.name
1249
+ end
1250
+
1251
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1252
+ metadata[:"x-goog-request-params"] ||= request_params_header
1253
+
1254
+ options.apply_defaults timeout: @config.rpcs.update_config.timeout,
1255
+ metadata: metadata,
1256
+ retry_policy: @config.rpcs.update_config.retry_policy
1257
+
1258
+ options.apply_defaults timeout: @config.timeout,
1259
+ metadata: @config.metadata,
1260
+ retry_policy: @config.retry_policy
1261
+
1262
+ @speech_stub.call_rpc :update_config, request, options: options do |response, operation|
1263
+ yield response, operation if block_given?
1264
+ return response
1265
+ end
1266
+ rescue ::GRPC::BadStatus => e
1267
+ raise ::Google::Cloud::Error.from_error(e)
1268
+ end
1269
+
1270
+ ##
1271
+ # Creates a {::Google::Cloud::Speech::V2::CustomClass CustomClass}.
1272
+ #
1273
+ # @overload create_custom_class(request, options = nil)
1274
+ # Pass arguments to `create_custom_class` via a request object, either of type
1275
+ # {::Google::Cloud::Speech::V2::CreateCustomClassRequest} or an equivalent Hash.
1276
+ #
1277
+ # @param request [::Google::Cloud::Speech::V2::CreateCustomClassRequest, ::Hash]
1278
+ # A request object representing the call parameters. Required. To specify no
1279
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1280
+ # @param options [::Gapic::CallOptions, ::Hash]
1281
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1282
+ #
1283
+ # @overload create_custom_class(custom_class: nil, validate_only: nil, custom_class_id: nil, parent: nil)
1284
+ # Pass arguments to `create_custom_class` via keyword arguments. Note that at
1285
+ # least one keyword argument is required. To specify no parameters, or to keep all
1286
+ # the default parameter values, pass an empty Hash as a request object (see above).
1287
+ #
1288
+ # @param custom_class [::Google::Cloud::Speech::V2::CustomClass, ::Hash]
1289
+ # Required. The CustomClass to create.
1290
+ # @param validate_only [::Boolean]
1291
+ # If set, validate the request and preview the CustomClass, but do not
1292
+ # actually create it.
1293
+ # @param custom_class_id [::String]
1294
+ # The ID to use for the CustomClass, which will become the final component of
1295
+ # the CustomClass's resource name.
1296
+ #
1297
+ # This value should be 4-63 characters, and valid characters
1298
+ # are /[a-z][0-9]-/.
1299
+ # @param parent [::String]
1300
+ # Required. The project and location where this CustomClass will be created.
1301
+ # The expected format is `projects/{project}/locations/{location}`.
1302
+ #
1303
+ # @yield [response, operation] Access the result along with the RPC operation
1304
+ # @yieldparam response [::Gapic::Operation]
1305
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1306
+ #
1307
+ # @return [::Gapic::Operation]
1308
+ #
1309
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1310
+ #
1311
+ # @example Basic example
1312
+ # require "google/cloud/speech/v2"
1313
+ #
1314
+ # # Create a client object. The client can be reused for multiple calls.
1315
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
1316
+ #
1317
+ # # Create a request. To set request fields, pass in keyword arguments.
1318
+ # request = Google::Cloud::Speech::V2::CreateCustomClassRequest.new
1319
+ #
1320
+ # # Call the create_custom_class method.
1321
+ # result = client.create_custom_class request
1322
+ #
1323
+ # # The returned object is of type Gapic::Operation. You can use this
1324
+ # # object to check the status of an operation, cancel it, or wait
1325
+ # # for results. Here is how to block until completion:
1326
+ # result.wait_until_done! timeout: 60
1327
+ # if result.response?
1328
+ # p result.response
1329
+ # else
1330
+ # puts "Error!"
1331
+ # end
1332
+ #
1333
+ def create_custom_class request, options = nil
1334
+ raise ::ArgumentError, "request must be provided" if request.nil?
1335
+
1336
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::CreateCustomClassRequest
1337
+
1338
+ # Converts hash and nil to an options object
1339
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1340
+
1341
+ # Customize the options with defaults
1342
+ metadata = @config.rpcs.create_custom_class.metadata.to_h
1343
+
1344
+ # Set x-goog-api-client and x-goog-user-project headers
1345
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1346
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1347
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
1348
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1349
+
1350
+ header_params = {}
1351
+ if request.parent
1352
+ header_params["parent"] = request.parent
1353
+ end
1354
+
1355
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1356
+ metadata[:"x-goog-request-params"] ||= request_params_header
1357
+
1358
+ options.apply_defaults timeout: @config.rpcs.create_custom_class.timeout,
1359
+ metadata: metadata,
1360
+ retry_policy: @config.rpcs.create_custom_class.retry_policy
1361
+
1362
+ options.apply_defaults timeout: @config.timeout,
1363
+ metadata: @config.metadata,
1364
+ retry_policy: @config.retry_policy
1365
+
1366
+ @speech_stub.call_rpc :create_custom_class, request, options: options do |response, operation|
1367
+ response = ::Gapic::Operation.new response, @operations_client, options: options
1368
+ yield response, operation if block_given?
1369
+ return response
1370
+ end
1371
+ rescue ::GRPC::BadStatus => e
1372
+ raise ::Google::Cloud::Error.from_error(e)
1373
+ end
1374
+
1375
+ ##
1376
+ # Lists CustomClasses.
1377
+ #
1378
+ # @overload list_custom_classes(request, options = nil)
1379
+ # Pass arguments to `list_custom_classes` via a request object, either of type
1380
+ # {::Google::Cloud::Speech::V2::ListCustomClassesRequest} or an equivalent Hash.
1381
+ #
1382
+ # @param request [::Google::Cloud::Speech::V2::ListCustomClassesRequest, ::Hash]
1383
+ # A request object representing the call parameters. Required. To specify no
1384
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1385
+ # @param options [::Gapic::CallOptions, ::Hash]
1386
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1387
+ #
1388
+ # @overload list_custom_classes(parent: nil, page_size: nil, page_token: nil, show_deleted: nil)
1389
+ # Pass arguments to `list_custom_classes` via keyword arguments. Note that at
1390
+ # least one keyword argument is required. To specify no parameters, or to keep all
1391
+ # the default parameter values, pass an empty Hash as a request object (see above).
1392
+ #
1393
+ # @param parent [::String]
1394
+ # Required. The project and location of CustomClass resources to list. The
1395
+ # expected format is `projects/{project}/locations/{location}`.
1396
+ # @param page_size [::Integer]
1397
+ # Number of results per requests. A valid page_size ranges from 0 to 20
1398
+ # inclusive. If the page_size is zero or unspecified, a page size of 5 will
1399
+ # be chosen. If the page size exceeds 20, it will be coerced down to 20. Note
1400
+ # that a call might return fewer results than the requested page size.
1401
+ # @param page_token [::String]
1402
+ # A page token, received from a previous
1403
+ # {::Google::Cloud::Speech::V2::Speech::Client#list_custom_classes ListCustomClasses} call.
1404
+ # Provide this to retrieve the subsequent page.
1405
+ #
1406
+ # When paginating, all other parameters provided to
1407
+ # {::Google::Cloud::Speech::V2::Speech::Client#list_custom_classes ListCustomClasses} must
1408
+ # match the call that provided the page token.
1409
+ # @param show_deleted [::Boolean]
1410
+ # Whether, or not, to show resources that have been deleted.
1411
+ #
1412
+ # @yield [response, operation] Access the result along with the RPC operation
1413
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Speech::V2::CustomClass>]
1414
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1415
+ #
1416
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Speech::V2::CustomClass>]
1417
+ #
1418
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1419
+ #
1420
+ # @example Basic example
1421
+ # require "google/cloud/speech/v2"
1422
+ #
1423
+ # # Create a client object. The client can be reused for multiple calls.
1424
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
1425
+ #
1426
+ # # Create a request. To set request fields, pass in keyword arguments.
1427
+ # request = Google::Cloud::Speech::V2::ListCustomClassesRequest.new
1428
+ #
1429
+ # # Call the list_custom_classes method.
1430
+ # result = client.list_custom_classes request
1431
+ #
1432
+ # # The returned object is of type Gapic::PagedEnumerable. You can
1433
+ # # iterate over all elements by calling #each, and the enumerable
1434
+ # # will lazily make API calls to fetch subsequent pages. Other
1435
+ # # methods are also available for managing paging directly.
1436
+ # result.each do |response|
1437
+ # # Each element is of type ::Google::Cloud::Speech::V2::CustomClass.
1438
+ # p response
1439
+ # end
1440
+ #
1441
+ def list_custom_classes request, options = nil
1442
+ raise ::ArgumentError, "request must be provided" if request.nil?
1443
+
1444
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::ListCustomClassesRequest
1445
+
1446
+ # Converts hash and nil to an options object
1447
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1448
+
1449
+ # Customize the options with defaults
1450
+ metadata = @config.rpcs.list_custom_classes.metadata.to_h
1451
+
1452
+ # Set x-goog-api-client and x-goog-user-project headers
1453
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1454
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1455
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
1456
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1457
+
1458
+ header_params = {}
1459
+ if request.parent
1460
+ header_params["parent"] = request.parent
1461
+ end
1462
+
1463
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1464
+ metadata[:"x-goog-request-params"] ||= request_params_header
1465
+
1466
+ options.apply_defaults timeout: @config.rpcs.list_custom_classes.timeout,
1467
+ metadata: metadata,
1468
+ retry_policy: @config.rpcs.list_custom_classes.retry_policy
1469
+
1470
+ options.apply_defaults timeout: @config.timeout,
1471
+ metadata: @config.metadata,
1472
+ retry_policy: @config.retry_policy
1473
+
1474
+ @speech_stub.call_rpc :list_custom_classes, request, options: options do |response, operation|
1475
+ response = ::Gapic::PagedEnumerable.new @speech_stub, :list_custom_classes, request, response, operation, options
1476
+ yield response, operation if block_given?
1477
+ return response
1478
+ end
1479
+ rescue ::GRPC::BadStatus => e
1480
+ raise ::Google::Cloud::Error.from_error(e)
1481
+ end
1482
+
1483
+ ##
1484
+ # Returns the requested
1485
+ # {::Google::Cloud::Speech::V2::CustomClass CustomClass}.
1486
+ #
1487
+ # @overload get_custom_class(request, options = nil)
1488
+ # Pass arguments to `get_custom_class` via a request object, either of type
1489
+ # {::Google::Cloud::Speech::V2::GetCustomClassRequest} or an equivalent Hash.
1490
+ #
1491
+ # @param request [::Google::Cloud::Speech::V2::GetCustomClassRequest, ::Hash]
1492
+ # A request object representing the call parameters. Required. To specify no
1493
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1494
+ # @param options [::Gapic::CallOptions, ::Hash]
1495
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1496
+ #
1497
+ # @overload get_custom_class(name: nil)
1498
+ # Pass arguments to `get_custom_class` via keyword arguments. Note that at
1499
+ # least one keyword argument is required. To specify no parameters, or to keep all
1500
+ # the default parameter values, pass an empty Hash as a request object (see above).
1501
+ #
1502
+ # @param name [::String]
1503
+ # Required. The name of the CustomClass to retrieve. The expected format is
1504
+ # `projects/{project}/locations/{location}/customClasses/{custom_class}`.
1505
+ #
1506
+ # @yield [response, operation] Access the result along with the RPC operation
1507
+ # @yieldparam response [::Google::Cloud::Speech::V2::CustomClass]
1508
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1509
+ #
1510
+ # @return [::Google::Cloud::Speech::V2::CustomClass]
1511
+ #
1512
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1513
+ #
1514
+ # @example Basic example
1515
+ # require "google/cloud/speech/v2"
1516
+ #
1517
+ # # Create a client object. The client can be reused for multiple calls.
1518
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
1519
+ #
1520
+ # # Create a request. To set request fields, pass in keyword arguments.
1521
+ # request = Google::Cloud::Speech::V2::GetCustomClassRequest.new
1522
+ #
1523
+ # # Call the get_custom_class method.
1524
+ # result = client.get_custom_class request
1525
+ #
1526
+ # # The returned object is of type Google::Cloud::Speech::V2::CustomClass.
1527
+ # p result
1528
+ #
1529
+ def get_custom_class request, options = nil
1530
+ raise ::ArgumentError, "request must be provided" if request.nil?
1531
+
1532
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::GetCustomClassRequest
1533
+
1534
+ # Converts hash and nil to an options object
1535
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1536
+
1537
+ # Customize the options with defaults
1538
+ metadata = @config.rpcs.get_custom_class.metadata.to_h
1539
+
1540
+ # Set x-goog-api-client and x-goog-user-project headers
1541
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1542
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1543
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
1544
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1545
+
1546
+ header_params = {}
1547
+ if request.name
1548
+ header_params["name"] = request.name
1549
+ end
1550
+
1551
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1552
+ metadata[:"x-goog-request-params"] ||= request_params_header
1553
+
1554
+ options.apply_defaults timeout: @config.rpcs.get_custom_class.timeout,
1555
+ metadata: metadata,
1556
+ retry_policy: @config.rpcs.get_custom_class.retry_policy
1557
+
1558
+ options.apply_defaults timeout: @config.timeout,
1559
+ metadata: @config.metadata,
1560
+ retry_policy: @config.retry_policy
1561
+
1562
+ @speech_stub.call_rpc :get_custom_class, request, options: options do |response, operation|
1563
+ yield response, operation if block_given?
1564
+ return response
1565
+ end
1566
+ rescue ::GRPC::BadStatus => e
1567
+ raise ::Google::Cloud::Error.from_error(e)
1568
+ end
1569
+
1570
+ ##
1571
+ # Updates the {::Google::Cloud::Speech::V2::CustomClass CustomClass}.
1572
+ #
1573
+ # @overload update_custom_class(request, options = nil)
1574
+ # Pass arguments to `update_custom_class` via a request object, either of type
1575
+ # {::Google::Cloud::Speech::V2::UpdateCustomClassRequest} or an equivalent Hash.
1576
+ #
1577
+ # @param request [::Google::Cloud::Speech::V2::UpdateCustomClassRequest, ::Hash]
1578
+ # A request object representing the call parameters. Required. To specify no
1579
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1580
+ # @param options [::Gapic::CallOptions, ::Hash]
1581
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1582
+ #
1583
+ # @overload update_custom_class(custom_class: nil, update_mask: nil, validate_only: nil)
1584
+ # Pass arguments to `update_custom_class` via keyword arguments. Note that at
1585
+ # least one keyword argument is required. To specify no parameters, or to keep all
1586
+ # the default parameter values, pass an empty Hash as a request object (see above).
1587
+ #
1588
+ # @param custom_class [::Google::Cloud::Speech::V2::CustomClass, ::Hash]
1589
+ # Required. The CustomClass to update.
1590
+ #
1591
+ # The CustomClass's `name` field is used to identify the CustomClass to
1592
+ # update. Format:
1593
+ # `projects/{project}/locations/{location}/customClasses/{custom_class}`.
1594
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
1595
+ # The list of fields to be updated. If empty, all fields are considered for
1596
+ # update.
1597
+ # @param validate_only [::Boolean]
1598
+ # If set, validate the request and preview the updated CustomClass, but do
1599
+ # not actually update it.
1600
+ #
1601
+ # @yield [response, operation] Access the result along with the RPC operation
1602
+ # @yieldparam response [::Gapic::Operation]
1603
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1604
+ #
1605
+ # @return [::Gapic::Operation]
1606
+ #
1607
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1608
+ #
1609
+ # @example Basic example
1610
+ # require "google/cloud/speech/v2"
1611
+ #
1612
+ # # Create a client object. The client can be reused for multiple calls.
1613
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
1614
+ #
1615
+ # # Create a request. To set request fields, pass in keyword arguments.
1616
+ # request = Google::Cloud::Speech::V2::UpdateCustomClassRequest.new
1617
+ #
1618
+ # # Call the update_custom_class method.
1619
+ # result = client.update_custom_class request
1620
+ #
1621
+ # # The returned object is of type Gapic::Operation. You can use this
1622
+ # # object to check the status of an operation, cancel it, or wait
1623
+ # # for results. Here is how to block until completion:
1624
+ # result.wait_until_done! timeout: 60
1625
+ # if result.response?
1626
+ # p result.response
1627
+ # else
1628
+ # puts "Error!"
1629
+ # end
1630
+ #
1631
+ def update_custom_class request, options = nil
1632
+ raise ::ArgumentError, "request must be provided" if request.nil?
1633
+
1634
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UpdateCustomClassRequest
1635
+
1636
+ # Converts hash and nil to an options object
1637
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1638
+
1639
+ # Customize the options with defaults
1640
+ metadata = @config.rpcs.update_custom_class.metadata.to_h
1641
+
1642
+ # Set x-goog-api-client and x-goog-user-project headers
1643
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1644
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1645
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
1646
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1647
+
1648
+ header_params = {}
1649
+ if request.custom_class&.name
1650
+ header_params["custom_class.name"] = request.custom_class.name
1651
+ end
1652
+
1653
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1654
+ metadata[:"x-goog-request-params"] ||= request_params_header
1655
+
1656
+ options.apply_defaults timeout: @config.rpcs.update_custom_class.timeout,
1657
+ metadata: metadata,
1658
+ retry_policy: @config.rpcs.update_custom_class.retry_policy
1659
+
1660
+ options.apply_defaults timeout: @config.timeout,
1661
+ metadata: @config.metadata,
1662
+ retry_policy: @config.retry_policy
1663
+
1664
+ @speech_stub.call_rpc :update_custom_class, request, options: options do |response, operation|
1665
+ response = ::Gapic::Operation.new response, @operations_client, options: options
1666
+ yield response, operation if block_given?
1667
+ return response
1668
+ end
1669
+ rescue ::GRPC::BadStatus => e
1670
+ raise ::Google::Cloud::Error.from_error(e)
1671
+ end
1672
+
1673
+ ##
1674
+ # Deletes the {::Google::Cloud::Speech::V2::CustomClass CustomClass}.
1675
+ #
1676
+ # @overload delete_custom_class(request, options = nil)
1677
+ # Pass arguments to `delete_custom_class` via a request object, either of type
1678
+ # {::Google::Cloud::Speech::V2::DeleteCustomClassRequest} or an equivalent Hash.
1679
+ #
1680
+ # @param request [::Google::Cloud::Speech::V2::DeleteCustomClassRequest, ::Hash]
1681
+ # A request object representing the call parameters. Required. To specify no
1682
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1683
+ # @param options [::Gapic::CallOptions, ::Hash]
1684
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1685
+ #
1686
+ # @overload delete_custom_class(name: nil, validate_only: nil, allow_missing: nil, etag: nil)
1687
+ # Pass arguments to `delete_custom_class` via keyword arguments. Note that at
1688
+ # least one keyword argument is required. To specify no parameters, or to keep all
1689
+ # the default parameter values, pass an empty Hash as a request object (see above).
1690
+ #
1691
+ # @param name [::String]
1692
+ # Required. The name of the CustomClass to delete.
1693
+ # Format:
1694
+ # `projects/{project}/locations/{location}/customClasses/{custom_class}`
1695
+ # @param validate_only [::Boolean]
1696
+ # If set, validate the request and preview the deleted CustomClass, but do
1697
+ # not actually delete it.
1698
+ # @param allow_missing [::Boolean]
1699
+ # If set to true, and the CustomClass is not found, the request will succeed
1700
+ # and be a no-op (no Operation is recorded in this case).
1701
+ # @param etag [::String]
1702
+ # This checksum is computed by the server based on the value of other
1703
+ # fields. This may be sent on update, undelete, and delete requests to ensure
1704
+ # the client has an up-to-date value before proceeding.
1705
+ #
1706
+ # @yield [response, operation] Access the result along with the RPC operation
1707
+ # @yieldparam response [::Gapic::Operation]
1708
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1709
+ #
1710
+ # @return [::Gapic::Operation]
1711
+ #
1712
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1713
+ #
1714
+ # @example Basic example
1715
+ # require "google/cloud/speech/v2"
1716
+ #
1717
+ # # Create a client object. The client can be reused for multiple calls.
1718
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
1719
+ #
1720
+ # # Create a request. To set request fields, pass in keyword arguments.
1721
+ # request = Google::Cloud::Speech::V2::DeleteCustomClassRequest.new
1722
+ #
1723
+ # # Call the delete_custom_class method.
1724
+ # result = client.delete_custom_class request
1725
+ #
1726
+ # # The returned object is of type Gapic::Operation. You can use this
1727
+ # # object to check the status of an operation, cancel it, or wait
1728
+ # # for results. Here is how to block until completion:
1729
+ # result.wait_until_done! timeout: 60
1730
+ # if result.response?
1731
+ # p result.response
1732
+ # else
1733
+ # puts "Error!"
1734
+ # end
1735
+ #
1736
+ def delete_custom_class request, options = nil
1737
+ raise ::ArgumentError, "request must be provided" if request.nil?
1738
+
1739
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::DeleteCustomClassRequest
1740
+
1741
+ # Converts hash and nil to an options object
1742
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1743
+
1744
+ # Customize the options with defaults
1745
+ metadata = @config.rpcs.delete_custom_class.metadata.to_h
1746
+
1747
+ # Set x-goog-api-client and x-goog-user-project headers
1748
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1749
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1750
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
1751
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1752
+
1753
+ header_params = {}
1754
+ if request.name
1755
+ header_params["name"] = request.name
1756
+ end
1757
+
1758
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1759
+ metadata[:"x-goog-request-params"] ||= request_params_header
1760
+
1761
+ options.apply_defaults timeout: @config.rpcs.delete_custom_class.timeout,
1762
+ metadata: metadata,
1763
+ retry_policy: @config.rpcs.delete_custom_class.retry_policy
1764
+
1765
+ options.apply_defaults timeout: @config.timeout,
1766
+ metadata: @config.metadata,
1767
+ retry_policy: @config.retry_policy
1768
+
1769
+ @speech_stub.call_rpc :delete_custom_class, request, options: options do |response, operation|
1770
+ response = ::Gapic::Operation.new response, @operations_client, options: options
1771
+ yield response, operation if block_given?
1772
+ return response
1773
+ end
1774
+ rescue ::GRPC::BadStatus => e
1775
+ raise ::Google::Cloud::Error.from_error(e)
1776
+ end
1777
+
1778
+ ##
1779
+ # Undeletes the {::Google::Cloud::Speech::V2::CustomClass CustomClass}.
1780
+ #
1781
+ # @overload undelete_custom_class(request, options = nil)
1782
+ # Pass arguments to `undelete_custom_class` via a request object, either of type
1783
+ # {::Google::Cloud::Speech::V2::UndeleteCustomClassRequest} or an equivalent Hash.
1784
+ #
1785
+ # @param request [::Google::Cloud::Speech::V2::UndeleteCustomClassRequest, ::Hash]
1786
+ # A request object representing the call parameters. Required. To specify no
1787
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1788
+ # @param options [::Gapic::CallOptions, ::Hash]
1789
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1790
+ #
1791
+ # @overload undelete_custom_class(name: nil, validate_only: nil, etag: nil)
1792
+ # Pass arguments to `undelete_custom_class` via keyword arguments. Note that at
1793
+ # least one keyword argument is required. To specify no parameters, or to keep all
1794
+ # the default parameter values, pass an empty Hash as a request object (see above).
1795
+ #
1796
+ # @param name [::String]
1797
+ # Required. The name of the CustomClass to undelete.
1798
+ # Format:
1799
+ # `projects/{project}/locations/{location}/customClasses/{custom_class}`
1800
+ # @param validate_only [::Boolean]
1801
+ # If set, validate the request and preview the undeleted CustomClass, but do
1802
+ # not actually undelete it.
1803
+ # @param etag [::String]
1804
+ # This checksum is computed by the server based on the value of other
1805
+ # fields. This may be sent on update, undelete, and delete requests to ensure
1806
+ # the client has an up-to-date value before proceeding.
1807
+ #
1808
+ # @yield [response, operation] Access the result along with the RPC operation
1809
+ # @yieldparam response [::Gapic::Operation]
1810
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1811
+ #
1812
+ # @return [::Gapic::Operation]
1813
+ #
1814
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1815
+ #
1816
+ # @example Basic example
1817
+ # require "google/cloud/speech/v2"
1818
+ #
1819
+ # # Create a client object. The client can be reused for multiple calls.
1820
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
1821
+ #
1822
+ # # Create a request. To set request fields, pass in keyword arguments.
1823
+ # request = Google::Cloud::Speech::V2::UndeleteCustomClassRequest.new
1824
+ #
1825
+ # # Call the undelete_custom_class method.
1826
+ # result = client.undelete_custom_class request
1827
+ #
1828
+ # # The returned object is of type Gapic::Operation. You can use this
1829
+ # # object to check the status of an operation, cancel it, or wait
1830
+ # # for results. Here is how to block until completion:
1831
+ # result.wait_until_done! timeout: 60
1832
+ # if result.response?
1833
+ # p result.response
1834
+ # else
1835
+ # puts "Error!"
1836
+ # end
1837
+ #
1838
+ def undelete_custom_class request, options = nil
1839
+ raise ::ArgumentError, "request must be provided" if request.nil?
1840
+
1841
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UndeleteCustomClassRequest
1842
+
1843
+ # Converts hash and nil to an options object
1844
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1845
+
1846
+ # Customize the options with defaults
1847
+ metadata = @config.rpcs.undelete_custom_class.metadata.to_h
1848
+
1849
+ # Set x-goog-api-client and x-goog-user-project headers
1850
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1851
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1852
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
1853
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1854
+
1855
+ header_params = {}
1856
+ if request.name
1857
+ header_params["name"] = request.name
1858
+ end
1859
+
1860
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1861
+ metadata[:"x-goog-request-params"] ||= request_params_header
1862
+
1863
+ options.apply_defaults timeout: @config.rpcs.undelete_custom_class.timeout,
1864
+ metadata: metadata,
1865
+ retry_policy: @config.rpcs.undelete_custom_class.retry_policy
1866
+
1867
+ options.apply_defaults timeout: @config.timeout,
1868
+ metadata: @config.metadata,
1869
+ retry_policy: @config.retry_policy
1870
+
1871
+ @speech_stub.call_rpc :undelete_custom_class, request, options: options do |response, operation|
1872
+ response = ::Gapic::Operation.new response, @operations_client, options: options
1873
+ yield response, operation if block_given?
1874
+ return response
1875
+ end
1876
+ rescue ::GRPC::BadStatus => e
1877
+ raise ::Google::Cloud::Error.from_error(e)
1878
+ end
1879
+
1880
+ ##
1881
+ # Creates a {::Google::Cloud::Speech::V2::PhraseSet PhraseSet}.
1882
+ #
1883
+ # @overload create_phrase_set(request, options = nil)
1884
+ # Pass arguments to `create_phrase_set` via a request object, either of type
1885
+ # {::Google::Cloud::Speech::V2::CreatePhraseSetRequest} or an equivalent Hash.
1886
+ #
1887
+ # @param request [::Google::Cloud::Speech::V2::CreatePhraseSetRequest, ::Hash]
1888
+ # A request object representing the call parameters. Required. To specify no
1889
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1890
+ # @param options [::Gapic::CallOptions, ::Hash]
1891
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1892
+ #
1893
+ # @overload create_phrase_set(phrase_set: nil, validate_only: nil, phrase_set_id: nil, parent: nil)
1894
+ # Pass arguments to `create_phrase_set` via keyword arguments. Note that at
1895
+ # least one keyword argument is required. To specify no parameters, or to keep all
1896
+ # the default parameter values, pass an empty Hash as a request object (see above).
1897
+ #
1898
+ # @param phrase_set [::Google::Cloud::Speech::V2::PhraseSet, ::Hash]
1899
+ # Required. The PhraseSet to create.
1900
+ # @param validate_only [::Boolean]
1901
+ # If set, validate the request and preview the PhraseSet, but do not
1902
+ # actually create it.
1903
+ # @param phrase_set_id [::String]
1904
+ # The ID to use for the PhraseSet, which will become the final component of
1905
+ # the PhraseSet's resource name.
1906
+ #
1907
+ # This value should be 4-63 characters, and valid characters
1908
+ # are /[a-z][0-9]-/.
1909
+ # @param parent [::String]
1910
+ # Required. The project and location where this PhraseSet will be created.
1911
+ # The expected format is `projects/{project}/locations/{location}`.
1912
+ #
1913
+ # @yield [response, operation] Access the result along with the RPC operation
1914
+ # @yieldparam response [::Gapic::Operation]
1915
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1916
+ #
1917
+ # @return [::Gapic::Operation]
1918
+ #
1919
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1920
+ #
1921
+ # @example Basic example
1922
+ # require "google/cloud/speech/v2"
1923
+ #
1924
+ # # Create a client object. The client can be reused for multiple calls.
1925
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
1926
+ #
1927
+ # # Create a request. To set request fields, pass in keyword arguments.
1928
+ # request = Google::Cloud::Speech::V2::CreatePhraseSetRequest.new
1929
+ #
1930
+ # # Call the create_phrase_set method.
1931
+ # result = client.create_phrase_set request
1932
+ #
1933
+ # # The returned object is of type Gapic::Operation. You can use this
1934
+ # # object to check the status of an operation, cancel it, or wait
1935
+ # # for results. Here is how to block until completion:
1936
+ # result.wait_until_done! timeout: 60
1937
+ # if result.response?
1938
+ # p result.response
1939
+ # else
1940
+ # puts "Error!"
1941
+ # end
1942
+ #
1943
+ def create_phrase_set request, options = nil
1944
+ raise ::ArgumentError, "request must be provided" if request.nil?
1945
+
1946
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::CreatePhraseSetRequest
1947
+
1948
+ # Converts hash and nil to an options object
1949
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1950
+
1951
+ # Customize the options with defaults
1952
+ metadata = @config.rpcs.create_phrase_set.metadata.to_h
1953
+
1954
+ # Set x-goog-api-client and x-goog-user-project headers
1955
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1956
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1957
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
1958
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1959
+
1960
+ header_params = {}
1961
+ if request.parent
1962
+ header_params["parent"] = request.parent
1963
+ end
1964
+
1965
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1966
+ metadata[:"x-goog-request-params"] ||= request_params_header
1967
+
1968
+ options.apply_defaults timeout: @config.rpcs.create_phrase_set.timeout,
1969
+ metadata: metadata,
1970
+ retry_policy: @config.rpcs.create_phrase_set.retry_policy
1971
+
1972
+ options.apply_defaults timeout: @config.timeout,
1973
+ metadata: @config.metadata,
1974
+ retry_policy: @config.retry_policy
1975
+
1976
+ @speech_stub.call_rpc :create_phrase_set, request, options: options do |response, operation|
1977
+ response = ::Gapic::Operation.new response, @operations_client, options: options
1978
+ yield response, operation if block_given?
1979
+ return response
1980
+ end
1981
+ rescue ::GRPC::BadStatus => e
1982
+ raise ::Google::Cloud::Error.from_error(e)
1983
+ end
1984
+
1985
+ ##
1986
+ # Lists PhraseSets.
1987
+ #
1988
+ # @overload list_phrase_sets(request, options = nil)
1989
+ # Pass arguments to `list_phrase_sets` via a request object, either of type
1990
+ # {::Google::Cloud::Speech::V2::ListPhraseSetsRequest} or an equivalent Hash.
1991
+ #
1992
+ # @param request [::Google::Cloud::Speech::V2::ListPhraseSetsRequest, ::Hash]
1993
+ # A request object representing the call parameters. Required. To specify no
1994
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1995
+ # @param options [::Gapic::CallOptions, ::Hash]
1996
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1997
+ #
1998
+ # @overload list_phrase_sets(parent: nil, page_size: nil, page_token: nil, show_deleted: nil)
1999
+ # Pass arguments to `list_phrase_sets` via keyword arguments. Note that at
2000
+ # least one keyword argument is required. To specify no parameters, or to keep all
2001
+ # the default parameter values, pass an empty Hash as a request object (see above).
2002
+ #
2003
+ # @param parent [::String]
2004
+ # Required. The project and location of PhraseSet resources to list. The
2005
+ # expected format is `projects/{project}/locations/{location}`.
2006
+ # @param page_size [::Integer]
2007
+ # The maximum number of PhraseSets to return. The service may return fewer
2008
+ # than this value. If unspecified, at most 20 PhraseSets will be returned.
2009
+ # The maximum value is 20; values above 20 will be coerced to 20.
2010
+ # @param page_token [::String]
2011
+ # A page token, received from a previous
2012
+ # {::Google::Cloud::Speech::V2::Speech::Client#list_phrase_sets ListPhraseSets} call.
2013
+ # Provide this to retrieve the subsequent page.
2014
+ #
2015
+ # When paginating, all other parameters provided to
2016
+ # {::Google::Cloud::Speech::V2::Speech::Client#list_phrase_sets ListPhraseSets} must match
2017
+ # the call that provided the page token.
2018
+ # @param show_deleted [::Boolean]
2019
+ # Whether, or not, to show resources that have been deleted.
2020
+ #
2021
+ # @yield [response, operation] Access the result along with the RPC operation
2022
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Speech::V2::PhraseSet>]
2023
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
2024
+ #
2025
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Speech::V2::PhraseSet>]
2026
+ #
2027
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
2028
+ #
2029
+ # @example Basic example
2030
+ # require "google/cloud/speech/v2"
2031
+ #
2032
+ # # Create a client object. The client can be reused for multiple calls.
2033
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
2034
+ #
2035
+ # # Create a request. To set request fields, pass in keyword arguments.
2036
+ # request = Google::Cloud::Speech::V2::ListPhraseSetsRequest.new
2037
+ #
2038
+ # # Call the list_phrase_sets method.
2039
+ # result = client.list_phrase_sets request
2040
+ #
2041
+ # # The returned object is of type Gapic::PagedEnumerable. You can
2042
+ # # iterate over all elements by calling #each, and the enumerable
2043
+ # # will lazily make API calls to fetch subsequent pages. Other
2044
+ # # methods are also available for managing paging directly.
2045
+ # result.each do |response|
2046
+ # # Each element is of type ::Google::Cloud::Speech::V2::PhraseSet.
2047
+ # p response
2048
+ # end
2049
+ #
2050
+ def list_phrase_sets request, options = nil
2051
+ raise ::ArgumentError, "request must be provided" if request.nil?
2052
+
2053
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::ListPhraseSetsRequest
2054
+
2055
+ # Converts hash and nil to an options object
2056
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
2057
+
2058
+ # Customize the options with defaults
2059
+ metadata = @config.rpcs.list_phrase_sets.metadata.to_h
2060
+
2061
+ # Set x-goog-api-client and x-goog-user-project headers
2062
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
2063
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
2064
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
2065
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
2066
+
2067
+ header_params = {}
2068
+ if request.parent
2069
+ header_params["parent"] = request.parent
2070
+ end
2071
+
2072
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
2073
+ metadata[:"x-goog-request-params"] ||= request_params_header
2074
+
2075
+ options.apply_defaults timeout: @config.rpcs.list_phrase_sets.timeout,
2076
+ metadata: metadata,
2077
+ retry_policy: @config.rpcs.list_phrase_sets.retry_policy
2078
+
2079
+ options.apply_defaults timeout: @config.timeout,
2080
+ metadata: @config.metadata,
2081
+ retry_policy: @config.retry_policy
2082
+
2083
+ @speech_stub.call_rpc :list_phrase_sets, request, options: options do |response, operation|
2084
+ response = ::Gapic::PagedEnumerable.new @speech_stub, :list_phrase_sets, request, response, operation, options
2085
+ yield response, operation if block_given?
2086
+ return response
2087
+ end
2088
+ rescue ::GRPC::BadStatus => e
2089
+ raise ::Google::Cloud::Error.from_error(e)
2090
+ end
2091
+
2092
+ ##
2093
+ # Returns the requested
2094
+ # {::Google::Cloud::Speech::V2::PhraseSet PhraseSet}.
2095
+ #
2096
+ # @overload get_phrase_set(request, options = nil)
2097
+ # Pass arguments to `get_phrase_set` via a request object, either of type
2098
+ # {::Google::Cloud::Speech::V2::GetPhraseSetRequest} or an equivalent Hash.
2099
+ #
2100
+ # @param request [::Google::Cloud::Speech::V2::GetPhraseSetRequest, ::Hash]
2101
+ # A request object representing the call parameters. Required. To specify no
2102
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
2103
+ # @param options [::Gapic::CallOptions, ::Hash]
2104
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
2105
+ #
2106
+ # @overload get_phrase_set(name: nil)
2107
+ # Pass arguments to `get_phrase_set` via keyword arguments. Note that at
2108
+ # least one keyword argument is required. To specify no parameters, or to keep all
2109
+ # the default parameter values, pass an empty Hash as a request object (see above).
2110
+ #
2111
+ # @param name [::String]
2112
+ # Required. The name of the PhraseSet to retrieve. The expected format is
2113
+ # `projects/{project}/locations/{location}/phraseSets/{phrase_set}`.
2114
+ #
2115
+ # @yield [response, operation] Access the result along with the RPC operation
2116
+ # @yieldparam response [::Google::Cloud::Speech::V2::PhraseSet]
2117
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
2118
+ #
2119
+ # @return [::Google::Cloud::Speech::V2::PhraseSet]
2120
+ #
2121
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
2122
+ #
2123
+ # @example Basic example
2124
+ # require "google/cloud/speech/v2"
2125
+ #
2126
+ # # Create a client object. The client can be reused for multiple calls.
2127
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
2128
+ #
2129
+ # # Create a request. To set request fields, pass in keyword arguments.
2130
+ # request = Google::Cloud::Speech::V2::GetPhraseSetRequest.new
2131
+ #
2132
+ # # Call the get_phrase_set method.
2133
+ # result = client.get_phrase_set request
2134
+ #
2135
+ # # The returned object is of type Google::Cloud::Speech::V2::PhraseSet.
2136
+ # p result
2137
+ #
2138
+ def get_phrase_set request, options = nil
2139
+ raise ::ArgumentError, "request must be provided" if request.nil?
2140
+
2141
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::GetPhraseSetRequest
2142
+
2143
+ # Converts hash and nil to an options object
2144
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
2145
+
2146
+ # Customize the options with defaults
2147
+ metadata = @config.rpcs.get_phrase_set.metadata.to_h
2148
+
2149
+ # Set x-goog-api-client and x-goog-user-project headers
2150
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
2151
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
2152
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
2153
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
2154
+
2155
+ header_params = {}
2156
+ if request.name
2157
+ header_params["name"] = request.name
2158
+ end
2159
+
2160
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
2161
+ metadata[:"x-goog-request-params"] ||= request_params_header
2162
+
2163
+ options.apply_defaults timeout: @config.rpcs.get_phrase_set.timeout,
2164
+ metadata: metadata,
2165
+ retry_policy: @config.rpcs.get_phrase_set.retry_policy
2166
+
2167
+ options.apply_defaults timeout: @config.timeout,
2168
+ metadata: @config.metadata,
2169
+ retry_policy: @config.retry_policy
2170
+
2171
+ @speech_stub.call_rpc :get_phrase_set, request, options: options do |response, operation|
2172
+ yield response, operation if block_given?
2173
+ return response
2174
+ end
2175
+ rescue ::GRPC::BadStatus => e
2176
+ raise ::Google::Cloud::Error.from_error(e)
2177
+ end
2178
+
2179
+ ##
2180
+ # Updates the {::Google::Cloud::Speech::V2::PhraseSet PhraseSet}.
2181
+ #
2182
+ # @overload update_phrase_set(request, options = nil)
2183
+ # Pass arguments to `update_phrase_set` via a request object, either of type
2184
+ # {::Google::Cloud::Speech::V2::UpdatePhraseSetRequest} or an equivalent Hash.
2185
+ #
2186
+ # @param request [::Google::Cloud::Speech::V2::UpdatePhraseSetRequest, ::Hash]
2187
+ # A request object representing the call parameters. Required. To specify no
2188
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
2189
+ # @param options [::Gapic::CallOptions, ::Hash]
2190
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
2191
+ #
2192
+ # @overload update_phrase_set(phrase_set: nil, update_mask: nil, validate_only: nil)
2193
+ # Pass arguments to `update_phrase_set` via keyword arguments. Note that at
2194
+ # least one keyword argument is required. To specify no parameters, or to keep all
2195
+ # the default parameter values, pass an empty Hash as a request object (see above).
2196
+ #
2197
+ # @param phrase_set [::Google::Cloud::Speech::V2::PhraseSet, ::Hash]
2198
+ # Required. The PhraseSet to update.
2199
+ #
2200
+ # The PhraseSet's `name` field is used to identify the PhraseSet to update.
2201
+ # Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`.
2202
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
2203
+ # The list of fields to update. If empty, all non-default valued fields are
2204
+ # considered for update. Use `*` to update the entire PhraseSet resource.
2205
+ # @param validate_only [::Boolean]
2206
+ # If set, validate the request and preview the updated PhraseSet, but do not
2207
+ # actually update it.
2208
+ #
2209
+ # @yield [response, operation] Access the result along with the RPC operation
2210
+ # @yieldparam response [::Gapic::Operation]
2211
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
2212
+ #
2213
+ # @return [::Gapic::Operation]
2214
+ #
2215
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
2216
+ #
2217
+ # @example Basic example
2218
+ # require "google/cloud/speech/v2"
2219
+ #
2220
+ # # Create a client object. The client can be reused for multiple calls.
2221
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
2222
+ #
2223
+ # # Create a request. To set request fields, pass in keyword arguments.
2224
+ # request = Google::Cloud::Speech::V2::UpdatePhraseSetRequest.new
2225
+ #
2226
+ # # Call the update_phrase_set method.
2227
+ # result = client.update_phrase_set request
2228
+ #
2229
+ # # The returned object is of type Gapic::Operation. You can use this
2230
+ # # object to check the status of an operation, cancel it, or wait
2231
+ # # for results. Here is how to block until completion:
2232
+ # result.wait_until_done! timeout: 60
2233
+ # if result.response?
2234
+ # p result.response
2235
+ # else
2236
+ # puts "Error!"
2237
+ # end
2238
+ #
2239
+ def update_phrase_set request, options = nil
2240
+ raise ::ArgumentError, "request must be provided" if request.nil?
2241
+
2242
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UpdatePhraseSetRequest
2243
+
2244
+ # Converts hash and nil to an options object
2245
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
2246
+
2247
+ # Customize the options with defaults
2248
+ metadata = @config.rpcs.update_phrase_set.metadata.to_h
2249
+
2250
+ # Set x-goog-api-client and x-goog-user-project headers
2251
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
2252
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
2253
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
2254
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
2255
+
2256
+ header_params = {}
2257
+ if request.phrase_set&.name
2258
+ header_params["phrase_set.name"] = request.phrase_set.name
2259
+ end
2260
+
2261
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
2262
+ metadata[:"x-goog-request-params"] ||= request_params_header
2263
+
2264
+ options.apply_defaults timeout: @config.rpcs.update_phrase_set.timeout,
2265
+ metadata: metadata,
2266
+ retry_policy: @config.rpcs.update_phrase_set.retry_policy
2267
+
2268
+ options.apply_defaults timeout: @config.timeout,
2269
+ metadata: @config.metadata,
2270
+ retry_policy: @config.retry_policy
2271
+
2272
+ @speech_stub.call_rpc :update_phrase_set, request, options: options do |response, operation|
2273
+ response = ::Gapic::Operation.new response, @operations_client, options: options
2274
+ yield response, operation if block_given?
2275
+ return response
2276
+ end
2277
+ rescue ::GRPC::BadStatus => e
2278
+ raise ::Google::Cloud::Error.from_error(e)
2279
+ end
2280
+
2281
+ ##
2282
+ # Deletes the {::Google::Cloud::Speech::V2::PhraseSet PhraseSet}.
2283
+ #
2284
+ # @overload delete_phrase_set(request, options = nil)
2285
+ # Pass arguments to `delete_phrase_set` via a request object, either of type
2286
+ # {::Google::Cloud::Speech::V2::DeletePhraseSetRequest} or an equivalent Hash.
2287
+ #
2288
+ # @param request [::Google::Cloud::Speech::V2::DeletePhraseSetRequest, ::Hash]
2289
+ # A request object representing the call parameters. Required. To specify no
2290
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
2291
+ # @param options [::Gapic::CallOptions, ::Hash]
2292
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
2293
+ #
2294
+ # @overload delete_phrase_set(name: nil, validate_only: nil, allow_missing: nil, etag: nil)
2295
+ # Pass arguments to `delete_phrase_set` via keyword arguments. Note that at
2296
+ # least one keyword argument is required. To specify no parameters, or to keep all
2297
+ # the default parameter values, pass an empty Hash as a request object (see above).
2298
+ #
2299
+ # @param name [::String]
2300
+ # Required. The name of the PhraseSet to delete.
2301
+ # Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`
2302
+ # @param validate_only [::Boolean]
2303
+ # If set, validate the request and preview the deleted PhraseSet, but do not
2304
+ # actually delete it.
2305
+ # @param allow_missing [::Boolean]
2306
+ # If set to true, and the PhraseSet is not found, the request will succeed
2307
+ # and be a no-op (no Operation is recorded in this case).
2308
+ # @param etag [::String]
2309
+ # This checksum is computed by the server based on the value of other
2310
+ # fields. This may be sent on update, undelete, and delete requests to ensure
2311
+ # the client has an up-to-date value before proceeding.
2312
+ #
2313
+ # @yield [response, operation] Access the result along with the RPC operation
2314
+ # @yieldparam response [::Gapic::Operation]
2315
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
2316
+ #
2317
+ # @return [::Gapic::Operation]
2318
+ #
2319
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
2320
+ #
2321
+ # @example Basic example
2322
+ # require "google/cloud/speech/v2"
2323
+ #
2324
+ # # Create a client object. The client can be reused for multiple calls.
2325
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
2326
+ #
2327
+ # # Create a request. To set request fields, pass in keyword arguments.
2328
+ # request = Google::Cloud::Speech::V2::DeletePhraseSetRequest.new
2329
+ #
2330
+ # # Call the delete_phrase_set method.
2331
+ # result = client.delete_phrase_set request
2332
+ #
2333
+ # # The returned object is of type Gapic::Operation. You can use this
2334
+ # # object to check the status of an operation, cancel it, or wait
2335
+ # # for results. Here is how to block until completion:
2336
+ # result.wait_until_done! timeout: 60
2337
+ # if result.response?
2338
+ # p result.response
2339
+ # else
2340
+ # puts "Error!"
2341
+ # end
2342
+ #
2343
+ def delete_phrase_set request, options = nil
2344
+ raise ::ArgumentError, "request must be provided" if request.nil?
2345
+
2346
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::DeletePhraseSetRequest
2347
+
2348
+ # Converts hash and nil to an options object
2349
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
2350
+
2351
+ # Customize the options with defaults
2352
+ metadata = @config.rpcs.delete_phrase_set.metadata.to_h
2353
+
2354
+ # Set x-goog-api-client and x-goog-user-project headers
2355
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
2356
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
2357
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
2358
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
2359
+
2360
+ header_params = {}
2361
+ if request.name
2362
+ header_params["name"] = request.name
2363
+ end
2364
+
2365
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
2366
+ metadata[:"x-goog-request-params"] ||= request_params_header
2367
+
2368
+ options.apply_defaults timeout: @config.rpcs.delete_phrase_set.timeout,
2369
+ metadata: metadata,
2370
+ retry_policy: @config.rpcs.delete_phrase_set.retry_policy
2371
+
2372
+ options.apply_defaults timeout: @config.timeout,
2373
+ metadata: @config.metadata,
2374
+ retry_policy: @config.retry_policy
2375
+
2376
+ @speech_stub.call_rpc :delete_phrase_set, request, options: options do |response, operation|
2377
+ response = ::Gapic::Operation.new response, @operations_client, options: options
2378
+ yield response, operation if block_given?
2379
+ return response
2380
+ end
2381
+ rescue ::GRPC::BadStatus => e
2382
+ raise ::Google::Cloud::Error.from_error(e)
2383
+ end
2384
+
2385
+ ##
2386
+ # Undeletes the {::Google::Cloud::Speech::V2::PhraseSet PhraseSet}.
2387
+ #
2388
+ # @overload undelete_phrase_set(request, options = nil)
2389
+ # Pass arguments to `undelete_phrase_set` via a request object, either of type
2390
+ # {::Google::Cloud::Speech::V2::UndeletePhraseSetRequest} or an equivalent Hash.
2391
+ #
2392
+ # @param request [::Google::Cloud::Speech::V2::UndeletePhraseSetRequest, ::Hash]
2393
+ # A request object representing the call parameters. Required. To specify no
2394
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
2395
+ # @param options [::Gapic::CallOptions, ::Hash]
2396
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
2397
+ #
2398
+ # @overload undelete_phrase_set(name: nil, validate_only: nil, etag: nil)
2399
+ # Pass arguments to `undelete_phrase_set` via keyword arguments. Note that at
2400
+ # least one keyword argument is required. To specify no parameters, or to keep all
2401
+ # the default parameter values, pass an empty Hash as a request object (see above).
2402
+ #
2403
+ # @param name [::String]
2404
+ # Required. The name of the PhraseSet to undelete.
2405
+ # Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`
2406
+ # @param validate_only [::Boolean]
2407
+ # If set, validate the request and preview the undeleted PhraseSet, but do
2408
+ # not actually undelete it.
2409
+ # @param etag [::String]
2410
+ # This checksum is computed by the server based on the value of other
2411
+ # fields. This may be sent on update, undelete, and delete requests to ensure
2412
+ # the client has an up-to-date value before proceeding.
2413
+ #
2414
+ # @yield [response, operation] Access the result along with the RPC operation
2415
+ # @yieldparam response [::Gapic::Operation]
2416
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
2417
+ #
2418
+ # @return [::Gapic::Operation]
2419
+ #
2420
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
2421
+ #
2422
+ # @example Basic example
2423
+ # require "google/cloud/speech/v2"
2424
+ #
2425
+ # # Create a client object. The client can be reused for multiple calls.
2426
+ # client = Google::Cloud::Speech::V2::Speech::Client.new
2427
+ #
2428
+ # # Create a request. To set request fields, pass in keyword arguments.
2429
+ # request = Google::Cloud::Speech::V2::UndeletePhraseSetRequest.new
2430
+ #
2431
+ # # Call the undelete_phrase_set method.
2432
+ # result = client.undelete_phrase_set request
2433
+ #
2434
+ # # The returned object is of type Gapic::Operation. You can use this
2435
+ # # object to check the status of an operation, cancel it, or wait
2436
+ # # for results. Here is how to block until completion:
2437
+ # result.wait_until_done! timeout: 60
2438
+ # if result.response?
2439
+ # p result.response
2440
+ # else
2441
+ # puts "Error!"
2442
+ # end
2443
+ #
2444
+ def undelete_phrase_set request, options = nil
2445
+ raise ::ArgumentError, "request must be provided" if request.nil?
2446
+
2447
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V2::UndeletePhraseSetRequest
2448
+
2449
+ # Converts hash and nil to an options object
2450
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
2451
+
2452
+ # Customize the options with defaults
2453
+ metadata = @config.rpcs.undelete_phrase_set.metadata.to_h
2454
+
2455
+ # Set x-goog-api-client and x-goog-user-project headers
2456
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
2457
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
2458
+ gapic_version: ::Google::Cloud::Speech::V2::VERSION
2459
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
2460
+
2461
+ header_params = {}
2462
+ if request.name
2463
+ header_params["name"] = request.name
2464
+ end
2465
+
2466
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
2467
+ metadata[:"x-goog-request-params"] ||= request_params_header
2468
+
2469
+ options.apply_defaults timeout: @config.rpcs.undelete_phrase_set.timeout,
2470
+ metadata: metadata,
2471
+ retry_policy: @config.rpcs.undelete_phrase_set.retry_policy
2472
+
2473
+ options.apply_defaults timeout: @config.timeout,
2474
+ metadata: @config.metadata,
2475
+ retry_policy: @config.retry_policy
2476
+
2477
+ @speech_stub.call_rpc :undelete_phrase_set, request, options: options do |response, operation|
2478
+ response = ::Gapic::Operation.new response, @operations_client, options: options
2479
+ yield response, operation if block_given?
2480
+ return response
2481
+ end
2482
+ rescue ::GRPC::BadStatus => e
2483
+ raise ::Google::Cloud::Error.from_error(e)
2484
+ end
2485
+
2486
+ ##
2487
+ # Configuration class for the Speech API.
2488
+ #
2489
+ # This class represents the configuration for Speech,
2490
+ # providing control over timeouts, retry behavior, logging, transport
2491
+ # parameters, and other low-level controls. Certain parameters can also be
2492
+ # applied individually to specific RPCs. See
2493
+ # {::Google::Cloud::Speech::V2::Speech::Client::Configuration::Rpcs}
2494
+ # for a list of RPCs that can be configured independently.
2495
+ #
2496
+ # Configuration can be applied globally to all clients, or to a single client
2497
+ # on construction.
2498
+ #
2499
+ # @example
2500
+ #
2501
+ # # Modify the global config, setting the timeout for
2502
+ # # create_recognizer to 20 seconds,
2503
+ # # and all remaining timeouts to 10 seconds.
2504
+ # ::Google::Cloud::Speech::V2::Speech::Client.configure do |config|
2505
+ # config.timeout = 10.0
2506
+ # config.rpcs.create_recognizer.timeout = 20.0
2507
+ # end
2508
+ #
2509
+ # # Apply the above configuration only to a new client.
2510
+ # client = ::Google::Cloud::Speech::V2::Speech::Client.new do |config|
2511
+ # config.timeout = 10.0
2512
+ # config.rpcs.create_recognizer.timeout = 20.0
2513
+ # end
2514
+ #
2515
+ # @!attribute [rw] endpoint
2516
+ # The hostname or hostname:port of the service endpoint.
2517
+ # Defaults to `"speech.googleapis.com"`.
2518
+ # @return [::String]
2519
+ # @!attribute [rw] credentials
2520
+ # Credentials to send with calls. You may provide any of the following types:
2521
+ # * (`String`) The path to a service account key file in JSON format
2522
+ # * (`Hash`) A service account key as a Hash
2523
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
2524
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
2525
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
2526
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
2527
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
2528
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
2529
+ # * (`nil`) indicating no credentials
2530
+ # @return [::Object]
2531
+ # @!attribute [rw] scope
2532
+ # The OAuth scopes
2533
+ # @return [::Array<::String>]
2534
+ # @!attribute [rw] lib_name
2535
+ # The library name as recorded in instrumentation and logging
2536
+ # @return [::String]
2537
+ # @!attribute [rw] lib_version
2538
+ # The library version as recorded in instrumentation and logging
2539
+ # @return [::String]
2540
+ # @!attribute [rw] channel_args
2541
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
2542
+ # `GRPC::Core::Channel` object is provided as the credential.
2543
+ # @return [::Hash]
2544
+ # @!attribute [rw] interceptors
2545
+ # An array of interceptors that are run before calls are executed.
2546
+ # @return [::Array<::GRPC::ClientInterceptor>]
2547
+ # @!attribute [rw] timeout
2548
+ # The call timeout in seconds.
2549
+ # @return [::Numeric]
2550
+ # @!attribute [rw] metadata
2551
+ # Additional gRPC headers to be sent with the call.
2552
+ # @return [::Hash{::Symbol=>::String}]
2553
+ # @!attribute [rw] retry_policy
2554
+ # The retry policy. The value is a hash with the following keys:
2555
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
2556
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
2557
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
2558
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
2559
+ # trigger a retry.
2560
+ # @return [::Hash]
2561
+ # @!attribute [rw] quota_project
2562
+ # A separate project against which to charge quota.
2563
+ # @return [::String]
2564
+ #
2565
+ class Configuration
2566
+ extend ::Gapic::Config
2567
+
2568
+ config_attr :endpoint, "speech.googleapis.com", ::String
2569
+ config_attr :credentials, nil do |value|
2570
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
2571
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
2572
+ allowed.any? { |klass| klass === value }
2573
+ end
2574
+ config_attr :scope, nil, ::String, ::Array, nil
2575
+ config_attr :lib_name, nil, ::String, nil
2576
+ config_attr :lib_version, nil, ::String, nil
2577
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
2578
+ config_attr :interceptors, nil, ::Array, nil
2579
+ config_attr :timeout, nil, ::Numeric, nil
2580
+ config_attr :metadata, nil, ::Hash, nil
2581
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
2582
+ config_attr :quota_project, nil, ::String, nil
2583
+
2584
+ # @private
2585
+ def initialize parent_config = nil
2586
+ @parent_config = parent_config unless parent_config.nil?
2587
+
2588
+ yield self if block_given?
2589
+ end
2590
+
2591
+ ##
2592
+ # Configurations for individual RPCs
2593
+ # @return [Rpcs]
2594
+ #
2595
+ def rpcs
2596
+ @rpcs ||= begin
2597
+ parent_rpcs = nil
2598
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
2599
+ Rpcs.new parent_rpcs
2600
+ end
2601
+ end
2602
+
2603
+ ##
2604
+ # Configuration RPC class for the Speech API.
2605
+ #
2606
+ # Includes fields providing the configuration for each RPC in this service.
2607
+ # Each configuration object is of type `Gapic::Config::Method` and includes
2608
+ # the following configuration fields:
2609
+ #
2610
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
2611
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
2612
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
2613
+ # include the following keys:
2614
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
2615
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
2616
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
2617
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
2618
+ # trigger a retry.
2619
+ #
2620
+ class Rpcs
2621
+ ##
2622
+ # RPC-specific configuration for `create_recognizer`
2623
+ # @return [::Gapic::Config::Method]
2624
+ #
2625
+ attr_reader :create_recognizer
2626
+ ##
2627
+ # RPC-specific configuration for `list_recognizers`
2628
+ # @return [::Gapic::Config::Method]
2629
+ #
2630
+ attr_reader :list_recognizers
2631
+ ##
2632
+ # RPC-specific configuration for `get_recognizer`
2633
+ # @return [::Gapic::Config::Method]
2634
+ #
2635
+ attr_reader :get_recognizer
2636
+ ##
2637
+ # RPC-specific configuration for `update_recognizer`
2638
+ # @return [::Gapic::Config::Method]
2639
+ #
2640
+ attr_reader :update_recognizer
2641
+ ##
2642
+ # RPC-specific configuration for `delete_recognizer`
2643
+ # @return [::Gapic::Config::Method]
2644
+ #
2645
+ attr_reader :delete_recognizer
2646
+ ##
2647
+ # RPC-specific configuration for `undelete_recognizer`
2648
+ # @return [::Gapic::Config::Method]
2649
+ #
2650
+ attr_reader :undelete_recognizer
2651
+ ##
2652
+ # RPC-specific configuration for `recognize`
2653
+ # @return [::Gapic::Config::Method]
2654
+ #
2655
+ attr_reader :recognize
2656
+ ##
2657
+ # RPC-specific configuration for `streaming_recognize`
2658
+ # @return [::Gapic::Config::Method]
2659
+ #
2660
+ attr_reader :streaming_recognize
2661
+ ##
2662
+ # RPC-specific configuration for `batch_recognize`
2663
+ # @return [::Gapic::Config::Method]
2664
+ #
2665
+ attr_reader :batch_recognize
2666
+ ##
2667
+ # RPC-specific configuration for `get_config`
2668
+ # @return [::Gapic::Config::Method]
2669
+ #
2670
+ attr_reader :get_config
2671
+ ##
2672
+ # RPC-specific configuration for `update_config`
2673
+ # @return [::Gapic::Config::Method]
2674
+ #
2675
+ attr_reader :update_config
2676
+ ##
2677
+ # RPC-specific configuration for `create_custom_class`
2678
+ # @return [::Gapic::Config::Method]
2679
+ #
2680
+ attr_reader :create_custom_class
2681
+ ##
2682
+ # RPC-specific configuration for `list_custom_classes`
2683
+ # @return [::Gapic::Config::Method]
2684
+ #
2685
+ attr_reader :list_custom_classes
2686
+ ##
2687
+ # RPC-specific configuration for `get_custom_class`
2688
+ # @return [::Gapic::Config::Method]
2689
+ #
2690
+ attr_reader :get_custom_class
2691
+ ##
2692
+ # RPC-specific configuration for `update_custom_class`
2693
+ # @return [::Gapic::Config::Method]
2694
+ #
2695
+ attr_reader :update_custom_class
2696
+ ##
2697
+ # RPC-specific configuration for `delete_custom_class`
2698
+ # @return [::Gapic::Config::Method]
2699
+ #
2700
+ attr_reader :delete_custom_class
2701
+ ##
2702
+ # RPC-specific configuration for `undelete_custom_class`
2703
+ # @return [::Gapic::Config::Method]
2704
+ #
2705
+ attr_reader :undelete_custom_class
2706
+ ##
2707
+ # RPC-specific configuration for `create_phrase_set`
2708
+ # @return [::Gapic::Config::Method]
2709
+ #
2710
+ attr_reader :create_phrase_set
2711
+ ##
2712
+ # RPC-specific configuration for `list_phrase_sets`
2713
+ # @return [::Gapic::Config::Method]
2714
+ #
2715
+ attr_reader :list_phrase_sets
2716
+ ##
2717
+ # RPC-specific configuration for `get_phrase_set`
2718
+ # @return [::Gapic::Config::Method]
2719
+ #
2720
+ attr_reader :get_phrase_set
2721
+ ##
2722
+ # RPC-specific configuration for `update_phrase_set`
2723
+ # @return [::Gapic::Config::Method]
2724
+ #
2725
+ attr_reader :update_phrase_set
2726
+ ##
2727
+ # RPC-specific configuration for `delete_phrase_set`
2728
+ # @return [::Gapic::Config::Method]
2729
+ #
2730
+ attr_reader :delete_phrase_set
2731
+ ##
2732
+ # RPC-specific configuration for `undelete_phrase_set`
2733
+ # @return [::Gapic::Config::Method]
2734
+ #
2735
+ attr_reader :undelete_phrase_set
2736
+
2737
+ # @private
2738
+ def initialize parent_rpcs = nil
2739
+ create_recognizer_config = parent_rpcs.create_recognizer if parent_rpcs.respond_to? :create_recognizer
2740
+ @create_recognizer = ::Gapic::Config::Method.new create_recognizer_config
2741
+ list_recognizers_config = parent_rpcs.list_recognizers if parent_rpcs.respond_to? :list_recognizers
2742
+ @list_recognizers = ::Gapic::Config::Method.new list_recognizers_config
2743
+ get_recognizer_config = parent_rpcs.get_recognizer if parent_rpcs.respond_to? :get_recognizer
2744
+ @get_recognizer = ::Gapic::Config::Method.new get_recognizer_config
2745
+ update_recognizer_config = parent_rpcs.update_recognizer if parent_rpcs.respond_to? :update_recognizer
2746
+ @update_recognizer = ::Gapic::Config::Method.new update_recognizer_config
2747
+ delete_recognizer_config = parent_rpcs.delete_recognizer if parent_rpcs.respond_to? :delete_recognizer
2748
+ @delete_recognizer = ::Gapic::Config::Method.new delete_recognizer_config
2749
+ undelete_recognizer_config = parent_rpcs.undelete_recognizer if parent_rpcs.respond_to? :undelete_recognizer
2750
+ @undelete_recognizer = ::Gapic::Config::Method.new undelete_recognizer_config
2751
+ recognize_config = parent_rpcs.recognize if parent_rpcs.respond_to? :recognize
2752
+ @recognize = ::Gapic::Config::Method.new recognize_config
2753
+ streaming_recognize_config = parent_rpcs.streaming_recognize if parent_rpcs.respond_to? :streaming_recognize
2754
+ @streaming_recognize = ::Gapic::Config::Method.new streaming_recognize_config
2755
+ batch_recognize_config = parent_rpcs.batch_recognize if parent_rpcs.respond_to? :batch_recognize
2756
+ @batch_recognize = ::Gapic::Config::Method.new batch_recognize_config
2757
+ get_config_config = parent_rpcs.get_config if parent_rpcs.respond_to? :get_config
2758
+ @get_config = ::Gapic::Config::Method.new get_config_config
2759
+ update_config_config = parent_rpcs.update_config if parent_rpcs.respond_to? :update_config
2760
+ @update_config = ::Gapic::Config::Method.new update_config_config
2761
+ create_custom_class_config = parent_rpcs.create_custom_class if parent_rpcs.respond_to? :create_custom_class
2762
+ @create_custom_class = ::Gapic::Config::Method.new create_custom_class_config
2763
+ list_custom_classes_config = parent_rpcs.list_custom_classes if parent_rpcs.respond_to? :list_custom_classes
2764
+ @list_custom_classes = ::Gapic::Config::Method.new list_custom_classes_config
2765
+ get_custom_class_config = parent_rpcs.get_custom_class if parent_rpcs.respond_to? :get_custom_class
2766
+ @get_custom_class = ::Gapic::Config::Method.new get_custom_class_config
2767
+ update_custom_class_config = parent_rpcs.update_custom_class if parent_rpcs.respond_to? :update_custom_class
2768
+ @update_custom_class = ::Gapic::Config::Method.new update_custom_class_config
2769
+ delete_custom_class_config = parent_rpcs.delete_custom_class if parent_rpcs.respond_to? :delete_custom_class
2770
+ @delete_custom_class = ::Gapic::Config::Method.new delete_custom_class_config
2771
+ undelete_custom_class_config = parent_rpcs.undelete_custom_class if parent_rpcs.respond_to? :undelete_custom_class
2772
+ @undelete_custom_class = ::Gapic::Config::Method.new undelete_custom_class_config
2773
+ create_phrase_set_config = parent_rpcs.create_phrase_set if parent_rpcs.respond_to? :create_phrase_set
2774
+ @create_phrase_set = ::Gapic::Config::Method.new create_phrase_set_config
2775
+ list_phrase_sets_config = parent_rpcs.list_phrase_sets if parent_rpcs.respond_to? :list_phrase_sets
2776
+ @list_phrase_sets = ::Gapic::Config::Method.new list_phrase_sets_config
2777
+ get_phrase_set_config = parent_rpcs.get_phrase_set if parent_rpcs.respond_to? :get_phrase_set
2778
+ @get_phrase_set = ::Gapic::Config::Method.new get_phrase_set_config
2779
+ update_phrase_set_config = parent_rpcs.update_phrase_set if parent_rpcs.respond_to? :update_phrase_set
2780
+ @update_phrase_set = ::Gapic::Config::Method.new update_phrase_set_config
2781
+ delete_phrase_set_config = parent_rpcs.delete_phrase_set if parent_rpcs.respond_to? :delete_phrase_set
2782
+ @delete_phrase_set = ::Gapic::Config::Method.new delete_phrase_set_config
2783
+ undelete_phrase_set_config = parent_rpcs.undelete_phrase_set if parent_rpcs.respond_to? :undelete_phrase_set
2784
+ @undelete_phrase_set = ::Gapic::Config::Method.new undelete_phrase_set_config
2785
+
2786
+ yield self if block_given?
2787
+ end
2788
+ end
2789
+ end
2790
+ end
2791
+ end
2792
+ end
2793
+ end
2794
+ end
2795
+ end