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

hub.exec.boto3.client.auditmanager.create_assessment
hub.exec.boto3.client.auditmanager.delete_assessment
hub.exec.boto3.client.auditmanager.get_assessment
hub.exec.boto3.client.auditmanager.list_assessments
hub.exec.boto3.client.auditmanager.update_assessment
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, assessment_reports_destination: Dict, scope: Dict, roles: List, framework_id: Text, description: Text = None, tags: Dict = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     Creates an assessment in Audit Manager.

    Args:
        name(Text):  The name of the assessment to be created.
        description(Text, optional):  The optional description of the assessment to be created. Defaults to None.
        assessment_reports_destination(Dict):  The assessment report storage destination for the specified assessment that is being created.
        scope(Dict):  The wrapper that contains the accounts and services in scope for the assessment.
        roles(List):  The list of roles for the specified assessment.
        framework_id(Text):  The identifier for the specified framework.
        tags(Dict, optional):  The tags associated with the assessment. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.auditmanager.assessment.present:
                - name: value
                - assessment_reports_destination: value
                - scope: value
                - roles: value
                - framework_id: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.auditmanager.assessment.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.auditmanager.get_assessment(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.auditmanager.create_assessment(
                ctx,
                
                
                **{"Name": name, "description": description, "assessmentReportsDestination": assessment_reports_destination, "scope": scope, "roles": roles, "frameworkId": framework_id, "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.auditmanager.get_assessment(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, assessment_id: Text)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
     Deletes an assessment in Audit Manager.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        assessment_id(Text):  The identifier for the specified assessment.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

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

