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

hub.exec.boto3.client.customer_profiles.delete_profile_object_type
hub.exec.boto3.client.customer_profiles.get_profile_object_type
hub.exec.boto3.client.customer_profiles.list_profile_object_types
hub.exec.boto3.client.customer_profiles.put_profile_object_type
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, domain_name: Text, object_type_name: Text, description: Text, template_id: Text = None, expiration_days: int = None, encryption_key: Text = None, allow_profile_creation: bool = None, fields: Dict = None, keys: Dict = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Defines a ProfileObjectType.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        domain_name(Text): The unique name of the domain.
        object_type_name(Text): The name of the profile object type.
        description(Text): Description of the profile object type.
        template_id(Text, optional): A unique identifier for the object template. Defaults to None.
        expiration_days(int, optional): The number of days until the data in the object expires. Defaults to None.
        encryption_key(Text, optional): The customer-provided key to encrypt the profile object that will be created in this profile
            object type. Defaults to None.
        allow_profile_creation(bool, optional): Indicates whether a profile should be created when data is received if one doesn’t exist for an
            object of this type. The default is FALSE. If the AllowProfileCreation flag is set to FALSE,
            then the service tries to fetch a standard profile and associate this object with the profile.
            If it is set to TRUE, and if no match is found, then the service creates a new standard profile. Defaults to None.
        fields(Dict, optional): A map of the name and ObjectType field. Defaults to None.
        keys(Dict, optional): A list of unique keys that can be used to map data to the profile. Defaults to None.
        tags(Dict, optional): The tags used to organize, track, or control access for this resource. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.customer_profiles.put_profile_object_type(
                ctx,
                
                
                **{"DomainName": domain_name, "ObjectTypeName": object_type_name, "Description": description, "TemplateId": template_id, "ExpirationDays": expiration_days, "EncryptionKey": encryption_key, "AllowProfileCreation": allow_profile_creation, "Fields": fields, "Keys": keys, "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.customer_profiles.get_profile_object_type(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, domain_name: Text, object_type_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Removes a ProfileObjectType from a specific domain as well as removes all the ProfileObjects of that type. It
    also disables integrations from this specific ProfileObjectType. In addition, it scrubs all of the fields of the
    standard profile that were populated from this ProfileObjectType.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        domain_name(Text): The unique name of the domain.
        object_type_name(Text): The name of the profile object type.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

