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

Commit 4e911b5

Browse files
fix: add model signature for batch document translation (#832)
* fix: add model signature for batch document translation PiperOrigin-RevId: 403140062 Source-Link: googleapis/googleapis@67e6e0a Source-Link: https://github.com/googleapis/googleapis-gen/commit/779ead92cdc2433d84ae5ae53418b1600843224e Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNzc5ZWFkOTJjZGMyNDMzZDg0YWU1YWU1MzQxOGIxNjAwODQzMjI0ZSJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 5ea9747 commit 4e911b5

File tree

10 files changed

+462
-76
lines changed

10 files changed

+462
-76
lines changed

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

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,130 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
913913
return stub.batchTranslateTextCallable();
914914
}
915915

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+
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
931+
* String sourceLanguageCode = "sourceLanguageCode1645917472";
932+
* List<String> targetLanguageCodes = new ArrayList<>();
933+
* List<BatchDocumentInputConfig> inputConfigs = new ArrayList<>();
934+
* BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build();
935+
* BatchTranslateDocumentResponse response =
936+
* translationServiceClient
937+
* .batchTranslateDocumentAsync(
938+
* parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig)
939+
* .get();
940+
* }
941+
* }</pre>
942+
*
943+
* @param parent Required. Location to make a regional call.
944+
* <p>Format: `projects/{project-number-or-id}/locations/{location-id}`.
945+
* <p>The `global` location is not supported for batch translation.
946+
* <p>Only AutoML Translation models or glossaries within the same region (have the same
947+
* location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
948+
* @param sourceLanguageCode Required. The BCP-47 language code of the input document if known,
949+
* for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support
950+
* (https://cloud.google.com/translate/docs/languages).
951+
* @param targetLanguageCodes Required. The BCP-47 language code to use for translation of the
952+
* input document. Specify up to 10 language codes here.
953+
* @param inputConfigs Required. Input configurations. The total number of files matched should be
954+
* &lt;= 100. The total content size to translate should be &lt;= 100M Unicode codepoints. The
955+
* files must use UTF-8 encoding.
956+
* @param outputConfig Required. Output configuration. If 2 input configs match to the same file
957+
* (that is, same input path), we don't generate output for duplicate inputs.
958+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
959+
*/
960+
public final OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata>
961+
batchTranslateDocumentAsync(
962+
LocationName parent,
963+
String sourceLanguageCode,
964+
List<String> targetLanguageCodes,
965+
List<BatchDocumentInputConfig> inputConfigs,
966+
BatchDocumentOutputConfig outputConfig) {
967+
BatchTranslateDocumentRequest request =
968+
BatchTranslateDocumentRequest.newBuilder()
969+
.setParent(parent == null ? null : parent.toString())
970+
.setSourceLanguageCode(sourceLanguageCode)
971+
.addAllTargetLanguageCodes(targetLanguageCodes)
972+
.addAllInputConfigs(inputConfigs)
973+
.setOutputConfig(outputConfig)
974+
.build();
975+
return batchTranslateDocumentAsync(request);
976+
}
977+
978+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
979+
/**
980+
* Translates a large volume of document in asynchronous batch mode. This function provides
981+
* real-time output as the inputs are being processed. If caller cancels a request, the partial
982+
* results (for an input file, it's all or nothing) may still be available on the specified output
983+
* location.
984+
*
985+
* <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the
986+
* status of the call.
987+
*
988+
* <p>Sample code:
989+
*
990+
* <pre>{@code
991+
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
992+
* String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
993+
* String sourceLanguageCode = "sourceLanguageCode1645917472";
994+
* List<String> targetLanguageCodes = new ArrayList<>();
995+
* List<BatchDocumentInputConfig> inputConfigs = new ArrayList<>();
996+
* BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build();
997+
* BatchTranslateDocumentResponse response =
998+
* translationServiceClient
999+
* .batchTranslateDocumentAsync(
1000+
* parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig)
1001+
* .get();
1002+
* }
1003+
* }</pre>
1004+
*
1005+
* @param parent Required. Location to make a regional call.
1006+
* <p>Format: `projects/{project-number-or-id}/locations/{location-id}`.
1007+
* <p>The `global` location is not supported for batch translation.
1008+
* <p>Only AutoML Translation models or glossaries within the same region (have the same
1009+
* location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
1010+
* @param sourceLanguageCode Required. The BCP-47 language code of the input document if known,
1011+
* for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support
1012+
* (https://cloud.google.com/translate/docs/languages).
1013+
* @param targetLanguageCodes Required. The BCP-47 language code to use for translation of the
1014+
* input document. Specify up to 10 language codes here.
1015+
* @param inputConfigs Required. Input configurations. The total number of files matched should be
1016+
* &lt;= 100. The total content size to translate should be &lt;= 100M Unicode codepoints. The
1017+
* files must use UTF-8 encoding.
1018+
* @param outputConfig Required. Output configuration. If 2 input configs match to the same file
1019+
* (that is, same input path), we don't generate output for duplicate inputs.
1020+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
1021+
*/
1022+
public final OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata>
1023+
batchTranslateDocumentAsync(
1024+
String parent,
1025+
String sourceLanguageCode,
1026+
List<String> targetLanguageCodes,
1027+
List<BatchDocumentInputConfig> inputConfigs,
1028+
BatchDocumentOutputConfig outputConfig) {
1029+
BatchTranslateDocumentRequest request =
1030+
BatchTranslateDocumentRequest.newBuilder()
1031+
.setParent(parent)
1032+
.setSourceLanguageCode(sourceLanguageCode)
1033+
.addAllTargetLanguageCodes(targetLanguageCodes)
1034+
.addAllInputConfigs(inputConfigs)
1035+
.setOutputConfig(outputConfig)
1036+
.build();
1037+
return batchTranslateDocumentAsync(request);
1038+
}
1039+
9161040
// AUTO-GENERATED DOCUMENTATION AND METHOD.
9171041
/**
9181042
* Translates a large volume of document in asynchronous batch mode. This function provides

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"libraryClient": "TranslationServiceClient",
1212
"rpcs": {
1313
"BatchTranslateDocument": {
14-
"methods": ["batchTranslateDocumentAsync", "batchTranslateDocumentOperationCallable", "batchTranslateDocumentCallable"]
14+
"methods": ["batchTranslateDocumentAsync", "batchTranslateDocumentAsync", "batchTranslateDocumentAsync", "batchTranslateDocumentOperationCallable", "batchTranslateDocumentCallable"]
1515
},
1616
"BatchTranslateText": {
1717
"methods": ["batchTranslateTextAsync", "batchTranslateTextOperationCallable", "batchTranslateTextCallable"]

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

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,130 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
692692
return stub.batchTranslateTextCallable();
693693
}
694694

695+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
696+
/**
697+
* Translates a large volume of documents in asynchronous batch mode. This function provides
698+
* real-time output as the inputs are being processed. If caller cancels a request, the partial
699+
* results (for an input file, it's all or nothing) may still be available on the specified output
700+
* location.
701+
*
702+
* <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the
703+
* status of the call.
704+
*
705+
* <p>Sample code:
706+
*
707+
* <pre>{@code
708+
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
709+
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
710+
* String sourceLanguageCode = "sourceLanguageCode1645917472";
711+
* List<String> targetLanguageCodes = new ArrayList<>();
712+
* List<BatchDocumentInputConfig> inputConfigs = new ArrayList<>();
713+
* BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build();
714+
* BatchTranslateDocumentResponse response =
715+
* translationServiceClient
716+
* .batchTranslateDocumentAsync(
717+
* parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig)
718+
* .get();
719+
* }
720+
* }</pre>
721+
*
722+
* @param parent Required. Location to make a regional call.
723+
* <p>Format: `projects/{project-number-or-id}/locations/{location-id}`.
724+
* <p>The `global` location is not supported for batch translation.
725+
* <p>Only AutoML Translation models or glossaries within the same region (have the same
726+
* location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
727+
* @param sourceLanguageCode Required. The BCP-47 language code of the input document if known,
728+
* for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support
729+
* (https://cloud.google.com/translate/docs/languages).
730+
* @param targetLanguageCodes Required. The BCP-47 language code to use for translation of the
731+
* input document. Specify up to 10 language codes here.
732+
* @param inputConfigs Required. Input configurations. The total number of files matched should be
733+
* &lt;= 100. The total content size to translate should be &lt;= 100M Unicode codepoints. The
734+
* files must use UTF-8 encoding.
735+
* @param outputConfig Required. Output configuration. If 2 input configs match to the same file
736+
* (that is, same input path), we don't generate output for duplicate inputs.
737+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
738+
*/
739+
public final OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata>
740+
batchTranslateDocumentAsync(
741+
LocationName parent,
742+
String sourceLanguageCode,
743+
List<String> targetLanguageCodes,
744+
List<BatchDocumentInputConfig> inputConfigs,
745+
BatchDocumentOutputConfig outputConfig) {
746+
BatchTranslateDocumentRequest request =
747+
BatchTranslateDocumentRequest.newBuilder()
748+
.setParent(parent == null ? null : parent.toString())
749+
.setSourceLanguageCode(sourceLanguageCode)
750+
.addAllTargetLanguageCodes(targetLanguageCodes)
751+
.addAllInputConfigs(inputConfigs)
752+
.setOutputConfig(outputConfig)
753+
.build();
754+
return batchTranslateDocumentAsync(request);
755+
}
756+
757+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
758+
/**
759+
* Translates a large volume of documents in asynchronous batch mode. This function provides
760+
* real-time output as the inputs are being processed. If caller cancels a request, the partial
761+
* results (for an input file, it's all or nothing) may still be available on the specified output
762+
* location.
763+
*
764+
* <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the
765+
* status of the call.
766+
*
767+
* <p>Sample code:
768+
*
769+
* <pre>{@code
770+
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
771+
* String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
772+
* String sourceLanguageCode = "sourceLanguageCode1645917472";
773+
* List<String> targetLanguageCodes = new ArrayList<>();
774+
* List<BatchDocumentInputConfig> inputConfigs = new ArrayList<>();
775+
* BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build();
776+
* BatchTranslateDocumentResponse response =
777+
* translationServiceClient
778+
* .batchTranslateDocumentAsync(
779+
* parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig)
780+
* .get();
781+
* }
782+
* }</pre>
783+
*
784+
* @param parent Required. Location to make a regional call.
785+
* <p>Format: `projects/{project-number-or-id}/locations/{location-id}`.
786+
* <p>The `global` location is not supported for batch translation.
787+
* <p>Only AutoML Translation models or glossaries within the same region (have the same
788+
* location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
789+
* @param sourceLanguageCode Required. The BCP-47 language code of the input document if known,
790+
* for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support
791+
* (https://cloud.google.com/translate/docs/languages).
792+
* @param targetLanguageCodes Required. The BCP-47 language code to use for translation of the
793+
* input document. Specify up to 10 language codes here.
794+
* @param inputConfigs Required. Input configurations. The total number of files matched should be
795+
* &lt;= 100. The total content size to translate should be &lt;= 100M Unicode codepoints. The
796+
* files must use UTF-8 encoding.
797+
* @param outputConfig Required. Output configuration. If 2 input configs match to the same file
798+
* (that is, same input path), we don't generate output for duplicate inputs.
799+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
800+
*/
801+
public final OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata>
802+
batchTranslateDocumentAsync(
803+
String parent,
804+
String sourceLanguageCode,
805+
List<String> targetLanguageCodes,
806+
List<BatchDocumentInputConfig> inputConfigs,
807+
BatchDocumentOutputConfig outputConfig) {
808+
BatchTranslateDocumentRequest request =
809+
BatchTranslateDocumentRequest.newBuilder()
810+
.setParent(parent)
811+
.setSourceLanguageCode(sourceLanguageCode)
812+
.addAllTargetLanguageCodes(targetLanguageCodes)
813+
.addAllInputConfigs(inputConfigs)
814+
.setOutputConfig(outputConfig)
815+
.build();
816+
return batchTranslateDocumentAsync(request);
817+
}
818+
695819
// AUTO-GENERATED DOCUMENTATION AND METHOD.
696820
/**
697821
* Translates a large volume of documents in asynchronous batch mode. This function provides

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"libraryClient": "TranslationServiceClient",
1212
"rpcs": {
1313
"BatchTranslateDocument": {
14-
"methods": ["batchTranslateDocumentAsync", "batchTranslateDocumentOperationCallable", "batchTranslateDocumentCallable"]
14+
"methods": ["batchTranslateDocumentAsync", "batchTranslateDocumentAsync", "batchTranslateDocumentAsync", "batchTranslateDocumentOperationCallable", "batchTranslateDocumentCallable"]
1515
},
1616
"BatchTranslateText": {
1717
"methods": ["batchTranslateTextAsync", "batchTranslateTextOperationCallable", "batchTranslateTextCallable"]

0 commit comments

Comments
 (0)