// 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;

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.GetLanguagesResult;
import com.azure.ai.translation.text.models.InputTextItem;
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.TranslatedTextItem;
import com.azure.ai.translation.text.models.TransliteratedText;
import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.exception.ClientAuthenticationException;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.util.BinaryData;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.serializer.TypeReference;
import java.util.List;
import reactor.core.publisher.Mono;

/** Initializes a new instance of the asynchronous TextTranslationClient type. */
@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
    TextTranslationAsyncClient(TextTranslationClientImpl serviceClient) {
        this.serviceClient = serviceClient;
    }

    /**
     * Gets the set of languages currently supported by other operations of the Translator.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>scope</td><td>String</td><td>No</td><td>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).</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Header Parameters</strong>
     *
     * <table border="1">
     *     <caption>Header Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>X-ClientTraceId</td><td>String</td><td>No</td><td>A client-generated GUID to uniquely identify the request.</td></tr>
     *     <tr><td>Accept-Language</td><td>String</td><td>No</td><td>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.</td></tr>
     *     <tr><td>If-None-Match</td><td>String</td><td>No</td><td>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.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addHeader}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     translation (Optional): {
     *         String (Optional): {
     *             name: String (Required)
     *             nativeName: String (Required)
     *             dir: String (Required)
     *         }
     *     }
     *     transliteration (Optional): {
     *         String (Optional): {
     *             name: String (Required)
     *             nativeName: String (Required)
     *             scripts (Required): [
     *                  (Required){
     *                     code: String (Required)
     *                     name: String (Required)
     *                     nativeName: String (Required)
     *                     dir: String (Required)
     *                     toScripts (Required): [
     *                          (Required){
     *                             code: String (Required)
     *                             name: String (Required)
     *                             nativeName: String (Required)
     *                             dir: String (Required)
     *                         }
     *                     ]
     *                 }
     *             ]
     *         }
     *     }
     *     dictionary (Optional): {
     *         String (Optional): {
     *             name: String (Required)
     *             nativeName: String (Required)
     *             dir: String (Required)
     *             translations (Required): [
     *                  (Required){
     *                     name: String (Required)
     *                     nativeName: String (Required)
     *                     dir: String (Required)
     *                     code: String (Required)
     *                 }
     *             ]
     *         }
     *     }
     * }
     * }</pre>
     *
     * @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<Response<BinaryData>> getLanguagesWithResponse(RequestOptions requestOptions) {
        return this.serviceClient.getLanguagesWithResponseAsync(requestOptions);
    }

    /**
     * Translate Text.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>from</td><td>String</td><td>No</td><td>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.</td></tr>
     *     <tr><td>textType</td><td>String</td><td>No</td><td>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. Allowed values: "plain", "html".</td></tr>
     *     <tr><td>category</td><td>String</td><td>No</td><td>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.</td></tr>
     *     <tr><td>profanityAction</td><td>String</td><td>No</td><td>Specifies how profanities should be treated in translations.
     * Possible values are: NoAction (default), Marked or Deleted. Allowed values: "NoAction", "Marked", "Deleted".</td></tr>
     *     <tr><td>profanityMarker</td><td>String</td><td>No</td><td>Specifies how profanities should be marked in translations.
     * Possible values are: Asterisk (default) or Tag. . Allowed values: "Asterisk", "Tag".</td></tr>
     *     <tr><td>includeAlignment</td><td>Boolean</td><td>No</td><td>Specifies whether to include alignment projection from source text to translated text.
     * Possible values are: true or false (default).</td></tr>
     *     <tr><td>includeSentenceLength</td><td>Boolean</td><td>No</td><td>Specifies whether to include sentence boundaries for the input text and the translated text.
     * Possible values are: true or false (default).</td></tr>
     *     <tr><td>suggestedFrom</td><td>String</td><td>No</td><td>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.</td></tr>
     *     <tr><td>fromScript</td><td>String</td><td>No</td><td>Specifies the script of the input text.</td></tr>
     *     <tr><td>toScript</td><td>String</td><td>No</td><td>Specifies the script of the translated text.</td></tr>
     *     <tr><td>allowFallback</td><td>Boolean</td><td>No</td><td>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.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Header Parameters</strong>
     *
     * <table border="1">
     *     <caption>Header Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>X-ClientTraceId</td><td>String</td><td>No</td><td>A client-generated GUID to uniquely identify the request.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addHeader}
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * [
     *      (Required){
     *         text: String (Required)
     *     }
     * ]
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * [
     *      (Required){
     *         detectedLanguage (Optional): {
     *             language: String (Required)
     *             score: double (Required)
     *         }
     *         translations (Required): [
     *              (Required){
     *                 to: String (Required)
     *                 text: String (Required)
     *                 transliteration (Optional): {
     *                     text: String (Required)
     *                     script: String (Required)
     *                 }
     *                 alignment (Optional): {
     *                     proj: String (Required)
     *                 }
     *                 sentLen (Optional): {
     *                     srcSentLen (Required): [
     *                         int (Required)
     *                     ]
     *                     transSentLen (Required): [
     *                         int (Required)
     *                     ]
     *                 }
     *             }
     *         ]
     *         sourceText (Optional): {
     *             text: String (Required)
     *         }
     *     }
     * ]
     * }</pre>
     *
     * @param to 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&amp;to=it to translate to German and Italian.
     * @param content Array of the text to be translated.
     * @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<Response<BinaryData>> translateWithResponse(
            List<String> to, BinaryData content, RequestOptions requestOptions) {
        return this.serviceClient.translateWithResponseAsync(to, content, requestOptions);
    }

    /**
     * Transliterate Text.
     *
     * <p><strong>Header Parameters</strong>
     *
     * <table border="1">
     *     <caption>Header Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>X-ClientTraceId</td><td>String</td><td>No</td><td>A client-generated GUID to uniquely identify the request.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addHeader}
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * [
     *      (Required){
     *         text: String (Required)
     *     }
     * ]
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * [
     *      (Required){
     *         text: String (Required)
     *         script: String (Required)
     *     }
     * ]
     * }</pre>
     *
     * @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 fromScript 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 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 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<Response<BinaryData>> transliterateWithResponse(
            String language, String fromScript, String toScript, BinaryData content, RequestOptions requestOptions) {
        return this.serviceClient.transliterateWithResponseAsync(
                language, fromScript, toScript, content, requestOptions);
    }

    /**
     * Find Sentence Boundaries.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>language</td><td>String</td><td>No</td><td>Language tag identifying the language of the input text.
     * If a code isn't specified, automatic language detection will be applied.</td></tr>
     *     <tr><td>script</td><td>String</td><td>No</td><td>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.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Header Parameters</strong>
     *
     * <table border="1">
     *     <caption>Header Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>X-ClientTraceId</td><td>String</td><td>No</td><td>A client-generated GUID to uniquely identify the request.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addHeader}
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * [
     *      (Required){
     *         text: String (Required)
     *     }
     * ]
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * [
     *      (Required){
     *         detectedLanguage (Optional): {
     *             language: String (Required)
     *             score: double (Required)
     *         }
     *         sentLen (Required): [
     *             int (Required)
     *         ]
     *     }
     * ]
     * }</pre>
     *
     * @param content Array of the text for which values the sentence boundaries will be calculated.
     * @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<Response<BinaryData>> findSentenceBoundariesWithResponse(
            BinaryData content, RequestOptions requestOptions) {
        return this.serviceClient.findSentenceBoundariesWithResponseAsync(content, requestOptions);
    }

    /**
     * Lookup Dictionary Entries.
     *
     * <p><strong>Header Parameters</strong>
     *
     * <table border="1">
     *     <caption>Header Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>X-ClientTraceId</td><td>String</td><td>No</td><td>A client-generated GUID to uniquely identify the request.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addHeader}
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * [
     *      (Required){
     *         text: String (Required)
     *     }
     * ]
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@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)
     *                     }
     *                 ]
     *             }
     *         ]
     *     }
     * ]
     * }</pre>
     *
     * @param from Specifies the language of the input text. The source language must be one of the supported languages
     *     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 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<Response<BinaryData>> lookupDictionaryEntriesWithResponse(
            String from, String to, BinaryData content, RequestOptions requestOptions) {
        return this.serviceClient.lookupDictionaryEntriesWithResponseAsync(from, to, content, requestOptions);
    }

    /**
     * Lookup Dictionary Examples.
     *
     * <p><strong>Header Parameters</strong>
     *
     * <table border="1">
     *     <caption>Header Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>X-ClientTraceId</td><td>String</td><td>No</td><td>A client-generated GUID to uniquely identify the request.</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addHeader}
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * [
     *      (Required){
     *         text: String (Required)
     *         translation: String (Required)
     *     }
     * ]
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@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)
     *             }
     *         ]
     *     }
     * ]
     * }</pre>
     *
     * @param from Specifies the language of the input text. The source language must be one of the supported languages
     *     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 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<Response<BinaryData>> lookupDictionaryExamplesWithResponse(
            String from, String to, BinaryData content, RequestOptions requestOptions) {
        return this.serviceClient.lookupDictionaryExamplesWithResponseAsync(from, to, content, requestOptions);
    }

    /**
     * Gets the set of languages currently supported by other operations of the Translator.
     *
     * @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.
     * @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<GetLanguagesResult> getLanguages(
            String clientTraceId, String scope, String acceptLanguage, String ifNoneMatch) {
        // Generated convenience method for getLanguagesWithResponse
        RequestOptions requestOptions = new RequestOptions();
        if (clientTraceId != null) {
            requestOptions.setHeader("X-ClientTraceId", clientTraceId);
        }
        if (scope != null) {
            requestOptions.addQueryParam("scope", scope, false);
        }
        if (acceptLanguage != null) {
            requestOptions.setHeader("Accept-Language", acceptLanguage);
        }
        if (ifNoneMatch != null) {
            requestOptions.setHeader("If-None-Match", ifNoneMatch);
        }
        return getLanguagesWithResponse(requestOptions)
                .flatMap(FluxUtil::toMono)
                .map(protocolMethodData -> protocolMethodData.toObject(GetLanguagesResult.class));
    }

    /**
     * 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<GetLanguagesResult> getLanguages() {
        // Generated convenience method for getLanguagesWithResponse
        RequestOptions requestOptions = new RequestOptions();
        return getLanguagesWithResponse(requestOptions)
                .flatMap(FluxUtil::toMono)
                .map(protocolMethodData -> protocolMethodData.toObject(GetLanguagesResult.class));
    }

    /**
     * Translate Text.
     *
     * @param to 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&amp;to=it to translate to German and Italian.
     * @param content Array of the text to be translated.
     * @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
     *     language detection is applied to determine the source language.
     *     <p>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 suggestedFrom 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 fromScript Specifies the script of the input text.
     * @param toScript 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.
     *     <p>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}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<List<TranslatedTextItem>> translate(
            List<String> to,
            List<InputTextItem> content,
            String clientTraceId,
            String from,
            TextType textType,
            String category,
            ProfanityAction profanityAction,
            ProfanityMarker profanityMarker,
            Boolean includeAlignment,
            Boolean includeSentenceLength,
            String suggestedFrom,
            String fromScript,
            String toScript,
            Boolean allowFallback) {
        // Generated convenience method for translateWithResponse
        RequestOptions requestOptions = new RequestOptions();
        if (clientTraceId != null) {
            requestOptions.setHeader("X-ClientTraceId", clientTraceId);
        }
        if (from != null) {
            requestOptions.addQueryParam("from", from, 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 (suggestedFrom != null) {
            requestOptions.addQueryParam("suggestedFrom", suggestedFrom, false);
        }
        if (fromScript != null) {
            requestOptions.addQueryParam("fromScript", fromScript, false);
        }
        if (toScript != null) {
            requestOptions.addQueryParam("toScript", toScript, false);
        }
        if (allowFallback != null) {
            requestOptions.addQueryParam("allowFallback", String.valueOf(allowFallback), false);
        }
        return translateWithResponse(to, BinaryData.fromObject(content), requestOptions)
                .flatMap(FluxUtil::toMono)
                .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM));
    }

    /**
     * Translate Text.
     *
     * @param to 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&amp;to=it to translate to German and Italian.
     * @param content Array of the text to be translated.
     * @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}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<List<TranslatedTextItem>> translate(List<String> to, List<InputTextItem> content) {
        // Generated convenience method for translateWithResponse
        RequestOptions requestOptions = new RequestOptions();
        return translateWithResponse(to, BinaryData.fromObject(content), requestOptions)
                .flatMap(FluxUtil::toMono)
                .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM));
    }

    /**
     * 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.
     * @param fromScript 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 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 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 body on successful completion of {@link Mono}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<List<TransliteratedText>> transliterate(
            String language, String fromScript, String toScript, List<InputTextItem> content, 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)
                .flatMap(FluxUtil::toMono)
                .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_TRANSLITERATED_TEXT));
    }

    /**
     * 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.
     * @param fromScript 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 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.
     * @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}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<List<TransliteratedText>> transliterate(
            String language, String fromScript, String toScript, List<InputTextItem> content) {
        // Generated convenience method for transliterateWithResponse
        RequestOptions requestOptions = new RequestOptions();
        return transliterateWithResponse(language, fromScript, toScript, BinaryData.fromObject(content), requestOptions)
                .flatMap(FluxUtil::toMono)
                .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_TRANSLITERATED_TEXT));
    }

    /**
     * Find Sentence Boundaries.
     *
     * @param content Array of the text for which values the sentence boundaries will be calculated.
     * @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.
     * @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}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<List<BreakSentenceItem>> findSentenceBoundaries(
            List<InputTextItem> content, String clientTraceId, String language, String script) {
        // Generated convenience method for findSentenceBoundariesWithResponse
        RequestOptions requestOptions = new RequestOptions();
        if (clientTraceId != null) {
            requestOptions.setHeader("X-ClientTraceId", clientTraceId);
        }
        if (language != null) {
            requestOptions.addQueryParam("language", language, false);
        }
        if (script != null) {
            requestOptions.addQueryParam("script", script, false);
        }
        return findSentenceBoundariesWithResponse(BinaryData.fromObject(content), requestOptions)
                .flatMap(FluxUtil::toMono)
                .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM));
    }

    /**
     * Find Sentence Boundaries.
     *
     * @param content Array of the text for which values the sentence boundaries will be calculated.
     * @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}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<List<BreakSentenceItem>> findSentenceBoundaries(List<InputTextItem> content) {
        // Generated convenience method for findSentenceBoundariesWithResponse
        RequestOptions requestOptions = new RequestOptions();
        return findSentenceBoundariesWithResponse(BinaryData.fromObject(content), requestOptions)
                .flatMap(FluxUtil::toMono)
                .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM));
    }

    /**
     * Lookup Dictionary Entries.
     *
     * @param from Specifies the language of the input text. The source language must be one of the supported languages
     *     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 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 body on successful completion of {@link Mono}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<List<DictionaryLookupItem>> lookupDictionaryEntries(
            String from, String to, List<InputTextItem> content, 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)
                .flatMap(FluxUtil::toMono)
                .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_DICTIONARY_LOOKUP_ITEM));
    }

    /**
     * Lookup Dictionary Entries.
     *
     * @param from Specifies the language of the input text. The source language must be one of the supported languages
     *     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.
     * @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}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<List<DictionaryLookupItem>> lookupDictionaryEntries(
            String from, String to, List<InputTextItem> content) {
        // Generated convenience method for lookupDictionaryEntriesWithResponse
        RequestOptions requestOptions = new RequestOptions();
        return lookupDictionaryEntriesWithResponse(from, to, BinaryData.fromObject(content), requestOptions)
                .flatMap(FluxUtil::toMono)
                .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_DICTIONARY_LOOKUP_ITEM));
    }

    /**
     * Lookup Dictionary Examples.
     *
     * @param from Specifies the language of the input text. The source language must be one of the supported languages
     *     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 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 body on successful completion of {@link Mono}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<List<DictionaryExampleItem>> lookupDictionaryExamples(
            String from, String to, List<DictionaryExampleTextItem> content, 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)
                .flatMap(FluxUtil::toMono)
                .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_DICTIONARY_EXAMPLE_ITEM));
    }

    /**
     * Lookup Dictionary Examples.
     *
     * @param from Specifies the language of the input text. The source language must be one of the supported languages
     *     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.
     * @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}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<List<DictionaryExampleItem>> lookupDictionaryExamples(
            String from, String to, List<DictionaryExampleTextItem> content) {
        // Generated convenience method for lookupDictionaryExamplesWithResponse
        RequestOptions requestOptions = new RequestOptions();
        return lookupDictionaryExamplesWithResponse(from, to, BinaryData.fromObject(content), requestOptions)
                .flatMap(FluxUtil::toMono)
                .map(protocolMethodData -> protocolMethodData.toObject(TYPE_REFERENCE_LIST_DICTIONARY_EXAMPLE_ITEM));
    }

    private static final TypeReference<List<TransliteratedText>> TYPE_REFERENCE_LIST_TRANSLITERATED_TEXT =
            new TypeReference<List<TransliteratedText>>() {};

    private static final TypeReference<List<BreakSentenceItem>> TYPE_REFERENCE_LIST_BREAK_SENTENCE_ITEM =
            new TypeReference<List<BreakSentenceItem>>() {};

    private static final TypeReference<List<DictionaryLookupItem>> TYPE_REFERENCE_LIST_DICTIONARY_LOOKUP_ITEM =
            new TypeReference<List<DictionaryLookupItem>>() {};

    private static final TypeReference<List<DictionaryExampleItem>> TYPE_REFERENCE_LIST_DICTIONARY_EXAMPLE_ITEM =
            new TypeReference<List<DictionaryExampleItem>>() {};

    private static final TypeReference<List<TranslatedTextItem>> TYPE_REFERENCE_LIST_TRANSLATED_TEXT_ITEM =
            new TypeReference<List<TranslatedTextItem>>() {};
}
