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

hub.exec.boto3.client.sagemaker.create_user_profile
hub.exec.boto3.client.sagemaker.delete_user_profile
hub.exec.boto3.client.sagemaker.describe_user_profile
hub.exec.boto3.client.sagemaker.list_user_profiles
hub.exec.boto3.client.sagemaker.update_user_profile
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, domain_id: Text, user_profile_name: Text, single_sign_on_user_identifier: Text = None, single_sign_on_user_value: Text = None, tags: List = None, user_settings: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a user profile. A user profile represents a single user within a domain, and is the main way to
    reference a "person" for the purposes of sharing, reporting, and other user-oriented features. This entity is
    created when a user onboards to Amazon SageMaker Studio. If an administrator invites a person by email or
    imports them from SSO, a user profile is automatically created. A user profile is the primary holder of settings
    for an individual user and has a reference to the user's private Amazon Elastic File System (EFS) home
    directory.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        domain_id(Text): The ID of the associated Domain.
        user_profile_name(Text): A name for the UserProfile. This value is not case sensitive.
        single_sign_on_user_identifier(Text, optional): A specifier for the type of value specified in SingleSignOnUserValue. Currently, the only
            supported value is "UserName". If the Domain's AuthMode is SSO, this field is required. If the
            Domain's AuthMode is not SSO, this field cannot be specified. Defaults to None.
        single_sign_on_user_value(Text, optional): The username of the associated Amazon Web Services Single Sign-On User for this UserProfile. If
            the Domain's AuthMode is SSO, this field is required, and must match a valid username of a user
            in your directory. If the Domain's AuthMode is not SSO, this field cannot be specified. Defaults to None.
        tags(List, optional): Each tag consists of a key and an optional value. Tag keys must be unique per resource. Tags
            that you specify for the User Profile are also added to all Apps that the User Profile launches. Defaults to None.
        user_settings(Dict, optional): A collection of settings. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.sagemaker.user_profile.present:
                - name: value
                - domain_id: value
                - user_profile_name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.sagemaker.user_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.sagemaker.describe_user_profile(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.sagemaker.create_user_profile(
                ctx,
                
                
                **{"DomainId": domain_id, "UserProfileName": user_profile_name, "SingleSignOnUserIdentifier": single_sign_on_user_identifier, "SingleSignOnUserValue": single_sign_on_user_value, "Tags": tags, "UserSettings": user_settings}
            )
            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.sagemaker.describe_user_profile(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, domain_id: Text, user_profile_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a user profile. When a user profile is deleted, the user loses access to their EFS volume, including
    data, notebooks, and other artifacts.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        domain_id(Text): The domain ID.
        user_profile_name(Text): The user profile name.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.sagemaker.user_profile.absent:
                - name: value
                - domain_id: value
                - user_profile_name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.sagemaker.user_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.sagemaker.describe_user_profile(name)

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

