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

hub.exec.boto3.client.lex_models.delete_bot_alias
hub.exec.boto3.client.lex_models.get_bot_alias
hub.exec.boto3.client.lex_models.put_bot_alias
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, bot_version: Text, bot_name: Text, description: Text = None, checksum: Text = None, conversation_logs: Dict = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates an alias for the specified version of the bot or replaces an alias for the specified bot. To change the
    version of the bot that the alias points to, replace the alias. For more information about aliases, see
    versioning-aliases. This operation requires permissions for the lex:PutBotAlias action.

    Args:
        name(Text): The name of the alias. The name is not case sensitive.
        description(Text, optional): A description of the alias. Defaults to None.
        bot_version(Text): The version of the bot.
        bot_name(Text): The name of the bot.
        checksum(Text, optional): Identifies a specific revision of the $LATEST version. When you create a new bot alias, leave
            the checksum field blank. If you specify a checksum you get a BadRequestException exception.
            When you want to update a bot alias, set the checksum field to the checksum of the most recent
            revision of the $LATEST version. If you don't specify the  checksum field, or if the checksum
            does not match the $LATEST version, you get a PreconditionFailedException exception. Defaults to None.
        conversation_logs(Dict, optional): Settings for conversation logs for the alias. Defaults to None.
        tags(List, 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 PutBotAlias 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.lex_models.bot_alias.present:
                - name: value
                - bot_version: value
                - bot_name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.lex_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.lex_models.get_bot_alias(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.lex_models.put_bot_alias(
                ctx,
                
                
                **{"Name": name, "description": description, "botVersion": bot_version, "botName": bot_name, "checksum": checksum, "conversationLogs": conversation_logs, "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.lex_models.get_bot_alias(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, bot_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an alias for the specified bot.  You can't delete an alias that is used in the association between a bot
    and a messaging channel. If an alias is used in a channel association, the DeleteBot operation returns a
    ResourceInUseException exception that includes a reference to the channel association that refers to the bot.
    You can remove the reference to the alias by deleting the channel association. If you get the same exception
    again, delete the referring association until the DeleteBotAlias operation is successful.

    Args:
        name(Text): The name of the alias to delete. The name is case sensitive.
        bot_name(Text): The name of the bot that the alias points to.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.lex_models.delete_bot_alias(
                ctx,
                
                
                **{"Name": name, "botName": bot_name}
            )
            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.lex_models.get_bot_alias(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

