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

hub.exec.boto3.client.workdocs.create_comment
hub.exec.boto3.client.workdocs.delete_comment
hub.exec.boto3.client.workdocs.describe_comments
"""



from typing import *
import dict_tools.differ as differ
async def present(hub, ctx, name: Text, document_id: Text, version_id: Text, text: Text, authentication_token: Text = None, parent_id: Text = None, thread_id: Text = None, visibility: Text = None, notify_collaborators: bool = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Adds a new comment to the specified document version.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        authentication_token(Text, optional): Amazon WorkDocs authentication token. Not required when using AWS administrator credentials to
            access the API. Defaults to None.
        document_id(Text): The ID of the document.
        version_id(Text): The ID of the document version.
        parent_id(Text, optional): The ID of the parent comment. Defaults to None.
        thread_id(Text, optional): The ID of the root comment in the thread. Defaults to None.
        text(Text): The text of the comment.
        visibility(Text, optional): The visibility of the comment. Options are either PRIVATE, where the comment is visible only to
            the comment author and document owner and co-owners, or PUBLIC, where the comment is visible to
            document owners, co-owners, and contributors. Defaults to None.
        notify_collaborators(bool, optional): Set this parameter to TRUE to send an email out to the document collaborators after the comment
            is created. Defaults to None.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

            resource_is_present:
              aws_auto.workdocs.comment.present:
                - name: value
                - document_id: value
                - version_id: value
                - text: value
    '''
    
    result = dict(comment="", changes= None, name=name, result=True)
    ret = await hub.exec.boto3.client.workdocs.comment.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.workdocs.describe_comments(name)

    if before:
        result["comment"] = f"'{name}' already exists"
    else:
        try:
            ret = await hub.exec.boto3.client.workdocs.create_comment(
                ctx,
                
                
                **{"AuthenticationToken": authentication_token, "DocumentId": document_id, "VersionId": version_id, "ParentId": parent_id, "ThreadId": thread_id, "Text": text, "Visibility": visibility, "NotifyCollaborators": notify_collaborators}
            )
            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.workdocs.describe_comments(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

async def absent(hub, ctx, name: Text, document_id: Text, version_id: Text, comment_id: Text, authentication_token: Text = None)  -> Dict[str, Any]:
    r'''
    **Autogenerated function**
    
    Deletes the specified comment from the document version.

    Args:
        name(Text): A name, ID, or JMES search path to identify the resource.
        authentication_token(Text, optional): Amazon WorkDocs authentication token. Not required when using AWS administrator credentials to
            access the API. Defaults to None.
        document_id(Text): The ID of the document.
        version_id(Text): The ID of the document version.
        comment_id(Text): The ID of the comment.

    Returns:
        Dict[str, Any]

    Examples:

        .. code-block:: sls

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

    if not before:
        result["comment"] = f"'{name}' already absent"
    else:
        try:
            ret = await hub.exec.boto3.client.workdocs.delete_comment(
                ctx,
                
                
                **{"AuthenticationToken": authentication_token, "DocumentId": document_id, "VersionId": version_id, "CommentId": comment_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.workdocs.describe_comments(name)
    result["changes"] = differ.deep_diff(before, after)
    return result

