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

hub.exec.boto3.client.quicksight.create_data_set
hub.exec.boto3.client.quicksight.delete_data_set
hub.exec.boto3.client.quicksight.describe_data_set
hub.exec.boto3.client.quicksight.list_data_sets
hub.exec.boto3.client.quicksight.update_data_set
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, aws_account_id: Text, data_set_id: Text, physical_table_map: Dict, import_mode: Text, logical_table_map: Dict = None, column_groups: List = None, field_folders: Dict = None, permissions: List = None, row_level_permission_data_set: Dict = None, row_level_permission_tag_configuration: Dict = None, column_level_permission_rules: List = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a dataset.

    Args:
        name(Text): The display name for the dataset.
        aws_account_id(Text): The Amazon Web Services account; ID.
        data_set_id(Text): An ID for the dataset that you want to create. This ID is unique per Amazon Web Services Region;
            for each Amazon Web Services account;.
        physical_table_map(Dict): Declares the physical tables that are available in the underlying data sources.
        logical_table_map(Dict, optional): Configures the combination and transformation of the data from the physical tables. Defaults to None.
        import_mode(Text): Indicates whether you want to import the data into SPICE.
        column_groups(List, optional): Groupings of columns that work together in certain QuickSight features. Currently, only
            geospatial hierarchy is supported. Defaults to None.
        field_folders(Dict, optional): The folder that contains fields and nested subfolders for your dataset. Defaults to None.
        permissions(List, optional): A list of resource permissions on the dataset. Defaults to None.
        row_level_permission_data_set(Dict, optional): The row-level security configuration for the data that you want to create. Defaults to None.
        row_level_permission_tag_configuration(Dict, optional): The configuration of tags on a dataset to set row-level security. Row-level security tags are
            currently supported for anonymous embedding only. Defaults to None.
        column_level_permission_rules(List, optional): A set of one or more definitions of a  ColumnLevelPermissionRule . Defaults to None.
        tags(List, optional): Contains a map of the key-value pairs for the resource tag or tags assigned to the dataset. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.quicksight.create_data_set(
                ctx,
                
                
                **{"Name": name, "AwsAccountId": aws_account_id, "DataSetId": data_set_id, "PhysicalTableMap": physical_table_map, "LogicalTableMap": logical_table_map, "ImportMode": import_mode, "ColumnGroups": column_groups, "FieldFolders": field_folders, "Permissions": permissions, "RowLevelPermissionDataSet": row_level_permission_data_set, "RowLevelPermissionTagConfiguration": row_level_permission_tag_configuration, "ColumnLevelPermissionRules": column_level_permission_rules, "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_data_set(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, aws_account_id: Text, data_set_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a dataset.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        aws_account_id(Text): The Amazon Web Services account; ID.
        data_set_id(Text): The ID for the dataset that you want to create. This ID is unique per Amazon Web Services
            Region; for each Amazon Web Services account;.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

