From ec3c36a29470b6ac90b2e00b74d203eb909b31a4 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Sat, 13 May 2023 01:22:04 +0000 Subject: [PATCH] CodeGen from PR 23971 in Azure/azure-rest-api-specs Merge d0639cce6c0e3ddb928c77debb53cbd06d5353da into 3ac733b1b1c63969fbed0c7ffe60ff5cccc708c7 --- .../text/TextTranslationAsyncClient.java | 102 +++++++++-------- .../text/TextTranslationClient.java | 105 ++++++++++-------- .../text/TextTranslationClientBuilder.java | 94 +--------------- .../TextTranslationClientImpl.java | 83 ++++++++------ .../ai/translation/text/models/TextType.java | 8 +- .../TextTranslationClientTestBase.java | 33 ++++++ 6 files changed, 200 insertions(+), 225 deletions(-) create mode 100644 sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/generated/TextTranslationClientTestBase.java 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 a9bf0ab504660..b4497e0148c7c 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 @@ -162,7 +162,7 @@ public Mono> getLanguagesWithResponse(RequestOptions reques * 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". + * 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. @@ -252,7 +252,7 @@ public Mono> getLanguagesWithResponse(RequestOptions reques * 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 content Array of the text to be translated. + * @param requestBody 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. @@ -263,8 +263,8 @@ public Mono> getLanguagesWithResponse(RequestOptions reques @Generated @ServiceMethod(returns = ReturnType.SINGLE) public Mono> translateWithResponse( - List to, BinaryData content, RequestOptions requestOptions) { - return this.serviceClient.translateWithResponseAsync(to, content, requestOptions); + List to, BinaryData requestBody, RequestOptions requestOptions) { + return this.serviceClient.translateWithResponseAsync(to, requestBody, requestOptions); } /** @@ -307,7 +307,7 @@ public Mono> translateWithResponse( * transliteration scope, to find input scripts available for the selected language. * @param toScript 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 content Array of the text to be transliterated. + * @param requestBody 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. @@ -318,9 +318,13 @@ public Mono> translateWithResponse( @Generated @ServiceMethod(returns = ReturnType.SINGLE) public Mono> transliterateWithResponse( - String language, String fromScript, String toScript, BinaryData content, RequestOptions requestOptions) { + String language, + String fromScript, + String toScript, + BinaryData requestBody, + RequestOptions requestOptions) { return this.serviceClient.transliterateWithResponseAsync( - language, fromScript, toScript, content, requestOptions); + language, fromScript, toScript, requestBody, requestOptions); } /** @@ -375,7 +379,7 @@ public Mono> transliterateWithResponse( * ] * } * - * @param content Array of the text for which values the sentence boundaries will be calculated. + * @param requestBody 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. @@ -386,8 +390,8 @@ public Mono> transliterateWithResponse( @Generated @ServiceMethod(returns = ReturnType.SINGLE) public Mono> findSentenceBoundariesWithResponse( - BinaryData content, RequestOptions requestOptions) { - return this.serviceClient.findSentenceBoundariesWithResponseAsync(content, requestOptions); + BinaryData requestBody, RequestOptions requestOptions) { + return this.serviceClient.findSentenceBoundariesWithResponseAsync(requestBody, requestOptions); } /** @@ -445,7 +449,7 @@ public Mono> findSentenceBoundariesWithResponse( * included in the dictionary scope. * @param to Specifies the language of the output text. The target language must be one of the supported languages * included in the dictionary scope. - * @param content Array of the text to be sent to dictionary. + * @param requestBody 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. @@ -456,8 +460,8 @@ public Mono> findSentenceBoundariesWithResponse( @Generated @ServiceMethod(returns = ReturnType.SINGLE) public Mono> lookupDictionaryEntriesWithResponse( - String from, String to, BinaryData content, RequestOptions requestOptions) { - return this.serviceClient.lookupDictionaryEntriesWithResponseAsync(from, to, content, requestOptions); + String from, String to, BinaryData requestBody, RequestOptions requestOptions) { + return this.serviceClient.lookupDictionaryEntriesWithResponseAsync(from, to, requestBody, requestOptions); } /** @@ -509,7 +513,7 @@ public Mono> lookupDictionaryEntriesWithResponse( * included in the dictionary scope. * @param to Specifies the language of the output text. The target language must be one of the supported languages * included in the dictionary scope. - * @param content Array of the text to be sent to dictionary. + * @param requestBody 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. @@ -520,8 +524,8 @@ public Mono> lookupDictionaryEntriesWithResponse( @Generated @ServiceMethod(returns = ReturnType.SINGLE) public Mono> lookupDictionaryExamplesWithResponse( - String from, String to, BinaryData content, RequestOptions requestOptions) { - return this.serviceClient.lookupDictionaryExamplesWithResponseAsync(from, to, content, requestOptions); + String from, String to, BinaryData requestBody, RequestOptions requestOptions) { + return this.serviceClient.lookupDictionaryExamplesWithResponseAsync(from, to, requestBody, requestOptions); } /** @@ -601,7 +605,7 @@ public Mono getLanguages() { * 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 content Array of the text to be translated. + * @param requestBody Defines the content of the request. * @param clientTraceId A client-generated GUID to uniquely identify the request. * @param from 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 @@ -647,7 +651,7 @@ public Mono getLanguages() { @ServiceMethod(returns = ReturnType.SINGLE) public Mono> translate( List to, - List content, + List requestBody, String clientTraceId, String from, TextType textType, @@ -698,7 +702,7 @@ public Mono> translate( if (allowFallback != null) { requestOptions.addQueryParam("allowFallback", String.valueOf(allowFallback), false); } - return translateWithResponse(to, BinaryData.fromObject(content), requestOptions) + return translateWithResponse(to, BinaryData.fromObject(requestBody), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM)); } @@ -710,7 +714,7 @@ public Mono> translate( * 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 content Array of the text to be translated. + * @param requestBody 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. @@ -721,10 +725,10 @@ public Mono> translate( */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> translate(List to, List content) { + public Mono> translate(List to, List requestBody) { // Generated convenience method for translateWithResponse RequestOptions requestOptions = new RequestOptions(); - return translateWithResponse(to, BinaryData.fromObject(content), requestOptions) + return translateWithResponse(to, BinaryData.fromObject(requestBody), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM)); } @@ -738,7 +742,7 @@ public Mono> translate(List to, List> translate(List to, List> transliterate( - String language, String fromScript, String toScript, List content, String clientTraceId) { + String language, + String fromScript, + String toScript, + List requestBody, + String clientTraceId) { // Generated convenience method for transliterateWithResponse RequestOptions requestOptions = new RequestOptions(); if (clientTraceId != null) { requestOptions.setHeader("X-ClientTraceId", clientTraceId); } - return transliterateWithResponse(language, fromScript, toScript, BinaryData.fromObject(content), requestOptions) + return transliterateWithResponse( + language, fromScript, toScript, BinaryData.fromObject(requestBody), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_TRANSLITERATED_TEXT)); } @@ -771,7 +780,7 @@ public Mono> transliterate( * transliteration scope, to find input scripts available for the selected language. * @param toScript 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 content Array of the text to be transliterated. + * @param requestBody 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. @@ -783,10 +792,11 @@ public Mono> transliterate( @Generated @ServiceMethod(returns = ReturnType.SINGLE) public Mono> transliterate( - String language, String fromScript, String toScript, List content) { + String language, String fromScript, String toScript, List requestBody) { // Generated convenience method for transliterateWithResponse RequestOptions requestOptions = new RequestOptions(); - return transliterateWithResponse(language, fromScript, toScript, BinaryData.fromObject(content), requestOptions) + return transliterateWithResponse( + language, fromScript, toScript, BinaryData.fromObject(requestBody), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_TRANSLITERATED_TEXT)); } @@ -794,7 +804,7 @@ public Mono> transliterate( /** * Find Sentence Boundaries. * - * @param content Array of the text for which values the sentence boundaries will be calculated. + * @param requestBody Defines the content of the request. * @param clientTraceId A client-generated GUID to uniquely identify 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. @@ -811,7 +821,7 @@ public Mono> transliterate( @Generated @ServiceMethod(returns = ReturnType.SINGLE) public Mono> findSentenceBoundaries( - List content, String clientTraceId, String language, String script) { + List requestBody, String clientTraceId, String language, String script) { // Generated convenience method for findSentenceBoundariesWithResponse RequestOptions requestOptions = new RequestOptions(); if (clientTraceId != null) { @@ -823,7 +833,7 @@ public Mono> findSentenceBoundaries( if (script != null) { requestOptions.addQueryParam("script", script, false); } - return findSentenceBoundariesWithResponse(BinaryData.fromObject(content), requestOptions) + return findSentenceBoundariesWithResponse(BinaryData.fromObject(requestBody), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM)); } @@ -831,7 +841,7 @@ public Mono> findSentenceBoundaries( /** * Find Sentence Boundaries. * - * @param content Array of the text for which values the sentence boundaries will be calculated. + * @param requestBody 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. @@ -842,10 +852,10 @@ public Mono> findSentenceBoundaries( */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> findSentenceBoundaries(List content) { + public Mono> findSentenceBoundaries(List requestBody) { // Generated convenience method for findSentenceBoundariesWithResponse RequestOptions requestOptions = new RequestOptions(); - return findSentenceBoundariesWithResponse(BinaryData.fromObject(content), requestOptions) + return findSentenceBoundariesWithResponse(BinaryData.fromObject(requestBody), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM)); } @@ -857,7 +867,7 @@ public Mono> findSentenceBoundaries(List * included in the dictionary scope. * @param to Specifies the language of the output text. The target language must be one of the supported languages * included in the dictionary scope. - * @param content Array of the text to be sent to dictionary. + * @param requestBody 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. @@ -870,13 +880,13 @@ public Mono> findSentenceBoundaries(List @Generated @ServiceMethod(returns = ReturnType.SINGLE) public Mono> lookupDictionaryEntries( - String from, String to, List content, String clientTraceId) { + String from, String to, List requestBody, String clientTraceId) { // Generated convenience method for lookupDictionaryEntriesWithResponse RequestOptions requestOptions = new RequestOptions(); if (clientTraceId != null) { requestOptions.setHeader("X-ClientTraceId", clientTraceId); } - return lookupDictionaryEntriesWithResponse(from, to, BinaryData.fromObject(content), requestOptions) + return lookupDictionaryEntriesWithResponse(from, to, BinaryData.fromObject(requestBody), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_DICTIONARY_LOOKUP_ITEM)); } @@ -888,7 +898,7 @@ public Mono> lookupDictionaryEntries( * included in the dictionary scope. * @param to Specifies the language of the output text. The target language must be one of the supported languages * included in the dictionary scope. - * @param content Array of the text to be sent to dictionary. + * @param requestBody 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. @@ -900,10 +910,10 @@ public Mono> lookupDictionaryEntries( @Generated @ServiceMethod(returns = ReturnType.SINGLE) public Mono> lookupDictionaryEntries( - String from, String to, List content) { + String from, String to, List requestBody) { // Generated convenience method for lookupDictionaryEntriesWithResponse RequestOptions requestOptions = new RequestOptions(); - return lookupDictionaryEntriesWithResponse(from, to, BinaryData.fromObject(content), requestOptions) + return lookupDictionaryEntriesWithResponse(from, to, BinaryData.fromObject(requestBody), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_DICTIONARY_LOOKUP_ITEM)); } @@ -915,7 +925,7 @@ public Mono> lookupDictionaryEntries( * included in the dictionary scope. * @param to Specifies the language of the output text. The target language must be one of the supported languages * included in the dictionary scope. - * @param content Array of the text to be sent to dictionary. + * @param requestBody 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. @@ -928,13 +938,13 @@ public Mono> lookupDictionaryEntries( @Generated @ServiceMethod(returns = ReturnType.SINGLE) public Mono> lookupDictionaryExamples( - String from, String to, List content, String clientTraceId) { + String from, String to, List requestBody, String clientTraceId) { // Generated convenience method for lookupDictionaryExamplesWithResponse RequestOptions requestOptions = new RequestOptions(); if (clientTraceId != null) { requestOptions.setHeader("X-ClientTraceId", clientTraceId); } - return lookupDictionaryExamplesWithResponse(from, to, BinaryData.fromObject(content), requestOptions) + return lookupDictionaryExamplesWithResponse(from, to, BinaryData.fromObject(requestBody), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_DICTIONARY_EXAMPLE_ITEM)); } @@ -946,7 +956,7 @@ public Mono> lookupDictionaryExamples( * included in the dictionary scope. * @param to Specifies the language of the output text. The target language must be one of the supported languages * included in the dictionary scope. - * @param content Array of the text to be sent to dictionary. + * @param requestBody 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. @@ -958,10 +968,10 @@ public Mono> lookupDictionaryExamples( @Generated @ServiceMethod(returns = ReturnType.SINGLE) public Mono> lookupDictionaryExamples( - String from, String to, List content) { + String from, String to, List requestBody) { // Generated convenience method for lookupDictionaryExamplesWithResponse RequestOptions requestOptions = new RequestOptions(); - return lookupDictionaryExamplesWithResponse(from, to, BinaryData.fromObject(content), requestOptions) + return lookupDictionaryExamplesWithResponse(from, to, BinaryData.fromObject(requestBody), requestOptions) .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_DICTIONARY_EXAMPLE_ITEM)); } 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 f6f784b81f146..c054db008a85a 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 @@ -159,7 +159,7 @@ public Response getLanguagesWithResponse(RequestOptions requestOptio * 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". + * 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. @@ -249,7 +249,7 @@ public Response getLanguagesWithResponse(RequestOptions requestOptio * 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 content Array of the text to be translated. + * @param requestBody 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. @@ -260,8 +260,8 @@ public Response getLanguagesWithResponse(RequestOptions requestOptio @Generated @ServiceMethod(returns = ReturnType.SINGLE) public Response translateWithResponse( - List to, BinaryData content, RequestOptions requestOptions) { - return this.client.translateWithResponse(to, content, requestOptions).block(); + List to, BinaryData requestBody, RequestOptions requestOptions) { + return this.client.translateWithResponse(to, requestBody, requestOptions).block(); } /** @@ -304,7 +304,7 @@ public Response translateWithResponse( * transliteration scope, to find input scripts available for the selected language. * @param toScript 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 content Array of the text to be transliterated. + * @param requestBody 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. @@ -315,8 +315,14 @@ public Response translateWithResponse( @Generated @ServiceMethod(returns = ReturnType.SINGLE) public Response transliterateWithResponse( - String language, String fromScript, String toScript, BinaryData content, RequestOptions requestOptions) { - return this.client.transliterateWithResponse(language, fromScript, toScript, content, requestOptions).block(); + String language, + String fromScript, + String toScript, + BinaryData requestBody, + RequestOptions requestOptions) { + return this.client + .transliterateWithResponse(language, fromScript, toScript, requestBody, requestOptions) + .block(); } /** @@ -371,7 +377,7 @@ public Response transliterateWithResponse( * ] * } * - * @param content Array of the text for which values the sentence boundaries will be calculated. + * @param requestBody 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. @@ -381,8 +387,9 @@ public Response transliterateWithResponse( */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public Response findSentenceBoundariesWithResponse(BinaryData content, RequestOptions requestOptions) { - return this.client.findSentenceBoundariesWithResponse(content, requestOptions).block(); + public Response findSentenceBoundariesWithResponse( + BinaryData requestBody, RequestOptions requestOptions) { + return this.client.findSentenceBoundariesWithResponse(requestBody, requestOptions).block(); } /** @@ -440,7 +447,7 @@ public Response findSentenceBoundariesWithResponse(BinaryData conten * included in the dictionary scope. * @param to Specifies the language of the output text. The target language must be one of the supported languages * included in the dictionary scope. - * @param content Array of the text to be sent to dictionary. + * @param requestBody 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. @@ -451,8 +458,8 @@ public Response findSentenceBoundariesWithResponse(BinaryData conten @Generated @ServiceMethod(returns = ReturnType.SINGLE) public Response lookupDictionaryEntriesWithResponse( - String from, String to, BinaryData content, RequestOptions requestOptions) { - return this.client.lookupDictionaryEntriesWithResponse(from, to, content, requestOptions).block(); + String from, String to, BinaryData requestBody, RequestOptions requestOptions) { + return this.client.lookupDictionaryEntriesWithResponse(from, to, requestBody, requestOptions).block(); } /** @@ -504,7 +511,7 @@ public Response lookupDictionaryEntriesWithResponse( * included in the dictionary scope. * @param to Specifies the language of the output text. The target language must be one of the supported languages * included in the dictionary scope. - * @param content Array of the text to be sent to dictionary. + * @param requestBody 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. @@ -515,8 +522,8 @@ public Response lookupDictionaryEntriesWithResponse( @Generated @ServiceMethod(returns = ReturnType.SINGLE) public Response lookupDictionaryExamplesWithResponse( - String from, String to, BinaryData content, RequestOptions requestOptions) { - return this.client.lookupDictionaryExamplesWithResponse(from, to, content, requestOptions).block(); + String from, String to, BinaryData requestBody, RequestOptions requestOptions) { + return this.client.lookupDictionaryExamplesWithResponse(from, to, requestBody, requestOptions).block(); } /** @@ -590,7 +597,7 @@ public GetLanguagesResult getLanguages() { * 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 content Array of the text to be translated. + * @param requestBody Defines the content of the request. * @param clientTraceId A client-generated GUID to uniquely identify the request. * @param from 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 @@ -636,7 +643,7 @@ public GetLanguagesResult getLanguages() { @ServiceMethod(returns = ReturnType.SINGLE) public List translate( List to, - List content, + List requestBody, String clientTraceId, String from, TextType textType, @@ -687,7 +694,7 @@ public List translate( if (allowFallback != null) { requestOptions.addQueryParam("allowFallback", String.valueOf(allowFallback), false); } - return translateWithResponse(to, BinaryData.fromObject(content), requestOptions) + return translateWithResponse(to, BinaryData.fromObject(requestBody), requestOptions) .getValue() .toObject(TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM); } @@ -699,7 +706,7 @@ public List translate( * 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 content Array of the text to be translated. + * @param requestBody 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. @@ -710,10 +717,10 @@ public List translate( */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public List translate(List to, List content) { + public List translate(List to, List requestBody) { // Generated convenience method for translateWithResponse RequestOptions requestOptions = new RequestOptions(); - return translateWithResponse(to, BinaryData.fromObject(content), requestOptions) + return translateWithResponse(to, BinaryData.fromObject(requestBody), requestOptions) .getValue() .toObject(TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM); } @@ -727,7 +734,7 @@ public List translate(List to, List c * transliteration scope, to find input scripts available for the selected language. * @param toScript 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 content Array of the text to be transliterated. + * @param requestBody 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. @@ -740,13 +747,18 @@ public List translate(List to, List c @Generated @ServiceMethod(returns = ReturnType.SINGLE) public List transliterate( - String language, String fromScript, String toScript, List content, String clientTraceId) { + String language, + String fromScript, + String toScript, + List requestBody, + String clientTraceId) { // Generated convenience method for transliterateWithResponse RequestOptions requestOptions = new RequestOptions(); if (clientTraceId != null) { requestOptions.setHeader("X-ClientTraceId", clientTraceId); } - return transliterateWithResponse(language, fromScript, toScript, BinaryData.fromObject(content), requestOptions) + return transliterateWithResponse( + language, fromScript, toScript, BinaryData.fromObject(requestBody), requestOptions) .getValue() .toObject(TYPE_REFERENCE_LIST_TRANSLITERATED_TEXT); } @@ -760,7 +772,7 @@ public List transliterate( * transliteration scope, to find input scripts available for the selected language. * @param toScript 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 content Array of the text to be transliterated. + * @param requestBody 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. @@ -772,10 +784,11 @@ public List transliterate( @Generated @ServiceMethod(returns = ReturnType.SINGLE) public List transliterate( - String language, String fromScript, String toScript, List content) { + String language, String fromScript, String toScript, List requestBody) { // Generated convenience method for transliterateWithResponse RequestOptions requestOptions = new RequestOptions(); - return transliterateWithResponse(language, fromScript, toScript, BinaryData.fromObject(content), requestOptions) + return transliterateWithResponse( + language, fromScript, toScript, BinaryData.fromObject(requestBody), requestOptions) .getValue() .toObject(TYPE_REFERENCE_LIST_TRANSLITERATED_TEXT); } @@ -783,7 +796,7 @@ public List transliterate( /** * Find Sentence Boundaries. * - * @param content Array of the text for which values the sentence boundaries will be calculated. + * @param requestBody Defines the content of the request. * @param clientTraceId A client-generated GUID to uniquely identify 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. @@ -800,7 +813,7 @@ public List transliterate( @Generated @ServiceMethod(returns = ReturnType.SINGLE) public List findSentenceBoundaries( - List content, String clientTraceId, String language, String script) { + List requestBody, String clientTraceId, String language, String script) { // Generated convenience method for findSentenceBoundariesWithResponse RequestOptions requestOptions = new RequestOptions(); if (clientTraceId != null) { @@ -812,7 +825,7 @@ public List findSentenceBoundaries( if (script != null) { requestOptions.addQueryParam("script", script, false); } - return findSentenceBoundariesWithResponse(BinaryData.fromObject(content), requestOptions) + return findSentenceBoundariesWithResponse(BinaryData.fromObject(requestBody), requestOptions) .getValue() .toObject(TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM); } @@ -820,7 +833,7 @@ public List findSentenceBoundaries( /** * Find Sentence Boundaries. * - * @param content Array of the text for which values the sentence boundaries will be calculated. + * @param requestBody 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. @@ -831,10 +844,10 @@ public List findSentenceBoundaries( */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public List findSentenceBoundaries(List content) { + public List findSentenceBoundaries(List requestBody) { // Generated convenience method for findSentenceBoundariesWithResponse RequestOptions requestOptions = new RequestOptions(); - return findSentenceBoundariesWithResponse(BinaryData.fromObject(content), requestOptions) + return findSentenceBoundariesWithResponse(BinaryData.fromObject(requestBody), requestOptions) .getValue() .toObject(TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM); } @@ -846,7 +859,7 @@ public List findSentenceBoundaries(List conten * included in the dictionary scope. * @param to Specifies the language of the output text. The target language must be one of the supported languages * included in the dictionary scope. - * @param content Array of the text to be sent to dictionary. + * @param requestBody 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. @@ -859,13 +872,13 @@ public List findSentenceBoundaries(List conten @Generated @ServiceMethod(returns = ReturnType.SINGLE) public List lookupDictionaryEntries( - String from, String to, List content, String clientTraceId) { + String from, String to, List requestBody, String clientTraceId) { // Generated convenience method for lookupDictionaryEntriesWithResponse RequestOptions requestOptions = new RequestOptions(); if (clientTraceId != null) { requestOptions.setHeader("X-ClientTraceId", clientTraceId); } - return lookupDictionaryEntriesWithResponse(from, to, BinaryData.fromObject(content), requestOptions) + return lookupDictionaryEntriesWithResponse(from, to, BinaryData.fromObject(requestBody), requestOptions) .getValue() .toObject(TYPE_REFERENCE_LIST_DICTIONARY_LOOKUP_ITEM); } @@ -877,7 +890,7 @@ public List lookupDictionaryEntries( * included in the dictionary scope. * @param to Specifies the language of the output text. The target language must be one of the supported languages * included in the dictionary scope. - * @param content Array of the text to be sent to dictionary. + * @param requestBody 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. @@ -888,10 +901,10 @@ public List lookupDictionaryEntries( */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public List lookupDictionaryEntries(String from, String to, List content) { + public List lookupDictionaryEntries(String from, String to, List requestBody) { // Generated convenience method for lookupDictionaryEntriesWithResponse RequestOptions requestOptions = new RequestOptions(); - return lookupDictionaryEntriesWithResponse(from, to, BinaryData.fromObject(content), requestOptions) + return lookupDictionaryEntriesWithResponse(from, to, BinaryData.fromObject(requestBody), requestOptions) .getValue() .toObject(TYPE_REFERENCE_LIST_DICTIONARY_LOOKUP_ITEM); } @@ -903,7 +916,7 @@ public List lookupDictionaryEntries(String from, String to * included in the dictionary scope. * @param to Specifies the language of the output text. The target language must be one of the supported languages * included in the dictionary scope. - * @param content Array of the text to be sent to dictionary. + * @param requestBody 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. @@ -916,13 +929,13 @@ public List lookupDictionaryEntries(String from, String to @Generated @ServiceMethod(returns = ReturnType.SINGLE) public List lookupDictionaryExamples( - String from, String to, List content, String clientTraceId) { + String from, String to, List requestBody, String clientTraceId) { // Generated convenience method for lookupDictionaryExamplesWithResponse RequestOptions requestOptions = new RequestOptions(); if (clientTraceId != null) { requestOptions.setHeader("X-ClientTraceId", clientTraceId); } - return lookupDictionaryExamplesWithResponse(from, to, BinaryData.fromObject(content), requestOptions) + return lookupDictionaryExamplesWithResponse(from, to, BinaryData.fromObject(requestBody), requestOptions) .getValue() .toObject(TYPE_REFERENCE_LIST_DICTIONARY_EXAMPLE_ITEM); } @@ -934,7 +947,7 @@ public List lookupDictionaryExamples( * included in the dictionary scope. * @param to Specifies the language of the output text. The target language must be one of the supported languages * included in the dictionary scope. - * @param content Array of the text to be sent to dictionary. + * @param requestBody 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. @@ -946,10 +959,10 @@ public List lookupDictionaryExamples( @Generated @ServiceMethod(returns = ReturnType.SINGLE) public List lookupDictionaryExamples( - String from, String to, List content) { + String from, String to, List requestBody) { // Generated convenience method for lookupDictionaryExamplesWithResponse RequestOptions requestOptions = new RequestOptions(); - return lookupDictionaryExamplesWithResponse(from, to, BinaryData.fromObject(content), requestOptions) + return lookupDictionaryExamplesWithResponse(from, to, BinaryData.fromObject(requestBody), 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 a3bdd34c17b12..328abad5ce7d6 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 @@ -7,13 +7,9 @@ import com.azure.ai.translation.text.implementation.TextTranslationClientImpl; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ServiceClientBuilder; -import com.azure.core.client.traits.AzureKeyCredentialTrait; 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.TokenCredentialTrait; -import com.azure.core.credential.AzureKeyCredential; -import com.azure.core.credential.TokenCredential; import com.azure.core.http.HttpClient; import com.azure.core.http.HttpHeaders; import com.azure.core.http.HttpPipeline; @@ -22,8 +18,6 @@ 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.AzureKeyCredentialPolicy; -import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; import com.azure.core.http.policy.CookiePolicy; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.HttpLoggingPolicy; @@ -38,8 +32,6 @@ import com.azure.core.util.CoreUtils; import com.azure.core.util.builder.ClientBuilderUtil; 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; @@ -50,20 +42,11 @@ public final class TextTranslationClientBuilder implements HttpTrait, ConfigurationTrait, - EndpointTrait, - AzureKeyCredentialTrait, - TokenCredentialTrait { + EndpointTrait { @Generated private static final String SDK_NAME = "name"; @Generated private static final String SDK_VERSION = "version"; - private static final String DEFAULT_SCOPE = "https://cognitiveservices.azure.com/.default"; - private static final String OCP_APIM_SUBSCRIPTION_KEY = "Ocp-Apim-Subscription-Key"; - - private String region; - private AzureKeyCredential credential; - private TokenCredential tokenCredential; - @Generated private static final Map PROPERTIES = CoreUtils.getProperties("azure-ai-translation-text.properties"); @@ -168,14 +151,11 @@ 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; } @@ -213,47 +193,6 @@ public TextTranslationClientBuilder retryPolicy(RetryPolicy retryPolicy) { return this; } - /** - * Sets the {@link AzureKeyCredential} used to authorize requests sent to the service. - * - * @param credential {@link AzureKeyCredential} used to authorize requests sent to the service. - * @return The updated {@link TextTranslationClientBuilder} object. - * @throws NullPointerException If {@code credential} is null. - */ - public TextTranslationClientBuilder credential(AzureKeyCredential 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 tokenCredential} is null. - */ - public TextTranslationClientBuilder region(String region) { - Objects.requireNonNull(region, "'region' cannot be null."); - this.region = region; - 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. * @@ -264,25 +203,9 @@ private TextTranslationClientImpl buildInnerClient() { 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; - } - TextTranslationClientImpl client = new TextTranslationClientImpl( - localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), serviceEndpoint, localServiceVersion); + localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, localServiceVersion); return client; } @@ -311,19 +234,6 @@ private HttpPipeline createHttpPipeline() { policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy())); policies.add(new AddDatePolicy()); policies.add(new CookiePolicy()); - - if (tokenCredential != null) { - policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPE)); - } - - if (this.credential != null) { - policies.add(new AzureKeyCredentialPolicy(OCP_APIM_SUBSCRIPTION_KEY, credential)); - - if (this.region != null) { - policies.add(new TranslatorRegionAuthenticationPolicy(this.region)); - } - } - this.pipelinePolicies.stream() .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) .forEach(p -> policies.add(p)); 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 a9c05dbff2436..015fa897c8b1e 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 @@ -191,7 +191,7 @@ Mono> translate( @QueryParam(value = "to", multipleQueryParams = true) List to, @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData content, + @BodyParam("application/json") BinaryData requestBody, RequestOptions requestOptions, Context context); @@ -214,7 +214,7 @@ Mono> transliterate( @QueryParam("toScript") String toScript, @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData content, + @BodyParam("application/json") BinaryData requestBody, RequestOptions requestOptions, Context context); @@ -234,7 +234,7 @@ Mono> findSentenceBoundaries( @HostParam("Endpoint") String endpoint, @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData content, + @BodyParam("application/json") BinaryData requestBody, RequestOptions requestOptions, Context context); @@ -256,7 +256,7 @@ Mono> lookupDictionaryEntries( @QueryParam("to") String to, @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData content, + @BodyParam("application/json") BinaryData requestBody, RequestOptions requestOptions, Context context); @@ -278,7 +278,7 @@ Mono> lookupDictionaryExamples( @QueryParam("to") String to, @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, - @BodyParam("application/json") BinaryData content, + @BodyParam("application/json") BinaryData requestBody, RequestOptions requestOptions, Context context); } @@ -504,7 +504,7 @@ public Response getLanguagesWithResponse(RequestOptions requestOptio * 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". + * 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. @@ -594,7 +594,7 @@ public Response getLanguagesWithResponse(RequestOptions requestOptio * 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 content Array of the text to be translated. + * @param requestBody 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. @@ -604,7 +604,7 @@ public Response getLanguagesWithResponse(RequestOptions requestOptio */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> translateWithResponseAsync( - List to, BinaryData content, RequestOptions requestOptions) { + List to, BinaryData requestBody, RequestOptions requestOptions) { final String accept = "application/json"; List toConverted = to.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); return FluxUtil.withContext( @@ -614,7 +614,7 @@ public Mono> translateWithResponseAsync( toConverted, this.getServiceVersion().getVersion(), accept, - content, + requestBody, requestOptions, context)); } @@ -634,7 +634,7 @@ public Mono> translateWithResponseAsync( * 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". + * 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. @@ -724,7 +724,7 @@ public Mono> translateWithResponseAsync( * 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 content Array of the text to be translated. + * @param requestBody 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. @@ -734,8 +734,8 @@ public Mono> translateWithResponseAsync( */ @ServiceMethod(returns = ReturnType.SINGLE) public Response translateWithResponse( - List to, BinaryData content, RequestOptions requestOptions) { - return translateWithResponseAsync(to, content, requestOptions).block(); + List to, BinaryData requestBody, RequestOptions requestOptions) { + return translateWithResponseAsync(to, requestBody, requestOptions).block(); } /** @@ -778,7 +778,7 @@ public Response translateWithResponse( * transliteration scope, to find input scripts available for the selected language. * @param toScript 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 content Array of the text to be transliterated. + * @param requestBody 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. @@ -788,7 +788,11 @@ public Response translateWithResponse( */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> transliterateWithResponseAsync( - String language, String fromScript, String toScript, BinaryData content, RequestOptions requestOptions) { + String language, + String fromScript, + String toScript, + BinaryData requestBody, + RequestOptions requestOptions) { final String accept = "application/json"; return FluxUtil.withContext( context -> @@ -799,7 +803,7 @@ public Mono> transliterateWithResponseAsync( toScript, this.getServiceVersion().getVersion(), accept, - content, + requestBody, requestOptions, context)); } @@ -844,7 +848,7 @@ public Mono> transliterateWithResponseAsync( * transliteration scope, to find input scripts available for the selected language. * @param toScript 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 content Array of the text to be transliterated. + * @param requestBody 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. @@ -854,8 +858,12 @@ public Mono> transliterateWithResponseAsync( */ @ServiceMethod(returns = ReturnType.SINGLE) public Response transliterateWithResponse( - String language, String fromScript, String toScript, BinaryData content, RequestOptions requestOptions) { - return transliterateWithResponseAsync(language, fromScript, toScript, content, requestOptions).block(); + String language, + String fromScript, + String toScript, + BinaryData requestBody, + RequestOptions requestOptions) { + return transliterateWithResponseAsync(language, fromScript, toScript, requestBody, requestOptions).block(); } /** @@ -910,7 +918,7 @@ public Response transliterateWithResponse( * ] * } * - * @param content Array of the text for which values the sentence boundaries will be calculated. + * @param requestBody 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. @@ -920,7 +928,7 @@ public Response transliterateWithResponse( */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> findSentenceBoundariesWithResponseAsync( - BinaryData content, RequestOptions requestOptions) { + BinaryData requestBody, RequestOptions requestOptions) { final String accept = "application/json"; return FluxUtil.withContext( context -> @@ -928,7 +936,7 @@ public Mono> findSentenceBoundariesWithResponseAsync( this.getEndpoint(), this.getServiceVersion().getVersion(), accept, - content, + requestBody, requestOptions, context)); } @@ -985,7 +993,7 @@ public Mono> findSentenceBoundariesWithResponseAsync( * ] * } * - * @param content Array of the text for which values the sentence boundaries will be calculated. + * @param requestBody 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. @@ -994,8 +1002,9 @@ public Mono> findSentenceBoundariesWithResponseAsync( * @return the response body along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response findSentenceBoundariesWithResponse(BinaryData content, RequestOptions requestOptions) { - return findSentenceBoundariesWithResponseAsync(content, requestOptions).block(); + public Response findSentenceBoundariesWithResponse( + BinaryData requestBody, RequestOptions requestOptions) { + return findSentenceBoundariesWithResponseAsync(requestBody, requestOptions).block(); } /** @@ -1053,7 +1062,7 @@ public Response findSentenceBoundariesWithResponse(BinaryData conten * included in the dictionary scope. * @param to Specifies the language of the output text. The target language must be one of the supported languages * included in the dictionary scope. - * @param content Array of the text to be sent to dictionary. + * @param requestBody 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. @@ -1063,7 +1072,7 @@ public Response findSentenceBoundariesWithResponse(BinaryData conten */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> lookupDictionaryEntriesWithResponseAsync( - String from, String to, BinaryData content, RequestOptions requestOptions) { + String from, String to, BinaryData requestBody, RequestOptions requestOptions) { final String accept = "application/json"; return FluxUtil.withContext( context -> @@ -1073,7 +1082,7 @@ public Mono> lookupDictionaryEntriesWithResponseAsync( to, this.getServiceVersion().getVersion(), accept, - content, + requestBody, requestOptions, context)); } @@ -1133,7 +1142,7 @@ public Mono> lookupDictionaryEntriesWithResponseAsync( * included in the dictionary scope. * @param to Specifies the language of the output text. The target language must be one of the supported languages * included in the dictionary scope. - * @param content Array of the text to be sent to dictionary. + * @param requestBody 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. @@ -1143,8 +1152,8 @@ public Mono> lookupDictionaryEntriesWithResponseAsync( */ @ServiceMethod(returns = ReturnType.SINGLE) public Response lookupDictionaryEntriesWithResponse( - String from, String to, BinaryData content, RequestOptions requestOptions) { - return lookupDictionaryEntriesWithResponseAsync(from, to, content, requestOptions).block(); + String from, String to, BinaryData requestBody, RequestOptions requestOptions) { + return lookupDictionaryEntriesWithResponseAsync(from, to, requestBody, requestOptions).block(); } /** @@ -1196,7 +1205,7 @@ public Response lookupDictionaryEntriesWithResponse( * included in the dictionary scope. * @param to Specifies the language of the output text. The target language must be one of the supported languages * included in the dictionary scope. - * @param content Array of the text to be sent to dictionary. + * @param requestBody 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. @@ -1206,7 +1215,7 @@ public Response lookupDictionaryEntriesWithResponse( */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> lookupDictionaryExamplesWithResponseAsync( - String from, String to, BinaryData content, RequestOptions requestOptions) { + String from, String to, BinaryData requestBody, RequestOptions requestOptions) { final String accept = "application/json"; return FluxUtil.withContext( context -> @@ -1216,7 +1225,7 @@ public Mono> lookupDictionaryExamplesWithResponseAsync( to, this.getServiceVersion().getVersion(), accept, - content, + requestBody, requestOptions, context)); } @@ -1270,7 +1279,7 @@ public Mono> lookupDictionaryExamplesWithResponseAsync( * included in the dictionary scope. * @param to Specifies the language of the output text. The target language must be one of the supported languages * included in the dictionary scope. - * @param content Array of the text to be sent to dictionary. + * @param requestBody 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. @@ -1280,7 +1289,7 @@ public Mono> lookupDictionaryExamplesWithResponseAsync( */ @ServiceMethod(returns = ReturnType.SINGLE) public Response lookupDictionaryExamplesWithResponse( - String from, String to, BinaryData content, RequestOptions requestOptions) { - return lookupDictionaryExamplesWithResponseAsync(from, to, content, requestOptions).block(); + String from, String to, BinaryData requestBody, RequestOptions requestOptions) { + return lookupDictionaryExamplesWithResponseAsync(from, to, requestBody, requestOptions).block(); } } diff --git a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TextType.java b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TextType.java index baffc9b5d1ebe..1e6cbc3f62b9f 100644 --- a/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TextType.java +++ b/sdk/translation/azure-ai-translation-text/src/main/java/com/azure/ai/translation/text/models/TextType.java @@ -10,11 +10,11 @@ /** Defines values for TextType. */ public final class TextType extends ExpandableStringEnum { - /** Static value plain for TextType. */ - public static final TextType PLAIN = fromString("plain"); + /** Static value Plain for TextType. */ + public static final TextType PLAIN = fromString("Plain"); - /** Static value html for TextType. */ - public static final TextType HTML = fromString("html"); + /** Static value Html for TextType. */ + public static final TextType HTML = fromString("Html"); /** * Creates a new instance of TextType value. diff --git a/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/generated/TextTranslationClientTestBase.java b/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/generated/TextTranslationClientTestBase.java new file mode 100644 index 0000000000000..9062680f0906e --- /dev/null +++ b/sdk/translation/azure-ai-translation-text/src/test/java/com/azure/ai/translation/text/generated/TextTranslationClientTestBase.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest 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.core.http.HttpClient; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.test.TestBase; +import com.azure.core.test.TestMode; +import com.azure.core.util.Configuration; + +class TextTranslationClientTestBase extends TestBase { + protected TextTranslationClient textTranslationClient; + + @Override + protected void beforeTest() { + TextTranslationClientBuilder textTranslationClientbuilder = + new TextTranslationClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + textTranslationClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + textTranslationClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + textTranslationClient = textTranslationClientbuilder.buildClient(); + } +}