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

hub.exec.boto3.client.ses.create_receipt_filter
hub.exec.boto3.client.ses.delete_receipt_filter
hub.exec.boto3.client.ses.list_receipt_filters
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, filter_: Dict)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new IP address filter. For information about setting up IP address filters, see the Amazon SES
    Developer Guide. You can execute this operation no more than once per second.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        filter_(Dict): A data structure that describes the IP address filter to create, which consists of a name, an IP
            address range, and whether to allow or block mail from it.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

async def absent(hub, ctx, name: Text, filter_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified IP address filter. For information about managing IP address filters, see the Amazon SES
    Developer Guide. You can execute this operation no more than once per second.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        filter_name(Text): The name of the IP address filter to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

