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

hub.exec.boto3.client.ec2.create_client_vpn_endpoint
hub.exec.boto3.client.ec2.delete_client_vpn_endpoint
hub.exec.boto3.client.ec2.describe_client_vpn_endpoints
hub.exec.boto3.client.ec2.modify_client_vpn_endpoint
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, client_cidr_block: Text, server_certificate_arn: Text, authentication_options: List, connection_log_options: Dict, dns_servers: List = None, transport_protocol: Text = None, vpn_port: int = None, description: Text = None, split_tunnel: bool = None, tag_specifications: List = None, security_group_ids: List = None, vpc_id: Text = None, self_service_portal: Text = None, client_connect_options: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a Client VPN endpoint. A Client VPN endpoint is the resource you create and configure to enable and
    manage client VPN sessions. It is the destination endpoint at which all client VPN sessions are terminated.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        client_cidr_block(Text): The IPv4 address range, in CIDR notation, from which to assign client IP addresses. The address
            range cannot overlap with the local CIDR of the VPC in which the associated subnet is located,
            or the routes that you add manually. The address range cannot be changed after the Client VPN
            endpoint has been created. The CIDR block should be /22 or greater.
        server_certificate_arn(Text): The ARN of the server certificate. For more information, see the AWS Certificate Manager User
            Guide.
        authentication_options(List): Information about the authentication method to be used to authenticate clients.
        connection_log_options(Dict): Information about the client connection logging options. If you enable client connection
            logging, data about client connections is sent to a Cloudwatch Logs log stream. The following
            information is logged:   Client connection requests   Client connection results (successful and
            unsuccessful)   Reasons for unsuccessful client connection requests   Client connection
            termination time.
        dns_servers(List, optional): Information about the DNS servers to be used for DNS resolution. A Client VPN endpoint can have
            up to two DNS servers. If no DNS server is specified, the DNS address configured on the device
            is used for the DNS server. Defaults to None.
        transport_protocol(Text, optional): The transport protocol to be used by the VPN session. Default value: udp. Defaults to None.
        vpn_port(int, optional): The port number to assign to the Client VPN endpoint for TCP and UDP traffic. Valid Values: 443
            | 1194  Default Value: 443. Defaults to None.
        description(Text, optional): A brief description of the Client VPN endpoint. Defaults to None.
        split_tunnel(bool, optional): Indicates whether split-tunnel is enabled on the AWS Client VPN endpoint. By default, split-
            tunnel on a VPN endpoint is disabled. For information about split-tunnel VPN endpoints, see
            Split-Tunnel AWS Client VPN Endpoint in the AWS Client VPN Administrator Guide. Defaults to None.
        tag_specifications(List, optional): The tags to apply to the Client VPN endpoint during creation. Defaults to None.
        security_group_ids(List, optional): The IDs of one or more security groups to apply to the target network. You must also specify the
            ID of the VPC that contains the security groups. Defaults to None.
        vpc_id(Text, optional): The ID of the VPC to associate with the Client VPN endpoint. If no security group IDs are
            specified in the request, the default security group for the VPC is applied. Defaults to None.
        self_service_portal(Text, optional): Specify whether to enable the self-service portal for the Client VPN endpoint. Default Value:
            enabled. Defaults to None.
        client_connect_options(Dict, optional): The options for managing connection authorization for new client connections. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.ec2.client_vpn_endpoint.present:
                - name: value
                - client_cidr_block: value
                - server_certificate_arn: value
                - authentication_options: value
                - connection_log_options: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.ec2.client_vpn_endpoint.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_client_vpn_endpoints(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.ec2.create_client_vpn_endpoint(
                ctx,
                DryRun=ctx.test,
                ClientToken=name,
                **{"ClientCidrBlock": client_cidr_block, "ServerCertificateArn": server_certificate_arn, "AuthenticationOptions": authentication_options, "ConnectionLogOptions": connection_log_options, "DnsServers": dns_servers, "TransportProtocol": transport_protocol, "VpnPort": vpn_port, "Description": description, "SplitTunnel": split_tunnel, "TagSpecifications": tag_specifications, "SecurityGroupIds": security_group_ids, "VpcId": vpc_id, "SelfServicePortal": self_service_portal, "ClientConnectOptions": client_connect_options}
            )
            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_client_vpn_endpoints(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, client_vpn_endpoint_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified Client VPN endpoint. You must disassociate all target networks before you can delete a
    Client VPN endpoint.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        client_vpn_endpoint_id(Text): The ID of the Client VPN to be deleted.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

