google-cloud-translate-v3 0.3.1 → 0.4.1
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/AUTHENTICATION.md +8 -8
- data/README.md +1 -1
- data/lib/google/cloud/translate/v3/translation_service/client.rb +580 -94
- data/lib/google/cloud/translate/v3/translation_service/operations.rb +149 -37
- data/lib/google/cloud/translate/v3/translation_service_pb.rb +101 -2
- data/lib/google/cloud/translate/v3/translation_service_services_pb.rb +11 -2
- data/lib/google/cloud/translate/v3/version.rb +1 -1
- data/proto_docs/google/api/field_behavior.rb +7 -1
- data/proto_docs/google/cloud/translate/v3/translation_service.rb +559 -25
- metadata +4 -4
@@ -41,13 +41,12 @@ module Google
|
|
41
41
|
# See {::Google::Cloud::Translate::V3::TranslationService::Client::Configuration}
|
42
42
|
# for a description of the configuration fields.
|
43
43
|
#
|
44
|
-
#
|
44
|
+
# @example
|
45
45
|
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
# end
|
46
|
+
# # Modify the configuration for all TranslationService clients
|
47
|
+
# ::Google::Cloud::Translate::V3::TranslationService::Client.configure do |config|
|
48
|
+
# config.timeout = 10.0
|
49
|
+
# end
|
51
50
|
#
|
52
51
|
# @yield [config] Configure the Client client.
|
53
52
|
# @yieldparam config [Client::Configuration]
|
@@ -71,38 +70,30 @@ module Google
|
|
71
70
|
|
72
71
|
default_config.rpcs.get_supported_languages.timeout = 600.0
|
73
72
|
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: [4, 14]
|
73
|
+
initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
|
78
74
|
}
|
79
75
|
|
76
|
+
default_config.rpcs.translate_document.timeout = 600.0
|
77
|
+
|
80
78
|
default_config.rpcs.batch_translate_text.timeout = 600.0
|
81
79
|
|
80
|
+
default_config.rpcs.batch_translate_document.timeout = 600.0
|
81
|
+
|
82
82
|
default_config.rpcs.create_glossary.timeout = 600.0
|
83
83
|
|
84
84
|
default_config.rpcs.list_glossaries.timeout = 600.0
|
85
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: [4, 14]
|
86
|
+
initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
|
90
87
|
}
|
91
88
|
|
92
89
|
default_config.rpcs.get_glossary.timeout = 600.0
|
93
90
|
default_config.rpcs.get_glossary.retry_policy = {
|
94
|
-
initial_delay: 0.1,
|
95
|
-
max_delay: 60.0,
|
96
|
-
multiplier: 1.3,
|
97
|
-
retry_codes: [4, 14]
|
91
|
+
initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
|
98
92
|
}
|
99
93
|
|
100
94
|
default_config.rpcs.delete_glossary.timeout = 600.0
|
101
95
|
default_config.rpcs.delete_glossary.retry_policy = {
|
102
|
-
initial_delay: 0.1,
|
103
|
-
max_delay: 60.0,
|
104
|
-
multiplier: 1.3,
|
105
|
-
retry_codes: [4, 14]
|
96
|
+
initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
|
106
97
|
}
|
107
98
|
|
108
99
|
default_config
|
@@ -134,19 +125,15 @@ module Google
|
|
134
125
|
##
|
135
126
|
# Create a new TranslationService client object.
|
136
127
|
#
|
137
|
-
#
|
138
|
-
#
|
139
|
-
# To create a new TranslationService client with the default
|
140
|
-
# configuration:
|
128
|
+
# @example
|
141
129
|
#
|
142
|
-
#
|
130
|
+
# # Create a client using the default configuration
|
131
|
+
# client = ::Google::Cloud::Translate::V3::TranslationService::Client.new
|
143
132
|
#
|
144
|
-
#
|
145
|
-
#
|
146
|
-
#
|
147
|
-
#
|
148
|
-
# config.timeout = 10.0
|
149
|
-
# end
|
133
|
+
# # Create a client using a custom configuration
|
134
|
+
# client = ::Google::Cloud::Translate::V3::TranslationService::Client.new do |config|
|
135
|
+
# config.timeout = 10.0
|
136
|
+
# end
|
150
137
|
#
|
151
138
|
# @yield [config] Configure the TranslationService client.
|
152
139
|
# @yieldparam config [Client::Configuration]
|
@@ -166,14 +153,13 @@ module Google
|
|
166
153
|
|
167
154
|
# Create credentials
|
168
155
|
credentials = @config.credentials
|
169
|
-
# Use self-signed JWT if the
|
156
|
+
# Use self-signed JWT if the endpoint is unchanged from default,
|
170
157
|
# but only if the default endpoint does not have a region prefix.
|
171
|
-
enable_self_signed_jwt = @config.
|
172
|
-
@config.endpoint == Client.configure.endpoint &&
|
158
|
+
enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
|
173
159
|
!@config.endpoint.split(".").first.include?("-")
|
174
160
|
credentials ||= Credentials.default scope: @config.scope,
|
175
161
|
enable_self_signed_jwt: enable_self_signed_jwt
|
176
|
-
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
162
|
+
if credentials.is_a?(::String) || credentials.is_a?(::Hash)
|
177
163
|
credentials = Credentials.new credentials, scope: @config.scope
|
178
164
|
end
|
179
165
|
@quota_project_id = @config.quota_project
|
@@ -222,7 +208,8 @@ module Google
|
|
222
208
|
#
|
223
209
|
# @param contents [::Array<::String>]
|
224
210
|
# Required. The content of the input in string format.
|
225
|
-
# We recommend the total content be less than 30k codepoints.
|
211
|
+
# We recommend the total content be less than 30k codepoints. The max length
|
212
|
+
# of this field is 1024.
|
226
213
|
# Use BatchTranslateText for larger text.
|
227
214
|
# @param mime_type [::String]
|
228
215
|
# Optional. The format of the source text, for example, "text/html",
|
@@ -261,14 +248,13 @@ module Google
|
|
261
248
|
#
|
262
249
|
# - General (built-in) models:
|
263
250
|
# `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
|
264
|
-
# `projects/{project-number-or-id}/locations/{location-id}/models/general/base`
|
265
251
|
#
|
266
252
|
#
|
267
253
|
# For global (non-regionalized) requests, use `location-id` `global`.
|
268
254
|
# For example,
|
269
255
|
# `projects/{project-number-or-id}/locations/global/models/general/nmt`.
|
270
256
|
#
|
271
|
-
# If
|
257
|
+
# If not provided, the default Google model (NMT) will be used.
|
272
258
|
# @param glossary_config [::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash]
|
273
259
|
# Optional. Glossary to be applied. The glossary must be
|
274
260
|
# within the same region (have the same location-id) as the model, otherwise
|
@@ -281,7 +267,8 @@ module Google
|
|
281
267
|
# characters, underscores and dashes. International characters are allowed.
|
282
268
|
# Label values are optional. Label keys must start with a letter.
|
283
269
|
#
|
284
|
-
# See https://cloud.google.com/translate/docs/labels for more
|
270
|
+
# See https://cloud.google.com/translate/docs/advanced/labels for more
|
271
|
+
# information.
|
285
272
|
#
|
286
273
|
# @yield [response, operation] Access the result along with the RPC operation
|
287
274
|
# @yieldparam response [::Google::Cloud::Translate::V3::TranslateTextResponse]
|
@@ -291,6 +278,21 @@ module Google
|
|
291
278
|
#
|
292
279
|
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
293
280
|
#
|
281
|
+
# @example Basic example
|
282
|
+
# require "google/cloud/translate/v3"
|
283
|
+
#
|
284
|
+
# # Create a client object. The client can be reused for multiple calls.
|
285
|
+
# client = Google::Cloud::Translate::V3::TranslationService::Client.new
|
286
|
+
#
|
287
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
288
|
+
# request = Google::Cloud::Translate::V3::TranslateTextRequest.new
|
289
|
+
#
|
290
|
+
# # Call the translate_text method.
|
291
|
+
# result = client.translate_text request
|
292
|
+
#
|
293
|
+
# # The returned object is of type Google::Cloud::Translate::V3::TranslateTextResponse.
|
294
|
+
# p result
|
295
|
+
#
|
294
296
|
def translate_text request, options = nil
|
295
297
|
raise ::ArgumentError, "request must be provided" if request.nil?
|
296
298
|
|
@@ -308,16 +310,20 @@ module Google
|
|
308
310
|
gapic_version: ::Google::Cloud::Translate::V3::VERSION
|
309
311
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
310
312
|
|
311
|
-
header_params = {
|
312
|
-
|
313
|
-
|
313
|
+
header_params = {}
|
314
|
+
if request.parent
|
315
|
+
header_params["parent"] = request.parent
|
316
|
+
end
|
317
|
+
|
314
318
|
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
315
319
|
metadata[:"x-goog-request-params"] ||= request_params_header
|
316
320
|
|
317
321
|
options.apply_defaults timeout: @config.rpcs.translate_text.timeout,
|
318
322
|
metadata: metadata,
|
319
323
|
retry_policy: @config.rpcs.translate_text.retry_policy
|
320
|
-
|
324
|
+
|
325
|
+
options.apply_defaults timeout: @config.timeout,
|
326
|
+
metadata: @config.metadata,
|
321
327
|
retry_policy: @config.retry_policy
|
322
328
|
|
323
329
|
@translation_service_stub.call_rpc :translate_text, request, options: options do |response, operation|
|
@@ -381,7 +387,8 @@ module Google
|
|
381
387
|
# characters, underscores and dashes. International characters are allowed.
|
382
388
|
# Label values are optional. Label keys must start with a letter.
|
383
389
|
#
|
384
|
-
# See https://cloud.google.com/translate/docs/labels for more
|
390
|
+
# See https://cloud.google.com/translate/docs/advanced/labels for more
|
391
|
+
# information.
|
385
392
|
#
|
386
393
|
# @yield [response, operation] Access the result along with the RPC operation
|
387
394
|
# @yieldparam response [::Google::Cloud::Translate::V3::DetectLanguageResponse]
|
@@ -391,6 +398,21 @@ module Google
|
|
391
398
|
#
|
392
399
|
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
393
400
|
#
|
401
|
+
# @example Basic example
|
402
|
+
# require "google/cloud/translate/v3"
|
403
|
+
#
|
404
|
+
# # Create a client object. The client can be reused for multiple calls.
|
405
|
+
# client = Google::Cloud::Translate::V3::TranslationService::Client.new
|
406
|
+
#
|
407
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
408
|
+
# request = Google::Cloud::Translate::V3::DetectLanguageRequest.new
|
409
|
+
#
|
410
|
+
# # Call the detect_language method.
|
411
|
+
# result = client.detect_language request
|
412
|
+
#
|
413
|
+
# # The returned object is of type Google::Cloud::Translate::V3::DetectLanguageResponse.
|
414
|
+
# p result
|
415
|
+
#
|
394
416
|
def detect_language request, options = nil
|
395
417
|
raise ::ArgumentError, "request must be provided" if request.nil?
|
396
418
|
|
@@ -408,16 +430,20 @@ module Google
|
|
408
430
|
gapic_version: ::Google::Cloud::Translate::V3::VERSION
|
409
431
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
410
432
|
|
411
|
-
header_params = {
|
412
|
-
|
413
|
-
|
433
|
+
header_params = {}
|
434
|
+
if request.parent
|
435
|
+
header_params["parent"] = request.parent
|
436
|
+
end
|
437
|
+
|
414
438
|
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
415
439
|
metadata[:"x-goog-request-params"] ||= request_params_header
|
416
440
|
|
417
441
|
options.apply_defaults timeout: @config.rpcs.detect_language.timeout,
|
418
442
|
metadata: metadata,
|
419
443
|
retry_policy: @config.rpcs.detect_language.retry_policy
|
420
|
-
|
444
|
+
|
445
|
+
options.apply_defaults timeout: @config.timeout,
|
446
|
+
metadata: @config.metadata,
|
421
447
|
retry_policy: @config.retry_policy
|
422
448
|
|
423
449
|
@translation_service_stub.call_rpc :detect_language, request, options: options do |response, operation|
|
@@ -474,11 +500,10 @@ module Google
|
|
474
500
|
#
|
475
501
|
# - General (built-in) models:
|
476
502
|
# `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
|
477
|
-
# `projects/{project-number-or-id}/locations/{location-id}/models/general/base`
|
478
503
|
#
|
479
504
|
#
|
480
505
|
# Returns languages supported by the specified model.
|
481
|
-
# If missing, we get supported languages of Google general
|
506
|
+
# If missing, we get supported languages of Google general NMT model.
|
482
507
|
#
|
483
508
|
# @yield [response, operation] Access the result along with the RPC operation
|
484
509
|
# @yieldparam response [::Google::Cloud::Translate::V3::SupportedLanguages]
|
@@ -488,6 +513,21 @@ module Google
|
|
488
513
|
#
|
489
514
|
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
490
515
|
#
|
516
|
+
# @example Basic example
|
517
|
+
# require "google/cloud/translate/v3"
|
518
|
+
#
|
519
|
+
# # Create a client object. The client can be reused for multiple calls.
|
520
|
+
# client = Google::Cloud::Translate::V3::TranslationService::Client.new
|
521
|
+
#
|
522
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
523
|
+
# request = Google::Cloud::Translate::V3::GetSupportedLanguagesRequest.new
|
524
|
+
#
|
525
|
+
# # Call the get_supported_languages method.
|
526
|
+
# result = client.get_supported_languages request
|
527
|
+
#
|
528
|
+
# # The returned object is of type Google::Cloud::Translate::V3::SupportedLanguages.
|
529
|
+
# p result
|
530
|
+
#
|
491
531
|
def get_supported_languages request, options = nil
|
492
532
|
raise ::ArgumentError, "request must be provided" if request.nil?
|
493
533
|
|
@@ -505,16 +545,20 @@ module Google
|
|
505
545
|
gapic_version: ::Google::Cloud::Translate::V3::VERSION
|
506
546
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
507
547
|
|
508
|
-
header_params = {
|
509
|
-
|
510
|
-
|
548
|
+
header_params = {}
|
549
|
+
if request.parent
|
550
|
+
header_params["parent"] = request.parent
|
551
|
+
end
|
552
|
+
|
511
553
|
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
512
554
|
metadata[:"x-goog-request-params"] ||= request_params_header
|
513
555
|
|
514
556
|
options.apply_defaults timeout: @config.rpcs.get_supported_languages.timeout,
|
515
557
|
metadata: metadata,
|
516
558
|
retry_policy: @config.rpcs.get_supported_languages.retry_policy
|
517
|
-
|
559
|
+
|
560
|
+
options.apply_defaults timeout: @config.timeout,
|
561
|
+
metadata: @config.metadata,
|
518
562
|
retry_policy: @config.retry_policy
|
519
563
|
|
520
564
|
@translation_service_stub.call_rpc :get_supported_languages, request, options: options do |response, operation|
|
@@ -525,6 +569,148 @@ module Google
|
|
525
569
|
raise ::Google::Cloud::Error.from_error(e)
|
526
570
|
end
|
527
571
|
|
572
|
+
##
|
573
|
+
# Translates documents in synchronous mode.
|
574
|
+
#
|
575
|
+
# @overload translate_document(request, options = nil)
|
576
|
+
# Pass arguments to `translate_document` via a request object, either of type
|
577
|
+
# {::Google::Cloud::Translate::V3::TranslateDocumentRequest} or an equivalent Hash.
|
578
|
+
#
|
579
|
+
# @param request [::Google::Cloud::Translate::V3::TranslateDocumentRequest, ::Hash]
|
580
|
+
# A request object representing the call parameters. Required. To specify no
|
581
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
582
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
583
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
584
|
+
#
|
585
|
+
# @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)
|
586
|
+
# Pass arguments to `translate_document` via keyword arguments. Note that at
|
587
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
588
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
589
|
+
#
|
590
|
+
# @param parent [::String]
|
591
|
+
# Required. Location to make a regional call.
|
592
|
+
#
|
593
|
+
# Format: `projects/{project-number-or-id}/locations/{location-id}`.
|
594
|
+
#
|
595
|
+
# For global calls, use `projects/{project-number-or-id}/locations/global` or
|
596
|
+
# `projects/{project-number-or-id}`.
|
597
|
+
#
|
598
|
+
# Non-global location is required for requests using AutoML models or custom
|
599
|
+
# glossaries.
|
600
|
+
#
|
601
|
+
# Models and glossaries must be within the same region (have the same
|
602
|
+
# location-id), otherwise an INVALID_ARGUMENT (400) error is returned.
|
603
|
+
# @param source_language_code [::String]
|
604
|
+
# Optional. The BCP-47 language code of the input document if known, for
|
605
|
+
# example, "en-US" or "sr-Latn". Supported language codes are listed in
|
606
|
+
# Language Support. If the source language isn't specified, the API attempts
|
607
|
+
# to identify the source language automatically and returns the source
|
608
|
+
# language within the response. Source language must be specified if the
|
609
|
+
# request contains a glossary or a custom model.
|
610
|
+
# @param target_language_code [::String]
|
611
|
+
# Required. The BCP-47 language code to use for translation of the input
|
612
|
+
# document, set to one of the language codes listed in Language Support.
|
613
|
+
# @param document_input_config [::Google::Cloud::Translate::V3::DocumentInputConfig, ::Hash]
|
614
|
+
# Required. Input configurations.
|
615
|
+
# @param document_output_config [::Google::Cloud::Translate::V3::DocumentOutputConfig, ::Hash]
|
616
|
+
# Optional. Output configurations.
|
617
|
+
# Defines if the output file should be stored within Cloud Storage as well
|
618
|
+
# as the desired output format. If not provided the translated file will
|
619
|
+
# only be returned through a byte-stream and its output mime type will be
|
620
|
+
# the same as the input file's mime type.
|
621
|
+
# @param model [::String]
|
622
|
+
# Optional. The `model` type requested for this translation.
|
623
|
+
#
|
624
|
+
# The format depends on model type:
|
625
|
+
#
|
626
|
+
# - AutoML Translation models:
|
627
|
+
# `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
|
628
|
+
#
|
629
|
+
# - General (built-in) models:
|
630
|
+
# `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
|
631
|
+
#
|
632
|
+
#
|
633
|
+
# If not provided, the default Google model (NMT) will be used for
|
634
|
+
# translation.
|
635
|
+
# @param glossary_config [::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash]
|
636
|
+
# Optional. Glossary to be applied. The glossary must be within the same
|
637
|
+
# region (have the same location-id) as the model, otherwise an
|
638
|
+
# INVALID_ARGUMENT (400) error is returned.
|
639
|
+
# @param labels [::Hash{::String => ::String}]
|
640
|
+
# Optional. The labels with user-defined metadata for the request.
|
641
|
+
#
|
642
|
+
# Label keys and values can be no longer than 63 characters (Unicode
|
643
|
+
# codepoints), can only contain lowercase letters, numeric characters,
|
644
|
+
# underscores and dashes. International characters are allowed. Label values
|
645
|
+
# are optional. Label keys must start with a letter.
|
646
|
+
#
|
647
|
+
# See https://cloud.google.com/translate/docs/advanced/labels for more
|
648
|
+
# information.
|
649
|
+
#
|
650
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
651
|
+
# @yieldparam response [::Google::Cloud::Translate::V3::TranslateDocumentResponse]
|
652
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
653
|
+
#
|
654
|
+
# @return [::Google::Cloud::Translate::V3::TranslateDocumentResponse]
|
655
|
+
#
|
656
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
657
|
+
#
|
658
|
+
# @example Basic example
|
659
|
+
# require "google/cloud/translate/v3"
|
660
|
+
#
|
661
|
+
# # Create a client object. The client can be reused for multiple calls.
|
662
|
+
# client = Google::Cloud::Translate::V3::TranslationService::Client.new
|
663
|
+
#
|
664
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
665
|
+
# request = Google::Cloud::Translate::V3::TranslateDocumentRequest.new
|
666
|
+
#
|
667
|
+
# # Call the translate_document method.
|
668
|
+
# result = client.translate_document request
|
669
|
+
#
|
670
|
+
# # The returned object is of type Google::Cloud::Translate::V3::TranslateDocumentResponse.
|
671
|
+
# p result
|
672
|
+
#
|
673
|
+
def translate_document request, options = nil
|
674
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
675
|
+
|
676
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::TranslateDocumentRequest
|
677
|
+
|
678
|
+
# Converts hash and nil to an options object
|
679
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
680
|
+
|
681
|
+
# Customize the options with defaults
|
682
|
+
metadata = @config.rpcs.translate_document.metadata.to_h
|
683
|
+
|
684
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
685
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
686
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
687
|
+
gapic_version: ::Google::Cloud::Translate::V3::VERSION
|
688
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
689
|
+
|
690
|
+
header_params = {}
|
691
|
+
if request.parent
|
692
|
+
header_params["parent"] = request.parent
|
693
|
+
end
|
694
|
+
|
695
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
696
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
697
|
+
|
698
|
+
options.apply_defaults timeout: @config.rpcs.translate_document.timeout,
|
699
|
+
metadata: metadata,
|
700
|
+
retry_policy: @config.rpcs.translate_document.retry_policy
|
701
|
+
|
702
|
+
options.apply_defaults timeout: @config.timeout,
|
703
|
+
metadata: @config.metadata,
|
704
|
+
retry_policy: @config.retry_policy
|
705
|
+
|
706
|
+
@translation_service_stub.call_rpc :translate_document, request, options: options do |response, operation|
|
707
|
+
yield response, operation if block_given?
|
708
|
+
return response
|
709
|
+
end
|
710
|
+
rescue ::GRPC::BadStatus => e
|
711
|
+
raise ::Google::Cloud::Error.from_error(e)
|
712
|
+
end
|
713
|
+
|
528
714
|
##
|
529
715
|
# Translates a large volume of text in asynchronous batch mode.
|
530
716
|
# This function provides real-time output as the inputs are being processed.
|
@@ -575,14 +761,13 @@ module Google
|
|
575
761
|
#
|
576
762
|
# - General (built-in) models:
|
577
763
|
# `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
|
578
|
-
# `projects/{project-number-or-id}/locations/{location-id}/models/general/base`
|
579
764
|
#
|
580
765
|
#
|
581
766
|
# If the map is empty or a specific model is
|
582
767
|
# not requested for a language pair, then default google model (nmt) is used.
|
583
768
|
# @param input_configs [::Array<::Google::Cloud::Translate::V3::InputConfig, ::Hash>]
|
584
769
|
# Required. Input configurations.
|
585
|
-
# The total number of files matched should be <=
|
770
|
+
# The total number of files matched should be <= 100.
|
586
771
|
# The total content size should be <= 100M Unicode codepoints.
|
587
772
|
# The files must use UTF-8 encoding.
|
588
773
|
# @param output_config [::Google::Cloud::Translate::V3::OutputConfig, ::Hash]
|
@@ -600,7 +785,8 @@ module Google
|
|
600
785
|
# characters, underscores and dashes. International characters are allowed.
|
601
786
|
# Label values are optional. Label keys must start with a letter.
|
602
787
|
#
|
603
|
-
# See https://cloud.google.com/translate/docs/labels for more
|
788
|
+
# See https://cloud.google.com/translate/docs/advanced/labels for more
|
789
|
+
# information.
|
604
790
|
#
|
605
791
|
# @yield [response, operation] Access the result along with the RPC operation
|
606
792
|
# @yieldparam response [::Gapic::Operation]
|
@@ -610,6 +796,28 @@ module Google
|
|
610
796
|
#
|
611
797
|
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
612
798
|
#
|
799
|
+
# @example Basic example
|
800
|
+
# require "google/cloud/translate/v3"
|
801
|
+
#
|
802
|
+
# # Create a client object. The client can be reused for multiple calls.
|
803
|
+
# client = Google::Cloud::Translate::V3::TranslationService::Client.new
|
804
|
+
#
|
805
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
806
|
+
# request = Google::Cloud::Translate::V3::BatchTranslateTextRequest.new
|
807
|
+
#
|
808
|
+
# # Call the batch_translate_text method.
|
809
|
+
# result = client.batch_translate_text request
|
810
|
+
#
|
811
|
+
# # The returned object is of type Gapic::Operation. You can use this
|
812
|
+
# # object to check the status of an operation, cancel it, or wait
|
813
|
+
# # for results. Here is how to block until completion:
|
814
|
+
# result.wait_until_done! timeout: 60
|
815
|
+
# if result.response?
|
816
|
+
# p result.response
|
817
|
+
# else
|
818
|
+
# puts "Error!"
|
819
|
+
# end
|
820
|
+
#
|
613
821
|
def batch_translate_text request, options = nil
|
614
822
|
raise ::ArgumentError, "request must be provided" if request.nil?
|
615
823
|
|
@@ -627,16 +835,20 @@ module Google
|
|
627
835
|
gapic_version: ::Google::Cloud::Translate::V3::VERSION
|
628
836
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
629
837
|
|
630
|
-
header_params = {
|
631
|
-
|
632
|
-
|
838
|
+
header_params = {}
|
839
|
+
if request.parent
|
840
|
+
header_params["parent"] = request.parent
|
841
|
+
end
|
842
|
+
|
633
843
|
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
634
844
|
metadata[:"x-goog-request-params"] ||= request_params_header
|
635
845
|
|
636
846
|
options.apply_defaults timeout: @config.rpcs.batch_translate_text.timeout,
|
637
847
|
metadata: metadata,
|
638
848
|
retry_policy: @config.rpcs.batch_translate_text.retry_policy
|
639
|
-
|
849
|
+
|
850
|
+
options.apply_defaults timeout: @config.timeout,
|
851
|
+
metadata: @config.metadata,
|
640
852
|
retry_policy: @config.retry_policy
|
641
853
|
|
642
854
|
@translation_service_stub.call_rpc :batch_translate_text, request, options: options do |response, operation|
|
@@ -648,6 +860,158 @@ module Google
|
|
648
860
|
raise ::Google::Cloud::Error.from_error(e)
|
649
861
|
end
|
650
862
|
|
863
|
+
##
|
864
|
+
# Translates a large volume of document in asynchronous batch mode.
|
865
|
+
# This function provides real-time output as the inputs are being processed.
|
866
|
+
# If caller cancels a request, the partial results (for an input file, it's
|
867
|
+
# all or nothing) may still be available on the specified output location.
|
868
|
+
#
|
869
|
+
# This call returns immediately and you can use
|
870
|
+
# google.longrunning.Operation.name to poll the status of the call.
|
871
|
+
#
|
872
|
+
# @overload batch_translate_document(request, options = nil)
|
873
|
+
# Pass arguments to `batch_translate_document` via a request object, either of type
|
874
|
+
# {::Google::Cloud::Translate::V3::BatchTranslateDocumentRequest} or an equivalent Hash.
|
875
|
+
#
|
876
|
+
# @param request [::Google::Cloud::Translate::V3::BatchTranslateDocumentRequest, ::Hash]
|
877
|
+
# A request object representing the call parameters. Required. To specify no
|
878
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
879
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
880
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
881
|
+
#
|
882
|
+
# @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)
|
883
|
+
# Pass arguments to `batch_translate_document` via keyword arguments. Note that at
|
884
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
885
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
886
|
+
#
|
887
|
+
# @param parent [::String]
|
888
|
+
# Required. Location to make a regional call.
|
889
|
+
#
|
890
|
+
# Format: `projects/{project-number-or-id}/locations/{location-id}`.
|
891
|
+
#
|
892
|
+
# The `global` location is not supported for batch translation.
|
893
|
+
#
|
894
|
+
# Only AutoML Translation models or glossaries within the same region (have
|
895
|
+
# the same location-id) can be used, otherwise an INVALID_ARGUMENT (400)
|
896
|
+
# error is returned.
|
897
|
+
# @param source_language_code [::String]
|
898
|
+
# Required. The BCP-47 language code of the input document if known, for
|
899
|
+
# example, "en-US" or "sr-Latn". Supported language codes are listed in
|
900
|
+
# Language Support (https://cloud.google.com/translate/docs/languages).
|
901
|
+
# @param target_language_codes [::Array<::String>]
|
902
|
+
# Required. The BCP-47 language code to use for translation of the input
|
903
|
+
# document. Specify up to 10 language codes here.
|
904
|
+
# @param input_configs [::Array<::Google::Cloud::Translate::V3::BatchDocumentInputConfig, ::Hash>]
|
905
|
+
# Required. Input configurations.
|
906
|
+
# The total number of files matched should be <= 100.
|
907
|
+
# The total content size to translate should be <= 100M Unicode codepoints.
|
908
|
+
# The files must use UTF-8 encoding.
|
909
|
+
# @param output_config [::Google::Cloud::Translate::V3::BatchDocumentOutputConfig, ::Hash]
|
910
|
+
# Required. Output configuration.
|
911
|
+
# If 2 input configs match to the same file (that is, same input path),
|
912
|
+
# we don't generate output for duplicate inputs.
|
913
|
+
# @param models [::Hash{::String => ::String}]
|
914
|
+
# Optional. The models to use for translation. Map's key is target language
|
915
|
+
# code. Map's value is the model name. Value can be a built-in general model,
|
916
|
+
# or an AutoML Translation model.
|
917
|
+
#
|
918
|
+
# The value format depends on model type:
|
919
|
+
#
|
920
|
+
# - AutoML Translation models:
|
921
|
+
# `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
|
922
|
+
#
|
923
|
+
# - General (built-in) models:
|
924
|
+
# `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
|
925
|
+
#
|
926
|
+
#
|
927
|
+
# If the map is empty or a specific model is
|
928
|
+
# not requested for a language pair, then default google model (nmt) is used.
|
929
|
+
# @param glossaries [::Hash{::String => ::Google::Cloud::Translate::V3::TranslateTextGlossaryConfig, ::Hash}]
|
930
|
+
# Optional. Glossaries to be applied. It's keyed by target language code.
|
931
|
+
# @param format_conversions [::Hash{::String => ::String}]
|
932
|
+
# Optional. File format conversion map to be applied to all input files.
|
933
|
+
# Map's key is the original mime_type. Map's value is the target mime_type of
|
934
|
+
# translated documents.
|
935
|
+
#
|
936
|
+
# Supported file format conversion includes:
|
937
|
+
# - `application/pdf` to
|
938
|
+
# `application/vnd.openxmlformats-officedocument.wordprocessingml.document`
|
939
|
+
#
|
940
|
+
# If nothing specified, output files will be in the same format as the
|
941
|
+
# original file.
|
942
|
+
#
|
943
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
944
|
+
# @yieldparam response [::Gapic::Operation]
|
945
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
946
|
+
#
|
947
|
+
# @return [::Gapic::Operation]
|
948
|
+
#
|
949
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
950
|
+
#
|
951
|
+
# @example Basic example
|
952
|
+
# require "google/cloud/translate/v3"
|
953
|
+
#
|
954
|
+
# # Create a client object. The client can be reused for multiple calls.
|
955
|
+
# client = Google::Cloud::Translate::V3::TranslationService::Client.new
|
956
|
+
#
|
957
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
958
|
+
# request = Google::Cloud::Translate::V3::BatchTranslateDocumentRequest.new
|
959
|
+
#
|
960
|
+
# # Call the batch_translate_document method.
|
961
|
+
# result = client.batch_translate_document request
|
962
|
+
#
|
963
|
+
# # The returned object is of type Gapic::Operation. You can use this
|
964
|
+
# # object to check the status of an operation, cancel it, or wait
|
965
|
+
# # for results. Here is how to block until completion:
|
966
|
+
# result.wait_until_done! timeout: 60
|
967
|
+
# if result.response?
|
968
|
+
# p result.response
|
969
|
+
# else
|
970
|
+
# puts "Error!"
|
971
|
+
# end
|
972
|
+
#
|
973
|
+
def batch_translate_document request, options = nil
|
974
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
975
|
+
|
976
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Translate::V3::BatchTranslateDocumentRequest
|
977
|
+
|
978
|
+
# Converts hash and nil to an options object
|
979
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
980
|
+
|
981
|
+
# Customize the options with defaults
|
982
|
+
metadata = @config.rpcs.batch_translate_document.metadata.to_h
|
983
|
+
|
984
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
985
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
986
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
987
|
+
gapic_version: ::Google::Cloud::Translate::V3::VERSION
|
988
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
989
|
+
|
990
|
+
header_params = {}
|
991
|
+
if request.parent
|
992
|
+
header_params["parent"] = request.parent
|
993
|
+
end
|
994
|
+
|
995
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
996
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
997
|
+
|
998
|
+
options.apply_defaults timeout: @config.rpcs.batch_translate_document.timeout,
|
999
|
+
metadata: metadata,
|
1000
|
+
retry_policy: @config.rpcs.batch_translate_document.retry_policy
|
1001
|
+
|
1002
|
+
options.apply_defaults timeout: @config.timeout,
|
1003
|
+
metadata: @config.metadata,
|
1004
|
+
retry_policy: @config.retry_policy
|
1005
|
+
|
1006
|
+
@translation_service_stub.call_rpc :batch_translate_document, request, options: options do |response, operation|
|
1007
|
+
response = ::Gapic::Operation.new response, @operations_client, options: options
|
1008
|
+
yield response, operation if block_given?
|
1009
|
+
return response
|
1010
|
+
end
|
1011
|
+
rescue ::GRPC::BadStatus => e
|
1012
|
+
raise ::Google::Cloud::Error.from_error(e)
|
1013
|
+
end
|
1014
|
+
|
651
1015
|
##
|
652
1016
|
# Creates a glossary and returns the long-running operation. Returns
|
653
1017
|
# NOT_FOUND, if the project doesn't exist.
|
@@ -680,6 +1044,28 @@ module Google
|
|
680
1044
|
#
|
681
1045
|
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
682
1046
|
#
|
1047
|
+
# @example Basic example
|
1048
|
+
# require "google/cloud/translate/v3"
|
1049
|
+
#
|
1050
|
+
# # Create a client object. The client can be reused for multiple calls.
|
1051
|
+
# client = Google::Cloud::Translate::V3::TranslationService::Client.new
|
1052
|
+
#
|
1053
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
1054
|
+
# request = Google::Cloud::Translate::V3::CreateGlossaryRequest.new
|
1055
|
+
#
|
1056
|
+
# # Call the create_glossary method.
|
1057
|
+
# result = client.create_glossary request
|
1058
|
+
#
|
1059
|
+
# # The returned object is of type Gapic::Operation. You can use this
|
1060
|
+
# # object to check the status of an operation, cancel it, or wait
|
1061
|
+
# # for results. Here is how to block until completion:
|
1062
|
+
# result.wait_until_done! timeout: 60
|
1063
|
+
# if result.response?
|
1064
|
+
# p result.response
|
1065
|
+
# else
|
1066
|
+
# puts "Error!"
|
1067
|
+
# end
|
1068
|
+
#
|
683
1069
|
def create_glossary request, options = nil
|
684
1070
|
raise ::ArgumentError, "request must be provided" if request.nil?
|
685
1071
|
|
@@ -697,16 +1083,20 @@ module Google
|
|
697
1083
|
gapic_version: ::Google::Cloud::Translate::V3::VERSION
|
698
1084
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
699
1085
|
|
700
|
-
header_params = {
|
701
|
-
|
702
|
-
|
1086
|
+
header_params = {}
|
1087
|
+
if request.parent
|
1088
|
+
header_params["parent"] = request.parent
|
1089
|
+
end
|
1090
|
+
|
703
1091
|
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
704
1092
|
metadata[:"x-goog-request-params"] ||= request_params_header
|
705
1093
|
|
706
1094
|
options.apply_defaults timeout: @config.rpcs.create_glossary.timeout,
|
707
1095
|
metadata: metadata,
|
708
1096
|
retry_policy: @config.rpcs.create_glossary.retry_policy
|
709
|
-
|
1097
|
+
|
1098
|
+
options.apply_defaults timeout: @config.timeout,
|
1099
|
+
metadata: @config.metadata,
|
710
1100
|
retry_policy: @config.retry_policy
|
711
1101
|
|
712
1102
|
@translation_service_stub.call_rpc :create_glossary, request, options: options do |response, operation|
|
@@ -749,7 +1139,20 @@ module Google
|
|
749
1139
|
# The first page is returned if `page_token`is empty or missing.
|
750
1140
|
# @param filter [::String]
|
751
1141
|
# Optional. Filter specifying constraints of a list operation.
|
752
|
-
#
|
1142
|
+
# Specify the constraint by the format of "key=value", where key must be
|
1143
|
+
# "src" or "tgt", and the value must be a valid language code.
|
1144
|
+
# For multiple restrictions, concatenate them by "AND" (uppercase only),
|
1145
|
+
# such as: "src=en-US AND tgt=zh-CN". Notice that the exact match is used
|
1146
|
+
# here, which means using 'en-US' and 'en' can lead to different results,
|
1147
|
+
# which depends on the language code you used when you create the glossary.
|
1148
|
+
# For the unidirectional glossaries, the "src" and "tgt" add restrictions
|
1149
|
+
# on the source and target language code separately.
|
1150
|
+
# For the equivalent term set glossaries, the "src" and/or "tgt" add
|
1151
|
+
# restrictions on the term set.
|
1152
|
+
# For example: "src=en-US AND tgt=zh-CN" will only pick the unidirectional
|
1153
|
+
# glossaries which exactly match the source language code as "en-US" and the
|
1154
|
+
# target language code "zh-CN", but all equivalent term set glossaries which
|
1155
|
+
# contain "en-US" and "zh-CN" in their language set will be picked.
|
753
1156
|
# If missing, no filtering is performed.
|
754
1157
|
#
|
755
1158
|
# @yield [response, operation] Access the result along with the RPC operation
|
@@ -760,6 +1163,27 @@ module Google
|
|
760
1163
|
#
|
761
1164
|
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
762
1165
|
#
|
1166
|
+
# @example Basic example
|
1167
|
+
# require "google/cloud/translate/v3"
|
1168
|
+
#
|
1169
|
+
# # Create a client object. The client can be reused for multiple calls.
|
1170
|
+
# client = Google::Cloud::Translate::V3::TranslationService::Client.new
|
1171
|
+
#
|
1172
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
1173
|
+
# request = Google::Cloud::Translate::V3::ListGlossariesRequest.new
|
1174
|
+
#
|
1175
|
+
# # Call the list_glossaries method.
|
1176
|
+
# result = client.list_glossaries request
|
1177
|
+
#
|
1178
|
+
# # The returned object is of type Gapic::PagedEnumerable. You can
|
1179
|
+
# # iterate over all elements by calling #each, and the enumerable
|
1180
|
+
# # will lazily make API calls to fetch subsequent pages. Other
|
1181
|
+
# # methods are also available for managing paging directly.
|
1182
|
+
# result.each do |response|
|
1183
|
+
# # Each element is of type ::Google::Cloud::Translate::V3::Glossary.
|
1184
|
+
# p response
|
1185
|
+
# end
|
1186
|
+
#
|
763
1187
|
def list_glossaries request, options = nil
|
764
1188
|
raise ::ArgumentError, "request must be provided" if request.nil?
|
765
1189
|
|
@@ -777,16 +1201,20 @@ module Google
|
|
777
1201
|
gapic_version: ::Google::Cloud::Translate::V3::VERSION
|
778
1202
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
779
1203
|
|
780
|
-
header_params = {
|
781
|
-
|
782
|
-
|
1204
|
+
header_params = {}
|
1205
|
+
if request.parent
|
1206
|
+
header_params["parent"] = request.parent
|
1207
|
+
end
|
1208
|
+
|
783
1209
|
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
784
1210
|
metadata[:"x-goog-request-params"] ||= request_params_header
|
785
1211
|
|
786
1212
|
options.apply_defaults timeout: @config.rpcs.list_glossaries.timeout,
|
787
1213
|
metadata: metadata,
|
788
1214
|
retry_policy: @config.rpcs.list_glossaries.retry_policy
|
789
|
-
|
1215
|
+
|
1216
|
+
options.apply_defaults timeout: @config.timeout,
|
1217
|
+
metadata: @config.metadata,
|
790
1218
|
retry_policy: @config.retry_policy
|
791
1219
|
|
792
1220
|
@translation_service_stub.call_rpc :list_glossaries, request, options: options do |response, operation|
|
@@ -828,6 +1256,21 @@ module Google
|
|
828
1256
|
#
|
829
1257
|
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
830
1258
|
#
|
1259
|
+
# @example Basic example
|
1260
|
+
# require "google/cloud/translate/v3"
|
1261
|
+
#
|
1262
|
+
# # Create a client object. The client can be reused for multiple calls.
|
1263
|
+
# client = Google::Cloud::Translate::V3::TranslationService::Client.new
|
1264
|
+
#
|
1265
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
1266
|
+
# request = Google::Cloud::Translate::V3::GetGlossaryRequest.new
|
1267
|
+
#
|
1268
|
+
# # Call the get_glossary method.
|
1269
|
+
# result = client.get_glossary request
|
1270
|
+
#
|
1271
|
+
# # The returned object is of type Google::Cloud::Translate::V3::Glossary.
|
1272
|
+
# p result
|
1273
|
+
#
|
831
1274
|
def get_glossary request, options = nil
|
832
1275
|
raise ::ArgumentError, "request must be provided" if request.nil?
|
833
1276
|
|
@@ -845,16 +1288,20 @@ module Google
|
|
845
1288
|
gapic_version: ::Google::Cloud::Translate::V3::VERSION
|
846
1289
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
847
1290
|
|
848
|
-
header_params = {
|
849
|
-
|
850
|
-
|
1291
|
+
header_params = {}
|
1292
|
+
if request.name
|
1293
|
+
header_params["name"] = request.name
|
1294
|
+
end
|
1295
|
+
|
851
1296
|
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
852
1297
|
metadata[:"x-goog-request-params"] ||= request_params_header
|
853
1298
|
|
854
1299
|
options.apply_defaults timeout: @config.rpcs.get_glossary.timeout,
|
855
1300
|
metadata: metadata,
|
856
1301
|
retry_policy: @config.rpcs.get_glossary.retry_policy
|
857
|
-
|
1302
|
+
|
1303
|
+
options.apply_defaults timeout: @config.timeout,
|
1304
|
+
metadata: @config.metadata,
|
858
1305
|
retry_policy: @config.retry_policy
|
859
1306
|
|
860
1307
|
@translation_service_stub.call_rpc :get_glossary, request, options: options do |response, operation|
|
@@ -896,6 +1343,28 @@ module Google
|
|
896
1343
|
#
|
897
1344
|
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
898
1345
|
#
|
1346
|
+
# @example Basic example
|
1347
|
+
# require "google/cloud/translate/v3"
|
1348
|
+
#
|
1349
|
+
# # Create a client object. The client can be reused for multiple calls.
|
1350
|
+
# client = Google::Cloud::Translate::V3::TranslationService::Client.new
|
1351
|
+
#
|
1352
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
1353
|
+
# request = Google::Cloud::Translate::V3::DeleteGlossaryRequest.new
|
1354
|
+
#
|
1355
|
+
# # Call the delete_glossary method.
|
1356
|
+
# result = client.delete_glossary request
|
1357
|
+
#
|
1358
|
+
# # The returned object is of type Gapic::Operation. You can use this
|
1359
|
+
# # object to check the status of an operation, cancel it, or wait
|
1360
|
+
# # for results. Here is how to block until completion:
|
1361
|
+
# result.wait_until_done! timeout: 60
|
1362
|
+
# if result.response?
|
1363
|
+
# p result.response
|
1364
|
+
# else
|
1365
|
+
# puts "Error!"
|
1366
|
+
# end
|
1367
|
+
#
|
899
1368
|
def delete_glossary request, options = nil
|
900
1369
|
raise ::ArgumentError, "request must be provided" if request.nil?
|
901
1370
|
|
@@ -913,16 +1382,20 @@ module Google
|
|
913
1382
|
gapic_version: ::Google::Cloud::Translate::V3::VERSION
|
914
1383
|
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
915
1384
|
|
916
|
-
header_params = {
|
917
|
-
|
918
|
-
|
1385
|
+
header_params = {}
|
1386
|
+
if request.name
|
1387
|
+
header_params["name"] = request.name
|
1388
|
+
end
|
1389
|
+
|
919
1390
|
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
920
1391
|
metadata[:"x-goog-request-params"] ||= request_params_header
|
921
1392
|
|
922
1393
|
options.apply_defaults timeout: @config.rpcs.delete_glossary.timeout,
|
923
1394
|
metadata: metadata,
|
924
1395
|
retry_policy: @config.rpcs.delete_glossary.retry_policy
|
925
|
-
|
1396
|
+
|
1397
|
+
options.apply_defaults timeout: @config.timeout,
|
1398
|
+
metadata: @config.metadata,
|
926
1399
|
retry_policy: @config.retry_policy
|
927
1400
|
|
928
1401
|
@translation_service_stub.call_rpc :delete_glossary, request, options: options do |response, operation|
|
@@ -947,22 +1420,21 @@ module Google
|
|
947
1420
|
# Configuration can be applied globally to all clients, or to a single client
|
948
1421
|
# on construction.
|
949
1422
|
#
|
950
|
-
#
|
951
|
-
#
|
952
|
-
# To modify the global config, setting the timeout for translate_text
|
953
|
-
# to 20 seconds, and all remaining timeouts to 10 seconds:
|
1423
|
+
# @example
|
954
1424
|
#
|
955
|
-
#
|
956
|
-
#
|
957
|
-
#
|
958
|
-
#
|
1425
|
+
# # Modify the global config, setting the timeout for
|
1426
|
+
# # translate_text to 20 seconds,
|
1427
|
+
# # and all remaining timeouts to 10 seconds.
|
1428
|
+
# ::Google::Cloud::Translate::V3::TranslationService::Client.configure do |config|
|
1429
|
+
# config.timeout = 10.0
|
1430
|
+
# config.rpcs.translate_text.timeout = 20.0
|
1431
|
+
# end
|
959
1432
|
#
|
960
|
-
#
|
961
|
-
#
|
962
|
-
#
|
963
|
-
#
|
964
|
-
#
|
965
|
-
# end
|
1433
|
+
# # Apply the above configuration only to a new client.
|
1434
|
+
# client = ::Google::Cloud::Translate::V3::TranslationService::Client.new do |config|
|
1435
|
+
# config.timeout = 10.0
|
1436
|
+
# config.rpcs.translate_text.timeout = 20.0
|
1437
|
+
# end
|
966
1438
|
#
|
967
1439
|
# @!attribute [rw] endpoint
|
968
1440
|
# The hostname or hostname:port of the service endpoint.
|
@@ -1086,11 +1558,21 @@ module Google
|
|
1086
1558
|
#
|
1087
1559
|
attr_reader :get_supported_languages
|
1088
1560
|
##
|
1561
|
+
# RPC-specific configuration for `translate_document`
|
1562
|
+
# @return [::Gapic::Config::Method]
|
1563
|
+
#
|
1564
|
+
attr_reader :translate_document
|
1565
|
+
##
|
1089
1566
|
# RPC-specific configuration for `batch_translate_text`
|
1090
1567
|
# @return [::Gapic::Config::Method]
|
1091
1568
|
#
|
1092
1569
|
attr_reader :batch_translate_text
|
1093
1570
|
##
|
1571
|
+
# RPC-specific configuration for `batch_translate_document`
|
1572
|
+
# @return [::Gapic::Config::Method]
|
1573
|
+
#
|
1574
|
+
attr_reader :batch_translate_document
|
1575
|
+
##
|
1094
1576
|
# RPC-specific configuration for `create_glossary`
|
1095
1577
|
# @return [::Gapic::Config::Method]
|
1096
1578
|
#
|
@@ -1119,8 +1601,12 @@ module Google
|
|
1119
1601
|
@detect_language = ::Gapic::Config::Method.new detect_language_config
|
1120
1602
|
get_supported_languages_config = parent_rpcs.get_supported_languages if parent_rpcs.respond_to? :get_supported_languages
|
1121
1603
|
@get_supported_languages = ::Gapic::Config::Method.new get_supported_languages_config
|
1604
|
+
translate_document_config = parent_rpcs.translate_document if parent_rpcs.respond_to? :translate_document
|
1605
|
+
@translate_document = ::Gapic::Config::Method.new translate_document_config
|
1122
1606
|
batch_translate_text_config = parent_rpcs.batch_translate_text if parent_rpcs.respond_to? :batch_translate_text
|
1123
1607
|
@batch_translate_text = ::Gapic::Config::Method.new batch_translate_text_config
|
1608
|
+
batch_translate_document_config = parent_rpcs.batch_translate_document if parent_rpcs.respond_to? :batch_translate_document
|
1609
|
+
@batch_translate_document = ::Gapic::Config::Method.new batch_translate_document_config
|
1124
1610
|
create_glossary_config = parent_rpcs.create_glossary if parent_rpcs.respond_to? :create_glossary
|
1125
1611
|
@create_glossary = ::Gapic::Config::Method.new create_glossary_config
|
1126
1612
|
list_glossaries_config = parent_rpcs.list_glossaries if parent_rpcs.respond_to? :list_glossaries
|