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": 709, "limit": 208, "responseCode": 200, "count": 133, "data": [{"id": 599, "mappings": [{"lastUpdatedTimestamp": 919115033, "comments": [{"timestamp": 951788795, "comment": "Avoid within heavy scene."}], "mappedTimestamp": 1034322276, "firstTriggeredTimestamp": 744054806, "lastTriggeredTimestamp": 1103068908, "triggerAmount": 464, "signature": "Ahead hit administration pass.", "flags": ["DEFAULT_BLOCK"]}], "comments": [{"timestamp": 403296644, "comment": "Strategy season character vote project idea hand at."}], "references": ["Own evening summer have appear activity value."], "labels": ["Decide attorney look provide."], "info": "Test nature everything put push modern interesting which.", "description": "End whole wonder Mrs positive hot fear.", "links": ["Full good parent pull edge approach result article."], "createdByUser": {"id": 940, "customerID": 458, "userName": "danielsanchez", "name": "Jennifer Miles"}, "createdTimestamp": 1357973567, "lastUpdatedByUser": {"id": 690, "customerID": 857, "userName": "sean67", "name": "Lauren Sanchez"}, "lastUpdatedTimestamp": 722404927, "lastCheckedByUser": {"id": 116, "customerID": 598, "userName": "vwong", "name": "Melissa Stuart"}, "lastCheckTimestamp": 633311272, "nextCheckTimestamp": 48376418, "flags": ["DELETED"]}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Authority future trouble society one whether seek wear.", "messageTemplate": "Magazine board may never process.", "field": "Mr indeed often modern piece especially.", "parameter": {}, "timestamp": 451205394}], "currentPage": 164, "size": 660} """ from requests import get from argus_api.exceptions import http url = "https://portal.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": 405, "limit": 812, "responseCode": 200, "count": 442, "data": [{"id": 659, "mappings": [{"lastUpdatedTimestamp": 410960231, "comments": [{"timestamp": 490973472, "comment": "Lay want edge."}], "mappedTimestamp": 45339727, "firstTriggeredTimestamp": 120039883, "lastTriggeredTimestamp": 440912034, "triggerAmount": 976, "signature": "Author by since perhaps anything.", "flags": ["ISS_SIGNATURE"]}], "comments": [{"timestamp": 470654339, "comment": "Thing rock success arrive spring."}], "references": ["Black guess this subject difficult between fast."], "labels": ["Its read city on."], "info": "Affect white back company never.", "description": "Beautiful material but.", "links": ["Stop card minute western market election establish could."], "createdByUser": {"id": 407, "customerID": 819, "userName": "bradleyjessica", "name": "Kayla Hammond"}, "createdTimestamp": 531340933, "lastUpdatedByUser": {"id": 304, "customerID": 790, "userName": "mark59", "name": "Ryan Parker"}, "lastUpdatedTimestamp": 257399928, "lastCheckedByUser": {"id": 988, "customerID": 778, "userName": "lisahaynes", "name": "James Jackson"}, "lastCheckTimestamp": 1470981360, "nextCheckTimestamp": 488594932, "flags": ["DISABLED"]}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Population all young get believe interview.", "messageTemplate": "Figure couple more goal near discussion.", "field": "Build machine senior hour represent personal ask.", "parameter": {}, "timestamp": 846439441}], "currentPage": 644, "size": 368} """ from requests import post from argus_api.exceptions import http url = "https://portal.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": 460, "limit": 451, "responseCode": 200, "count": 401, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Store behind before ready show marriage situation.", "messageTemplate": "Company entire morning family main meet material.", "field": "Pattern above anyone ability.", "parameter": {}, "timestamp": 337797720}], "currentPage": 51, "size": 602} """ from requests import get from argus_api.exceptions import http url = "https://portal.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