google-cloud-translate-v3 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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
+ # This gem does not autoload during Bundler.require. To load this gem,
20
+ # issue explicit require statements for the packages desired, e.g.:
21
+ # require "google/cloud/translate/v3"
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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/translate/v3/translation_service"
20
+ require "google/cloud/translate/v3/version"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Translate
25
+ ##
26
+ # To load this package, including all its services, and instantiate a client:
27
+ #
28
+ # require "google/cloud/translate/v3"
29
+ # client = ::Google::Cloud::Translate::V3::TranslationService::Client.new
30
+ #
31
+ module V3
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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 "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/translate/v3/version"
24
+
25
+ require "google/cloud/translate/v3/translation_service/credentials"
26
+ require "google/cloud/translate/v3/translation_service/paths"
27
+ require "google/cloud/translate/v3/translation_service/operations"
28
+ require "google/cloud/translate/v3/translation_service/client"
29
+
30
+ module Google
31
+ module Cloud
32
+ module Translate
33
+ module V3
34
+ ##
35
+ # Provides natural language translation operations.
36
+ #
37
+ # To load this service and instantiate a client:
38
+ #
39
+ # require "google/cloud/translate/v3/translation_service"
40
+ # client = ::Google::Cloud::Translate::V3::TranslationService::Client.new
41
+ #
42
+ module TranslationService
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ helper_path = ::File.join __dir__, "translation_service", "helpers.rb"
50
+ require "google/cloud/translate/v3/translation_service/helpers" if ::File.file? helper_path
@@ -0,0 +1,1136 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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/translate/v3/translation_service_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module Translate
25
+ module V3
26
+ module TranslationService
27
+ ##
28
+ # Client for the TranslationService service.
29
+ #
30
+ # Provides natural language translation operations.
31
+ #
32
+ class Client
33
+ include Paths
34
+
35
+ # @private
36
+ attr_reader :translation_service_stub
37
+
38
+ ##
39
+ # Configure the TranslationService Client class.
40
+ #
41
+ # See {::Google::Cloud::Translate::V3::TranslationService::Client::Configuration}
42
+ # for a description of the configuration fields.
43
+ #
44
+ # ## Example
45
+ #
46
+ # To modify the configuration for all TranslationService clients:
47
+ #
48
+ # ::Google::Cloud::Translate::V3::TranslationService::Client.configure do |config|
49
+ # config.timeout = 10.0
50
+ # end
51
+ #
52
+ # @yield [config] Configure the Client client.
53
+ # @yieldparam config [Client::Configuration]
54
+ #
55
+ # @return [Client::Configuration]
56
+ #
57
+ def self.configure
58
+ @configure ||= begin
59
+ namespace = ["Google", "Cloud", "Translate", "V3"]
60
+ parent_config = while namespace.any?
61
+ parent_name = namespace.join "::"
62
+ parent_const = const_get parent_name
63
+ break parent_const.configure if parent_const&.respond_to? :configure
64
+ namespace.pop
65
+ end
66
+ default_config = Client::Configuration.new parent_config
67
+
68
+ default_config.rpcs.translate_text.timeout = 600.0
69
+
70
+ default_config.rpcs.detect_language.timeout = 600.0
71
+
72
+ default_config.rpcs.get_supported_languages.timeout = 600.0
73
+ default_config.rpcs.get_supported_languages.retry_policy = {
74
+ initial_delay: 0.1,
75
+ max_delay: 60.0,
76
+ multiplier: 1.3,
77
+ retry_codes: ["DEADLINE_EXCEEDED", "UNAVAILABLE"]
78
+ }
79
+
80
+ default_config.rpcs.batch_translate_text.timeout = 600.0
81
+
82
+ default_config.rpcs.create_glossary.timeout = 600.0
83
+
84
+ default_config.rpcs.list_glossaries.timeout = 600.0
85
+ default_config.rpcs.list_glossaries.retry_policy = {
86
+ initial_delay: 0.1,
87
+ max_delay: 60.0,
88
+ multiplier: 1.3,
89
+ retry_codes: ["DEADLINE_EXCEEDED", "UNAVAILABLE"]
90
+ }
91
+
92
+ default_config.rpcs.get_glossary.timeout = 600.0
93
+ default_config.rpcs.get_glossary.retry_policy = {
94
+ initial_delay: 0.1,
95
+ max_delay: 60.0,
96
+ multiplier: 1.3,
97
+ retry_codes: ["DEADLINE_EXCEEDED", "UNAVAILABLE"]
98
+ }
99
+
100
+ default_config.rpcs.delete_glossary.timeout = 600.0
101
+ default_config.rpcs.delete_glossary.retry_policy = {
102
+ initial_delay: 0.1,
103
+ max_delay: 60.0,
104
+ multiplier: 1.3,
105
+ retry_codes: ["DEADLINE_EXCEEDED", "UNAVAILABLE"]
106
+ }
107
+
108
+ default_config
109
+ end
110
+ yield @configure if block_given?
111
+ @configure
112
+ end
113
+
114
+ ##
115
+ # Configure the TranslationService Client instance.
116
+ #
117
+ # The configuration is set to the derived mode, meaning that values can be changed,
118
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
119
+ # should be made on {Client.configure}.
120
+ #
121
+ # See {::Google::Cloud::Translate::V3::TranslationService::Client::Configuration}
122
+ # for a description of the configuration fields.
123
+ #
124
+ # @yield [config] Configure the Client client.
125
+ # @yieldparam config [Client::Configuration]
126
+ #
127
+ # @return [Client::Configuration]
128
+ #
129
+ def configure
130
+ yield @config if block_given?
131
+ @config
132
+ end
133
+
134
+ ##
135
+ # Create a new TranslationService client object.
136
+ #
137
+ # ## Examples
138
+ #
139
+ # To create a new TranslationService client with the default
140
+ # configuration:
141
+ #
142
+ # client = ::Google::Cloud::Translate::V3::TranslationService::Client.new
143
+ #
144
+ # To create a new TranslationService client with a custom
145
+ # configuration:
146
+ #
147
+ # client = ::Google::Cloud::Translate::V3::TranslationService::Client.new do |config|
148
+ # config.timeout = 10.0
149
+ # end
150
+ #
151
+ # @yield [config] Configure the TranslationService client.
152
+ # @yieldparam config [Client::Configuration]
153
+ #
154
+ def initialize
155
+ # These require statements are intentionally placed here to initialize
156
+ # the gRPC module only when it's required.
157
+ # See https://github.com/googleapis/toolkit/issues/446
158
+ require "gapic/grpc"
159
+ require "google/cloud/translate/v3/translation_service_services_pb"
160
+
161
+ # Create the configuration object
162
+ @config = Configuration.new Client.configure
163
+
164
+ # Yield the configuration if needed
165
+ yield @config if block_given?
166
+
167
+ # Create credentials
168
+ credentials = @config.credentials
169
+ credentials ||= Credentials.default scope: @config.scope
170
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
171
+ credentials = Credentials.new credentials, scope: @config.scope
172
+ end
173
+ @quota_project_id = @config.quota_project
174
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
175
+
176
+ @operations_client = Operations.new do |config|
177
+ config.credentials = credentials
178
+ config.endpoint = @config.endpoint
179
+ end
180
+
181
+ @translation_service_stub = ::Gapic::ServiceStub.new(
182
+ ::Google::Cloud::Translate::V3::TranslationService::Stub,
183
+ credentials: credentials,
184
+ endpoint: @config.endpoint,
185
+ channel_args: @config.channel_args,
186
+ interceptors: @config.interceptors
187
+ )
188
+ end
189
+
190
+ ##
191
+ # Get the associated client for long-running operations.
192
+ #
193
+ # @return [::Google::Cloud::Translate::V3::TranslationService::Operations]
194
+ #
195
+ attr_reader :operations_client
196
+
197
+ # Service calls
198
+
199
+ ##
200
+ # Translates input text and returns translated text.
201
+ #
202
+ # @overload translate_text(request, options = nil)
203
+ # Pass arguments to `translate_text` via a request object, either of type
204
+ # {::Google::Cloud::Translate::V3::TranslateTextRequest} or an equivalent Hash.
205
+ #
206
+ # @param request [::Google::Cloud::Translate::V3::TranslateTextRequest, ::Hash]
207
+ # A request object representing the call parameters. Required. To specify no
208
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
209
+ # @param options [::Gapic::CallOptions, ::Hash]
210
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
211
+ #
212
+ # @overload translate_text(contents: nil, mime_type: nil, source_language_code: nil, target_language_code: nil, parent: nil, model: nil, glossary_config: nil, labels: nil)
213
+ # Pass arguments to `translate_text` via keyword arguments. Note that at
214
+ # least one keyword argument is required. To specify no parameters, or to keep all
215
+ # the default parameter values, pass an empty Hash as a request object (see above).
216
+ #
217
+ # @param contents [::Array<::String>]
218
+ # Required. The content of the input in string format.
219
+ # We recommend the total content be less than 30k codepoints.
220
+ # Use BatchTranslateText for larger text.
221
+ # @param mime_type [::String]
222
+ # Optional. The format of the source text, for example, "text/html",
223
+ # "text/plain". If left blank, the MIME type defaults to "text/html".
224
+ # @param source_language_code [::String]
225
+ # Optional. The BCP-47 language code of the input text if
226
+ # known, for example, "en-US" or "sr-Latn". Supported language codes are
227
+ # listed in Language Support. If the source language isn't specified, the API
228
+ # attempts to identify the source language automatically and returns the
229
+ # source language within the response.
230
+ # @param target_language_code [::String]
231
+ # Required. The BCP-47 language code to use for translation of the input
232
+ # text, set to one of the language codes listed in Language Support.
233
+ # @param parent [::String]
234
+ # Required. Project or location to make a call. Must refer to a caller's
235
+ # project.
236
+ #
237
+ # Format: `projects/{project-number-or-id}` or
238
+ # `projects/{project-number-or-id}/locations/{location-id}`.
239
+ #
240
+ # For global calls, use `projects/{project-number-or-id}/locations/global` or
241
+ # `projects/{project-number-or-id}`.
242
+ #
243
+ # Non-global location is required for requests using AutoML models or
244
+ # custom glossaries.
245
+ #
246
+ # Models and glossaries must be within the same region (have same
247
+ # location-id), otherwise an INVALID_ARGUMENT (400) error is returned.
248
+ # @param model [::String]
249
+ # Optional. The `model` type requested for this translation.
250
+ #
251
+ # The format depends on model type:
252
+ #
253
+ # - AutoML Translation models:
254
+ # `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
255
+ #
256
+ # - General (built-in) models:
257
+ # `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
258
+ # `projects/{project-number-or-id}/locations/{location-id}/models/general/base`
259
+ #
260
+ #
261
+ # For global (non-regionalized) requests, use `location-id` `global`.
262
+ # For example,
263
+ # `projects/{project-number-or-id}/locations/global/models/general/nmt`.
264
+ #
265
+ # If missing, the system decides which google base model to use.
266
+ # @param glossary_config [::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash]
267
+ # Optional. Glossary to be applied. The glossary must be
268
+ # within the same region (have the same location-id) as the model, otherwise
269
+ # an INVALID_ARGUMENT (400) error is returned.
270
+ # @param labels [::Hash{::String => ::String}]
271
+ # Optional. The labels with user-defined metadata for the request.
272
+ #
273
+ # Label keys and values can be no longer than 63 characters
274
+ # (Unicode codepoints), can only contain lowercase letters, numeric
275
+ # characters, underscores and dashes. International characters are allowed.
276
+ # Label values are optional. Label keys must start with a letter.
277
+ #
278
+ # See https://cloud.google.com/translate/docs/labels for more information.
279
+ #
280
+ # @yield [response, operation] Access the result along with the RPC operation
281
+ # @yieldparam response [::Google::Cloud::Translate::V3::TranslateTextResponse]
282
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
283
+ #
284
+ # @return [::Google::Cloud::Translate::V3::TranslateTextResponse]
285
+ #
286
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
287
+ #
288
+ def translate_text request, options = nil
289
+ raise ::ArgumentError, "request must be provided" if request.nil?
290
+
291
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::TranslateTextRequest
292
+
293
+ # Converts hash and nil to an options object
294
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
295
+
296
+ # Customize the options with defaults
297
+ metadata = @config.rpcs.translate_text.metadata.to_h
298
+
299
+ # Set x-goog-api-client and x-goog-user-project headers
300
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
301
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
302
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION
303
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
304
+
305
+ header_params = {
306
+ "parent" => request.parent
307
+ }
308
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
309
+ metadata[:"x-goog-request-params"] ||= request_params_header
310
+
311
+ options.apply_defaults timeout: @config.rpcs.translate_text.timeout,
312
+ metadata: metadata,
313
+ retry_policy: @config.rpcs.translate_text.retry_policy
314
+ options.apply_defaults metadata: @config.metadata,
315
+ retry_policy: @config.retry_policy
316
+
317
+ @translation_service_stub.call_rpc :translate_text, request, options: options do |response, operation|
318
+ yield response, operation if block_given?
319
+ return response
320
+ end
321
+ rescue ::GRPC::BadStatus => e
322
+ raise ::Google::Cloud::Error.from_error(e)
323
+ end
324
+
325
+ ##
326
+ # Detects the language of text within a request.
327
+ #
328
+ # @overload detect_language(request, options = nil)
329
+ # Pass arguments to `detect_language` via a request object, either of type
330
+ # {::Google::Cloud::Translate::V3::DetectLanguageRequest} or an equivalent Hash.
331
+ #
332
+ # @param request [::Google::Cloud::Translate::V3::DetectLanguageRequest, ::Hash]
333
+ # A request object representing the call parameters. Required. To specify no
334
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
335
+ # @param options [::Gapic::CallOptions, ::Hash]
336
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
337
+ #
338
+ # @overload detect_language(parent: nil, model: nil, content: nil, mime_type: nil, labels: nil)
339
+ # Pass arguments to `detect_language` via keyword arguments. Note that at
340
+ # least one keyword argument is required. To specify no parameters, or to keep all
341
+ # the default parameter values, pass an empty Hash as a request object (see above).
342
+ #
343
+ # @param parent [::String]
344
+ # Required. Project or location to make a call. Must refer to a caller's
345
+ # project.
346
+ #
347
+ # Format: `projects/{project-number-or-id}/locations/{location-id}` or
348
+ # `projects/{project-number-or-id}`.
349
+ #
350
+ # For global calls, use `projects/{project-number-or-id}/locations/global` or
351
+ # `projects/{project-number-or-id}`.
352
+ #
353
+ # Only models within the same region (has same location-id) can be used.
354
+ # Otherwise an INVALID_ARGUMENT (400) error is returned.
355
+ # @param model [::String]
356
+ # Optional. The language detection model to be used.
357
+ #
358
+ # Format:
359
+ # `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/{model-id}`
360
+ #
361
+ # Only one language detection model is currently supported:
362
+ # `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/default`.
363
+ #
364
+ # If not specified, the default model is used.
365
+ # @param content [::String]
366
+ # The content of the input stored as a string.
367
+ # @param mime_type [::String]
368
+ # Optional. The format of the source text, for example, "text/html",
369
+ # "text/plain". If left blank, the MIME type defaults to "text/html".
370
+ # @param labels [::Hash{::String => ::String}]
371
+ # Optional. The labels with user-defined metadata for the request.
372
+ #
373
+ # Label keys and values can be no longer than 63 characters
374
+ # (Unicode codepoints), can only contain lowercase letters, numeric
375
+ # characters, underscores and dashes. International characters are allowed.
376
+ # Label values are optional. Label keys must start with a letter.
377
+ #
378
+ # See https://cloud.google.com/translate/docs/labels for more information.
379
+ #
380
+ # @yield [response, operation] Access the result along with the RPC operation
381
+ # @yieldparam response [::Google::Cloud::Translate::V3::DetectLanguageResponse]
382
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
383
+ #
384
+ # @return [::Google::Cloud::Translate::V3::DetectLanguageResponse]
385
+ #
386
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
387
+ #
388
+ def detect_language request, options = nil
389
+ raise ::ArgumentError, "request must be provided" if request.nil?
390
+
391
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::DetectLanguageRequest
392
+
393
+ # Converts hash and nil to an options object
394
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
395
+
396
+ # Customize the options with defaults
397
+ metadata = @config.rpcs.detect_language.metadata.to_h
398
+
399
+ # Set x-goog-api-client and x-goog-user-project headers
400
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
401
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
402
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION
403
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
404
+
405
+ header_params = {
406
+ "parent" => request.parent
407
+ }
408
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
409
+ metadata[:"x-goog-request-params"] ||= request_params_header
410
+
411
+ options.apply_defaults timeout: @config.rpcs.detect_language.timeout,
412
+ metadata: metadata,
413
+ retry_policy: @config.rpcs.detect_language.retry_policy
414
+ options.apply_defaults metadata: @config.metadata,
415
+ retry_policy: @config.retry_policy
416
+
417
+ @translation_service_stub.call_rpc :detect_language, request, options: options do |response, operation|
418
+ yield response, operation if block_given?
419
+ return response
420
+ end
421
+ rescue ::GRPC::BadStatus => e
422
+ raise ::Google::Cloud::Error.from_error(e)
423
+ end
424
+
425
+ ##
426
+ # Returns a list of supported languages for translation.
427
+ #
428
+ # @overload get_supported_languages(request, options = nil)
429
+ # Pass arguments to `get_supported_languages` via a request object, either of type
430
+ # {::Google::Cloud::Translate::V3::GetSupportedLanguagesRequest} or an equivalent Hash.
431
+ #
432
+ # @param request [::Google::Cloud::Translate::V3::GetSupportedLanguagesRequest, ::Hash]
433
+ # A request object representing the call parameters. Required. To specify no
434
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
435
+ # @param options [::Gapic::CallOptions, ::Hash]
436
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
437
+ #
438
+ # @overload get_supported_languages(parent: nil, display_language_code: nil, model: nil)
439
+ # Pass arguments to `get_supported_languages` via keyword arguments. Note that at
440
+ # least one keyword argument is required. To specify no parameters, or to keep all
441
+ # the default parameter values, pass an empty Hash as a request object (see above).
442
+ #
443
+ # @param parent [::String]
444
+ # Required. Project or location to make a call. Must refer to a caller's
445
+ # project.
446
+ #
447
+ # Format: `projects/{project-number-or-id}` or
448
+ # `projects/{project-number-or-id}/locations/{location-id}`.
449
+ #
450
+ # For global calls, use `projects/{project-number-or-id}/locations/global` or
451
+ # `projects/{project-number-or-id}`.
452
+ #
453
+ # Non-global location is required for AutoML models.
454
+ #
455
+ # Only models within the same region (have same location-id) can be used,
456
+ # otherwise an INVALID_ARGUMENT (400) error is returned.
457
+ # @param display_language_code [::String]
458
+ # Optional. The language to use to return localized, human readable names
459
+ # of supported languages. If missing, then display names are not returned
460
+ # in a response.
461
+ # @param model [::String]
462
+ # Optional. Get supported languages of this model.
463
+ #
464
+ # The format depends on model type:
465
+ #
466
+ # - AutoML Translation models:
467
+ # `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
468
+ #
469
+ # - General (built-in) models:
470
+ # `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
471
+ # `projects/{project-number-or-id}/locations/{location-id}/models/general/base`
472
+ #
473
+ #
474
+ # Returns languages supported by the specified model.
475
+ # If missing, we get supported languages of Google general base (PBMT) model.
476
+ #
477
+ # @yield [response, operation] Access the result along with the RPC operation
478
+ # @yieldparam response [::Google::Cloud::Translate::V3::SupportedLanguages]
479
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
480
+ #
481
+ # @return [::Google::Cloud::Translate::V3::SupportedLanguages]
482
+ #
483
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
484
+ #
485
+ def get_supported_languages request, options = nil
486
+ raise ::ArgumentError, "request must be provided" if request.nil?
487
+
488
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::GetSupportedLanguagesRequest
489
+
490
+ # Converts hash and nil to an options object
491
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
492
+
493
+ # Customize the options with defaults
494
+ metadata = @config.rpcs.get_supported_languages.metadata.to_h
495
+
496
+ # Set x-goog-api-client and x-goog-user-project headers
497
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
498
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
499
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION
500
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
501
+
502
+ header_params = {
503
+ "parent" => request.parent
504
+ }
505
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
506
+ metadata[:"x-goog-request-params"] ||= request_params_header
507
+
508
+ options.apply_defaults timeout: @config.rpcs.get_supported_languages.timeout,
509
+ metadata: metadata,
510
+ retry_policy: @config.rpcs.get_supported_languages.retry_policy
511
+ options.apply_defaults metadata: @config.metadata,
512
+ retry_policy: @config.retry_policy
513
+
514
+ @translation_service_stub.call_rpc :get_supported_languages, request, options: options do |response, operation|
515
+ yield response, operation if block_given?
516
+ return response
517
+ end
518
+ rescue ::GRPC::BadStatus => e
519
+ raise ::Google::Cloud::Error.from_error(e)
520
+ end
521
+
522
+ ##
523
+ # Translates a large volume of text in asynchronous batch mode.
524
+ # This function provides real-time output as the inputs are being processed.
525
+ # If caller cancels a request, the partial results (for an input file, it's
526
+ # all or nothing) may still be available on the specified output location.
527
+ #
528
+ # This call returns immediately and you can
529
+ # use google.longrunning.Operation.name to poll the status of the call.
530
+ #
531
+ # @overload batch_translate_text(request, options = nil)
532
+ # Pass arguments to `batch_translate_text` via a request object, either of type
533
+ # {::Google::Cloud::Translate::V3::BatchTranslateTextRequest} or an equivalent Hash.
534
+ #
535
+ # @param request [::Google::Cloud::Translate::V3::BatchTranslateTextRequest, ::Hash]
536
+ # A request object representing the call parameters. Required. To specify no
537
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
538
+ # @param options [::Gapic::CallOptions, ::Hash]
539
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
540
+ #
541
+ # @overload batch_translate_text(parent: nil, source_language_code: nil, target_language_codes: nil, models: nil, input_configs: nil, output_config: nil, glossaries: nil, labels: nil)
542
+ # Pass arguments to `batch_translate_text` via keyword arguments. Note that at
543
+ # least one keyword argument is required. To specify no parameters, or to keep all
544
+ # the default parameter values, pass an empty Hash as a request object (see above).
545
+ #
546
+ # @param parent [::String]
547
+ # Required. Location to make a call. Must refer to a caller's project.
548
+ #
549
+ # Format: `projects/{project-number-or-id}/locations/{location-id}`.
550
+ #
551
+ # The `global` location is not supported for batch translation.
552
+ #
553
+ # Only AutoML Translation models or glossaries within the same region (have
554
+ # the same location-id) can be used, otherwise an INVALID_ARGUMENT (400)
555
+ # error is returned.
556
+ # @param source_language_code [::String]
557
+ # Required. Source language code.
558
+ # @param target_language_codes [::Array<::String>]
559
+ # Required. Specify up to 10 language codes here.
560
+ # @param models [::Hash{::String => ::String}]
561
+ # Optional. The models to use for translation. Map's key is target language
562
+ # code. Map's value is model name. Value can be a built-in general model,
563
+ # or an AutoML Translation model.
564
+ #
565
+ # The value format depends on model type:
566
+ #
567
+ # - AutoML Translation models:
568
+ # `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
569
+ #
570
+ # - General (built-in) models:
571
+ # `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
572
+ # `projects/{project-number-or-id}/locations/{location-id}/models/general/base`
573
+ #
574
+ #
575
+ # If the map is empty or a specific model is
576
+ # not requested for a language pair, then default google model (nmt) is used.
577
+ # @param input_configs [::Array<::Google::Cloud::Translate::V3::InputConfig, ::Hash>]
578
+ # Required. Input configurations.
579
+ # The total number of files matched should be <= 1000.
580
+ # The total content size should be <= 100M Unicode codepoints.
581
+ # The files must use UTF-8 encoding.
582
+ # @param output_config [::Google::Cloud::Translate::V3::OutputConfig, ::Hash]
583
+ # Required. Output configuration.
584
+ # If 2 input configs match to the same file (that is, same input path),
585
+ # we don't generate output for duplicate inputs.
586
+ # @param glossaries [::Hash{::String => ::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash}]
587
+ # Optional. Glossaries to be applied for translation.
588
+ # It's keyed by target language code.
589
+ # @param labels [::Hash{::String => ::String}]
590
+ # Optional. The labels with user-defined metadata for the request.
591
+ #
592
+ # Label keys and values can be no longer than 63 characters
593
+ # (Unicode codepoints), can only contain lowercase letters, numeric
594
+ # characters, underscores and dashes. International characters are allowed.
595
+ # Label values are optional. Label keys must start with a letter.
596
+ #
597
+ # See https://cloud.google.com/translate/docs/labels for more information.
598
+ #
599
+ # @yield [response, operation] Access the result along with the RPC operation
600
+ # @yieldparam response [::Gapic::Operation]
601
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
602
+ #
603
+ # @return [::Gapic::Operation]
604
+ #
605
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
606
+ #
607
+ def batch_translate_text request, options = nil
608
+ raise ::ArgumentError, "request must be provided" if request.nil?
609
+
610
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::BatchTranslateTextRequest
611
+
612
+ # Converts hash and nil to an options object
613
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
614
+
615
+ # Customize the options with defaults
616
+ metadata = @config.rpcs.batch_translate_text.metadata.to_h
617
+
618
+ # Set x-goog-api-client and x-goog-user-project headers
619
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
620
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
621
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION
622
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
623
+
624
+ header_params = {
625
+ "parent" => request.parent
626
+ }
627
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
628
+ metadata[:"x-goog-request-params"] ||= request_params_header
629
+
630
+ options.apply_defaults timeout: @config.rpcs.batch_translate_text.timeout,
631
+ metadata: metadata,
632
+ retry_policy: @config.rpcs.batch_translate_text.retry_policy
633
+ options.apply_defaults metadata: @config.metadata,
634
+ retry_policy: @config.retry_policy
635
+
636
+ @translation_service_stub.call_rpc :batch_translate_text, request, options: options do |response, operation|
637
+ response = ::Gapic::Operation.new response, @operations_client, options: options
638
+ yield response, operation if block_given?
639
+ return response
640
+ end
641
+ rescue ::GRPC::BadStatus => e
642
+ raise ::Google::Cloud::Error.from_error(e)
643
+ end
644
+
645
+ ##
646
+ # Creates a glossary and returns the long-running operation. Returns
647
+ # NOT_FOUND, if the project doesn't exist.
648
+ #
649
+ # @overload create_glossary(request, options = nil)
650
+ # Pass arguments to `create_glossary` via a request object, either of type
651
+ # {::Google::Cloud::Translate::V3::CreateGlossaryRequest} or an equivalent Hash.
652
+ #
653
+ # @param request [::Google::Cloud::Translate::V3::CreateGlossaryRequest, ::Hash]
654
+ # A request object representing the call parameters. Required. To specify no
655
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
656
+ # @param options [::Gapic::CallOptions, ::Hash]
657
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
658
+ #
659
+ # @overload create_glossary(parent: nil, glossary: nil)
660
+ # Pass arguments to `create_glossary` via keyword arguments. Note that at
661
+ # least one keyword argument is required. To specify no parameters, or to keep all
662
+ # the default parameter values, pass an empty Hash as a request object (see above).
663
+ #
664
+ # @param parent [::String]
665
+ # Required. The project name.
666
+ # @param glossary [::Google::Cloud::Translate::V3::Glossary, ::Hash]
667
+ # Required. The glossary to create.
668
+ #
669
+ # @yield [response, operation] Access the result along with the RPC operation
670
+ # @yieldparam response [::Gapic::Operation]
671
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
672
+ #
673
+ # @return [::Gapic::Operation]
674
+ #
675
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
676
+ #
677
+ def create_glossary request, options = nil
678
+ raise ::ArgumentError, "request must be provided" if request.nil?
679
+
680
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::CreateGlossaryRequest
681
+
682
+ # Converts hash and nil to an options object
683
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
684
+
685
+ # Customize the options with defaults
686
+ metadata = @config.rpcs.create_glossary.metadata.to_h
687
+
688
+ # Set x-goog-api-client and x-goog-user-project headers
689
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
690
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
691
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION
692
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
693
+
694
+ header_params = {
695
+ "parent" => request.parent
696
+ }
697
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
698
+ metadata[:"x-goog-request-params"] ||= request_params_header
699
+
700
+ options.apply_defaults timeout: @config.rpcs.create_glossary.timeout,
701
+ metadata: metadata,
702
+ retry_policy: @config.rpcs.create_glossary.retry_policy
703
+ options.apply_defaults metadata: @config.metadata,
704
+ retry_policy: @config.retry_policy
705
+
706
+ @translation_service_stub.call_rpc :create_glossary, request, options: options do |response, operation|
707
+ response = ::Gapic::Operation.new response, @operations_client, options: options
708
+ yield response, operation if block_given?
709
+ return response
710
+ end
711
+ rescue ::GRPC::BadStatus => e
712
+ raise ::Google::Cloud::Error.from_error(e)
713
+ end
714
+
715
+ ##
716
+ # Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't
717
+ # exist.
718
+ #
719
+ # @overload list_glossaries(request, options = nil)
720
+ # Pass arguments to `list_glossaries` via a request object, either of type
721
+ # {::Google::Cloud::Translate::V3::ListGlossariesRequest} or an equivalent Hash.
722
+ #
723
+ # @param request [::Google::Cloud::Translate::V3::ListGlossariesRequest, ::Hash]
724
+ # A request object representing the call parameters. Required. To specify no
725
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
726
+ # @param options [::Gapic::CallOptions, ::Hash]
727
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
728
+ #
729
+ # @overload list_glossaries(parent: nil, page_size: nil, page_token: nil, filter: nil)
730
+ # Pass arguments to `list_glossaries` via keyword arguments. Note that at
731
+ # least one keyword argument is required. To specify no parameters, or to keep all
732
+ # the default parameter values, pass an empty Hash as a request object (see above).
733
+ #
734
+ # @param parent [::String]
735
+ # Required. The name of the project from which to list all of the glossaries.
736
+ # @param page_size [::Integer]
737
+ # Optional. Requested page size. The server may return fewer glossaries than
738
+ # requested. If unspecified, the server picks an appropriate default.
739
+ # @param page_token [::String]
740
+ # Optional. A token identifying a page of results the server should return.
741
+ # Typically, this is the value of [ListGlossariesResponse.next_page_token]
742
+ # returned from the previous call to `ListGlossaries` method.
743
+ # The first page is returned if `page_token`is empty or missing.
744
+ # @param filter [::String]
745
+ # Optional. Filter specifying constraints of a list operation.
746
+ # Filtering is not supported yet, and the parameter currently has no effect.
747
+ # If missing, no filtering is performed.
748
+ #
749
+ # @yield [response, operation] Access the result along with the RPC operation
750
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Translate::V3::Glossary>]
751
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
752
+ #
753
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::Translate::V3::Glossary>]
754
+ #
755
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
756
+ #
757
+ def list_glossaries request, options = nil
758
+ raise ::ArgumentError, "request must be provided" if request.nil?
759
+
760
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::ListGlossariesRequest
761
+
762
+ # Converts hash and nil to an options object
763
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
764
+
765
+ # Customize the options with defaults
766
+ metadata = @config.rpcs.list_glossaries.metadata.to_h
767
+
768
+ # Set x-goog-api-client and x-goog-user-project headers
769
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
770
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
771
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION
772
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
773
+
774
+ header_params = {
775
+ "parent" => request.parent
776
+ }
777
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
778
+ metadata[:"x-goog-request-params"] ||= request_params_header
779
+
780
+ options.apply_defaults timeout: @config.rpcs.list_glossaries.timeout,
781
+ metadata: metadata,
782
+ retry_policy: @config.rpcs.list_glossaries.retry_policy
783
+ options.apply_defaults metadata: @config.metadata,
784
+ retry_policy: @config.retry_policy
785
+
786
+ @translation_service_stub.call_rpc :list_glossaries, request, options: options do |response, operation|
787
+ response = ::Gapic::PagedEnumerable.new @translation_service_stub, :list_glossaries, request, response, operation, options
788
+ yield response, operation if block_given?
789
+ return response
790
+ end
791
+ rescue ::GRPC::BadStatus => e
792
+ raise ::Google::Cloud::Error.from_error(e)
793
+ end
794
+
795
+ ##
796
+ # Gets a glossary. Returns NOT_FOUND, if the glossary doesn't
797
+ # exist.
798
+ #
799
+ # @overload get_glossary(request, options = nil)
800
+ # Pass arguments to `get_glossary` via a request object, either of type
801
+ # {::Google::Cloud::Translate::V3::GetGlossaryRequest} or an equivalent Hash.
802
+ #
803
+ # @param request [::Google::Cloud::Translate::V3::GetGlossaryRequest, ::Hash]
804
+ # A request object representing the call parameters. Required. To specify no
805
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
806
+ # @param options [::Gapic::CallOptions, ::Hash]
807
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
808
+ #
809
+ # @overload get_glossary(name: nil)
810
+ # Pass arguments to `get_glossary` via keyword arguments. Note that at
811
+ # least one keyword argument is required. To specify no parameters, or to keep all
812
+ # the default parameter values, pass an empty Hash as a request object (see above).
813
+ #
814
+ # @param name [::String]
815
+ # Required. The name of the glossary to retrieve.
816
+ #
817
+ # @yield [response, operation] Access the result along with the RPC operation
818
+ # @yieldparam response [::Google::Cloud::Translate::V3::Glossary]
819
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
820
+ #
821
+ # @return [::Google::Cloud::Translate::V3::Glossary]
822
+ #
823
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
824
+ #
825
+ def get_glossary request, options = nil
826
+ raise ::ArgumentError, "request must be provided" if request.nil?
827
+
828
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::GetGlossaryRequest
829
+
830
+ # Converts hash and nil to an options object
831
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
832
+
833
+ # Customize the options with defaults
834
+ metadata = @config.rpcs.get_glossary.metadata.to_h
835
+
836
+ # Set x-goog-api-client and x-goog-user-project headers
837
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
838
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
839
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION
840
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
841
+
842
+ header_params = {
843
+ "name" => request.name
844
+ }
845
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
846
+ metadata[:"x-goog-request-params"] ||= request_params_header
847
+
848
+ options.apply_defaults timeout: @config.rpcs.get_glossary.timeout,
849
+ metadata: metadata,
850
+ retry_policy: @config.rpcs.get_glossary.retry_policy
851
+ options.apply_defaults metadata: @config.metadata,
852
+ retry_policy: @config.retry_policy
853
+
854
+ @translation_service_stub.call_rpc :get_glossary, request, options: options do |response, operation|
855
+ yield response, operation if block_given?
856
+ return response
857
+ end
858
+ rescue ::GRPC::BadStatus => e
859
+ raise ::Google::Cloud::Error.from_error(e)
860
+ end
861
+
862
+ ##
863
+ # Deletes a glossary, or cancels glossary construction
864
+ # if the glossary isn't created yet.
865
+ # Returns NOT_FOUND, if the glossary doesn't exist.
866
+ #
867
+ # @overload delete_glossary(request, options = nil)
868
+ # Pass arguments to `delete_glossary` via a request object, either of type
869
+ # {::Google::Cloud::Translate::V3::DeleteGlossaryRequest} or an equivalent Hash.
870
+ #
871
+ # @param request [::Google::Cloud::Translate::V3::DeleteGlossaryRequest, ::Hash]
872
+ # A request object representing the call parameters. Required. To specify no
873
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
874
+ # @param options [::Gapic::CallOptions, ::Hash]
875
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
876
+ #
877
+ # @overload delete_glossary(name: nil)
878
+ # Pass arguments to `delete_glossary` via keyword arguments. Note that at
879
+ # least one keyword argument is required. To specify no parameters, or to keep all
880
+ # the default parameter values, pass an empty Hash as a request object (see above).
881
+ #
882
+ # @param name [::String]
883
+ # Required. The name of the glossary to delete.
884
+ #
885
+ # @yield [response, operation] Access the result along with the RPC operation
886
+ # @yieldparam response [::Gapic::Operation]
887
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
888
+ #
889
+ # @return [::Gapic::Operation]
890
+ #
891
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
892
+ #
893
+ def delete_glossary request, options = nil
894
+ raise ::ArgumentError, "request must be provided" if request.nil?
895
+
896
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::DeleteGlossaryRequest
897
+
898
+ # Converts hash and nil to an options object
899
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
900
+
901
+ # Customize the options with defaults
902
+ metadata = @config.rpcs.delete_glossary.metadata.to_h
903
+
904
+ # Set x-goog-api-client and x-goog-user-project headers
905
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
906
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
907
+ gapic_version: ::Google::Cloud::Translate::V3::VERSION
908
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
909
+
910
+ header_params = {
911
+ "name" => request.name
912
+ }
913
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
914
+ metadata[:"x-goog-request-params"] ||= request_params_header
915
+
916
+ options.apply_defaults timeout: @config.rpcs.delete_glossary.timeout,
917
+ metadata: metadata,
918
+ retry_policy: @config.rpcs.delete_glossary.retry_policy
919
+ options.apply_defaults metadata: @config.metadata,
920
+ retry_policy: @config.retry_policy
921
+
922
+ @translation_service_stub.call_rpc :delete_glossary, request, options: options do |response, operation|
923
+ response = ::Gapic::Operation.new response, @operations_client, options: options
924
+ yield response, operation if block_given?
925
+ return response
926
+ end
927
+ rescue ::GRPC::BadStatus => e
928
+ raise ::Google::Cloud::Error.from_error(e)
929
+ end
930
+
931
+ ##
932
+ # Configuration class for the TranslationService API.
933
+ #
934
+ # This class represents the configuration for TranslationService,
935
+ # providing control over timeouts, retry behavior, logging, transport
936
+ # parameters, and other low-level controls. Certain parameters can also be
937
+ # applied individually to specific RPCs. See
938
+ # {::Google::Cloud::Translate::V3::TranslationService::Client::Configuration::Rpcs}
939
+ # for a list of RPCs that can be configured independently.
940
+ #
941
+ # Configuration can be applied globally to all clients, or to a single client
942
+ # on construction.
943
+ #
944
+ # # Examples
945
+ #
946
+ # To modify the global config, setting the timeout for translate_text
947
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
948
+ #
949
+ # ::Google::Cloud::Translate::V3::TranslationService::Client.configure do |config|
950
+ # config.timeout = 10.0
951
+ # config.rpcs.translate_text.timeout = 20.0
952
+ # end
953
+ #
954
+ # To apply the above configuration only to a new client:
955
+ #
956
+ # client = ::Google::Cloud::Translate::V3::TranslationService::Client.new do |config|
957
+ # config.timeout = 10.0
958
+ # config.rpcs.translate_text.timeout = 20.0
959
+ # end
960
+ #
961
+ # @!attribute [rw] endpoint
962
+ # The hostname or hostname:port of the service endpoint.
963
+ # Defaults to `"translate.googleapis.com"`.
964
+ # @return [::String]
965
+ # @!attribute [rw] credentials
966
+ # Credentials to send with calls. You may provide any of the following types:
967
+ # * (`String`) The path to a service account key file in JSON format
968
+ # * (`Hash`) A service account key as a Hash
969
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
970
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
971
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
972
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
973
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
974
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
975
+ # * (`nil`) indicating no credentials
976
+ # @return [::Object]
977
+ # @!attribute [rw] scope
978
+ # The OAuth scopes
979
+ # @return [::Array<::String>]
980
+ # @!attribute [rw] lib_name
981
+ # The library name as recorded in instrumentation and logging
982
+ # @return [::String]
983
+ # @!attribute [rw] lib_version
984
+ # The library version as recorded in instrumentation and logging
985
+ # @return [::String]
986
+ # @!attribute [rw] channel_args
987
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
988
+ # `GRPC::Core::Channel` object is provided as the credential.
989
+ # @return [::Hash]
990
+ # @!attribute [rw] interceptors
991
+ # An array of interceptors that are run before calls are executed.
992
+ # @return [::Array<::GRPC::ClientInterceptor>]
993
+ # @!attribute [rw] timeout
994
+ # The call timeout in seconds.
995
+ # @return [::Numeric]
996
+ # @!attribute [rw] metadata
997
+ # Additional gRPC headers to be sent with the call.
998
+ # @return [::Hash{::Symbol=>::String}]
999
+ # @!attribute [rw] retry_policy
1000
+ # The retry policy. The value is a hash with the following keys:
1001
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1002
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1003
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1004
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1005
+ # trigger a retry.
1006
+ # @return [::Hash]
1007
+ # @!attribute [rw] quota_project
1008
+ # A separate project against which to charge quota.
1009
+ # @return [::String]
1010
+ #
1011
+ class Configuration
1012
+ extend ::Gapic::Config
1013
+
1014
+ config_attr :endpoint, "translate.googleapis.com", ::String
1015
+ config_attr :credentials, nil do |value|
1016
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1017
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
1018
+ allowed.any? { |klass| klass === value }
1019
+ end
1020
+ config_attr :scope, nil, ::String, ::Array, nil
1021
+ config_attr :lib_name, nil, ::String, nil
1022
+ config_attr :lib_version, nil, ::String, nil
1023
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
1024
+ config_attr :interceptors, nil, ::Array, nil
1025
+ config_attr :timeout, nil, ::Numeric, nil
1026
+ config_attr :metadata, nil, ::Hash, nil
1027
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1028
+ config_attr :quota_project, nil, ::String, nil
1029
+
1030
+ # @private
1031
+ def initialize parent_config = nil
1032
+ @parent_config = parent_config unless parent_config.nil?
1033
+
1034
+ yield self if block_given?
1035
+ end
1036
+
1037
+ ##
1038
+ # Configurations for individual RPCs
1039
+ # @return [Rpcs]
1040
+ #
1041
+ def rpcs
1042
+ @rpcs ||= begin
1043
+ parent_rpcs = nil
1044
+ parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
1045
+ Rpcs.new parent_rpcs
1046
+ end
1047
+ end
1048
+
1049
+ ##
1050
+ # Configuration RPC class for the TranslationService API.
1051
+ #
1052
+ # Includes fields providing the configuration for each RPC in this service.
1053
+ # Each configuration object is of type `Gapic::Config::Method` and includes
1054
+ # the following configuration fields:
1055
+ #
1056
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
1057
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
1058
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1059
+ # include the following keys:
1060
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1061
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1062
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1063
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1064
+ # trigger a retry.
1065
+ #
1066
+ class Rpcs
1067
+ ##
1068
+ # RPC-specific configuration for `translate_text`
1069
+ # @return [::Gapic::Config::Method]
1070
+ #
1071
+ attr_reader :translate_text
1072
+ ##
1073
+ # RPC-specific configuration for `detect_language`
1074
+ # @return [::Gapic::Config::Method]
1075
+ #
1076
+ attr_reader :detect_language
1077
+ ##
1078
+ # RPC-specific configuration for `get_supported_languages`
1079
+ # @return [::Gapic::Config::Method]
1080
+ #
1081
+ attr_reader :get_supported_languages
1082
+ ##
1083
+ # RPC-specific configuration for `batch_translate_text`
1084
+ # @return [::Gapic::Config::Method]
1085
+ #
1086
+ attr_reader :batch_translate_text
1087
+ ##
1088
+ # RPC-specific configuration for `create_glossary`
1089
+ # @return [::Gapic::Config::Method]
1090
+ #
1091
+ attr_reader :create_glossary
1092
+ ##
1093
+ # RPC-specific configuration for `list_glossaries`
1094
+ # @return [::Gapic::Config::Method]
1095
+ #
1096
+ attr_reader :list_glossaries
1097
+ ##
1098
+ # RPC-specific configuration for `get_glossary`
1099
+ # @return [::Gapic::Config::Method]
1100
+ #
1101
+ attr_reader :get_glossary
1102
+ ##
1103
+ # RPC-specific configuration for `delete_glossary`
1104
+ # @return [::Gapic::Config::Method]
1105
+ #
1106
+ attr_reader :delete_glossary
1107
+
1108
+ # @private
1109
+ def initialize parent_rpcs = nil
1110
+ translate_text_config = parent_rpcs&.translate_text if parent_rpcs&.respond_to? :translate_text
1111
+ @translate_text = ::Gapic::Config::Method.new translate_text_config
1112
+ detect_language_config = parent_rpcs&.detect_language if parent_rpcs&.respond_to? :detect_language
1113
+ @detect_language = ::Gapic::Config::Method.new detect_language_config
1114
+ get_supported_languages_config = parent_rpcs&.get_supported_languages if parent_rpcs&.respond_to? :get_supported_languages
1115
+ @get_supported_languages = ::Gapic::Config::Method.new get_supported_languages_config
1116
+ batch_translate_text_config = parent_rpcs&.batch_translate_text if parent_rpcs&.respond_to? :batch_translate_text
1117
+ @batch_translate_text = ::Gapic::Config::Method.new batch_translate_text_config
1118
+ create_glossary_config = parent_rpcs&.create_glossary if parent_rpcs&.respond_to? :create_glossary
1119
+ @create_glossary = ::Gapic::Config::Method.new create_glossary_config
1120
+ list_glossaries_config = parent_rpcs&.list_glossaries if parent_rpcs&.respond_to? :list_glossaries
1121
+ @list_glossaries = ::Gapic::Config::Method.new list_glossaries_config
1122
+ get_glossary_config = parent_rpcs&.get_glossary if parent_rpcs&.respond_to? :get_glossary
1123
+ @get_glossary = ::Gapic::Config::Method.new get_glossary_config
1124
+ delete_glossary_config = parent_rpcs&.delete_glossary if parent_rpcs&.respond_to? :delete_glossary
1125
+ @delete_glossary = ::Gapic::Config::Method.new delete_glossary_config
1126
+
1127
+ yield self if block_given?
1128
+ end
1129
+ end
1130
+ end
1131
+ end
1132
+ end
1133
+ end
1134
+ end
1135
+ end
1136
+ end