# Source code for api.documents.v1.document.document

    """Autogenerated API"""
    import requests
    from argus_cli.plugin import register_command

    @register_command(extending=('documents','v1','document',''))
    def get_meta_info_by_id(documentID: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Fetch specified document excluding content (PUBLIC)

        :param int documentID: ID of document to fetch
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 265, "limit": 880, "responseCode": 200, "count": 512, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Ten term laugh whom owner across road.", "messageTemplate": "Statement should wrong go a.", "field": "Enter catch according dinner part.", "parameter": {}, "timestamp": 969614494}], "currentPage": 809, "size": 924}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/documents/v1/document/{documentID}".format(documentID=documentID)
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        response = get(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response

    @register_command(extending=('documents','v1','document',''))
    def update_document(documentID: int, name: str = None, mimeType: str = None, data: str = None, text: str = None, lockRequestTime: int = 300000,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Update specified document (PUBLIC)

        :param int documentID: ID of document to update
        :param str name: If set change document name  => Sanitize by regex [a-zA-Z0-9ÅåØøÆæ_\-\. ]*
        :param str mimeType: If set change document MIME type
        :param str data: Base64 encoded document content formatted according to the given MIME type. If set change document content
        :param str text: Plain text document content. If set change document content
        :param int lockRequestTime: Specify how long the document should be locked (default 300000)
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises Exception: on 423
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 474, "limit": 974, "responseCode": 200, "count": 219, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Tax resource maintain her big.", "messageTemplate": "Difficult high event effect.", "field": "With organization ready both scene red former.", "parameter": {}, "timestamp": 796802119}], "currentPage": 874, "size": 45}
        """
        from requests import put
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/documents/v1/document/{documentID}".format(documentID=documentID)
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        if lockRequestTime:
            body.update({"lockRequestTime": lockRequestTime})

        if name:
            body.update({"name": name})

        if mimeType:
            body.update({"mimeType": mimeType})

        if data:
            body.update({"data": data})

        if text:
            body.update({"text": text})

        response = put(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response

    @register_command(extending=('documents','v1','document',''))
    def list_document_access(documentID: int, offset: int = 0, limit: int = 25,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Fetch ACL for specified document (PUBLIC)

        :param int documentID: Document ID
        :param int offset: Skip a number of results
        :param int limit: Maximum number of returned results
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 110, "limit": 13, "responseCode": 200, "count": 852, "data": [{"id": 205, "subject": {"id": 427, "customerID": 952, "name": "Thomas Jones"}, "level": "write"}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Trip despite recognize range.", "messageTemplate": "Finish soldier one over.", "field": "Foot lead hundred recent kitchen member car.", "parameter": {}, "timestamp": 1341714018}], "currentPage": 277, "size": 825}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/documents/v1/document/{documentID}/access".format(documentID=documentID)
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        if offset:
            body.update({"offset": offset})

        if limit:
            body.update({"limit": limit})

        response = get(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response

    @register_command(extending=('documents','v1','document',''))
    def grant_document_access(documentID: int, subjectID: int = None, level: str = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Grant access to specified document (PUBLIC)
    If the access level is folder, the user is allowed to obtain the information about the document (without content). If the access level is read, the user is allowed to obtain the content of the document. If the access level is write, the user is allowed to update the document.

        :param int documentID: Document ID
        :param int subjectID: Specify user/group to grant access to
        :param str level: Specify access level to grant to user/group
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 560, "limit": 7, "responseCode": 200, "count": 721, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Put you day against let history culture.", "messageTemplate": "Body time alone.", "field": "Bill either drug.", "parameter": {}, "timestamp": 1184612010}], "currentPage": 348, "size": 394}
        """
        from requests import post
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/documents/v1/document/{documentID}/access".format(documentID=documentID)
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        if subjectID:
            body.update({"subjectID": subjectID})

        if level:
            body.update({"level": level})

        response = post(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response

    @register_command(extending=('documents','v1','document',''))
    def update_document_access_settings(documentID: int, accessMode: str = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Change access settings on specified document (PUBLIC)
    If the access mode is roleBased, user accessing the document must have appropriate role, set by administrator. If the access mode is writeRestricted, user accessing the document can read, but must have appropriate role for write, set by administrator. If the access mode is readRestricted, user accessing the document must have appropriate roles for both read and write, set by administrator. If the access mode is explicit, user accessing the document must have explicit grant by document's owner.

        :param int documentID: Document ID
        :param str accessMode: Specify general access mode for document/folder
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 625, "limit": 779, "responseCode": 200, "count": 718, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Remember future list road board suddenly.", "messageTemplate": "Continue stock level million region can.", "field": "Once method mind actually guess music house.", "parameter": {}, "timestamp": 1009393371}], "currentPage": 579, "size": 165}
        """
        from requests import put
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/documents/v1/document/{documentID}/access".format(documentID=documentID)
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        if accessMode:
            body.update({"accessMode": accessMode})

        response = put(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response

    @register_command(extending=('documents','v1','document',''))
    def revoke_document_access(documentID: int, accessID: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Revoke specified explicit access from document (PUBLIC)

        :param int documentID: Document ID
        :param int accessID: Access ID
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 240, "limit": 607, "responseCode": 200, "count": 227, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Wear Mr brother despite few plant.", "messageTemplate": "Fish cup including sign.", "field": "Hotel relationship energy listen while indicate.", "parameter": {}, "timestamp": 1447789523}], "currentPage": 663, "size": 28}
        """
        from requests import delete
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/documents/v1/document/{documentID}/access/{accessID}".format(documentID=documentID, accessID=accessID)
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        response = delete(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response

    @register_command(extending=('documents','v1','document',''))
    def commit_document(documentID: int, name: str = None, mimeType: str = None, data: str = None, text: str = None, lockRequestTime: int = 300000,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Commit specified document (PUBLIC)

        :param int documentID: ID of document to commit
        :param str name: If set change document name  => Sanitize by regex [a-zA-Z0-9ÅåØøÆæ_\-\. ]*
        :param str mimeType: If set change document MIME type
        :param str data: Base64 encoded document content formatted according to the given MIME type. If set change document content
        :param str text: Plain text document content. If set change document content
        :param int lockRequestTime: Specify how long the document should be locked (default 300000)
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises Exception: on 423
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 818, "limit": 767, "responseCode": 200, "count": 380, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Country join certainly.", "messageTemplate": "Process human friend again present lose.", "field": "Team policy life.", "parameter": {}, "timestamp": 797858429}], "currentPage": 135, "size": 749}
        """
        from requests import put
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/documents/v1/document/{documentID}/commit".format(documentID=documentID)
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        if lockRequestTime:
            body.update({"lockRequestTime": lockRequestTime})

        if name:
            body.update({"name": name})

        if mimeType:
            body.update({"mimeType": mimeType})

        if data:
            body.update({"data": data})

        if text:
            body.update({"text": text})

        response = put(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response

    @register_command(extending=('documents','v1','document',''))
    def get_document_content_by_id(documentID: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Download content as a file for specified document (PUBLIC)

        :param int documentID: ID of document to fetch
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/documents/v1/document/{documentID}/content".format(documentID=documentID)
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        response = get(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response

    @register_command(extending=('documents','v1','document',''))
    def lock_document(documentID: int, lockRequestTime: int = None, mode: str = 'LOCK',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Lock/Unlock specified document (PUBLIC)

        :param int documentID: ID of document to lock/unlock
        :param int lockRequestTime: If 'mode' is set to LOCK, specify how long the document should be locked
        :param str mode: Specify whether to lock or unlock the document, or to override an existing lock (default LOCK)
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises Exception: on 423
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 391, "limit": 789, "responseCode": 200, "count": 121, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Part thought who bring up so.", "messageTemplate": "Choose really back.", "field": "Rock officer my rock save her.", "parameter": {}, "timestamp": 1102556181}], "currentPage": 791, "size": 273}
        """
        from requests import put
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/documents/v1/document/{documentID}/lock".format(documentID=documentID)
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        if mode:
            body.update({"mode": mode})

        if lockRequestTime:
            body.update({"lockRequestTime": lockRequestTime})

        response = put(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response

    @register_command(extending=('documents','v1','document',''))
    def get_document_revisions(documentID: int, limit: int = 25, offset: int = 0,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Fetch specified document revisions (PUBLIC)

        :param int documentID: ID of document to fetch revisions
        :param int limit: Maximum number of returned results
        :param int offset: Skip a number of results
        :raises AuthenticationFailedException: on 401
        :raises ValidationFailedException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 319, "limit": 859, "responseCode": 200, "count": 775, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Kind hope up send more.", "messageTemplate": "Edge cultural check contain team.", "field": "Be into bring finish appear.", "parameter": {}, "timestamp": 2648399}], "currentPage": 497, "size": 54}
        """
        from requests import get
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/documents/v1/document/{documentID}/versions".format(documentID=documentID)
        headers = {
            'Content-Type': 'application/json',
            'User-Agent': 'ArgusToolbelt/1.0'
        }

        if apiKey:
            headers["Argus-API-Key"] = apiKey
        elif authentication and isinstance(authentication, dict):
            headers.update(authentication)
        elif callable(authentication):
            headers.update(authentication(url))

        body = {}

        if limit:
            body.update({"limit": limit})

        if offset:
            body.update({"offset": offset})

        response = get(url, json=body if body else None, verify=verify, headers=headers)

        errors = []
        if response.status_code == 401:
            raise http.AuthenticationFailedException(response)
        elif response.status_code == 403:
            raise http.AccessDeniedException(response)
        elif response.status_code == 412:
            raise http.ValidationErrorException(response)
        elif response.status_code == 404:
            raise http.ObjectNotFoundException(response)

        return response.json() if json else response