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

hub.exec.boto3.client.directconnect.accept_direct_connect_gateway_association_proposal
hub.exec.boto3.client.directconnect.create_direct_connect_gateway_association_proposal
hub.exec.boto3.client.directconnect.delete_direct_connect_gateway_association_proposal
hub.exec.boto3.client.directconnect.describe_direct_connect_gateway_association_proposals
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, direct_connect_gateway_id: Text, direct_connect_gateway_owner_account: Text, gateway_id: Text, add_allowed_prefixes_to_direct_connect_gateway: List = None, remove_allowed_prefixes_to_direct_connect_gateway: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a proposal to associate the specified virtual private gateway or transit gateway with the specified
    Direct Connect gateway. You can associate a Direct Connect gateway and virtual private gateway or transit
    gateway that is owned by any account.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        direct_connect_gateway_id(Text): The ID of the Direct Connect gateway.
        direct_connect_gateway_owner_account(Text): The ID of the account that owns the Direct Connect gateway.
        gateway_id(Text): The ID of the virtual private gateway or transit gateway.
        add_allowed_prefixes_to_direct_connect_gateway(List, optional): The Amazon VPC prefixes to advertise to the Direct Connect gateway. Defaults to None.
        remove_allowed_prefixes_to_direct_connect_gateway(List, optional): The Amazon VPC prefixes to no longer advertise to the Direct Connect gateway. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.directconnect.direct_connect_gateway_association_proposal.present:
                - name: value
                - direct_connect_gateway_id: value
                - direct_connect_gateway_owner_account: value
                - gateway_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.directconnect.direct_connect_gateway_association_proposal.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.directconnect.describe_direct_connect_gateway_association_proposals(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.directconnect.create_direct_connect_gateway_association_proposal(
                ctx,
                
                
                **{"directConnectGatewayId": direct_connect_gateway_id, "directConnectGatewayOwnerAccount": direct_connect_gateway_owner_account, "gatewayId": gateway_id, "addAllowedPrefixesToDirectConnectGateway": add_allowed_prefixes_to_direct_connect_gateway, "removeAllowedPrefixesToDirectConnectGateway": remove_allowed_prefixes_to_direct_connect_gateway}
            )
            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.directconnect.describe_direct_connect_gateway_association_proposals(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, proposal_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the association proposal request between the specified Direct Connect gateway and virtual private
    gateway or transit gateway.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

