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

hub.exec.boto3.client.sagemaker.associate_trial_component
hub.exec.boto3.client.sagemaker.create_trial_component
hub.exec.boto3.client.sagemaker.delete_trial_component
hub.exec.boto3.client.sagemaker.describe_trial_component
hub.exec.boto3.client.sagemaker.disassociate_trial_component
hub.exec.boto3.client.sagemaker.list_trial_components
hub.exec.boto3.client.sagemaker.update_trial_component
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, trial_component_name: Text, display_name: Text = None, status: Dict = None, start_time: Text = None, end_time: Text = None, parameters: Dict = None, input_artifacts: Dict = None, output_artifacts: Dict = None, metadata_properties: Dict = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a trial component, which is a stage of a machine learning trial. A trial is composed of one or more
    trial components. A trial component can be used in multiple trials. Trial components include pre-processing
    jobs, training jobs, and batch transform jobs. When you use SageMaker Studio or the SageMaker Python SDK, all
    experiments, trials, and trial components are automatically tracked, logged, and indexed. When you use the
    Amazon Web Services SDK for Python (Boto), you must use the logging APIs provided by the SDK. You can add tags
    to a trial component and then use the Search API to search for the tags.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        trial_component_name(Text): The name of the component. The name must be unique in your Amazon Web Services account and is
            not case-sensitive.
        display_name(Text, optional): The name of the component as displayed. The name doesn't need to be unique. If DisplayName isn't
            specified, TrialComponentName is displayed. Defaults to None.
        status(Dict, optional): The status of the component. States include:   InProgress   Completed   Failed. Defaults to None.
        start_time(Text, optional): When the component started. Defaults to None.
        end_time(Text, optional): When the component ended. Defaults to None.
        parameters(Dict, optional): The hyperparameters for the component. Defaults to None.
        input_artifacts(Dict, optional): The input artifacts for the component. Examples of input artifacts are datasets, algorithms,
            hyperparameters, source code, and instance types. Defaults to None.
        output_artifacts(Dict, optional): The output artifacts for the component. Examples of output artifacts are metrics, snapshots,
            logs, and images. Defaults to None.
        metadata_properties(Dict, optional): Metadata properties of the tracking entity, trial, or trial component. Defaults to None.
        tags(List, optional): A list of tags to associate with the component. You can use Search API to search on the tags. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.sagemaker.trial_component.present:
                - name: value
                - trial_component_name: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.sagemaker.trial_component.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.sagemaker.describe_trial_component(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.sagemaker.create_trial_component(
                ctx,
                
                
                **{"TrialComponentName": trial_component_name, "DisplayName": display_name, "Status": status, "StartTime": start_time, "EndTime": end_time, "Parameters": parameters, "InputArtifacts": input_artifacts, "OutputArtifacts": output_artifacts, "MetadataProperties": metadata_properties, "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.sagemaker.describe_trial_component(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, trial_component_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified trial component. A trial component must be disassociated from all trials before the trial
    component can be deleted. To disassociate a trial component from a trial, call the DisassociateTrialComponent
    API.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        trial_component_name(Text): The name of the component to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

