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": 423, "limit": 484, "responseCode": 200, "count": 894, "data": [{"lastEventTimestamp": 994478686, "lastUpdateTimestamp": 888677726, "messageRate": 474, "lastAgentHost": "Difficult attorney learn anyone safe a."}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Reach discussion near box him hear section.", "messageTemplate": "Investment compare get heavy suddenly home seek.", "field": "Action eight common see.", "parameter": {}, "timestamp": 220547604}], "currentPage": 446, "size": 344} """ from requests import get from argus_api.exceptions import http url = "https://portal.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": 55, "limit": 350, "responseCode": 200, "count": 281, "data": [{"lastEventTimestamp": 327670603, "lastUpdateTimestamp": 455004236, "messageRate": 38, "lastAgentHost": "Marriage meet knowledge."}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Region evening book region positive.", "messageTemplate": "Expert friend toward health several may evidence.", "field": "Nation hand than area later more nothing test.", "parameter": {}, "timestamp": 595075513}], "currentPage": 388, "size": 363} """ from requests import post from argus_api.exceptions import http url = "https://portal.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": 186, "limit": 406, "responseCode": 200, "count": 130, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Find behavior full statement more last since audience.", "messageTemplate": "Green adult vote any.", "field": "Move suffer degree center also down.", "parameter": {}, "timestamp": 532985732}], "currentPage": 151, "size": 195} """ from requests import get from argus_api.exceptions import http url = "https://portal.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