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

hub.exec.boto3.client.network_firewall.associate_firewall_policy
hub.exec.boto3.client.network_firewall.create_firewall_policy
hub.exec.boto3.client.network_firewall.delete_firewall_policy
hub.exec.boto3.client.network_firewall.describe_firewall_policy
hub.exec.boto3.client.network_firewall.list_firewall_policies
hub.exec.boto3.client.network_firewall.update_firewall_policy
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, firewall_policy_name: Text, firewall_policy: Dict, description: Text = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates the firewall policy for the firewall according to the specifications.  An AWS Network Firewall firewall
    policy defines the behavior of a firewall, in a collection of stateless and stateful rule groups and other
    settings. You can use one firewall policy for multiple firewalls.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        firewall_policy_name(Text): The descriptive name of the firewall policy. You can't change the name of a firewall policy
            after you create it.
        firewall_policy(Dict): The rule groups and policy actions to use in the firewall policy.
        description(Text, optional): A description of the firewall policy. Defaults to None.
        tags(List, optional): The key:value pairs to associate with the resource. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.network_firewall.create_firewall_policy(
                ctx,
                DryRun=ctx.test,
                
                **{"FirewallPolicyName": firewall_policy_name, "FirewallPolicy": firewall_policy, "Description": description, "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.network_firewall.describe_firewall_policy(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, firewall_policy_name: Text = None, firewall_policy_arn: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified FirewallPolicy.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        firewall_policy_name(Text, optional): The descriptive name of the firewall policy. You can't change the name of a firewall policy
            after you create it. You must specify the ARN or the name, and you can specify both. Defaults to None.
        firewall_policy_arn(Text, optional): The Amazon Resource Name (ARN) of the firewall policy. You must specify the ARN or the name, and
            you can specify both. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.network_firewall.delete_firewall_policy(
                ctx,
                
                
                **{"FirewallPolicyName": firewall_policy_name, "FirewallPolicyArn": firewall_policy_arn}
            )
            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.network_firewall.describe_firewall_policy(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

