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

hub.exec.boto3.client.quicksight.create_dashboard
hub.exec.boto3.client.quicksight.delete_dashboard
hub.exec.boto3.client.quicksight.describe_dashboard
hub.exec.boto3.client.quicksight.list_dashboards
hub.exec.boto3.client.quicksight.search_dashboards
hub.exec.boto3.client.quicksight.update_dashboard
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, aws_account_id: Text, dashboard_id: Text, source_entity: Dict, parameters: Dict = None, permissions: List = None, tags: List = None, version_description: Text = None, dashboard_publish_options: Dict = None, theme_arn: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a dashboard from a template. To first create a template, see the  CreateTemplate  API operation. A
    dashboard is an entity in QuickSight that identifies QuickSight reports, created from analyses. You can share
    QuickSight dashboards. With the right permissions, you can create scheduled email reports from them. If you have
    the correct permissions, you can create a dashboard from a template that exists in a different Amazon Web
    Services account;.

    Args:
        name(Text): The display name of the dashboard.
        aws_account_id(Text): The ID of the Amazon Web Services account; where you want to create the dashboard.
        dashboard_id(Text): The ID for the dashboard, also added to the IAM policy.
        parameters(Dict, optional): The parameters for the creation of the dashboard, which you want to use to override the default
            settings. A dashboard can have any type of parameters, and some parameters might accept multiple
            values. Defaults to None.
        permissions(List, optional): A structure that contains the permissions of the dashboard. You can use this structure for
            granting permissions by providing a list of IAM action information for each principal ARN.  To
            specify no permissions, omit the permissions list. Defaults to None.
        source_entity(Dict): The entity that you are using as a source when you create the dashboard. In SourceEntity, you
            specify the type of object you're using as source. You can only create a dashboard from a
            template, so you use a SourceTemplate entity. If you need to create a dashboard from an
            analysis, first convert the analysis to a template by using the CreateTemplate API operation.
            For SourceTemplate, specify the Amazon Resource Name (ARN) of the source template. The
            SourceTemplateARN can contain any Amazon Web Services account; and any QuickSight-supported
            Amazon Web Services Region;.  Use the DataSetReferences entity within SourceTemplate to list the
            replacement datasets for the placeholders listed in the original. The schema in each dataset
            must match its placeholder.
        tags(List, optional): Contains a map of the key-value pairs for the resource tag or tags assigned to the dashboard. Defaults to None.
        version_description(Text, optional): A description for the first version of the dashboard being created. Defaults to None.
        dashboard_publish_options(Dict, optional): Options for publishing the dashboard when you create it:    AvailabilityStatus for
            AdHocFilteringOption - This status can be either ENABLED or DISABLED. When this is set to
            DISABLED, QuickSight disables the left filter pane on the published dashboard, which can be used
            for ad hoc (one-time) filtering. This option is ENABLED by default.     AvailabilityStatus for
            ExportToCSVOption - This status can be either ENABLED or DISABLED. The visual option to export
            data to .CSV format isn't enabled when this is set to DISABLED. This option is ENABLED by
            default.     VisibilityState for SheetControlsOption - This visibility state can be either
            COLLAPSED or EXPANDED. This option is COLLAPSED by default. Defaults to None.
        theme_arn(Text, optional): The Amazon Resource Name (ARN) of the theme that is being used for this dashboard. If you add a
            value for this field, it overrides the value that is used in the source entity. The theme ARN
            must exist in the same Amazon Web Services account; where you create the dashboard. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.quicksight.create_dashboard(
                ctx,
                
                
                **{"Name": name, "AwsAccountId": aws_account_id, "DashboardId": dashboard_id, "Parameters": parameters, "Permissions": permissions, "SourceEntity": source_entity, "Tags": tags, "VersionDescription": version_description, "DashboardPublishOptions": dashboard_publish_options, "ThemeArn": theme_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.quicksight.describe_dashboard(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

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

    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 dashboard that you're deleting.
        dashboard_id(Text): The ID for the dashboard.
        version_number(int, optional): The version number of the dashboard. If the version number property is provided, only the
            specified version of the dashboard is deleted. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

