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

hub.exec.boto3.client.chime.create_attendee
hub.exec.boto3.client.chime.delete_attendee
hub.exec.boto3.client.chime.get_attendee
hub.exec.boto3.client.chime.list_attendees
hub.exec.boto3.client.chime.tag_attendee
hub.exec.boto3.client.chime.untag_attendee
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, meeting_id: Text, external_user_id: Text, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     Creates a new attendee for an active Amazon Chime SDK meeting. For more information about the Amazon Chime SDK,
    see Using the Amazon Chime SDK in the Amazon Chime Developer Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        meeting_id(Text): The Amazon Chime SDK meeting ID.
        external_user_id(Text): The Amazon Chime SDK external user ID. An idempotency token. Links the attendee to an identity
            managed by a builder application.
        tags(List, optional): The tag key-value pairs. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.chime.attendee.present:
                - name: value
                - meeting_id: value
                - external_user_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.chime.attendee.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.chime.get_attendee(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.chime.create_attendee(
                ctx,
                
                
                **{"MeetingId": meeting_id, "ExternalUserId": external_user_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.chime.get_attendee(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, meeting_id: Text, attendee_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an attendee from the specified Amazon Chime SDK meeting and deletes their JoinToken. Attendees are
    automatically deleted when a Amazon Chime SDK meeting is deleted. For more information about the Amazon Chime
    SDK, see Using the Amazon Chime SDK in the Amazon Chime Developer Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        meeting_id(Text): The Amazon Chime SDK meeting ID.
        attendee_id(Text): The Amazon Chime SDK attendee ID.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

