"""Autogenerated API"""
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 = None,
limit: int = 25,
json: bool = True,
verify: bool = True,
apiKey: str = None,
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': 563, 'limit': 950, 'responseCode': 200, 'count': 847, 'data': [{'id': 604, 'mappings': [{'lastUpdatedTimestamp': 972701567, 'comments': [{'timestamp': 1372528008, 'comment': 'Capital between now describe town make.'}], 'mappedTimestamp': 1027950597, 'firstTriggeredTimestamp': 1024690292, 'lastTriggeredTimestamp': 929672160, 'triggerAmount': 577, 'signature': 'Give impact compare amount.', 'flags': ['DELETED']}], 'comments': [{'timestamp': 1309345056, 'comment': 'Quickly least treatment impact letter.'}], 'references': ['Company customer face every condition.'], 'labels': ['Allow building billion see.'], 'info': 'Sense international cover necessary hotel left statement.', 'description': 'Home pay body sister media member.', 'links': ['Appear fund his agent.'], 'createdByUser': {'id': 927, 'customerID': 146, 'userName': 'robert14', 'name': 'Stephen Barton'}, 'createdTimestamp': 862191237, 'lastUpdatedByUser': {'id': 710, 'customerID': 612, 'userName': 'rebecca56', 'name': 'Robert Daugherty'}, 'lastUpdatedTimestamp': 870099623, 'lastCheckedByUser': {'id': 912, 'customerID': 184, 'userName': 'karenhaney', 'name': 'Devin Mcneil'}, 'lastCheckTimestamp': 630503804, 'nextCheckTimestamp': 1164731268, 'flags': ['DELETED']}], 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Position reality real.', 'messageTemplate': 'Concern trade ok talk thus.', 'field': 'Source detail speech energy citizen owner cell.', 'parameter': {}, 'timestamp': 1457646060}], 'currentPage': 565, 'size': 847}
"""
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/'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {
"keywordMatch": keywordMatch,
"offset": offset,
"limit": limit,
"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","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 = None,
exclude: bool = None,
required: bool = None,
includeMappings: bool = None,
includeComments: bool = None,
json: bool = True,
verify: bool = True,
apiKey: str = None,
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': 675, 'limit': 171, 'responseCode': 200, 'count': 846, 'data': [{'id': 837, 'mappings': [{'lastUpdatedTimestamp': 141869288, 'comments': [{'timestamp': 942797836, 'comment': 'Artist collection out me.'}], 'mappedTimestamp': 645901664, 'firstTriggeredTimestamp': 1497557799, 'lastTriggeredTimestamp': 814742113, 'triggerAmount': 602, 'signature': 'Approach hot modern indicate.', 'flags': ['DELETED']}], 'comments': [{'timestamp': 387206257, 'comment': 'Whole off place student.'}], 'references': ['Trade all hot moment.'], 'labels': ['Else stand election budget.'], 'info': 'Measure central improve continue daughter democratic.', 'description': 'Campaign miss culture everybody key if example consider.', 'links': ['Very attack to camera also.'], 'createdByUser': {'id': 935, 'customerID': 687, 'userName': 'cardenasveronica', 'name': 'Jeffrey Gardner'}, 'createdTimestamp': 980172360, 'lastUpdatedByUser': {'id': 762, 'customerID': 209, 'userName': 'emily27', 'name': 'Megan Morris'}, 'lastUpdatedTimestamp': 91266829, 'lastCheckedByUser': {'id': 39, 'customerID': 836, 'userName': 'turneramanda', 'name': 'Steven Frank'}, 'lastCheckTimestamp': 1208333868, 'nextCheckTimestamp': 501946315, 'flags': ['DELETED']}], 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'Say wait instead save town low.', 'messageTemplate': 'Meeting attack real.', 'field': 'Option role during call home product.', 'parameter': {}, 'timestamp': 1300717810}], 'currentPage': 211, 'size': 570}
"""
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/'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {
"timeMatchStrategy": timeMatchStrategy,
"keywordMatchStrategy": keywordMatchStrategy,
"limit": limit,
"offset": offset,
"includeDeleted": includeDeleted,
"subCriteria": subCriteria,
"exclude": exclude,
"required": required,
"attackCategoryID": attackCategoryID,
"alarmID": alarmID,
"alarmReferences": alarmReferences,
"labels": labels,
"includeMappings": includeMappings,
"includeComments": includeComments,
"startTimestamp": startTimestamp,
"endTimestamp": endTimestamp,
"timeFieldStrategy": timeFieldStrategy,
"keywords": keywords,
"keywordFieldStrategy": keywordFieldStrategy,
"signature": signature,
"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","alarm"))
def get_alarm_by_id(
id: int,
json: bool = True,
verify: bool = True,
apiKey: str = None,
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': 123, 'limit': 683, 'responseCode': 200, 'count': 784, 'metaData': {'additionalProperties': {}}, 'messages': [{'message': 'As hear happen bit.', 'messageTemplate': 'Evening break science whom middle what keep allow.', 'field': 'More responsibility account stuff surface.', 'parameter': {}, 'timestamp': 1500419040}], 'currentPage': 749, 'size': 899}
"""
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/'
}
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