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

hub.exec.boto3.client.nimble.create_studio
hub.exec.boto3.client.nimble.delete_studio
hub.exec.boto3.client.nimble.get_studio
hub.exec.boto3.client.nimble.update_studio
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, admin_role_arn: Text, display_name: Text, studio_name: Text, user_role_arn: Text, client_token: Text = None, studio_encryption_configuration: Dict = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Create a new Studio. When creating a Studio, two IAM roles must be provided: the admin role and the user Role.
    These roles are assumed by your users when they log in to the Nimble Studio portal. The user role must have the
    AmazonNimbleStudio-StudioUser managed policy attached for the portal to function properly. The Admin Role must
    have the AmazonNimbleStudio-StudioAdmin managed policy attached for the portal to function properly. You may
    optionally specify a KMS key in the StudioEncryptionConfiguration. In Nimble Studio, resource names,
    descriptions, initialization scripts, and other data you provide are always encrypted at rest using an KMS key.
    By default, this key is owned by Amazon Web Services and managed on your behalf. You may provide your own KMS
    key when calling CreateStudio to encrypt this data using a key you own and manage. When providing an KMS key
    during studio creation, Nimble Studio creates KMS grants in your account to provide your studio user and admin
    roles access to these KMS keys. If you delete this grant, the studio will no longer be accessible to your portal
    users. If you delete the studio KMS key, your studio will no longer be accessible.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        admin_role_arn(Text): The IAM role that Studio Admins will assume when logging in to the Nimble Studio portal.
        client_token(Text, optional): To make an idempotent API request using one of these actions, specify a client token in the
            request. You should not reuse the same client token for other API requests. If you retry a
            request that completed successfully using the same client token and the same parameters, the
            retry succeeds without performing any further actions. If you retry a successful request using
            the same client token, but one or more of the parameters are different, the retry fails with a
            ValidationException error. Defaults to None.
        display_name(Text): A friendly name for the studio.
        studio_encryption_configuration(Dict, optional): The studio encryption configuration. Defaults to None.
        studio_name(Text): The studio name that is used in the URL of the Nimble Studio portal when accessed by Nimble
            Studio users.
        tags(Dict, optional): A collection of labels, in the form of key:value pairs, that apply to this resource. Defaults to None.
        user_role_arn(Text): The IAM role that Studio Users will assume when logging in to the Nimble Studio portal.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.nimble.studio.present:
                - name: value
                - admin_role_arn: value
                - display_name: value
                - studio_name: value
                - user_role_arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.nimble.studio.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.nimble.get_studio(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.nimble.create_studio(
                ctx,
                
                
                **{"adminRoleArn": admin_role_arn, "clientToken": client_token, "displayName": display_name, "studioEncryptionConfiguration": studio_encryption_configuration, "studioName": studio_name, "tags": tags, "userRoleArn": user_role_arn}
            )
            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.nimble.get_studio(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, studio_id: Text, client_token: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Delete a studio resource.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        client_token(Text, optional): To make an idempotent API request using one of these actions, specify a client token in the
            request. You should not reuse the same client token for other API requests. If you retry a
            request that completed successfully using the same client token and the same parameters, the
            retry succeeds without performing any further actions. If you retry a successful request using
            the same client token, but one or more of the parameters are different, the retry fails with a
            ValidationException error. Defaults to None.
        studio_id(Text): The studio ID.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.nimble.delete_studio(
                ctx,
                
                
                **{"clientToken": client_token, "studioId": studio_id}
            )
            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.nimble.get_studio(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

