"""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": 233, "limit": 538, "responseCode": 200, "count": 946, "data": [{"id": 385, "expectedUpdateTime": 578, "scheduledDowntimeFromTime": 894, "scheduledDowntimeUntilTime": 918, "information": "Another just three raise positive performance.", "hostname": "Color course protect number land could yet.", "additionalData": "Decide purpose hotel radio include.", "flags": ["CLOCK_OUT_OF_SYNC"], "lastUpdatedByUser": {"id": 791, "customerID": 673, "userName": "kelly80", "name": "Sharon Wallace"}, "lastUpdatedTimestamp": 222753395, "lastAcknowledgedTimestamp": 321492218, "inScheduledDowntime": true}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Significant wear black move avoid democratic.", "messageTemplate": "Society forward either authority notice it than.", "field": "Owner seat market onto line media during model.", "parameter": {}, "timestamp": 1116532982}], "currentPage": 19, "size": 832}
"""
from requests import get
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 570, "limit": 757, "responseCode": 200, "count": 153, "data": [{"id": 196, "expectedUpdateTime": 809, "scheduledDowntimeFromTime": 26, "scheduledDowntimeUntilTime": 986, "information": "Challenge soldier question relationship anything.", "hostname": "Bag crime court sport east.", "additionalData": "Attack general husband plant easy drug contain.", "flags": ["ACTIVE"], "lastUpdatedByUser": {"id": 239, "customerID": 714, "userName": "marcwillis", "name": "Vincent Wilson"}, "lastUpdatedTimestamp": 1465277898, "lastAcknowledgedTimestamp": 65587477, "inScheduledDowntime": false}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Detail after pull like cultural president.", "messageTemplate": "White executive peace.", "field": "Note generation support order receive campaign dark.", "parameter": {}, "timestamp": 1312697370}], "currentPage": 539, "size": 372}
"""
from requests import post
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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": 4, "limit": 682, "responseCode": 200, "count": 492, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Together experience look exist peace.", "messageTemplate": "Can have two per on or past.", "field": "Analysis book evidence stay ready whole could.", "parameter": {}, "timestamp": 1050950909}], "currentPage": 943, "size": 313}
"""
from requests import get
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.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