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

hub.exec.boto3.client.ec2.create_vpc_endpoint_connection_notification
hub.exec.boto3.client.ec2.delete_vpc_endpoint_connection_notifications
hub.exec.boto3.client.ec2.describe_vpc_endpoint_connection_notifications
hub.exec.boto3.client.ec2.modify_vpc_endpoint_connection_notification
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, connection_notification_arn: Text, connection_events: List, service_id: Text = None, vpc_endpoint_id: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a connection notification for a specified VPC endpoint or VPC endpoint service. A connection
    notification notifies you of specific endpoint events. You must create an SNS topic to receive notifications.
    For more information, see Create a Topic in the Amazon Simple Notification Service Developer Guide. You can
    create a connection notification for interface endpoints only.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        service_id(Text, optional): The ID of the endpoint service. Defaults to None.
        vpc_endpoint_id(Text, optional): The ID of the endpoint. Defaults to None.
        connection_notification_arn(Text): The ARN of the SNS topic for the notifications.
        connection_events(List): One or more endpoint events for which to receive notifications. Valid values are Accept,
            Connect, Delete, and Reject.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.ec2.create_vpc_endpoint_connection_notification(
                ctx,
                DryRun=ctx.test,
                ClientToken=name,
                **{"ServiceId": service_id, "VpcEndpointId": vpc_endpoint_id, "ConnectionNotificationArn": connection_notification_arn, "ConnectionEvents": connection_events}
            )
            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_endpoint_connection_notifications(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, connection_notification_ids: List)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes one or more VPC endpoint connection notifications.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        connection_notification_ids(List): One or more notification IDs.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

