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

hub.exec.boto3.client.ec2.attach_vpn_gateway
hub.exec.boto3.client.ec2.create_vpn_gateway
hub.exec.boto3.client.ec2.delete_vpn_gateway
hub.exec.boto3.client.ec2.describe_vpn_gateways
hub.exec.boto3.client.ec2.detach_vpn_gateway
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, type_: Text, availability_zone: Text = None, tag_specifications: List = None, amazon_side_asn: int = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a virtual private gateway. A virtual private gateway is the endpoint on the VPC side of your VPN
    connection. You can create a virtual private gateway before creating the VPC itself. For more information, see
    AWS Site-to-Site VPN in the AWS Site-to-Site VPN User Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        availability_zone(Text, optional): The Availability Zone for the virtual private gateway. Defaults to None.
        type_(Text): The type of VPN connection this virtual private gateway supports.
        tag_specifications(List, optional): The tags to apply to the virtual private gateway. Defaults to None.
        amazon_side_asn(int, optional): A private Autonomous System Number (ASN) for the Amazon side of a BGP session. If you're using a
            16-bit ASN, it must be in the 64512 to 65534 range. If you're using a 32-bit ASN, it must be in
            the 4200000000 to 4294967294 range. Default: 64512. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.ec2.create_vpn_gateway(
                ctx,
                DryRun=ctx.test,
                
                **{"AvailabilityZone": availability_zone, "Type": type_, "TagSpecifications": tag_specifications, "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.ec2.describe_vpn_gateways(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, vpn_gateway_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified virtual private gateway. You must first detach the virtual private gateway from the VPC.
    Note that you don't need to delete the virtual private gateway if you plan to delete and recreate the VPN
    connection between your VPC and your network.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        vpn_gateway_id(Text): The ID of the virtual private gateway.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.ec2.vpn_gateway.absent:
                - name: value
                - vpn_gateway_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.ec2.vpn_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.ec2.describe_vpn_gateways(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.ec2.delete_vpn_gateway(
                ctx,
                DryRun=ctx.test,
                
                **{"VpnGatewayId": vpn_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.ec2.describe_vpn_gateways(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

