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

hub.exec.boto3.client.elasticache.create_cache_subnet_group
hub.exec.boto3.client.elasticache.delete_cache_subnet_group
hub.exec.boto3.client.elasticache.describe_cache_subnet_groups
hub.exec.boto3.client.elasticache.modify_cache_subnet_group
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, cache_subnet_group_name: Text, cache_subnet_group_description: Text, subnet_ids: List, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new cache subnet group. Use this parameter only when you are creating a cluster in an Amazon Virtual
    Private Cloud (Amazon VPC).

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        cache_subnet_group_name(Text): A name for the cache subnet group. This value is stored as a lowercase string. Constraints: Must
            contain no more than 255 alphanumeric characters or hyphens. Example: mysubnetgroup.
        cache_subnet_group_description(Text): A description for the cache subnet group.
        subnet_ids(List): A list of VPC subnet IDs for the cache subnet group.
        tags(List, optional): A list of tags to be added to this resource. A tag is a key-value pair. A tag key must be
            accompanied by a tag value, although null is accepted. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.elasticache.cache_subnet_group.present:
                - name: value
                - cache_subnet_group_name: value
                - cache_subnet_group_description: value
                - subnet_ids: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.elasticache.cache_subnet_group.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.elasticache.describe_cache_subnet_groups(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.elasticache.create_cache_subnet_group(
                ctx,
                
                
                **{"CacheSubnetGroupName": cache_subnet_group_name, "CacheSubnetGroupDescription": cache_subnet_group_description, "SubnetIds": subnet_ids, "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.elasticache.describe_cache_subnet_groups(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, cache_subnet_group_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a cache subnet group.  You cannot delete a default cache subnet group or one that is associated with any
    clusters.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        cache_subnet_group_name(Text): The name of the cache subnet group to delete. Constraints: Must contain no more than 255
            alphanumeric characters or hyphens.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

