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

hub.exec.boto3.client.lexv2_models.create_bot
hub.exec.boto3.client.lexv2_models.delete_bot
hub.exec.boto3.client.lexv2_models.describe_bot
hub.exec.boto3.client.lexv2_models.list_bots
hub.exec.boto3.client.lexv2_models.update_bot
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, bot_name: Text, role_arn: Text, data_privacy: Dict, idle_session_ttl_in_seconds: int, description: Text = None, bot_tags: Dict = None, test_bot_alias_tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates an Amazon Lex conversational bot.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        bot_name(Text): The name of the bot. The bot name must be unique in the account that creates the bot.
        description(Text, optional): A description of the bot. It appears in lists to help you identify a particular bot. Defaults to None.
        role_arn(Text): The Amazon Resource Name (ARN) of an IAM role that has permission to access the bot.
        data_privacy(Dict): Provides information on additional privacy protections Amazon Lex should use with the bot's
            data.
        idle_session_ttl_in_seconds(int): The time, in seconds, that Amazon Lex should keep information about a user's conversation with
            the bot.  A user interaction remains active for the amount of time specified. If no conversation
            occurs during this time, the session expires and Amazon Lex deletes any data provided before the
            timeout. You can specify between 60 (1 minute) and 86,400 (24 hours) seconds.
        bot_tags(Dict, optional): A list of tags to add to the bot. You can only add tags when you create a bot. You can't use the
            UpdateBot operation to update tags. To update tags, use the TagResource operation. Defaults to None.
        test_bot_alias_tags(Dict, optional): A list of tags to add to the test alias for a bot. You can only add tags when you create a bot.
            You can't use the UpdateAlias operation to update tags. To update tags on the test alias, use
            the TagResource operation. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.lexv2_models.bot.present:
                - name: value
                - bot_name: value
                - role_arn: value
                - data_privacy: value
                - idle_session_ttl_in_seconds: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.lexv2_models.bot.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(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.lexv2_models.create_bot(
                ctx,
                
                
                **{"botName": bot_name, "description": description, "roleArn": role_arn, "dataPrivacy": data_privacy, "idleSessionTTLInSeconds": idle_session_ttl_in_seconds, "botTags": bot_tags, "testBotAliasTags": test_bot_alias_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(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, bot_id: Text, skip_resource_in_use_check: bool = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes all versions of a bot, including the Draft version. To delete a specific version, use the
    DeleteBotVersion operation. When you delete a bot, all of the resources contained in the bot are also deleted.
    Deleting a bot removes all locales, intents, slot, and slot types defined for the bot. If a bot has an alias,
    the DeleteBot operation returns a ResourceInUseException exception. If you want to delete the bot and the alias,
    set the skipResourceInUseCheck parameter to true.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        bot_id(Text): The identifier of the bot to delete.
        skip_resource_in_use_check(bool, optional): When true, Amazon Lex doesn't check to see if another resource, such as an alias, is using the
            bot before it is deleted. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

