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

hub.exec.boto3.client.frauddetector.create_model_version
hub.exec.boto3.client.frauddetector.delete_model_version
hub.exec.boto3.client.frauddetector.describe_model_versions
hub.exec.boto3.client.frauddetector.get_model_version
hub.exec.boto3.client.frauddetector.update_model_version
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, model_id: Text, model_type: Text, training_data_source: Text, training_data_schema: Dict, external_events_detail: Dict = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a version of the model using the specified model type and model id.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        model_id(Text): The model ID.
        model_type(Text): The model type.
        training_data_source(Text): The training data source location in Amazon S3.
        training_data_schema(Dict): The training data schema.
        external_events_detail(Dict, optional): Details for the external events data used for model version training. Required if
            trainingDataSource is EXTERNAL_EVENTS. Defaults to None.
        tags(List, optional): A collection of key and value pairs. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.frauddetector.model_version.present:
                - name: value
                - model_id: value
                - model_type: value
                - training_data_source: value
                - training_data_schema: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.frauddetector.model_version.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.frauddetector.describe_model_versions(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.frauddetector.create_model_version(
                ctx,
                
                
                **{"modelId": model_id, "modelType": model_type, "trainingDataSource": training_data_source, "trainingDataSchema": training_data_schema, "externalEventsDetail": external_events_detail, "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.frauddetector.describe_model_versions(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, model_id: Text, model_type: Text, model_version_number: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes a model version. You can delete models and model versions in Amazon Fraud Detector, provided that they
    are not associated with a detector version.  When you delete a model version, Amazon Fraud Detector permanently
    deletes that model version and the data is no longer stored in Amazon Fraud Detector.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        model_id(Text): The model ID of the model version to delete.
        model_type(Text): The model type of the model version to delete.
        model_version_number(Text): The model version number of the model version to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.frauddetector.model_version.absent:
                - name: value
                - model_id: value
                - model_type: value
                - model_version_number: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.frauddetector.model_version.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.frauddetector.describe_model_versions(name)

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.frauddetector.delete_model_version(
                ctx,
                
                
                **{"modelId": model_id, "modelType": model_type, "modelVersionNumber": model_version_number}
            )
            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.frauddetector.describe_model_versions(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

