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

hub.exec.boto3.client.directconnect.create_direct_connect_gateway
hub.exec.boto3.client.directconnect.delete_direct_connect_gateway
hub.exec.boto3.client.directconnect.describe_direct_connect_gateways
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, direct_connect_gateway_name: Text, amazon_side_asn: int = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a Direct Connect gateway, which is an intermediate object that enables you to connect a set of virtual
    interfaces and virtual private gateways. A Direct Connect gateway is global and visible in any Region after it
    is created. The virtual interfaces and virtual private gateways that are connected through a Direct Connect
    gateway can be in different Regions. This enables you to connect to a VPC in any Region, regardless of the
    Region in which the virtual interfaces are located, and pass traffic between them.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        direct_connect_gateway_name(Text): The name of the Direct Connect gateway.
        amazon_side_asn(int, optional): The autonomous system number (ASN) for Border Gateway Protocol (BGP) to be configured on the
            Amazon side of the connection. The ASN must be in the private range of 64,512 to 65,534 or
            4,200,000,000 to 4,294,967,294. The default is 64512. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.directconnect.create_direct_connect_gateway(
                ctx,
                
                
                **{"directConnectGatewayName": direct_connect_gateway_name, "amazonSideAsn": amazon_side_asn}
            )
            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_gateways(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, direct_connect_gateway_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified Direct Connect gateway. You must first delete all virtual interfaces that are attached to
    the Direct Connect gateway and disassociate all virtual private gateways associated with the Direct Connect
    gateway.

    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.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

