diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationAsyncClient.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationAsyncClient.java index d43270cc3354..3a5e37dc42f7 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationAsyncClient.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationAsyncClient.java @@ -1,20 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.ai.translation.text; import com.azure.ai.translation.text.implementation.TextTranslationClientImpl; -import com.azure.ai.translation.text.models.BreakSentenceItem; -import com.azure.ai.translation.text.models.DictionaryExampleItem; -import com.azure.ai.translation.text.models.DictionaryExampleTextItem; -import com.azure.ai.translation.text.models.DictionaryLookupItem; import com.azure.ai.translation.text.models.GetSupportedLanguagesResult; import com.azure.ai.translation.text.models.InputTextItem; -import com.azure.ai.translation.text.models.LanguageScope; -import com.azure.ai.translation.text.models.ProfanityAction; -import com.azure.ai.translation.text.models.ProfanityMarker; -import com.azure.ai.translation.text.models.TextType; -import com.azure.ai.translation.text.models.TranslateOptions; +import com.azure.ai.translation.text.models.TranslateBodyDetails; import com.azure.ai.translation.text.models.TranslatedTextItem; import com.azure.ai.translation.text.models.TransliteratedText; import com.azure.core.annotation.Generated; @@ -31,8 +24,6 @@ import com.azure.core.util.BinaryData; import com.azure.core.util.FluxUtil; import com.azure.core.util.serializer.TypeReference; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import reactor.core.publisher.Mono; @@ -41,13 +32,12 @@ */ @ServiceClient(builder = TextTranslationClientBuilder.class, isAsync = true) public final class TextTranslationAsyncClient { - @Generated private final TextTranslationClientImpl serviceClient; /** * Initializes an instance of TextTranslationAsyncClient class. - * + * * @param serviceClient the service client implementation. */ @Generated @@ -56,54 +46,17 @@ public final class TextTranslationAsyncClient { } /** - * Translate Text. + * Gets the set of languages currently supported by other operations of the Translator. *

Query Parameters

* * * - * - * - * - * - * - * - * - * - * - * - * + * *
Query Parameters
NameTypeRequiredDescription
fromStringNoSpecifies the language of the input text. Find which languages are - * available to translate from by - * looking up supported languages using the translation scope. If the from parameter isn't specified, - * automatic language detection is applied to determine the source language. - * - * You must use the from parameter rather than autodetection when using the dynamic dictionary feature. - * Note: the dynamic dictionary feature is case-sensitive.
textTypeStringNoDefines whether the text being translated is plain text or - * HTML text. Any HTML needs to be a well-formed, - * complete element. Possible values are: plain (default) or html. Allowed values: "Plain", "Html".
categoryStringNoA string specifying the category (domain) of the translation. - * This parameter is used to get translations - * from a customized system built with Custom Translator. Add the Category ID from your Custom Translator - * project details to this parameter to use your deployed customized system. Default value is: general.
profanityActionStringNoSpecifies how profanities should be treated in - * translations. - * Possible values are: NoAction (default), Marked or Deleted. Allowed values: "NoAction", "Marked", - * "Deleted".
profanityMarkerStringNoSpecifies how profanities should be marked in - * translations. - * Possible values are: Asterisk (default) or Tag. . Allowed values: "Asterisk", "Tag".
includeAlignmentBooleanNoSpecifies whether to include alignment projection - * from source text to translated text. - * Possible values are: true or false (default).
includeSentenceLengthBooleanNoSpecifies whether to include sentence boundaries - * for the input text and the translated text. - * Possible values are: true or false (default).
suggestedFromStringNoSpecifies a fallback language if the language of the - * input text can't be identified. - * Language autodetection is applied when the from parameter is omitted. If detection fails, - * the suggestedFrom language will be assumed.
fromScriptStringNoSpecifies the script of the input text.
toScriptStringNoSpecifies the script of the translated text.
allowFallbackBooleanNoSpecifies that the service is allowed to fall back to a - * general system when a custom system doesn't exist. - * Possible values are: true (default) or false. - * - * allowFallback=false specifies that the translation should only use systems trained for the category specified - * by the request. If a translation for language X to language Y requires chaining through a pivot language E, - * then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. - * If no system is found with the specific category, the request will return a 400 status code. allowFallback=true - * specifies that the service is allowed to fall back to a general system when a custom system doesn't - * exist.
scopeStringNoA comma-separated list of names defining the group of languages + * to return. + * Allowed group names are: `translation`, `transliteration` and `dictionary`. + * If no scope is given, then all groups are returned, which is equivalent to passing + * `scope=translation,transliteration,dictionary`. To decide which set of supported languages + * is appropriate for your scenario, see the description of the [response object](#response-body).
* You can add these to a request with {@link RequestOptions#addQueryParam} *

Header Parameters

@@ -112,6 +65,94 @@ public final class TextTranslationAsyncClient { * NameTypeRequiredDescription * X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the * request. + * Accept-LanguageStringNoThe language to use for user interface strings. Some of + * the fields in the response are names of languages or + * names of regions. Use this parameter to define the language in which these names are returned. + * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` + * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. + * Names are provided in the English language when a target language is not specified or when localization + * is not available. + * If-None-MatchStringNoPassing the value of the ETag response header in an + * If-None-Match field will allow the service to optimize the response. + * If the resource has not been modified, the service will return status code 304 and an empty response + * body. + * + * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     translation (Optional): {
+     *         String (Required): {
+     *             name: String (Required)
+     *             nativeName: String (Required)
+     *             dir: String(ltr/rtl) (Required)
+     *         }
+     *     }
+     *     transliteration (Optional): {
+     *         String (Required): {
+     *             name: String (Required)
+     *             nativeName: String (Required)
+     *             scripts (Required): [
+     *                  (Required){
+     *                     code: String (Required)
+     *                     name: String (Required)
+     *                     nativeName: String (Required)
+     *                     dir: String(ltr/rtl) (Required)
+     *                     toScripts (Required): [
+     *                          (Required){
+     *                             code: String (Required)
+     *                             name: String (Required)
+     *                             nativeName: String (Required)
+     *                             dir: String(ltr/rtl) (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     dictionary (Optional): {
+     *         String (Required): {
+     *             name: String (Required)
+     *             nativeName: String (Required)
+     *             dir: String(ltr/rtl) (Required)
+     *             translations (Required): [
+     *                  (Required){
+     *                     name: String (Required)
+     *                     nativeName: String (Required)
+     *                     dir: String(ltr/rtl) (Required)
+     *                     code: String (Required)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the set of languages currently supported by other operations of the Translator along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getSupportedLanguagesWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getSupportedLanguagesWithResponseAsync(requestOptions); + } + + /** + * Translate Text. + *

Header Parameters

+ * + * + * + * *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the + * request.
* You can add these to a request with {@link RequestOptions#addHeader} *

Request Body Schema

@@ -121,6 +162,31 @@ public final class TextTranslationAsyncClient { * [ * (Required){ * text: String (Required) + * script: String (Optional) + * language: String (Optional) + * textType: String(Plain/Html) (Optional) + * targets (Required): [ + * (Required){ + * language (Required): [ + * String (Required) + * ] + * script: String (Optional) + * profanityAction: String(NoAction/Marked/Deleted) (Optional) + * profanityMarker: String(Asterisk/Tag) (Optional) + * deploymentNameModel: String (Optional) + * allowFallback: Boolean (Optional) + * grade: String (Optional) + * tone: String (Optional) + * gender: String (Optional) + * adaptiveDatasetId: String (Optional) + * referenceTextPairs (Optional): [ + * (Optional){ + * referenceTextPairsSource: String (Required) + * referenceTextPairsTarget: String (Required) + * } + * ] + * } + * ] * } * ] * } @@ -144,17 +210,6 @@ public final class TextTranslationAsyncClient { * text: String (Required) * script: String (Required) * } - * alignment (Optional): { - * proj: String (Required) - * } - * sentLen (Optional): { - * srcSentLen (Required): [ - * int (Required) - * ] - * transSentLen (Required): [ - * int (Required) - * ] - * } * } * ] * sourceText (Optional): { @@ -164,12 +219,7 @@ public final class TextTranslationAsyncClient { * ] * } * - * - * @param targetLanguages Specifies the language of the output text. The target language must be one of the - * supported languages included - * in the translation scope. For example, use to=de to translate to German. - * It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. - * For example, use to=de&to=it to translate to German and Italian. + * * @param body Defines the content of the request. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. @@ -180,9 +230,8 @@ public final class TextTranslationAsyncClient { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> translateWithResponse(List targetLanguages, BinaryData body, - RequestOptions requestOptions) { - return this.serviceClient.translateWithResponseAsync(targetLanguages, body, requestOptions); + public Mono> translate2WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.translate2WithResponseAsync(body, requestOptions); } /** @@ -219,7 +268,7 @@ public Mono> translateWithResponse(List targetLangu * ] * } * - * + * * @param language Specifies the language of the text to convert from one script to another. * Possible languages are listed in the transliteration scope obtained by querying the service * for its supported languages. @@ -246,320 +295,103 @@ public Mono> transliterateWithResponse(String language, Str } /** - * Find Sentence Boundaries. - *

Query Parameters

- * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
languageStringNoLanguage tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied.
scriptStringNoScript tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed.
- * You can add these to a request with {@link RequestOptions#addQueryParam} - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

+ * Gets the set of languages currently supported by other operations of the Translator. * - *
-     * {@code
-     * [
-     *      (Required){
-     *         detectedLanguage (Optional): {
-     *             language: String (Required)
-     *             score: double (Required)
-     *         }
-     *         sentLen (Required): [
-     *             int (Required)
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @param clientTraceId A client-generated GUID to uniquely identify the request. + * @param scope A comma-separated list of names defining the group of languages to return. + * Allowed group names are: `translation`, `transliteration` and `dictionary`. + * If no scope is given, then all groups are returned, which is equivalent to passing + * `scope=translation,transliteration,dictionary`. To decide which set of supported languages + * is appropriate for your scenario, see the description of the [response object](#response-body). + * @param acceptLanguage The language to use for user interface strings. Some of the fields in the response are + * names of languages or + * names of regions. Use this parameter to define the language in which these names are returned. + * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` + * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. + * Names are provided in the English language when a target language is not specified or when localization + * is not available. + * @param ifNoneMatch Passing the value of the ETag response header in an If-None-Match field will allow the service + * to optimize the response. + * If the resource has not been modified, the service will return status code 304 and an empty response body. + * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the set of languages currently supported by other operations of the Translator on successful completion + * of {@link Mono}. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> findSentenceBoundariesWithResponse(BinaryData body, - RequestOptions requestOptions) { - return this.serviceClient.findSentenceBoundariesWithResponseAsync(body, requestOptions); + public Mono getSupportedLanguages(String clientTraceId, String scope, + String acceptLanguage, String ifNoneMatch) { + // Generated convenience method for getSupportedLanguagesWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (clientTraceId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("X-ClientTraceId"), clientTraceId); + } + if (scope != null) { + requestOptions.addQueryParam("scope", scope, false); + } + if (acceptLanguage != null) { + requestOptions.setHeader(HttpHeaderName.ACCEPT_LANGUAGE, acceptLanguage); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + return getSupportedLanguagesWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(GetSupportedLanguagesResult.class)); } /** - * Lookup Dictionary Entries. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
+ * Gets the set of languages currently supported by other operations of the Translator. * - *

Response Body Schema

+ * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the set of languages currently supported by other operations of the Translator on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getSupportedLanguages() { + // Generated convenience method for getSupportedLanguagesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getSupportedLanguagesWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(GetSupportedLanguagesResult.class)); + } + + /** + * Translate Text. * - *
-     * {@code
-     * [
-     *      (Required){
-     *         normalizedSource: String (Required)
-     *         displaySource: String (Required)
-     *         translations (Required): [
-     *              (Required){
-     *                 normalizedTarget: String (Required)
-     *                 displayTarget: String (Required)
-     *                 posTag: String (Required)
-     *                 confidence: double (Required)
-     *                 prefixWord: String (Required)
-     *                 backTranslations (Required): [
-     *                      (Required){
-     *                         normalizedText: String (Required)
-     *                         displayText: String (Required)
-     *                         numExamples: int (Required)
-     *                         frequencyCount: int (Required)
-     *                     }
-     *                 ]
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @param clientTraceId A client-generated GUID to uniquely identify the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> lookupDictionaryEntriesWithResponse(String sourceLanguage, String targetLanguage, - BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.lookupDictionaryEntriesWithResponseAsync(sourceLanguage, targetLanguage, body, - requestOptions); - } - - /** - * Lookup Dictionary Examples. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *         translation: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         normalizedSource: String (Required)
-     *         normalizedTarget: String (Required)
-     *         examples (Required): [
-     *              (Required){
-     *                 sourcePrefix: String (Required)
-     *                 sourceTerm: String (Required)
-     *                 sourceSuffix: String (Required)
-     *                 targetPrefix: String (Required)
-     *                 targetTerm: String (Required)
-     *                 targetSuffix: String (Required)
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> lookupDictionaryExamplesWithResponse(String sourceLanguage, String targetLanguage, - BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.lookupDictionaryExamplesWithResponseAsync(sourceLanguage, targetLanguage, body, - requestOptions); + public Mono> translate2(List body, String clientTraceId) { + // Generated convenience method for translate2WithResponse + RequestOptions requestOptions = new RequestOptions(); + if (clientTraceId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("X-ClientTraceId"), clientTraceId); + } + return translate2WithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM)); } /** * Translate Text. - * - * @param targetLanguages Specifies the language of the output text. The target language must be one of the - * supported languages included - * in the translation scope. For example, use to=de to translate to German. - * It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. - * For example, use to=de&to=it to translate to German and Italian. - * @param body Defines the content of the request. - * @param clientTraceId A client-generated GUID to uniquely identify the request. - * @param sourceLanguage Specifies the language of the input text. Find which languages are available to translate - * from by - * looking up supported languages using the translation scope. If the from parameter isn't specified, - * automatic language detection is applied to determine the source language. - * - * You must use the from parameter rather than autodetection when using the dynamic dictionary feature. - * Note: the dynamic dictionary feature is case-sensitive. - * @param textType Defines whether the text being translated is plain text or HTML text. Any HTML needs to be a - * well-formed, - * complete element. Possible values are: plain (default) or html. - * @param category A string specifying the category (domain) of the translation. This parameter is used to get - * translations - * from a customized system built with Custom Translator. Add the Category ID from your Custom Translator - * project details to this parameter to use your deployed customized system. Default value is: general. - * @param profanityAction Specifies how profanities should be treated in translations. - * Possible values are: NoAction (default), Marked or Deleted. - * @param profanityMarker Specifies how profanities should be marked in translations. - * Possible values are: Asterisk (default) or Tag. - * @param includeAlignment Specifies whether to include alignment projection from source text to translated text. - * Possible values are: true or false (default). - * @param includeSentenceLength Specifies whether to include sentence boundaries for the input text and the - * translated text. - * Possible values are: true or false (default). - * @param suggestedSourceLanguage Specifies a fallback language if the language of the input text can't be - * identified. - * Language autodetection is applied when the from parameter is omitted. If detection fails, - * the suggestedFrom language will be assumed. - * @param sourceLanguageScript Specifies the script of the input text. - * @param targetLanguageScript Specifies the script of the translated text. - * @param allowFallback Specifies that the service is allowed to fall back to a general system when a custom system - * doesn't exist. - * Possible values are: true (default) or false. - * - * allowFallback=false specifies that the translation should only use systems trained for the category specified - * by the request. If a translation for language X to language Y requires chaining through a pivot language E, - * then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. - * If no system is found with the specific category, the request will return a 400 status code. allowFallback=true - * specifies that the service is allowed to fall back to a general system when a custom system doesn't exist. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - private Mono> translate(List targetLanguages, List body, - String clientTraceId, String sourceLanguage, TextType textType, String category, - ProfanityAction profanityAction, ProfanityMarker profanityMarker, Boolean includeAlignment, - Boolean includeSentenceLength, String suggestedSourceLanguage, String sourceLanguageScript, - String targetLanguageScript, Boolean allowFallback) { - // Generated convenience method for translateWithResponse - RequestOptions requestOptions = new RequestOptions(); - if (clientTraceId != null) { - requestOptions.setHeader(HttpHeaderName.fromString("X-ClientTraceId"), clientTraceId); - } - if (sourceLanguage != null) { - requestOptions.addQueryParam("from", sourceLanguage, false); - } - if (textType != null) { - requestOptions.addQueryParam("textType", textType.toString(), false); - } - if (category != null) { - requestOptions.addQueryParam("category", category, false); - } - if (profanityAction != null) { - requestOptions.addQueryParam("profanityAction", profanityAction.toString(), false); - } - if (profanityMarker != null) { - requestOptions.addQueryParam("profanityMarker", profanityMarker.toString(), false); - } - if (includeAlignment != null) { - requestOptions.addQueryParam("includeAlignment", String.valueOf(includeAlignment), false); - } - if (includeSentenceLength != null) { - requestOptions.addQueryParam("includeSentenceLength", String.valueOf(includeSentenceLength), false); - } - if (suggestedSourceLanguage != null) { - requestOptions.addQueryParam("suggestedFrom", suggestedSourceLanguage, false); - } - if (sourceLanguageScript != null) { - requestOptions.addQueryParam("fromScript", sourceLanguageScript, false); - } - if (targetLanguageScript != null) { - requestOptions.addQueryParam("toScript", targetLanguageScript, false); - } - if (allowFallback != null) { - requestOptions.addQueryParam("allowFallback", String.valueOf(allowFallback), false); - } - return translateWithResponse(targetLanguages, BinaryData.fromObject(body), requestOptions) - .flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM)); - } - - /** - * Translate Text. - * - * @param targetLanguages Specifies the language of the output text. The target language must be one of the - * supported languages included - * in the translation scope. For example, use to=de to translate to German. - * It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. - * For example, use to=de&to=it to translate to German and Italian. + * * @param body Defines the content of the request. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -569,124 +401,18 @@ private Mono> translate(List targetLanguages, L * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response body on successful completion of {@link Mono}. */ - private Mono> translateInner(List targetLanguages, List body) { - // Generated convenience method for translateWithResponse + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> translate2(List body) { + // Generated convenience method for translate2WithResponse RequestOptions requestOptions = new RequestOptions(); - return translateWithResponse(targetLanguages, BinaryData.fromObject(body), requestOptions) - .flatMap(FluxUtil::toMono) + return translate2WithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM)); } - /** - * Translate Text. - *

- * This method is used when you have single target language and multiple texts to translate. - *

- * - * @param targetLanguage Specifies the language of the output text. The target language must be one of the - * supported languages included - * in the translation scope. For example, use to=de to translate to German. - * It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. - * For example, use to=de&to=it to translate to German and Italian. - * @param texts Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> translate(String targetLanguage, List texts) { - return translateInner(Arrays.asList(targetLanguage), convertTextToData(texts)); - } - - /** - * Translate Text. - *

- * This method is used when you have single target language and single text to translate. - *

- * - * @param targetLanguage Specifies the language of the output text. The target language must be one of the - * supported languages included - * in the translation scope. For example, use to=de to translate to German. - * It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. - * For example, use to=de&to=it to translate to German and Italian. - * @param text Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono translate(String targetLanguage, String text) { - return translate(targetLanguage, Arrays.asList(text)) - .map(translatedTextItems -> translatedTextItems.isEmpty() ? null : translatedTextItems.get(0)) - .defaultIfEmpty(null); - } - - /** - * Translate Text. - *

- * This method is used when you have one input text and the optional parameters are needed such as specification - * of a source language, profanity handling etc. - *

- * - * @param text Text to translate. - * @param translateOptions Translate Options. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono translate(String text, TranslateOptions translateOptions) { - return translate(Arrays.asList(text), translateOptions) - .map(translatedTextItems -> translatedTextItems.isEmpty() ? null : translatedTextItems.get(0)) - .defaultIfEmpty(null); - } - - /** - * Translate Text. - *

- * This method is used when you have multiple texts and the optional parameters are needed such as specification - * of a source language, profanity handling etc.. - *

- * - * @param texts List of text to translate. - * @param translateOptions Translate Options. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> translate(List texts, TranslateOptions translateOptions) { - List content = new ArrayList<>(); - for (String text : texts) { - content.add(new InputTextItem(text)); - } - return translate(translateOptions.getTargetLanguages(), content, translateOptions.getClientTraceId(), - translateOptions.getSourceLanguage(), translateOptions.getTextType(), translateOptions.getCategory(), - translateOptions.getProfanityAction(), translateOptions.getProfanityMarker(), - translateOptions.isIncludeAlignment(), translateOptions.isIncludeSentenceLength(), - translateOptions.getSuggestedSourceLanguage(), translateOptions.getSourceLanguageScript(), - translateOptions.getTargetLanguageScript(), translateOptions.isAllowFallback()); - } - /** * Transliterate Text. - * + * * @param language Specifies the language of the text to convert from one script to another. * Possible languages are listed in the transliteration scope obtained by querying the service * for its supported languages. @@ -697,6 +423,7 @@ public Mono> translate(List texts, TranslateOpt * scope, to find output * scripts available for the selected combination of input language and input script. * @param body Defines the content of the request. + * @param clientTraceId A client-generated GUID to uniquely identify the request. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -705,10 +432,15 @@ public Mono> translate(List texts, TranslateOpt * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response body on successful completion of {@link Mono}. */ - private Mono> transliterateInner(String language, String sourceLanguageScript, - String targetLanguageScript, List body) { + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> transliterate(String language, String sourceLanguageScript, + String targetLanguageScript, List body, String clientTraceId) { // Generated convenience method for transliterateWithResponse RequestOptions requestOptions = new RequestOptions(); + if (clientTraceId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("X-ClientTraceId"), clientTraceId); + } return transliterateWithResponse(language, sourceLanguageScript, targetLanguageScript, BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_TRANSLITERATED_TEXT)); @@ -716,40 +448,7 @@ private Mono> transliterateInner(String language, Strin /** * Transliterate Text. - *

- * This method is used when you have multiple texts to transliterate and you want to provide client trace id. - *

- * - * @param language Specifies the language of the text to convert from one script to another. - * Possible languages are listed in the transliteration scope obtained by querying the service - * for its supported languages. - * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the - * transliteration scope, - * to find input scripts available for the selected language. - * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration - * scope, to find output - * scripts available for the selected combination of input language and input script. - * @param body Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> transliterate(String language, String sourceLanguageScript, - String targetLanguageScript, List body) { - return transliterateInner(language, sourceLanguageScript, targetLanguageScript, convertTextToData(body)); - } - - /** - * Transliterate Text. - *

- * This method is used when you have single text to transliterate and you want to provide client trace id. - *

- * + * * @param language Specifies the language of the text to convert from one script to another. * Possible languages are listed in the transliteration scope obtained by querying the service * for its supported languages. @@ -759,256 +458,6 @@ public Mono> transliterate(String language, String sour * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration * scope, to find output * scripts available for the selected combination of input language and input script. - * @param text Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono transliterate(String language, String sourceLanguageScript, - String targetLanguageScript, String text) { - return transliterate(language, sourceLanguageScript, targetLanguageScript, Arrays.asList(text)) - .map(translatedTextItems -> translatedTextItems.isEmpty() ? null : translatedTextItems.get(0)) - .defaultIfEmpty(null); - } - - /** - * Find Sentence Boundaries. - * - * @param body Defines the content of the request. - * @param language Language tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied. - * @param script Script tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - private Mono> findSentenceBoundariesInner(List body, String language, - String script) { - // Generated convenience method for findSentenceBoundariesWithResponse - RequestOptions requestOptions = new RequestOptions(); - if (language != null) { - requestOptions.addQueryParam("language", language, false); - } - if (script != null) { - requestOptions.addQueryParam("script", script, false); - } - return findSentenceBoundariesWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM)); - } - - /** - * Find Sentence Boundaries. - *

- * This method is used when you have multiple texts for which you want to find sentence boundaries and you want to - * provide - * client trace id. - *

- * - * @param texts Defines the content of the request. - * @param language Language tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied. - * @param script Script tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> findSentenceBoundaries(List texts, String language, String script) { - return findSentenceBoundariesInner(convertTextToData(texts), language, script); - } - - /** - * Find Sentence Boundaries. - *

- * This method is used when you have single text for which you want to find sentence boundaries and you want to - * provide - * client trace id. - *

- * - * @param text Defines the content of the request. - * @param language Language tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied. - * @param script Script tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono findSentenceBoundaries(String text, String language, String script) { - return findSentenceBoundaries(Arrays.asList(text), language, script) - .map(translatedTextItems -> translatedTextItems.isEmpty() ? null : translatedTextItems.get(0)) - .defaultIfEmpty(null); - } - - /** - * Find Sentence Boundaries. - * - * @param body Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - private Mono> findSentenceBoundariesInner(List body) { - // Generated convenience method for findSentenceBoundariesWithResponse - RequestOptions requestOptions = new RequestOptions(); - return findSentenceBoundariesWithResponse(BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM)); - } - - /** - * Find Sentence Boundaries. - *

- * This method is used when you have multiple texts for which you want to find sentence boundaries and you want - * the source language to be auto-detected by the service. - *

- * - * @param texts Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> findSentenceBoundaries(List texts) { - return findSentenceBoundariesInner(convertTextToData(texts)); - } - - /** - * Find Sentence Boundaries. - *

- * This method is used when you have single text for which you want to find sentence boundaries and you want - * the source language to be auto-detected by the service. - *

- * - * @param text Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono findSentenceBoundaries(String text) { - return findSentenceBoundaries(Arrays.asList(text)) - .map(translatedTextItems -> translatedTextItems.isEmpty() ? null : translatedTextItems.get(0)) - .defaultIfEmpty(null); - } - - /** - * Lookup Dictionary Entries. - * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response body on successful completion of {@link Mono}. - */ - private Mono> lookupDictionaryEntriesInner(String sourceLanguage, String targetLanguage, - List body) { - // Generated convenience method for lookupDictionaryEntriesWithResponse - RequestOptions requestOptions = new RequestOptions(); - return lookupDictionaryEntriesWithResponse(sourceLanguage, targetLanguage, BinaryData.fromObject(body), - requestOptions).flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_DICTIONARY_LOOKUP_ITEM)); - } - - /** - * Lookup Dictionary Entries. - *

- * This method is used when you want lookup multiple entries in the dictionary and you want to provide - * client trace id. - *

- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param texts Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> lookupDictionaryEntries(String sourceLanguage, String targetLanguage, - List texts) { - return lookupDictionaryEntriesInner(sourceLanguage, targetLanguage, convertTextToData(texts)); - } - - /** - * Lookup Dictionary Entries. - *

- * This method is used when you want lookup single entry in the dictionary and you want to provide - * client trace id. - *

- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param text Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono lookupDictionaryEntries(String sourceLanguage, String targetLanguage, - String text) { - return lookupDictionaryEntries(sourceLanguage, targetLanguage, Arrays.asList(text)) - .map(translatedTextItems -> translatedTextItems.isEmpty() ? null : translatedTextItems.get(0)) - .defaultIfEmpty(null); - } - - /** - * Lookup Dictionary Examples. - * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. * @param body Defines the content of the request. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -1018,14 +467,15 @@ public Mono lookupDictionaryEntries(String sourceLanguage, * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response body on successful completion of {@link Mono}. */ + @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> lookupDictionaryExamples(String sourceLanguage, String targetLanguage, - List body) { - // Generated convenience method for lookupDictionaryExamplesWithResponse + public Mono> transliterate(String language, String sourceLanguageScript, + String targetLanguageScript, List body) { + // Generated convenience method for transliterateWithResponse RequestOptions requestOptions = new RequestOptions(); - return lookupDictionaryExamplesWithResponse(sourceLanguage, targetLanguage, BinaryData.fromObject(body), - requestOptions).flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_DICTIONARY_EXAMPLE_ITEM)); + return transliterateWithResponse(language, sourceLanguageScript, targetLanguageScript, + BinaryData.fromObject(body), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_TRANSLITERATED_TEXT)); } @Generated @@ -1033,237 +483,8 @@ public Mono> lookupDictionaryExamples(String sourceL = new TypeReference>() { }; - @Generated - private static final TypeReference> TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM - = new TypeReference>() { - }; - - @Generated - private static final TypeReference> TYPE_REFERENCE_LIST_DICTIONARY_LOOKUP_ITEM - = new TypeReference>() { - }; - - @Generated - private static final TypeReference> TYPE_REFERENCE_LIST_DICTIONARY_EXAMPLE_ITEM - = new TypeReference>() { - }; - @Generated private static final TypeReference> TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM = new TypeReference>() { }; - - /** - * Gets the set of languages currently supported by other operations of the Translator. - *

Query Parameters

- * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
scopeStringNoA comma-separated list of names defining the group of languages - * to return. - * Allowed group names are: `translation`, `transliteration` and `dictionary`. - * If no scope is given, then all groups are returned, which is equivalent to passing - * `scope=translation,transliteration,dictionary`. To decide which set of supported languages - * is appropriate for your scenario, see the description of the [response object](#response-body).
- * You can add these to a request with {@link RequestOptions#addQueryParam} - *

Header Parameters

- * - * - * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
Accept-LanguageStringNoThe language to use for user interface strings. Some of - * the fields in the response are names of languages or - * names of regions. Use this parameter to define the language in which these names are returned. - * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` - * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. - * Names are provided in the English language when a target language is not specified or when localization - * is not available.
If-None-MatchStringNoPassing the value of the ETag response header in an - * If-None-Match field will allow the service to optimize the response. - * If the resource has not been modified, the service will return status code 304 and an empty response - * body.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Response Body Schema

- * - *
-     * {@code
-     * {
-     *     translation (Optional): {
-     *         String (Required): {
-     *             name: String (Required)
-     *             nativeName: String (Required)
-     *             dir: String(ltr/rtl) (Required)
-     *         }
-     *     }
-     *     transliteration (Optional): {
-     *         String (Required): {
-     *             name: String (Required)
-     *             nativeName: String (Required)
-     *             scripts (Required): [
-     *                  (Required){
-     *                     code: String (Required)
-     *                     name: String (Required)
-     *                     nativeName: String (Required)
-     *                     dir: String(ltr/rtl) (Required)
-     *                     toScripts (Required): [
-     *                          (Required){
-     *                             code: String (Required)
-     *                             name: String (Required)
-     *                             nativeName: String (Required)
-     *                             dir: String(ltr/rtl) (Required)
-     *                         }
-     *                     ]
-     *                 }
-     *             ]
-     *         }
-     *     }
-     *     dictionary (Optional): {
-     *         String (Required): {
-     *             name: String (Required)
-     *             nativeName: String (Required)
-     *             dir: String(ltr/rtl) (Required)
-     *             translations (Required): [
-     *                  (Required){
-     *                     name: String (Required)
-     *                     nativeName: String (Required)
-     *                     dir: String(ltr/rtl) (Required)
-     *                     code: String (Required)
-     *                 }
-     *             ]
-     *         }
-     *     }
-     * }
-     * }
-     * 
- * - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the set of languages currently supported by other operations of the Translator along with - * {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getSupportedLanguagesWithResponse(RequestOptions requestOptions) { - return this.serviceClient.getSupportedLanguagesWithResponseAsync(requestOptions); - } - - /** - * Gets the set of languages currently supported by other operations of the Translator. - * - * @param scope A comma-separated list of names defining the group of languages to return. - * Allowed group names are: `translation`, `transliteration` and `dictionary`. - * If no scope is given, then all groups are returned, which is equivalent to passing - * `scope=translation,transliteration,dictionary`. To decide which set of supported languages - * is appropriate for your scenario, see the description of the [response object](#response-body). - * @param acceptLanguage The language to use for user interface strings. Some of the fields in the response are - * names of languages or - * names of regions. Use this parameter to define the language in which these names are returned. - * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` - * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. - * Names are provided in the English language when a target language is not specified or when localization - * is not available. - * @param ifNoneMatch Passing the value of the ETag response header in an If-None-Match field will allow the service - * to optimize the response. - * If the resource has not been modified, the service will return status code 304 and an empty response body. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the set of languages currently supported by other operations of the Translator on successful completion - * of {@link Mono}. - */ - private Mono getSupportedLanguages(String scope, String acceptLanguage, - String ifNoneMatch) { - // Generated convenience method for getSupportedLanguagesWithResponse - RequestOptions requestOptions = new RequestOptions(); - if (scope != null) { - requestOptions.addQueryParam("scope", scope, false); - } - if (acceptLanguage != null) { - requestOptions.setHeader(HttpHeaderName.ACCEPT_LANGUAGE, acceptLanguage); - } - if (ifNoneMatch != null) { - requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); - } - return getSupportedLanguagesWithResponse(requestOptions).flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(GetSupportedLanguagesResult.class)); - } - - /** - * Gets the set of languages currently supported by other operations of the Translator. - * - * @param scopes List of names defining the group of languages to return. - * @param acceptLanguage The language to use for user interface strings. Some of the fields in the response are - * names of languages or - * names of regions. Use this parameter to define the language in which these names are returned. - * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` - * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. - * Names are provided in the English language when a target language is not specified or when localization - * is not available. - * @param ifNoneMatch Passing the value of the ETag response header in an If-None-Match field will allow the service - * to optimize the response. - * If the resource has not been modified, the service will return status code 304 and an empty response body. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the set of languages currently supported by other operations of the Translator. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getSupportedLanguages(List scopes, String acceptLanguage, - String ifNoneMatch) { - return getSupportedLanguages(convertToScopesString(scopes), acceptLanguage, ifNoneMatch); - } - - /** - * Gets the set of languages currently supported by other operations of the Translator. - * - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the set of languages currently supported by other operations of the Translator on successful completion - * of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono getSupportedLanguages() { - // Generated convenience method for getSupportedLanguagesWithResponse - RequestOptions requestOptions = new RequestOptions(); - return getSupportedLanguagesWithResponse(requestOptions).flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(GetSupportedLanguagesResult.class)); - } - - private List convertTextToData(List texts) { - List content = new ArrayList<>(); - for (String text : texts) { - content.add(new InputTextItem(text)); - } - return content; - } - - private String convertToScopesString(List scopes) { - if (scopes == null) { - return null; - } - StringBuilder result = new StringBuilder(); - for (LanguageScope scope : scopes) { - if (result.length() > 0) { - result.append(","); - } - result.append(scope.toString()); - } - return result.toString(); - } } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationClient.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationClient.java index 14d6e9528634..90fb156aef6e 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationClient.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationClient.java @@ -1,20 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.ai.translation.text; import com.azure.ai.translation.text.implementation.TextTranslationClientImpl; -import com.azure.ai.translation.text.models.BreakSentenceItem; -import com.azure.ai.translation.text.models.DictionaryExampleItem; -import com.azure.ai.translation.text.models.DictionaryExampleTextItem; -import com.azure.ai.translation.text.models.DictionaryLookupItem; import com.azure.ai.translation.text.models.GetSupportedLanguagesResult; import com.azure.ai.translation.text.models.InputTextItem; -import com.azure.ai.translation.text.models.LanguageScope; -import com.azure.ai.translation.text.models.ProfanityAction; -import com.azure.ai.translation.text.models.ProfanityMarker; -import com.azure.ai.translation.text.models.TextType; -import com.azure.ai.translation.text.models.TranslateOptions; +import com.azure.ai.translation.text.models.TranslateBodyDetails; import com.azure.ai.translation.text.models.TranslatedTextItem; import com.azure.ai.translation.text.models.TransliteratedText; import com.azure.core.annotation.Generated; @@ -30,8 +23,6 @@ import com.azure.core.http.rest.Response; import com.azure.core.util.BinaryData; import com.azure.core.util.serializer.TypeReference; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; /** @@ -39,13 +30,12 @@ */ @ServiceClient(builder = TextTranslationClientBuilder.class) public final class TextTranslationClient { - @Generated private final TextTranslationClientImpl serviceClient; /** * Initializes an instance of TextTranslationClient class. - * + * * @param serviceClient the service client implementation. */ @Generated @@ -54,54 +44,17 @@ public final class TextTranslationClient { } /** - * Translate Text. + * Gets the set of languages currently supported by other operations of the Translator. *

Query Parameters

* * * - * - * - * - * - * - * - * - * - * - * - * + * *
Query Parameters
NameTypeRequiredDescription
fromStringNoSpecifies the language of the input text. Find which languages are - * available to translate from by - * looking up supported languages using the translation scope. If the from parameter isn't specified, - * automatic language detection is applied to determine the source language. - * - * You must use the from parameter rather than autodetection when using the dynamic dictionary feature. - * Note: the dynamic dictionary feature is case-sensitive.
textTypeStringNoDefines whether the text being translated is plain text or - * HTML text. Any HTML needs to be a well-formed, - * complete element. Possible values are: plain (default) or html. Allowed values: "Plain", "Html".
categoryStringNoA string specifying the category (domain) of the translation. - * This parameter is used to get translations - * from a customized system built with Custom Translator. Add the Category ID from your Custom Translator - * project details to this parameter to use your deployed customized system. Default value is: general.
profanityActionStringNoSpecifies how profanities should be treated in - * translations. - * Possible values are: NoAction (default), Marked or Deleted. Allowed values: "NoAction", "Marked", - * "Deleted".
profanityMarkerStringNoSpecifies how profanities should be marked in - * translations. - * Possible values are: Asterisk (default) or Tag. . Allowed values: "Asterisk", "Tag".
includeAlignmentBooleanNoSpecifies whether to include alignment projection - * from source text to translated text. - * Possible values are: true or false (default).
includeSentenceLengthBooleanNoSpecifies whether to include sentence boundaries - * for the input text and the translated text. - * Possible values are: true or false (default).
suggestedFromStringNoSpecifies a fallback language if the language of the - * input text can't be identified. - * Language autodetection is applied when the from parameter is omitted. If detection fails, - * the suggestedFrom language will be assumed.
fromScriptStringNoSpecifies the script of the input text.
toScriptStringNoSpecifies the script of the translated text.
allowFallbackBooleanNoSpecifies that the service is allowed to fall back to a - * general system when a custom system doesn't exist. - * Possible values are: true (default) or false. - * - * allowFallback=false specifies that the translation should only use systems trained for the category specified - * by the request. If a translation for language X to language Y requires chaining through a pivot language E, - * then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. - * If no system is found with the specific category, the request will return a 400 status code. allowFallback=true - * specifies that the service is allowed to fall back to a general system when a custom system doesn't - * exist.
scopeStringNoA comma-separated list of names defining the group of languages + * to return. + * Allowed group names are: `translation`, `transliteration` and `dictionary`. + * If no scope is given, then all groups are returned, which is equivalent to passing + * `scope=translation,transliteration,dictionary`. To decide which set of supported languages + * is appropriate for your scenario, see the description of the [response object](#response-body).
* You can add these to a request with {@link RequestOptions#addQueryParam} *

Header Parameters

@@ -110,6 +63,94 @@ public final class TextTranslationClient { * NameTypeRequiredDescription * X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the * request. + * Accept-LanguageStringNoThe language to use for user interface strings. Some of + * the fields in the response are names of languages or + * names of regions. Use this parameter to define the language in which these names are returned. + * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` + * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. + * Names are provided in the English language when a target language is not specified or when localization + * is not available. + * If-None-MatchStringNoPassing the value of the ETag response header in an + * If-None-Match field will allow the service to optimize the response. + * If the resource has not been modified, the service will return status code 304 and an empty response + * body. + * + * You can add these to a request with {@link RequestOptions#addHeader} + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     translation (Optional): {
+     *         String (Required): {
+     *             name: String (Required)
+     *             nativeName: String (Required)
+     *             dir: String(ltr/rtl) (Required)
+     *         }
+     *     }
+     *     transliteration (Optional): {
+     *         String (Required): {
+     *             name: String (Required)
+     *             nativeName: String (Required)
+     *             scripts (Required): [
+     *                  (Required){
+     *                     code: String (Required)
+     *                     name: String (Required)
+     *                     nativeName: String (Required)
+     *                     dir: String(ltr/rtl) (Required)
+     *                     toScripts (Required): [
+     *                          (Required){
+     *                             code: String (Required)
+     *                             name: String (Required)
+     *                             nativeName: String (Required)
+     *                             dir: String(ltr/rtl) (Required)
+     *                         }
+     *                     ]
+     *                 }
+     *             ]
+     *         }
+     *     }
+     *     dictionary (Optional): {
+     *         String (Required): {
+     *             name: String (Required)
+     *             nativeName: String (Required)
+     *             dir: String(ltr/rtl) (Required)
+     *             translations (Required): [
+     *                  (Required){
+     *                     name: String (Required)
+     *                     nativeName: String (Required)
+     *                     dir: String(ltr/rtl) (Required)
+     *                     code: String (Required)
+     *                 }
+     *             ]
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the set of languages currently supported by other operations of the Translator along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getSupportedLanguagesWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getSupportedLanguagesWithResponse(requestOptions); + } + + /** + * Translate Text. + *

Header Parameters

+ * + * + * + * *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the + * request.
* You can add these to a request with {@link RequestOptions#addHeader} *

Request Body Schema

@@ -119,6 +160,31 @@ public final class TextTranslationClient { * [ * (Required){ * text: String (Required) + * script: String (Optional) + * language: String (Optional) + * textType: String(Plain/Html) (Optional) + * targets (Required): [ + * (Required){ + * language (Required): [ + * String (Required) + * ] + * script: String (Optional) + * profanityAction: String(NoAction/Marked/Deleted) (Optional) + * profanityMarker: String(Asterisk/Tag) (Optional) + * deploymentNameModel: String (Optional) + * allowFallback: Boolean (Optional) + * grade: String (Optional) + * tone: String (Optional) + * gender: String (Optional) + * adaptiveDatasetId: String (Optional) + * referenceTextPairs (Optional): [ + * (Optional){ + * referenceTextPairsSource: String (Required) + * referenceTextPairsTarget: String (Required) + * } + * ] + * } + * ] * } * ] * } @@ -142,17 +208,6 @@ public final class TextTranslationClient { * text: String (Required) * script: String (Required) * } - * alignment (Optional): { - * proj: String (Required) - * } - * sentLen (Optional): { - * srcSentLen (Required): [ - * int (Required) - * ] - * transSentLen (Required): [ - * int (Required) - * ] - * } * } * ] * sourceText (Optional): { @@ -162,12 +217,7 @@ public final class TextTranslationClient { * ] * } * - * - * @param targetLanguages Specifies the language of the output text. The target language must be one of the - * supported languages included - * in the translation scope. For example, use to=de to translate to German. - * It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. - * For example, use to=de&to=it to translate to German and Italian. + * * @param body Defines the content of the request. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. @@ -178,9 +228,8 @@ public final class TextTranslationClient { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response translateWithResponse(List targetLanguages, BinaryData body, - RequestOptions requestOptions) { - return this.serviceClient.translateWithResponse(targetLanguages, body, requestOptions); + public Response translate2WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.translate2WithResponse(body, requestOptions); } /** @@ -217,7 +266,7 @@ public Response translateWithResponse(List targetLanguages, * ] * } * - * + * * @param language Specifies the language of the text to convert from one script to another. * Possible languages are listed in the transliteration scope obtained by querying the service * for its supported languages. @@ -244,318 +293,99 @@ public Response transliterateWithResponse(String language, String so } /** - * Find Sentence Boundaries. - *

Query Parameters

- * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
languageStringNoLanguage tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied.
scriptStringNoScript tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed.
- * You can add these to a request with {@link RequestOptions#addQueryParam} - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

+ * Gets the set of languages currently supported by other operations of the Translator. * - *
-     * {@code
-     * [
-     *      (Required){
-     *         detectedLanguage (Optional): {
-     *             language: String (Required)
-     *             score: double (Required)
-     *         }
-     *         sentLen (Required): [
-     *             int (Required)
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @param clientTraceId A client-generated GUID to uniquely identify the request. + * @param scope A comma-separated list of names defining the group of languages to return. + * Allowed group names are: `translation`, `transliteration` and `dictionary`. + * If no scope is given, then all groups are returned, which is equivalent to passing + * `scope=translation,transliteration,dictionary`. To decide which set of supported languages + * is appropriate for your scenario, see the description of the [response object](#response-body). + * @param acceptLanguage The language to use for user interface strings. Some of the fields in the response are + * names of languages or + * names of regions. Use this parameter to define the language in which these names are returned. + * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` + * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. + * Names are provided in the English language when a target language is not specified or when localization + * is not available. + * @param ifNoneMatch Passing the value of the ETag response header in an If-None-Match field will allow the service + * to optimize the response. + * If the resource has not been modified, the service will return status code 304 and an empty response body. + * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the set of languages currently supported by other operations of the Translator. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response findSentenceBoundariesWithResponse(BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.findSentenceBoundariesWithResponse(body, requestOptions); + public GetSupportedLanguagesResult getSupportedLanguages(String clientTraceId, String scope, String acceptLanguage, + String ifNoneMatch) { + // Generated convenience method for getSupportedLanguagesWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (clientTraceId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("X-ClientTraceId"), clientTraceId); + } + if (scope != null) { + requestOptions.addQueryParam("scope", scope, false); + } + if (acceptLanguage != null) { + requestOptions.setHeader(HttpHeaderName.ACCEPT_LANGUAGE, acceptLanguage); + } + if (ifNoneMatch != null) { + requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); + } + return getSupportedLanguagesWithResponse(requestOptions).getValue().toObject(GetSupportedLanguagesResult.class); } /** - * Lookup Dictionary Entries. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
+ * Gets the set of languages currently supported by other operations of the Translator. * - *

Response Body Schema

+ * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the set of languages currently supported by other operations of the Translator. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public GetSupportedLanguagesResult getSupportedLanguages() { + // Generated convenience method for getSupportedLanguagesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getSupportedLanguagesWithResponse(requestOptions).getValue().toObject(GetSupportedLanguagesResult.class); + } + + /** + * Translate Text. * - *
-     * {@code
-     * [
-     *      (Required){
-     *         normalizedSource: String (Required)
-     *         displaySource: String (Required)
-     *         translations (Required): [
-     *              (Required){
-     *                 normalizedTarget: String (Required)
-     *                 displayTarget: String (Required)
-     *                 posTag: String (Required)
-     *                 confidence: double (Required)
-     *                 prefixWord: String (Required)
-     *                 backTranslations (Required): [
-     *                      (Required){
-     *                         normalizedText: String (Required)
-     *                         displayText: String (Required)
-     *                         numExamples: int (Required)
-     *                         frequencyCount: int (Required)
-     *                     }
-     *                 ]
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @param clientTraceId A client-generated GUID to uniquely identify the request. + * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response lookupDictionaryEntriesWithResponse(String sourceLanguage, String targetLanguage, - BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.lookupDictionaryEntriesWithResponse(sourceLanguage, targetLanguage, body, - requestOptions); - } - - /** - * Lookup Dictionary Examples. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *         translation: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         normalizedSource: String (Required)
-     *         normalizedTarget: String (Required)
-     *         examples (Required): [
-     *              (Required){
-     *                 sourcePrefix: String (Required)
-     *                 sourceTerm: String (Required)
-     *                 sourceSuffix: String (Required)
-     *                 targetPrefix: String (Required)
-     *                 targetTerm: String (Required)
-     *                 targetSuffix: String (Required)
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response lookupDictionaryExamplesWithResponse(String sourceLanguage, String targetLanguage, - BinaryData body, RequestOptions requestOptions) { - return this.serviceClient.lookupDictionaryExamplesWithResponse(sourceLanguage, targetLanguage, body, - requestOptions); + public List translate2(List body, String clientTraceId) { + // Generated convenience method for translate2WithResponse + RequestOptions requestOptions = new RequestOptions(); + if (clientTraceId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("X-ClientTraceId"), clientTraceId); + } + return translate2WithResponse(BinaryData.fromObject(body), requestOptions).getValue() + .toObject(TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM); } /** * Translate Text. - * - * @param targetLanguages Specifies the language of the output text. The target language must be one of the - * supported languages included - * in the translation scope. For example, use to=de to translate to German. - * It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. - * For example, use to=de&to=it to translate to German and Italian. - * @param body Defines the content of the request. - * @param clientTraceId A client-generated GUID to uniquely identify the request. - * @param sourceLanguage Specifies the language of the input text. Find which languages are available to translate - * from by - * looking up supported languages using the translation scope. If the from parameter isn't specified, - * automatic language detection is applied to determine the source language. - * - * You must use the from parameter rather than autodetection when using the dynamic dictionary feature. - * Note: the dynamic dictionary feature is case-sensitive. - * @param textType Defines whether the text being translated is plain text or HTML text. Any HTML needs to be a - * well-formed, - * complete element. Possible values are: plain (default) or html. - * @param category A string specifying the category (domain) of the translation. This parameter is used to get - * translations - * from a customized system built with Custom Translator. Add the Category ID from your Custom Translator - * project details to this parameter to use your deployed customized system. Default value is: general. - * @param profanityAction Specifies how profanities should be treated in translations. - * Possible values are: NoAction (default), Marked or Deleted. - * @param profanityMarker Specifies how profanities should be marked in translations. - * Possible values are: Asterisk (default) or Tag. - * @param includeAlignment Specifies whether to include alignment projection from source text to translated text. - * Possible values are: true or false (default). - * @param includeSentenceLength Specifies whether to include sentence boundaries for the input text and the - * translated text. - * Possible values are: true or false (default). - * @param suggestedSourceLanguage Specifies a fallback language if the language of the input text can't be - * identified. - * Language autodetection is applied when the from parameter is omitted. If detection fails, - * the suggestedFrom language will be assumed. - * @param sourceLanguageScript Specifies the script of the input text. - * @param targetLanguageScript Specifies the script of the translated text. - * @param allowFallback Specifies that the service is allowed to fall back to a general system when a custom system - * doesn't exist. - * Possible values are: true (default) or false. - * - * allowFallback=false specifies that the translation should only use systems trained for the category specified - * by the request. If a translation for language X to language Y requires chaining through a pivot language E, - * then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. - * If no system is found with the specific category, the request will return a 400 status code. allowFallback=true - * specifies that the service is allowed to fall back to a general system when a custom system doesn't exist. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - private List translate(List targetLanguages, List body, - String clientTraceId, String sourceLanguage, TextType textType, String category, - ProfanityAction profanityAction, ProfanityMarker profanityMarker, Boolean includeAlignment, - Boolean includeSentenceLength, String suggestedSourceLanguage, String sourceLanguageScript, - String targetLanguageScript, Boolean allowFallback) { - // Generated convenience method for translateWithResponse - RequestOptions requestOptions = new RequestOptions(); - if (clientTraceId != null) { - requestOptions.setHeader(HttpHeaderName.fromString("X-ClientTraceId"), clientTraceId); - } - if (sourceLanguage != null) { - requestOptions.addQueryParam("from", sourceLanguage, false); - } - if (textType != null) { - requestOptions.addQueryParam("textType", textType.toString(), false); - } - if (category != null) { - requestOptions.addQueryParam("category", category, false); - } - if (profanityAction != null) { - requestOptions.addQueryParam("profanityAction", profanityAction.toString(), false); - } - if (profanityMarker != null) { - requestOptions.addQueryParam("profanityMarker", profanityMarker.toString(), false); - } - if (includeAlignment != null) { - requestOptions.addQueryParam("includeAlignment", String.valueOf(includeAlignment), false); - } - if (includeSentenceLength != null) { - requestOptions.addQueryParam("includeSentenceLength", String.valueOf(includeSentenceLength), false); - } - if (suggestedSourceLanguage != null) { - requestOptions.addQueryParam("suggestedFrom", suggestedSourceLanguage, false); - } - if (sourceLanguageScript != null) { - requestOptions.addQueryParam("fromScript", sourceLanguageScript, false); - } - if (targetLanguageScript != null) { - requestOptions.addQueryParam("toScript", targetLanguageScript, false); - } - if (allowFallback != null) { - requestOptions.addQueryParam("allowFallback", String.valueOf(allowFallback), false); - } - return translateWithResponse(targetLanguages, BinaryData.fromObject(body), requestOptions).getValue() - .toObject(TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM); - } - - /** - * Translate Text. - * - * @param targetLanguages Specifies the language of the output text. The target language must be one of the - * supported languages included - * in the translation scope. For example, use to=de to translate to German. - * It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. - * For example, use to=de&to=it to translate to German and Italian. + * * @param body Defines the content of the request. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -565,119 +395,18 @@ private List translate(List targetLanguages, List translateInner(List targetLanguages, List body) { - // Generated convenience method for translateWithResponse + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List translate2(List body) { + // Generated convenience method for translate2WithResponse RequestOptions requestOptions = new RequestOptions(); - return translateWithResponse(targetLanguages, BinaryData.fromObject(body), requestOptions).getValue() + return translate2WithResponse(BinaryData.fromObject(body), requestOptions).getValue() .toObject(TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM); } - /** - * Translate Text. - *

- * This method is used when you have single target language and multiple texts to translate. - *

- * - * @param targetLanguage Specifies the language of the output text. The target language must be one of the - * supported languages included - * in the translation scope. For example, use to=de to translate to German. - * It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. - * For example, use to=de&to=it to translate to German and Italian. - * @param texts Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public List translate(String targetLanguage, List texts) { - return translateInner(Arrays.asList(targetLanguage), convertTextToData(texts)); - } - - /** - * Translate Text. - *

- * This method is used when you have single target language and single text to translate. - *

- * - * @param targetLanguage Specifies the language of the output text. The target language must be one of the - * supported languages included - * in the translation scope. For example, use to=de to translate to German. - * It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. - * For example, use to=de&to=it to translate to German and Italian. - * @param text Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public TranslatedTextItem translate(String targetLanguage, String text) { - return translate(targetLanguage, Arrays.asList(text)).get(0); - } - - /** - * Translate Text. - *

- * This method is used when you have one input text and the optional parameters are needed such as specification - * of a source language, profanity handling etc. - *

- * - * @param text Text to translate. - * @param translateOptions Translate Options. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public TranslatedTextItem translate(String text, TranslateOptions translateOptions) { - return translate(Arrays.asList(text), translateOptions).get(0); - } - - /** - * Translate Text. - *

- * This method is used when you have multiple texts and the optional parameters are needed such as specification - * of a source language, profanity handling etc.. - *

- * - * @param texts List of text to translate. - * @param translateOptions Translate Options. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public List translate(List texts, TranslateOptions translateOptions) { - List content = new ArrayList<>(); - for (String text : texts) { - content.add(new InputTextItem(text)); - } - return translate(translateOptions.getTargetLanguages(), content, translateOptions.getClientTraceId(), - translateOptions.getSourceLanguage(), translateOptions.getTextType(), translateOptions.getCategory(), - translateOptions.getProfanityAction(), translateOptions.getProfanityMarker(), - translateOptions.isIncludeAlignment(), translateOptions.isIncludeSentenceLength(), - translateOptions.getSuggestedSourceLanguage(), translateOptions.getSourceLanguageScript(), - translateOptions.getTargetLanguageScript(), translateOptions.isAllowFallback()); - } - /** * Transliterate Text. - * + * * @param language Specifies the language of the text to convert from one script to another. * Possible languages are listed in the transliteration scope obtained by querying the service * for its supported languages. @@ -688,6 +417,7 @@ public List translate(List texts, TranslateOptions t * scope, to find output * scripts available for the selected combination of input language and input script. * @param body Defines the content of the request. + * @param clientTraceId A client-generated GUID to uniquely identify the request. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -696,50 +426,22 @@ public List translate(List texts, TranslateOptions t * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. * @return the response. */ - private List transliterateInner(String language, String sourceLanguageScript, - String targetLanguageScript, List body) { + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public List transliterate(String language, String sourceLanguageScript, + String targetLanguageScript, List body, String clientTraceId) { // Generated convenience method for transliterateWithResponse RequestOptions requestOptions = new RequestOptions(); + if (clientTraceId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("X-ClientTraceId"), clientTraceId); + } return transliterateWithResponse(language, sourceLanguageScript, targetLanguageScript, BinaryData.fromObject(body), requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_TRANSLITERATED_TEXT); } /** * Transliterate Text. - *

- * This method is used when you have multiple texts to transliterate and you want to provide client trace id. - *

- * - * @param language Specifies the language of the text to convert from one script to another. - * Possible languages are listed in the transliteration scope obtained by querying the service - * for its supported languages. - * @param sourceLanguageScript Specifies the script used by the input text. Look up supported languages using the - * transliteration scope, - * to find input scripts available for the selected language. - * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration - * scope, to find output - * scripts available for the selected combination of input language and input script. - * @param body Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public List transliterate(String language, String sourceLanguageScript, - String targetLanguageScript, List body) { - return transliterateInner(language, sourceLanguageScript, targetLanguageScript, convertTextToData(body)); - } - - /** - * Transliterate Text. - *

- * This method is used when you have single text to transliterate and you want to provide client trace id. - *

- * + * * @param language Specifies the language of the text to convert from one script to another. * Possible languages are listed in the transliteration scope obtained by querying the service * for its supported languages. @@ -749,246 +451,6 @@ public List transliterate(String language, String sourceLang * @param targetLanguageScript Specifies the output script. Look up supported languages using the transliteration * scope, to find output * scripts available for the selected combination of input language and input script. - * @param text Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public TransliteratedText transliterate(String language, String sourceLanguageScript, String targetLanguageScript, - String text) { - return transliterate(language, sourceLanguageScript, targetLanguageScript, Arrays.asList(text)).get(0); - } - - /** - * Find Sentence Boundaries. - * - * @param body Defines the content of the request. - * @param language Language tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied. - * @param script Script tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - private List findSentenceBoundariesInner(List body, String language, - String script) { - // Generated convenience method for findSentenceBoundariesWithResponse - RequestOptions requestOptions = new RequestOptions(); - if (language != null) { - requestOptions.addQueryParam("language", language, false); - } - if (script != null) { - requestOptions.addQueryParam("script", script, false); - } - return findSentenceBoundariesWithResponse(BinaryData.fromObject(body), requestOptions).getValue() - .toObject(TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM); - } - - /** - * Find Sentence Boundaries. - *

- * This method is used when you have multiple texts for which you want to find sentence boundaries and you want to - * provide - * client trace id. - *

- * - * @param texts Defines the content of the request. - * @param language Language tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied. - * @param script Script tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public List findSentenceBoundaries(List texts, String language, String script) { - return findSentenceBoundariesInner(convertTextToData(texts), language, script); - } - - /** - * Find Sentence Boundaries. - *

- * This method is used when you have single text for which you want to find sentence boundaries and you want to - * provide - * client trace id. - *

- * - * @param text Defines the content of the request. - * @param language Language tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied. - * @param script Script tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BreakSentenceItem findSentenceBoundaries(String text, String language, String script) { - return findSentenceBoundaries(Arrays.asList(text), language, script).get(0); - } - - /** - * Find Sentence Boundaries. - * - * @param body Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - private List findSentenceBoundariesInner(List body) { - // Generated convenience method for findSentenceBoundariesWithResponse - RequestOptions requestOptions = new RequestOptions(); - return findSentenceBoundariesWithResponse(BinaryData.fromObject(body), requestOptions).getValue() - .toObject(TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM); - } - - /** - * Find Sentence Boundaries. - *

- * This method is used when you have multiple texts for which you want to find sentence boundaries and you want - * the source language to be auto-detected by the service. - *

- * - * @param texts Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public List findSentenceBoundaries(List texts) { - return findSentenceBoundariesInner(convertTextToData(texts)); - } - - /** - * Find Sentence Boundaries. - *

- * This method is used when you have single text for which you want to find sentence boundaries and you want - * the source language to be auto-detected by the service. - *

- * - * @param text Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public BreakSentenceItem findSentenceBoundaries(String text) { - return findSentenceBoundaries(Arrays.asList(text)).get(0); - } - - /** - * Lookup Dictionary Entries. - * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - private List lookupDictionaryEntriesInner(String sourceLanguage, String targetLanguage, - List body) { - // Generated convenience method for lookupDictionaryEntriesWithResponse - RequestOptions requestOptions = new RequestOptions(); - return lookupDictionaryEntriesWithResponse(sourceLanguage, targetLanguage, BinaryData.fromObject(body), - requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_DICTIONARY_LOOKUP_ITEM); - } - - /** - * Lookup Dictionary Entries. - *

- * This method is used when you want lookup multiple entries in the dictionary and you want to provide - * client trace id. - *

- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param texts Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public List lookupDictionaryEntries(String sourceLanguage, String targetLanguage, - List texts) { - return lookupDictionaryEntriesInner(sourceLanguage, targetLanguage, convertTextToData(texts)); - } - - /** - * Lookup Dictionary Entries. - *

- * This method is used when you want lookup single entry in the dictionary and you want to provide - * client trace id. - *

- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param text Defines the content of the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public DictionaryLookupItem lookupDictionaryEntries(String sourceLanguage, String targetLanguage, String text) { - return lookupDictionaryEntries(sourceLanguage, targetLanguage, Arrays.asList(text)).get(0); - } - - /** - * Lookup Dictionary Examples. - * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. * @param body Defines the content of the request. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. @@ -1000,12 +462,12 @@ public DictionaryLookupItem lookupDictionaryEntries(String sourceLanguage, Strin */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public List lookupDictionaryExamples(String sourceLanguage, String targetLanguage, - List body) { - // Generated convenience method for lookupDictionaryExamplesWithResponse + public List transliterate(String language, String sourceLanguageScript, + String targetLanguageScript, List body) { + // Generated convenience method for transliterateWithResponse RequestOptions requestOptions = new RequestOptions(); - return lookupDictionaryExamplesWithResponse(sourceLanguage, targetLanguage, BinaryData.fromObject(body), - requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_DICTIONARY_EXAMPLE_ITEM); + return transliterateWithResponse(language, sourceLanguageScript, targetLanguageScript, + BinaryData.fromObject(body), requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_TRANSLITERATED_TEXT); } @Generated @@ -1013,260 +475,8 @@ public List lookupDictionaryExamples(String sourceLanguag = new TypeReference>() { }; - @Generated - private static final TypeReference> TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM - = new TypeReference>() { - }; - - @Generated - private static final TypeReference> TYPE_REFERENCE_LIST_DICTIONARY_LOOKUP_ITEM - = new TypeReference>() { - }; - - @Generated - private static final TypeReference> TYPE_REFERENCE_LIST_DICTIONARY_EXAMPLE_ITEM - = new TypeReference>() { - }; - @Generated private static final TypeReference> TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM = new TypeReference>() { }; - - /** - * Gets the set of languages currently supported by other operations of the Translator. - *

Query Parameters

- * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
scopeStringNoA comma-separated list of names defining the group of languages - * to return. - * Allowed group names are: `translation`, `transliteration` and `dictionary`. - * If no scope is given, then all groups are returned, which is equivalent to passing - * `scope=translation,transliteration,dictionary`. To decide which set of supported languages - * is appropriate for your scenario, see the description of the [response object](#response-body).
- * You can add these to a request with {@link RequestOptions#addQueryParam} - *

Header Parameters

- * - * - * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
Accept-LanguageStringNoThe language to use for user interface strings. Some of - * the fields in the response are names of languages or - * names of regions. Use this parameter to define the language in which these names are returned. - * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` - * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. - * Names are provided in the English language when a target language is not specified or when localization - * is not available.
If-None-MatchStringNoPassing the value of the ETag response header in an - * If-None-Match field will allow the service to optimize the response. - * If the resource has not been modified, the service will return status code 304 and an empty response - * body.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Response Body Schema

- * - *
-     * {@code
-     * {
-     *     translation (Optional): {
-     *         String (Required): {
-     *             name: String (Required)
-     *             nativeName: String (Required)
-     *             dir: String(ltr/rtl) (Required)
-     *         }
-     *     }
-     *     transliteration (Optional): {
-     *         String (Required): {
-     *             name: String (Required)
-     *             nativeName: String (Required)
-     *             scripts (Required): [
-     *                  (Required){
-     *                     code: String (Required)
-     *                     name: String (Required)
-     *                     nativeName: String (Required)
-     *                     dir: String(ltr/rtl) (Required)
-     *                     toScripts (Required): [
-     *                          (Required){
-     *                             code: String (Required)
-     *                             name: String (Required)
-     *                             nativeName: String (Required)
-     *                             dir: String(ltr/rtl) (Required)
-     *                         }
-     *                     ]
-     *                 }
-     *             ]
-     *         }
-     *     }
-     *     dictionary (Optional): {
-     *         String (Required): {
-     *             name: String (Required)
-     *             nativeName: String (Required)
-     *             dir: String(ltr/rtl) (Required)
-     *             translations (Required): [
-     *                  (Required){
-     *                     name: String (Required)
-     *                     nativeName: String (Required)
-     *                     dir: String(ltr/rtl) (Required)
-     *                     code: String (Required)
-     *                 }
-     *             ]
-     *         }
-     *     }
-     * }
-     * }
-     * 
- * - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the set of languages currently supported by other operations of the Translator along with - * {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Response getSupportedLanguagesWithResponse(RequestOptions requestOptions) { - return this.serviceClient.getSupportedLanguagesWithResponse(requestOptions); - } - - /** - * Gets the set of languages currently supported by other operations of the Translator. - * - * @param scope A comma-separated list of names defining the group of languages to return. - * Allowed group names are: `translation`, `transliteration` and `dictionary`. - * If no scope is given, then all groups are returned, which is equivalent to passing - * `scope=translation,transliteration,dictionary`. To decide which set of supported languages - * is appropriate for your scenario, see the description of the [response object](#response-body). - * @param acceptLanguage The language to use for user interface strings. Some of the fields in the response are - * names of languages or - * names of regions. Use this parameter to define the language in which these names are returned. - * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` - * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. - * Names are provided in the English language when a target language is not specified or when localization - * is not available. - * @param ifNoneMatch Passing the value of the ETag response header in an If-None-Match field will allow the service - * to optimize the response. - * If the resource has not been modified, the service will return status code 304 and an empty response body. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the set of languages currently supported by other operations of the Translator. - */ - private GetSupportedLanguagesResult getSupportedLanguages(String scope, String acceptLanguage, String ifNoneMatch) { - // Generated convenience method for getSupportedLanguagesWithResponse - RequestOptions requestOptions = new RequestOptions(); - if (scope != null) { - requestOptions.addQueryParam("scope", scope, false); - } - if (acceptLanguage != null) { - requestOptions.setHeader(HttpHeaderName.ACCEPT_LANGUAGE, acceptLanguage); - } - if (ifNoneMatch != null) { - requestOptions.setHeader(HttpHeaderName.IF_NONE_MATCH, ifNoneMatch); - } - return getSupportedLanguagesWithResponse(requestOptions).getValue().toObject(GetSupportedLanguagesResult.class); - } - - /** - * Gets the set of languages currently supported by other operations of the Translator. - * - * @param scopes List of names defining the group of languages to return. - * @param acceptLanguage The language to use for user interface strings. Some of the fields in the response are - * names of languages or - * names of regions. Use this parameter to define the language in which these names are returned. - * The language is specified by providing a well-formed BCP 47 language tag. For instance, use the value `fr` - * to request names in French or use the value `zh-Hant` to request names in Chinese Traditional. - * Names are provided in the English language when a target language is not specified or when localization - * is not available. - * @param ifNoneMatch Passing the value of the ETag response header in an If-None-Match field will allow the service - * to optimize the response. - * If the resource has not been modified, the service will return status code 304 and an empty response body. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the set of languages currently supported by other operations of the Translator. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public GetSupportedLanguagesResult getSupportedLanguages(List scopes, String acceptLanguage, - String ifNoneMatch) { - return getSupportedLanguages(convertToScopesString(scopes), acceptLanguage, ifNoneMatch); - } - - /** - * Gets the set of languages currently supported by other operations of the Translator. - * - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the set of languages currently supported by other operations of the Translator. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public GetSupportedLanguagesResult getSupportedLanguages() { - // Generated convenience method for getSupportedLanguagesWithResponse - RequestOptions requestOptions = new RequestOptions(); - return getSupportedLanguagesWithResponse(requestOptions).getValue().toObject(GetSupportedLanguagesResult.class); - } - - private List convertTextToData(List texts) { - List content = new ArrayList<>(); - for (String text : texts) { - content.add(new InputTextItem(text)); - } - return content; - } - - private String convertToScopesString(List scopes) { - if (scopes == null) { - return null; - } - StringBuilder result = new StringBuilder(); - for (LanguageScope scope : scopes) { - if (result.length() > 0) { - result.append(","); - } - result.append(scope.toString()); - } - return result.toString(); - } - - /** - * Lookup Dictionary Examples. - * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @param clientTraceId A client-generated GUID to uniquely identify the request. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response. - */ - private List lookupDictionaryExamples(String sourceLanguage, String targetLanguage, - List body, String clientTraceId) { - // Generated convenience method for lookupDictionaryExamplesWithResponse - RequestOptions requestOptions = new RequestOptions(); - if (clientTraceId != null) { - requestOptions.setHeader(HttpHeaderName.fromString("X-ClientTraceId"), clientTraceId); - } - return lookupDictionaryExamplesWithResponse(sourceLanguage, targetLanguage, BinaryData.fromObject(body), - requestOptions).getValue().toObject(TYPE_REFERENCE_LIST_DICTIONARY_EXAMPLE_ITEM); - } } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationClientBuilder.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationClientBuilder.java index 30244e9974dd..1c280d9185f4 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationClientBuilder.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationClientBuilder.java @@ -1,21 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.ai.translation.text; import com.azure.ai.translation.text.implementation.TextTranslationClientImpl; -import com.azure.ai.translation.text.models.TextTranslationAudience; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ServiceClientBuilder; import com.azure.core.client.traits.ConfigurationTrait; import com.azure.core.client.traits.EndpointTrait; import com.azure.core.client.traits.HttpTrait; -import com.azure.core.client.traits.KeyCredentialTrait; -import com.azure.core.client.traits.TokenCredentialTrait; -import com.azure.core.credential.KeyCredential; -import com.azure.core.credential.TokenCredential; import com.azure.core.http.HttpClient; -import com.azure.core.http.HttpHeaderName; import com.azure.core.http.HttpHeaders; import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpPipelineBuilder; @@ -23,12 +18,10 @@ import com.azure.core.http.policy.AddDatePolicy; import com.azure.core.http.policy.AddHeadersFromContextPolicy; import com.azure.core.http.policy.AddHeadersPolicy; -import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.HttpLoggingPolicy; import com.azure.core.http.policy.HttpPipelinePolicy; import com.azure.core.http.policy.HttpPolicyProviders; -import com.azure.core.http.policy.KeyCredentialPolicy; import com.azure.core.http.policy.RequestIdPolicy; import com.azure.core.http.policy.RetryOptions; import com.azure.core.http.policy.RetryPolicy; @@ -39,8 +32,6 @@ import com.azure.core.util.builder.ClientBuilderUtil; import com.azure.core.util.logging.ClientLogger; import com.azure.core.util.serializer.JacksonAdapter; -import java.net.MalformedURLException; -import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -51,33 +42,13 @@ */ @ServiceClientBuilder(serviceClients = { TextTranslationClient.class, TextTranslationAsyncClient.class }) public final class TextTranslationClientBuilder implements HttpTrait, - ConfigurationTrait, EndpointTrait, - KeyCredentialTrait, TokenCredentialTrait { - + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @Generated private static final String SDK_VERSION = "version"; - private static final String DEFAULT_SCOPE = "/.default"; - - private static final String OCP_APIM_SUBSCRIPTION_KEY = "Ocp-Apim-Subscription-Key"; - - private static final String OCP_APIM_SUBSCRIPTION_REGION = "Ocp-Apim-Subscription-Region"; - - private static final String OCP_APIM_RESOURCE_ID_KEY = "Ocp-Apim-ResourceId"; - - private String region; - - private String resourceId; - - private TextTranslationAudience audience; - - private KeyCredential credential; - - private TokenCredential tokenCredential; - @Generated private static final Map PROPERTIES = CoreUtils.getProperties("azure-ai-translation-text.properties"); @@ -94,37 +65,37 @@ public TextTranslationClientBuilder() { } /* - * The HTTP pipeline to send requests through. + * The HTTP client used to send the request. */ @Generated - private HttpPipeline pipeline; + private HttpClient httpClient; /** * {@inheritDoc}. */ @Generated @Override - public TextTranslationClientBuilder pipeline(HttpPipeline pipeline) { - if (this.pipeline != null && pipeline == null) { - LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); - } - this.pipeline = pipeline; + public TextTranslationClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; return this; } /* - * The HTTP client used to send the request. + * The HTTP pipeline to send requests through. */ @Generated - private HttpClient httpClient; + private HttpPipeline pipeline; /** * {@inheritDoc}. */ @Generated @Override - public TextTranslationClientBuilder httpClient(HttpClient httpClient) { - this.httpClient = httpClient; + public TextTranslationClientBuilder pipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; return this; } @@ -209,15 +180,13 @@ public TextTranslationClientBuilder configuration(Configuration configuration) { @Generated private String endpoint; - private Boolean isCustomEndpoint = false; - /** * {@inheritDoc}. */ + @Generated @Override public TextTranslationClientBuilder endpoint(String endpoint) { this.endpoint = endpoint; - this.isCustomEndpoint = CustomEndpointUtils.isPlatformHost(endpoint); return this; } @@ -229,7 +198,7 @@ public TextTranslationClientBuilder endpoint(String endpoint) { /** * Sets Service version. - * + * * @param serviceVersion the serviceVersion value. * @return the TextTranslationClientBuilder. */ @@ -247,7 +216,7 @@ public TextTranslationClientBuilder serviceVersion(TextTranslationServiceVersion /** * Sets The retry policy that will attempt to retry failed requests, if applicable. - * + * * @param retryPolicy the retryPolicy value. * @return the TextTranslationClientBuilder. */ @@ -257,113 +226,30 @@ public TextTranslationClientBuilder retryPolicy(RetryPolicy retryPolicy) { return this; } - /** - * Sets the {@link KeyCredential} used to authorize requests sent to the service. - * - * @param credential {@link KeyCredential} used to authorize requests sent to the service. - * @return The updated {@link TextTranslationClientBuilder} object. - * @throws NullPointerException If {@code credential} is null. - */ - public TextTranslationClientBuilder credential(KeyCredential credential) { - Objects.requireNonNull(credential, "'credential' cannot be null."); - this.credential = credential; - return this; - } - - /** - * Sets the region used to authorize requests sent to the service. - * - * @param region where the Translator resource is created. - * @return The updated {@link TextTranslationClientBuilder} object. - * @throws NullPointerException If {@code region} is null. - */ - public TextTranslationClientBuilder region(String region) { - Objects.requireNonNull(region, "'region' cannot be null."); - this.region = region; - return this; - } - - /** - * Sets the Azure Resource Id used to authorize requests sent to the service. - * - * @param resourceId Id of the Translator Resource. - * @return The updated {@link TextTranslationClientBuilder} object. - * @throws NullPointerException If {@code resourceId} is null. - */ - public TextTranslationClientBuilder resourceId(String resourceId) { - Objects.requireNonNull(resourceId, "'resourceId' cannot be null."); - this.resourceId = resourceId; - return this; - } - - /** - * Sets the Authentication audience used to authorize requests sent to the service. - * - * @param audience Token Audience. - * @return The updated {@link TextTranslationClientBuilder} object. - * @throws NullPointerException If {@code audience} is null. - */ - public TextTranslationClientBuilder audience(TextTranslationAudience audience) { - Objects.requireNonNull(audience, "'audience' cannot be null."); - this.audience = audience; - return this; - } - - /** - * Sets the {@link TokenCredential} used to authorize requests sent to the service. Refer to the Azure SDK for Java - * identity and authentication - * documentation for more details on proper usage of the {@link TokenCredential} type. - * - * @param tokenCredential {@link TokenCredential} used to authorize requests sent to the service. - * @return The updated {@link TextTranslationClientBuilder} object. - * @throws NullPointerException If {@code tokenCredential} is null. - */ - public TextTranslationClientBuilder credential(TokenCredential tokenCredential) { - Objects.requireNonNull(tokenCredential, "'tokenCredential' cannot be null."); - this.tokenCredential = tokenCredential; - return this; - } - /** * Builds an instance of TextTranslationClientImpl with the provided parameters. - * + * * @return an instance of TextTranslationClientImpl. */ + @Generated private TextTranslationClientImpl buildInnerClient() { + this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); TextTranslationServiceVersion localServiceVersion = (serviceVersion != null) ? serviceVersion : TextTranslationServiceVersion.getLatest(); - String serviceEndpoint; - if (this.endpoint == null) { - serviceEndpoint = "https://api.cognitive.microsofttranslator.com"; - } else if (this.isCustomEndpoint) { - try { - URL hostUri = new URL(endpoint); - URL fullUri = new URL(hostUri, "/translator/text/v" + localServiceVersion.getVersion()); - serviceEndpoint = fullUri.toString(); - } catch (MalformedURLException ex) { - serviceEndpoint = endpoint; - } - } else { - serviceEndpoint = endpoint; - } - if (tokenCredential != null && (this.region != null || this.resourceId != null)) { - Objects.requireNonNull(this.region, "'region' cannot be null."); - Objects.requireNonNull(this.resourceId, "'resourceId' cannot be null."); - } - if (this.credential != null && !CoreUtils.isNullOrEmpty(this.resourceId)) { - throw LOGGER.logExceptionAsError( - new IllegalStateException("Resource Id cannot be used with key credential. Set resourceId to null.")); - } - if (tokenCredential != null && this.credential != null) { - throw LOGGER.logExceptionAsError( - new IllegalStateException("Both token credential and key credential cannot be set.")); - } TextTranslationClientImpl client = new TextTranslationClientImpl(localPipeline, - JacksonAdapter.createDefaultSerializerAdapter(), serviceEndpoint, localServiceVersion); + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); return client; } + @Generated + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @Generated private HttpPipeline createHttpPipeline() { Configuration buildConfiguration = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; @@ -376,10 +262,8 @@ private HttpPipeline createHttpPipeline() { policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration)); policies.add(new RequestIdPolicy()); policies.add(new AddHeadersFromContextPolicy()); - HttpHeaders headers = new HttpHeaders(); - localClientOptions.getHeaders() - .forEach(header -> headers.set(HttpHeaderName.fromString(header.getName()), header.getValue())); - if (headers.getSize() > 0) { + HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions); + if (headers != null) { policies.add(new AddHeadersPolicy(headers)); } this.pipelinePolicies.stream() @@ -388,27 +272,6 @@ private HttpPipeline createHttpPipeline() { HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); policies.add(new AddDatePolicy()); - if (tokenCredential != null) { - TextTranslationAudience authAudience = TextTranslationAudience.AZURE_PUBLIC_CLOUD; - if (this.audience != null) { - authAudience = this.audience; - } - policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, authAudience + DEFAULT_SCOPE)); - if (this.region != null || this.resourceId != null) { - HttpHeaders aadHeaders = new HttpHeaders(); - aadHeaders.put(OCP_APIM_RESOURCE_ID_KEY, this.resourceId); - aadHeaders.put(OCP_APIM_SUBSCRIPTION_REGION, this.region); - policies.add(new AddHeadersPolicy(aadHeaders)); - } - } - if (this.credential != null) { - policies.add(new KeyCredentialPolicy(OCP_APIM_SUBSCRIPTION_KEY, credential)); - if (this.region != null) { - HttpHeaders regionHeaders = new HttpHeaders(); - regionHeaders.put(OCP_APIM_SUBSCRIPTION_REGION, this.region); - policies.add(new AddHeadersPolicy(regionHeaders)); - } - } this.pipelinePolicies.stream() .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) .forEach(p -> policies.add(p)); @@ -423,7 +286,7 @@ private HttpPipeline createHttpPipeline() { /** * Builds an instance of TextTranslationAsyncClient class. - * + * * @return an instance of TextTranslationAsyncClient. */ @Generated @@ -433,7 +296,7 @@ public TextTranslationAsyncClient buildAsyncClient() { /** * Builds an instance of TextTranslationClient class. - * + * * @return an instance of TextTranslationClient. */ @Generated @@ -442,11 +305,4 @@ public TextTranslationClient buildClient() { } private static final ClientLogger LOGGER = new ClientLogger(TextTranslationClientBuilder.class); - - @Generated - private void validateClient() { - // This method is invoked from 'buildInnerClient'/'buildClient' method. - // Developer can customize this method, to validate that the necessary conditions are met for the new client. - Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); - } } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationServiceVersion.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationServiceVersion.java index 242d435b87d2..3dd0929e96ee 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationServiceVersion.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/TextTranslationServiceVersion.java @@ -11,9 +11,14 @@ */ public enum TextTranslationServiceVersion implements ServiceVersion { /** - * Enum value 3.0. + * Enum value v3.0. */ - V3_0("3.0"); + V3_0("v3.0"), + + /** + * Enum value 2025-05-01-preview. + */ + V2025_05_01_PREVIEW("2025-05-01-preview"); private final String version; @@ -35,6 +40,6 @@ public String getVersion() { * @return The latest {@link TextTranslationServiceVersion}. */ public static TextTranslationServiceVersion getLatest() { - return V3_0; + return V2025_05_01_PREVIEW; } } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/implementation/TextTranslationClientImpl.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/implementation/TextTranslationClientImpl.java index 6b380032aeb1..8f5a68866f60 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/implementation/TextTranslationClientImpl.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/implementation/TextTranslationClientImpl.java @@ -33,9 +33,6 @@ import com.azure.core.util.FluxUtil; import com.azure.core.util.serializer.JacksonAdapter; import com.azure.core.util.serializer.SerializerAdapter; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; import reactor.core.publisher.Mono; /** @@ -176,26 +173,24 @@ Response getSupportedLanguagesSync(@HostParam("Endpoint") String end @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - @Post("/translate") + @Post("/translate2") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> translate(@HostParam("Endpoint") String endpoint, - @QueryParam(value = "to", multipleQueryParams = true) List targetLanguages, + Mono> translate2(@HostParam("Endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); - @Post("/translate") + @Post("/translate2") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response translateSync(@HostParam("Endpoint") String endpoint, - @QueryParam(value = "to", multipleQueryParams = true) List targetLanguages, + Response translate2Sync(@HostParam("Endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); @@ -223,76 +218,6 @@ Response transliterateSync(@HostParam("Endpoint") String endpoint, @QueryParam("toScript") String targetLanguageScript, @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); - - @Post("/breaksentence") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> findSentenceBoundaries(@HostParam("Endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); - - @Post("/breaksentence") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response findSentenceBoundariesSync(@HostParam("Endpoint") String endpoint, - @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); - - @Post("/dictionary/lookup") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> lookupDictionaryEntries(@HostParam("Endpoint") String endpoint, - @QueryParam("from") String sourceLanguage, @QueryParam("to") String targetLanguage, - @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); - - @Post("/dictionary/lookup") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response lookupDictionaryEntriesSync(@HostParam("Endpoint") String endpoint, - @QueryParam("from") String sourceLanguage, @QueryParam("to") String targetLanguage, - @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); - - @Post("/dictionary/examples") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> lookupDictionaryExamples(@HostParam("Endpoint") String endpoint, - @QueryParam("from") String sourceLanguage, @QueryParam("to") String targetLanguage, - @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); - - @Post("/dictionary/examples") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response lookupDictionaryExamplesSync(@HostParam("Endpoint") String endpoint, - @QueryParam("from") String sourceLanguage, @QueryParam("to") String targetLanguage, - @QueryParam("api-version") String apiVersion, @HeaderParam("Content-Type") String contentType, - @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, - RequestOptions requestOptions, Context context); } /** @@ -499,55 +424,6 @@ public Response getSupportedLanguagesWithResponse(RequestOptions req /** * Translate Text. - *

Query Parameters

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
fromStringNoSpecifies the language of the input text. Find which languages are - * available to translate from by - * looking up supported languages using the translation scope. If the from parameter isn't specified, - * automatic language detection is applied to determine the source language. - * - * You must use the from parameter rather than autodetection when using the dynamic dictionary feature. - * Note: the dynamic dictionary feature is case-sensitive.
textTypeStringNoDefines whether the text being translated is plain text or - * HTML text. Any HTML needs to be a well-formed, - * complete element. Possible values are: plain (default) or html. Allowed values: "Plain", "Html".
categoryStringNoA string specifying the category (domain) of the translation. - * This parameter is used to get translations - * from a customized system built with Custom Translator. Add the Category ID from your Custom Translator - * project details to this parameter to use your deployed customized system. Default value is: general.
profanityActionStringNoSpecifies how profanities should be treated in - * translations. - * Possible values are: NoAction (default), Marked or Deleted. Allowed values: "NoAction", "Marked", - * "Deleted".
profanityMarkerStringNoSpecifies how profanities should be marked in - * translations. - * Possible values are: Asterisk (default) or Tag. . Allowed values: "Asterisk", "Tag".
includeAlignmentBooleanNoSpecifies whether to include alignment projection - * from source text to translated text. - * Possible values are: true or false (default).
includeSentenceLengthBooleanNoSpecifies whether to include sentence boundaries - * for the input text and the translated text. - * Possible values are: true or false (default).
suggestedFromStringNoSpecifies a fallback language if the language of the - * input text can't be identified. - * Language autodetection is applied when the from parameter is omitted. If detection fails, - * the suggestedFrom language will be assumed.
fromScriptStringNoSpecifies the script of the input text.
toScriptStringNoSpecifies the script of the translated text.
allowFallbackBooleanNoSpecifies that the service is allowed to fall back to a - * general system when a custom system doesn't exist. - * Possible values are: true (default) or false. - * - * allowFallback=false specifies that the translation should only use systems trained for the category specified - * by the request. If a translation for language X to language Y requires chaining through a pivot language E, - * then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. - * If no system is found with the specific category, the request will return a 400 status code. allowFallback=true - * specifies that the service is allowed to fall back to a general system when a custom system doesn't - * exist.
- * You can add these to a request with {@link RequestOptions#addQueryParam} *

Header Parameters

* * @@ -563,6 +439,31 @@ public Response getSupportedLanguagesWithResponse(RequestOptions req * [ * (Required){ * text: String (Required) + * script: String (Optional) + * language: String (Optional) + * textType: String(Plain/Html) (Optional) + * targets (Required): [ + * (Required){ + * language (Required): [ + * String (Required) + * ] + * script: String (Optional) + * profanityAction: String(NoAction/Marked/Deleted) (Optional) + * profanityMarker: String(Asterisk/Tag) (Optional) + * deploymentNameModel: String (Optional) + * allowFallback: Boolean (Optional) + * grade: String (Optional) + * tone: String (Optional) + * gender: String (Optional) + * adaptiveDatasetId: String (Optional) + * referenceTextPairs (Optional): [ + * (Optional){ + * referenceTextPairsSource: String (Required) + * referenceTextPairsTarget: String (Required) + * } + * ] + * } + * ] * } * ] * } @@ -586,17 +487,6 @@ public Response getSupportedLanguagesWithResponse(RequestOptions req * text: String (Required) * script: String (Required) * } - * alignment (Optional): { - * proj: String (Required) - * } - * sentLen (Optional): { - * srcSentLen (Required): [ - * int (Required) - * ] - * transSentLen (Required): [ - * int (Required) - * ] - * } * } * ] * sourceText (Optional): { @@ -607,11 +497,6 @@ public Response getSupportedLanguagesWithResponse(RequestOptions req * } * * - * @param targetLanguages Specifies the language of the output text. The target language must be one of the - * supported languages included - * in the translation scope. For example, use to=de to translate to German. - * It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. - * For example, use to=de&to=it to translate to German and Italian. * @param body Defines the content of the request. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. @@ -621,67 +506,15 @@ public Response getSupportedLanguagesWithResponse(RequestOptions req * @return the response body along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> translateWithResponseAsync(List targetLanguages, BinaryData body, - RequestOptions requestOptions) { + public Mono> translate2WithResponseAsync(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; - List targetLanguagesConverted - = targetLanguages.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); - return FluxUtil.withContext(context -> service.translate(this.getEndpoint(), targetLanguagesConverted, + return FluxUtil.withContext(context -> service.translate2(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, context)); } /** * Translate Text. - *

Query Parameters

- *
Header Parameters
- * - * - * - * - * - * - * - * - * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
fromStringNoSpecifies the language of the input text. Find which languages are - * available to translate from by - * looking up supported languages using the translation scope. If the from parameter isn't specified, - * automatic language detection is applied to determine the source language. - * - * You must use the from parameter rather than autodetection when using the dynamic dictionary feature. - * Note: the dynamic dictionary feature is case-sensitive.
textTypeStringNoDefines whether the text being translated is plain text or - * HTML text. Any HTML needs to be a well-formed, - * complete element. Possible values are: plain (default) or html. Allowed values: "Plain", "Html".
categoryStringNoA string specifying the category (domain) of the translation. - * This parameter is used to get translations - * from a customized system built with Custom Translator. Add the Category ID from your Custom Translator - * project details to this parameter to use your deployed customized system. Default value is: general.
profanityActionStringNoSpecifies how profanities should be treated in - * translations. - * Possible values are: NoAction (default), Marked or Deleted. Allowed values: "NoAction", "Marked", - * "Deleted".
profanityMarkerStringNoSpecifies how profanities should be marked in - * translations. - * Possible values are: Asterisk (default) or Tag. . Allowed values: "Asterisk", "Tag".
includeAlignmentBooleanNoSpecifies whether to include alignment projection - * from source text to translated text. - * Possible values are: true or false (default).
includeSentenceLengthBooleanNoSpecifies whether to include sentence boundaries - * for the input text and the translated text. - * Possible values are: true or false (default).
suggestedFromStringNoSpecifies a fallback language if the language of the - * input text can't be identified. - * Language autodetection is applied when the from parameter is omitted. If detection fails, - * the suggestedFrom language will be assumed.
fromScriptStringNoSpecifies the script of the input text.
toScriptStringNoSpecifies the script of the translated text.
allowFallbackBooleanNoSpecifies that the service is allowed to fall back to a - * general system when a custom system doesn't exist. - * Possible values are: true (default) or false. - * - * allowFallback=false specifies that the translation should only use systems trained for the category specified - * by the request. If a translation for language X to language Y requires chaining through a pivot language E, - * then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. - * If no system is found with the specific category, the request will return a 400 status code. allowFallback=true - * specifies that the service is allowed to fall back to a general system when a custom system doesn't - * exist.
- * You can add these to a request with {@link RequestOptions#addQueryParam} *

Header Parameters

* * @@ -697,6 +530,31 @@ public Mono> translateWithResponseAsync(List target * [ * (Required){ * text: String (Required) + * script: String (Optional) + * language: String (Optional) + * textType: String(Plain/Html) (Optional) + * targets (Required): [ + * (Required){ + * language (Required): [ + * String (Required) + * ] + * script: String (Optional) + * profanityAction: String(NoAction/Marked/Deleted) (Optional) + * profanityMarker: String(Asterisk/Tag) (Optional) + * deploymentNameModel: String (Optional) + * allowFallback: Boolean (Optional) + * grade: String (Optional) + * tone: String (Optional) + * gender: String (Optional) + * adaptiveDatasetId: String (Optional) + * referenceTextPairs (Optional): [ + * (Optional){ + * referenceTextPairsSource: String (Required) + * referenceTextPairsTarget: String (Required) + * } + * ] + * } + * ] * } * ] * } @@ -720,17 +578,6 @@ public Mono> translateWithResponseAsync(List target * text: String (Required) * script: String (Required) * } - * alignment (Optional): { - * proj: String (Required) - * } - * sentLen (Optional): { - * srcSentLen (Required): [ - * int (Required) - * ] - * transSentLen (Required): [ - * int (Required) - * ] - * } * } * ] * sourceText (Optional): { @@ -741,11 +588,6 @@ public Mono> translateWithResponseAsync(List target * } * * - * @param targetLanguages Specifies the language of the output text. The target language must be one of the - * supported languages included - * in the translation scope. For example, use to=de to translate to German. - * It's possible to translate to multiple languages simultaneously by repeating the parameter in the query string. - * For example, use to=de&to=it to translate to German and Italian. * @param body Defines the content of the request. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. @@ -755,14 +597,11 @@ public Mono> translateWithResponseAsync(List target * @return the response body along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response translateWithResponse(List targetLanguages, BinaryData body, - RequestOptions requestOptions) { + public Response translate2WithResponse(BinaryData body, RequestOptions requestOptions) { final String contentType = "application/json"; final String accept = "application/json"; - List targetLanguagesConverted - = targetLanguages.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); - return service.translateSync(this.getEndpoint(), targetLanguagesConverted, - this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, Context.NONE); + return service.translate2Sync(this.getEndpoint(), this.getServiceVersion().getVersion(), contentType, accept, + body, requestOptions, Context.NONE); } /** @@ -887,417 +726,4 @@ public Response transliterateWithResponse(String language, String so return service.transliterateSync(this.getEndpoint(), language, sourceLanguageScript, targetLanguageScript, this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, Context.NONE); } - - /** - * Find Sentence Boundaries. - *

Query Parameters

- *
Header Parameters
- * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
languageStringNoLanguage tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied.
scriptStringNoScript tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed.
- * You can add these to a request with {@link RequestOptions#addQueryParam} - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         detectedLanguage (Optional): {
-     *             language: String (Required)
-     *             score: double (Required)
-     *         }
-     *         sentLen (Required): [
-     *             int (Required)
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> findSentenceBoundariesWithResponseAsync(BinaryData body, - RequestOptions requestOptions) { - final String contentType = "application/json"; - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.findSentenceBoundaries(this.getEndpoint(), - this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, context)); - } - - /** - * Find Sentence Boundaries. - *

Query Parameters

- * - * - * - * - * - *
Query Parameters
NameTypeRequiredDescription
languageStringNoLanguage tag identifying the language of the input text. - * If a code isn't specified, automatic language detection will be applied.
scriptStringNoScript tag identifying the script used by the input text. - * If a script isn't specified, the default script of the language will be assumed.
- * You can add these to a request with {@link RequestOptions#addQueryParam} - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         detectedLanguage (Optional): {
-     *             language: String (Required)
-     *             score: double (Required)
-     *         }
-     *         sentLen (Required): [
-     *             int (Required)
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response findSentenceBoundariesWithResponse(BinaryData body, RequestOptions requestOptions) { - final String contentType = "application/json"; - final String accept = "application/json"; - return service.findSentenceBoundariesSync(this.getEndpoint(), this.getServiceVersion().getVersion(), - contentType, accept, body, requestOptions, Context.NONE); - } - - /** - * Lookup Dictionary Entries. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         normalizedSource: String (Required)
-     *         displaySource: String (Required)
-     *         translations (Required): [
-     *              (Required){
-     *                 normalizedTarget: String (Required)
-     *                 displayTarget: String (Required)
-     *                 posTag: String (Required)
-     *                 confidence: double (Required)
-     *                 prefixWord: String (Required)
-     *                 backTranslations (Required): [
-     *                      (Required){
-     *                         normalizedText: String (Required)
-     *                         displayText: String (Required)
-     *                         numExamples: int (Required)
-     *                         frequencyCount: int (Required)
-     *                     }
-     *                 ]
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> lookupDictionaryEntriesWithResponseAsync(String sourceLanguage, - String targetLanguage, BinaryData body, RequestOptions requestOptions) { - final String contentType = "application/json"; - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.lookupDictionaryEntries(this.getEndpoint(), sourceLanguage, - targetLanguage, this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, context)); - } - - /** - * Lookup Dictionary Entries. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         normalizedSource: String (Required)
-     *         displaySource: String (Required)
-     *         translations (Required): [
-     *              (Required){
-     *                 normalizedTarget: String (Required)
-     *                 displayTarget: String (Required)
-     *                 posTag: String (Required)
-     *                 confidence: double (Required)
-     *                 prefixWord: String (Required)
-     *                 backTranslations (Required): [
-     *                      (Required){
-     *                         normalizedText: String (Required)
-     *                         displayText: String (Required)
-     *                         numExamples: int (Required)
-     *                         frequencyCount: int (Required)
-     *                     }
-     *                 ]
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response lookupDictionaryEntriesWithResponse(String sourceLanguage, String targetLanguage, - BinaryData body, RequestOptions requestOptions) { - final String contentType = "application/json"; - final String accept = "application/json"; - return service.lookupDictionaryEntriesSync(this.getEndpoint(), sourceLanguage, targetLanguage, - this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, Context.NONE); - } - - /** - * Lookup Dictionary Examples. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *         translation: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         normalizedSource: String (Required)
-     *         normalizedTarget: String (Required)
-     *         examples (Required): [
-     *              (Required){
-     *                 sourcePrefix: String (Required)
-     *                 sourceTerm: String (Required)
-     *                 sourceSuffix: String (Required)
-     *                 targetPrefix: String (Required)
-     *                 targetTerm: String (Required)
-     *                 targetSuffix: String (Required)
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> lookupDictionaryExamplesWithResponseAsync(String sourceLanguage, - String targetLanguage, BinaryData body, RequestOptions requestOptions) { - final String contentType = "application/json"; - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.lookupDictionaryExamples(this.getEndpoint(), sourceLanguage, - targetLanguage, this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, context)); - } - - /** - * Lookup Dictionary Examples. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
X-ClientTraceIdStringNoA client-generated GUID to uniquely identify the - * request.
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         text: String (Required)
-     *         translation: String (Required)
-     *     }
-     * ]
-     * }
-     * 
- * - *

Response Body Schema

- * - *
-     * {@code
-     * [
-     *      (Required){
-     *         normalizedSource: String (Required)
-     *         normalizedTarget: String (Required)
-     *         examples (Required): [
-     *              (Required){
-     *                 sourcePrefix: String (Required)
-     *                 sourceTerm: String (Required)
-     *                 sourceSuffix: String (Required)
-     *                 targetPrefix: String (Required)
-     *                 targetTerm: String (Required)
-     *                 targetSuffix: String (Required)
-     *             }
-     *         ]
-     *     }
-     * ]
-     * }
-     * 
- * - * @param sourceLanguage Specifies the language of the input text. - * The source language must be one of the supported languages included in the dictionary scope. - * @param targetLanguage Specifies the language of the output text. - * The target language must be one of the supported languages included in the dictionary scope. - * @param body Defines the content of the request. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the response body along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response lookupDictionaryExamplesWithResponse(String sourceLanguage, String targetLanguage, - BinaryData body, RequestOptions requestOptions) { - final String contentType = "application/json"; - final String accept = "application/json"; - return service.lookupDictionaryExamplesSync(this.getEndpoint(), sourceLanguage, targetLanguage, - this.getServiceVersion().getVersion(), contentType, accept, body, requestOptions, Context.NONE); - } } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/implementation/package-info.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/implementation/package-info.java index 549f610bf494..63541cb64d53 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/implementation/package-info.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/implementation/package-info.java @@ -1,26 +1,23 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. + /** * Package containing the implementations for TextTranslation. * Text translation is a cloud-based REST API feature of the Translator service that uses neural * machine translation technology to enable quick and accurate source-to-target text translation * in real time across all supported languages. - * + * * The following methods are supported by the Text Translation feature: - * + * * Languages. Returns a list of languages supported by Translate, Transliterate, and Dictionary Lookup operations. - * + * * Translate. Renders single source-language text to multiple target-language texts with a single request. - * + * * Transliterate. Converts characters or letters of a source language to the corresponding characters or letters of a * target language. - * + * * Detect. Returns the source code language code and a boolean variable denoting whether the detected language is * supported for text translation and transliteration. - * - * Dictionary lookup. Returns equivalent words for the source term in the target language. - * - * Dictionary example Returns grammatical structure and context examples for the source term and target term pair. */ package com.azure.ai.translation.text.implementation; diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DetectedLanguage.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DetectedLanguage.java index 4d519097e781..dd69298d2910 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DetectedLanguage.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/DetectedLanguage.java @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.ai.translation.text.models; import com.azure.core.annotation.Generated; @@ -16,7 +17,6 @@ */ @Immutable public final class DetectedLanguage implements JsonSerializable { - /* * A string representing the code of the detected language. */ @@ -32,7 +32,7 @@ public final class DetectedLanguage implements JsonSerializable { - /* * Languages that support translate API. */ @@ -45,7 +45,7 @@ private GetSupportedLanguagesResult() { /** * Get the translation property: Languages that support translate API. - * + * * @return the translation value. */ @Generated @@ -55,7 +55,7 @@ public Map getTranslation() { /** * Get the transliteration property: Languages that support transliteration API. - * + * * @return the transliteration value. */ @Generated @@ -65,7 +65,7 @@ public Map getTransliteration() { /** * Get the dictionary property: Languages that support dictionary API. - * + * * @return the dictionary value. */ @Generated @@ -89,7 +89,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of GetSupportedLanguagesResult from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of GetSupportedLanguagesResult if the JsonReader was pointing to an instance of it, or null * if it was pointing to JSON null. @@ -102,6 +102,7 @@ public static GetSupportedLanguagesResult fromJson(JsonReader jsonReader) throws while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); + if ("translation".equals(fieldName)) { Map translation = reader.readMap(reader1 -> TranslationLanguage.fromJson(reader1)); @@ -118,6 +119,7 @@ public static GetSupportedLanguagesResult fromJson(JsonReader jsonReader) throws reader.skipChildren(); } } + return deserializedGetSupportedLanguagesResult; }); } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/InputTextItem.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/InputTextItem.java index 73e602ce5eeb..cab668672e92 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/InputTextItem.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/InputTextItem.java @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.ai.translation.text.models; import com.azure.core.annotation.Generated; @@ -15,8 +16,7 @@ * Element containing the text for translation. */ @Immutable -public class InputTextItem implements JsonSerializable { - +public final class InputTextItem implements JsonSerializable { /* * Text to translate. */ @@ -25,7 +25,7 @@ public class InputTextItem implements JsonSerializable { /** * Creates an instance of InputTextItem class. - * + * * @param text the text value to set. */ @Generated @@ -35,7 +35,7 @@ public InputTextItem(String text) { /** * Get the text property: Text to translate. - * + * * @return the text value. */ @Generated @@ -56,7 +56,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of InputTextItem from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of InputTextItem if the JsonReader was pointing to an instance of it, or null if it was * pointing to JSON null. @@ -70,6 +70,7 @@ public static InputTextItem fromJson(JsonReader jsonReader) throws IOException { while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); + if ("text".equals(fieldName)) { text = reader.getString(); } else { diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/LanguageScript.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/LanguageScript.java index d8c91461553f..2c36d5f18b31 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/LanguageScript.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/LanguageScript.java @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.ai.translation.text.models; import com.azure.core.annotation.Generated; @@ -16,7 +17,6 @@ */ @Immutable public class LanguageScript implements JsonSerializable { - /* * Code identifying the script. */ @@ -43,7 +43,7 @@ public class LanguageScript implements JsonSerializable { /** * Creates an instance of LanguageScript class. - * + * * @param code the code value to set. * @param name the name value to set. * @param nativeName the nativeName value to set. @@ -59,7 +59,7 @@ protected LanguageScript(String code, String name, String nativeName, LanguageDi /** * Get the code property: Code identifying the script. - * + * * @return the code value. */ @Generated @@ -69,7 +69,7 @@ public String getCode() { /** * Get the name property: Display name of the script in the locale requested via Accept-Language header. - * + * * @return the name value. */ @Generated @@ -79,7 +79,7 @@ public String getName() { /** * Get the nativeName property: Display name of the language in the locale native for the language. - * + * * @return the nativeName value. */ @Generated @@ -90,7 +90,7 @@ public String getNativeName() { /** * Get the directionality property: Directionality, which is rtl for right-to-left languages or ltr for * left-to-right languages. - * + * * @return the directionality value. */ @Generated @@ -114,7 +114,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of LanguageScript from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of LanguageScript if the JsonReader was pointing to an instance of it, or null if it was * pointing to JSON null. @@ -131,6 +131,7 @@ public static LanguageScript fromJson(JsonReader jsonReader) throws IOException while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); + if ("code".equals(fieldName)) { code = reader.getString(); } else if ("name".equals(fieldName)) { diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/ReferenceSentencePair.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/ReferenceSentencePair.java new file mode 100644 index 000000000000..b6425bb8bda6 --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/ReferenceSentencePair.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.text.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Reference sentence pair. + */ +@Immutable +public final class ReferenceSentencePair implements JsonSerializable { + /* + * Source reference sentence. + */ + @Generated + private final String referenceTextPairsSource; + + /* + * Target reference sentence. + */ + @Generated + private final String referenceTextPairsTarget; + + /** + * Creates an instance of ReferenceSentencePair class. + * + * @param referenceTextPairsSource the referenceTextPairsSource value to set. + * @param referenceTextPairsTarget the referenceTextPairsTarget value to set. + */ + @Generated + public ReferenceSentencePair(String referenceTextPairsSource, String referenceTextPairsTarget) { + this.referenceTextPairsSource = referenceTextPairsSource; + this.referenceTextPairsTarget = referenceTextPairsTarget; + } + + /** + * Get the referenceTextPairsSource property: Source reference sentence. + * + * @return the referenceTextPairsSource value. + */ + @Generated + public String getReferenceTextPairsSource() { + return this.referenceTextPairsSource; + } + + /** + * Get the referenceTextPairsTarget property: Target reference sentence. + * + * @return the referenceTextPairsTarget value. + */ + @Generated + public String getReferenceTextPairsTarget() { + return this.referenceTextPairsTarget; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("referenceTextPairsSource", this.referenceTextPairsSource); + jsonWriter.writeStringField("referenceTextPairsTarget", this.referenceTextPairsTarget); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ReferenceSentencePair from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ReferenceSentencePair if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ReferenceSentencePair. + */ + @Generated + public static ReferenceSentencePair fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String referenceTextPairsSource = null; + String referenceTextPairsTarget = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("referenceTextPairsSource".equals(fieldName)) { + referenceTextPairsSource = reader.getString(); + } else if ("referenceTextPairsTarget".equals(fieldName)) { + referenceTextPairsTarget = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ReferenceSentencePair(referenceTextPairsSource, referenceTextPairsTarget); + }); + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/SourceDictionaryLanguage.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/SourceDictionaryLanguage.java index 49b777bf10ac..d109b3c9fcd3 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/SourceDictionaryLanguage.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/SourceDictionaryLanguage.java @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.ai.translation.text.models; import com.azure.core.annotation.Generated; @@ -17,7 +18,6 @@ */ @Immutable public final class SourceDictionaryLanguage implements JsonSerializable { - /* * Display name of the language in the locale requested via Accept-Language header. */ @@ -44,7 +44,7 @@ public final class SourceDictionaryLanguage implements JsonSerializable { - /* * Input text in the default script of the source language. */ @@ -25,7 +25,7 @@ public final class SourceText implements JsonSerializable { /** * Creates an instance of SourceText class. - * + * * @param text the text value to set. */ @Generated @@ -35,7 +35,7 @@ private SourceText(String text) { /** * Get the text property: Input text in the default script of the source language. - * + * * @return the text value. */ @Generated @@ -56,7 +56,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of SourceText from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of SourceText if the JsonReader was pointing to an instance of it, or null if it was pointing * to JSON null. @@ -70,6 +70,7 @@ public static SourceText fromJson(JsonReader jsonReader) throws IOException { while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); + if ("text".equals(fieldName)) { text = reader.getString(); } else { diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TargetDictionaryLanguage.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TargetDictionaryLanguage.java index 1bab0ee966e4..d2d70feaeccf 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TargetDictionaryLanguage.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TargetDictionaryLanguage.java @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.ai.translation.text.models; import com.azure.core.annotation.Generated; @@ -16,7 +17,6 @@ */ @Immutable public final class TargetDictionaryLanguage implements JsonSerializable { - /* * Display name of the language in the locale requested via Accept-Language header. */ @@ -43,7 +43,7 @@ public final class TargetDictionaryLanguage implements JsonSerializable { - /** * Plain text. */ @@ -26,7 +26,7 @@ public final class TextType extends ExpandableStringEnum { /** * Creates a new instance of TextType value. - * + * * @deprecated Use the {@link #fromString(String)} factory method. */ @Generated @@ -36,7 +36,7 @@ public TextType() { /** * Creates or finds a TextType from its string representation. - * + * * @param name a name to look for. * @return the corresponding TextType. */ @@ -47,7 +47,7 @@ public static TextType fromString(String name) { /** * Gets known TextType values. - * + * * @return known TextType values. */ @Generated diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateBodyDetails.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateBodyDetails.java new file mode 100644 index 000000000000..117b8e8080d2 --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateBodyDetails.java @@ -0,0 +1,229 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.text.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Request body parameters for the translate API. + */ +@Fluent +public final class TranslateBodyDetails implements JsonSerializable { + /* + * Specifies the text string to be translated in the translate API. + */ + @Generated + private final String text; + + /* + * Specifies the script of the input text. + */ + @Generated + private String script; + + /* + * Specifies the language of the input text. Find which languages are available to translate by + * looking up supported languages using the translation scope. If the language parameter isn't + * specified, automatic language detection is applied to determine the source language. + * + * You must use the language parameter rather than autodetection when using the dynamic dictionary feature. + * Note: the dynamic dictionary feature is case-sensitive. + */ + @Generated + private String language; + + /* + * Defines whether the text being translated is plain text or HTML text. Any HTML needs to be a well-formed, + * complete element. Possible values are: plain (default) or html. + */ + @Generated + private TextType textType; + + /* + * Translation target parameters. + */ + @Generated + private final List targets; + + /** + * Creates an instance of TranslateBodyDetails class. + * + * @param text the text value to set. + * @param targets the targets value to set. + */ + @Generated + public TranslateBodyDetails(String text, List targets) { + this.text = text; + this.targets = targets; + } + + /** + * Get the text property: Specifies the text string to be translated in the translate API. + * + * @return the text value. + */ + @Generated + public String getText() { + return this.text; + } + + /** + * Get the script property: Specifies the script of the input text. + * + * @return the script value. + */ + @Generated + public String getScript() { + return this.script; + } + + /** + * Set the script property: Specifies the script of the input text. + * + * @param script the script value to set. + * @return the TranslateBodyDetails object itself. + */ + @Generated + public TranslateBodyDetails setScript(String script) { + this.script = script; + return this; + } + + /** + * Get the language property: Specifies the language of the input text. Find which languages are available to + * translate by + * looking up supported languages using the translation scope. If the language parameter isn't + * specified, automatic language detection is applied to determine the source language. + * + * You must use the language parameter rather than autodetection when using the dynamic dictionary feature. + * Note: the dynamic dictionary feature is case-sensitive. + * + * @return the language value. + */ + @Generated + public String getLanguage() { + return this.language; + } + + /** + * Set the language property: Specifies the language of the input text. Find which languages are available to + * translate by + * looking up supported languages using the translation scope. If the language parameter isn't + * specified, automatic language detection is applied to determine the source language. + * + * You must use the language parameter rather than autodetection when using the dynamic dictionary feature. + * Note: the dynamic dictionary feature is case-sensitive. + * + * @param language the language value to set. + * @return the TranslateBodyDetails object itself. + */ + @Generated + public TranslateBodyDetails setLanguage(String language) { + this.language = language; + return this; + } + + /** + * Get the textType property: Defines whether the text being translated is plain text or HTML text. Any HTML needs + * to be a well-formed, + * complete element. Possible values are: plain (default) or html. + * + * @return the textType value. + */ + @Generated + public TextType getTextType() { + return this.textType; + } + + /** + * Set the textType property: Defines whether the text being translated is plain text or HTML text. Any HTML needs + * to be a well-formed, + * complete element. Possible values are: plain (default) or html. + * + * @param textType the textType value to set. + * @return the TranslateBodyDetails object itself. + */ + @Generated + public TranslateBodyDetails setTextType(TextType textType) { + this.textType = textType; + return this; + } + + /** + * Get the targets property: Translation target parameters. + * + * @return the targets value. + */ + @Generated + public List getTargets() { + return this.targets; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("text", this.text); + jsonWriter.writeArrayField("targets", this.targets, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("script", this.script); + jsonWriter.writeStringField("language", this.language); + jsonWriter.writeStringField("textType", this.textType == null ? null : this.textType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TranslateBodyDetails from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TranslateBodyDetails if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the TranslateBodyDetails. + */ + @Generated + public static TranslateBodyDetails fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String text = null; + List targets = null; + String script = null; + String language = null; + TextType textType = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("text".equals(fieldName)) { + text = reader.getString(); + } else if ("targets".equals(fieldName)) { + targets = reader.readArray(reader1 -> TranslateTarget.fromJson(reader1)); + } else if ("script".equals(fieldName)) { + script = reader.getString(); + } else if ("language".equals(fieldName)) { + language = reader.getString(); + } else if ("textType".equals(fieldName)) { + textType = TextType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + TranslateBodyDetails deserializedTranslateBodyDetails = new TranslateBodyDetails(text, targets); + deserializedTranslateBodyDetails.script = script; + deserializedTranslateBodyDetails.language = language; + deserializedTranslateBodyDetails.textType = textType; + + return deserializedTranslateBodyDetails; + }); + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateTarget.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateTarget.java new file mode 100644 index 000000000000..464ad87993fc --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslateTarget.java @@ -0,0 +1,482 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.text.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Translate targets parameters. + */ +@Fluent +public final class TranslateTarget implements JsonSerializable { + /* + * Specifies the language of the output text. The target language must be one of the supported languages included + * in the translation scope. It's possible to translate to multiple languages simultaneously by including + * multiple string values in the targetsLanguage array. + */ + @Generated + private final List language; + + /* + * Specifies the script of the translated text. + */ + @Generated + private String script; + + /* + * Specifies how profanities should be treated in translations. + * Possible values are: NoAction (default), Marked or Deleted. + */ + @Generated + private ProfanityAction profanityAction; + + /* + * Specifies how profanities should be marked in translations. + * Possible values are: Asterisk (default) or Tag. + */ + @Generated + private ProfanityMarker profanityMarker; + + /* + * Default is ‘general’, which uses NMT system. + * ‘abc-inc-gpt-4o’, and ‘abc-inc-gpt-4o-mini’ are examples of deployment names which use GPT-4o uses or + * GPT-4o-mini model. ‘gpt-4o’ uses GPT-4o model. + * + * ‘’ uses the custom NMT model tuned by customer. + * ‘best’ system determines which is the best model to use for the request. This intelligence could be introduced + * in future. Customer should have deployed it in their resource. + */ + @Generated + private String deploymentNameModel; + + /* + * In the case where a custom system is being used, specifies that the service is allowed to fall back to a + * general system when a custom system doesn't exist. + * In the case where a Large Language Model is being used, specifies that the service is allowed to fall + * back to a Small Language Model if an error occurs. + * Possible values are: true (default) or false. + * + * allowFallback=false specifies that the translation should only use systems trained for the category specified + * by the request. If a translation for language X to language Y requires chaining through a pivot language E, + * then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. + * If no system is found with the specific category, the request will return a 400 status code. allowFallback=true + * specifies that the service is allowed to fall back to a general system when a custom system doesn't exist. + */ + @Generated + private Boolean allowFallback; + + /* + * Defines complexity of LLM prompts to provide high accuracy translation. + */ + @Generated + private String grade; + + /* + * Desired tone of target translation. + */ + @Generated + private String tone; + + /* + * Desired gender of target translation. + */ + @Generated + private String gender; + + /* + * Reference dataset ID having sentence pair to generate adaptive customized translation. + */ + @Generated + private String adaptiveDatasetId; + + /* + * Reference sentence pairs to generate adaptive results. + */ + @Generated + private List referenceTextPairs; + + /** + * Creates an instance of TranslateTarget class. + * + * @param language the language value to set. + */ + @Generated + public TranslateTarget(List language) { + this.language = language; + } + + /** + * Get the language property: Specifies the language of the output text. The target language must be one of the + * supported languages included + * in the translation scope. It's possible to translate to multiple languages simultaneously by including + * multiple string values in the targetsLanguage array. + * + * @return the language value. + */ + @Generated + public List getLanguage() { + return this.language; + } + + /** + * Get the script property: Specifies the script of the translated text. + * + * @return the script value. + */ + @Generated + public String getScript() { + return this.script; + } + + /** + * Set the script property: Specifies the script of the translated text. + * + * @param script the script value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setScript(String script) { + this.script = script; + return this; + } + + /** + * Get the profanityAction property: Specifies how profanities should be treated in translations. + * Possible values are: NoAction (default), Marked or Deleted. + * + * @return the profanityAction value. + */ + @Generated + public ProfanityAction getProfanityAction() { + return this.profanityAction; + } + + /** + * Set the profanityAction property: Specifies how profanities should be treated in translations. + * Possible values are: NoAction (default), Marked or Deleted. + * + * @param profanityAction the profanityAction value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setProfanityAction(ProfanityAction profanityAction) { + this.profanityAction = profanityAction; + return this; + } + + /** + * Get the profanityMarker property: Specifies how profanities should be marked in translations. + * Possible values are: Asterisk (default) or Tag. + * + * @return the profanityMarker value. + */ + @Generated + public ProfanityMarker getProfanityMarker() { + return this.profanityMarker; + } + + /** + * Set the profanityMarker property: Specifies how profanities should be marked in translations. + * Possible values are: Asterisk (default) or Tag. + * + * @param profanityMarker the profanityMarker value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setProfanityMarker(ProfanityMarker profanityMarker) { + this.profanityMarker = profanityMarker; + return this; + } + + /** + * Get the deploymentNameModel property: Default is ‘general’, which uses NMT system. + * ‘abc-inc-gpt-4o’, and ‘abc-inc-gpt-4o-mini’ are examples of deployment names which use GPT-4o uses or + * GPT-4o-mini model. ‘gpt-4o’ uses GPT-4o model. + * + * ‘<custom model id>’ uses the custom NMT model tuned by customer. + * ‘best’ system determines which is the best model to use for the request. This intelligence could be introduced + * in future. Customer should have deployed it in their resource. + * + * @return the deploymentNameModel value. + */ + @Generated + public String getDeploymentNameModel() { + return this.deploymentNameModel; + } + + /** + * Set the deploymentNameModel property: Default is ‘general’, which uses NMT system. + * ‘abc-inc-gpt-4o’, and ‘abc-inc-gpt-4o-mini’ are examples of deployment names which use GPT-4o uses or + * GPT-4o-mini model. ‘gpt-4o’ uses GPT-4o model. + * + * ‘<custom model id>’ uses the custom NMT model tuned by customer. + * ‘best’ system determines which is the best model to use for the request. This intelligence could be introduced + * in future. Customer should have deployed it in their resource. + * + * @param deploymentNameModel the deploymentNameModel value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setDeploymentNameModel(String deploymentNameModel) { + this.deploymentNameModel = deploymentNameModel; + return this; + } + + /** + * Get the allowFallback property: In the case where a custom system is being used, specifies that the service is + * allowed to fall back to a + * general system when a custom system doesn't exist. + * In the case where a Large Language Model is being used, specifies that the service is allowed to fall + * back to a Small Language Model if an error occurs. + * Possible values are: true (default) or false. + * + * allowFallback=false specifies that the translation should only use systems trained for the category specified + * by the request. If a translation for language X to language Y requires chaining through a pivot language E, + * then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. + * If no system is found with the specific category, the request will return a 400 status code. allowFallback=true + * specifies that the service is allowed to fall back to a general system when a custom system doesn't exist. + * + * @return the allowFallback value. + */ + @Generated + public Boolean isAllowFallback() { + return this.allowFallback; + } + + /** + * Set the allowFallback property: In the case where a custom system is being used, specifies that the service is + * allowed to fall back to a + * general system when a custom system doesn't exist. + * In the case where a Large Language Model is being used, specifies that the service is allowed to fall + * back to a Small Language Model if an error occurs. + * Possible values are: true (default) or false. + * + * allowFallback=false specifies that the translation should only use systems trained for the category specified + * by the request. If a translation for language X to language Y requires chaining through a pivot language E, + * then all the systems in the chain (X → E and E → Y) will need to be custom and have the same category. + * If no system is found with the specific category, the request will return a 400 status code. allowFallback=true + * specifies that the service is allowed to fall back to a general system when a custom system doesn't exist. + * + * @param allowFallback the allowFallback value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setAllowFallback(Boolean allowFallback) { + this.allowFallback = allowFallback; + return this; + } + + /** + * Get the grade property: Defines complexity of LLM prompts to provide high accuracy translation. + * + * @return the grade value. + */ + @Generated + public String getGrade() { + return this.grade; + } + + /** + * Set the grade property: Defines complexity of LLM prompts to provide high accuracy translation. + * + * @param grade the grade value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setGrade(String grade) { + this.grade = grade; + return this; + } + + /** + * Get the tone property: Desired tone of target translation. + * + * @return the tone value. + */ + @Generated + public String getTone() { + return this.tone; + } + + /** + * Set the tone property: Desired tone of target translation. + * + * @param tone the tone value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setTone(String tone) { + this.tone = tone; + return this; + } + + /** + * Get the gender property: Desired gender of target translation. + * + * @return the gender value. + */ + @Generated + public String getGender() { + return this.gender; + } + + /** + * Set the gender property: Desired gender of target translation. + * + * @param gender the gender value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setGender(String gender) { + this.gender = gender; + return this; + } + + /** + * Get the adaptiveDatasetId property: Reference dataset ID having sentence pair to generate adaptive customized + * translation. + * + * @return the adaptiveDatasetId value. + */ + @Generated + public String getAdaptiveDatasetId() { + return this.adaptiveDatasetId; + } + + /** + * Set the adaptiveDatasetId property: Reference dataset ID having sentence pair to generate adaptive customized + * translation. + * + * @param adaptiveDatasetId the adaptiveDatasetId value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setAdaptiveDatasetId(String adaptiveDatasetId) { + this.adaptiveDatasetId = adaptiveDatasetId; + return this; + } + + /** + * Get the referenceTextPairs property: Reference sentence pairs to generate adaptive results. + * + * @return the referenceTextPairs value. + */ + @Generated + public List getReferenceTextPairs() { + return this.referenceTextPairs; + } + + /** + * Set the referenceTextPairs property: Reference sentence pairs to generate adaptive results. + * + * @param referenceTextPairs the referenceTextPairs value to set. + * @return the TranslateTarget object itself. + */ + @Generated + public TranslateTarget setReferenceTextPairs(List referenceTextPairs) { + this.referenceTextPairs = referenceTextPairs; + return this; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("language", this.language, (writer, element) -> writer.writeString(element)); + jsonWriter.writeStringField("script", this.script); + jsonWriter.writeStringField("profanityAction", + this.profanityAction == null ? null : this.profanityAction.toString()); + jsonWriter.writeStringField("profanityMarker", + this.profanityMarker == null ? null : this.profanityMarker.toString()); + jsonWriter.writeStringField("deploymentNameModel", this.deploymentNameModel); + jsonWriter.writeBooleanField("allowFallback", this.allowFallback); + jsonWriter.writeStringField("grade", this.grade); + jsonWriter.writeStringField("tone", this.tone); + jsonWriter.writeStringField("gender", this.gender); + jsonWriter.writeStringField("adaptiveDatasetId", this.adaptiveDatasetId); + jsonWriter.writeArrayField("referenceTextPairs", this.referenceTextPairs, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TranslateTarget from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TranslateTarget if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the TranslateTarget. + */ + @Generated + public static TranslateTarget fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List language = null; + String script = null; + ProfanityAction profanityAction = null; + ProfanityMarker profanityMarker = null; + String deploymentNameModel = null; + Boolean allowFallback = null; + String grade = null; + String tone = null; + String gender = null; + String adaptiveDatasetId = null; + List referenceTextPairs = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("language".equals(fieldName)) { + language = reader.readArray(reader1 -> reader1.getString()); + } else if ("script".equals(fieldName)) { + script = reader.getString(); + } else if ("profanityAction".equals(fieldName)) { + profanityAction = ProfanityAction.fromString(reader.getString()); + } else if ("profanityMarker".equals(fieldName)) { + profanityMarker = ProfanityMarker.fromString(reader.getString()); + } else if ("deploymentNameModel".equals(fieldName)) { + deploymentNameModel = reader.getString(); + } else if ("allowFallback".equals(fieldName)) { + allowFallback = reader.getNullable(JsonReader::getBoolean); + } else if ("grade".equals(fieldName)) { + grade = reader.getString(); + } else if ("tone".equals(fieldName)) { + tone = reader.getString(); + } else if ("gender".equals(fieldName)) { + gender = reader.getString(); + } else if ("adaptiveDatasetId".equals(fieldName)) { + adaptiveDatasetId = reader.getString(); + } else if ("referenceTextPairs".equals(fieldName)) { + referenceTextPairs = reader.readArray(reader1 -> ReferenceSentencePair.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + TranslateTarget deserializedTranslateTarget = new TranslateTarget(language); + deserializedTranslateTarget.script = script; + deserializedTranslateTarget.profanityAction = profanityAction; + deserializedTranslateTarget.profanityMarker = profanityMarker; + deserializedTranslateTarget.deploymentNameModel = deploymentNameModel; + deserializedTranslateTarget.allowFallback = allowFallback; + deserializedTranslateTarget.grade = grade; + deserializedTranslateTarget.tone = tone; + deserializedTranslateTarget.gender = gender; + deserializedTranslateTarget.adaptiveDatasetId = adaptiveDatasetId; + deserializedTranslateTarget.referenceTextPairs = referenceTextPairs; + + return deserializedTranslateTarget; + }); + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslatedTextItem.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslatedTextItem.java index b8d8026cc01e..b576b8da65dc 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslatedTextItem.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslatedTextItem.java @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.ai.translation.text.models; import com.azure.core.annotation.Generated; @@ -17,7 +18,6 @@ */ @Immutable public final class TranslatedTextItem implements JsonSerializable { - /* * The detectedLanguage property is only present in the result object when language auto-detection is requested. */ @@ -42,7 +42,7 @@ public final class TranslatedTextItem implements JsonSerializable translations) { /** * Get the detectedLanguage property: The detectedLanguage property is only present in the result object when * language auto-detection is requested. - * + * * @return the detectedLanguage value. */ @Generated @@ -65,7 +65,7 @@ public DetectedLanguage getDetectedLanguage() { * Get the translations property: An array of translation results. The size of the array matches the number of * target * languages specified through the to query parameter. - * + * * @return the translations value. */ @Generated @@ -79,7 +79,7 @@ public List getTranslations() { * the input is expressed in a script that's not the usual script for the language. For example, * if the input were Arabic written in Latin script, then sourceText.text would be the same Arabic text * converted into Arab script. - * + * * @return the sourceText value. */ @Generated @@ -102,7 +102,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of TranslatedTextItem from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of TranslatedTextItem if the JsonReader was pointing to an instance of it, or null if it was * pointing to JSON null. @@ -118,6 +118,7 @@ public static TranslatedTextItem fromJson(JsonReader jsonReader) throws IOExcept while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); + if ("translations".equals(fieldName)) { translations = reader.readArray(reader1 -> TranslationText.fromJson(reader1)); } else if ("detectedLanguage".equals(fieldName)) { @@ -131,6 +132,7 @@ public static TranslatedTextItem fromJson(JsonReader jsonReader) throws IOExcept TranslatedTextItem deserializedTranslatedTextItem = new TranslatedTextItem(translations); deserializedTranslatedTextItem.detectedLanguage = detectedLanguage; deserializedTranslatedTextItem.sourceText = sourceText; + return deserializedTranslatedTextItem; }); } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationLanguage.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationLanguage.java index 51a715a9ddd4..ba00f8fa551b 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationLanguage.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TranslationLanguage.java @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.ai.translation.text.models; import com.azure.core.annotation.Generated; @@ -17,7 +18,6 @@ */ @Immutable public final class TranslationLanguage implements JsonSerializable { - /* * Display name of the language in the locale requested via Accept-Language header. */ @@ -38,7 +38,7 @@ public final class TranslationLanguage implements JsonSerializable { + /* + * A string representing the language code of the target language. + */ + @Generated + private final String targetLanguage; /* * A string giving the translated text. @@ -29,21 +35,9 @@ public final class TranslationText implements JsonSerializable @Generated private TransliteratedText transliteration; - /* - * Alignment information. - */ - @Generated - private TranslatedTextAlignment alignment; - - /* - * Sentence boundaries in the input and output texts. - */ - @Generated - private SentenceBoundaries sentenceBoundaries; - /** * Creates an instance of TranslationText class. - * + * * @param targetLanguage the targetLanguage value to set. * @param text the text value to set. */ @@ -55,7 +49,7 @@ private TranslationText(String targetLanguage, String text) { /** * Get the targetLanguage property: A string representing the language code of the target language. - * + * * @return the targetLanguage value. */ @Generated @@ -65,7 +59,7 @@ public String getTargetLanguage() { /** * Get the text property: A string giving the translated text. - * + * * @return the text value. */ @Generated @@ -76,7 +70,7 @@ public String getText() { /** * Get the transliteration property: An object giving the translated text in the script specified by the toScript * parameter. - * + * * @return the transliteration value. */ @Generated @@ -84,32 +78,6 @@ public TransliteratedText getTransliteration() { return this.transliteration; } - /** - * Get the alignment property: Alignment information. - * - * @return the alignment value. - */ - @Generated - public TranslatedTextAlignment getAlignment() { - return this.alignment; - } - - /** - * Get the sentenceBoundaries property: Sentence boundaries in the input and output texts. - * - * @return the sentenceBoundaries value. - */ - @Generated - public SentenceBoundaries getSentenceBoundaries() { - return this.sentenceBoundaries; - } - - /* - * A string representing the language code of the target language. - */ - @Generated - private final String targetLanguage; - /** * {@inheritDoc} */ @@ -120,14 +88,12 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { jsonWriter.writeStringField("to", this.targetLanguage); jsonWriter.writeStringField("text", this.text); jsonWriter.writeJsonField("transliteration", this.transliteration); - jsonWriter.writeJsonField("alignment", this.alignment); - jsonWriter.writeJsonField("sentLen", this.sentenceBoundaries); return jsonWriter.writeEndObject(); } /** * Reads an instance of TranslationText from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of TranslationText if the JsonReader was pointing to an instance of it, or null if it was * pointing to JSON null. @@ -140,29 +106,23 @@ public static TranslationText fromJson(JsonReader jsonReader) throws IOException String targetLanguage = null; String text = null; TransliteratedText transliteration = null; - TranslatedTextAlignment alignment = null; - SentenceBoundaries sentenceBoundaries = null; while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); + if ("to".equals(fieldName)) { targetLanguage = reader.getString(); } else if ("text".equals(fieldName)) { text = reader.getString(); } else if ("transliteration".equals(fieldName)) { transliteration = TransliteratedText.fromJson(reader); - } else if ("alignment".equals(fieldName)) { - alignment = TranslatedTextAlignment.fromJson(reader); - } else if ("sentLen".equals(fieldName)) { - sentenceBoundaries = SentenceBoundaries.fromJson(reader); } else { reader.skipChildren(); } } TranslationText deserializedTranslationText = new TranslationText(targetLanguage, text); deserializedTranslationText.transliteration = transliteration; - deserializedTranslationText.alignment = alignment; - deserializedTranslationText.sentenceBoundaries = sentenceBoundaries; + return deserializedTranslationText; }); } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterableScript.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterableScript.java index 9b5e708e5091..0a708cae5822 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterableScript.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliterableScript.java @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.ai.translation.text.models; import com.azure.core.annotation.Generated; @@ -16,10 +17,15 @@ */ @Immutable public final class TransliterableScript extends LanguageScript { + /* + * List of scripts available to convert text to. + */ + @Generated + private final List targetLanguageScripts; /** * Creates an instance of TransliterableScript class. - * + * * @param code the code value to set. * @param name the name value to set. * @param nativeName the nativeName value to set. @@ -35,7 +41,7 @@ private TransliterableScript(String code, String name, String nativeName, Langua /** * Get the targetLanguageScripts property: List of scripts available to convert text to. - * + * * @return the targetLanguageScripts value. */ @Generated @@ -43,12 +49,6 @@ public List getTargetLanguageScripts() { return this.targetLanguageScripts; } - /* - * List of scripts available to convert text to. - */ - @Generated - private final List targetLanguageScripts; - /** * {@inheritDoc} */ @@ -67,7 +67,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of TransliterableScript from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of TransliterableScript if the JsonReader was pointing to an instance of it, or null if it * was pointing to JSON null. @@ -85,6 +85,7 @@ public static TransliterableScript fromJson(JsonReader jsonReader) throws IOExce while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); + if ("code".equals(fieldName)) { code = reader.getString(); } else if ("name".equals(fieldName)) { diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliteratedText.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliteratedText.java index b29ff1c2476a..1a8d16187bc1 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliteratedText.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TransliteratedText.java @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. + package com.azure.ai.translation.text.models; import com.azure.core.annotation.Generated; @@ -16,7 +17,6 @@ */ @Immutable public final class TransliteratedText implements JsonSerializable { - /* * A string which is the result of converting the input string to the output script. */ @@ -31,7 +31,7 @@ public final class TransliteratedText implements JsonSerializable { - /* * Display name of the language in the locale requested via Accept-Language header. */ @@ -40,7 +40,7 @@ public final class TransliterationLanguage implements JsonSerializable * Package containing the data models for TextTranslation. * Text translation is a cloud-based REST API feature of the Translator service that uses neural * machine translation technology to enable quick and accurate source-to-target text translation * in real time across all supported languages. - * + * * The following methods are supported by the Text Translation feature: - * + * * Languages. Returns a list of languages supported by Translate, Transliterate, and Dictionary Lookup operations. - * + * * Translate. Renders single source-language text to multiple target-language texts with a single request. - * + * * Transliterate. Converts characters or letters of a source language to the corresponding characters or letters of a * target language. - * + * * Detect. Returns the source code language code and a boolean variable denoting whether the detected language is * supported for text translation and transliteration. - * - * Dictionary lookup. Returns equivalent words for the source term in the target language. - * - * Dictionary example Returns grammatical structure and context examples for the source term and target term pair. - * */ package com.azure.ai.translation.text.models; diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/package-info.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/package-info.java index c58ca3f782d1..cdec5243ca00 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/package-info.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/package-info.java @@ -1,26 +1,23 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. + /** * Package containing the classes for TextTranslation. * Text translation is a cloud-based REST API feature of the Translator service that uses neural * machine translation technology to enable quick and accurate source-to-target text translation * in real time across all supported languages. - * + * * The following methods are supported by the Text Translation feature: - * + * * Languages. Returns a list of languages supported by Translate, Transliterate, and Dictionary Lookup operations. - * + * * Translate. Renders single source-language text to multiple target-language texts with a single request. - * + * * Transliterate. Converts characters or letters of a source language to the corresponding characters or letters of a * target language. - * + * * Detect. Returns the source code language code and a boolean variable denoting whether the detected language is * supported for text translation and transliteration. - * - * Dictionary lookup. Returns equivalent words for the source term in the target language. - * - * Dictionary example Returns grammatical structure and context examples for the source term and target term pair. */ package com.azure.ai.translation.text; diff --git a/sdk/translation/azure-ai-translation-text/src/main/resources/META-INF/azure-ai-translation-text_apiview_properties.json b/sdk/translation/azure-ai-translation-text/src/main/resources/META-INF/azure-ai-translation-text_apiview_properties.json index fb99b1295b77..e9c5153ef074 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/resources/META-INF/azure-ai-translation-text_apiview_properties.json +++ b/sdk/translation/azure-ai-translation-text/src/main/resources/META-INF/azure-ai-translation-text_apiview_properties.json @@ -2,52 +2,34 @@ "flavor": "azure", "CrossLanguageDefinitionId": { "com.azure.ai.translation.text.TextTranslationAsyncClient": "TextTranslation", - "com.azure.ai.translation.text.TextTranslationAsyncClient.findSentenceBoundaries": "TextTranslation.findSentenceBoundaries", - "com.azure.ai.translation.text.TextTranslationAsyncClient.findSentenceBoundariesWithResponse": "TextTranslation.findSentenceBoundaries", "com.azure.ai.translation.text.TextTranslationAsyncClient.getSupportedLanguages": "TextTranslation.getSupportedLanguages", "com.azure.ai.translation.text.TextTranslationAsyncClient.getSupportedLanguagesWithResponse": "TextTranslation.getSupportedLanguages", - "com.azure.ai.translation.text.TextTranslationAsyncClient.lookupDictionaryEntries": "TextTranslation.lookupDictionaryEntries", - "com.azure.ai.translation.text.TextTranslationAsyncClient.lookupDictionaryEntriesWithResponse": "TextTranslation.lookupDictionaryEntries", - "com.azure.ai.translation.text.TextTranslationAsyncClient.lookupDictionaryExamples": "TextTranslation.lookupDictionaryExamples", - "com.azure.ai.translation.text.TextTranslationAsyncClient.lookupDictionaryExamplesWithResponse": "TextTranslation.lookupDictionaryExamples", - "com.azure.ai.translation.text.TextTranslationAsyncClient.translate": "TextTranslation.translate", - "com.azure.ai.translation.text.TextTranslationAsyncClient.translateWithResponse": "TextTranslation.translate", + "com.azure.ai.translation.text.TextTranslationAsyncClient.translate2": "TextTranslation.translate2", + "com.azure.ai.translation.text.TextTranslationAsyncClient.translate2WithResponse": "TextTranslation.translate2", "com.azure.ai.translation.text.TextTranslationAsyncClient.transliterate": "TextTranslation.transliterate", "com.azure.ai.translation.text.TextTranslationAsyncClient.transliterateWithResponse": "TextTranslation.transliterate", "com.azure.ai.translation.text.TextTranslationClient": "TextTranslation", - "com.azure.ai.translation.text.TextTranslationClient.findSentenceBoundaries": "TextTranslation.findSentenceBoundaries", - "com.azure.ai.translation.text.TextTranslationClient.findSentenceBoundariesWithResponse": "TextTranslation.findSentenceBoundaries", "com.azure.ai.translation.text.TextTranslationClient.getSupportedLanguages": "TextTranslation.getSupportedLanguages", "com.azure.ai.translation.text.TextTranslationClient.getSupportedLanguagesWithResponse": "TextTranslation.getSupportedLanguages", - "com.azure.ai.translation.text.TextTranslationClient.lookupDictionaryEntries": "TextTranslation.lookupDictionaryEntries", - "com.azure.ai.translation.text.TextTranslationClient.lookupDictionaryEntriesWithResponse": "TextTranslation.lookupDictionaryEntries", - "com.azure.ai.translation.text.TextTranslationClient.lookupDictionaryExamples": "TextTranslation.lookupDictionaryExamples", - "com.azure.ai.translation.text.TextTranslationClient.lookupDictionaryExamplesWithResponse": "TextTranslation.lookupDictionaryExamples", - "com.azure.ai.translation.text.TextTranslationClient.translate": "TextTranslation.translate", - "com.azure.ai.translation.text.TextTranslationClient.translateWithResponse": "TextTranslation.translate", + "com.azure.ai.translation.text.TextTranslationClient.translate2": "TextTranslation.translate2", + "com.azure.ai.translation.text.TextTranslationClient.translate2WithResponse": "TextTranslation.translate2", "com.azure.ai.translation.text.TextTranslationClient.transliterate": "TextTranslation.transliterate", "com.azure.ai.translation.text.TextTranslationClient.transliterateWithResponse": "TextTranslation.transliterate", "com.azure.ai.translation.text.TextTranslationClientBuilder": "TextTranslation", - "com.azure.ai.translation.text.models.BackTranslation": "TextTranslation.BackTranslation", - "com.azure.ai.translation.text.models.BreakSentenceItem": "TextTranslation.BreakSentenceItem", "com.azure.ai.translation.text.models.DetectedLanguage": "TextTranslation.DetectedLanguage", - "com.azure.ai.translation.text.models.DictionaryExample": "TextTranslation.DictionaryExample", - "com.azure.ai.translation.text.models.DictionaryExampleItem": "TextTranslation.DictionaryExampleItem", - "com.azure.ai.translation.text.models.DictionaryExampleTextItem": "TextTranslation.DictionaryExampleTextItem", - "com.azure.ai.translation.text.models.DictionaryLookupItem": "TextTranslation.DictionaryLookupItem", - "com.azure.ai.translation.text.models.DictionaryTranslation": "TextTranslation.DictionaryTranslation", "com.azure.ai.translation.text.models.GetSupportedLanguagesResult": "TextTranslation.GetSupportedLanguagesResult", "com.azure.ai.translation.text.models.InputTextItem": "TextTranslation.InputTextItem", "com.azure.ai.translation.text.models.LanguageDirectionality": "TextTranslation.LanguageDirectionality", "com.azure.ai.translation.text.models.LanguageScript": "TextTranslation.LanguageScript", "com.azure.ai.translation.text.models.ProfanityAction": "TextTranslation.ProfanityAction", "com.azure.ai.translation.text.models.ProfanityMarker": "TextTranslation.ProfanityMarker", - "com.azure.ai.translation.text.models.SentenceBoundaries": "TextTranslation.SentenceBoundaries", + "com.azure.ai.translation.text.models.ReferenceSentencePair": "TextTranslation.ReferenceSentencePair", "com.azure.ai.translation.text.models.SourceDictionaryLanguage": "TextTranslation.SourceDictionaryLanguage", "com.azure.ai.translation.text.models.SourceText": "TextTranslation.SourceText", "com.azure.ai.translation.text.models.TargetDictionaryLanguage": "TextTranslation.TargetDictionaryLanguage", "com.azure.ai.translation.text.models.TextType": "TextTranslation.TextType", - "com.azure.ai.translation.text.models.TranslatedTextAlignment": "TextTranslation.TranslatedTextAlignment", + "com.azure.ai.translation.text.models.TranslateBodyDetails": "TextTranslation.TranslateBodyDetails", + "com.azure.ai.translation.text.models.TranslateTarget": "TextTranslation.TranslateTarget", "com.azure.ai.translation.text.models.TranslatedTextItem": "TextTranslation.TranslatedTextItem", "com.azure.ai.translation.text.models.TranslationLanguage": "TextTranslation.TranslationLanguage", "com.azure.ai.translation.text.models.TranslationText": "TextTranslation.TranslationText", diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/GetsTheSetOfLanguagesCurrentlySupportedByOtherOperationsOfTheTranslator.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/GetsTheSetOfLanguagesCurrentlySupportedByOtherOperationsOfTheTranslator.java new file mode 100644 index 000000000000..544a2851b373 --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/GetsTheSetOfLanguagesCurrentlySupportedByOtherOperationsOfTheTranslator.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.text.generated; + +import com.azure.ai.translation.text.TextTranslationClient; +import com.azure.ai.translation.text.TextTranslationClientBuilder; +import com.azure.ai.translation.text.models.GetSupportedLanguagesResult; +import com.azure.core.util.Configuration; + +public class GetsTheSetOfLanguagesCurrentlySupportedByOtherOperationsOfTheTranslator { + public static void main(String[] args) { + TextTranslationClient textTranslationClient + = new TextTranslationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.translation.text.generated.getsupportedlanguages.getsthesetoflanguagescurrentlysupportedbyotheroperationsofthetranslator + GetSupportedLanguagesResult response = textTranslationClient.getSupportedLanguages("kayfnugjec", + "translation,transliteration,dictionary", "en", "fpnhruttllvc"); + // END:com.azure.ai.translation.text.generated.getsupportedlanguages.getsthesetoflanguagescurrentlysupportedbyotheroperationsofthetranslator + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/GetsTheSetOfLanguagesCurrentlySupportedByOtherOperationsOfTheTranslatorWithMinimumProperties.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/GetsTheSetOfLanguagesCurrentlySupportedByOtherOperationsOfTheTranslatorWithMinimumProperties.java new file mode 100644 index 000000000000..1688a848debc --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/GetsTheSetOfLanguagesCurrentlySupportedByOtherOperationsOfTheTranslatorWithMinimumProperties.java @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.text.generated; + +import com.azure.ai.translation.text.TextTranslationClient; +import com.azure.ai.translation.text.TextTranslationClientBuilder; +import com.azure.ai.translation.text.models.GetSupportedLanguagesResult; +import com.azure.core.util.Configuration; + +public class GetsTheSetOfLanguagesCurrentlySupportedByOtherOperationsOfTheTranslatorWithMinimumProperties { + public static void main(String[] args) { + TextTranslationClient textTranslationClient + = new TextTranslationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.translation.text.generated.getsupportedlanguages.getsthesetoflanguagescurrentlysupportedbyotheroperationsofthetranslatorwithminimumproperties + GetSupportedLanguagesResult response = textTranslationClient.getSupportedLanguages(null, null, null, null); + // END:com.azure.ai.translation.text.generated.getsupportedlanguages.getsthesetoflanguagescurrentlysupportedbyotheroperationsofthetranslatorwithminimumproperties + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TransliterateText.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TransliterateText.java new file mode 100644 index 000000000000..dd4cf67eec1a --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TransliterateText.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.text.generated; + +import com.azure.ai.translation.text.TextTranslationClient; +import com.azure.ai.translation.text.TextTranslationClientBuilder; +import com.azure.ai.translation.text.models.InputTextItem; +import com.azure.ai.translation.text.models.TransliteratedText; +import com.azure.core.util.Configuration; +import java.util.Arrays; +import java.util.List; + +public class TransliterateText { + public static void main(String[] args) { + TextTranslationClient textTranslationClient + = new TextTranslationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.translation.text.generated.transliterate.transliteratetext + List response = textTranslationClient.transliterate("zh-Hans", "Hans", "Latn", + Arrays.asList(new InputTextItem("这是个测试。")), "dzncrimwmvtwjnheh"); + // END:com.azure.ai.translation.text.generated.transliterate.transliteratetext + } +} diff --git a/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TransliterateTextWithMinimumProperties.java b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TransliterateTextWithMinimumProperties.java new file mode 100644 index 000000000000..630920131dc2 --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/samples/java/com/azure/ai/translation/text/generated/TransliterateTextWithMinimumProperties.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.ai.translation.text.generated; + +import com.azure.ai.translation.text.TextTranslationClient; +import com.azure.ai.translation.text.TextTranslationClientBuilder; +import com.azure.ai.translation.text.models.InputTextItem; +import com.azure.ai.translation.text.models.TransliteratedText; +import com.azure.core.util.Configuration; +import java.util.Arrays; +import java.util.List; + +public class TransliterateTextWithMinimumProperties { + public static void main(String[] args) { + TextTranslationClient textTranslationClient + = new TextTranslationClientBuilder().endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT")) + .buildClient(); + // BEGIN:com.azure.ai.translation.text.generated.transliterate.transliteratetextwithminimumproperties + List response = textTranslationClient.transliterate("zh-Hans", "Hans", "Latn", + Arrays.asList(new InputTextItem("这是个测试。")), null); + // END:com.azure.ai.translation.text.generated.transliterate.transliteratetextwithminimumproperties + } +} diff --git a/sdk/translation/azure-ai-translation-text/tsp-location.yaml b/sdk/translation/azure-ai-translation-text/tsp-location.yaml index 146d196467b0..044f762a6fe3 100644 --- a/sdk/translation/azure-ai-translation-text/tsp-location.yaml +++ b/sdk/translation/azure-ai-translation-text/tsp-location.yaml @@ -1,3 +1,4 @@ directory: specification/translation/Azure.AI.TextTranslation -commit: 2ddcc49aa62928eff65f3864a88832fb4959166c +commit: fd1acec611e742a931327cba26fd87a7ea559735 repo: Azure/azure-rest-api-specs +additionalDirectories: