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

hub.exec.boto3.client.sesv2.create_dedicated_ip_pool
hub.exec.boto3.client.sesv2.delete_dedicated_ip_pool
hub.exec.boto3.client.sesv2.list_dedicated_ip_pools
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, pool_name: Text, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Create a new pool of dedicated IP addresses. A pool can include one or more dedicated IP addresses that are
    associated with your AWS account. You can associate a pool with a configuration set. When you send an email that
    uses that configuration set, the message is sent from one of the addresses in the associated pool.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        pool_name(Text): The name of the dedicated IP pool.
        tags(List, optional): An object that defines the tags (keys and values) that you want to associate with the pool. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

async def absent(hub, ctx, name: Text, pool_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Delete a dedicated IP pool.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        pool_name(Text): The name of the dedicated IP pool that you want to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

