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

hub.exec.boto3.client.route53resolver.associate_resolver_rule
hub.exec.boto3.client.route53resolver.create_resolver_rule
hub.exec.boto3.client.route53resolver.delete_resolver_rule
hub.exec.boto3.client.route53resolver.disassociate_resolver_rule
hub.exec.boto3.client.route53resolver.get_resolver_rule
hub.exec.boto3.client.route53resolver.list_resolver_rules
hub.exec.boto3.client.route53resolver.update_resolver_rule
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, creator_request_id: Text, rule_type: Text, domain_name: Text, name: Text = None, target_ips: List = None, resolver_endpoint_id: Text = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    For DNS queries that originate in your VPCs, specifies which Resolver endpoint the queries pass through, one
    domain name that you want to forward to your network, and the IP addresses of the DNS resolvers in your network.

    Args:
        name(Text, optional): A friendly name that lets you easily find a rule 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.
        rule_type(Text): When you want to forward DNS queries for specified domain name to resolvers on your network,
            specify FORWARD. When you have a forwarding rule to forward DNS queries for a domain to your
            network and you want Resolver to process queries for a subdomain of that domain, specify SYSTEM.
            For example, to forward DNS queries for example.com to resolvers on your network, you create a
            rule and specify FORWARD for RuleType. To then have Resolver process queries for
            apex.example.com, you create a rule and specify SYSTEM for RuleType. Currently, only Resolver
            can create rules that have a value of RECURSIVE for RuleType.
        domain_name(Text): DNS queries for this domain name are forwarded to the IP addresses that you specify in
            TargetIps. If a query matches multiple Resolver rules (example.com and www.example.com),
            outbound DNS queries are routed using the Resolver rule that contains the most specific domain
            name (www.example.com).
        target_ips(List, optional): The IPs that you want Resolver to forward DNS queries to. You can specify only IPv4 addresses.
            Separate IP addresses with a space.  TargetIps is available only when the value of Rule type is
            FORWARD. Defaults to None.
        resolver_endpoint_id(Text, optional): The ID of the outbound Resolver endpoint that you want to use to route DNS queries to the IP
            addresses that you specify in TargetIps. Defaults to None.
        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_rule.present:
                - creator_request_id: value
                - rule_type: value
                - domain_name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.route53resolver.resolver_rule.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_rule(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.route53resolver.create_resolver_rule(
                ctx,
                
                
                **{"Name": name, "CreatorRequestId": creator_request_id, "RuleType": rule_type, "DomainName": domain_name, "TargetIps": target_ips, "ResolverEndpointId": resolver_endpoint_id, "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_rule(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, resolver_rule_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a Resolver rule. Before you can delete a Resolver rule, you must disassociate it from all the VPCs that
    you associated the Resolver rule with. For more information, see DisassociateResolverRule.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

