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

hub.exec.boto3.client.route53resolver.create_resolver_endpoint
hub.exec.boto3.client.route53resolver.delete_resolver_endpoint
hub.exec.boto3.client.route53resolver.get_resolver_endpoint
hub.exec.boto3.client.route53resolver.list_resolver_endpoints
hub.exec.boto3.client.route53resolver.update_resolver_endpoint
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, creator_request_id: Text, security_group_ids: List, direction: Text, ip_addresses: List, name: Text = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a Resolver endpoint. There are two types of Resolver endpoints, inbound and outbound:   An inbound
    Resolver endpoint forwards DNS queries to the DNS service for a VPC from your network.   An outbound Resolver
    endpoint forwards DNS queries from the DNS service for a VPC to your network.

    Args:
        name(Text, optional): A friendly name that lets you easily find a configuration in the Resolver dashboard in the Route
            53 console. Defaults to None.
        creator_request_id(Text): A unique string that identifies the request and that allows failed requests to be retried
            without the risk of running the operation twice. CreatorRequestId can be any unique string, for
            example, a date/time stamp.
        security_group_ids(List): The ID of one or more security groups that you want to use to control access to this VPC. The
            security group that you specify must include one or more inbound rules (for inbound Resolver
            endpoints) or outbound rules (for outbound Resolver endpoints). Inbound and outbound rules must
            allow TCP and UDP access. For inbound access, open port 53. For outbound access, open the port
            that you're using for DNS queries on your network.
        direction(Text): Specify the applicable value:    INBOUND: Resolver forwards DNS queries to the DNS service for a
            VPC from your network    OUTBOUND: Resolver forwards DNS queries from the DNS service for a VPC
            to your network.
        ip_addresses(List): The subnets and IP addresses in your VPC that DNS queries originate from (for outbound
            endpoints) or that you forward DNS queries to (for inbound endpoints). The subnet ID uniquely
            identifies a VPC.
        tags(List, optional): A list of the tag keys and values that you want to associate with the endpoint. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.route53resolver.resolver_endpoint.present:
                - creator_request_id: value
                - security_group_ids: value
                - direction: value
                - ip_addresses: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.route53resolver.resolver_endpoint.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.route53resolver.get_resolver_endpoint(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.route53resolver.create_resolver_endpoint(
                ctx,
                
                
                **{"Name": name, "CreatorRequestId": creator_request_id, "SecurityGroupIds": security_group_ids, "Direction": direction, "IpAddresses": ip_addresses, "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.route53resolver.get_resolver_endpoint(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, resolver_endpoint_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a Resolver endpoint. The effect of deleting a Resolver endpoint depends on whether it's an inbound or an
    outbound Resolver endpoint:    Inbound: DNS queries from your network are no longer routed to the DNS service
    for the specified VPC.    Outbound: DNS queries from a VPC are no longer routed to your network.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        resolver_endpoint_id(Text): The ID of the Resolver endpoint that you want to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

