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

hub.exec.boto3.client.lookoutequipment.create_model
hub.exec.boto3.client.lookoutequipment.delete_model
hub.exec.boto3.client.lookoutequipment.describe_model
hub.exec.boto3.client.lookoutequipment.list_models
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, model_name: Text, dataset_name: Text, dataset_schema: Dict = None, labels_input_configuration: Dict = None, training_data_start_time: Text = None, training_data_end_time: Text = None, evaluation_data_start_time: Text = None, evaluation_data_end_time: Text = None, role_arn: Text = None, data_pre_processing_configuration: Dict = None, server_side_kms_key_id: Text = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates an ML model for data inference.  A machine-learning (ML) model is a mathematical model that finds
    patterns in your data. In Amazon Lookout for Equipment, the model learns the patterns of normal behavior and
    detects abnormal behavior that could be potential equipment failure (or maintenance events). The models are made
    by analyzing normal data and abnormalities in machine behavior that have already occurred. Your model is trained
    using a portion of the data from your dataset and uses that data to learn patterns of normal behavior and
    abnormal patterns that lead to equipment failure. Another portion of the data is used to evaluate the model's
    accuracy.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        model_name(Text): The name for the ML model to be created.
        dataset_name(Text): The name of the dataset for the ML model being created.
        dataset_schema(Dict, optional): The data schema for the ML model being created. Defaults to None.
        labels_input_configuration(Dict, optional): The input configuration for the labels being used for the ML model that's being created. Defaults to None.
        training_data_start_time(Text, optional): Indicates the time reference in the dataset that should be used to begin the subset of training
            data for the ML model. Defaults to None.
        training_data_end_time(Text, optional): Indicates the time reference in the dataset that should be used to end the subset of training
            data for the ML model. Defaults to None.
        evaluation_data_start_time(Text, optional): Indicates the time reference in the dataset that should be used to begin the subset of
            evaluation data for the ML model. Defaults to None.
        evaluation_data_end_time(Text, optional):  Indicates the time reference in the dataset that should be used to end the subset of evaluation
            data for the ML model. Defaults to None.
        role_arn(Text, optional):  The Amazon Resource Name (ARN) of a role with permission to access the data source being used
            to create the ML model. Defaults to None.
        data_pre_processing_configuration(Dict, optional): The configuration is the TargetSamplingRate, which is the sampling rate of the data after post
            processing by Amazon Lookout for Equipment. For example, if you provide data that has been
            collected at a 1 second level and you want the system to resample the data at a 1 minute rate
            before training, the TargetSamplingRate is 1 minute. When providing a value for the
            TargetSamplingRate, you must attach the prefix "PT" to the rate you want. The value for a 1
            second rate is therefore PT1S, the value for a 15 minute rate is PT15M, and the value for a 1
            hour rate is PT1H. Defaults to None.
        server_side_kms_key_id(Text, optional): Provides the identifier of the AWS KMS customer master key (CMK) used to encrypt model data by
            Amazon Lookout for Equipment. Defaults to None.
        tags(List, optional):  Any tags associated with the ML model being created. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.lookoutequipment.create_model(
                ctx,
                
                ClientToken=name,
                **{"ModelName": model_name, "DatasetName": dataset_name, "DatasetSchema": dataset_schema, "LabelsInputConfiguration": labels_input_configuration, "TrainingDataStartTime": training_data_start_time, "TrainingDataEndTime": training_data_end_time, "EvaluationDataStartTime": evaluation_data_start_time, "EvaluationDataEndTime": evaluation_data_end_time, "RoleArn": role_arn, "DataPreProcessingConfiguration": data_pre_processing_configuration, "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_model(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, model_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an ML model currently available for Amazon Lookout for Equipment. This will prevent it from being used
    with an inference scheduler, even one that is already set up.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

