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

hub.exec.boto3.client.dataexchange.create_data_set
hub.exec.boto3.client.dataexchange.delete_data_set
hub.exec.boto3.client.dataexchange.get_data_set
hub.exec.boto3.client.dataexchange.list_data_sets
hub.exec.boto3.client.dataexchange.update_data_set
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, asset_type: Text, description: Text, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    This operation creates a data set.

    Args:
        name(Text): The name of the data set.
        asset_type(Text): The type of file your data is stored in. Currently, the supported asset type is S3_SNAPSHOT.
        description(Text): A description for the data set. This value can be up to 16,348 characters long.
        tags(Dict, optional): A data set tag is an optional label that you can assign to a data set when you create it. Each
            tag consists of a key and an optional value, both of which you define. When you use tagging, you
            can also use tag-based access control in IAM policies to control access to these data sets and
            revisions. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.dataexchange.data_set.present:
                - name: value
                - asset_type: value
                - description: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.dataexchange.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.dataexchange.get_data_set(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.dataexchange.create_data_set(
                ctx,
                
                
                **{"Name": name, "AssetType": asset_type, "Description": description, "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.dataexchange.get_data_set(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, data_set_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    This operation deletes a data set.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        data_set_id(Text): The unique identifier for a data set.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

