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

hub.exec.boto3.client.ec2.create_network_insights_path
hub.exec.boto3.client.ec2.delete_network_insights_path
hub.exec.boto3.client.ec2.describe_network_insights_paths
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, source: Text, destination: Text, protocol: Text, source_ip: Text = None, destination_ip: Text = None, destination_port: int = None, tag_specifications: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a path to analyze for reachability. Reachability Analyzer enables you to analyze and debug network
    reachability between two resources in your virtual private cloud (VPC). For more information, see What is
    Reachability Analyzer.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        source_ip(Text, optional): The IP address of the Amazon Web Services resource that is the source of the path. Defaults to None.
        destination_ip(Text, optional): The IP address of the Amazon Web Services resource that is the destination of the path. Defaults to None.
        source(Text): The Amazon Web Services resource that is the source of the path.
        destination(Text): The Amazon Web Services resource that is the destination of the path.
        protocol(Text): The protocol.
        destination_port(int, optional): The destination port. Defaults to None.
        tag_specifications(List, optional): The tags to add to the path. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.ec2.create_network_insights_path(
                ctx,
                DryRun=ctx.test,
                ClientToken=name,
                **{"SourceIp": source_ip, "DestinationIp": destination_ip, "Source": source, "Destination": destination, "Protocol": protocol, "DestinationPort": destination_port, "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_network_insights_paths(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

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

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

