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

hub.exec.boto3.client.sns.create_sms_sandbox_phone_number
hub.exec.boto3.client.sns.delete_sms_sandbox_phone_number
hub.exec.boto3.client.sns.list_sms_sandbox_phone_numbers
hub.exec.boto3.client.sns.verify_sms_sandbox_phone_number
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, phone_number: Text, language_code: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Adds a destination phone number to an account in the SMS sandbox and sends a one-time password (OTP) to that
    phone number. When you start using Amazon SNS to send SMS messages, your account is in the SMS sandbox. The SMS
    sandbox provides a safe environment for you to try Amazon SNS features without risking your reputation as an SMS
    sender. While your account is in the SMS sandbox, you can use all of the features of Amazon SNS. However, you
    can send SMS messages only to verified destination phone numbers. For more information, including how to move
    out of the sandbox to send messages without restrictions, see SMS sandbox in the Amazon SNS Developer Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        phone_number(Text): The destination phone number to verify. On verification, Amazon SNS adds this phone number to
            the list of verified phone numbers that you can send SMS messages to.
        language_code(Text, optional): The language to use for sending the OTP. The default value is en-US. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.sns.create_sms_sandbox_phone_number(
                ctx,
                
                
                **{"PhoneNumber": phone_number, "LanguageCode": language_code}
            )
            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.sns.list_sms_sandbox_phone_numbers(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, phone_number: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an account's verified or pending phone number from the SMS sandbox. When you start using Amazon SNS to
    send SMS messages, your account is in the SMS sandbox. The SMS sandbox provides a safe environment for you to
    try Amazon SNS features without risking your reputation as an SMS sender. While your account is in the SMS
    sandbox, you can use all of the features of Amazon SNS. However, you can send SMS messages only to verified
    destination phone numbers. For more information, including how to move out of the sandbox to send messages
    without restrictions, see SMS sandbox in the Amazon SNS Developer Guide.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        phone_number(Text): The destination phone number to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

