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

hub.exec.boto3.client.ec2.create_traffic_mirror_filter
hub.exec.boto3.client.ec2.delete_traffic_mirror_filter
hub.exec.boto3.client.ec2.describe_traffic_mirror_filters
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, description: Text = None, tag_specifications: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a Traffic Mirror filter. A Traffic Mirror filter is a set of rules that defines the traffic to mirror.
    By default, no traffic is mirrored. To mirror traffic, use CreateTrafficMirrorFilterRule to add Traffic Mirror
    rules to the filter. The rules you add define what traffic gets mirrored. You can also use
    ModifyTrafficMirrorFilterNetworkServices to mirror supported network services.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        description(Text, optional): The description of the Traffic Mirror filter. Defaults to None.
        tag_specifications(List, optional): The tags to assign to a Traffic Mirror filter. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.ec2.create_traffic_mirror_filter(
                ctx,
                DryRun=ctx.test,
                ClientToken=name,
                **{"Description": description, "TagSpecifications": tag_specifications}
            )
            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.ec2.describe_traffic_mirror_filters(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, traffic_mirror_filter_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified Traffic Mirror filter. You cannot delete a Traffic Mirror filter that is in use by a
    Traffic Mirror session.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        traffic_mirror_filter_id(Text): The ID of the Traffic Mirror filter.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.ec2.delete_traffic_mirror_filter(
                ctx,
                DryRun=ctx.test,
                
                **{"TrafficMirrorFilterId": traffic_mirror_filter_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.ec2.describe_traffic_mirror_filters(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

