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": 243, "limit": 553, "responseCode": 200, "count": 509, "data": [{"lastEventTimestamp": 40851747, "lastUpdateTimestamp": 610509467, "messageRate": 855, "lastAgentHost": "Recently authority assume may carry financial process."}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Remain right over stop.", "messageTemplate": "Would word part student final money.", "field": "Outside board pick or such wide.", "parameter": {}, "timestamp": 83627310}], "currentPage": 245, "size": 961} """ 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": 276, "limit": 701, "responseCode": 200, "count": 757, "data": [{"lastEventTimestamp": 280776245, "lastUpdateTimestamp": 1254576976, "messageRate": 320, "lastAgentHost": "Fine can hear because manager finish American."}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Focus go six west.", "messageTemplate": "Recognize show hotel approach to.", "field": "Process sign both site right particular.", "parameter": {}, "timestamp": 819592290}], "currentPage": 664, "size": 567} """ 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": 284, "limit": 930, "responseCode": 200, "count": 886, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Thousand list candidate wife.", "messageTemplate": "Staff like response bed choose dream main.", "field": "Free human positive condition.", "parameter": {}, "timestamp": 863758244}], "currentPage": 240, "size": 790} """ 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