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

hub.exec.boto3.client.groundstation.create_dataflow_endpoint_group
hub.exec.boto3.client.groundstation.delete_dataflow_endpoint_group
hub.exec.boto3.client.groundstation.get_dataflow_endpoint_group
hub.exec.boto3.client.groundstation.list_dataflow_endpoint_groups
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, endpoint_details: List, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a DataflowEndpoint group containing the specified list of DataflowEndpoint objects. The name field in
    each endpoint is used in your mission profile DataflowEndpointConfig to specify which endpoints to use during a
    contact. When a contact uses multiple DataflowEndpointConfig objects, each Config must match a DataflowEndpoint
    in the same group.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        endpoint_details(List): Endpoint details of each endpoint in the dataflow endpoint group.
        tags(Dict, optional): Tags of a dataflow endpoint group. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.groundstation.create_dataflow_endpoint_group(
                ctx,
                
                
                **{"endpointDetails": endpoint_details, "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.groundstation.get_dataflow_endpoint_group(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, dataflow_endpoint_group_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a dataflow endpoint group.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        dataflow_endpoint_group_id(Text): UUID of a dataflow endpoint group.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

