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

hub.exec.boto3.client.rekognition.create_project
hub.exec.boto3.client.rekognition.delete_project
hub.exec.boto3.client.rekognition.describe_projects
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, project_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a new Amazon Rekognition Custom Labels project. A project is a logical grouping of resources (images,
    Labels, models) and operations (training, evaluation and detection).  This operation requires permissions to
    perform the rekognition:CreateProject action.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        project_name(Text): The name of the project to create.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

async def absent(hub, ctx, name: Text, project_arn: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an Amazon Rekognition Custom Labels project. To delete a project you must first delete all models
    associated with the project. To delete a model, see DeleteProjectVersion. This operation requires permissions to
    perform the rekognition:DeleteProject action.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        project_arn(Text): The Amazon Resource Name (ARN) of the project that you want to delete.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

