Source code for api.alarms.v1.alarm

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


[docs]@register_command(extending=('alarms','v1','alarm')) def get_alarms(keywords: list = None, keywordField: list = None, keywordMatch: str = 'all', offset: int = 0, limit: int = 25,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Get all alarms (PUBLIC) :param list keywords: Search by keywords :param list keywordField: Set field strategy for keyword search :param str keywordMatch: Set match strategy for keyword search :param int offset: Skip a number of alarms :param int limit: Maximum number of returned alarms :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :returns: {"offset": 560, "limit": 627, "responseCode": 200, "count": 596, "data": [{"id": 98, "mappings": [{"lastUpdatedTimestamp": 1168867658, "comments": [{"timestamp": 966201729, "comment": "Skill thus offer leg determine fall back reduce."}], "mappedTimestamp": 153583951, "firstTriggeredTimestamp": 511437760, "lastTriggeredTimestamp": 235998723, "triggerAmount": 799, "signature": "Finally him tough paper political story.", "flags": ["ISS_SIGNATURE"]}], "comments": [{"timestamp": 1501611969, "comment": "Order between could tonight keep."}], "references": ["Pretty water miss specific require behind."], "labels": ["Poor large stay defense focus product."], "info": "In travel maybe policy natural.", "description": "Citizen popular pay until wide song just.", "links": ["Away often action care matter treat."], "createdByUser": {"id": 678, "customerID": 235, "userName": "pwolf", "name": "Alexa Rogers"}, "createdTimestamp": 1279744404, "lastUpdatedByUser": {"id": 622, "customerID": 223, "userName": "lgomez", "name": "Mary Smith"}, "lastUpdatedTimestamp": 720668143, "lastCheckedByUser": {"id": 964, "customerID": 45, "userName": "brownmatthew", "name": "Brian Weaver"}, "lastCheckTimestamp": 529024452, "nextCheckTimestamp": 310704273, "flags": ["DELETED"]}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Society yard cup push term.", "messageTemplate": "Identify person budget although officer least we.", "field": "Turn prove director current call technology no.", "parameter": {}, "timestamp": 515172767}], "currentPage": 123, "size": 466} """ from requests import get from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/alarms/v1/alarm".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 keywordMatch: body.update({"keywordMatch": keywordMatch}) if offset: body.update({"offset": offset}) if limit: body.update({"limit": limit}) if keywords: body.update({"keywords": keywords}) if keywordField: body.update({"keywordField": keywordField}) 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=('alarms','v1','alarm')) def search_alarms(limit: int = None, offset: int = None, subCriteria: list = None, attackCategoryID: list = None, alarmID: list = None, alarmReferences: list = None, labels: list = None, startTimestamp: int = None, endTimestamp: int = None, timeFieldStrategy: list = None, keywords: list = None, keywordFieldStrategy: list = None, signature: list = None, sortBy: list = None, includeFlags: list = None, excludeFlags: list = None, timeMatchStrategy: str = 'any', keywordMatchStrategy: str = 'all', includeDeleted: bool = 'False', exclude: bool = 'False', required: bool = 'False', includeMappings: bool = 'False', includeComments: bool = 'False',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Get all alarms 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 alarmID: A set of IDs for alarms. :param list alarmReferences: A set of references. It does an exact match. :param list labels: A set of labels. It does an exact match. :param int startTimestamp: Only include alarms based on the set TimeFieldStrategy and TimeMatchStrategy (start timestamp) :param int endTimestamp: Only include alarms based on the set TimeFieldStrategy and TimeMatchStrategy (end timestamp) :param list timeFieldStrategy: TimeFieldStrategy to define which timestamp field(s) to match. (default lastUpdatedTimestamp) :param list keywords: A set of keywords matched against alarms based on the set KeywordFieldStrategy and KeywordMatchStrategy. :param list keywordFieldStrategy: KeywordFieldStrategy to define which field(s) to match against keywords. (default all) :param list signature: A set of signatures. It does an exact match. :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 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). :param bool includeMappings: Set to include mappings in the search result. (default false) :param bool includeComments: Set to include comments in the search result. (default false) :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :returns: {"offset": 882, "limit": 114, "responseCode": 200, "count": 393, "data": [{"id": 719, "mappings": [{"lastUpdatedTimestamp": 125146401, "comments": [{"timestamp": 97224788, "comment": "Choose relate force option."}], "mappedTimestamp": 656164389, "firstTriggeredTimestamp": 247471690, "lastTriggeredTimestamp": 40291557, "triggerAmount": 684, "signature": "Process face dark let son thus.", "flags": ["DEFAULT_BLOCK"]}], "comments": [{"timestamp": 1092197088, "comment": "Create future bill finally color new."}], "references": ["Though rather buy series."], "labels": ["Sign several head their guy structure peace over."], "info": "Establish take challenge cost result whose stage.", "description": "Painting dinner mission while degree.", "links": ["Scene weight do girl."], "createdByUser": {"id": 689, "customerID": 767, "userName": "dbarnes", "name": "Sandra White"}, "createdTimestamp": 1189756469, "lastUpdatedByUser": {"id": 312, "customerID": 440, "userName": "garciabridget", "name": "Chase Norris"}, "lastUpdatedTimestamp": 564309522, "lastCheckedByUser": {"id": 487, "customerID": 510, "userName": "burgesscharles", "name": "Mary Winters"}, "lastCheckTimestamp": 1446630777, "nextCheckTimestamp": 1132984629, "flags": ["DISABLED"]}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Show opportunity least natural tax.", "messageTemplate": "Manage around out.", "field": "Forward speak if other city within.", "parameter": {}, "timestamp": 1086003361}], "currentPage": 374, "size": 88} """ from requests import post from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/alarms/v1/alarm/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 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 attackCategoryID: body.update({"attackCategoryID": attackCategoryID}) if alarmID: body.update({"alarmID": alarmID}) if alarmReferences: body.update({"alarmReferences": alarmReferences}) if labels: body.update({"labels": labels}) if includeMappings: body.update({"includeMappings": includeMappings}) if includeComments: body.update({"includeComments": includeComments}) 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 signature: body.update({"signature": signature}) 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=('alarms','v1','alarm')) def get_alarm_by_id(id: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Get alarm by Id (PUBLIC) :param int id: ID of alarm :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {"offset": 295, "limit": 904, "responseCode": 200, "count": 74, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Public enough sound take nature seek.", "messageTemplate": "Affect you sure impact buy music follow.", "field": "That if occur behind.", "parameter": {}, "timestamp": 149711893}], "currentPage": 544, "size": 574} """ from requests import get from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/alarms/v1/alarm/{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