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

hub.exec.boto3.client.connect.associate_bot
hub.exec.boto3.client.connect.disassociate_bot
hub.exec.boto3.client.connect.list_bots
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, instance_id: Text, lex_bot: Dict = None, lex_v2_bot: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    This API is in preview release for Amazon Connect and is subject to change. Allows the specified Amazon Connect
    instance to access the specified Amazon Lex or Amazon Lex V2 bot.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        instance_id(Text): The identifier of the Amazon Connect instance. You can find the instanceId in the ARN of the
            instance.
        lex_bot(Dict, optional): Configuration information of an Amazon Lex bot. Defaults to None.
        lex_v2_bot(Dict, optional): The Amazon Lex V2 bot to associate with the instance. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.connect.associate_bot(
                ctx,
                
                
                **{"InstanceId": instance_id, "LexBot": lex_bot, "LexV2Bot": lex_v2_bot}
            )
            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.connect.list_bots(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, instance_id: Text, lex_bot: Dict = None, lex_v2_bot: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    This API is in preview release for Amazon Connect and is subject to change. Revokes authorization from the
    specified instance to access the specified Amazon Lex or Amazon Lex V2 bot.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        instance_id(Text): The identifier of the Amazon Connect instance. You can find the instanceId in the ARN of the
            instance.
        lex_bot(Dict, optional): Configuration information of an Amazon Lex bot. Defaults to None.
        lex_v2_bot(Dict, optional): The Amazon Lex V2 bot to disassociate from the instance. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

