"""Autogenerated API"""
import requests
from argus_cli.plugin import register_command
[docs]@register_command(extending=('documents','v1','folder','root'))
def get_current_user_root_folder(limit: int = 25, offset: int = 0,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Fetch root folder for the customers that current user has access to (PUBLIC)
If the current user has access to a single customer it returns the content of that customer's root folder, otherwise it returns the list of root folders for each customer, without a content.
: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": 674, "limit": 155, "responseCode": 200, "count": 641, "data": [{"lastUpdatedTimestamp": 147902220, "createdByUser": {"id": 298, "customerID": 841, "userName": "davidshannon", "name": "James Lynch"}, "createdTimestamp": 804738582, "lastUpdatedByUser": {"id": 386, "customerID": 406, "userName": "guerreroangela", "name": "Patricia Robinson"}, "ownedByUser": {"id": 241, "customerID": 192, "userName": "sperez", "name": "Rebecca Brown"}, "accessMode": "roleBased", "parentElements": [{"id": 66, "name": "Adam Short"}], "effectiveAccessMode": "writeRestricted", "currentUserAccessLevel": "folder", "elementType": "document", "name": "Mr. Justin Christian", "id": 375}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Right within might popular.", "messageTemplate": "Him prove themselves hear.", "field": "Up mind newspaper bank care stock name four.", "parameter": {}, "timestamp": 434668775}], "currentPage": 926, "size": 650}
"""
from requests import get
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/documents/v1/folder/root".format()
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
[docs]@register_command(extending=('documents','v1','folder','root'))
def update_folder(folderID: int, name: str = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Update specified folder (PUBLIC)
:param int folderID: ID of folder to update
:param str name: If set change folder name => Sanitize by regex [a-zA-Z0-9ÅåØøÆæ_\-\. ]*
:raises AuthenticationFailedException: on 401
:raises ValidationFailedException: on 412
:raises AccessDeniedException: on 403
:raises ObjectNotFoundException: on 404
:returns: {"offset": 111, "limit": 451, "responseCode": 200, "count": 831, "metaData": {"additionalProperties": {}}, "messages": [{"message": "More personal of skill.", "messageTemplate": "Sing direction position project morning.", "field": "Compare box already hair get maybe involve.", "parameter": {}, "timestamp": 854976512}], "currentPage": 835, "size": 118}
"""
from requests import put
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/documents/v1/folder/{folderID}".format(folderID=folderID)
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 name:
body.update({"name": name})
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
[docs]@register_command(extending=('documents','v1','folder','root'))
def delete_folder(folderID: int, cascadeDocumentID: list = None, mode: str = 'DELETE_IF_EMPTY',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Delete specified folder, possibly recursively discarding contained documents (PUBLIC)
If folder contains undeleted documents, the mode must be DELETE_CASCADE_ALL or DELETE_CASCADE_LISTED_DOCUMENTS with a list of documents to delete. If mode is DELETE_IF_EMPTY (default) and folder contains undeleted documents, the request will fail with a 409 CONFLICT and a metadata key 'documentID' listing documents which are not deleted.
:param int folderID: ID of folder to delete
:param list cascadeDocumentID: List with IDs of documents which can be discarded (with mode DELETE_CASCADE_LISTED_DOCUMENTS)
:param str mode: Recursive folder delete strategy, default is DELETE_IF_EMPTY
:raises AuthenticationFailedException: on 401
:raises ValidationFailedException: on 412
:raises Exception: on 423
:raises AccessDeniedException: on 403
:raises ObjectNotFoundException: on 404
:raises Exception: on 409
:returns: {"offset": 931, "limit": 531, "responseCode": 200, "count": 271, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Me citizen hospital already policy blood player performance.", "messageTemplate": "Ball those something front plant.", "field": "Indicate same whatever oil environmental level newspaper.", "parameter": {}, "timestamp": 360956717}], "currentPage": 189, "size": 534}
"""
from requests import delete
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/documents/v1/folder/{folderID}".format(folderID=folderID)
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 cascadeDocumentID:
body.update({"cascadeDocumentID": cascadeDocumentID})
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
[docs]@register_command(extending=('documents','v1','folder','root'))
def list_folder_access(folderID: int, offset: int = 0, limit: int = 25,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Fetch ACL for specified folder (PUBLIC)
:param int folderID: Folder 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": 835, "limit": 15, "responseCode": 200, "count": 909, "data": [{"id": 314, "subject": {"id": 979, "customerID": 525, "name": "Angela Walter"}, "level": "folder"}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Laugh reality page risk occur same.", "messageTemplate": "See stuff city production coach.", "field": "Community send region wife one it firm.", "parameter": {}, "timestamp": 462542891}], "currentPage": 352, "size": 268}
"""
from requests import get
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/documents/v1/folder/{folderID}/access".format(folderID=folderID)
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
[docs]@register_command(extending=('documents','v1','folder','root'))
def grant_folder_access(folderID: int, subjectID: int = None, level: str = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Grant access to specified folder (PUBLIC)
If the access level is folder, the user is allowed to obtain the information about the folder (without folder content). If the access level is read, the user is allowed to obtain the content of the folder. If the access level is write, the user is allowed to update the folder.
:param int folderID: Folder 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": 11, "limit": 658, "responseCode": 200, "count": 360, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Take threat win act those site ago.", "messageTemplate": "Exist wind compare note.", "field": "Director reality street set out.", "parameter": {}, "timestamp": 1349023726}], "currentPage": 249, "size": 428}
"""
from requests import post
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/documents/v1/folder/{folderID}/access".format(folderID=folderID)
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
[docs]@register_command(extending=('documents','v1','folder','root'))
def update_document_access_settings(folderID: int, accessMode: str = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Change access settings on specified folder (PUBLIC)
If the access mode is roleBased, user accessing the folder must have appropriate role, set by administrator. If the access mode is writeRestricted, user accessing the folder can read, but must have appropriate role for write, set by administrator. If the access mode is readRestricted, user accessing the folder must have appropriate roles for both read and write, set by administrator. If the access mode is explicit, user accessing the folder must have explicit grant by folder's owner.
:param int folderID: Folder 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": 512, "limit": 921, "responseCode": 200, "count": 281, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Always experience assume spring might.", "messageTemplate": "Member identify top right product magazine.", "field": "Box pattern even policy resource thought economy finally.", "parameter": {}, "timestamp": 411083450}], "currentPage": 163, "size": 243}
"""
from requests import put
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/documents/v1/folder/{folderID}/access".format(folderID=folderID)
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
[docs]@register_command(extending=('documents','v1','folder','root'))
def revoke_folder_access(folderID: int, accessID: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Revoke specified explicit access from folder (PUBLIC)
:param int folderID: Folder ID
:param int accessID: Access ID
:raises AuthenticationFailedException: on 401
:raises ValidationFailedException: on 412
:raises AccessDeniedException: on 403
:raises ObjectNotFoundException: on 404
:returns: {"offset": 737, "limit": 870, "responseCode": 200, "count": 729, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Gas save begin time get.", "messageTemplate": "Hit sometimes laugh smile.", "field": "Half three itself record hair focus life.", "parameter": {}, "timestamp": 178112672}], "currentPage": 570, "size": 74}
"""
from requests import delete
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/documents/v1/folder/{folderID}/access/{accessID}".format(folderID=folderID, 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
[docs]@register_command(extending=('documents','v1','folder','root'))
def browse_folder(folderID: int, limit: int = 25, offset: int = 0,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Fetch specified folder entries (PUBLIC)
:param int folderID: ID of folder to browse
: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 FolderNotFoundException: on 404
:returns: {"offset": 351, "limit": 448, "responseCode": 200, "count": 241, "data": [{"lastUpdatedTimestamp": 1048170734, "createdByUser": {"id": 494, "customerID": 557, "userName": "taramoore", "name": "James Jackson"}, "createdTimestamp": 436453650, "lastUpdatedByUser": {"id": 130, "customerID": 850, "userName": "edwardserrano", "name": "Molly Williams"}, "ownedByUser": {"id": 598, "customerID": 321, "userName": "linda62", "name": "Lauren Lee"}, "accessMode": "writeRestricted", "parentElements": [{"id": 711, "name": "Andrew Olson"}], "effectiveAccessMode": "writeRestricted", "currentUserAccessLevel": "read", "elementType": "document", "name": "Jonathan Jimenez", "id": 267}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Three choose drop cell clearly professional back really.", "messageTemplate": "Painting project along force open sign woman.", "field": "Opportunity statement vote thank than pull sure.", "parameter": {}, "timestamp": 210084756}], "currentPage": 596, "size": 660}
"""
from requests import get
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/documents/v1/folder/{folderID}/content".format(folderID=folderID)
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
[docs]@register_command(extending=('documents','v1','folder','root'))
def add_document(folderID: int, name: str = None, data: str = None, text: str = None, mimeType: str = None, accessMode: str = 'roleBased', lockRequestTime: int = 300000, inheritExplicitPermissions: bool = 'True',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Create a new document (PUBLIC)
In order to create plain text document, use 'text' property and send text. Otherwise use 'data' property populated with base64 encoded representation of the document. Sending the both parameters will result in error.
:param int folderID: Parent folder ID
:param str name: Name of new document => Sanitize by regex [a-zA-Z0-9ÅåØøÆæ_\-\. ]*
:param str data: Base64 encoded document content formatted according to the given MIME type. It is required if 'text' parameter is not defined
:param str text: Plain text document content. It is required if the 'data' parameter is not defined
:param str mimeType: MIME type of document content
:param str accessMode: General access mode of new document (default roleBased)
:param int lockRequestTime: Specify how long the document should be locked (default 300000)
:param bool inheritExplicitPermissions: Inherit explicit permissions from parent folder (default true)
:raises AuthenticationFailedException: on 401
:raises ValidationFailedException: on 412
:raises AccessDeniedException: on 403
:raises ParentFolderNotFoundException: on 404
:returns: {"offset": 620, "limit": 603, "responseCode": 200, "count": 246, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Stop summer record husband Democrat growth.", "messageTemplate": "Say final head.", "field": "Clearly bed upon.", "parameter": {}, "timestamp": 980664928}], "currentPage": 617, "size": 630}
"""
from requests import post
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/documents/v1/folder/{folderID}/documents".format(folderID=folderID)
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})
if lockRequestTime:
body.update({"lockRequestTime": lockRequestTime})
if inheritExplicitPermissions:
body.update({"inheritExplicitPermissions": inheritExplicitPermissions})
if name:
body.update({"name": name})
if data:
body.update({"data": data})
if text:
body.update({"text": text})
if mimeType:
body.update({"mimeType": mimeType})
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
[docs]@register_command(extending=('documents','v1','folder','root'))
def add_folder(parentID: int, name: str = None, accessMode: str = 'roleBased', inheritExplicitPermissions: bool = 'True',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Create a new subfolder (PUBLIC)
:param int parentID: ID of parent folder
:param str name: Name of new folder => Sanitize by regex [a-zA-Z0-9ÅåØøÆæ_\-\. ]*
:param str accessMode: General access mode of new folder (default roleBased)
:param bool inheritExplicitPermissions: Inherit explicit permissions from parent folder (default true)
:raises AuthenticationFailedException: on 401
:raises ValidationFailedException: on 412
:raises AccessDeniedException: on 403
:raises ParentFolderNotFoundException: on 404
:returns: {"offset": 590, "limit": 891, "responseCode": 200, "count": 541, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Ago happy animal.", "messageTemplate": "Work seem loss weight available public.", "field": "Sell produce agree state scene.", "parameter": {}, "timestamp": 113938444}], "currentPage": 96, "size": 861}
"""
from requests import post
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/documents/v1/folder/{parentID}".format(parentID=parentID)
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})
if inheritExplicitPermissions:
body.update({"inheritExplicitPermissions": inheritExplicitPermissions})
if name:
body.update({"name": name})
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