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

hub.exec.boto3.client.lookoutvision.create_project
hub.exec.boto3.client.lookoutvision.delete_project
hub.exec.boto3.client.lookoutvision.describe_project
hub.exec.boto3.client.lookoutvision.list_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 an empty Amazon Lookout for Vision project. After you create the project, add a dataset by calling
    CreateDataset. This operation requires permissions to perform the lookoutvision:CreateProject operation.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

async def absent(hub, ctx, name: Text, project_name: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes an Amazon Lookout for Vision project. To delete a project, you must first delete each version of the
    model associated with the project. To delete a model use the DeleteModel operation. You also have to delete the
    dataset(s) associated with the model. For more information, see DeleteDataset. The images referenced by the
    training and test datasets aren't deleted.  This operation requires permissions to perform the
    lookoutvision:DeleteProject operation.

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

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

