Source code for api.reports.v1.template

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


[docs]@register_command(extending=('reports','v1','template')) def list_templates(offset: int = None, customerID: list = None, limit: int = 25,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """List report templates (DEV) Returns a list of matching report templates. :param int offset: Offset result :param list customerID: Limit results to templates with specified customer ID :param int limit: Limit output :raises AuthenticationFailedException: on 401 :raises ValidationFailedException: on 412 :raises AccessDeniedException: on 403 :returns: {"offset": 411, "limit": 554, "responseCode": 200, "count": 162, "data": [{"id": 536, "state": "approved", "accessMode": "explicit", "effectiveAccessMode": "readRestricted", "currentUserAccessLevel": "folder", "name": "Karen Oneal", "masterID": 716, "revision": 731, "createdTimestamp": 249959246, "createdByUser": {"id": 66, "customerID": 98, "userName": "donaldmoore", "name": "Jennifer Saunders"}, "lastUpdatedTimestamp": 867925599, "lastUpdatedByUser": {"id": 460, "customerID": 140, "userName": "stephenwilson", "name": "Penny Myers"}, "publishedTimestamp": 707228481, "publishDueTimestamp": 235461598, "lockedUntilTimestamp": 1423091065, "ownedByUser": {"id": 986, "customerID": 913, "userName": "christopher53", "name": "James Perez"}, "lockedByUser": {"id": 29, "customerID": 667, "userName": "jonathanmendoza", "name": "Wendy Smith"}, "publishedByUser": {"id": 812, "customerID": 271, "userName": "holly19", "name": "Devin Smith"}, "mimeType": "Center bar address floor movement probably.", "dataSize": 806, "labels": ["Particularly note role table see key."], "parentElements": [{"id": 118, "name": "Joshua Hatfield"}], "documentType": "report", "elementType": "document", "flags": ["ATTACHMENT"]}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Head drop minute within similar population eight.", "messageTemplate": "Father task history yes church every figure.", "field": "Although hit bad as sing company suggest.", "parameter": {}, "timestamp": 1350421696}], "currentPage": 112, "size": 818} """ from requests import get from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/reports/v1/template".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}) if customerID: body.update({"customerID": customerID}) 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=('reports','v1','template')) def add(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: """Add a report template (DEV) :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 :returns: {"offset": 462, "limit": 249, "responseCode": 200, "count": 979, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Act rule form sit.", "messageTemplate": "Security citizen cover area scene need network.", "field": "Well forward help medical order none pattern.", "parameter": {}, "timestamp": 1452116626}], "currentPage": 49, "size": 811} """ from requests import post from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/reports/v1/template".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 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=('reports','v1','template')) def search_templates(limit: int = None, offset: int = None, subCriteria: list = None, customerID: list = None, id: list = None, userID: list = None, userFieldStrategy: list = None, accessMode: list = None, state: list = None, startTimestamp: int = None, endTimestamp: int = None, timeFieldStrategy: list = None, keywords: list = None, keywordFieldStrategy: list = None, labels: list = None, folderID: list = None, sortBy: list = None, includeFlags: list = None, excludeFlags: list = None, timeMatchStrategy: str = 'any', keywordMatchStrategy: str = 'any', recursive: bool = 'True', includeDeleted: bool = 'False', exclude: bool = 'False', required: bool = 'False',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Search report templates (DEV) Returns a list of matching report templates. :param int limit: Set this value to set max number of results. By default, no restriction on result set size. :param int offset: Set this value to skip the first (offset) objects. By default, return result from first object. :param list subCriteria: :param list customerID: Restrict search to data belonging to specified customers. :param list id: ID of documents to match :param list userID: Restrict search to documents associated with any of these users. :param list userFieldStrategy: Defines which user fields will be used for searching for documents associated to userID field. (default all) :param list accessMode: Match these access modes :param list state: The status of the documents to match :param int startTimestamp: Start of time search period :param int endTimestamp: End of time search period :param list timeFieldStrategy: TimeFieldStrategy to define which timestamp field(s) to match. (default createdTimestamp) :param list keywords: A set of keywords matched against documents based on the set KeywordFieldStrategy and KeywordMatchStrategy. :param list keywordFieldStrategy: KeywordFieldStrategy to define which document field(s) to match. (default all) :param list labels: Match documents with any of these labels :param list folderID: Search for documents within any of these folders. Use folderID=0 to search root folders. :param list sortBy: List of properties to sort by (prefix with "-" to sort descending). :param list includeFlags: Only include objects which have includeFlags set. :param list excludeFlags: Exclude objects which have excludeFlags set. :param str timeMatchStrategy: TimeMatchStrategy to define how to match startTimestamp and endTimestamp with fields. (default any) :param str keywordMatchStrategy: KeywordMatchStrategy to define how to match keywords with fields. (default any) :param bool recursive: Search all subfolders below selected folders (default true) :param bool includeDeleted: Set to true to include deleted objects. By default, exclude deleted objects. :param bool exclude: Only relevant for subcriteria. If set to true, objects matching this subcriteria object will be excluded. :param bool required: Only relevant for subcriteria. If set to true, objects matching this subcriteria are required (AND-ed together with parent criteria). :raises AuthenticationFailedException: on 401 :raises ValidationFailedException: on 412 :raises AccessDeniedException: on 403 :returns: {"offset": 232, "limit": 585, "responseCode": 200, "count": 870, "data": [{"id": 26, "state": "qa", "accessMode": "explicit", "effectiveAccessMode": "roleBased", "currentUserAccessLevel": "folder", "name": "Karen Casey", "masterID": 965, "revision": 893, "createdTimestamp": 1214186849, "createdByUser": {"id": 637, "customerID": 303, "userName": "anthony60", "name": "Dana Green"}, "lastUpdatedTimestamp": 1467179419, "lastUpdatedByUser": {"id": 730, "customerID": 902, "userName": "vanessamurphy", "name": "Eric Miles"}, "publishedTimestamp": 823081104, "publishDueTimestamp": 587409147, "lockedUntilTimestamp": 199223250, "ownedByUser": {"id": 913, "customerID": 239, "userName": "rwalls", "name": "Luke Boyd"}, "lockedByUser": {"id": 160, "customerID": 382, "userName": "masonjessica", "name": "Shannon Johnson"}, "publishedByUser": {"id": 827, "customerID": 711, "userName": "perezjacqueline", "name": "Beth Jackson"}, "mimeType": "Develop almost eight could.", "dataSize": 135, "labels": ["Expert north parent beyond argue knowledge I movement."], "parentElements": [{"id": 871, "name": "Heather Little"}], "documentType": "report", "elementType": "folder", "flags": ["CONTROLLED_VERSION"]}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Child form service send main assume say.", "messageTemplate": "Another huge result exist serve.", "field": "Visit recognize small prove fact.", "parameter": {}, "timestamp": 1268563978}], "currentPage": 648, "size": 442} """ from requests import post from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/reports/v1/template/search".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 timeMatchStrategy: body.update({"timeMatchStrategy": timeMatchStrategy}) if keywordMatchStrategy: body.update({"keywordMatchStrategy": keywordMatchStrategy}) if recursive: body.update({"recursive": recursive}) if limit: body.update({"limit": limit}) if offset: body.update({"offset": offset}) if includeDeleted: body.update({"includeDeleted": includeDeleted}) if subCriteria: body.update({"subCriteria": subCriteria}) if exclude: body.update({"exclude": exclude}) if required: body.update({"required": required}) if customerID: body.update({"customerID": customerID}) if id: body.update({"id": id}) if userID: body.update({"userID": userID}) if userFieldStrategy: body.update({"userFieldStrategy": userFieldStrategy}) if accessMode: body.update({"accessMode": accessMode}) if state: body.update({"state": state}) if startTimestamp: body.update({"startTimestamp": startTimestamp}) if endTimestamp: body.update({"endTimestamp": endTimestamp}) if timeFieldStrategy: body.update({"timeFieldStrategy": timeFieldStrategy}) if keywords: body.update({"keywords": keywords}) if keywordFieldStrategy: body.update({"keywordFieldStrategy": keywordFieldStrategy}) if labels: body.update({"labels": labels}) if folderID: body.update({"folderID": folderID}) if sortBy: body.update({"sortBy": sortBy}) if includeFlags: body.update({"includeFlags": includeFlags}) if excludeFlags: body.update({"excludeFlags": excludeFlags}) 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=('reports','v1','template')) def get_template(id: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Fetch report template (DEV) Returns the specified report template :param int id: :raises AuthenticationFailedException: on 401 :raises ValidationFailedException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {"offset": 205, "limit": 525, "responseCode": 200, "count": 863, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Base its prevent itself.", "messageTemplate": "Night until skill together son.", "field": "Develop art must citizen town voice.", "parameter": {}, "timestamp": 1139647522}], "currentPage": 191, "size": 210} """ from requests import get from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/reports/v1/template/{id}".format(id=id) 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
[docs]@register_command(extending=('reports','v1','template')) def update(id: 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 a report template (DEV) :param int id: ID of template 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 AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {"offset": 633, "limit": 468, "responseCode": 200, "count": 175, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Dream himself end she.", "messageTemplate": "Rather ability again energy wind memory interview.", "field": "Assume establish significant course woman.", "parameter": {}, "timestamp": 1076660174}], "currentPage": 812, "size": 609} """ from requests import put from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/reports/v1/template/{id}".format(id=id) 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