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

hub.exec.boto3.client.lookoutequipment.create_dataset
hub.exec.boto3.client.lookoutequipment.delete_dataset
hub.exec.boto3.client.lookoutequipment.describe_dataset
hub.exec.boto3.client.lookoutequipment.list_datasets
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, dataset_name: Text, dataset_schema: Dict, server_side_kms_key_id: Text = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a container for a collection of data being ingested for analysis. The dataset contains the metadata
    describing where the data is and what the data actually looks like. In other words, it contains the location of
    the data source, the data schema, and other information. A dataset also contains any tags associated with the
    ingested data.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        dataset_name(Text): The name of the dataset being created.
        dataset_schema(Dict): A JSON description of the data that is in each time series dataset, including names, column
            names, and data types.
        server_side_kms_key_id(Text, optional): Provides the identifier of the AWS KMS customer master key (CMK) used to encrypt dataset data by
            Amazon Lookout for Equipment. Defaults to None.
        tags(List, optional): Any tags associated with the ingested data described in the dataset. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.lookoutequipment.dataset.present:
                - name: value
                - dataset_name: value
                - dataset_schema: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.lookoutequipment.dataset.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.lookoutequipment.describe_dataset(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.lookoutequipment.create_dataset(
                ctx,
                
                ClientToken=name,
                **{"DatasetName": dataset_name, "DatasetSchema": dataset_schema, "ServerSideKmsKeyId": server_side_kms_key_id, "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.lookoutequipment.describe_dataset(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, dataset_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     Deletes a dataset and associated artifacts. The operation will check to see if any inference scheduler or data
    ingestion job is currently using the dataset, and if there isn't, the dataset, its metadata, and any associated
    data stored in S3 will be deleted. This does not affect any models that used this dataset for training and
    evaluation, but does prevent it from being used in the future.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        dataset_name(Text): The name of the dataset to be deleted.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

