"""
Autogenerated state module using `pop-create-idem <https://gitlab.com/saltstack/pop/pop-create-idem>`__

hub.exec.boto3.client.lexv2_models.build_bot_locale
hub.exec.boto3.client.lexv2_models.create_bot_locale
hub.exec.boto3.client.lexv2_models.delete_bot_locale
hub.exec.boto3.client.lexv2_models.describe_bot_locale
hub.exec.boto3.client.lexv2_models.list_bot_locales
hub.exec.boto3.client.lexv2_models.update_bot_locale
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, bot_id: Text, bot_version: Text, locale_id: Text, nlu_intent_confidence_threshold: float, description: Text = None, voice_settings: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a locale in the bot. The locale contains the intents and slot types that the bot uses in conversations
    with users in the specified language and locale. You must add a locale to a bot before you can add intents and
    slot types to the bot.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        bot_id(Text): The identifier of the bot to create the locale for.
        bot_version(Text): The version of the bot to create the locale for. This can only be the draft version of the bot.
        locale_id(Text): The identifier of the language and locale that the bot will be used in. The string must match
            one of the supported locales. All of the intents, slot types, and slots used in the bot must
            have the same locale. For more information, see Supported languages.
        description(Text, optional): A description of the bot locale. Use this to help identify the bot locale in lists. Defaults to None.
        nlu_intent_confidence_threshold(float): Determines the threshold where Amazon Lex will insert the AMAZON.FallbackIntent,
            AMAZON.KendraSearchIntent, or both when returning alternative intents. AMAZON.FallbackIntent and
            AMAZON.KendraSearchIntent are only inserted if they are configured for the bot. For example,
            suppose a bot is configured with the confidence threshold of 0.80 and the AMAZON.FallbackIntent.
            Amazon Lex returns three alternative intents with the following confidence scores: IntentA
            (0.70), IntentB (0.60), IntentC (0.50). The response from the PostText operation would be:
            AMAZON.FallbackIntent   IntentA   IntentB   IntentC.
        voice_settings(Dict, optional): The Amazon Polly voice ID that Amazon Lex uses for voice interaction with the user. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.lexv2_models.bot_locale.present:
                - name: value
                - bot_id: value
                - bot_version: value
                - locale_id: value
                - nlu_intent_confidence_threshold: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.lexv2_models.bot_locale.id(
        ctx,
        jmes_path=name
    )
    if ret["status"]:
        # name is now the first id that matched the JMES search path
        name = ret["ret"]
    

    
    before = await hub.exec.boto3.client.lexv2_models.describe_bot_locale(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.lexv2_models.create_bot_locale(
                ctx,
                
                
                **{"botId": bot_id, "botVersion": bot_version, "localeId": locale_id, "description": description, "nluIntentConfidenceThreshold": nlu_intent_confidence_threshold, "voiceSettings": voice_settings}
            )
            result["result"] = ret["status"]
            if not result["result"]:
                result["comment"] = ret["comment"]
                return result
            ret["comment"] = f"Created '{name}'"
        except hub.tool.boto3.exception.ClientError as e:
            result["comment"] = f"{e.__class__.__name__}: {e}"

    
    # TODO perform other modifications as needed here
    ...

    after = await hub.exec.boto3.client.lexv2_models.describe_bot_locale(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, bot_id: Text, bot_version: Text, locale_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Removes a locale from a bot. When you delete a locale, all intents, slots, and slot types defined for the locale
    are also deleted.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        bot_id(Text): The unique identifier of the bot that contains the locale.
        bot_version(Text): The version of the bot that contains the locale.
        locale_id(Text): The identifier of the language and locale that will be deleted. The string must match one of the
            supported locales. For more information, see Supported languages.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.lexv2_models.bot_locale.absent:
                - name: value
                - bot_id: value
                - bot_version: value
                - locale_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.lexv2_models.bot_locale.id(
        ctx,
        jmes_path=name
    )
    if ret["status"]:
        # name is now the first id that matched the JMES search path
        name = ret["ret"]
    

    

    before = await hub.exec.boto3.client.lexv2_models.describe_bot_locale(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.lexv2_models.delete_bot_locale(
                ctx,
                
                
                **{"botId": bot_id, "botVersion": bot_version, "localeId": locale_id}
            )
            result["result"] = ret["status"]
            if not result["result"]:
                result["comment"] = ret["comment"]
                return result
            result["comment"] = f"Deleted '{name}'"
        except hub.tool.boto3.exception.ClientError as e:
            result["comment"] = f"{e.__class__.__name__}: {e}"

    

    after = await hub.exec.boto3.client.lexv2_models.describe_bot_locale(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

