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

hub.exec.boto3.client.ec2.describe_vpc_classic_link
hub.exec.boto3.client.ec2.disable_vpc_classic_link
hub.exec.boto3.client.ec2.enable_vpc_classic_link
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, vpc_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Enables a VPC for ClassicLink. You can then link EC2-Classic instances to your ClassicLink-enabled VPC to allow
    communication over private IP addresses. You cannot enable your VPC for ClassicLink if any of your VPC route
    tables have existing routes for address ranges within the 10.0.0.0/8 IP address range, excluding local routes
    for VPCs in the 10.0.0.0/16 and 10.1.0.0/16 IP address ranges. For more information, see ClassicLink in the
    Amazon Elastic Compute Cloud User Guide.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

async def absent(hub, ctx, name: Text, vpc_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Disables ClassicLink for a VPC. You cannot disable ClassicLink for a VPC that has EC2-Classic instances linked
    to it.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

