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

hub.exec.boto3.client.quicksight.create_account_customization
hub.exec.boto3.client.quicksight.delete_account_customization
hub.exec.boto3.client.quicksight.describe_account_customization
hub.exec.boto3.client.quicksight.update_account_customization
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, aws_account_id: Text, account_customization: Dict, namespace: Text = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates Amazon QuickSight customizations the current Amazon Web Services Region;. Currently, you can add a
    custom default theme by using the CreateAccountCustomization or UpdateAccountCustomization API operation. To
    further customize QuickSight by removing QuickSight sample assets and videos for all new users, see Customizing
    QuickSight in the Amazon QuickSight User Guide.  You can create customizations for your Amazon Web Services
    account; or, if you specify a namespace, for a QuickSight namespace instead. Customizations that apply to a
    namespace always override customizations that apply to an Amazon Web Services account;. To find out which
    customizations apply, use the DescribeAccountCustomization API operation. Before you use the
    CreateAccountCustomization API operation to add a theme as the namespace default, make sure that you first share
    the theme with the namespace. If you don't share it with the namespace, the theme isn't visible to your users
    even if you make it the default theme. To check if the theme is shared, view the current permissions by using
    the  DescribeThemePermissions  API operation. To share the theme, grant permissions by using the
    UpdateThemePermissions  API operation.

    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 customize QuickSight for.
        namespace(Text, optional): The QuickSight namespace that you want to add customizations to. Defaults to None.
        account_customization(Dict): The QuickSight customizations you're adding in the current Amazon Web Services Region;. You can
            add these to an Amazon Web Services account; and a QuickSight namespace.  For example, you can
            add a default theme by setting AccountCustomization to the midnight theme:
            "AccountCustomization": { "DefaultTheme": "arn:aws:quicksight::aws:theme/MIDNIGHT" }. Or, you
            can add a custom theme by specifying "AccountCustomization": { "DefaultTheme":
            "arn:aws:quicksight:us-west-2:111122223333:theme/bdb844d0-0fe9-4d9d-b520-0fe602d93639" }.
        tags(List, optional): A list of the tags that you want to attach to this resource. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

async def absent(hub, ctx, name: Text, aws_account_id: Text, namespace: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes all Amazon QuickSight customizations in this Amazon Web Services Region; for the specified Amazon Web
    Services account; and QuickSight namespace.

    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 QuickSight customizations
            from in this Amazon Web Services Region;.
        namespace(Text, optional): The QuickSight namespace that you're deleting the customizations from. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

