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

hub.exec.boto3.client.lexv2_models.create_bot_alias
hub.exec.boto3.client.lexv2_models.delete_bot_alias
hub.exec.boto3.client.lexv2_models.describe_bot_alias
hub.exec.boto3.client.lexv2_models.update_bot_alias
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, bot_alias_name: Text, bot_id: Text, description: Text = None, bot_version: Text = None, bot_alias_locale_settings: Dict = None, conversation_log_settings: Dict = None, sentiment_analysis_settings: Dict = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates an alias for the specified version of a bot. Use an alias to enable you to change the version of a bot
    without updating applications that use the bot. For example, you can create an alias called "PROD" that your
    applications use to call the Amazon Lex bot.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        bot_alias_name(Text): The alias to create. The name must be unique for the bot.
        description(Text, optional): A description of the alias. Use this description to help identify the alias. Defaults to None.
        bot_version(Text, optional): The version of the bot that this alias points to. You can use the operation to change the bot
            version associated with the alias. Defaults to None.
        bot_alias_locale_settings(Dict, optional): Maps configuration information to a specific locale. You can use this parameter to specify a
            specific Lambda function to run different functions in different locales. Defaults to None.
        conversation_log_settings(Dict, optional): Specifies whether Amazon Lex logs text and audio for a conversation with the bot. When you
            enable conversation logs, text logs store text input, transcripts of audio input, and associated
            metadata in Amazon CloudWatch Logs. Audio logs store audio input in Amazon S3. Defaults to None.
        sentiment_analysis_settings(Dict, optional): Determines whether Amazon Lex will use Amazon Comprehend to detect the sentiment of user
            utterances. Defaults to None.
        bot_id(Text): The unique identifier of the bot that the alias applies to.
        tags(Dict, optional): A list of tags to add to the bot alias. You can only add tags when you create an alias, you
            can't use the UpdateBotAlias operation to update the tags on a bot alias. To update tags, use
            the TagResource operation. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.lexv2_models.bot_alias.present:
                - name: value
                - bot_alias_name: value
                - bot_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.lexv2_models.bot_alias.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_alias(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.lexv2_models.create_bot_alias(
                ctx,
                
                
                **{"botAliasName": bot_alias_name, "description": description, "botVersion": bot_version, "botAliasLocaleSettings": bot_alias_locale_settings, "conversationLogSettings": conversation_log_settings, "sentimentAnalysisSettings": sentiment_analysis_settings, "botId": bot_id, "tags": tags}
            )
            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_alias(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, bot_alias_id: Text, bot_id: Text, skip_resource_in_use_check: bool = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified bot alias.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        bot_alias_id(Text): The unique identifier of the bot alias to delete.
        bot_id(Text): The unique identifier of the bot associated with the alias to delete.
        skip_resource_in_use_check(bool, optional): When this parameter is true, Amazon Lex doesn't check to see if any other resource is using the
            alias before it is deleted. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.lexv2_models.bot_alias.absent:
                - name: value
                - bot_alias_id: value
                - bot_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.lexv2_models.bot_alias.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_alias(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.lexv2_models.delete_bot_alias(
                ctx,
                
                
                **{"botAliasId": bot_alias_id, "botId": bot_id, "skipResourceInUseCheck": skip_resource_in_use_check}
            )
            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_alias(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

