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

hub.exec.boto3.client.quicksight.create_theme
hub.exec.boto3.client.quicksight.delete_theme
hub.exec.boto3.client.quicksight.describe_theme
hub.exec.boto3.client.quicksight.list_themes
hub.exec.boto3.client.quicksight.update_theme
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, aws_account_id: Text, theme_id: Text, base_theme_id: Text, configuration: Dict, version_description: Text = None, permissions: List = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a theme. A theme is set of configuration options for color and layout. Themes apply to analyses and
    dashboards. For more information, see Using Themes in Amazon QuickSight in the Amazon QuickSight User Guide.

    Args:
        name(Text): A display name for the theme.
        aws_account_id(Text): The ID of the Amazon Web Services account; where you want to store the new theme.
        theme_id(Text): An ID for the theme that you want to create. The theme ID is unique per Amazon Web Services
            Region; in each Amazon Web Services account;.
        base_theme_id(Text): The ID of the theme that a custom theme will inherit from. All themes inherit from one of the
            starting themes defined by Amazon QuickSight. For a list of the starting themes, use ListThemes
            or choose Themes from within a QuickSight analysis.
        version_description(Text, optional): A description of the first version of the theme that you're creating. Every time UpdateTheme is
            called, a new version is created. Each version of the theme has a description of the version in
            the VersionDescription field. Defaults to None.
        configuration(Dict): The theme configuration, which contains the theme display properties.
        permissions(List, optional): A valid grouping of resource permissions to apply to the new theme. Defaults to None.
        tags(List, optional): A map of the key-value pairs for the resource tag or tags that you want to add to the resource. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.quicksight.create_theme(
                ctx,
                
                
                **{"Name": name, "AwsAccountId": aws_account_id, "ThemeId": theme_id, "BaseThemeId": base_theme_id, "VersionDescription": version_description, "Configuration": configuration, "Permissions": permissions, "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_theme(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, aws_account_id: Text, theme_id: Text, version_number: int = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a theme.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        aws_account_id(Text): The ID of the Amazon Web Services account; that contains the theme that you're deleting.
        theme_id(Text): An ID for the theme that you want to delete.
        version_number(int, optional): The version of the theme that you want to delete.   Note: If you don't provide a version number,
            you're using this call to DeleteTheme to delete all versions of the theme. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

