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

hub.exec.boto3.client.customer_profiles.create_profile
hub.exec.boto3.client.customer_profiles.delete_profile
hub.exec.boto3.client.customer_profiles.merge_profiles
hub.exec.boto3.client.customer_profiles.search_profiles
hub.exec.boto3.client.customer_profiles.update_profile
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, domain_name: Text, account_number: Text = None, additional_information: Text = None, party_type: Text = None, business_name: Text = None, first_name: Text = None, middle_name: Text = None, last_name: Text = None, birth_date: Text = None, gender: Text = None, phone_number: Text = None, mobile_phone_number: Text = None, home_phone_number: Text = None, business_phone_number: Text = None, email_address: Text = None, personal_email_address: Text = None, business_email_address: Text = None, address: Dict = None, shipping_address: Dict = None, mailing_address: Dict = None, billing_address: Dict = None, attributes: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a standard profile. A standard profile represents the following attributes for a customer profile in a
    domain.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        domain_name(Text): The unique name of the domain.
        account_number(Text, optional): A unique account number that you have given to the customer. Defaults to None.
        additional_information(Text, optional): Any additional information relevant to the customer’s profile. Defaults to None.
        party_type(Text, optional): The type of profile used to describe the customer. Defaults to None.
        business_name(Text, optional): The name of the customer’s business. Defaults to None.
        first_name(Text, optional): The customer’s first name. Defaults to None.
        middle_name(Text, optional): The customer’s middle name. Defaults to None.
        last_name(Text, optional): The customer’s last name. Defaults to None.
        birth_date(Text, optional): The customer’s birth date. Defaults to None.
        gender(Text, optional): The gender with which the customer identifies. Defaults to None.
        phone_number(Text, optional): The customer’s phone number, which has not been specified as a mobile, home, or business number. Defaults to None.
        mobile_phone_number(Text, optional): The customer’s mobile phone number. Defaults to None.
        home_phone_number(Text, optional): The customer’s home phone number. Defaults to None.
        business_phone_number(Text, optional): The customer’s business phone number. Defaults to None.
        email_address(Text, optional): The customer’s email address, which has not been specified as a personal or business address. Defaults to None.
        personal_email_address(Text, optional): The customer’s personal email address. Defaults to None.
        business_email_address(Text, optional): The customer’s business email address. Defaults to None.
        address(Dict, optional): A generic address associated with the customer that is not mailing, shipping, or billing. Defaults to None.
        shipping_address(Dict, optional): The customer’s shipping address. Defaults to None.
        mailing_address(Dict, optional): The customer’s mailing address. Defaults to None.
        billing_address(Dict, optional): The customer’s billing address. Defaults to None.
        attributes(Dict, optional): A key value pair of attributes of a customer profile. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.customer_profiles.create_profile(
                ctx,
                
                
                **{"DomainName": domain_name, "AccountNumber": account_number, "AdditionalInformation": additional_information, "PartyType": party_type, "BusinessName": business_name, "FirstName": first_name, "MiddleName": middle_name, "LastName": last_name, "BirthDate": birth_date, "Gender": gender, "PhoneNumber": phone_number, "MobilePhoneNumber": mobile_phone_number, "HomePhoneNumber": home_phone_number, "BusinessPhoneNumber": business_phone_number, "EmailAddress": email_address, "PersonalEmailAddress": personal_email_address, "BusinessEmailAddress": business_email_address, "Address": address, "ShippingAddress": shipping_address, "MailingAddress": mailing_address, "BillingAddress": billing_address, "Attributes": attributes}
            )
            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.customer_profiles.search_profiles(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, profile_id: Text, domain_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the standard customer profile and all data pertaining to the profile.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        profile_id(Text): The unique identifier of a customer profile.
        domain_name(Text): The unique name of the domain.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

