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

hub.exec.boto3.client.sagemaker.create_project
hub.exec.boto3.client.sagemaker.delete_project
hub.exec.boto3.client.sagemaker.describe_project
hub.exec.boto3.client.sagemaker.list_projects
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, project_name: Text, service_catalog_provisioning_details: Dict, project_description: Text = None, tags: List = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Creates a machine learning (ML) project that can contain one or more templates that set up an ML pipeline from
    training to deploying an approved model.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        project_name(Text): The name of the project.
        project_description(Text, optional): A description for the project. Defaults to None.
        service_catalog_provisioning_details(Dict): The product ID and provisioning artifact ID to provision a service catalog. For information, see
            What is Amazon Web Services Service Catalog.
        tags(List, optional): An array of key-value pairs that you want to use to organize and track your Amazon Web Services
            resource costs. For more information, see Tagging Amazon Web Services resources in the Amazon
            Web Services General Reference Guide. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.sagemaker.create_project(
                ctx,
                
                
                **{"ProjectName": project_name, "ProjectDescription": project_description, "ServiceCatalogProvisioningDetails": service_catalog_provisioning_details, "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_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**
    
    Delete the specified project.

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

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

