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

hub.exec.boto3.client.rekognition.create_stream_processor
hub.exec.boto3.client.rekognition.delete_stream_processor
hub.exec.boto3.client.rekognition.describe_stream_processor
hub.exec.boto3.client.rekognition.list_stream_processors
hub.exec.boto3.client.rekognition.start_stream_processor
hub.exec.boto3.client.rekognition.stop_stream_processor
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, input_: Dict, output: Dict, settings: Dict, role_arn: Text, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates an Amazon Rekognition stream processor that you can use to detect and recognize faces in a streaming
    video. Amazon Rekognition Video is a consumer of live video from Amazon Kinesis Video Streams. Amazon
    Rekognition Video sends analysis results to Amazon Kinesis Data Streams. You provide as input a Kinesis video
    stream (Input) and a Kinesis data stream (Output) stream. You also specify the face recognition criteria in
    Settings. For example, the collection containing faces that you want to recognize. Use Name to assign an
    identifier for the stream processor. You use Name to manage the stream processor. For example, you can start
    processing the source video by calling StartStreamProcessor with the Name field.  After you have finished
    analyzing a streaming video, use StopStreamProcessor to stop processing. You can delete the stream processor by
    calling DeleteStreamProcessor. This operation requires permissions to perform the
    rekognition:CreateStreamProcessor action. If you want to tag your stream processor, you also require permission
    to perform the rekognition:TagResource operation.

    Args:
        name(Text): An identifier you assign to the stream processor. You can use Name to manage the stream
            processor. For example, you can get the current status of the stream processor by calling
            DescribeStreamProcessor. Name is idempotent.
        input_(Dict): Kinesis video stream stream that provides the source streaming video. If you are using the AWS
            CLI, the parameter name is StreamProcessorInput.
        output(Dict): Kinesis data stream stream to which Amazon Rekognition Video puts the analysis results. If you
            are using the AWS CLI, the parameter name is StreamProcessorOutput.
        settings(Dict): Face recognition input parameters to be used by the stream processor. Includes the collection to
            use for face recognition and the face attributes to detect.
        role_arn(Text): ARN of the IAM role that allows access to the stream processor.
        tags(Dict, optional):  A set of tags (key-value pairs) that you want to attach to the stream processor. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.rekognition.stream_processor.present:
                - name: value
                - input_: value
                - output: value
                - settings: value
                - role_arn: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.rekognition.stream_processor.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.rekognition.describe_stream_processor(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.rekognition.create_stream_processor(
                ctx,
                
                
                **{"Name": name, "Input": input_, "Output": output, "Settings": settings, "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.rekognition.describe_stream_processor(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the stream processor identified by Name. You assign the value for Name when you create the stream
    processor with CreateStreamProcessor. You might not be able to use the same name for a stream processor for a
    few seconds after calling DeleteStreamProcessor.

    Args:
        name(Text): The name of the stream processor you want to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

