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

hub.exec.boto3.client.quicksight.create_namespace
hub.exec.boto3.client.quicksight.delete_namespace
hub.exec.boto3.client.quicksight.describe_namespace
hub.exec.boto3.client.quicksight.list_namespaces
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, aws_account_id: Text, namespace: Text, identity_store: Text, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    (Enterprise edition only) Creates a new namespace for you to use with Amazon QuickSight. A namespace allows you
    to isolate the QuickSight users and groups that are registered for that namespace. Users that access the
    namespace can share assets only with other users or groups in the same namespace. They can't see users and
    groups in other namespaces. You can create a namespace after your Amazon Web Services account; is subscribed to
    QuickSight. The namespace must be unique within the Amazon Web Services account;. By default, there is a limit
    of 100 namespaces per Amazon Web Services account;. To increase your limit, create a ticket with Amazon Web
    Services Support.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        aws_account_id(Text): The ID for the Amazon Web Services account; that you want to create the QuickSight namespace in.
        namespace(Text): The name that you want to use to describe the new namespace.
        identity_store(Text): Specifies the type of your user identity directory. Currently, this supports users with an
            identity type of QUICKSIGHT.
        tags(List, optional): The tags that you want to associate with the namespace that you're creating. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.quicksight.namespace.present:
                - name: value
                - aws_account_id: value
                - namespace: value
                - identity_store: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.quicksight.namespace.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.quicksight.describe_namespace(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.quicksight.create_namespace(
                ctx,
                
                
                **{"AwsAccountId": aws_account_id, "Namespace": namespace, "IdentityStore": identity_store, "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.quicksight.describe_namespace(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, aws_account_id: Text, namespace: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a namespace and the users and groups that are associated with the namespace. This is an asynchronous
    process. Assets including dashboards, analyses, datasets and data sources are not deleted. To delete these
    assets, you use the API operations for the relevant asset.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        aws_account_id(Text): The ID for the Amazon Web Services account; that you want to delete the QuickSight namespace
            from.
        namespace(Text): The namespace that you want to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.quicksight.delete_namespace(
                ctx,
                
                
                **{"AwsAccountId": aws_account_id, "Namespace": namespace}
            )
            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.quicksight.describe_namespace(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

