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

hub.exec.boto3.client.pinpoint_email.create_configuration_set_event_destination
hub.exec.boto3.client.pinpoint_email.delete_configuration_set_event_destination
hub.exec.boto3.client.pinpoint_email.get_configuration_set_event_destinations
hub.exec.boto3.client.pinpoint_email.update_configuration_set_event_destination
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, configuration_set_name: Text, event_destination_name: Text, event_destination: Dict)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Create an event destination. In Amazon Pinpoint, events include message sends, deliveries, opens, clicks,
    bounces, and complaints. Event destinations are places that you can send information about these events to. For
    example, you can send event data to Amazon SNS to receive notifications when you receive bounces or complaints,
    or you can use Amazon Kinesis Data Firehose to stream data to Amazon S3 for long-term storage. A single
    configuration set can include more than one event destination.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        configuration_set_name(Text): The name of the configuration set that you want to add an event destination to.
        event_destination_name(Text): A name that identifies the event destination within the configuration set.
        event_destination(Dict): An object that defines the event destination.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.pinpoint_email.configuration_set_event_destination.present:
                - name: value
                - configuration_set_name: value
                - event_destination_name: value
                - event_destination: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.pinpoint_email.configuration_set_event_destination.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.pinpoint_email.get_configuration_set_event_destinations(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.pinpoint_email.create_configuration_set_event_destination(
                ctx,
                
                
                **{"ConfigurationSetName": configuration_set_name, "EventDestinationName": event_destination_name, "EventDestination": event_destination}
            )
            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.pinpoint_email.get_configuration_set_event_destinations(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, configuration_set_name: Text, event_destination_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Delete an event destination. In Amazon Pinpoint, events include message sends, deliveries, opens, clicks,
    bounces, and complaints. Event destinations are places that you can send information about these events to. For
    example, you can send event data to Amazon SNS to receive notifications when you receive bounces or complaints,
    or you can use Amazon Kinesis Data Firehose to stream data to Amazon S3 for long-term storage.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        configuration_set_name(Text): The name of the configuration set that contains the event destination that you want to delete.
        event_destination_name(Text): The name of the event destination that you want to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.pinpoint_email.configuration_set_event_destination.absent:
                - name: value
                - configuration_set_name: value
                - event_destination_name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.pinpoint_email.configuration_set_event_destination.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.pinpoint_email.get_configuration_set_event_destinations(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.pinpoint_email.delete_configuration_set_event_destination(
                ctx,
                
                
                **{"ConfigurationSetName": configuration_set_name, "EventDestinationName": event_destination_name}
            )
            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.pinpoint_email.get_configuration_set_event_destinations(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

