"""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": 94, "limit": 869, "responseCode": 200, "count": 476, "data": [{"lastUpdatedTimestamp": 1401902639, "createdByUser": {"id": 149, "customerID": 829, "userName": "paulluna", "name": "Brandy Cunningham"}, "createdTimestamp": 1460783726, "lastUpdatedByUser": {"id": 891, "customerID": 612, "userName": "paulacox", "name": "Jeremy Hamilton"}, "ownedByUser": {"id": 261, "customerID": 702, "userName": "ewoods", "name": "Jeffrey Braun"}, "accessMode": "readRestricted", "parentElements": [{"id": 704, "name": "Amber Flynn"}], "effectiveAccessMode": "readRestricted", "currentUserAccessLevel": "folder", "elementType": "document", "name": "Jordan Contreras", "id": 912}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Loss people production prepare when lot throughout.", "messageTemplate": "Stuff step but alone across teach.", "field": "Activity election life economic.", "parameter": {}, "timestamp": 886675470}], "currentPage": 946, "size": 349}
"""
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": 299, "limit": 126, "responseCode": 200, "count": 230, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Away sit simply at establish friend magazine.", "messageTemplate": "Research prove indeed.", "field": "Box dream relationship again north trade turn.", "parameter": {}, "timestamp": 1464466352}], "currentPage": 462, "size": 884}
"""
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": 516, "limit": 483, "responseCode": 200, "count": 630, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Final mean consumer control hair hospital.", "messageTemplate": "Month particular police cover long.", "field": "Their ball field level.", "parameter": {}, "timestamp": 954592320}], "currentPage": 260, "size": 106}
"""
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": 252, "limit": 155, "responseCode": 200, "count": 275, "data": [{"id": 945, "subject": {"id": 959, "customerID": 322, "name": "Nathaniel White"}, "level": "write"}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Usually her day maintain side.", "messageTemplate": "Any college factor occur.", "field": "Everybody value benefit pay vote television question focus.", "parameter": {}, "timestamp": 1208617922}], "currentPage": 162, "size": 714}
"""
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": 3, "limit": 34, "responseCode": 200, "count": 110, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Member far coach any soon wife year.", "messageTemplate": "Right character size explain.", "field": "Miss artist task money bill.", "parameter": {}, "timestamp": 1392423198}], "currentPage": 174, "size": 51}
"""
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": 260, "limit": 400, "responseCode": 200, "count": 782, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Side page quality perform network.", "messageTemplate": "Black end check woman within.", "field": "South level wrong talk suffer the along.", "parameter": {}, "timestamp": 1471275194}], "currentPage": 711, "size": 133}
"""
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": 376, "limit": 700, "responseCode": 200, "count": 498, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Big sit home consumer such music.", "messageTemplate": "Film fine least particularly firm.", "field": "Growth career answer against.", "parameter": {}, "timestamp": 469471729}], "currentPage": 703, "size": 370}
"""
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": 531, "limit": 527, "responseCode": 200, "count": 485, "data": [{"lastUpdatedTimestamp": 1141083799, "createdByUser": {"id": 165, "customerID": 799, "userName": "simmonsjoseph", "name": "Matthew Phillips"}, "createdTimestamp": 953267665, "lastUpdatedByUser": {"id": 225, "customerID": 228, "userName": "bradleytaylor", "name": "Jeffrey Horn"}, "ownedByUser": {"id": 475, "customerID": 602, "userName": "solomonjamie", "name": "Perry Benjamin"}, "accessMode": "explicit", "parentElements": [{"id": 73, "name": "Joyce Lee"}], "effectiveAccessMode": "readRestricted", "currentUserAccessLevel": "write", "elementType": "document", "name": "Kelly Davidson", "id": 722}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Call hand force top mention prove source.", "messageTemplate": "Various chance hospital decision interest road send.", "field": "Enter chance hotel read how.", "parameter": {}, "timestamp": 1313694743}], "currentPage": 432, "size": 249}
"""
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": 721, "limit": 907, "responseCode": 200, "count": 175, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Customer specific question clearly.", "messageTemplate": "Employee age morning international wait find.", "field": "However upon visit change add offer.", "parameter": {}, "timestamp": 459520920}], "currentPage": 930, "size": 563}
"""
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": 956, "limit": 345, "responseCode": 200, "count": 13, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Agreement radio fund than.", "messageTemplate": "May difficult city story task consumer.", "field": "Require usually do.", "parameter": {}, "timestamp": 541212748}], "currentPage": 190, "size": 627}
"""
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