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

hub.exec.boto3.client.groundstation.create_mission_profile
hub.exec.boto3.client.groundstation.delete_mission_profile
hub.exec.boto3.client.groundstation.get_mission_profile
hub.exec.boto3.client.groundstation.list_mission_profiles
hub.exec.boto3.client.groundstation.update_mission_profile
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, dataflow_edges: List, minimum_viable_contact_duration_seconds: int, tracking_config_arn: Text, contact_post_pass_duration_seconds: int = None, contact_pre_pass_duration_seconds: int = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a mission profile.  dataflowEdges is a list of lists of strings. Each lower level list of strings has
    two elements: a from ARN and a to ARN.

    Args:
        name(Text): Name of a mission profile.
        contact_post_pass_duration_seconds(int, optional): Amount of time after a contact ends that you’d like to receive a CloudWatch event indicating the
            pass has finished. Defaults to None.
        contact_pre_pass_duration_seconds(int, optional): Amount of time prior to contact start you’d like to receive a CloudWatch event indicating an
            upcoming pass. Defaults to None.
        dataflow_edges(List): A list of lists of ARNs. Each list of ARNs is an edge, with a from Config and a to Config.
        minimum_viable_contact_duration_seconds(int): Smallest amount of time in seconds that you’d like to see for an available contact. AWS Ground
            Station will not present you with contacts shorter than this duration.
        tags(Dict, optional): Tags assigned to a mission profile. Defaults to None.
        tracking_config_arn(Text): ARN of a tracking Config.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.groundstation.mission_profile.present:
                - name: value
                - dataflow_edges: value
                - minimum_viable_contact_duration_seconds: value
                - tracking_config_arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.groundstation.mission_profile.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.groundstation.get_mission_profile(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.groundstation.create_mission_profile(
                ctx,
                
                
                **{"Name": name, "contactPostPassDurationSeconds": contact_post_pass_duration_seconds, "contactPrePassDurationSeconds": contact_pre_pass_duration_seconds, "dataflowEdges": dataflow_edges, "minimumViableContactDurationSeconds": minimum_viable_contact_duration_seconds, "tags": tags, "trackingConfigArn": tracking_config_arn}
            )
            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.groundstation.get_mission_profile(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, mission_profile_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a mission profile.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        mission_profile_id(Text): UUID of a mission profile.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

