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

hub.exec.boto3.client.frauddetector.delete_external_model
hub.exec.boto3.client.frauddetector.get_external_models
hub.exec.boto3.client.frauddetector.put_external_model
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, model_endpoint: Text, model_source: Text, invoke_model_endpoint_role_arn: Text, input_configuration: Dict, output_configuration: Dict, model_endpoint_status: Text, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates or updates an Amazon SageMaker model endpoint. You can also use this action to update the configuration
    of the model endpoint, including the IAM role and/or the mapped variables.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        model_endpoint(Text): The model endpoints name.
        model_source(Text): The source of the model.
        invoke_model_endpoint_role_arn(Text): The IAM role used to invoke the model endpoint.
        input_configuration(Dict): The model endpoint input configuration.
        output_configuration(Dict): The model endpoint output configuration.
        model_endpoint_status(Text): The model endpoint’s status in Amazon Fraud Detector.
        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.external_model.present:
                - name: value
                - model_endpoint: value
                - model_source: value
                - invoke_model_endpoint_role_arn: value
                - input_configuration: value
                - output_configuration: value
                - model_endpoint_status: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.frauddetector.external_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.frauddetector.get_external_models(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.frauddetector.put_external_model(
                ctx,
                
                
                **{"modelEndpoint": model_endpoint, "modelSource": model_source, "invokeModelEndpointRoleArn": invoke_model_endpoint_role_arn, "inputConfiguration": input_configuration, "outputConfiguration": output_configuration, "modelEndpointStatus": model_endpoint_status, "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.get_external_models(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, model_endpoint: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Removes a SageMaker model from Amazon Fraud Detector. You can remove an Amazon SageMaker model if it is not
    associated with a detector version. Removing a SageMaker model disconnects it from Amazon Fraud Detector, but
    the model remains available in SageMaker.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        model_endpoint(Text): The endpoint of the Amazon Sagemaker model to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_absent:
              aws_auto.frauddetector.external_model.absent:
                - name: value
                - model_endpoint: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.frauddetector.external_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.frauddetector.get_external_models(name)

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

