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

hub.exec.boto3.client.mediaconnect.create_flow
hub.exec.boto3.client.mediaconnect.delete_flow
hub.exec.boto3.client.mediaconnect.describe_flow
hub.exec.boto3.client.mediaconnect.list_flows
hub.exec.boto3.client.mediaconnect.start_flow
hub.exec.boto3.client.mediaconnect.stop_flow
hub.exec.boto3.client.mediaconnect.update_flow
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, availability_zone: Text = None, entitlements: List = None, media_streams: List = None, outputs: List = None, source: Dict = None, source_failover_config: Dict = None, sources: List = None, vpc_interfaces: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new flow. The request must include one source. The request optionally can include outputs (up to 50)
    and entitlements (up to 50).

    Args:
        name(Text): The name of the flow.
        availability_zone(Text, optional): The Availability Zone that you want to create the flow in. These options are limited to the
            Availability Zones within the current AWS Region. Defaults to None.
        entitlements(List, optional): The entitlements that you want to grant on a flow. Defaults to None.
        media_streams(List, optional): The media streams that you want to add to the flow. You can associate these media streams with
            sources and outputs on the flow. Defaults to None.
        outputs(List, optional): The outputs that you want to add to this flow. Defaults to None.
        source(Dict, optional): The settings for the source of the flow. Defaults to None.
        source_failover_config(Dict, optional): The settings for source failover. Defaults to None.
        sources(List, optional): . Defaults to None.
        vpc_interfaces(List, optional): The VPC interfaces you want on the flow. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.mediaconnect.create_flow(
                ctx,
                
                
                **{"Name": name, "AvailabilityZone": availability_zone, "Entitlements": entitlements, "MediaStreams": media_streams, "Outputs": outputs, "Source": source, "SourceFailoverConfig": source_failover_config, "Sources": sources, "VpcInterfaces": vpc_interfaces}
            )
            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.mediaconnect.describe_flow(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, flow_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a flow. Before you can delete a flow, you must stop the flow.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        flow_arn(Text): The ARN of the flow that you want to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

