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

hub.exec.boto3.client.sagemaker.create_flow_definition
hub.exec.boto3.client.sagemaker.delete_flow_definition
hub.exec.boto3.client.sagemaker.describe_flow_definition
hub.exec.boto3.client.sagemaker.list_flow_definitions
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, flow_definition_name: Text, human_loop_config: Dict, output_config: Dict, role_arn: Text, human_loop_request_source: Dict = None, human_loop_activation_config: Dict = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a flow definition.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        flow_definition_name(Text): The name of your flow definition.
        human_loop_request_source(Dict, optional): Container for configuring the source of human task requests. Use to specify if Amazon
            Rekognition or Amazon Textract is used as an integration source. Defaults to None.
        human_loop_activation_config(Dict, optional): An object containing information about the events that trigger a human workflow. Defaults to None.
        human_loop_config(Dict): An object containing information about the tasks the human reviewers will perform.
        output_config(Dict): An object containing information about where the human review results will be uploaded.
        role_arn(Text): The Amazon Resource Name (ARN) of the role needed to call other services on your behalf. For
            example, arn:aws:iam::1234567890:role/service-role/AmazonSageMaker-
            ExecutionRole-20180111T151298.
        tags(List, optional): An array of key-value pairs that contain metadata to help you categorize and organize a flow
            definition. Each tag consists of a key and a value, both of which you define. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.sagemaker.flow_definition.present:
                - name: value
                - flow_definition_name: value
                - human_loop_config: value
                - output_config: value
                - role_arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.sagemaker.flow_definition.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_flow_definition(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.sagemaker.create_flow_definition(
                ctx,
                
                
                **{"FlowDefinitionName": flow_definition_name, "HumanLoopRequestSource": human_loop_request_source, "HumanLoopActivationConfig": human_loop_activation_config, "HumanLoopConfig": human_loop_config, "OutputConfig": output_config, "RoleArn": role_arn, "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_flow_definition(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, flow_definition_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified flow definition.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        flow_definition_name(Text): The name of the flow definition you are deleting.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

