Source code for api.alarms.v1.category

"""Autogenerated API"""

from argus_cli.plugin import register_command



[docs]@register_command(extending=("alarms","v1","category")) def get_categories( keywords: list = None, keywordField: list = None, offset: int = None, limit: int = 25, keywordMatch: str = "all", json: bool = True, verify: bool = True, apiKey: str = None, authentication: dict = {} ) -> dict: """Get all categories (PUBLIC) :param list keywords: Filter categories by keywords :param list keywordField: Set field strategy for keyword search :param int offset: Skip a number of categories :param int limit: Maximum number of returned categories :param str keywordMatch: Set match strategy for keyword search :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :returns: {'offset': 253, 'limit': 945, 'responseCode': 200, 'count': 970, 'data': [{'id': 558, 'info': 'Help because board stop.', 'name': 'Tanya Cohen', 'flags': ['DELETED']}], 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Again citizen whatever project season movie house place.', 'messageTemplate': 'Paper nothing alone white if.', 'field': 'Family anything knowledge clearly anything institution half head.', 'parameter': {}, 'timestamp': 414432778}], 'currentPage': 77, 'size': 522} """ from requests import get from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/alarms/v1/category".format() headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = { "offset": offset, "limit": limit, "keywordMatch": keywordMatch, "keywords": keywords, "keywordField": keywordField } response = get(url, json=body if body else None, verify=verify, headers=headers ) 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=("alarms","v1","category")) def search_categories( limit: int = None, offset: int = None, subCriteria: list = None, attackCategoryID: list = None, keywords: list = None, keywordFieldStrategy: list = None, sortBy: list = None, includeFlags: list = None, excludeFlags: list = None, keywordMatchStrategy: str = "all", includeDeleted: bool = None, exclude: bool = None, required: bool = None, json: bool = True, verify: bool = True, apiKey: str = None, authentication: dict = {} ) -> dict: """Get all categories matching a given search criteria (PUBLIC) :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 attackCategoryID: A set of IDs for attack categories (alarm category). :param list keywords: A set of keywords matched against categories based on the set KeywordFieldStrategy and KeywordMatchStrategy. :param list keywordFieldStrategy: KeywordFieldStrategy to define which field(s) to match against keywords. (default all) :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 keywordMatchStrategy: KeywordMatchStrategy to define how to match keywords with fields. (default all) :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 ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :returns: {'offset': 561, 'limit': 4, 'responseCode': 200, 'count': 467, 'data': [{'id': 949, 'info': 'Most boy detail senior huge much bit.', 'name': 'Andrew Morgan', 'flags': ['DELETED']}], 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Exactly the direction animal question during activity.', 'messageTemplate': 'Drive particularly water into word enough.', 'field': 'Especially environment without parent on.', 'parameter': {}, 'timestamp': 120208669}], 'currentPage': 325, 'size': 762} """ from requests import post from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/alarms/v1/category/search".format() headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/' } if apiKey: headers["Argus-API-Key"] = apiKey elif authentication and isinstance(authentication, dict): headers.update(authentication) elif callable(authentication): headers.update(authentication(url)) body = { "keywordMatchStrategy": keywordMatchStrategy, "limit": limit, "offset": offset, "includeDeleted": includeDeleted, "subCriteria": subCriteria, "exclude": exclude, "required": required, "attackCategoryID": attackCategoryID, "keywords": keywords, "keywordFieldStrategy": keywordFieldStrategy, "sortBy": sortBy, "includeFlags": includeFlags, "excludeFlags": excludeFlags } response = post(url, json=body if body else None, verify=verify, headers=headers ) 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=("alarms","v1","category")) def get_category_by_id( id: int, json: bool = True, verify: bool = True, apiKey: str = None, authentication: dict = {} ) -> dict: """Get category by Id (PUBLIC) :param int id: ID of category :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {'offset': 434, 'limit': 23, 'responseCode': 200, 'count': 955, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Amount tree by series.', 'messageTemplate': 'Though despite person best.', 'field': 'Chance example course information to class.', 'parameter': {}, 'timestamp': 749478214}], 'currentPage': 845, 'size': 624} """ from requests import get from argus_api.exceptions import http url = "https://portal.mnemonic.no/web/api/alarms/v1/category/{id}".format(id=id) headers = { 'Content-Type': 'application/json', 'User-Agent': 'ArgusToolbelt/' } 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 ) 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