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

hub.exec.boto3.client.quicksight.create_data_source
hub.exec.boto3.client.quicksight.delete_data_source
hub.exec.boto3.client.quicksight.describe_data_source
hub.exec.boto3.client.quicksight.list_data_sources
hub.exec.boto3.client.quicksight.update_data_source
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, aws_account_id: Text, data_source_id: Text, type_: Text, data_source_parameters: Dict = None, credentials: Dict = None, permissions: List = None, vpc_connection_properties: Dict = None, ssl_properties: Dict = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a data source.

    Args:
        name(Text): A display name for the data source.
        aws_account_id(Text): The Amazon Web Services account; ID.
        data_source_id(Text): An ID for the data source. This ID is unique per Amazon Web Services Region; for each Amazon Web
            Services account;.
        type_(Text): The type of the data source. Currently, the supported types for this operation are: ATHENA,
            AURORA, AURORA_POSTGRESQL, AMAZON_ELASTICSEARCH, MARIADB, MYSQL, POSTGRESQL, PRESTO, REDSHIFT,
            S3, SNOWFLAKE, SPARK, SQLSERVER, TERADATA. Use ListDataSources to return a list of all data
            sources.  AMAZON_ELASTICSEARCH is for Amazon managed Elasticsearch Service.
        data_source_parameters(Dict, optional): The parameters that QuickSight uses to connect to your underlying source. Defaults to None.
        credentials(Dict, optional): The credentials QuickSight that uses to connect to your underlying source. Currently, only
            credentials based on user name and password are supported. Defaults to None.
        permissions(List, optional): A list of resource permissions on the data source. Defaults to None.
        vpc_connection_properties(Dict, optional): Use this parameter only when you want QuickSight to use a VPC connection when connecting to your
            underlying source. Defaults to None.
        ssl_properties(Dict, optional): Secure Socket Layer (SSL) properties that apply when QuickSight connects to your underlying
            source. Defaults to None.
        tags(List, optional): Contains a map of the key-value pairs for the resource tag or tags assigned to the data source. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.quicksight.create_data_source(
                ctx,
                
                
                **{"Name": name, "AwsAccountId": aws_account_id, "DataSourceId": data_source_id, "Type": type_, "DataSourceParameters": data_source_parameters, "Credentials": credentials, "Permissions": permissions, "VpcConnectionProperties": vpc_connection_properties, "SslProperties": ssl_properties, "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_source(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, aws_account_id: Text, data_source_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the data source permanently. This operation breaks all the datasets that reference the deleted data
    source.

    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_source_id(Text): The ID of the data source. 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_source.absent:
                - name: value
                - aws_account_id: value
                - data_source_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.quicksight.data_source.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_source(name)

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

