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

hub.exec.boto3.client.ses.create_custom_verification_email_template
hub.exec.boto3.client.ses.delete_custom_verification_email_template
hub.exec.boto3.client.ses.get_custom_verification_email_template
hub.exec.boto3.client.ses.list_custom_verification_email_templates
hub.exec.boto3.client.ses.update_custom_verification_email_template
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, template_name: Text, from_email_address: Text, template_subject: Text, template_content: Text, success_redirection_url: Text, failure_redirection_url: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new custom verification email template. For more information about custom verification email
    templates, see Using Custom Verification Email Templates in the Amazon SES Developer Guide. You can execute this
    operation no more than once per second.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        template_name(Text): The name of the custom verification email template.
        from_email_address(Text): The email address that the custom verification email is sent from.
        template_subject(Text): The subject line of the custom verification email.
        template_content(Text): The content of the custom verification email. The total size of the email must be less than 10
            MB. The message body may contain HTML, with some limitations. For more information, see Custom
            Verification Email Frequently Asked Questions in the Amazon SES Developer Guide.
        success_redirection_url(Text): The URL that the recipient of the verification email is sent to if his or her address is
            successfully verified.
        failure_redirection_url(Text): The URL that the recipient of the verification email is sent to if his or her address is not
            successfully verified.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.ses.custom_verification_email_template.present:
                - name: value
                - template_name: value
                - from_email_address: value
                - template_subject: value
                - template_content: value
                - success_redirection_url: value
                - failure_redirection_url: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.ses.custom_verification_email_template.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.ses.get_custom_verification_email_template(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.ses.create_custom_verification_email_template(
                ctx,
                
                
                **{"TemplateName": template_name, "FromEmailAddress": from_email_address, "TemplateSubject": template_subject, "TemplateContent": template_content, "SuccessRedirectionURL": success_redirection_url, "FailureRedirectionURL": failure_redirection_url}
            )
            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.ses.get_custom_verification_email_template(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, template_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an existing custom verification email template.  For more information about custom verification email
    templates, see Using Custom Verification Email Templates in the Amazon SES Developer Guide. You can execute this
    operation no more than once per second.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        template_name(Text): The name of the custom verification email template that you want to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

