"""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": 44, "limit": 498, "responseCode": 200, "count": 355, "data": [{"parentElements": [{"id": 966, "name": "Gary Mcclain"}], "effectiveAccessMode": "writeRestricted", "currentUserAccessLevel": "folder", "lastUpdatedTimestamp": 65204796, "createdByUser": {"id": 992, "customerID": 201, "userName": "morganbruce", "name": "Crystal Campbell"}, "createdTimestamp": 650547216, "lastUpdatedByUser": {"id": 839, "customerID": 896, "userName": "lclark", "name": "Leslie Williams"}, "ownedByUser": {"id": 461, "customerID": 495, "userName": "longmitchell", "name": "Dustin Hale"}, "accessMode": "readRestricted", "elementType": "folder", "name": "Stephen Gonzales", "id": 817}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "At modern professional serve.", "messageTemplate": "Day time able white group way least effort.", "field": "Customer end turn drug tough no support.", "parameter": {}, "timestamp": 142739859}], "currentPage": 860, "size": 43}
"""
from requests import get
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 710, "limit": 311, "responseCode": 200, "count": 2, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Magazine pick degree right.", "messageTemplate": "Role why effort at majority wind structure.", "field": "Member quickly result anything our always.", "parameter": {}, "timestamp": 195192902}], "currentPage": 262, "size": 707}
"""
from requests import put
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 823, "limit": 688, "responseCode": 200, "count": 578, "metaData": {"additionalProperties": {}}, "messages": [{"message": "May different imagine how chair few.", "messageTemplate": "Budget born provide skill.", "field": "Even item development I travel why degree walk.", "parameter": {}, "timestamp": 1279314325}], "currentPage": 494, "size": 729}
"""
from requests import delete
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 580, "limit": 430, "responseCode": 200, "count": 971, "data": [{"id": 942, "subject": {"id": 82, "customerID": 171, "name": "Scott Ellis"}, "level": "write"}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Short gas style.", "messageTemplate": "Interesting reduce chair determine miss away.", "field": "Take myself protect inside.", "parameter": {}, "timestamp": 1153732623}], "currentPage": 374, "size": 152}
"""
from requests import get
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 361, "limit": 801, "responseCode": 200, "count": 643, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Show history suddenly professional away represent perhaps.", "messageTemplate": "Pattern recently current this land help into.", "field": "Operation single boy decade reflect interview.", "parameter": {}, "timestamp": 1064429822}], "currentPage": 935, "size": 816}
"""
from requests import post
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 744, "limit": 927, "responseCode": 200, "count": 407, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Song product cut skin campaign wide get.", "messageTemplate": "Happen pick save join never likely.", "field": "Area human once college sign.", "parameter": {}, "timestamp": 1211423714}], "currentPage": 973, "size": 417}
"""
from requests import put
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 978, "limit": 895, "responseCode": 200, "count": 261, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Make situation trial fill resource.", "messageTemplate": "Carry behavior development low girl laugh decide check.", "field": "At natural team race character environment away.", "parameter": {}, "timestamp": 130265149}], "currentPage": 323, "size": 168}
"""
from requests import delete
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 781, "limit": 60, "responseCode": 200, "count": 924, "data": [{"parentElements": [{"id": 310, "name": "John Vasquez"}], "effectiveAccessMode": "roleBased", "currentUserAccessLevel": "folder", "lastUpdatedTimestamp": 736282983, "createdByUser": {"id": 705, "customerID": 989, "userName": "jamestorres", "name": "Danielle Hendrix"}, "createdTimestamp": 503509156, "lastUpdatedByUser": {"id": 544, "customerID": 868, "userName": "diana52", "name": "Kimberly Blevins"}, "ownedByUser": {"id": 362, "customerID": 705, "userName": "icarr", "name": "Wayne Henderson"}, "accessMode": "roleBased", "elementType": "document", "name": "Angel Day", "id": 447}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Occur me world image test site.", "messageTemplate": "Lot even threat assume improve range whether.", "field": "Stock assume prevent defense election.", "parameter": {}, "timestamp": 970402464}], "currentPage": 65, "size": 176}
"""
from requests import get
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 272, "limit": 205, "responseCode": 200, "count": 444, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Feeling enough newspaper despite.", "messageTemplate": "Win step good short.", "field": "Page why paper.", "parameter": {}, "timestamp": 1102676384}], "currentPage": 508, "size": 967}
"""
from requests import post
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 27, "limit": 608, "responseCode": 200, "count": 51, "metaData": {"additionalProperties": {}}, "messages": [{"message": "About world others hot.", "messageTemplate": "Late against until money show.", "field": "Lay shake when plant my animal mean deal.", "parameter": {}, "timestamp": 133120927}], "currentPage": 115, "size": 10}
"""
from requests import post
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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