Source code for api.sensors.v1.status

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


[docs]@register_command(extending=('sensors','v1','status')) def list_sensors(customerID: list = None, applicationName: list = None, keywords: list = None, offset: int = None, limit: int = 25,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """List sensor status (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 offset: Offset results :param int limit: Limit results :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :returns: {"offset": 216, "limit": 327, "responseCode": 200, "count": 250, "data": [{"lastEventTimestamp": 1380534508, "lastUpdateTimestamp": 422236541, "messageRate": 282, "lastAgentHost": "Own not feeling clearly."}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Woman pay radio finish.", "messageTemplate": "Gun everything trial billion property civil with measure.", "field": "Woman rise hard fire.", "parameter": {}, "timestamp": 80486462}], "currentPage": 583, "size": 840} """ from requests import get from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/sensors/v1/status".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 customerID: body.update({"customerID": customerID}) if applicationName: body.update({"applicationName": applicationName}) if keywords: body.update({"keywords": keywords}) if offset: body.update({"offset": offset}) 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','status')) 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', excludeReportingSensors: bool = 'False', excludeSensorsInScheduledDowntime: bool = 'False', excludeSensorsInReportingCluster: bool = 'False',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Search sensor status (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) :param bool excludeReportingSensors: Exclude sensors which are reporting :param bool excludeSensorsInScheduledDowntime: Exclude sensors which are in scheduled downtime :param bool excludeSensorsInReportingCluster: Exclude sensors which are member of a cluster where any member is reporting :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :returns: {"offset": 834, "limit": 955, "responseCode": 200, "count": 806, "data": [{"lastEventTimestamp": 222599881, "lastUpdateTimestamp": 1156699226, "messageRate": 354, "lastAgentHost": "Mouth business try foot forget we catch."}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Size something employee stage anything themselves put.", "messageTemplate": "Only cold garden word best office.", "field": "Win best run important happen.", "parameter": {}, "timestamp": 603506808}], "currentPage": 866, "size": 750} """ from requests import post from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/sensors/v1/status/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 excludeReportingSensors: body.update({"excludeReportingSensors": excludeReportingSensors}) if excludeSensorsInScheduledDowntime: body.update({"excludeSensorsInScheduledDowntime": excludeSensorsInScheduledDowntime}) if excludeSensorsInReportingCluster: body.update({"excludeSensorsInReportingCluster": excludeSensorsInReportingCluster}) 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','status')) def get_sensor(id: int,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Fetch sensor status by ID (PUBLIC) :param int id: ID of sensor to fetch status for :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {"offset": 276, "limit": 897, "responseCode": 200, "count": 79, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Production we task continue parent.", "messageTemplate": "Ok southern fire me itself point despite.", "field": "Mean hold new term.", "parameter": {}, "timestamp": 777992535}], "currentPage": 306, "size": 662} """ from requests import get from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/sensors/v1/status/{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