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

Commit

Permalink
fix: add model signature for batch document translation (#832)
Browse files Browse the repository at this point in the history
* fix: add model signature for batch document translation

PiperOrigin-RevId: 403140062

Source-Link: googleapis/googleapis@67e6e0a

Source-Link: googleapis/googleapis-gen@779ead9
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>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed Oct 19, 2021
1 parent 5ea9747 commit 4e911b5
Show file tree
Hide file tree
Showing 10 changed files with 462 additions and 76 deletions.
Expand Up @@ -913,6 +913,130 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
return stub.batchTranslateTextCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Translates a large volume of document in asynchronous batch mode. This function provides
* real-time output as the inputs are being processed. If caller cancels a request, the partial
* results (for an input file, it's all or nothing) may still be available on the specified output
* location.
*
* <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the
* status of the call.
*
* <p>Sample code:
*
* <pre>{@code
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
* String sourceLanguageCode = "sourceLanguageCode1645917472";
* List<String> targetLanguageCodes = new ArrayList<>();
* List<BatchDocumentInputConfig> inputConfigs = new ArrayList<>();
* BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build();
* BatchTranslateDocumentResponse response =
* translationServiceClient
* .batchTranslateDocumentAsync(
* parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig)
* .get();
* }
* }</pre>
*
* @param parent Required. Location to make a regional call.
* <p>Format: `projects/{project-number-or-id}/locations/{location-id}`.
* <p>The `global` location is not supported for batch translation.
* <p>Only AutoML Translation models or glossaries within the same region (have the same
* location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
* @param sourceLanguageCode Required. The BCP-47 language code of the input document if known,
* for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support
* (https://cloud.google.com/translate/docs/languages).
* @param targetLanguageCodes Required. The BCP-47 language code to use for translation of the
* input document. Specify up to 10 language codes here.
* @param inputConfigs Required. Input configurations. The total number of files matched should be
* &lt;= 100. The total content size to translate should be &lt;= 100M Unicode codepoints. The
* files must use UTF-8 encoding.
* @param outputConfig Required. Output configuration. If 2 input configs match to the same file
* (that is, same input path), we don't generate output for duplicate inputs.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata>
batchTranslateDocumentAsync(
LocationName parent,
String sourceLanguageCode,
List<String> targetLanguageCodes,
List<BatchDocumentInputConfig> inputConfigs,
BatchDocumentOutputConfig outputConfig) {
BatchTranslateDocumentRequest request =
BatchTranslateDocumentRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setSourceLanguageCode(sourceLanguageCode)
.addAllTargetLanguageCodes(targetLanguageCodes)
.addAllInputConfigs(inputConfigs)
.setOutputConfig(outputConfig)
.build();
return batchTranslateDocumentAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Translates a large volume of document in asynchronous batch mode. This function provides
* real-time output as the inputs are being processed. If caller cancels a request, the partial
* results (for an input file, it's all or nothing) may still be available on the specified output
* location.
*
* <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the
* status of the call.
*
* <p>Sample code:
*
* <pre>{@code
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
* String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
* String sourceLanguageCode = "sourceLanguageCode1645917472";
* List<String> targetLanguageCodes = new ArrayList<>();
* List<BatchDocumentInputConfig> inputConfigs = new ArrayList<>();
* BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build();
* BatchTranslateDocumentResponse response =
* translationServiceClient
* .batchTranslateDocumentAsync(
* parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig)
* .get();
* }
* }</pre>
*
* @param parent Required. Location to make a regional call.
* <p>Format: `projects/{project-number-or-id}/locations/{location-id}`.
* <p>The `global` location is not supported for batch translation.
* <p>Only AutoML Translation models or glossaries within the same region (have the same
* location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
* @param sourceLanguageCode Required. The BCP-47 language code of the input document if known,
* for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support
* (https://cloud.google.com/translate/docs/languages).
* @param targetLanguageCodes Required. The BCP-47 language code to use for translation of the
* input document. Specify up to 10 language codes here.
* @param inputConfigs Required. Input configurations. The total number of files matched should be
* &lt;= 100. The total content size to translate should be &lt;= 100M Unicode codepoints. The
* files must use UTF-8 encoding.
* @param outputConfig Required. Output configuration. If 2 input configs match to the same file
* (that is, same input path), we don't generate output for duplicate inputs.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata>
batchTranslateDocumentAsync(
String parent,
String sourceLanguageCode,
List<String> targetLanguageCodes,
List<BatchDocumentInputConfig> inputConfigs,
BatchDocumentOutputConfig outputConfig) {
BatchTranslateDocumentRequest request =
BatchTranslateDocumentRequest.newBuilder()
.setParent(parent)
.setSourceLanguageCode(sourceLanguageCode)
.addAllTargetLanguageCodes(targetLanguageCodes)
.addAllInputConfigs(inputConfigs)
.setOutputConfig(outputConfig)
.build();
return batchTranslateDocumentAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Translates a large volume of document in asynchronous batch mode. This function provides
Expand Down
Expand Up @@ -11,7 +11,7 @@
"libraryClient": "TranslationServiceClient",
"rpcs": {
"BatchTranslateDocument": {
"methods": ["batchTranslateDocumentAsync", "batchTranslateDocumentOperationCallable", "batchTranslateDocumentCallable"]
"methods": ["batchTranslateDocumentAsync", "batchTranslateDocumentAsync", "batchTranslateDocumentAsync", "batchTranslateDocumentOperationCallable", "batchTranslateDocumentCallable"]
},
"BatchTranslateText": {
"methods": ["batchTranslateTextAsync", "batchTranslateTextOperationCallable", "batchTranslateTextCallable"]
Expand Down
Expand Up @@ -692,6 +692,130 @@ public final UnaryCallable<BatchTranslateTextRequest, Operation> batchTranslateT
return stub.batchTranslateTextCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Translates a large volume of documents in asynchronous batch mode. This function provides
* real-time output as the inputs are being processed. If caller cancels a request, the partial
* results (for an input file, it's all or nothing) may still be available on the specified output
* location.
*
* <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the
* status of the call.
*
* <p>Sample code:
*
* <pre>{@code
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
* String sourceLanguageCode = "sourceLanguageCode1645917472";
* List<String> targetLanguageCodes = new ArrayList<>();
* List<BatchDocumentInputConfig> inputConfigs = new ArrayList<>();
* BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build();
* BatchTranslateDocumentResponse response =
* translationServiceClient
* .batchTranslateDocumentAsync(
* parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig)
* .get();
* }
* }</pre>
*
* @param parent Required. Location to make a regional call.
* <p>Format: `projects/{project-number-or-id}/locations/{location-id}`.
* <p>The `global` location is not supported for batch translation.
* <p>Only AutoML Translation models or glossaries within the same region (have the same
* location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
* @param sourceLanguageCode Required. The BCP-47 language code of the input document if known,
* for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support
* (https://cloud.google.com/translate/docs/languages).
* @param targetLanguageCodes Required. The BCP-47 language code to use for translation of the
* input document. Specify up to 10 language codes here.
* @param inputConfigs Required. Input configurations. The total number of files matched should be
* &lt;= 100. The total content size to translate should be &lt;= 100M Unicode codepoints. The
* files must use UTF-8 encoding.
* @param outputConfig Required. Output configuration. If 2 input configs match to the same file
* (that is, same input path), we don't generate output for duplicate inputs.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata>
batchTranslateDocumentAsync(
LocationName parent,
String sourceLanguageCode,
List<String> targetLanguageCodes,
List<BatchDocumentInputConfig> inputConfigs,
BatchDocumentOutputConfig outputConfig) {
BatchTranslateDocumentRequest request =
BatchTranslateDocumentRequest.newBuilder()
.setParent(parent == null ? null : parent.toString())
.setSourceLanguageCode(sourceLanguageCode)
.addAllTargetLanguageCodes(targetLanguageCodes)
.addAllInputConfigs(inputConfigs)
.setOutputConfig(outputConfig)
.build();
return batchTranslateDocumentAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Translates a large volume of documents in asynchronous batch mode. This function provides
* real-time output as the inputs are being processed. If caller cancels a request, the partial
* results (for an input file, it's all or nothing) may still be available on the specified output
* location.
*
* <p>This call returns immediately and you can use google.longrunning.Operation.name to poll the
* status of the call.
*
* <p>Sample code:
*
* <pre>{@code
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
* String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
* String sourceLanguageCode = "sourceLanguageCode1645917472";
* List<String> targetLanguageCodes = new ArrayList<>();
* List<BatchDocumentInputConfig> inputConfigs = new ArrayList<>();
* BatchDocumentOutputConfig outputConfig = BatchDocumentOutputConfig.newBuilder().build();
* BatchTranslateDocumentResponse response =
* translationServiceClient
* .batchTranslateDocumentAsync(
* parent, sourceLanguageCode, targetLanguageCodes, inputConfigs, outputConfig)
* .get();
* }
* }</pre>
*
* @param parent Required. Location to make a regional call.
* <p>Format: `projects/{project-number-or-id}/locations/{location-id}`.
* <p>The `global` location is not supported for batch translation.
* <p>Only AutoML Translation models or glossaries within the same region (have the same
* location-id) can be used, otherwise an INVALID_ARGUMENT (400) error is returned.
* @param sourceLanguageCode Required. The BCP-47 language code of the input document if known,
* for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support
* (https://cloud.google.com/translate/docs/languages).
* @param targetLanguageCodes Required. The BCP-47 language code to use for translation of the
* input document. Specify up to 10 language codes here.
* @param inputConfigs Required. Input configurations. The total number of files matched should be
* &lt;= 100. The total content size to translate should be &lt;= 100M Unicode codepoints. The
* files must use UTF-8 encoding.
* @param outputConfig Required. Output configuration. If 2 input configs match to the same file
* (that is, same input path), we don't generate output for duplicate inputs.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata>
batchTranslateDocumentAsync(
String parent,
String sourceLanguageCode,
List<String> targetLanguageCodes,
List<BatchDocumentInputConfig> inputConfigs,
BatchDocumentOutputConfig outputConfig) {
BatchTranslateDocumentRequest request =
BatchTranslateDocumentRequest.newBuilder()
.setParent(parent)
.setSourceLanguageCode(sourceLanguageCode)
.addAllTargetLanguageCodes(targetLanguageCodes)
.addAllInputConfigs(inputConfigs)
.setOutputConfig(outputConfig)
.build();
return batchTranslateDocumentAsync(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Translates a large volume of documents in asynchronous batch mode. This function provides
Expand Down
Expand Up @@ -11,7 +11,7 @@
"libraryClient": "TranslationServiceClient",
"rpcs": {
"BatchTranslateDocument": {
"methods": ["batchTranslateDocumentAsync", "batchTranslateDocumentOperationCallable", "batchTranslateDocumentCallable"]
"methods": ["batchTranslateDocumentAsync", "batchTranslateDocumentAsync", "batchTranslateDocumentAsync", "batchTranslateDocumentOperationCallable", "batchTranslateDocumentCallable"]
},
"BatchTranslateText": {
"methods": ["batchTranslateTextAsync", "batchTranslateTextOperationCallable", "batchTranslateTextCallable"]
Expand Down

0 comments on commit 4e911b5

Please sign in to comment.