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

hub.exec.boto3.client.ec2.create_transit_gateway
hub.exec.boto3.client.ec2.delete_transit_gateway
hub.exec.boto3.client.ec2.describe_transit_gateways
hub.exec.boto3.client.ec2.modify_transit_gateway
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, description: Text = None, options: Dict = None, tag_specifications: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a transit gateway. You can use a transit gateway to interconnect your virtual private clouds (VPC) and
    on-premises networks. After the transit gateway enters the available state, you can attach your VPCs and VPN
    connections to the transit gateway. To attach your VPCs, use CreateTransitGatewayVpcAttachment. To attach a VPN
    connection, use CreateCustomerGateway to create a customer gateway and specify the ID of the customer gateway
    and the ID of the transit gateway in a call to CreateVpnConnection. When you create a transit gateway, we create
    a default transit gateway route table and use it as the default association route table and the default
    propagation route table. You can use CreateTransitGatewayRouteTable to create additional transit gateway route
    tables. If you disable automatic route propagation, we do not create a default transit gateway route table. You
    can use EnableTransitGatewayRouteTablePropagation to propagate routes from a resource attachment to a transit
    gateway route table. If you disable automatic associations, you can use AssociateTransitGatewayRouteTable to
    associate a resource attachment with a transit gateway route table.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        description(Text, optional): A description of the transit gateway. Defaults to None.
        options(Dict, optional): The transit gateway options. Defaults to None.
        tag_specifications(List, optional): The tags to apply to the transit gateway. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

async def absent(hub, ctx, name: Text, transit_gateway_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified transit gateway.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

