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

hub.exec.boto3.client.chime.create_channel_ban
hub.exec.boto3.client.chime.delete_channel_ban
hub.exec.boto3.client.chime.describe_channel_ban
hub.exec.boto3.client.chime.list_channel_bans
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, channel_arn: Text, member_arn: Text, chime_bearer: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Permanently bans a member from a channel. Moderators can't add banned members to a channel. To undo a ban, you
    first have to DeleteChannelBan, and then CreateChannelMembership. Bans are cleaned up when you delete users or
    channels. If you ban a user who is already part of a channel, that user is automatically kicked from the
    channel.  The x-amz-chime-bearer request header is mandatory. Use the AppInstanceUserArn of the user that makes
    the API call as the value in the header.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        channel_arn(Text): The ARN of the ban request.
        member_arn(Text): The ARN of the member being banned.
        chime_bearer(Text, optional): The AppInstanceUserArn of the user that makes the API call. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.chime.create_channel_ban(
                ctx,
                
                
                **{"ChannelArn": channel_arn, "MemberArn": member_arn, "ChimeBearer": chime_bearer}
            )
            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.describe_channel_ban(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, channel_arn: Text, member_arn: Text, chime_bearer: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Removes a user from a channel's ban list.  The x-amz-chime-bearer request header is mandatory. Use the
    AppInstanceUserArn of the user that makes the API call as the value in the header.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        channel_arn(Text): The ARN of the channel from which the AppInstanceUser was banned.
        member_arn(Text): The ARN of the AppInstanceUser that you want to reinstate.
        chime_bearer(Text, optional): The AppInstanceUserArn of the user that makes the API call. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

