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