google-cloud-translate-v3 0.5.1 → 0.6.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.
- checksums.yaml +4 -4
- data/lib/google/cloud/translate/v3/rest.rb +37 -0
- data/lib/google/cloud/translate/v3/translation_service/client.rb +49 -34
- data/lib/google/cloud/translate/v3/translation_service/operations.rb +20 -14
- data/lib/google/cloud/translate/v3/translation_service/rest/client.rb +1362 -0
- data/lib/google/cloud/translate/v3/translation_service/rest/operations.rb +935 -0
- data/lib/google/cloud/translate/v3/translation_service/rest/service_stub.rb +667 -0
- data/lib/google/cloud/translate/v3/translation_service/rest.rb +53 -0
- data/lib/google/cloud/translate/v3/translation_service.rb +7 -1
- data/lib/google/cloud/translate/v3/translation_service_pb.rb +5 -0
- data/lib/google/cloud/translate/v3/version.rb +1 -1
- data/lib/google/cloud/translate/v3.rb +7 -2
- data/proto_docs/google/cloud/translate/v3/translation_service.rb +54 -30
- data/proto_docs/google/rpc/status.rb +4 -2
- metadata +12 -7
@@ -0,0 +1,1362 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2023 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
require "google/cloud/errors"
|
20
|
+
require "google/cloud/translate/v3/translation_service_pb"
|
21
|
+
require "google/cloud/translate/v3/translation_service/rest/service_stub"
|
22
|
+
|
23
|
+
module Google
|
24
|
+
module Cloud
|
25
|
+
module Translate
|
26
|
+
module V3
|
27
|
+
module TranslationService
|
28
|
+
module Rest
|
29
|
+
##
|
30
|
+
# REST client for the TranslationService service.
|
31
|
+
#
|
32
|
+
# Provides natural language translation operations.
|
33
|
+
#
|
34
|
+
class Client
|
35
|
+
include Paths
|
36
|
+
|
37
|
+
# @private
|
38
|
+
attr_reader :translation_service_stub
|
39
|
+
|
40
|
+
##
|
41
|
+
# Configure the TranslationService Client class.
|
42
|
+
#
|
43
|
+
# See {::Google::Cloud::Translate::V3::TranslationService::Rest::Client::Configuration}
|
44
|
+
# for a description of the configuration fields.
|
45
|
+
#
|
46
|
+
# @example
|
47
|
+
#
|
48
|
+
# # Modify the configuration for all TranslationService clients
|
49
|
+
# ::Google::Cloud::Translate::V3::TranslationService::Rest::Client.configure do |config|
|
50
|
+
# config.timeout = 10.0
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# @yield [config] Configure the Client client.
|
54
|
+
# @yieldparam config [Client::Configuration]
|
55
|
+
#
|
56
|
+
# @return [Client::Configuration]
|
57
|
+
#
|
58
|
+
def self.configure
|
59
|
+
@configure ||= begin
|
60
|
+
namespace = ["Google", "Cloud", "Translate", "V3"]
|
61
|
+
parent_config = while namespace.any?
|
62
|
+
parent_name = namespace.join "::"
|
63
|
+
parent_const = const_get parent_name
|
64
|
+
break parent_const.configure if parent_const.respond_to? :configure
|
65
|
+
namespace.pop
|
66
|
+
end
|
67
|
+
default_config = Client::Configuration.new parent_config
|
68
|
+
|
69
|
+
default_config.rpcs.translate_text.timeout = 600.0
|
70
|
+
|
71
|
+
default_config.rpcs.detect_language.timeout = 600.0
|
72
|
+
|
73
|
+
default_config.rpcs.get_supported_languages.timeout = 600.0
|
74
|
+
default_config.rpcs.get_supported_languages.retry_policy = {
|
75
|
+
initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
|
76
|
+
}
|
77
|
+
|
78
|
+
default_config.rpcs.translate_document.timeout = 600.0
|
79
|
+
|
80
|
+
default_config.rpcs.batch_translate_text.timeout = 600.0
|
81
|
+
|
82
|
+
default_config.rpcs.batch_translate_document.timeout = 600.0
|
83
|
+
|
84
|
+
default_config.rpcs.create_glossary.timeout = 600.0
|
85
|
+
|
86
|
+
default_config.rpcs.list_glossaries.timeout = 600.0
|
87
|
+
default_config.rpcs.list_glossaries.retry_policy = {
|
88
|
+
initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
|
89
|
+
}
|
90
|
+
|
91
|
+
default_config.rpcs.get_glossary.timeout = 600.0
|
92
|
+
default_config.rpcs.get_glossary.retry_policy = {
|
93
|
+
initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
|
94
|
+
}
|
95
|
+
|
96
|
+
default_config.rpcs.delete_glossary.timeout = 600.0
|
97
|
+
default_config.rpcs.delete_glossary.retry_policy = {
|
98
|
+
initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
|
99
|
+
}
|
100
|
+
|
101
|
+
default_config
|
102
|
+
end
|
103
|
+
yield @configure if block_given?
|
104
|
+
@configure
|
105
|
+
end
|
106
|
+
|
107
|
+
##
|
108
|
+
# Configure the TranslationService Client instance.
|
109
|
+
#
|
110
|
+
# The configuration is set to the derived mode, meaning that values can be changed,
|
111
|
+
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
|
112
|
+
# should be made on {Client.configure}.
|
113
|
+
#
|
114
|
+
# See {::Google::Cloud::Translate::V3::TranslationService::Rest::Client::Configuration}
|
115
|
+
# for a description of the configuration fields.
|
116
|
+
#
|
117
|
+
# @yield [config] Configure the Client client.
|
118
|
+
# @yieldparam config [Client::Configuration]
|
119
|
+
#
|
120
|
+
# @return [Client::Configuration]
|
121
|
+
#
|
122
|
+
def configure
|
123
|
+
yield @config if block_given?
|
124
|
+
@config
|
125
|
+
end
|
126
|
+
|
127
|
+
##
|
128
|
+
# Create a new TranslationService REST client object.
|
129
|
+
#
|
130
|
+
# @example
|
131
|
+
#
|
132
|
+
# # Create a client using the default configuration
|
133
|
+
# client = ::Google::Cloud::Translate::V3::TranslationService::Rest::Client.new
|
134
|
+
#
|
135
|
+
# # Create a client using a custom configuration
|
136
|
+
# client = ::Google::Cloud::Translate::V3::TranslationService::Rest::Client.new do |config|
|
137
|
+
# config.timeout = 10.0
|
138
|
+
# end
|
139
|
+
#
|
140
|
+
# @yield [config] Configure the TranslationService client.
|
141
|
+
# @yieldparam config [Client::Configuration]
|
142
|
+
#
|
143
|
+
def initialize
|
144
|
+
# Create the configuration object
|
145
|
+
@config = Configuration.new Client.configure
|
146
|
+
|
147
|
+
# Yield the configuration if needed
|
148
|
+
yield @config if block_given?
|
149
|
+
|
150
|
+
# Create credentials
|
151
|
+
credentials = @config.credentials
|
152
|
+
# Use self-signed JWT if the endpoint is unchanged from default,
|
153
|
+
# but only if the default endpoint does not have a region prefix.
|
154
|
+
enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
|
155
|
+
!@config.endpoint.split(".").first.include?("-")
|
156
|
+
credentials ||= Credentials.default scope: @config.scope,
|
157
|
+
enable_self_signed_jwt: enable_self_signed_jwt
|
158
|
+
if credentials.is_a?(::String) || credentials.is_a?(::Hash)
|
159
|
+
credentials = Credentials.new credentials, scope: @config.scope
|
160
|
+
end
|
161
|
+
|
162
|
+
@quota_project_id = @config.quota_project
|
163
|
+
@quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
|
164
|
+
|
165
|
+
@operations_client = ::Google::Cloud::Translate::V3::TranslationService::Rest::Operations.new do |config|
|
166
|
+
config.credentials = credentials
|
167
|
+
config.quota_project = @quota_project_id
|
168
|
+
config.endpoint = @config.endpoint
|
169
|
+
end
|
170
|
+
|
171
|
+
@translation_service_stub = ::Google::Cloud::Translate::V3::TranslationService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
|
172
|
+
end
|
173
|
+
|
174
|
+
##
|
175
|
+
# Get the associated client for long-running operations.
|
176
|
+
#
|
177
|
+
# @return [::Google::Cloud::Translate::V3::TranslationService::Rest::Operations]
|
178
|
+
#
|
179
|
+
attr_reader :operations_client
|
180
|
+
|
181
|
+
# Service calls
|
182
|
+
|
183
|
+
##
|
184
|
+
# Translates input text and returns translated text.
|
185
|
+
#
|
186
|
+
# @overload translate_text(request, options = nil)
|
187
|
+
# Pass arguments to `translate_text` via a request object, either of type
|
188
|
+
# {::Google::Cloud::Translate::V3::TranslateTextRequest} or an equivalent Hash.
|
189
|
+
#
|
190
|
+
# @param request [::Google::Cloud::Translate::V3::TranslateTextRequest, ::Hash]
|
191
|
+
# A request object representing the call parameters. Required. To specify no
|
192
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
193
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
194
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
195
|
+
#
|
196
|
+
# @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)
|
197
|
+
# Pass arguments to `translate_text` via keyword arguments. Note that at
|
198
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
199
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
200
|
+
#
|
201
|
+
# @param contents [::Array<::String>]
|
202
|
+
# Required. The content of the input in string format.
|
203
|
+
# We recommend the total content be less than 30,000 codepoints. The max
|
204
|
+
# length of this field is 1024. Use BatchTranslateText for larger text.
|
205
|
+
# @param mime_type [::String]
|
206
|
+
# Optional. The format of the source text, for example, "text/html",
|
207
|
+
# "text/plain". If left blank, the MIME type defaults to "text/html".
|
208
|
+
# @param source_language_code [::String]
|
209
|
+
# Optional. The ISO-639 language code of the input text if
|
210
|
+
# known, for example, "en-US" or "sr-Latn". Supported language codes are
|
211
|
+
# listed in Language Support. If the source language isn't specified, the API
|
212
|
+
# attempts to identify the source language automatically and returns the
|
213
|
+
# source language within the response.
|
214
|
+
# @param target_language_code [::String]
|
215
|
+
# Required. The ISO-639 language code to use for translation of the input
|
216
|
+
# text, set to one of the language codes listed in Language Support.
|
217
|
+
# @param parent [::String]
|
218
|
+
# Required. Project or location to make a call. Must refer to a caller's
|
219
|
+
# project.
|
220
|
+
#
|
221
|
+
# Format: `projects/{project-number-or-id}` or
|
222
|
+
# `projects/{project-number-or-id}/locations/{location-id}`.
|
223
|
+
#
|
224
|
+
# For global calls, use `projects/{project-number-or-id}/locations/global` or
|
225
|
+
# `projects/{project-number-or-id}`.
|
226
|
+
#
|
227
|
+
# Non-global location is required for requests using AutoML models or
|
228
|
+
# custom glossaries.
|
229
|
+
#
|
230
|
+
# Models and glossaries must be within the same region (have same
|
231
|
+
# location-id), otherwise an INVALID_ARGUMENT (400) error is returned.
|
232
|
+
# @param model [::String]
|
233
|
+
# Optional. The `model` type requested for this translation.
|
234
|
+
#
|
235
|
+
# The format depends on model type:
|
236
|
+
#
|
237
|
+
# - AutoML Translation models:
|
238
|
+
# `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
|
239
|
+
#
|
240
|
+
# - General (built-in) models:
|
241
|
+
# `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
|
242
|
+
#
|
243
|
+
#
|
244
|
+
# For global (non-regionalized) requests, use `location-id` `global`.
|
245
|
+
# For example,
|
246
|
+
# `projects/{project-number-or-id}/locations/global/models/general/nmt`.
|
247
|
+
#
|
248
|
+
# If not provided, the default Google model (NMT) will be used.
|
249
|
+
# @param glossary_config [::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash]
|
250
|
+
# Optional. Glossary to be applied. The glossary must be
|
251
|
+
# within the same region (have the same location-id) as the model, otherwise
|
252
|
+
# an INVALID_ARGUMENT (400) error is returned.
|
253
|
+
# @param labels [::Hash{::String => ::String}]
|
254
|
+
# Optional. The labels with user-defined metadata for the request.
|
255
|
+
#
|
256
|
+
# Label keys and values can be no longer than 63 characters
|
257
|
+
# (Unicode codepoints), can only contain lowercase letters, numeric
|
258
|
+
# characters, underscores and dashes. International characters are allowed.
|
259
|
+
# Label values are optional. Label keys must start with a letter.
|
260
|
+
#
|
261
|
+
# See https://cloud.google.com/translate/docs/advanced/labels for more
|
262
|
+
# information.
|
263
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
264
|
+
# @yieldparam result [::Google::Cloud::Translate::V3::TranslateTextResponse]
|
265
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
266
|
+
#
|
267
|
+
# @return [::Google::Cloud::Translate::V3::TranslateTextResponse]
|
268
|
+
#
|
269
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
270
|
+
def translate_text request, options = nil
|
271
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
272
|
+
|
273
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::TranslateTextRequest
|
274
|
+
|
275
|
+
# Converts hash and nil to an options object
|
276
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
277
|
+
|
278
|
+
# Customize the options with defaults
|
279
|
+
call_metadata = @config.rpcs.translate_text.metadata.to_h
|
280
|
+
|
281
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
282
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
283
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
284
|
+
gapic_version: ::Google::Cloud::Translate::V3::VERSION,
|
285
|
+
transports_version_send: [:rest]
|
286
|
+
|
287
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
288
|
+
|
289
|
+
options.apply_defaults timeout: @config.rpcs.translate_text.timeout,
|
290
|
+
metadata: call_metadata,
|
291
|
+
retry_policy: @config.rpcs.translate_text.retry_policy
|
292
|
+
|
293
|
+
options.apply_defaults timeout: @config.timeout,
|
294
|
+
metadata: @config.metadata,
|
295
|
+
retry_policy: @config.retry_policy
|
296
|
+
|
297
|
+
@translation_service_stub.translate_text request, options do |result, operation|
|
298
|
+
yield result, operation if block_given?
|
299
|
+
return result
|
300
|
+
end
|
301
|
+
rescue ::Gapic::Rest::Error => e
|
302
|
+
raise ::Google::Cloud::Error.from_error(e)
|
303
|
+
end
|
304
|
+
|
305
|
+
##
|
306
|
+
# Detects the language of text within a request.
|
307
|
+
#
|
308
|
+
# @overload detect_language(request, options = nil)
|
309
|
+
# Pass arguments to `detect_language` via a request object, either of type
|
310
|
+
# {::Google::Cloud::Translate::V3::DetectLanguageRequest} or an equivalent Hash.
|
311
|
+
#
|
312
|
+
# @param request [::Google::Cloud::Translate::V3::DetectLanguageRequest, ::Hash]
|
313
|
+
# A request object representing the call parameters. Required. To specify no
|
314
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
315
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
316
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
317
|
+
#
|
318
|
+
# @overload detect_language(parent: nil, model: nil, content: nil, mime_type: nil, labels: nil)
|
319
|
+
# Pass arguments to `detect_language` via keyword arguments. Note that at
|
320
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
321
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
322
|
+
#
|
323
|
+
# @param parent [::String]
|
324
|
+
# Required. Project or location to make a call. Must refer to a caller's
|
325
|
+
# project.
|
326
|
+
#
|
327
|
+
# Format: `projects/{project-number-or-id}/locations/{location-id}` or
|
328
|
+
# `projects/{project-number-or-id}`.
|
329
|
+
#
|
330
|
+
# For global calls, use `projects/{project-number-or-id}/locations/global` or
|
331
|
+
# `projects/{project-number-or-id}`.
|
332
|
+
#
|
333
|
+
# Only models within the same region (has same location-id) can be used.
|
334
|
+
# Otherwise an INVALID_ARGUMENT (400) error is returned.
|
335
|
+
# @param model [::String]
|
336
|
+
# Optional. The language detection model to be used.
|
337
|
+
#
|
338
|
+
# Format:
|
339
|
+
# `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/{model-id}`
|
340
|
+
#
|
341
|
+
# Only one language detection model is currently supported:
|
342
|
+
# `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/default`.
|
343
|
+
#
|
344
|
+
# If not specified, the default model is used.
|
345
|
+
# @param content [::String]
|
346
|
+
# The content of the input stored as a string.
|
347
|
+
# @param mime_type [::String]
|
348
|
+
# Optional. The format of the source text, for example, "text/html",
|
349
|
+
# "text/plain". If left blank, the MIME type defaults to "text/html".
|
350
|
+
# @param labels [::Hash{::String => ::String}]
|
351
|
+
# Optional. The labels with user-defined metadata for the request.
|
352
|
+
#
|
353
|
+
# Label keys and values can be no longer than 63 characters
|
354
|
+
# (Unicode codepoints), can only contain lowercase letters, numeric
|
355
|
+
# characters, underscores and dashes. International characters are allowed.
|
356
|
+
# Label values are optional. Label keys must start with a letter.
|
357
|
+
#
|
358
|
+
# See https://cloud.google.com/translate/docs/advanced/labels for more
|
359
|
+
# information.
|
360
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
361
|
+
# @yieldparam result [::Google::Cloud::Translate::V3::DetectLanguageResponse]
|
362
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
363
|
+
#
|
364
|
+
# @return [::Google::Cloud::Translate::V3::DetectLanguageResponse]
|
365
|
+
#
|
366
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
367
|
+
def detect_language request, options = nil
|
368
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
369
|
+
|
370
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::DetectLanguageRequest
|
371
|
+
|
372
|
+
# Converts hash and nil to an options object
|
373
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
374
|
+
|
375
|
+
# Customize the options with defaults
|
376
|
+
call_metadata = @config.rpcs.detect_language.metadata.to_h
|
377
|
+
|
378
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
379
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
380
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
381
|
+
gapic_version: ::Google::Cloud::Translate::V3::VERSION,
|
382
|
+
transports_version_send: [:rest]
|
383
|
+
|
384
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
385
|
+
|
386
|
+
options.apply_defaults timeout: @config.rpcs.detect_language.timeout,
|
387
|
+
metadata: call_metadata,
|
388
|
+
retry_policy: @config.rpcs.detect_language.retry_policy
|
389
|
+
|
390
|
+
options.apply_defaults timeout: @config.timeout,
|
391
|
+
metadata: @config.metadata,
|
392
|
+
retry_policy: @config.retry_policy
|
393
|
+
|
394
|
+
@translation_service_stub.detect_language request, options do |result, operation|
|
395
|
+
yield result, operation if block_given?
|
396
|
+
return result
|
397
|
+
end
|
398
|
+
rescue ::Gapic::Rest::Error => e
|
399
|
+
raise ::Google::Cloud::Error.from_error(e)
|
400
|
+
end
|
401
|
+
|
402
|
+
##
|
403
|
+
# Returns a list of supported languages for translation.
|
404
|
+
#
|
405
|
+
# @overload get_supported_languages(request, options = nil)
|
406
|
+
# Pass arguments to `get_supported_languages` via a request object, either of type
|
407
|
+
# {::Google::Cloud::Translate::V3::GetSupportedLanguagesRequest} or an equivalent Hash.
|
408
|
+
#
|
409
|
+
# @param request [::Google::Cloud::Translate::V3::GetSupportedLanguagesRequest, ::Hash]
|
410
|
+
# A request object representing the call parameters. Required. To specify no
|
411
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
412
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
413
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
414
|
+
#
|
415
|
+
# @overload get_supported_languages(parent: nil, display_language_code: nil, model: nil)
|
416
|
+
# Pass arguments to `get_supported_languages` via keyword arguments. Note that at
|
417
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
418
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
419
|
+
#
|
420
|
+
# @param parent [::String]
|
421
|
+
# Required. Project or location to make a call. Must refer to a caller's
|
422
|
+
# project.
|
423
|
+
#
|
424
|
+
# Format: `projects/{project-number-or-id}` or
|
425
|
+
# `projects/{project-number-or-id}/locations/{location-id}`.
|
426
|
+
#
|
427
|
+
# For global calls, use `projects/{project-number-or-id}/locations/global` or
|
428
|
+
# `projects/{project-number-or-id}`.
|
429
|
+
#
|
430
|
+
# Non-global location is required for AutoML models.
|
431
|
+
#
|
432
|
+
# Only models within the same region (have same location-id) can be used,
|
433
|
+
# otherwise an INVALID_ARGUMENT (400) error is returned.
|
434
|
+
# @param display_language_code [::String]
|
435
|
+
# Optional. The language to use to return localized, human readable names
|
436
|
+
# of supported languages. If missing, then display names are not returned
|
437
|
+
# in a response.
|
438
|
+
# @param model [::String]
|
439
|
+
# Optional. Get supported languages of this model.
|
440
|
+
#
|
441
|
+
# The format depends on model type:
|
442
|
+
#
|
443
|
+
# - AutoML Translation models:
|
444
|
+
# `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
|
445
|
+
#
|
446
|
+
# - General (built-in) models:
|
447
|
+
# `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
|
448
|
+
#
|
449
|
+
#
|
450
|
+
# Returns languages supported by the specified model.
|
451
|
+
# If missing, we get supported languages of Google general NMT model.
|
452
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
453
|
+
# @yieldparam result [::Google::Cloud::Translate::V3::SupportedLanguages]
|
454
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
455
|
+
#
|
456
|
+
# @return [::Google::Cloud::Translate::V3::SupportedLanguages]
|
457
|
+
#
|
458
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
459
|
+
def get_supported_languages request, options = nil
|
460
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
461
|
+
|
462
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::GetSupportedLanguagesRequest
|
463
|
+
|
464
|
+
# Converts hash and nil to an options object
|
465
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
466
|
+
|
467
|
+
# Customize the options with defaults
|
468
|
+
call_metadata = @config.rpcs.get_supported_languages.metadata.to_h
|
469
|
+
|
470
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
471
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
472
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
473
|
+
gapic_version: ::Google::Cloud::Translate::V3::VERSION,
|
474
|
+
transports_version_send: [:rest]
|
475
|
+
|
476
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
477
|
+
|
478
|
+
options.apply_defaults timeout: @config.rpcs.get_supported_languages.timeout,
|
479
|
+
metadata: call_metadata,
|
480
|
+
retry_policy: @config.rpcs.get_supported_languages.retry_policy
|
481
|
+
|
482
|
+
options.apply_defaults timeout: @config.timeout,
|
483
|
+
metadata: @config.metadata,
|
484
|
+
retry_policy: @config.retry_policy
|
485
|
+
|
486
|
+
@translation_service_stub.get_supported_languages request, options do |result, operation|
|
487
|
+
yield result, operation if block_given?
|
488
|
+
return result
|
489
|
+
end
|
490
|
+
rescue ::Gapic::Rest::Error => e
|
491
|
+
raise ::Google::Cloud::Error.from_error(e)
|
492
|
+
end
|
493
|
+
|
494
|
+
##
|
495
|
+
# Translates documents in synchronous mode.
|
496
|
+
#
|
497
|
+
# @overload translate_document(request, options = nil)
|
498
|
+
# Pass arguments to `translate_document` via a request object, either of type
|
499
|
+
# {::Google::Cloud::Translate::V3::TranslateDocumentRequest} or an equivalent Hash.
|
500
|
+
#
|
501
|
+
# @param request [::Google::Cloud::Translate::V3::TranslateDocumentRequest, ::Hash]
|
502
|
+
# A request object representing the call parameters. Required. To specify no
|
503
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
504
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
505
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
506
|
+
#
|
507
|
+
# @overload translate_document(parent: nil, source_language_code: nil, target_language_code: nil, document_input_config: nil, document_output_config: nil, model: nil, glossary_config: nil, labels: nil, customized_attribution: nil, is_translate_native_pdf_only: nil, enable_shadow_removal_native_pdf: nil)
|
508
|
+
# Pass arguments to `translate_document` via keyword arguments. Note that at
|
509
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
510
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
511
|
+
#
|
512
|
+
# @param parent [::String]
|
513
|
+
# Required. Location to make a regional call.
|
514
|
+
#
|
515
|
+
# Format: `projects/{project-number-or-id}/locations/{location-id}`.
|
516
|
+
#
|
517
|
+
# For global calls, use `projects/{project-number-or-id}/locations/global` or
|
518
|
+
# `projects/{project-number-or-id}`.
|
519
|
+
#
|
520
|
+
# Non-global location is required for requests using AutoML models or custom
|
521
|
+
# glossaries.
|
522
|
+
#
|
523
|
+
# Models and glossaries must be within the same region (have the same
|
524
|
+
# location-id), otherwise an INVALID_ARGUMENT (400) error is returned.
|
525
|
+
# @param source_language_code [::String]
|
526
|
+
# Optional. The ISO-639 language code of the input document if known, for
|
527
|
+
# example, "en-US" or "sr-Latn". Supported language codes are listed in
|
528
|
+
# Language Support. If the source language isn't specified, the API attempts
|
529
|
+
# to identify the source language automatically and returns the source
|
530
|
+
# language within the response. Source language must be specified if the
|
531
|
+
# request contains a glossary or a custom model.
|
532
|
+
# @param target_language_code [::String]
|
533
|
+
# Required. The ISO-639 language code to use for translation of the input
|
534
|
+
# document, set to one of the language codes listed in Language Support.
|
535
|
+
# @param document_input_config [::Google::Cloud::Translate::V3::DocumentInputConfig, ::Hash]
|
536
|
+
# Required. Input configurations.
|
537
|
+
# @param document_output_config [::Google::Cloud::Translate::V3::DocumentOutputConfig, ::Hash]
|
538
|
+
# Optional. Output configurations.
|
539
|
+
# Defines if the output file should be stored within Cloud Storage as well
|
540
|
+
# as the desired output format. If not provided the translated file will
|
541
|
+
# only be returned through a byte-stream and its output mime type will be
|
542
|
+
# the same as the input file's mime type.
|
543
|
+
# @param model [::String]
|
544
|
+
# Optional. The `model` type requested for this translation.
|
545
|
+
#
|
546
|
+
# The format depends on model type:
|
547
|
+
#
|
548
|
+
# - AutoML Translation models:
|
549
|
+
# `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
|
550
|
+
#
|
551
|
+
# - General (built-in) models:
|
552
|
+
# `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
|
553
|
+
#
|
554
|
+
#
|
555
|
+
# If not provided, the default Google model (NMT) will be used for
|
556
|
+
# translation.
|
557
|
+
# @param glossary_config [::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash]
|
558
|
+
# Optional. Glossary to be applied. The glossary must be within the same
|
559
|
+
# region (have the same location-id) as the model, otherwise an
|
560
|
+
# INVALID_ARGUMENT (400) error is returned.
|
561
|
+
# @param labels [::Hash{::String => ::String}]
|
562
|
+
# Optional. The labels with user-defined metadata for the request.
|
563
|
+
#
|
564
|
+
# Label keys and values can be no longer than 63 characters (Unicode
|
565
|
+
# codepoints), can only contain lowercase letters, numeric characters,
|
566
|
+
# underscores and dashes. International characters are allowed. Label values
|
567
|
+
# are optional. Label keys must start with a letter.
|
568
|
+
#
|
569
|
+
# See https://cloud.google.com/translate/docs/advanced/labels for more
|
570
|
+
# information.
|
571
|
+
# @param customized_attribution [::String]
|
572
|
+
# Optional. This flag is to support user customized attribution.
|
573
|
+
# If not provided, the default is `Machine Translated by Google`.
|
574
|
+
# Customized attribution should follow rules in
|
575
|
+
# https://cloud.google.com/translate/attribution#attribution_and_logos
|
576
|
+
# @param is_translate_native_pdf_only [::Boolean]
|
577
|
+
# Optional. If true, the page limit of online native pdf translation is 300
|
578
|
+
# and only native pdf pages will be translated.
|
579
|
+
# @param enable_shadow_removal_native_pdf [::Boolean]
|
580
|
+
# Optional. If true, use the text removal to remove the shadow text on
|
581
|
+
# background image for native pdf translation.
|
582
|
+
# Shadow removal feature can only be enabled when
|
583
|
+
# is_translate_native_pdf_only is false
|
584
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
585
|
+
# @yieldparam result [::Google::Cloud::Translate::V3::TranslateDocumentResponse]
|
586
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
587
|
+
#
|
588
|
+
# @return [::Google::Cloud::Translate::V3::TranslateDocumentResponse]
|
589
|
+
#
|
590
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
591
|
+
def translate_document request, options = nil
|
592
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
593
|
+
|
594
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::TranslateDocumentRequest
|
595
|
+
|
596
|
+
# Converts hash and nil to an options object
|
597
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
598
|
+
|
599
|
+
# Customize the options with defaults
|
600
|
+
call_metadata = @config.rpcs.translate_document.metadata.to_h
|
601
|
+
|
602
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
603
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
604
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
605
|
+
gapic_version: ::Google::Cloud::Translate::V3::VERSION,
|
606
|
+
transports_version_send: [:rest]
|
607
|
+
|
608
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
609
|
+
|
610
|
+
options.apply_defaults timeout: @config.rpcs.translate_document.timeout,
|
611
|
+
metadata: call_metadata,
|
612
|
+
retry_policy: @config.rpcs.translate_document.retry_policy
|
613
|
+
|
614
|
+
options.apply_defaults timeout: @config.timeout,
|
615
|
+
metadata: @config.metadata,
|
616
|
+
retry_policy: @config.retry_policy
|
617
|
+
|
618
|
+
@translation_service_stub.translate_document request, options do |result, operation|
|
619
|
+
yield result, operation if block_given?
|
620
|
+
return result
|
621
|
+
end
|
622
|
+
rescue ::Gapic::Rest::Error => e
|
623
|
+
raise ::Google::Cloud::Error.from_error(e)
|
624
|
+
end
|
625
|
+
|
626
|
+
##
|
627
|
+
# Translates a large volume of text in asynchronous batch mode.
|
628
|
+
# This function provides real-time output as the inputs are being processed.
|
629
|
+
# If caller cancels a request, the partial results (for an input file, it's
|
630
|
+
# all or nothing) may still be available on the specified output location.
|
631
|
+
#
|
632
|
+
# This call returns immediately and you can
|
633
|
+
# use google.longrunning.Operation.name to poll the status of the call.
|
634
|
+
#
|
635
|
+
# @overload batch_translate_text(request, options = nil)
|
636
|
+
# Pass arguments to `batch_translate_text` via a request object, either of type
|
637
|
+
# {::Google::Cloud::Translate::V3::BatchTranslateTextRequest} or an equivalent Hash.
|
638
|
+
#
|
639
|
+
# @param request [::Google::Cloud::Translate::V3::BatchTranslateTextRequest, ::Hash]
|
640
|
+
# A request object representing the call parameters. Required. To specify no
|
641
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
642
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
643
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
644
|
+
#
|
645
|
+
# @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)
|
646
|
+
# Pass arguments to `batch_translate_text` via keyword arguments. Note that at
|
647
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
648
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
649
|
+
#
|
650
|
+
# @param parent [::String]
|
651
|
+
# Required. Location to make a call. Must refer to a caller's project.
|
652
|
+
#
|
653
|
+
# Format: `projects/{project-number-or-id}/locations/{location-id}`.
|
654
|
+
#
|
655
|
+
# The `global` location is not supported for batch translation.
|
656
|
+
#
|
657
|
+
# Only AutoML Translation models or glossaries within the same region (have
|
658
|
+
# the same location-id) can be used, otherwise an INVALID_ARGUMENT (400)
|
659
|
+
# error is returned.
|
660
|
+
# @param source_language_code [::String]
|
661
|
+
# Required. Source language code.
|
662
|
+
# @param target_language_codes [::Array<::String>]
|
663
|
+
# Required. Specify up to 10 language codes here.
|
664
|
+
# @param models [::Hash{::String => ::String}]
|
665
|
+
# Optional. The models to use for translation. Map's key is target language
|
666
|
+
# code. Map's value is model name. Value can be a built-in general model,
|
667
|
+
# or an AutoML Translation model.
|
668
|
+
#
|
669
|
+
# The value format depends on model type:
|
670
|
+
#
|
671
|
+
# - AutoML Translation models:
|
672
|
+
# `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
|
673
|
+
#
|
674
|
+
# - General (built-in) models:
|
675
|
+
# `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
|
676
|
+
#
|
677
|
+
#
|
678
|
+
# If the map is empty or a specific model is
|
679
|
+
# not requested for a language pair, then default google model (nmt) is used.
|
680
|
+
# @param input_configs [::Array<::Google::Cloud::Translate::V3::InputConfig, ::Hash>]
|
681
|
+
# Required. Input configurations.
|
682
|
+
# The total number of files matched should be <= 100.
|
683
|
+
# The total content size should be <= 100M Unicode codepoints.
|
684
|
+
# The files must use UTF-8 encoding.
|
685
|
+
# @param output_config [::Google::Cloud::Translate::V3::OutputConfig, ::Hash]
|
686
|
+
# Required. Output configuration.
|
687
|
+
# If 2 input configs match to the same file (that is, same input path),
|
688
|
+
# we don't generate output for duplicate inputs.
|
689
|
+
# @param glossaries [::Hash{::String => ::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash}]
|
690
|
+
# Optional. Glossaries to be applied for translation.
|
691
|
+
# It's keyed by target language code.
|
692
|
+
# @param labels [::Hash{::String => ::String}]
|
693
|
+
# Optional. The labels with user-defined metadata for the request.
|
694
|
+
#
|
695
|
+
# Label keys and values can be no longer than 63 characters
|
696
|
+
# (Unicode codepoints), can only contain lowercase letters, numeric
|
697
|
+
# characters, underscores and dashes. International characters are allowed.
|
698
|
+
# Label values are optional. Label keys must start with a letter.
|
699
|
+
#
|
700
|
+
# See https://cloud.google.com/translate/docs/advanced/labels for more
|
701
|
+
# information.
|
702
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
703
|
+
# @yieldparam result [::Gapic::Operation]
|
704
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
705
|
+
#
|
706
|
+
# @return [::Gapic::Operation]
|
707
|
+
#
|
708
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
709
|
+
def batch_translate_text request, options = nil
|
710
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
711
|
+
|
712
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::BatchTranslateTextRequest
|
713
|
+
|
714
|
+
# Converts hash and nil to an options object
|
715
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
716
|
+
|
717
|
+
# Customize the options with defaults
|
718
|
+
call_metadata = @config.rpcs.batch_translate_text.metadata.to_h
|
719
|
+
|
720
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
721
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
722
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
723
|
+
gapic_version: ::Google::Cloud::Translate::V3::VERSION,
|
724
|
+
transports_version_send: [:rest]
|
725
|
+
|
726
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
727
|
+
|
728
|
+
options.apply_defaults timeout: @config.rpcs.batch_translate_text.timeout,
|
729
|
+
metadata: call_metadata,
|
730
|
+
retry_policy: @config.rpcs.batch_translate_text.retry_policy
|
731
|
+
|
732
|
+
options.apply_defaults timeout: @config.timeout,
|
733
|
+
metadata: @config.metadata,
|
734
|
+
retry_policy: @config.retry_policy
|
735
|
+
|
736
|
+
@translation_service_stub.batch_translate_text request, options do |result, operation|
|
737
|
+
result = ::Gapic::Operation.new result, @operations_client, options: options
|
738
|
+
yield result, operation if block_given?
|
739
|
+
return result
|
740
|
+
end
|
741
|
+
rescue ::Gapic::Rest::Error => e
|
742
|
+
raise ::Google::Cloud::Error.from_error(e)
|
743
|
+
end
|
744
|
+
|
745
|
+
##
|
746
|
+
# Translates a large volume of document in asynchronous batch mode.
|
747
|
+
# This function provides real-time output as the inputs are being processed.
|
748
|
+
# If caller cancels a request, the partial results (for an input file, it's
|
749
|
+
# all or nothing) may still be available on the specified output location.
|
750
|
+
#
|
751
|
+
# This call returns immediately and you can use
|
752
|
+
# google.longrunning.Operation.name to poll the status of the call.
|
753
|
+
#
|
754
|
+
# @overload batch_translate_document(request, options = nil)
|
755
|
+
# Pass arguments to `batch_translate_document` via a request object, either of type
|
756
|
+
# {::Google::Cloud::Translate::V3::BatchTranslateDocumentRequest} or an equivalent Hash.
|
757
|
+
#
|
758
|
+
# @param request [::Google::Cloud::Translate::V3::BatchTranslateDocumentRequest, ::Hash]
|
759
|
+
# A request object representing the call parameters. Required. To specify no
|
760
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
761
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
762
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
763
|
+
#
|
764
|
+
# @overload batch_translate_document(parent: nil, source_language_code: nil, target_language_codes: nil, input_configs: nil, output_config: nil, models: nil, glossaries: nil, format_conversions: nil, customized_attribution: nil)
|
765
|
+
# Pass arguments to `batch_translate_document` via keyword arguments. Note that at
|
766
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
767
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
768
|
+
#
|
769
|
+
# @param parent [::String]
|
770
|
+
# Required. Location to make a regional call.
|
771
|
+
#
|
772
|
+
# Format: `projects/{project-number-or-id}/locations/{location-id}`.
|
773
|
+
#
|
774
|
+
# The `global` location is not supported for batch translation.
|
775
|
+
#
|
776
|
+
# Only AutoML Translation models or glossaries within the same region (have
|
777
|
+
# the same location-id) can be used, otherwise an INVALID_ARGUMENT (400)
|
778
|
+
# error is returned.
|
779
|
+
# @param source_language_code [::String]
|
780
|
+
# Required. The ISO-639 language code of the input document if known, for
|
781
|
+
# example, "en-US" or "sr-Latn". Supported language codes are listed in
|
782
|
+
# [Language Support](https://cloud.google.com/translate/docs/languages).
|
783
|
+
# @param target_language_codes [::Array<::String>]
|
784
|
+
# Required. The ISO-639 language code to use for translation of the input
|
785
|
+
# document. Specify up to 10 language codes here.
|
786
|
+
# @param input_configs [::Array<::Google::Cloud::Translate::V3::BatchDocumentInputConfig, ::Hash>]
|
787
|
+
# Required. Input configurations.
|
788
|
+
# The total number of files matched should be <= 100.
|
789
|
+
# The total content size to translate should be <= 100M Unicode codepoints.
|
790
|
+
# The files must use UTF-8 encoding.
|
791
|
+
# @param output_config [::Google::Cloud::Translate::V3::BatchDocumentOutputConfig, ::Hash]
|
792
|
+
# Required. Output configuration.
|
793
|
+
# If 2 input configs match to the same file (that is, same input path),
|
794
|
+
# we don't generate output for duplicate inputs.
|
795
|
+
# @param models [::Hash{::String => ::String}]
|
796
|
+
# Optional. The models to use for translation. Map's key is target language
|
797
|
+
# code. Map's value is the model name. Value can be a built-in general model,
|
798
|
+
# or an AutoML Translation model.
|
799
|
+
#
|
800
|
+
# The value format depends on model type:
|
801
|
+
#
|
802
|
+
# - AutoML Translation models:
|
803
|
+
# `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
|
804
|
+
#
|
805
|
+
# - General (built-in) models:
|
806
|
+
# `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
|
807
|
+
#
|
808
|
+
#
|
809
|
+
# If the map is empty or a specific model is
|
810
|
+
# not requested for a language pair, then default google model (nmt) is used.
|
811
|
+
# @param glossaries [::Hash{::String => ::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash}]
|
812
|
+
# Optional. Glossaries to be applied. It's keyed by target language code.
|
813
|
+
# @param format_conversions [::Hash{::String => ::String}]
|
814
|
+
# Optional. File format conversion map to be applied to all input files.
|
815
|
+
# Map's key is the original mime_type. Map's value is the target mime_type of
|
816
|
+
# translated documents.
|
817
|
+
#
|
818
|
+
# Supported file format conversion includes:
|
819
|
+
# - `application/pdf` to
|
820
|
+
# `application/vnd.openxmlformats-officedocument.wordprocessingml.document`
|
821
|
+
#
|
822
|
+
# If nothing specified, output files will be in the same format as the
|
823
|
+
# original file.
|
824
|
+
# @param customized_attribution [::String]
|
825
|
+
# Optional. This flag is to support user customized attribution.
|
826
|
+
# If not provided, the default is `Machine Translated by Google`.
|
827
|
+
# Customized attribution should follow rules in
|
828
|
+
# https://cloud.google.com/translate/attribution#attribution_and_logos
|
829
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
830
|
+
# @yieldparam result [::Gapic::Operation]
|
831
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
832
|
+
#
|
833
|
+
# @return [::Gapic::Operation]
|
834
|
+
#
|
835
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
836
|
+
def batch_translate_document request, options = nil
|
837
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
838
|
+
|
839
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::BatchTranslateDocumentRequest
|
840
|
+
|
841
|
+
# Converts hash and nil to an options object
|
842
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
843
|
+
|
844
|
+
# Customize the options with defaults
|
845
|
+
call_metadata = @config.rpcs.batch_translate_document.metadata.to_h
|
846
|
+
|
847
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
848
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
849
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
850
|
+
gapic_version: ::Google::Cloud::Translate::V3::VERSION,
|
851
|
+
transports_version_send: [:rest]
|
852
|
+
|
853
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
854
|
+
|
855
|
+
options.apply_defaults timeout: @config.rpcs.batch_translate_document.timeout,
|
856
|
+
metadata: call_metadata,
|
857
|
+
retry_policy: @config.rpcs.batch_translate_document.retry_policy
|
858
|
+
|
859
|
+
options.apply_defaults timeout: @config.timeout,
|
860
|
+
metadata: @config.metadata,
|
861
|
+
retry_policy: @config.retry_policy
|
862
|
+
|
863
|
+
@translation_service_stub.batch_translate_document request, options do |result, operation|
|
864
|
+
result = ::Gapic::Operation.new result, @operations_client, options: options
|
865
|
+
yield result, operation if block_given?
|
866
|
+
return result
|
867
|
+
end
|
868
|
+
rescue ::Gapic::Rest::Error => e
|
869
|
+
raise ::Google::Cloud::Error.from_error(e)
|
870
|
+
end
|
871
|
+
|
872
|
+
##
|
873
|
+
# Creates a glossary and returns the long-running operation. Returns
|
874
|
+
# NOT_FOUND, if the project doesn't exist.
|
875
|
+
#
|
876
|
+
# @overload create_glossary(request, options = nil)
|
877
|
+
# Pass arguments to `create_glossary` via a request object, either of type
|
878
|
+
# {::Google::Cloud::Translate::V3::CreateGlossaryRequest} or an equivalent Hash.
|
879
|
+
#
|
880
|
+
# @param request [::Google::Cloud::Translate::V3::CreateGlossaryRequest, ::Hash]
|
881
|
+
# A request object representing the call parameters. Required. To specify no
|
882
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
883
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
884
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
885
|
+
#
|
886
|
+
# @overload create_glossary(parent: nil, glossary: nil)
|
887
|
+
# Pass arguments to `create_glossary` via keyword arguments. Note that at
|
888
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
889
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
890
|
+
#
|
891
|
+
# @param parent [::String]
|
892
|
+
# Required. The project name.
|
893
|
+
# @param glossary [::Google::Cloud::Translate::V3::Glossary, ::Hash]
|
894
|
+
# Required. The glossary to create.
|
895
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
896
|
+
# @yieldparam result [::Gapic::Operation]
|
897
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
898
|
+
#
|
899
|
+
# @return [::Gapic::Operation]
|
900
|
+
#
|
901
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
902
|
+
def create_glossary request, options = nil
|
903
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
904
|
+
|
905
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::CreateGlossaryRequest
|
906
|
+
|
907
|
+
# Converts hash and nil to an options object
|
908
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
909
|
+
|
910
|
+
# Customize the options with defaults
|
911
|
+
call_metadata = @config.rpcs.create_glossary.metadata.to_h
|
912
|
+
|
913
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
914
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
915
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
916
|
+
gapic_version: ::Google::Cloud::Translate::V3::VERSION,
|
917
|
+
transports_version_send: [:rest]
|
918
|
+
|
919
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
920
|
+
|
921
|
+
options.apply_defaults timeout: @config.rpcs.create_glossary.timeout,
|
922
|
+
metadata: call_metadata,
|
923
|
+
retry_policy: @config.rpcs.create_glossary.retry_policy
|
924
|
+
|
925
|
+
options.apply_defaults timeout: @config.timeout,
|
926
|
+
metadata: @config.metadata,
|
927
|
+
retry_policy: @config.retry_policy
|
928
|
+
|
929
|
+
@translation_service_stub.create_glossary request, options do |result, operation|
|
930
|
+
result = ::Gapic::Operation.new result, @operations_client, options: options
|
931
|
+
yield result, operation if block_given?
|
932
|
+
return result
|
933
|
+
end
|
934
|
+
rescue ::Gapic::Rest::Error => e
|
935
|
+
raise ::Google::Cloud::Error.from_error(e)
|
936
|
+
end
|
937
|
+
|
938
|
+
##
|
939
|
+
# Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't
|
940
|
+
# exist.
|
941
|
+
#
|
942
|
+
# @overload list_glossaries(request, options = nil)
|
943
|
+
# Pass arguments to `list_glossaries` via a request object, either of type
|
944
|
+
# {::Google::Cloud::Translate::V3::ListGlossariesRequest} or an equivalent Hash.
|
945
|
+
#
|
946
|
+
# @param request [::Google::Cloud::Translate::V3::ListGlossariesRequest, ::Hash]
|
947
|
+
# A request object representing the call parameters. Required. To specify no
|
948
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
949
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
950
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
951
|
+
#
|
952
|
+
# @overload list_glossaries(parent: nil, page_size: nil, page_token: nil, filter: nil)
|
953
|
+
# Pass arguments to `list_glossaries` via keyword arguments. Note that at
|
954
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
955
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
956
|
+
#
|
957
|
+
# @param parent [::String]
|
958
|
+
# Required. The name of the project from which to list all of the glossaries.
|
959
|
+
# @param page_size [::Integer]
|
960
|
+
# Optional. Requested page size. The server may return fewer glossaries than
|
961
|
+
# requested. If unspecified, the server picks an appropriate default.
|
962
|
+
# @param page_token [::String]
|
963
|
+
# Optional. A token identifying a page of results the server should return.
|
964
|
+
# Typically, this is the value of [ListGlossariesResponse.next_page_token]
|
965
|
+
# returned from the previous call to `ListGlossaries` method.
|
966
|
+
# The first page is returned if `page_token`is empty or missing.
|
967
|
+
# @param filter [::String]
|
968
|
+
# Optional. Filter specifying constraints of a list operation.
|
969
|
+
# Specify the constraint by the format of "key=value", where key must be
|
970
|
+
# "src" or "tgt", and the value must be a valid language code.
|
971
|
+
# For multiple restrictions, concatenate them by "AND" (uppercase only),
|
972
|
+
# such as: "src=en-US AND tgt=zh-CN". Notice that the exact match is used
|
973
|
+
# here, which means using 'en-US' and 'en' can lead to different results,
|
974
|
+
# which depends on the language code you used when you create the glossary.
|
975
|
+
# For the unidirectional glossaries, the "src" and "tgt" add restrictions
|
976
|
+
# on the source and target language code separately.
|
977
|
+
# For the equivalent term set glossaries, the "src" and/or "tgt" add
|
978
|
+
# restrictions on the term set.
|
979
|
+
# For example: "src=en-US AND tgt=zh-CN" will only pick the unidirectional
|
980
|
+
# glossaries which exactly match the source language code as "en-US" and the
|
981
|
+
# target language code "zh-CN", but all equivalent term set glossaries which
|
982
|
+
# contain "en-US" and "zh-CN" in their language set will be picked.
|
983
|
+
# If missing, no filtering is performed.
|
984
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
985
|
+
# @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Glossary>]
|
986
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
987
|
+
#
|
988
|
+
# @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Translate::V3::Glossary>]
|
989
|
+
#
|
990
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
991
|
+
def list_glossaries request, options = nil
|
992
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
993
|
+
|
994
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::ListGlossariesRequest
|
995
|
+
|
996
|
+
# Converts hash and nil to an options object
|
997
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
998
|
+
|
999
|
+
# Customize the options with defaults
|
1000
|
+
call_metadata = @config.rpcs.list_glossaries.metadata.to_h
|
1001
|
+
|
1002
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
1003
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
1004
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
1005
|
+
gapic_version: ::Google::Cloud::Translate::V3::VERSION,
|
1006
|
+
transports_version_send: [:rest]
|
1007
|
+
|
1008
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
1009
|
+
|
1010
|
+
options.apply_defaults timeout: @config.rpcs.list_glossaries.timeout,
|
1011
|
+
metadata: call_metadata,
|
1012
|
+
retry_policy: @config.rpcs.list_glossaries.retry_policy
|
1013
|
+
|
1014
|
+
options.apply_defaults timeout: @config.timeout,
|
1015
|
+
metadata: @config.metadata,
|
1016
|
+
retry_policy: @config.retry_policy
|
1017
|
+
|
1018
|
+
@translation_service_stub.list_glossaries request, options do |result, operation|
|
1019
|
+
result = ::Gapic::Rest::PagedEnumerable.new @translation_service_stub, :list_glossaries, "glossaries", request, result, options
|
1020
|
+
yield result, operation if block_given?
|
1021
|
+
return result
|
1022
|
+
end
|
1023
|
+
rescue ::Gapic::Rest::Error => e
|
1024
|
+
raise ::Google::Cloud::Error.from_error(e)
|
1025
|
+
end
|
1026
|
+
|
1027
|
+
##
|
1028
|
+
# Gets a glossary. Returns NOT_FOUND, if the glossary doesn't
|
1029
|
+
# exist.
|
1030
|
+
#
|
1031
|
+
# @overload get_glossary(request, options = nil)
|
1032
|
+
# Pass arguments to `get_glossary` via a request object, either of type
|
1033
|
+
# {::Google::Cloud::Translate::V3::GetGlossaryRequest} or an equivalent Hash.
|
1034
|
+
#
|
1035
|
+
# @param request [::Google::Cloud::Translate::V3::GetGlossaryRequest, ::Hash]
|
1036
|
+
# A request object representing the call parameters. Required. To specify no
|
1037
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
1038
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
1039
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
1040
|
+
#
|
1041
|
+
# @overload get_glossary(name: nil)
|
1042
|
+
# Pass arguments to `get_glossary` via keyword arguments. Note that at
|
1043
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
1044
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
1045
|
+
#
|
1046
|
+
# @param name [::String]
|
1047
|
+
# Required. The name of the glossary to retrieve.
|
1048
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
1049
|
+
# @yieldparam result [::Google::Cloud::Translate::V3::Glossary]
|
1050
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
1051
|
+
#
|
1052
|
+
# @return [::Google::Cloud::Translate::V3::Glossary]
|
1053
|
+
#
|
1054
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
1055
|
+
def get_glossary request, options = nil
|
1056
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
1057
|
+
|
1058
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::GetGlossaryRequest
|
1059
|
+
|
1060
|
+
# Converts hash and nil to an options object
|
1061
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
1062
|
+
|
1063
|
+
# Customize the options with defaults
|
1064
|
+
call_metadata = @config.rpcs.get_glossary.metadata.to_h
|
1065
|
+
|
1066
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
1067
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
1068
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
1069
|
+
gapic_version: ::Google::Cloud::Translate::V3::VERSION,
|
1070
|
+
transports_version_send: [:rest]
|
1071
|
+
|
1072
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
1073
|
+
|
1074
|
+
options.apply_defaults timeout: @config.rpcs.get_glossary.timeout,
|
1075
|
+
metadata: call_metadata,
|
1076
|
+
retry_policy: @config.rpcs.get_glossary.retry_policy
|
1077
|
+
|
1078
|
+
options.apply_defaults timeout: @config.timeout,
|
1079
|
+
metadata: @config.metadata,
|
1080
|
+
retry_policy: @config.retry_policy
|
1081
|
+
|
1082
|
+
@translation_service_stub.get_glossary request, options do |result, operation|
|
1083
|
+
yield result, operation if block_given?
|
1084
|
+
return result
|
1085
|
+
end
|
1086
|
+
rescue ::Gapic::Rest::Error => e
|
1087
|
+
raise ::Google::Cloud::Error.from_error(e)
|
1088
|
+
end
|
1089
|
+
|
1090
|
+
##
|
1091
|
+
# Deletes a glossary, or cancels glossary construction
|
1092
|
+
# if the glossary isn't created yet.
|
1093
|
+
# Returns NOT_FOUND, if the glossary doesn't exist.
|
1094
|
+
#
|
1095
|
+
# @overload delete_glossary(request, options = nil)
|
1096
|
+
# Pass arguments to `delete_glossary` via a request object, either of type
|
1097
|
+
# {::Google::Cloud::Translate::V3::DeleteGlossaryRequest} or an equivalent Hash.
|
1098
|
+
#
|
1099
|
+
# @param request [::Google::Cloud::Translate::V3::DeleteGlossaryRequest, ::Hash]
|
1100
|
+
# A request object representing the call parameters. Required. To specify no
|
1101
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
1102
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
1103
|
+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
|
1104
|
+
#
|
1105
|
+
# @overload delete_glossary(name: nil)
|
1106
|
+
# Pass arguments to `delete_glossary` via keyword arguments. Note that at
|
1107
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
1108
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
1109
|
+
#
|
1110
|
+
# @param name [::String]
|
1111
|
+
# Required. The name of the glossary to delete.
|
1112
|
+
# @yield [result, operation] Access the result along with the TransportOperation object
|
1113
|
+
# @yieldparam result [::Gapic::Operation]
|
1114
|
+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
|
1115
|
+
#
|
1116
|
+
# @return [::Gapic::Operation]
|
1117
|
+
#
|
1118
|
+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
|
1119
|
+
def delete_glossary request, options = nil
|
1120
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
1121
|
+
|
1122
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::DeleteGlossaryRequest
|
1123
|
+
|
1124
|
+
# Converts hash and nil to an options object
|
1125
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
1126
|
+
|
1127
|
+
# Customize the options with defaults
|
1128
|
+
call_metadata = @config.rpcs.delete_glossary.metadata.to_h
|
1129
|
+
|
1130
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
1131
|
+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
1132
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
1133
|
+
gapic_version: ::Google::Cloud::Translate::V3::VERSION,
|
1134
|
+
transports_version_send: [:rest]
|
1135
|
+
|
1136
|
+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
1137
|
+
|
1138
|
+
options.apply_defaults timeout: @config.rpcs.delete_glossary.timeout,
|
1139
|
+
metadata: call_metadata,
|
1140
|
+
retry_policy: @config.rpcs.delete_glossary.retry_policy
|
1141
|
+
|
1142
|
+
options.apply_defaults timeout: @config.timeout,
|
1143
|
+
metadata: @config.metadata,
|
1144
|
+
retry_policy: @config.retry_policy
|
1145
|
+
|
1146
|
+
@translation_service_stub.delete_glossary request, options do |result, operation|
|
1147
|
+
result = ::Gapic::Operation.new result, @operations_client, options: options
|
1148
|
+
yield result, operation if block_given?
|
1149
|
+
return result
|
1150
|
+
end
|
1151
|
+
rescue ::Gapic::Rest::Error => e
|
1152
|
+
raise ::Google::Cloud::Error.from_error(e)
|
1153
|
+
end
|
1154
|
+
|
1155
|
+
##
|
1156
|
+
# Configuration class for the TranslationService REST API.
|
1157
|
+
#
|
1158
|
+
# This class represents the configuration for TranslationService REST,
|
1159
|
+
# providing control over timeouts, retry behavior, logging, transport
|
1160
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
1161
|
+
# applied individually to specific RPCs. See
|
1162
|
+
# {::Google::Cloud::Translate::V3::TranslationService::Rest::Client::Configuration::Rpcs}
|
1163
|
+
# for a list of RPCs that can be configured independently.
|
1164
|
+
#
|
1165
|
+
# Configuration can be applied globally to all clients, or to a single client
|
1166
|
+
# on construction.
|
1167
|
+
#
|
1168
|
+
# @example
|
1169
|
+
#
|
1170
|
+
# # Modify the global config, setting the timeout for
|
1171
|
+
# # translate_text to 20 seconds,
|
1172
|
+
# # and all remaining timeouts to 10 seconds.
|
1173
|
+
# ::Google::Cloud::Translate::V3::TranslationService::Rest::Client.configure do |config|
|
1174
|
+
# config.timeout = 10.0
|
1175
|
+
# config.rpcs.translate_text.timeout = 20.0
|
1176
|
+
# end
|
1177
|
+
#
|
1178
|
+
# # Apply the above configuration only to a new client.
|
1179
|
+
# client = ::Google::Cloud::Translate::V3::TranslationService::Rest::Client.new do |config|
|
1180
|
+
# config.timeout = 10.0
|
1181
|
+
# config.rpcs.translate_text.timeout = 20.0
|
1182
|
+
# end
|
1183
|
+
#
|
1184
|
+
# @!attribute [rw] endpoint
|
1185
|
+
# The hostname or hostname:port of the service endpoint.
|
1186
|
+
# Defaults to `"translate.googleapis.com"`.
|
1187
|
+
# @return [::String]
|
1188
|
+
# @!attribute [rw] credentials
|
1189
|
+
# Credentials to send with calls. You may provide any of the following types:
|
1190
|
+
# * (`String`) The path to a service account key file in JSON format
|
1191
|
+
# * (`Hash`) A service account key as a Hash
|
1192
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
1193
|
+
# (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
|
1194
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
1195
|
+
# (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
|
1196
|
+
# * (`nil`) indicating no credentials
|
1197
|
+
# @return [::Object]
|
1198
|
+
# @!attribute [rw] scope
|
1199
|
+
# The OAuth scopes
|
1200
|
+
# @return [::Array<::String>]
|
1201
|
+
# @!attribute [rw] lib_name
|
1202
|
+
# The library name as recorded in instrumentation and logging
|
1203
|
+
# @return [::String]
|
1204
|
+
# @!attribute [rw] lib_version
|
1205
|
+
# The library version as recorded in instrumentation and logging
|
1206
|
+
# @return [::String]
|
1207
|
+
# @!attribute [rw] timeout
|
1208
|
+
# The call timeout in seconds.
|
1209
|
+
# @return [::Numeric]
|
1210
|
+
# @!attribute [rw] metadata
|
1211
|
+
# Additional headers to be sent with the call.
|
1212
|
+
# @return [::Hash{::Symbol=>::String}]
|
1213
|
+
# @!attribute [rw] retry_policy
|
1214
|
+
# The retry policy. The value is a hash with the following keys:
|
1215
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
1216
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
1217
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
1218
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
1219
|
+
# trigger a retry.
|
1220
|
+
# @return [::Hash]
|
1221
|
+
# @!attribute [rw] quota_project
|
1222
|
+
# A separate project against which to charge quota.
|
1223
|
+
# @return [::String]
|
1224
|
+
#
|
1225
|
+
class Configuration
|
1226
|
+
extend ::Gapic::Config
|
1227
|
+
|
1228
|
+
config_attr :endpoint, "translate.googleapis.com", ::String
|
1229
|
+
config_attr :credentials, nil do |value|
|
1230
|
+
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
1231
|
+
allowed.any? { |klass| klass === value }
|
1232
|
+
end
|
1233
|
+
config_attr :scope, nil, ::String, ::Array, nil
|
1234
|
+
config_attr :lib_name, nil, ::String, nil
|
1235
|
+
config_attr :lib_version, nil, ::String, nil
|
1236
|
+
config_attr :timeout, nil, ::Numeric, nil
|
1237
|
+
config_attr :metadata, nil, ::Hash, nil
|
1238
|
+
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
1239
|
+
config_attr :quota_project, nil, ::String, nil
|
1240
|
+
|
1241
|
+
# @private
|
1242
|
+
def initialize parent_config = nil
|
1243
|
+
@parent_config = parent_config unless parent_config.nil?
|
1244
|
+
|
1245
|
+
yield self if block_given?
|
1246
|
+
end
|
1247
|
+
|
1248
|
+
##
|
1249
|
+
# Configurations for individual RPCs
|
1250
|
+
# @return [Rpcs]
|
1251
|
+
#
|
1252
|
+
def rpcs
|
1253
|
+
@rpcs ||= begin
|
1254
|
+
parent_rpcs = nil
|
1255
|
+
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
|
1256
|
+
Rpcs.new parent_rpcs
|
1257
|
+
end
|
1258
|
+
end
|
1259
|
+
|
1260
|
+
##
|
1261
|
+
# Configuration RPC class for the TranslationService API.
|
1262
|
+
#
|
1263
|
+
# Includes fields providing the configuration for each RPC in this service.
|
1264
|
+
# Each configuration object is of type `Gapic::Config::Method` and includes
|
1265
|
+
# the following configuration fields:
|
1266
|
+
#
|
1267
|
+
# * `timeout` (*type:* `Numeric`) - The call timeout in seconds
|
1268
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
|
1269
|
+
# * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
|
1270
|
+
# include the following keys:
|
1271
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
1272
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
1273
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
1274
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
1275
|
+
# trigger a retry.
|
1276
|
+
#
|
1277
|
+
class Rpcs
|
1278
|
+
##
|
1279
|
+
# RPC-specific configuration for `translate_text`
|
1280
|
+
# @return [::Gapic::Config::Method]
|
1281
|
+
#
|
1282
|
+
attr_reader :translate_text
|
1283
|
+
##
|
1284
|
+
# RPC-specific configuration for `detect_language`
|
1285
|
+
# @return [::Gapic::Config::Method]
|
1286
|
+
#
|
1287
|
+
attr_reader :detect_language
|
1288
|
+
##
|
1289
|
+
# RPC-specific configuration for `get_supported_languages`
|
1290
|
+
# @return [::Gapic::Config::Method]
|
1291
|
+
#
|
1292
|
+
attr_reader :get_supported_languages
|
1293
|
+
##
|
1294
|
+
# RPC-specific configuration for `translate_document`
|
1295
|
+
# @return [::Gapic::Config::Method]
|
1296
|
+
#
|
1297
|
+
attr_reader :translate_document
|
1298
|
+
##
|
1299
|
+
# RPC-specific configuration for `batch_translate_text`
|
1300
|
+
# @return [::Gapic::Config::Method]
|
1301
|
+
#
|
1302
|
+
attr_reader :batch_translate_text
|
1303
|
+
##
|
1304
|
+
# RPC-specific configuration for `batch_translate_document`
|
1305
|
+
# @return [::Gapic::Config::Method]
|
1306
|
+
#
|
1307
|
+
attr_reader :batch_translate_document
|
1308
|
+
##
|
1309
|
+
# RPC-specific configuration for `create_glossary`
|
1310
|
+
# @return [::Gapic::Config::Method]
|
1311
|
+
#
|
1312
|
+
attr_reader :create_glossary
|
1313
|
+
##
|
1314
|
+
# RPC-specific configuration for `list_glossaries`
|
1315
|
+
# @return [::Gapic::Config::Method]
|
1316
|
+
#
|
1317
|
+
attr_reader :list_glossaries
|
1318
|
+
##
|
1319
|
+
# RPC-specific configuration for `get_glossary`
|
1320
|
+
# @return [::Gapic::Config::Method]
|
1321
|
+
#
|
1322
|
+
attr_reader :get_glossary
|
1323
|
+
##
|
1324
|
+
# RPC-specific configuration for `delete_glossary`
|
1325
|
+
# @return [::Gapic::Config::Method]
|
1326
|
+
#
|
1327
|
+
attr_reader :delete_glossary
|
1328
|
+
|
1329
|
+
# @private
|
1330
|
+
def initialize parent_rpcs = nil
|
1331
|
+
translate_text_config = parent_rpcs.translate_text if parent_rpcs.respond_to? :translate_text
|
1332
|
+
@translate_text = ::Gapic::Config::Method.new translate_text_config
|
1333
|
+
detect_language_config = parent_rpcs.detect_language if parent_rpcs.respond_to? :detect_language
|
1334
|
+
@detect_language = ::Gapic::Config::Method.new detect_language_config
|
1335
|
+
get_supported_languages_config = parent_rpcs.get_supported_languages if parent_rpcs.respond_to? :get_supported_languages
|
1336
|
+
@get_supported_languages = ::Gapic::Config::Method.new get_supported_languages_config
|
1337
|
+
translate_document_config = parent_rpcs.translate_document if parent_rpcs.respond_to? :translate_document
|
1338
|
+
@translate_document = ::Gapic::Config::Method.new translate_document_config
|
1339
|
+
batch_translate_text_config = parent_rpcs.batch_translate_text if parent_rpcs.respond_to? :batch_translate_text
|
1340
|
+
@batch_translate_text = ::Gapic::Config::Method.new batch_translate_text_config
|
1341
|
+
batch_translate_document_config = parent_rpcs.batch_translate_document if parent_rpcs.respond_to? :batch_translate_document
|
1342
|
+
@batch_translate_document = ::Gapic::Config::Method.new batch_translate_document_config
|
1343
|
+
create_glossary_config = parent_rpcs.create_glossary if parent_rpcs.respond_to? :create_glossary
|
1344
|
+
@create_glossary = ::Gapic::Config::Method.new create_glossary_config
|
1345
|
+
list_glossaries_config = parent_rpcs.list_glossaries if parent_rpcs.respond_to? :list_glossaries
|
1346
|
+
@list_glossaries = ::Gapic::Config::Method.new list_glossaries_config
|
1347
|
+
get_glossary_config = parent_rpcs.get_glossary if parent_rpcs.respond_to? :get_glossary
|
1348
|
+
@get_glossary = ::Gapic::Config::Method.new get_glossary_config
|
1349
|
+
delete_glossary_config = parent_rpcs.delete_glossary if parent_rpcs.respond_to? :delete_glossary
|
1350
|
+
@delete_glossary = ::Gapic::Config::Method.new delete_glossary_config
|
1351
|
+
|
1352
|
+
yield self if block_given?
|
1353
|
+
end
|
1354
|
+
end
|
1355
|
+
end
|
1356
|
+
end
|
1357
|
+
end
|
1358
|
+
end
|
1359
|
+
end
|
1360
|
+
end
|
1361
|
+
end
|
1362
|
+
end
|