Skip to content
This repository was archived by the owner on Oct 14, 2023. It is now read-only.

Commit 89d2849

Browse files
feat: added v3 proto for online/batch document translation and updated v3beta1 proto for format conversion (#767)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 393656336 Source-Link: googleapis/googleapis@17d3fb2 Source-Link: https://github.com/googleapis/googleapis-gen/commit/00ca50bdde80906d6f62314ef4f7630b8cdb6e15
1 parent 2f3e33e commit 89d2849

File tree

87 files changed

+34421
-918
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+34421
-918
lines changed

google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceClient.java

Lines changed: 188 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ public final OperationsClient getOperationsClient() {
194194
* @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
195195
* input text, set to one of the language codes listed in Language Support.
196196
* @param contents Required. The content of the input in string format. We recommend the total
197-
* content be less than 30k codepoints. Use BatchTranslateText for larger text.
197+
* content be less than 30k codepoints. The max length of this field is 1024. Use
198+
* BatchTranslateText for larger text.
198199
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
199200
*/
200201
public final TranslateTextResponse translateText(
@@ -235,7 +236,8 @@ public final TranslateTextResponse translateText(
235236
* @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
236237
* input text, set to one of the language codes listed in Language Support.
237238
* @param contents Required. The content of the input in string format. We recommend the total
238-
* content be less than 30k codepoints. Use BatchTranslateText for larger text.
239+
* content be less than 30k codepoints. The max length of this field is 1024. Use
240+
* BatchTranslateText for larger text.
239241
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
240242
*/
241243
public final TranslateTextResponse translateText(
@@ -283,10 +285,9 @@ public final TranslateTextResponse translateText(
283285
* `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
284286
* <p>- General (built-in) models:
285287
* `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
286-
* `projects/{project-number-or-id}/locations/{location-id}/models/general/base`
287288
* <p>For global (non-regionalized) requests, use `location-id` `global`. For example,
288289
* `projects/{project-number-or-id}/locations/global/models/general/nmt`.
289-
* <p>If missing, the system decides which google base model to use.
290+
* <p>If not provided, the default Google model (NMT) will be used.
290291
* @param mimeType Optional. The format of the source text, for example, "text/html",
291292
* "text/plain". If left blank, the MIME type defaults to "text/html".
292293
* @param sourceLanguageCode Optional. The BCP-47 language code of the input text if known, for
@@ -296,7 +297,8 @@ public final TranslateTextResponse translateText(
296297
* @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
297298
* input text, set to one of the language codes listed in Language Support.
298299
* @param contents Required. The content of the input in string format. We recommend the total
299-
* content be less than 30k codepoints. Use BatchTranslateText for larger text.
300+
* content be less than 30k codepoints. The max length of this field is 1024. Use
301+
* BatchTranslateText for larger text.
300302
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
301303
*/
302304
public final TranslateTextResponse translateText(
@@ -352,10 +354,9 @@ public final TranslateTextResponse translateText(
352354
* `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
353355
* <p>- General (built-in) models:
354356
* `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
355-
* `projects/{project-number-or-id}/locations/{location-id}/models/general/base`
356357
* <p>For global (non-regionalized) requests, use `location-id` `global`. For example,
357358
* `projects/{project-number-or-id}/locations/global/models/general/nmt`.
358-
* <p>If missing, the system decides which google base model to use.
359+
* <p>If not provided, the default Google model (NMT) will be used.
359360
* @param mimeType Optional. The format of the source text, for example, "text/html",
360361
* "text/plain". If left blank, the MIME type defaults to "text/html".
361362
* @param sourceLanguageCode Optional. The BCP-47 language code of the input text if known, for
@@ -365,7 +366,8 @@ public final TranslateTextResponse translateText(
365366
* @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
366367
* input text, set to one of the language codes listed in Language Support.
367368
* @param contents Required. The content of the input in string format. We recommend the total
368-
* content be less than 30k codepoints. Use BatchTranslateText for larger text.
369+
* content be less than 30k codepoints. The max length of this field is 1024. Use
370+
* BatchTranslateText for larger text.
369371
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
370372
*/
371373
public final TranslateTextResponse translateText(
@@ -624,9 +626,8 @@ public final DetectLanguageResponse detectLanguage(DetectLanguageRequest request
624626
* `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
625627
* <p>- General (built-in) models:
626628
* `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
627-
* `projects/{project-number-or-id}/locations/{location-id}/models/general/base`
628629
* <p>Returns languages supported by the specified model. If missing, we get supported
629-
* languages of Google general base (PBMT) model.
630+
* languages of Google general NMT model.
630631
* @param displayLanguageCode Optional. The language to use to return localized, human readable
631632
* names of supported languages. If missing, then display names are not returned in a
632633
* response.
@@ -673,9 +674,8 @@ public final SupportedLanguages getSupportedLanguages(
673674
* `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
674675
* <p>- General (built-in) models:
675676
* `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
676-
* `projects/{project-number-or-id}/locations/{location-id}/models/general/base`
677677
* <p>Returns languages supported by the specified model. If missing, we get supported
678-
* languages of Google general base (PBMT) model.
678+
* languages of Google general NMT model.
679679
* @param displayLanguageCode Optional. The language to use to return localized, human readable
680680
* names of supported languages. If missing, then display names are not returned in a
681681
* response.
@@ -743,6 +743,67 @@ public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesReque
743743
return stub.getSupportedLanguagesCallable();
744744
}
745745

746+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
747+
/**
748+
* Translates documents in synchronous mode.
749+
*
750+
* <p>Sample code:
751+
*
752+
* <pre>{@code
753+
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
754+
* TranslateDocumentRequest request =
755+
* TranslateDocumentRequest.newBuilder()
756+
* .setParent("parent-995424086")
757+
* .setSourceLanguageCode("sourceLanguageCode1645917472")
758+
* .setTargetLanguageCode("targetLanguageCode-106414698")
759+
* .setDocumentInputConfig(DocumentInputConfig.newBuilder().build())
760+
* .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build())
761+
* .setModel("model104069929")
762+
* .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
763+
* .putAllLabels(new HashMap<String, String>())
764+
* .build();
765+
* TranslateDocumentResponse response = translationServiceClient.translateDocument(request);
766+
* }
767+
* }</pre>
768+
*
769+
* @param request The request object containing all of the parameters for the API call.
770+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
771+
*/
772+
public final TranslateDocumentResponse translateDocument(TranslateDocumentRequest request) {
773+
return translateDocumentCallable().call(request);
774+
}
775+
776+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
777+
/**
778+
* Translates documents in synchronous mode.
779+
*
780+
* <p>Sample code:
781+
*
782+
* <pre>{@code
783+
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
784+
* TranslateDocumentRequest request =
785+
* TranslateDocumentRequest.newBuilder()
786+
* .setParent("parent-995424086")
787+
* .setSourceLanguageCode("sourceLanguageCode1645917472")
788+
* .setTargetLanguageCode("targetLanguageCode-106414698")
789+
* .setDocumentInputConfig(DocumentInputConfig.newBuilder().build())
790+
* .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build())
791+
* .setModel("model104069929")
792+
* .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
793+
* .putAllLabels(new HashMap<String, String>())
794+
* .build();
795+
* ApiFuture<TranslateDocumentResponse> future =
796+
* translationServiceClient.translateDocumentCallable().futureCall(request);
797+
* // Do something.
798+
* TranslateDocumentResponse response = future.get();
799+
* }
800+
* }</pre>
801+
*/
802+
public final UnaryCallable<TranslateDocumentRequest, TranslateDocumentResponse>
803+
translateDocumentCallable() {
804+
return stub.translateDocumentCallable();
805+
}
806+
746807
// AUTO-GENERATED DOCUMENTATION AND METHOD.
747808
/**
748809
* Translates a large volume of text in asynchronous batch mode. This function provides real-time
@@ -852,6 +913,121 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
852913
return stub.batchTranslateTextCallable();
853914
}
854915

916+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
917+
/**
918+
* Translates a large volume of document in asynchronous batch mode. This function provides
919+
* real-time output as the inputs are being processed. If caller cancels a request, the partial
920+
* results (for an input file, it's all or nothing) may still be available on the specified output
921+
* location.
922+
*
923+
* <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the
924+
* status of the call.
925+
*
926+
* <p>Sample code:
927+
*
928+
* <pre>{@code
929+
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
930+
* BatchTranslateDocumentRequest request =
931+
* BatchTranslateDocumentRequest.newBuilder()
932+
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
933+
* .setSourceLanguageCode("sourceLanguageCode1645917472")
934+
* .addAllTargetLanguageCodes(new ArrayList<String>())
935+
* .addAllInputConfigs(new ArrayList<BatchDocumentInputConfig>())
936+
* .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build())
937+
* .putAllModels(new HashMap<String, String>())
938+
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
939+
* .putAllFormatConversions(new HashMap<String, String>())
940+
* .build();
941+
* BatchTranslateDocumentResponse response =
942+
* translationServiceClient.batchTranslateDocumentAsync(request).get();
943+
* }
944+
* }</pre>
945+
*
946+
* @param request The request object containing all of the parameters for the API call.
947+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
948+
*/
949+
public final OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata>
950+
batchTranslateDocumentAsync(BatchTranslateDocumentRequest request) {
951+
return batchTranslateDocumentOperationCallable().futureCall(request);
952+
}
953+
954+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
955+
/**
956+
* Translates a large volume of document in asynchronous batch mode. This function provides
957+
* real-time output as the inputs are being processed. If caller cancels a request, the partial
958+
* results (for an input file, it's all or nothing) may still be available on the specified output
959+
* location.
960+
*
961+
* <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the
962+
* status of the call.
963+
*
964+
* <p>Sample code:
965+
*
966+
* <pre>{@code
967+
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
968+
* BatchTranslateDocumentRequest request =
969+
* BatchTranslateDocumentRequest.newBuilder()
970+
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
971+
* .setSourceLanguageCode("sourceLanguageCode1645917472")
972+
* .addAllTargetLanguageCodes(new ArrayList<String>())
973+
* .addAllInputConfigs(new ArrayList<BatchDocumentInputConfig>())
974+
* .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build())
975+
* .putAllModels(new HashMap<String, String>())
976+
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
977+
* .putAllFormatConversions(new HashMap<String, String>())
978+
* .build();
979+
* OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> future =
980+
* translationServiceClient.batchTranslateDocumentOperationCallable().futureCall(request);
981+
* // Do something.
982+
* BatchTranslateDocumentResponse response = future.get();
983+
* }
984+
* }</pre>
985+
*/
986+
public final OperationCallable<
987+
BatchTranslateDocumentRequest,
988+
BatchTranslateDocumentResponse,
989+
BatchTranslateDocumentMetadata>
990+
batchTranslateDocumentOperationCallable() {
991+
return stub.batchTranslateDocumentOperationCallable();
992+
}
993+
994+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
995+
/**
996+
* Translates a large volume of document in asynchronous batch mode. This function provides
997+
* real-time output as the inputs are being processed. If caller cancels a request, the partial
998+
* results (for an input file, it's all or nothing) may still be available on the specified output
999+
* location.
1000+
*
1001+
* <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the
1002+
* status of the call.
1003+
*
1004+
* <p>Sample code:
1005+
*
1006+
* <pre>{@code
1007+
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
1008+
* BatchTranslateDocumentRequest request =
1009+
* BatchTranslateDocumentRequest.newBuilder()
1010+
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
1011+
* .setSourceLanguageCode("sourceLanguageCode1645917472")
1012+
* .addAllTargetLanguageCodes(new ArrayList<String>())
1013+
* .addAllInputConfigs(new ArrayList<BatchDocumentInputConfig>())
1014+
* .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build())
1015+
* .putAllModels(new HashMap<String, String>())
1016+
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
1017+
* .putAllFormatConversions(new HashMap<String, String>())
1018+
* .build();
1019+
* ApiFuture<Operation> future =
1020+
* translationServiceClient.batchTranslateDocumentCallable().futureCall(request);
1021+
* // Do something.
1022+
* Operation response = future.get();
1023+
* }
1024+
* }</pre>
1025+
*/
1026+
public final UnaryCallable<BatchTranslateDocumentRequest, Operation>
1027+
batchTranslateDocumentCallable() {
1028+
return stub.batchTranslateDocumentCallable();
1029+
}
1030+
8551031
// AUTO-GENERATED DOCUMENTATION AND METHOD.
8561032
/**
8571033
* Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project

google-cloud-translate/src/main/java/com/google/cloud/translate/v3/TranslationServiceSettings.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ public UnaryCallSettings<DetectLanguageRequest, DetectLanguageResponse> detectLa
8888
return ((TranslationServiceStubSettings) getStubSettings()).getSupportedLanguagesSettings();
8989
}
9090

91+
/** Returns the object with the settings used for calls to translateDocument. */
92+
public UnaryCallSettings<TranslateDocumentRequest, TranslateDocumentResponse>
93+
translateDocumentSettings() {
94+
return ((TranslationServiceStubSettings) getStubSettings()).translateDocumentSettings();
95+
}
96+
9197
/** Returns the object with the settings used for calls to batchTranslateText. */
9298
public UnaryCallSettings<BatchTranslateTextRequest, Operation> batchTranslateTextSettings() {
9399
return ((TranslationServiceStubSettings) getStubSettings()).batchTranslateTextSettings();
@@ -101,6 +107,22 @@ public UnaryCallSettings<BatchTranslateTextRequest, Operation> batchTranslateTex
101107
.batchTranslateTextOperationSettings();
102108
}
103109

110+
/** Returns the object with the settings used for calls to batchTranslateDocument. */
111+
public UnaryCallSettings<BatchTranslateDocumentRequest, Operation>
112+
batchTranslateDocumentSettings() {
113+
return ((TranslationServiceStubSettings) getStubSettings()).batchTranslateDocumentSettings();
114+
}
115+
116+
/** Returns the object with the settings used for calls to batchTranslateDocument. */
117+
public OperationCallSettings<
118+
BatchTranslateDocumentRequest,
119+
BatchTranslateDocumentResponse,
120+
BatchTranslateDocumentMetadata>
121+
batchTranslateDocumentOperationSettings() {
122+
return ((TranslationServiceStubSettings) getStubSettings())
123+
.batchTranslateDocumentOperationSettings();
124+
}
125+
104126
/** Returns the object with the settings used for calls to createGlossary. */
105127
public UnaryCallSettings<CreateGlossaryRequest, Operation> createGlossarySettings() {
106128
return ((TranslationServiceStubSettings) getStubSettings()).createGlossarySettings();
@@ -251,6 +273,12 @@ public Builder applyToAllUnaryMethods(
251273
return getStubSettingsBuilder().getSupportedLanguagesSettings();
252274
}
253275

276+
/** Returns the builder for the settings used for calls to translateDocument. */
277+
public UnaryCallSettings.Builder<TranslateDocumentRequest, TranslateDocumentResponse>
278+
translateDocumentSettings() {
279+
return getStubSettingsBuilder().translateDocumentSettings();
280+
}
281+
254282
/** Returns the builder for the settings used for calls to batchTranslateText. */
255283
public UnaryCallSettings.Builder<BatchTranslateTextRequest, Operation>
256284
batchTranslateTextSettings() {
@@ -264,6 +292,21 @@ public Builder applyToAllUnaryMethods(
264292
return getStubSettingsBuilder().batchTranslateTextOperationSettings();
265293
}
266294

295+
/** Returns the builder for the settings used for calls to batchTranslateDocument. */
296+
public UnaryCallSettings.Builder<BatchTranslateDocumentRequest, Operation>
297+
batchTranslateDocumentSettings() {
298+
return getStubSettingsBuilder().batchTranslateDocumentSettings();
299+
}
300+
301+
/** Returns the builder for the settings used for calls to batchTranslateDocument. */
302+
public OperationCallSettings.Builder<
303+
BatchTranslateDocumentRequest,
304+
BatchTranslateDocumentResponse,
305+
BatchTranslateDocumentMetadata>
306+
batchTranslateDocumentOperationSettings() {
307+
return getStubSettingsBuilder().batchTranslateDocumentOperationSettings();
308+
}
309+
267310
/** Returns the builder for the settings used for calls to createGlossary. */
268311
public UnaryCallSettings.Builder<CreateGlossaryRequest, Operation> createGlossarySettings() {
269312
return getStubSettingsBuilder().createGlossarySettings();

google-cloud-translate/src/main/java/com/google/cloud/translate/v3/gapic_metadata.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"grpc": {
1111
"libraryClient": "TranslationServiceClient",
1212
"rpcs": {
13+
"BatchTranslateDocument": {
14+
"methods": ["batchTranslateDocumentAsync", "batchTranslateDocumentOperationCallable", "batchTranslateDocumentCallable"]
15+
},
1316
"BatchTranslateText": {
1417
"methods": ["batchTranslateTextAsync", "batchTranslateTextOperationCallable", "batchTranslateTextCallable"]
1518
},
@@ -31,6 +34,9 @@
3134
"ListGlossaries": {
3235
"methods": ["listGlossaries", "listGlossaries", "listGlossaries", "listGlossariesPagedCallable", "listGlossariesCallable"]
3336
},
37+
"TranslateDocument": {
38+
"methods": ["translateDocument", "translateDocumentCallable"]
39+
},
3440
"TranslateText": {
3541
"methods": ["translateText", "translateText", "translateText", "translateText", "translateText", "translateTextCallable"]
3642
}

google-cloud-translate/src/main/java/com/google/cloud/translate/v3/package-info.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
*/
1616

1717
/**
18-
* The interfaces provided are listed below, along with usage samples.
18+
* A client to Cloud Translation API
19+
*
20+
* <p>The interfaces provided are listed below, along with usage samples.
1921
*
2022
* <p>======================= TranslationServiceClient =======================
2123
*

0 commit comments

Comments
 (0)