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

hub.exec.boto3.client.pinpoint_email.create_configuration_set
hub.exec.boto3.client.pinpoint_email.delete_configuration_set
hub.exec.boto3.client.pinpoint_email.get_configuration_set
hub.exec.boto3.client.pinpoint_email.list_configuration_sets
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, configuration_set_name: Text, tracking_options: Dict = None, delivery_options: Dict = None, reputation_options: Dict = None, sending_options: Dict = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Create a configuration set. Configuration sets are groups of rules that you can apply to the emails you send
    using Amazon Pinpoint. You apply a configuration set to an email by including a reference to the configuration
    set in the headers of the email. When you apply a configuration set to an email, all of the rules in that
    configuration set are applied to the email.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        configuration_set_name(Text): The name of the configuration set.
        tracking_options(Dict, optional): An object that defines the open and click tracking options for emails that you send using the
            configuration set. Defaults to None.
        delivery_options(Dict, optional): An object that defines the dedicated IP pool that is used to send emails that you send using the
            configuration set. Defaults to None.
        reputation_options(Dict, optional): An object that defines whether or not Amazon Pinpoint collects reputation metrics for the emails
            that you send that use the configuration set. Defaults to None.
        sending_options(Dict, optional): An object that defines whether or not Amazon Pinpoint can send email that you send using the
            configuration set. Defaults to None.
        tags(List, optional): An array of objects that define the tags (keys and values) that you want to associate with the
            configuration set. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.pinpoint_email.create_configuration_set(
                ctx,
                
                
                **{"ConfigurationSetName": configuration_set_name, "TrackingOptions": tracking_options, "DeliveryOptions": delivery_options, "ReputationOptions": reputation_options, "SendingOptions": sending_options, "Tags": tags}
            )
            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(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, configuration_set_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Delete an existing configuration set. In Amazon Pinpoint, configuration sets are groups of rules that you can
    apply to the emails you send. You apply a configuration set to an email by including a reference to the
    configuration set in the headers of the email. When you apply a configuration set to an email, all of the rules
    in that configuration set are applied to the email.

    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 delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

