44package com .azure .ai .translation .text ;
55
66import com .azure .ai .translation .text .implementation .TextTranslationClientImpl ;
7+ import com .azure .ai .translation .text .implementation .models .InputTextItem ;
8+ import com .azure .ai .translation .text .implementation .models .TranslateBody ;
9+ import com .azure .ai .translation .text .implementation .models .TranslationResult ;
10+ import com .azure .ai .translation .text .implementation .models .TransliterateBody ;
11+ import com .azure .ai .translation .text .implementation .models .TransliterateResult ;
712import com .azure .ai .translation .text .models .GetSupportedLanguagesResult ;
8- import com .azure .ai .translation .text .models .InputTextItem ;
913import com .azure .ai .translation .text .models .LanguageScope ;
1014import com .azure .ai .translation .text .models .TranslateInputItem ;
11- import com .azure .ai .translation .text .models .TranslateInputs ;
1215import com .azure .ai .translation .text .models .TranslatedTextItem ;
13- import com .azure .ai .translation .text .models .TranslationResult ;
1416import com .azure .ai .translation .text .models .TranslationTarget ;
15- import com .azure .ai .translation .text .models .TransliterateInputs ;
16- import com .azure .ai .translation .text .models .TransliterateResult ;
1717import com .azure .ai .translation .text .models .TransliteratedText ;
1818import com .azure .core .annotation .Generated ;
1919import com .azure .core .annotation .ReturnType ;
@@ -309,27 +309,63 @@ public Mono<Response<BinaryData>> transliterateWithResponse(String language, Str
309309 * @param fromScript Specifies the script used by the input text. Look up supported languages using the
310310 * transliteration scope,
311311 * to find input scripts available for the selected language.
312- * @param toScript Specifies the output script. Look up supported languages using the transliteration
313- * scope, to find output
312+ * @param toScript Specifies the output script. Look up supported languages using the transliteration scope, to find
313+ * output
314314 * scripts available for the selected combination of input language and input script.
315- * @param inputs Defines the text inputs to transliterate.
315+ * @param transliterateInput Defines the content of the request.
316+ * @param clientTraceId A client-generated GUID to uniquely identify the request.
316317 * @throws IllegalArgumentException thrown if parameters fail the validation.
317318 * @throws HttpResponseException thrown if the request is rejected by server.
318319 * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
319320 * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
320321 * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
321322 * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
322- * @return the response body on successful completion of {@link Mono}.
323+ * @return response for the transliteration API on successful completion of {@link Mono}.
324+ */
325+ @ Generated
326+ @ ServiceMethod (returns = ReturnType .SINGLE )
327+ Mono <TransliterateResult > transliterate (String language , String fromScript , String toScript ,
328+ TransliterateBody transliterateInput , String clientTraceId ) {
329+ // Generated convenience method for transliterateWithResponse
330+ RequestOptions requestOptions = new RequestOptions ();
331+ if (clientTraceId != null ) {
332+ requestOptions .setHeader (HttpHeaderName .fromString ("X-ClientTraceId" ), clientTraceId );
333+ }
334+ return transliterateWithResponse (language , fromScript , toScript , BinaryData .fromObject (transliterateInput ),
335+ requestOptions ).flatMap (FluxUtil ::toMono )
336+ .map (protocolMethodData -> protocolMethodData .toObject (TransliterateResult .class ));
337+ }
338+
339+ /**
340+ * Transliterate Text.
341+ *
342+ * @param language Specifies the language of the text to convert from one script to another.
343+ * Possible languages are listed in the transliteration scope obtained by querying the service
344+ * for its supported languages.
345+ * @param fromScript Specifies the script used by the input text. Look up supported languages using the
346+ * transliteration scope,
347+ * to find input scripts available for the selected language.
348+ * @param toScript Specifies the output script. Look up supported languages using the transliteration scope, to find
349+ * output
350+ * scripts available for the selected combination of input language and input script.
351+ * @param transliterateInput Defines the content of the request.
352+ * @throws IllegalArgumentException thrown if parameters fail the validation.
353+ * @throws HttpResponseException thrown if the request is rejected by server.
354+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
355+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
356+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
357+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
358+ * @return response for the transliteration API on successful completion of {@link Mono}.
323359 */
324- private Mono <List <TransliteratedText >> transliterateInner (String language , String fromScript , String toScript ,
325- List <InputTextItem > inputs ) {
360+ @ Generated
361+ @ ServiceMethod (returns = ReturnType .SINGLE )
362+ Mono <TransliterateResult > transliterate (String language , String fromScript , String toScript ,
363+ TransliterateBody transliterateInput ) {
364+ // Generated convenience method for transliterateWithResponse
326365 RequestOptions requestOptions = new RequestOptions ();
327- TransliterateInputs transliterateBody = new TransliterateInputs (inputs );
328- return transliterateWithResponse (language , fromScript , toScript , BinaryData .fromObject (transliterateBody ),
329- requestOptions ).flatMap (FluxUtil ::toMono ).map (protocolMethodData -> {
330- TransliterateResult result = protocolMethodData .toObject (TransliterateResult .class );
331- return result .getValue ();
332- });
366+ return transliterateWithResponse (language , fromScript , toScript , BinaryData .fromObject (transliterateInput ),
367+ requestOptions ).flatMap (FluxUtil ::toMono )
368+ .map (protocolMethodData -> protocolMethodData .toObject (TransliterateResult .class ));
333369 }
334370
335371 /**
@@ -359,7 +395,8 @@ private Mono<List<TransliteratedText>> transliterateInner(String language, Strin
359395 @ ServiceMethod (returns = ReturnType .SINGLE )
360396 public Mono <List <TransliteratedText >> transliterate (String language , String fromScript , String toScript ,
361397 List <String > inputs ) {
362- return transliterateInner (language , fromScript , toScript , convertTextsToInputTextItems (inputs ));
398+ TransliterateBody transliterateBody = new TransliterateBody (convertTextsToInputTextItems (inputs ));
399+ return transliterate (language , fromScript , toScript , transliterateBody ).map (result -> result .getValue ());
363400 }
364401
365402 /**
@@ -482,6 +519,52 @@ public Mono<Response<BinaryData>> translateWithResponse(BinaryData translateInpu
482519 return this .serviceClient .translateWithResponseAsync (translateInput , requestOptions );
483520 }
484521
522+ /**
523+ * Translate Text.
524+ *
525+ * @param translateInput Defines the content of the request.
526+ * @param clientTraceId A client-generated GUID to uniquely identify the request.
527+ * @throws IllegalArgumentException thrown if parameters fail the validation.
528+ * @throws HttpResponseException thrown if the request is rejected by server.
529+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
530+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
531+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
532+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
533+ * @return response for the translation API on successful completion of {@link Mono}.
534+ */
535+ @ Generated
536+ @ ServiceMethod (returns = ReturnType .SINGLE )
537+ Mono <TranslationResult > translate (TranslateBody translateInput , String clientTraceId ) {
538+ // Generated convenience method for translateWithResponse
539+ RequestOptions requestOptions = new RequestOptions ();
540+ if (clientTraceId != null ) {
541+ requestOptions .setHeader (HttpHeaderName .fromString ("X-ClientTraceId" ), clientTraceId );
542+ }
543+ return translateWithResponse (BinaryData .fromObject (translateInput ), requestOptions ).flatMap (FluxUtil ::toMono )
544+ .map (protocolMethodData -> protocolMethodData .toObject (TranslationResult .class ));
545+ }
546+
547+ /**
548+ * Translate Text.
549+ *
550+ * @param translateInput Defines the content of the request.
551+ * @throws IllegalArgumentException thrown if parameters fail the validation.
552+ * @throws HttpResponseException thrown if the request is rejected by server.
553+ * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
554+ * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
555+ * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
556+ * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
557+ * @return response for the translation API on successful completion of {@link Mono}.
558+ */
559+ @ Generated
560+ @ ServiceMethod (returns = ReturnType .SINGLE )
561+ Mono <TranslationResult > translate (TranslateBody translateInput ) {
562+ // Generated convenience method for translateWithResponse
563+ RequestOptions requestOptions = new RequestOptions ();
564+ return translateWithResponse (BinaryData .fromObject (translateInput ), requestOptions ).flatMap (FluxUtil ::toMono )
565+ .map (protocolMethodData -> protocolMethodData .toObject (TranslationResult .class ));
566+ }
567+
485568 /**
486569 * Translate Text.
487570 *
@@ -496,14 +579,8 @@ public Mono<Response<BinaryData>> translateWithResponse(BinaryData translateInpu
496579 */
497580 @ ServiceMethod (returns = ReturnType .SINGLE )
498581 public Mono <List <TranslatedTextItem >> translate (List <TranslateInputItem > inputs ) {
499- // Generated convenience method for translateWithResponse
500- RequestOptions requestOptions = new RequestOptions ();
501- TranslateInputs translateBody = new TranslateInputs (inputs );
502- return translateWithResponse (BinaryData .fromObject (translateBody ), requestOptions ).flatMap (FluxUtil ::toMono )
503- .map (protocolMethodData -> {
504- TranslationResult result = protocolMethodData .toObject (TranslationResult .class );
505- return result .getValue ();
506- });
582+ TranslateBody translateBody = new TranslateBody (inputs );
583+ return translate (translateBody ).map (result -> result .getValue ());
507584 }
508585
509586 /**
0 commit comments