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

hub.exec.boto3.client.route53resolver.associate_firewall_rule_group
hub.exec.boto3.client.route53resolver.create_firewall_rule_group
hub.exec.boto3.client.route53resolver.delete_firewall_rule_group
hub.exec.boto3.client.route53resolver.disassociate_firewall_rule_group
hub.exec.boto3.client.route53resolver.get_firewall_rule_group
hub.exec.boto3.client.route53resolver.list_firewall_rule_groups
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, creator_request_id: Text, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates an empty DNS Firewall rule group for filtering DNS network traffic in a VPC. You can add rules to the
    new rule group by calling CreateFirewallRule.

    Args:
        name(Text): A name that lets you identify the rule group, to manage and use it.
        creator_request_id(Text): A unique string defined by you to identify the request. This allows you to retry failed requests
            without the risk of running the operation twice. This can be any unique string, for example, a
            timestamp.
        tags(List, optional): A list of the tag keys and values that you want to associate with the rule group. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.route53resolver.create_firewall_rule_group(
                ctx,
                
                
                **{"Name": name, "CreatorRequestId": creator_request_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_firewall_rule_group(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, firewall_rule_group_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified firewall rule group.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        firewall_rule_group_id(Text): The unique identifier of the firewall rule group that you want to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

