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

hub.exec.boto3.client.ec2.create_egress_only_internet_gateway
hub.exec.boto3.client.ec2.delete_egress_only_internet_gateway
hub.exec.boto3.client.ec2.describe_egress_only_internet_gateways
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, vpc_id: Text, tag_specifications: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    [IPv6 only] Creates an egress-only internet gateway for your VPC. An egress-only internet gateway is used to
    enable outbound communication over IPv6 from instances in your VPC to the internet, and prevents hosts outside
    of your VPC from initiating an IPv6 connection with your instance.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        vpc_id(Text): The ID of the VPC for which to create the egress-only internet gateway.
        tag_specifications(List, optional): The tags to assign to the egress-only internet gateway. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

async def absent(hub, ctx, name: Text, egress_only_internet_gateway_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an egress-only internet gateway.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        egress_only_internet_gateway_id(Text): The ID of the egress-only internet gateway.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

