"""Autogenerated API"""
import requests
from argus_cli.plugin import register_command
[docs]@register_command(extending=('sensors','v1','sensor'))
def list_sensors(customerID: list = None, applicationName: list = None, keywords: list = None, limit: int = 25, offset: int = 0,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""List sensors (PUBLIC)
:param list customerID: Limit search to these customer IDs
:param list applicationName: Limit search to these applications by name
:param list keywords: Limit search by sensor hostname or IP address
:param int limit: Limit results
:param int offset: Offset results
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:returns: {"offset": 436, "limit": 754, "responseCode": 200, "count": 241, "data": [{"id": 975, "expectedUpdateTime": 331, "scheduledDowntimeFromTime": 56, "scheduledDowntimeUntilTime": 573, "information": "Treat itself actually station.", "hostname": "Sometimes stop free.", "additionalData": "Whom mind receive during hair everyone seem.", "flags": ["OVERRIDE_UPDATE_TIME"], "lastUpdatedByUser": {"id": 75, "customerID": 937, "userName": "jtucker", "name": "Heather Carpenter"}, "lastUpdatedTimestamp": 360123135, "lastAcknowledgedTimestamp": 1460829507, "inScheduledDowntime": false}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Ok lead think general than.", "messageTemplate": "Lawyer significant man lay respond big it low.", "field": "Recognize everybody goal wear begin smile live.", "parameter": {}, "timestamp": 1401288531}], "currentPage": 232, "size": 988}
"""
from requests import get
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/sensors/v1/sensor".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})
if applicationName:
body.update({"applicationName": applicationName})
if keywords:
body.update({"keywords": keywords})
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=('sensors','v1','sensor'))
def find_sensors(limit: int = None, offset: int = None, customerID: list = None, keywords: list = None, sortBy: list = None, startTimestamp: int = None, endTimestamp: int = None, includeFlags: list = None, excludeFlags: list = None, sensorID: list = None, locationName: list = None, applicationName: list = None, subCriteria: list = None, includeDeleted: bool = 'False',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Search sensors (PUBLIC)
:param int limit: Limit results
:param int offset: Offset results
:param list customerID: Limit result to objects belonging to these customers
:param list keywords: Search for sensors matching this hostname or IP-address
:param list sortBy: Order results by these properties (prefix with - to sort descending)
:param int startTimestamp: Search objects from this timestamp
:param int endTimestamp: Search objects until this timestamp
:param list includeFlags: Search objects with these flags set
:param list excludeFlags: Exclude objects with these flags set
:param list sensorID: Search for specific sensors by ID
:param list locationName: Search for sensors bound to any of these locations
:param list applicationName: Search for sensors by application type
:param list subCriteria:
:param bool includeDeleted: Also include deleted objects (where implemented)
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:returns: {"offset": 383, "limit": 693, "responseCode": 200, "count": 923, "data": [{"id": 443, "expectedUpdateTime": 620, "scheduledDowntimeFromTime": 474, "scheduledDowntimeUntilTime": 185, "information": "Why bring health center yard cell program.", "hostname": "Seek feel large suggest receive safe him.", "additionalData": "Modern why among require its.", "flags": ["ACKNOWLEDGED"], "lastUpdatedByUser": {"id": 209, "customerID": 784, "userName": "tannerbrett", "name": "Debra Lawrence"}, "lastUpdatedTimestamp": 922866972, "lastAcknowledgedTimestamp": 75635449, "inScheduledDowntime": true}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Republican Mrs level loss work trade significant eye.", "messageTemplate": "Ready anyone raise field benefit.", "field": "Threat economy paper message between day.", "parameter": {}, "timestamp": 583786703}], "currentPage": 351, "size": 90}
"""
from requests import post
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/sensors/v1/sensor/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 limit:
body.update({"limit": limit})
if offset:
body.update({"offset": offset})
if includeDeleted:
body.update({"includeDeleted": includeDeleted})
if customerID:
body.update({"customerID": customerID})
if keywords:
body.update({"keywords": keywords})
if sortBy:
body.update({"sortBy": sortBy})
if startTimestamp:
body.update({"startTimestamp": startTimestamp})
if endTimestamp:
body.update({"endTimestamp": endTimestamp})
if includeFlags:
body.update({"includeFlags": includeFlags})
if excludeFlags:
body.update({"excludeFlags": excludeFlags})
if sensorID:
body.update({"sensorID": sensorID})
if locationName:
body.update({"locationName": locationName})
if applicationName:
body.update({"applicationName": applicationName})
if subCriteria:
body.update({"subCriteria": subCriteria})
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=('sensors','v1','sensor'))
def get_sensor(id: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Fetch sensor by ID (PUBLIC)
:param int id: ID of sensor to fetch
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:raises ObjectNotFoundException: on 404
:returns: {"offset": 391, "limit": 146, "responseCode": 200, "count": 289, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Travel until account far contain consider develop.", "messageTemplate": "Particular time evidence themselves simple impact.", "field": "Nice manage before subject food himself huge.", "parameter": {}, "timestamp": 958747246}], "currentPage": 53, "size": 755}
"""
from requests import get
from argus_api.exceptions import http
url = "https://portal.mnemonic.no/web/api/sensors/v1/sensor/{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