google-cloud-speech-v1 0.7.3 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1347 @@
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/v1/cloud_speech_adaptation_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Speech
25
+ module V1
26
+ module Adaptation
27
+ ##
28
+ # Client for the Adaptation service.
29
+ #
30
+ # Service that implements Google Cloud Speech Adaptation API.
31
+ #
32
+ class Client
33
+ include Paths
34
+
35
+ # @private
36
+ attr_reader :adaptation_stub
37
+
38
+ ##
39
+ # Configure the Adaptation Client class.
40
+ #
41
+ # See {::Google::Cloud::Speech::V1::Adaptation::Client::Configuration}
42
+ # for a description of the configuration fields.
43
+ #
44
+ # @example
45
+ #
46
+ # # Modify the configuration for all Adaptation clients
47
+ # ::Google::Cloud::Speech::V1::Adaptation::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", "V1"]
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
68
+ end
69
+ yield @configure if block_given?
70
+ @configure
71
+ end
72
+
73
+ ##
74
+ # Configure the Adaptation Client instance.
75
+ #
76
+ # The configuration is set to the derived mode, meaning that values can be changed,
77
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
78
+ # should be made on {Client.configure}.
79
+ #
80
+ # See {::Google::Cloud::Speech::V1::Adaptation::Client::Configuration}
81
+ # for a description of the configuration fields.
82
+ #
83
+ # @yield [config] Configure the Client client.
84
+ # @yieldparam config [Client::Configuration]
85
+ #
86
+ # @return [Client::Configuration]
87
+ #
88
+ def configure
89
+ yield @config if block_given?
90
+ @config
91
+ end
92
+
93
+ ##
94
+ # Create a new Adaptation client object.
95
+ #
96
+ # @example
97
+ #
98
+ # # Create a client using the default configuration
99
+ # client = ::Google::Cloud::Speech::V1::Adaptation::Client.new
100
+ #
101
+ # # Create a client using a custom configuration
102
+ # client = ::Google::Cloud::Speech::V1::Adaptation::Client.new do |config|
103
+ # config.timeout = 10.0
104
+ # end
105
+ #
106
+ # @yield [config] Configure the Adaptation client.
107
+ # @yieldparam config [Client::Configuration]
108
+ #
109
+ def initialize
110
+ # These require statements are intentionally placed here to initialize
111
+ # the gRPC module only when it's required.
112
+ # See https://github.com/googleapis/toolkit/issues/446
113
+ require "gapic/grpc"
114
+ require "google/cloud/speech/v1/cloud_speech_adaptation_services_pb"
115
+
116
+ # Create the configuration object
117
+ @config = Configuration.new Client.configure
118
+
119
+ # Yield the configuration if needed
120
+ yield @config if block_given?
121
+
122
+ # Create credentials
123
+ credentials = @config.credentials
124
+ # Use self-signed JWT if the endpoint is unchanged from default,
125
+ # but only if the default endpoint does not have a region prefix.
126
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
127
+ !@config.endpoint.split(".").first.include?("-")
128
+ credentials ||= Credentials.default scope: @config.scope,
129
+ enable_self_signed_jwt: enable_self_signed_jwt
130
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
131
+ credentials = Credentials.new credentials, scope: @config.scope
132
+ end
133
+ @quota_project_id = @config.quota_project
134
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
135
+
136
+ @adaptation_stub = ::Gapic::ServiceStub.new(
137
+ ::Google::Cloud::Speech::V1::Adaptation::Stub,
138
+ credentials: credentials,
139
+ endpoint: @config.endpoint,
140
+ channel_args: @config.channel_args,
141
+ interceptors: @config.interceptors
142
+ )
143
+ end
144
+
145
+ # Service calls
146
+
147
+ ##
148
+ # Create a set of phrase hints. Each item in the set can be a single word or
149
+ # a multi-word phrase. The items in the PhraseSet are favored by the
150
+ # recognition model when you send a call that includes the PhraseSet.
151
+ #
152
+ # @overload create_phrase_set(request, options = nil)
153
+ # Pass arguments to `create_phrase_set` via a request object, either of type
154
+ # {::Google::Cloud::Speech::V1::CreatePhraseSetRequest} or an equivalent Hash.
155
+ #
156
+ # @param request [::Google::Cloud::Speech::V1::CreatePhraseSetRequest, ::Hash]
157
+ # A request object representing the call parameters. Required. To specify no
158
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
159
+ # @param options [::Gapic::CallOptions, ::Hash]
160
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
161
+ #
162
+ # @overload create_phrase_set(parent: nil, phrase_set_id: nil, phrase_set: nil)
163
+ # Pass arguments to `create_phrase_set` via keyword arguments. Note that at
164
+ # least one keyword argument is required. To specify no parameters, or to keep all
165
+ # the default parameter values, pass an empty Hash as a request object (see above).
166
+ #
167
+ # @param parent [::String]
168
+ # Required. The parent resource where this phrase set will be created. Format:
169
+ #
170
+ # `projects/{project}/locations/{location}/phraseSets`
171
+ #
172
+ # Speech-to-Text supports three locations: `global`, `us` (US North America),
173
+ # and `eu` (Europe). If you are calling the `speech.googleapis.com`
174
+ # endpoint, use the `global` location. To specify a region, use a
175
+ # [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints)
176
+ # with matching `us` or `eu` location value.
177
+ # @param phrase_set_id [::String]
178
+ # Required. The ID to use for the phrase set, which will become the final
179
+ # component of the phrase set's resource name.
180
+ #
181
+ # This value should restrict to letters, numbers, and hyphens, with the first
182
+ # character a letter, the last a letter or a number, and be 4-63 characters.
183
+ # @param phrase_set [::Google::Cloud::Speech::V1::PhraseSet, ::Hash]
184
+ # Required. The phrase set to create.
185
+ #
186
+ # @yield [response, operation] Access the result along with the RPC operation
187
+ # @yieldparam response [::Google::Cloud::Speech::V1::PhraseSet]
188
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
189
+ #
190
+ # @return [::Google::Cloud::Speech::V1::PhraseSet]
191
+ #
192
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
193
+ #
194
+ # @example Basic example
195
+ # require "google/cloud/speech/v1"
196
+ #
197
+ # # Create a client object. The client can be reused for multiple calls.
198
+ # client = Google::Cloud::Speech::V1::Adaptation::Client.new
199
+ #
200
+ # # Create a request. To set request fields, pass in keyword arguments.
201
+ # request = Google::Cloud::Speech::V1::CreatePhraseSetRequest.new
202
+ #
203
+ # # Call the create_phrase_set method.
204
+ # result = client.create_phrase_set request
205
+ #
206
+ # # The returned object is of type Google::Cloud::Speech::V1::PhraseSet.
207
+ # p result
208
+ #
209
+ def create_phrase_set request, options = nil
210
+ raise ::ArgumentError, "request must be provided" if request.nil?
211
+
212
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V1::CreatePhraseSetRequest
213
+
214
+ # Converts hash and nil to an options object
215
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
216
+
217
+ # Customize the options with defaults
218
+ metadata = @config.rpcs.create_phrase_set.metadata.to_h
219
+
220
+ # Set x-goog-api-client and x-goog-user-project headers
221
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
222
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
223
+ gapic_version: ::Google::Cloud::Speech::V1::VERSION
224
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
225
+
226
+ header_params = {}
227
+ if request.parent
228
+ header_params["parent"] = request.parent
229
+ end
230
+
231
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
232
+ metadata[:"x-goog-request-params"] ||= request_params_header
233
+
234
+ options.apply_defaults timeout: @config.rpcs.create_phrase_set.timeout,
235
+ metadata: metadata,
236
+ retry_policy: @config.rpcs.create_phrase_set.retry_policy
237
+
238
+ options.apply_defaults timeout: @config.timeout,
239
+ metadata: @config.metadata,
240
+ retry_policy: @config.retry_policy
241
+
242
+ @adaptation_stub.call_rpc :create_phrase_set, request, options: options do |response, operation|
243
+ yield response, operation if block_given?
244
+ return response
245
+ end
246
+ rescue ::GRPC::BadStatus => e
247
+ raise ::Google::Cloud::Error.from_error(e)
248
+ end
249
+
250
+ ##
251
+ # Get a phrase set.
252
+ #
253
+ # @overload get_phrase_set(request, options = nil)
254
+ # Pass arguments to `get_phrase_set` via a request object, either of type
255
+ # {::Google::Cloud::Speech::V1::GetPhraseSetRequest} or an equivalent Hash.
256
+ #
257
+ # @param request [::Google::Cloud::Speech::V1::GetPhraseSetRequest, ::Hash]
258
+ # A request object representing the call parameters. Required. To specify no
259
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
260
+ # @param options [::Gapic::CallOptions, ::Hash]
261
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
262
+ #
263
+ # @overload get_phrase_set(name: nil)
264
+ # Pass arguments to `get_phrase_set` via keyword arguments. Note that at
265
+ # least one keyword argument is required. To specify no parameters, or to keep all
266
+ # the default parameter values, pass an empty Hash as a request object (see above).
267
+ #
268
+ # @param name [::String]
269
+ # Required. The name of the phrase set to retrieve. Format:
270
+ #
271
+ # `projects/{project}/locations/{location}/phraseSets/{phrase_set}`
272
+ #
273
+ # Speech-to-Text supports three locations: `global`, `us` (US North America),
274
+ # and `eu` (Europe). If you are calling the `speech.googleapis.com`
275
+ # endpoint, use the `global` location. To specify a region, use a
276
+ # [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints)
277
+ # with matching `us` or `eu` location value.
278
+ #
279
+ # @yield [response, operation] Access the result along with the RPC operation
280
+ # @yieldparam response [::Google::Cloud::Speech::V1::PhraseSet]
281
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
282
+ #
283
+ # @return [::Google::Cloud::Speech::V1::PhraseSet]
284
+ #
285
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
286
+ #
287
+ # @example Basic example
288
+ # require "google/cloud/speech/v1"
289
+ #
290
+ # # Create a client object. The client can be reused for multiple calls.
291
+ # client = Google::Cloud::Speech::V1::Adaptation::Client.new
292
+ #
293
+ # # Create a request. To set request fields, pass in keyword arguments.
294
+ # request = Google::Cloud::Speech::V1::GetPhraseSetRequest.new
295
+ #
296
+ # # Call the get_phrase_set method.
297
+ # result = client.get_phrase_set request
298
+ #
299
+ # # The returned object is of type Google::Cloud::Speech::V1::PhraseSet.
300
+ # p result
301
+ #
302
+ def get_phrase_set request, options = nil
303
+ raise ::ArgumentError, "request must be provided" if request.nil?
304
+
305
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V1::GetPhraseSetRequest
306
+
307
+ # Converts hash and nil to an options object
308
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
309
+
310
+ # Customize the options with defaults
311
+ metadata = @config.rpcs.get_phrase_set.metadata.to_h
312
+
313
+ # Set x-goog-api-client and x-goog-user-project headers
314
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
315
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
316
+ gapic_version: ::Google::Cloud::Speech::V1::VERSION
317
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
318
+
319
+ header_params = {}
320
+ if request.name
321
+ header_params["name"] = request.name
322
+ end
323
+
324
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
325
+ metadata[:"x-goog-request-params"] ||= request_params_header
326
+
327
+ options.apply_defaults timeout: @config.rpcs.get_phrase_set.timeout,
328
+ metadata: metadata,
329
+ retry_policy: @config.rpcs.get_phrase_set.retry_policy
330
+
331
+ options.apply_defaults timeout: @config.timeout,
332
+ metadata: @config.metadata,
333
+ retry_policy: @config.retry_policy
334
+
335
+ @adaptation_stub.call_rpc :get_phrase_set, request, options: options do |response, operation|
336
+ yield response, operation if block_given?
337
+ return response
338
+ end
339
+ rescue ::GRPC::BadStatus => e
340
+ raise ::Google::Cloud::Error.from_error(e)
341
+ end
342
+
343
+ ##
344
+ # List phrase sets.
345
+ #
346
+ # @overload list_phrase_set(request, options = nil)
347
+ # Pass arguments to `list_phrase_set` via a request object, either of type
348
+ # {::Google::Cloud::Speech::V1::ListPhraseSetRequest} or an equivalent Hash.
349
+ #
350
+ # @param request [::Google::Cloud::Speech::V1::ListPhraseSetRequest, ::Hash]
351
+ # A request object representing the call parameters. Required. To specify no
352
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
353
+ # @param options [::Gapic::CallOptions, ::Hash]
354
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
355
+ #
356
+ # @overload list_phrase_set(parent: nil, page_size: nil, page_token: nil)
357
+ # Pass arguments to `list_phrase_set` via keyword arguments. Note that at
358
+ # least one keyword argument is required. To specify no parameters, or to keep all
359
+ # the default parameter values, pass an empty Hash as a request object (see above).
360
+ #
361
+ # @param parent [::String]
362
+ # Required. The parent, which owns this collection of phrase set. Format:
363
+ #
364
+ # `projects/{project}/locations/{location}`
365
+ #
366
+ # Speech-to-Text supports three locations: `global`, `us` (US North America),
367
+ # and `eu` (Europe). If you are calling the `speech.googleapis.com`
368
+ # endpoint, use the `global` location. To specify a region, use a
369
+ # [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints)
370
+ # with matching `us` or `eu` location value.
371
+ # @param page_size [::Integer]
372
+ # The maximum number of phrase sets to return. The service may return
373
+ # fewer than this value. If unspecified, at most 50 phrase sets will be
374
+ # returned. The maximum value is 1000; values above 1000 will be coerced to
375
+ # 1000.
376
+ # @param page_token [::String]
377
+ # A page token, received from a previous `ListPhraseSet` call.
378
+ # Provide this to retrieve the subsequent page.
379
+ #
380
+ # When paginating, all other parameters provided to `ListPhraseSet` must
381
+ # match the call that provided the page token.
382
+ #
383
+ # @yield [response, operation] Access the result along with the RPC operation
384
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Speech::V1::PhraseSet>]
385
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
386
+ #
387
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Speech::V1::PhraseSet>]
388
+ #
389
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
390
+ #
391
+ # @example Basic example
392
+ # require "google/cloud/speech/v1"
393
+ #
394
+ # # Create a client object. The client can be reused for multiple calls.
395
+ # client = Google::Cloud::Speech::V1::Adaptation::Client.new
396
+ #
397
+ # # Create a request. To set request fields, pass in keyword arguments.
398
+ # request = Google::Cloud::Speech::V1::ListPhraseSetRequest.new
399
+ #
400
+ # # Call the list_phrase_set method.
401
+ # result = client.list_phrase_set request
402
+ #
403
+ # # The returned object is of type Gapic::PagedEnumerable. You can
404
+ # # iterate over all elements by calling #each, and the enumerable
405
+ # # will lazily make API calls to fetch subsequent pages. Other
406
+ # # methods are also available for managing paging directly.
407
+ # result.each do |response|
408
+ # # Each element is of type ::Google::Cloud::Speech::V1::PhraseSet.
409
+ # p response
410
+ # end
411
+ #
412
+ def list_phrase_set request, options = nil
413
+ raise ::ArgumentError, "request must be provided" if request.nil?
414
+
415
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V1::ListPhraseSetRequest
416
+
417
+ # Converts hash and nil to an options object
418
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
419
+
420
+ # Customize the options with defaults
421
+ metadata = @config.rpcs.list_phrase_set.metadata.to_h
422
+
423
+ # Set x-goog-api-client and x-goog-user-project headers
424
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
425
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
426
+ gapic_version: ::Google::Cloud::Speech::V1::VERSION
427
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
428
+
429
+ header_params = {}
430
+ if request.parent
431
+ header_params["parent"] = request.parent
432
+ end
433
+
434
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
435
+ metadata[:"x-goog-request-params"] ||= request_params_header
436
+
437
+ options.apply_defaults timeout: @config.rpcs.list_phrase_set.timeout,
438
+ metadata: metadata,
439
+ retry_policy: @config.rpcs.list_phrase_set.retry_policy
440
+
441
+ options.apply_defaults timeout: @config.timeout,
442
+ metadata: @config.metadata,
443
+ retry_policy: @config.retry_policy
444
+
445
+ @adaptation_stub.call_rpc :list_phrase_set, request, options: options do |response, operation|
446
+ response = ::Gapic::PagedEnumerable.new @adaptation_stub, :list_phrase_set, request, response, operation, options
447
+ yield response, operation if block_given?
448
+ return response
449
+ end
450
+ rescue ::GRPC::BadStatus => e
451
+ raise ::Google::Cloud::Error.from_error(e)
452
+ end
453
+
454
+ ##
455
+ # Update a phrase set.
456
+ #
457
+ # @overload update_phrase_set(request, options = nil)
458
+ # Pass arguments to `update_phrase_set` via a request object, either of type
459
+ # {::Google::Cloud::Speech::V1::UpdatePhraseSetRequest} or an equivalent Hash.
460
+ #
461
+ # @param request [::Google::Cloud::Speech::V1::UpdatePhraseSetRequest, ::Hash]
462
+ # A request object representing the call parameters. Required. To specify no
463
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
464
+ # @param options [::Gapic::CallOptions, ::Hash]
465
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
466
+ #
467
+ # @overload update_phrase_set(phrase_set: nil, update_mask: nil)
468
+ # Pass arguments to `update_phrase_set` via keyword arguments. Note that at
469
+ # least one keyword argument is required. To specify no parameters, or to keep all
470
+ # the default parameter values, pass an empty Hash as a request object (see above).
471
+ #
472
+ # @param phrase_set [::Google::Cloud::Speech::V1::PhraseSet, ::Hash]
473
+ # Required. The phrase set to update.
474
+ #
475
+ # The phrase set's `name` field is used to identify the set to be
476
+ # updated. Format:
477
+ #
478
+ # `projects/{project}/locations/{location}/phraseSets/{phrase_set}`
479
+ #
480
+ # Speech-to-Text supports three locations: `global`, `us` (US North America),
481
+ # and `eu` (Europe). If you are calling the `speech.googleapis.com`
482
+ # endpoint, use the `global` location. To specify a region, use a
483
+ # [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints)
484
+ # with matching `us` or `eu` location value.
485
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
486
+ # The list of fields to be updated.
487
+ #
488
+ # @yield [response, operation] Access the result along with the RPC operation
489
+ # @yieldparam response [::Google::Cloud::Speech::V1::PhraseSet]
490
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
491
+ #
492
+ # @return [::Google::Cloud::Speech::V1::PhraseSet]
493
+ #
494
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
495
+ #
496
+ # @example Basic example
497
+ # require "google/cloud/speech/v1"
498
+ #
499
+ # # Create a client object. The client can be reused for multiple calls.
500
+ # client = Google::Cloud::Speech::V1::Adaptation::Client.new
501
+ #
502
+ # # Create a request. To set request fields, pass in keyword arguments.
503
+ # request = Google::Cloud::Speech::V1::UpdatePhraseSetRequest.new
504
+ #
505
+ # # Call the update_phrase_set method.
506
+ # result = client.update_phrase_set request
507
+ #
508
+ # # The returned object is of type Google::Cloud::Speech::V1::PhraseSet.
509
+ # p result
510
+ #
511
+ def update_phrase_set request, options = nil
512
+ raise ::ArgumentError, "request must be provided" if request.nil?
513
+
514
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V1::UpdatePhraseSetRequest
515
+
516
+ # Converts hash and nil to an options object
517
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
518
+
519
+ # Customize the options with defaults
520
+ metadata = @config.rpcs.update_phrase_set.metadata.to_h
521
+
522
+ # Set x-goog-api-client and x-goog-user-project headers
523
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
524
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
525
+ gapic_version: ::Google::Cloud::Speech::V1::VERSION
526
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
527
+
528
+ header_params = {}
529
+ if request.phrase_set&.name
530
+ header_params["phrase_set.name"] = request.phrase_set.name
531
+ end
532
+
533
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
534
+ metadata[:"x-goog-request-params"] ||= request_params_header
535
+
536
+ options.apply_defaults timeout: @config.rpcs.update_phrase_set.timeout,
537
+ metadata: metadata,
538
+ retry_policy: @config.rpcs.update_phrase_set.retry_policy
539
+
540
+ options.apply_defaults timeout: @config.timeout,
541
+ metadata: @config.metadata,
542
+ retry_policy: @config.retry_policy
543
+
544
+ @adaptation_stub.call_rpc :update_phrase_set, request, options: options do |response, operation|
545
+ yield response, operation if block_given?
546
+ return response
547
+ end
548
+ rescue ::GRPC::BadStatus => e
549
+ raise ::Google::Cloud::Error.from_error(e)
550
+ end
551
+
552
+ ##
553
+ # Delete a phrase set.
554
+ #
555
+ # @overload delete_phrase_set(request, options = nil)
556
+ # Pass arguments to `delete_phrase_set` via a request object, either of type
557
+ # {::Google::Cloud::Speech::V1::DeletePhraseSetRequest} or an equivalent Hash.
558
+ #
559
+ # @param request [::Google::Cloud::Speech::V1::DeletePhraseSetRequest, ::Hash]
560
+ # A request object representing the call parameters. Required. To specify no
561
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
562
+ # @param options [::Gapic::CallOptions, ::Hash]
563
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
564
+ #
565
+ # @overload delete_phrase_set(name: nil)
566
+ # Pass arguments to `delete_phrase_set` via keyword arguments. Note that at
567
+ # least one keyword argument is required. To specify no parameters, or to keep all
568
+ # the default parameter values, pass an empty Hash as a request object (see above).
569
+ #
570
+ # @param name [::String]
571
+ # Required. The name of the phrase set to delete. Format:
572
+ #
573
+ # `projects/{project}/locations/{location}/phraseSets/{phrase_set}`
574
+ #
575
+ # @yield [response, operation] Access the result along with the RPC operation
576
+ # @yieldparam response [::Google::Protobuf::Empty]
577
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
578
+ #
579
+ # @return [::Google::Protobuf::Empty]
580
+ #
581
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
582
+ #
583
+ # @example Basic example
584
+ # require "google/cloud/speech/v1"
585
+ #
586
+ # # Create a client object. The client can be reused for multiple calls.
587
+ # client = Google::Cloud::Speech::V1::Adaptation::Client.new
588
+ #
589
+ # # Create a request. To set request fields, pass in keyword arguments.
590
+ # request = Google::Cloud::Speech::V1::DeletePhraseSetRequest.new
591
+ #
592
+ # # Call the delete_phrase_set method.
593
+ # result = client.delete_phrase_set request
594
+ #
595
+ # # The returned object is of type Google::Protobuf::Empty.
596
+ # p result
597
+ #
598
+ def delete_phrase_set request, options = nil
599
+ raise ::ArgumentError, "request must be provided" if request.nil?
600
+
601
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V1::DeletePhraseSetRequest
602
+
603
+ # Converts hash and nil to an options object
604
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
605
+
606
+ # Customize the options with defaults
607
+ metadata = @config.rpcs.delete_phrase_set.metadata.to_h
608
+
609
+ # Set x-goog-api-client and x-goog-user-project headers
610
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
611
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
612
+ gapic_version: ::Google::Cloud::Speech::V1::VERSION
613
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
614
+
615
+ header_params = {}
616
+ if request.name
617
+ header_params["name"] = request.name
618
+ end
619
+
620
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
621
+ metadata[:"x-goog-request-params"] ||= request_params_header
622
+
623
+ options.apply_defaults timeout: @config.rpcs.delete_phrase_set.timeout,
624
+ metadata: metadata,
625
+ retry_policy: @config.rpcs.delete_phrase_set.retry_policy
626
+
627
+ options.apply_defaults timeout: @config.timeout,
628
+ metadata: @config.metadata,
629
+ retry_policy: @config.retry_policy
630
+
631
+ @adaptation_stub.call_rpc :delete_phrase_set, request, options: options do |response, operation|
632
+ yield response, operation if block_given?
633
+ return response
634
+ end
635
+ rescue ::GRPC::BadStatus => e
636
+ raise ::Google::Cloud::Error.from_error(e)
637
+ end
638
+
639
+ ##
640
+ # Create a custom class.
641
+ #
642
+ # @overload create_custom_class(request, options = nil)
643
+ # Pass arguments to `create_custom_class` via a request object, either of type
644
+ # {::Google::Cloud::Speech::V1::CreateCustomClassRequest} or an equivalent Hash.
645
+ #
646
+ # @param request [::Google::Cloud::Speech::V1::CreateCustomClassRequest, ::Hash]
647
+ # A request object representing the call parameters. Required. To specify no
648
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
649
+ # @param options [::Gapic::CallOptions, ::Hash]
650
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
651
+ #
652
+ # @overload create_custom_class(parent: nil, custom_class_id: nil, custom_class: nil)
653
+ # Pass arguments to `create_custom_class` via keyword arguments. Note that at
654
+ # least one keyword argument is required. To specify no parameters, or to keep all
655
+ # the default parameter values, pass an empty Hash as a request object (see above).
656
+ #
657
+ # @param parent [::String]
658
+ # Required. The parent resource where this custom class will be created. Format:
659
+ #
660
+ # `projects/{project}/locations/{location}/customClasses`
661
+ #
662
+ # Speech-to-Text supports three locations: `global`, `us` (US North America),
663
+ # and `eu` (Europe). If you are calling the `speech.googleapis.com`
664
+ # endpoint, use the `global` location. To specify a region, use a
665
+ # [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints)
666
+ # with matching `us` or `eu` location value.
667
+ # @param custom_class_id [::String]
668
+ # Required. The ID to use for the custom class, which will become the final
669
+ # component of the custom class' resource name.
670
+ #
671
+ # This value should restrict to letters, numbers, and hyphens, with the first
672
+ # character a letter, the last a letter or a number, and be 4-63 characters.
673
+ # @param custom_class [::Google::Cloud::Speech::V1::CustomClass, ::Hash]
674
+ # Required. The custom class to create.
675
+ #
676
+ # @yield [response, operation] Access the result along with the RPC operation
677
+ # @yieldparam response [::Google::Cloud::Speech::V1::CustomClass]
678
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
679
+ #
680
+ # @return [::Google::Cloud::Speech::V1::CustomClass]
681
+ #
682
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
683
+ #
684
+ # @example Basic example
685
+ # require "google/cloud/speech/v1"
686
+ #
687
+ # # Create a client object. The client can be reused for multiple calls.
688
+ # client = Google::Cloud::Speech::V1::Adaptation::Client.new
689
+ #
690
+ # # Create a request. To set request fields, pass in keyword arguments.
691
+ # request = Google::Cloud::Speech::V1::CreateCustomClassRequest.new
692
+ #
693
+ # # Call the create_custom_class method.
694
+ # result = client.create_custom_class request
695
+ #
696
+ # # The returned object is of type Google::Cloud::Speech::V1::CustomClass.
697
+ # p result
698
+ #
699
+ def create_custom_class request, options = nil
700
+ raise ::ArgumentError, "request must be provided" if request.nil?
701
+
702
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V1::CreateCustomClassRequest
703
+
704
+ # Converts hash and nil to an options object
705
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
706
+
707
+ # Customize the options with defaults
708
+ metadata = @config.rpcs.create_custom_class.metadata.to_h
709
+
710
+ # Set x-goog-api-client and x-goog-user-project headers
711
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
712
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
713
+ gapic_version: ::Google::Cloud::Speech::V1::VERSION
714
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
715
+
716
+ header_params = {}
717
+ if request.parent
718
+ header_params["parent"] = request.parent
719
+ end
720
+
721
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
722
+ metadata[:"x-goog-request-params"] ||= request_params_header
723
+
724
+ options.apply_defaults timeout: @config.rpcs.create_custom_class.timeout,
725
+ metadata: metadata,
726
+ retry_policy: @config.rpcs.create_custom_class.retry_policy
727
+
728
+ options.apply_defaults timeout: @config.timeout,
729
+ metadata: @config.metadata,
730
+ retry_policy: @config.retry_policy
731
+
732
+ @adaptation_stub.call_rpc :create_custom_class, request, options: options do |response, operation|
733
+ yield response, operation if block_given?
734
+ return response
735
+ end
736
+ rescue ::GRPC::BadStatus => e
737
+ raise ::Google::Cloud::Error.from_error(e)
738
+ end
739
+
740
+ ##
741
+ # Get a custom class.
742
+ #
743
+ # @overload get_custom_class(request, options = nil)
744
+ # Pass arguments to `get_custom_class` via a request object, either of type
745
+ # {::Google::Cloud::Speech::V1::GetCustomClassRequest} or an equivalent Hash.
746
+ #
747
+ # @param request [::Google::Cloud::Speech::V1::GetCustomClassRequest, ::Hash]
748
+ # A request object representing the call parameters. Required. To specify no
749
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
750
+ # @param options [::Gapic::CallOptions, ::Hash]
751
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
752
+ #
753
+ # @overload get_custom_class(name: nil)
754
+ # Pass arguments to `get_custom_class` via keyword arguments. Note that at
755
+ # least one keyword argument is required. To specify no parameters, or to keep all
756
+ # the default parameter values, pass an empty Hash as a request object (see above).
757
+ #
758
+ # @param name [::String]
759
+ # Required. The name of the custom class to retrieve. Format:
760
+ #
761
+ # `projects/{project}/locations/{location}/customClasses/{custom_class}`
762
+ #
763
+ # @yield [response, operation] Access the result along with the RPC operation
764
+ # @yieldparam response [::Google::Cloud::Speech::V1::CustomClass]
765
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
766
+ #
767
+ # @return [::Google::Cloud::Speech::V1::CustomClass]
768
+ #
769
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
770
+ #
771
+ # @example Basic example
772
+ # require "google/cloud/speech/v1"
773
+ #
774
+ # # Create a client object. The client can be reused for multiple calls.
775
+ # client = Google::Cloud::Speech::V1::Adaptation::Client.new
776
+ #
777
+ # # Create a request. To set request fields, pass in keyword arguments.
778
+ # request = Google::Cloud::Speech::V1::GetCustomClassRequest.new
779
+ #
780
+ # # Call the get_custom_class method.
781
+ # result = client.get_custom_class request
782
+ #
783
+ # # The returned object is of type Google::Cloud::Speech::V1::CustomClass.
784
+ # p result
785
+ #
786
+ def get_custom_class request, options = nil
787
+ raise ::ArgumentError, "request must be provided" if request.nil?
788
+
789
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V1::GetCustomClassRequest
790
+
791
+ # Converts hash and nil to an options object
792
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
793
+
794
+ # Customize the options with defaults
795
+ metadata = @config.rpcs.get_custom_class.metadata.to_h
796
+
797
+ # Set x-goog-api-client and x-goog-user-project headers
798
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
799
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
800
+ gapic_version: ::Google::Cloud::Speech::V1::VERSION
801
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
802
+
803
+ header_params = {}
804
+ if request.name
805
+ header_params["name"] = request.name
806
+ end
807
+
808
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
809
+ metadata[:"x-goog-request-params"] ||= request_params_header
810
+
811
+ options.apply_defaults timeout: @config.rpcs.get_custom_class.timeout,
812
+ metadata: metadata,
813
+ retry_policy: @config.rpcs.get_custom_class.retry_policy
814
+
815
+ options.apply_defaults timeout: @config.timeout,
816
+ metadata: @config.metadata,
817
+ retry_policy: @config.retry_policy
818
+
819
+ @adaptation_stub.call_rpc :get_custom_class, request, options: options do |response, operation|
820
+ yield response, operation if block_given?
821
+ return response
822
+ end
823
+ rescue ::GRPC::BadStatus => e
824
+ raise ::Google::Cloud::Error.from_error(e)
825
+ end
826
+
827
+ ##
828
+ # List custom classes.
829
+ #
830
+ # @overload list_custom_classes(request, options = nil)
831
+ # Pass arguments to `list_custom_classes` via a request object, either of type
832
+ # {::Google::Cloud::Speech::V1::ListCustomClassesRequest} or an equivalent Hash.
833
+ #
834
+ # @param request [::Google::Cloud::Speech::V1::ListCustomClassesRequest, ::Hash]
835
+ # A request object representing the call parameters. Required. To specify no
836
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
837
+ # @param options [::Gapic::CallOptions, ::Hash]
838
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
839
+ #
840
+ # @overload list_custom_classes(parent: nil, page_size: nil, page_token: nil)
841
+ # Pass arguments to `list_custom_classes` via keyword arguments. Note that at
842
+ # least one keyword argument is required. To specify no parameters, or to keep all
843
+ # the default parameter values, pass an empty Hash as a request object (see above).
844
+ #
845
+ # @param parent [::String]
846
+ # Required. The parent, which owns this collection of custom classes. Format:
847
+ #
848
+ # `projects/{project}/locations/{location}/customClasses`
849
+ #
850
+ # Speech-to-Text supports three locations: `global`, `us` (US North America),
851
+ # and `eu` (Europe). If you are calling the `speech.googleapis.com`
852
+ # endpoint, use the `global` location. To specify a region, use a
853
+ # [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints)
854
+ # with matching `us` or `eu` location value.
855
+ # @param page_size [::Integer]
856
+ # The maximum number of custom classes to return. The service may return
857
+ # fewer than this value. If unspecified, at most 50 custom classes will be
858
+ # returned. The maximum value is 1000; values above 1000 will be coerced to
859
+ # 1000.
860
+ # @param page_token [::String]
861
+ # A page token, received from a previous `ListCustomClass` call.
862
+ # Provide this to retrieve the subsequent page.
863
+ #
864
+ # When paginating, all other parameters provided to `ListCustomClass` must
865
+ # match the call that provided the page token.
866
+ #
867
+ # @yield [response, operation] Access the result along with the RPC operation
868
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Speech::V1::CustomClass>]
869
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
870
+ #
871
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Speech::V1::CustomClass>]
872
+ #
873
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
874
+ #
875
+ # @example Basic example
876
+ # require "google/cloud/speech/v1"
877
+ #
878
+ # # Create a client object. The client can be reused for multiple calls.
879
+ # client = Google::Cloud::Speech::V1::Adaptation::Client.new
880
+ #
881
+ # # Create a request. To set request fields, pass in keyword arguments.
882
+ # request = Google::Cloud::Speech::V1::ListCustomClassesRequest.new
883
+ #
884
+ # # Call the list_custom_classes method.
885
+ # result = client.list_custom_classes request
886
+ #
887
+ # # The returned object is of type Gapic::PagedEnumerable. You can
888
+ # # iterate over all elements by calling #each, and the enumerable
889
+ # # will lazily make API calls to fetch subsequent pages. Other
890
+ # # methods are also available for managing paging directly.
891
+ # result.each do |response|
892
+ # # Each element is of type ::Google::Cloud::Speech::V1::CustomClass.
893
+ # p response
894
+ # end
895
+ #
896
+ def list_custom_classes request, options = nil
897
+ raise ::ArgumentError, "request must be provided" if request.nil?
898
+
899
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V1::ListCustomClassesRequest
900
+
901
+ # Converts hash and nil to an options object
902
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
903
+
904
+ # Customize the options with defaults
905
+ metadata = @config.rpcs.list_custom_classes.metadata.to_h
906
+
907
+ # Set x-goog-api-client and x-goog-user-project headers
908
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
909
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
910
+ gapic_version: ::Google::Cloud::Speech::V1::VERSION
911
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
912
+
913
+ header_params = {}
914
+ if request.parent
915
+ header_params["parent"] = request.parent
916
+ end
917
+
918
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
919
+ metadata[:"x-goog-request-params"] ||= request_params_header
920
+
921
+ options.apply_defaults timeout: @config.rpcs.list_custom_classes.timeout,
922
+ metadata: metadata,
923
+ retry_policy: @config.rpcs.list_custom_classes.retry_policy
924
+
925
+ options.apply_defaults timeout: @config.timeout,
926
+ metadata: @config.metadata,
927
+ retry_policy: @config.retry_policy
928
+
929
+ @adaptation_stub.call_rpc :list_custom_classes, request, options: options do |response, operation|
930
+ response = ::Gapic::PagedEnumerable.new @adaptation_stub, :list_custom_classes, request, response, operation, options
931
+ yield response, operation if block_given?
932
+ return response
933
+ end
934
+ rescue ::GRPC::BadStatus => e
935
+ raise ::Google::Cloud::Error.from_error(e)
936
+ end
937
+
938
+ ##
939
+ # Update a custom class.
940
+ #
941
+ # @overload update_custom_class(request, options = nil)
942
+ # Pass arguments to `update_custom_class` via a request object, either of type
943
+ # {::Google::Cloud::Speech::V1::UpdateCustomClassRequest} or an equivalent Hash.
944
+ #
945
+ # @param request [::Google::Cloud::Speech::V1::UpdateCustomClassRequest, ::Hash]
946
+ # A request object representing the call parameters. Required. To specify no
947
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
948
+ # @param options [::Gapic::CallOptions, ::Hash]
949
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
950
+ #
951
+ # @overload update_custom_class(custom_class: nil, update_mask: nil)
952
+ # Pass arguments to `update_custom_class` via keyword arguments. Note that at
953
+ # least one keyword argument is required. To specify no parameters, or to keep all
954
+ # the default parameter values, pass an empty Hash as a request object (see above).
955
+ #
956
+ # @param custom_class [::Google::Cloud::Speech::V1::CustomClass, ::Hash]
957
+ # Required. The custom class to update.
958
+ #
959
+ # The custom class's `name` field is used to identify the custom class to be
960
+ # updated. Format:
961
+ #
962
+ # `projects/{project}/locations/{location}/customClasses/{custom_class}`
963
+ #
964
+ # Speech-to-Text supports three locations: `global`, `us` (US North America),
965
+ # and `eu` (Europe). If you are calling the `speech.googleapis.com`
966
+ # endpoint, use the `global` location. To specify a region, use a
967
+ # [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints)
968
+ # with matching `us` or `eu` location value.
969
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
970
+ # The list of fields to be updated.
971
+ #
972
+ # @yield [response, operation] Access the result along with the RPC operation
973
+ # @yieldparam response [::Google::Cloud::Speech::V1::CustomClass]
974
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
975
+ #
976
+ # @return [::Google::Cloud::Speech::V1::CustomClass]
977
+ #
978
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
979
+ #
980
+ # @example Basic example
981
+ # require "google/cloud/speech/v1"
982
+ #
983
+ # # Create a client object. The client can be reused for multiple calls.
984
+ # client = Google::Cloud::Speech::V1::Adaptation::Client.new
985
+ #
986
+ # # Create a request. To set request fields, pass in keyword arguments.
987
+ # request = Google::Cloud::Speech::V1::UpdateCustomClassRequest.new
988
+ #
989
+ # # Call the update_custom_class method.
990
+ # result = client.update_custom_class request
991
+ #
992
+ # # The returned object is of type Google::Cloud::Speech::V1::CustomClass.
993
+ # p result
994
+ #
995
+ def update_custom_class request, options = nil
996
+ raise ::ArgumentError, "request must be provided" if request.nil?
997
+
998
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V1::UpdateCustomClassRequest
999
+
1000
+ # Converts hash and nil to an options object
1001
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1002
+
1003
+ # Customize the options with defaults
1004
+ metadata = @config.rpcs.update_custom_class.metadata.to_h
1005
+
1006
+ # Set x-goog-api-client and x-goog-user-project headers
1007
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1008
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1009
+ gapic_version: ::Google::Cloud::Speech::V1::VERSION
1010
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1011
+
1012
+ header_params = {}
1013
+ if request.custom_class&.name
1014
+ header_params["custom_class.name"] = request.custom_class.name
1015
+ end
1016
+
1017
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1018
+ metadata[:"x-goog-request-params"] ||= request_params_header
1019
+
1020
+ options.apply_defaults timeout: @config.rpcs.update_custom_class.timeout,
1021
+ metadata: metadata,
1022
+ retry_policy: @config.rpcs.update_custom_class.retry_policy
1023
+
1024
+ options.apply_defaults timeout: @config.timeout,
1025
+ metadata: @config.metadata,
1026
+ retry_policy: @config.retry_policy
1027
+
1028
+ @adaptation_stub.call_rpc :update_custom_class, request, options: options do |response, operation|
1029
+ yield response, operation if block_given?
1030
+ return response
1031
+ end
1032
+ rescue ::GRPC::BadStatus => e
1033
+ raise ::Google::Cloud::Error.from_error(e)
1034
+ end
1035
+
1036
+ ##
1037
+ # Delete a custom class.
1038
+ #
1039
+ # @overload delete_custom_class(request, options = nil)
1040
+ # Pass arguments to `delete_custom_class` via a request object, either of type
1041
+ # {::Google::Cloud::Speech::V1::DeleteCustomClassRequest} or an equivalent Hash.
1042
+ #
1043
+ # @param request [::Google::Cloud::Speech::V1::DeleteCustomClassRequest, ::Hash]
1044
+ # A request object representing the call parameters. Required. To specify no
1045
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1046
+ # @param options [::Gapic::CallOptions, ::Hash]
1047
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1048
+ #
1049
+ # @overload delete_custom_class(name: nil)
1050
+ # Pass arguments to `delete_custom_class` via keyword arguments. Note that at
1051
+ # least one keyword argument is required. To specify no parameters, or to keep all
1052
+ # the default parameter values, pass an empty Hash as a request object (see above).
1053
+ #
1054
+ # @param name [::String]
1055
+ # Required. The name of the custom class to delete. Format:
1056
+ #
1057
+ # `projects/{project}/locations/{location}/customClasses/{custom_class}`
1058
+ #
1059
+ # Speech-to-Text supports three locations: `global`, `us` (US North America),
1060
+ # and `eu` (Europe). If you are calling the `speech.googleapis.com`
1061
+ # endpoint, use the `global` location. To specify a region, use a
1062
+ # [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints)
1063
+ # with matching `us` or `eu` location value.
1064
+ #
1065
+ # @yield [response, operation] Access the result along with the RPC operation
1066
+ # @yieldparam response [::Google::Protobuf::Empty]
1067
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
1068
+ #
1069
+ # @return [::Google::Protobuf::Empty]
1070
+ #
1071
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
1072
+ #
1073
+ # @example Basic example
1074
+ # require "google/cloud/speech/v1"
1075
+ #
1076
+ # # Create a client object. The client can be reused for multiple calls.
1077
+ # client = Google::Cloud::Speech::V1::Adaptation::Client.new
1078
+ #
1079
+ # # Create a request. To set request fields, pass in keyword arguments.
1080
+ # request = Google::Cloud::Speech::V1::DeleteCustomClassRequest.new
1081
+ #
1082
+ # # Call the delete_custom_class method.
1083
+ # result = client.delete_custom_class request
1084
+ #
1085
+ # # The returned object is of type Google::Protobuf::Empty.
1086
+ # p result
1087
+ #
1088
+ def delete_custom_class request, options = nil
1089
+ raise ::ArgumentError, "request must be provided" if request.nil?
1090
+
1091
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Speech::V1::DeleteCustomClassRequest
1092
+
1093
+ # Converts hash and nil to an options object
1094
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1095
+
1096
+ # Customize the options with defaults
1097
+ metadata = @config.rpcs.delete_custom_class.metadata.to_h
1098
+
1099
+ # Set x-goog-api-client and x-goog-user-project headers
1100
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1101
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1102
+ gapic_version: ::Google::Cloud::Speech::V1::VERSION
1103
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1104
+
1105
+ header_params = {}
1106
+ if request.name
1107
+ header_params["name"] = request.name
1108
+ end
1109
+
1110
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1111
+ metadata[:"x-goog-request-params"] ||= request_params_header
1112
+
1113
+ options.apply_defaults timeout: @config.rpcs.delete_custom_class.timeout,
1114
+ metadata: metadata,
1115
+ retry_policy: @config.rpcs.delete_custom_class.retry_policy
1116
+
1117
+ options.apply_defaults timeout: @config.timeout,
1118
+ metadata: @config.metadata,
1119
+ retry_policy: @config.retry_policy
1120
+
1121
+ @adaptation_stub.call_rpc :delete_custom_class, request, options: options do |response, operation|
1122
+ yield response, operation if block_given?
1123
+ return response
1124
+ end
1125
+ rescue ::GRPC::BadStatus => e
1126
+ raise ::Google::Cloud::Error.from_error(e)
1127
+ end
1128
+
1129
+ ##
1130
+ # Configuration class for the Adaptation API.
1131
+ #
1132
+ # This class represents the configuration for Adaptation,
1133
+ # providing control over timeouts, retry behavior, logging, transport
1134
+ # parameters, and other low-level controls. Certain parameters can also be
1135
+ # applied individually to specific RPCs. See
1136
+ # {::Google::Cloud::Speech::V1::Adaptation::Client::Configuration::Rpcs}
1137
+ # for a list of RPCs that can be configured independently.
1138
+ #
1139
+ # Configuration can be applied globally to all clients, or to a single client
1140
+ # on construction.
1141
+ #
1142
+ # @example
1143
+ #
1144
+ # # Modify the global config, setting the timeout for
1145
+ # # create_phrase_set to 20 seconds,
1146
+ # # and all remaining timeouts to 10 seconds.
1147
+ # ::Google::Cloud::Speech::V1::Adaptation::Client.configure do |config|
1148
+ # config.timeout = 10.0
1149
+ # config.rpcs.create_phrase_set.timeout = 20.0
1150
+ # end
1151
+ #
1152
+ # # Apply the above configuration only to a new client.
1153
+ # client = ::Google::Cloud::Speech::V1::Adaptation::Client.new do |config|
1154
+ # config.timeout = 10.0
1155
+ # config.rpcs.create_phrase_set.timeout = 20.0
1156
+ # end
1157
+ #
1158
+ # @!attribute [rw] endpoint
1159
+ # The hostname or hostname:port of the service endpoint.
1160
+ # Defaults to `"speech.googleapis.com"`.
1161
+ # @return [::String]
1162
+ # @!attribute [rw] credentials
1163
+ # Credentials to send with calls. You may provide any of the following types:
1164
+ # * (`String`) The path to a service account key file in JSON format
1165
+ # * (`Hash`) A service account key as a Hash
1166
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
1167
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
1168
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
1169
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
1170
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
1171
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
1172
+ # * (`nil`) indicating no credentials
1173
+ # @return [::Object]
1174
+ # @!attribute [rw] scope
1175
+ # The OAuth scopes
1176
+ # @return [::Array<::String>]
1177
+ # @!attribute [rw] lib_name
1178
+ # The library name as recorded in instrumentation and logging
1179
+ # @return [::String]
1180
+ # @!attribute [rw] lib_version
1181
+ # The library version as recorded in instrumentation and logging
1182
+ # @return [::String]
1183
+ # @!attribute [rw] channel_args
1184
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
1185
+ # `GRPC::Core::Channel` object is provided as the credential.
1186
+ # @return [::Hash]
1187
+ # @!attribute [rw] interceptors
1188
+ # An array of interceptors that are run before calls are executed.
1189
+ # @return [::Array<::GRPC::ClientInterceptor>]
1190
+ # @!attribute [rw] timeout
1191
+ # The call timeout in seconds.
1192
+ # @return [::Numeric]
1193
+ # @!attribute [rw] metadata
1194
+ # Additional gRPC headers to be sent with the call.
1195
+ # @return [::Hash{::Symbol=>::String}]
1196
+ # @!attribute [rw] retry_policy
1197
+ # The retry policy. The value is a hash with the following keys:
1198
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1199
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1200
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1201
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1202
+ # trigger a retry.
1203
+ # @return [::Hash]
1204
+ # @!attribute [rw] quota_project
1205
+ # A separate project against which to charge quota.
1206
+ # @return [::String]
1207
+ #
1208
+ class Configuration
1209
+ extend ::Gapic::Config
1210
+
1211
+ config_attr :endpoint, "speech.googleapis.com", ::String
1212
+ config_attr :credentials, nil do |value|
1213
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1214
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
1215
+ allowed.any? { |klass| klass === value }
1216
+ end
1217
+ config_attr :scope, nil, ::String, ::Array, nil
1218
+ config_attr :lib_name, nil, ::String, nil
1219
+ config_attr :lib_version, nil, ::String, nil
1220
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
1221
+ config_attr :interceptors, nil, ::Array, nil
1222
+ config_attr :timeout, nil, ::Numeric, nil
1223
+ config_attr :metadata, nil, ::Hash, nil
1224
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1225
+ config_attr :quota_project, nil, ::String, nil
1226
+
1227
+ # @private
1228
+ def initialize parent_config = nil
1229
+ @parent_config = parent_config unless parent_config.nil?
1230
+
1231
+ yield self if block_given?
1232
+ end
1233
+
1234
+ ##
1235
+ # Configurations for individual RPCs
1236
+ # @return [Rpcs]
1237
+ #
1238
+ def rpcs
1239
+ @rpcs ||= begin
1240
+ parent_rpcs = nil
1241
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
1242
+ Rpcs.new parent_rpcs
1243
+ end
1244
+ end
1245
+
1246
+ ##
1247
+ # Configuration RPC class for the Adaptation API.
1248
+ #
1249
+ # Includes fields providing the configuration for each RPC in this service.
1250
+ # Each configuration object is of type `Gapic::Config::Method` and includes
1251
+ # the following configuration fields:
1252
+ #
1253
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
1254
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
1255
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1256
+ # include the following keys:
1257
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1258
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1259
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1260
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1261
+ # trigger a retry.
1262
+ #
1263
+ class Rpcs
1264
+ ##
1265
+ # RPC-specific configuration for `create_phrase_set`
1266
+ # @return [::Gapic::Config::Method]
1267
+ #
1268
+ attr_reader :create_phrase_set
1269
+ ##
1270
+ # RPC-specific configuration for `get_phrase_set`
1271
+ # @return [::Gapic::Config::Method]
1272
+ #
1273
+ attr_reader :get_phrase_set
1274
+ ##
1275
+ # RPC-specific configuration for `list_phrase_set`
1276
+ # @return [::Gapic::Config::Method]
1277
+ #
1278
+ attr_reader :list_phrase_set
1279
+ ##
1280
+ # RPC-specific configuration for `update_phrase_set`
1281
+ # @return [::Gapic::Config::Method]
1282
+ #
1283
+ attr_reader :update_phrase_set
1284
+ ##
1285
+ # RPC-specific configuration for `delete_phrase_set`
1286
+ # @return [::Gapic::Config::Method]
1287
+ #
1288
+ attr_reader :delete_phrase_set
1289
+ ##
1290
+ # RPC-specific configuration for `create_custom_class`
1291
+ # @return [::Gapic::Config::Method]
1292
+ #
1293
+ attr_reader :create_custom_class
1294
+ ##
1295
+ # RPC-specific configuration for `get_custom_class`
1296
+ # @return [::Gapic::Config::Method]
1297
+ #
1298
+ attr_reader :get_custom_class
1299
+ ##
1300
+ # RPC-specific configuration for `list_custom_classes`
1301
+ # @return [::Gapic::Config::Method]
1302
+ #
1303
+ attr_reader :list_custom_classes
1304
+ ##
1305
+ # RPC-specific configuration for `update_custom_class`
1306
+ # @return [::Gapic::Config::Method]
1307
+ #
1308
+ attr_reader :update_custom_class
1309
+ ##
1310
+ # RPC-specific configuration for `delete_custom_class`
1311
+ # @return [::Gapic::Config::Method]
1312
+ #
1313
+ attr_reader :delete_custom_class
1314
+
1315
+ # @private
1316
+ def initialize parent_rpcs = nil
1317
+ create_phrase_set_config = parent_rpcs.create_phrase_set if parent_rpcs.respond_to? :create_phrase_set
1318
+ @create_phrase_set = ::Gapic::Config::Method.new create_phrase_set_config
1319
+ get_phrase_set_config = parent_rpcs.get_phrase_set if parent_rpcs.respond_to? :get_phrase_set
1320
+ @get_phrase_set = ::Gapic::Config::Method.new get_phrase_set_config
1321
+ list_phrase_set_config = parent_rpcs.list_phrase_set if parent_rpcs.respond_to? :list_phrase_set
1322
+ @list_phrase_set = ::Gapic::Config::Method.new list_phrase_set_config
1323
+ update_phrase_set_config = parent_rpcs.update_phrase_set if parent_rpcs.respond_to? :update_phrase_set
1324
+ @update_phrase_set = ::Gapic::Config::Method.new update_phrase_set_config
1325
+ delete_phrase_set_config = parent_rpcs.delete_phrase_set if parent_rpcs.respond_to? :delete_phrase_set
1326
+ @delete_phrase_set = ::Gapic::Config::Method.new delete_phrase_set_config
1327
+ create_custom_class_config = parent_rpcs.create_custom_class if parent_rpcs.respond_to? :create_custom_class
1328
+ @create_custom_class = ::Gapic::Config::Method.new create_custom_class_config
1329
+ get_custom_class_config = parent_rpcs.get_custom_class if parent_rpcs.respond_to? :get_custom_class
1330
+ @get_custom_class = ::Gapic::Config::Method.new get_custom_class_config
1331
+ list_custom_classes_config = parent_rpcs.list_custom_classes if parent_rpcs.respond_to? :list_custom_classes
1332
+ @list_custom_classes = ::Gapic::Config::Method.new list_custom_classes_config
1333
+ update_custom_class_config = parent_rpcs.update_custom_class if parent_rpcs.respond_to? :update_custom_class
1334
+ @update_custom_class = ::Gapic::Config::Method.new update_custom_class_config
1335
+ delete_custom_class_config = parent_rpcs.delete_custom_class if parent_rpcs.respond_to? :delete_custom_class
1336
+ @delete_custom_class = ::Gapic::Config::Method.new delete_custom_class_config
1337
+
1338
+ yield self if block_given?
1339
+ end
1340
+ end
1341
+ end
1342
+ end
1343
+ end
1344
+ end
1345
+ end
1346
+ end
1347
+ end