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

feat: added v3 proto for online/batch document translation and updated v3beta1 proto for format conversion #767

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -194,7 +194,8 @@ public final OperationsClient getOperationsClient() {
* @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
* input text, set to one of the language codes listed in Language Support.
* @param contents Required. The content of the input in string format. We recommend the total
* content be less than 30k codepoints. Use BatchTranslateText for larger text.
* content be less than 30k codepoints. The max length of this field is 1024. Use
* BatchTranslateText for larger text.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final TranslateTextResponse translateText(
Expand Down Expand Up @@ -235,7 +236,8 @@ public final TranslateTextResponse translateText(
* @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
* input text, set to one of the language codes listed in Language Support.
* @param contents Required. The content of the input in string format. We recommend the total
* content be less than 30k codepoints. Use BatchTranslateText for larger text.
* content be less than 30k codepoints. The max length of this field is 1024. Use
* BatchTranslateText for larger text.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final TranslateTextResponse translateText(
Expand Down Expand Up @@ -283,10 +285,9 @@ public final TranslateTextResponse translateText(
* `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
* <p>- General (built-in) models:
* `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
* `projects/{project-number-or-id}/locations/{location-id}/models/general/base`
* <p>For global (non-regionalized) requests, use `location-id` `global`. For example,
* `projects/{project-number-or-id}/locations/global/models/general/nmt`.
* <p>If missing, the system decides which google base model to use.
* <p>If not provided, the default Google model (NMT) will be used.
* @param mimeType Optional. The format of the source text, for example, "text/html",
* "text/plain". If left blank, the MIME type defaults to "text/html".
* @param sourceLanguageCode Optional. The BCP-47 language code of the input text if known, for
Expand All @@ -296,7 +297,8 @@ public final TranslateTextResponse translateText(
* @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
* input text, set to one of the language codes listed in Language Support.
* @param contents Required. The content of the input in string format. We recommend the total
* content be less than 30k codepoints. Use BatchTranslateText for larger text.
* content be less than 30k codepoints. The max length of this field is 1024. Use
* BatchTranslateText for larger text.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final TranslateTextResponse translateText(
Expand Down Expand Up @@ -352,10 +354,9 @@ public final TranslateTextResponse translateText(
* `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
* <p>- General (built-in) models:
* `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
* `projects/{project-number-or-id}/locations/{location-id}/models/general/base`
* <p>For global (non-regionalized) requests, use `location-id` `global`. For example,
* `projects/{project-number-or-id}/locations/global/models/general/nmt`.
* <p>If missing, the system decides which google base model to use.
* <p>If not provided, the default Google model (NMT) will be used.
* @param mimeType Optional. The format of the source text, for example, "text/html",
* "text/plain". If left blank, the MIME type defaults to "text/html".
* @param sourceLanguageCode Optional. The BCP-47 language code of the input text if known, for
Expand All @@ -365,7 +366,8 @@ public final TranslateTextResponse translateText(
* @param targetLanguageCode Required. The BCP-47 language code to use for translation of the
* input text, set to one of the language codes listed in Language Support.
* @param contents Required. The content of the input in string format. We recommend the total
* content be less than 30k codepoints. Use BatchTranslateText for larger text.
* content be less than 30k codepoints. The max length of this field is 1024. Use
* BatchTranslateText for larger text.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final TranslateTextResponse translateText(
Expand Down Expand Up @@ -624,9 +626,8 @@ public final DetectLanguageResponse detectLanguage(DetectLanguageRequest request
* `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
* <p>- General (built-in) models:
* `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
* `projects/{project-number-or-id}/locations/{location-id}/models/general/base`
* <p>Returns languages supported by the specified model. If missing, we get supported
* languages of Google general base (PBMT) model.
* languages of Google general NMT model.
* @param displayLanguageCode Optional. The language to use to return localized, human readable
* names of supported languages. If missing, then display names are not returned in a
* response.
Expand Down Expand Up @@ -673,9 +674,8 @@ public final SupportedLanguages getSupportedLanguages(
* `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
* <p>- General (built-in) models:
* `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
* `projects/{project-number-or-id}/locations/{location-id}/models/general/base`
* <p>Returns languages supported by the specified model. If missing, we get supported
* languages of Google general base (PBMT) model.
* languages of Google general NMT model.
* @param displayLanguageCode Optional. The language to use to return localized, human readable
* names of supported languages. If missing, then display names are not returned in a
* response.
Expand Down Expand Up @@ -743,6 +743,67 @@ public final SupportedLanguages getSupportedLanguages(GetSupportedLanguagesReque
return stub.getSupportedLanguagesCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Translates documents in synchronous mode.
*
* <p>Sample code:
*
* <pre>{@code
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
* TranslateDocumentRequest request =
* TranslateDocumentRequest.newBuilder()
* .setParent("parent-995424086")
* .setSourceLanguageCode("sourceLanguageCode1645917472")
* .setTargetLanguageCode("targetLanguageCode-106414698")
* .setDocumentInputConfig(DocumentInputConfig.newBuilder().build())
* .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build())
* .setModel("model104069929")
* .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
* .putAllLabels(new HashMap<String, String>())
* .build();
* TranslateDocumentResponse response = translationServiceClient.translateDocument(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final TranslateDocumentResponse translateDocument(TranslateDocumentRequest request) {
return translateDocumentCallable().call(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Translates documents in synchronous mode.
*
* <p>Sample code:
*
* <pre>{@code
* try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
* TranslateDocumentRequest request =
* TranslateDocumentRequest.newBuilder()
* .setParent("parent-995424086")
* .setSourceLanguageCode("sourceLanguageCode1645917472")
* .setTargetLanguageCode("targetLanguageCode-106414698")
* .setDocumentInputConfig(DocumentInputConfig.newBuilder().build())
* .setDocumentOutputConfig(DocumentOutputConfig.newBuilder().build())
* .setModel("model104069929")
* .setGlossaryConfig(TranslateTextGlossaryConfig.newBuilder().build())
* .putAllLabels(new HashMap<String, String>())
* .build();
* ApiFuture<TranslateDocumentResponse> future =
* translationServiceClient.translateDocumentCallable().futureCall(request);
* // Do something.
* TranslateDocumentResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<TranslateDocumentRequest, TranslateDocumentResponse>
translateDocumentCallable() {
return stub.translateDocumentCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Translates a large volume of text in asynchronous batch mode. This function provides real-time
Expand Down Expand Up @@ -852,6 +913,121 @@ 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()) {
* BatchTranslateDocumentRequest request =
* BatchTranslateDocumentRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setSourceLanguageCode("sourceLanguageCode1645917472")
* .addAllTargetLanguageCodes(new ArrayList<String>())
* .addAllInputConfigs(new ArrayList<BatchDocumentInputConfig>())
* .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build())
* .putAllModels(new HashMap<String, String>())
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
* .putAllFormatConversions(new HashMap<String, String>())
* .build();
* BatchTranslateDocumentResponse response =
* translationServiceClient.batchTranslateDocumentAsync(request).get();
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata>
batchTranslateDocumentAsync(BatchTranslateDocumentRequest request) {
return batchTranslateDocumentOperationCallable().futureCall(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()) {
* BatchTranslateDocumentRequest request =
* BatchTranslateDocumentRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setSourceLanguageCode("sourceLanguageCode1645917472")
* .addAllTargetLanguageCodes(new ArrayList<String>())
* .addAllInputConfigs(new ArrayList<BatchDocumentInputConfig>())
* .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build())
* .putAllModels(new HashMap<String, String>())
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
* .putAllFormatConversions(new HashMap<String, String>())
* .build();
* OperationFuture<BatchTranslateDocumentResponse, BatchTranslateDocumentMetadata> future =
* translationServiceClient.batchTranslateDocumentOperationCallable().futureCall(request);
* // Do something.
* BatchTranslateDocumentResponse response = future.get();
* }
* }</pre>
*/
public final OperationCallable<
BatchTranslateDocumentRequest,
BatchTranslateDocumentResponse,
BatchTranslateDocumentMetadata>
batchTranslateDocumentOperationCallable() {
return stub.batchTranslateDocumentOperationCallable();
}

// 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()) {
* BatchTranslateDocumentRequest request =
* BatchTranslateDocumentRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setSourceLanguageCode("sourceLanguageCode1645917472")
* .addAllTargetLanguageCodes(new ArrayList<String>())
* .addAllInputConfigs(new ArrayList<BatchDocumentInputConfig>())
* .setOutputConfig(BatchDocumentOutputConfig.newBuilder().build())
* .putAllModels(new HashMap<String, String>())
* .putAllGlossaries(new HashMap<String, TranslateTextGlossaryConfig>())
* .putAllFormatConversions(new HashMap<String, String>())
* .build();
* ApiFuture<Operation> future =
* translationServiceClient.batchTranslateDocumentCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<BatchTranslateDocumentRequest, Operation>
batchTranslateDocumentCallable() {
return stub.batchTranslateDocumentCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project
Expand Down
Expand Up @@ -88,6 +88,12 @@ public UnaryCallSettings<DetectLanguageRequest, DetectLanguageResponse> detectLa
return ((TranslationServiceStubSettings) getStubSettings()).getSupportedLanguagesSettings();
}

/** Returns the object with the settings used for calls to translateDocument. */
public UnaryCallSettings<TranslateDocumentRequest, TranslateDocumentResponse>
translateDocumentSettings() {
return ((TranslationServiceStubSettings) getStubSettings()).translateDocumentSettings();
}

/** Returns the object with the settings used for calls to batchTranslateText. */
public UnaryCallSettings<BatchTranslateTextRequest, Operation> batchTranslateTextSettings() {
return ((TranslationServiceStubSettings) getStubSettings()).batchTranslateTextSettings();
Expand All @@ -101,6 +107,22 @@ public UnaryCallSettings<BatchTranslateTextRequest, Operation> batchTranslateTex
.batchTranslateTextOperationSettings();
}

/** Returns the object with the settings used for calls to batchTranslateDocument. */
public UnaryCallSettings<BatchTranslateDocumentRequest, Operation>
batchTranslateDocumentSettings() {
return ((TranslationServiceStubSettings) getStubSettings()).batchTranslateDocumentSettings();
}

/** Returns the object with the settings used for calls to batchTranslateDocument. */
public OperationCallSettings<
BatchTranslateDocumentRequest,
BatchTranslateDocumentResponse,
BatchTranslateDocumentMetadata>
batchTranslateDocumentOperationSettings() {
return ((TranslationServiceStubSettings) getStubSettings())
.batchTranslateDocumentOperationSettings();
}

/** Returns the object with the settings used for calls to createGlossary. */
public UnaryCallSettings<CreateGlossaryRequest, Operation> createGlossarySettings() {
return ((TranslationServiceStubSettings) getStubSettings()).createGlossarySettings();
Expand Down Expand Up @@ -251,6 +273,12 @@ public Builder applyToAllUnaryMethods(
return getStubSettingsBuilder().getSupportedLanguagesSettings();
}

/** Returns the builder for the settings used for calls to translateDocument. */
public UnaryCallSettings.Builder<TranslateDocumentRequest, TranslateDocumentResponse>
translateDocumentSettings() {
return getStubSettingsBuilder().translateDocumentSettings();
}

/** Returns the builder for the settings used for calls to batchTranslateText. */
public UnaryCallSettings.Builder<BatchTranslateTextRequest, Operation>
batchTranslateTextSettings() {
Expand All @@ -264,6 +292,21 @@ public Builder applyToAllUnaryMethods(
return getStubSettingsBuilder().batchTranslateTextOperationSettings();
}

/** Returns the builder for the settings used for calls to batchTranslateDocument. */
public UnaryCallSettings.Builder<BatchTranslateDocumentRequest, Operation>
batchTranslateDocumentSettings() {
return getStubSettingsBuilder().batchTranslateDocumentSettings();
}

/** Returns the builder for the settings used for calls to batchTranslateDocument. */
public OperationCallSettings.Builder<
BatchTranslateDocumentRequest,
BatchTranslateDocumentResponse,
BatchTranslateDocumentMetadata>
batchTranslateDocumentOperationSettings() {
return getStubSettingsBuilder().batchTranslateDocumentOperationSettings();
}

/** Returns the builder for the settings used for calls to createGlossary. */
public UnaryCallSettings.Builder<CreateGlossaryRequest, Operation> createGlossarySettings() {
return getStubSettingsBuilder().createGlossarySettings();
Expand Down
Expand Up @@ -10,6 +10,9 @@
"grpc": {
"libraryClient": "TranslationServiceClient",
"rpcs": {
"BatchTranslateDocument": {
"methods": ["batchTranslateDocumentAsync", "batchTranslateDocumentOperationCallable", "batchTranslateDocumentCallable"]
},
"BatchTranslateText": {
"methods": ["batchTranslateTextAsync", "batchTranslateTextOperationCallable", "batchTranslateTextCallable"]
},
Expand All @@ -31,6 +34,9 @@
"ListGlossaries": {
"methods": ["listGlossaries", "listGlossaries", "listGlossaries", "listGlossariesPagedCallable", "listGlossariesCallable"]
},
"TranslateDocument": {
"methods": ["translateDocument", "translateDocumentCallable"]
},
"TranslateText": {
"methods": ["translateText", "translateText", "translateText", "translateText", "translateText", "translateTextCallable"]
}
Expand Down
Expand Up @@ -15,7 +15,9 @@
*/

/**
* The interfaces provided are listed below, along with usage samples.
* A client to Cloud Translation API
*
* <p>The interfaces provided are listed below, along with usage samples.
*
* <p>======================= TranslationServiceClient =======================
*
Expand Down