Source code for api.sensors.v1.sensor

"""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": 453, "limit": 701, "responseCode": 200, "count": 959, "data": [{"id": 230, "expectedUpdateTime": 183, "scheduledDowntimeFromTime": 892, "scheduledDowntimeUntilTime": 480, "information": "Visit big phone to away fine those none.", "hostname": "Total center huge edge.", "additionalData": "Car great win.", "flags": ["SHARED_CUSTOMER_DATA"], "lastUpdatedByUser": {"id": 672, "customerID": 601, "userName": "megan27", "name": "Devin Jackson"}, "lastUpdatedTimestamp": 1403180108, "lastAcknowledgedTimestamp": 578620743, "inScheduledDowntime": false}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Know fact fire.", "messageTemplate": "Professor bad during.", "field": "Drug since should across federal official.", "parameter": {}, "timestamp": 379274416}], "currentPage": 953, "size": 916} """ 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": 814, "limit": 620, "responseCode": 200, "count": 771, "data": [{"id": 557, "expectedUpdateTime": 889, "scheduledDowntimeFromTime": 27, "scheduledDowntimeUntilTime": 565, "information": "Sort degree finally address happy source play.", "hostname": "Tough hot who American as.", "additionalData": "Business tonight join treatment avoid.", "flags": ["MONITORED"], "lastUpdatedByUser": {"id": 47, "customerID": 84, "userName": "erindoyle", "name": "Sierra Torres"}, "lastUpdatedTimestamp": 394559952, "lastAcknowledgedTimestamp": 206154138, "inScheduledDowntime": true}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Beat just national must not.", "messageTemplate": "Ready fund yet way.", "field": "Stage plan hour today.", "parameter": {}, "timestamp": 1290204947}], "currentPage": 233, "size": 225} """ 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": 852, "limit": 838, "responseCode": 200, "count": 727, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Run cold street.", "messageTemplate": "Finish within method teacher build.", "field": "Specific onto student into everything low or.", "parameter": {}, "timestamp": 1091517871}], "currentPage": 154, "size": 991} """ 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
[docs]@register_command(extending=('sensors','v1','sensor')) def get_sensor_comments(sensorID: int, limit: int = 25, offset: int = 0,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict: """Fetch sensor comments by sensor ID (PUBLIC) :param int sensorID: ID of sensor to fetch comments for :param int limit: Limit results :param int offset: Offset results :raises AuthenticationFailedException: on 401 :raises ValidationErrorException: on 412 :raises AccessDeniedException: on 403 :raises ObjectNotFoundException: on 404 :returns: {"offset": 492, "limit": 500, "responseCode": 200, "count": 446, "data": [{"timestamp": 650524006, "user": {"id": 273, "customerID": 672, "userName": "spenceadam", "name": "Cynthia Young"}, "comment": "Pattern form last there."}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Democratic difficult score yourself close in.", "messageTemplate": "Eat child produce technology very.", "field": "Adult clearly home support window wait year.", "parameter": {}, "timestamp": 95204308}], "currentPage": 56, "size": 841} """ from requests import get from argus_api.exceptions import http url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/sensors/v1/sensor/{sensorID}/comments".format(sensorID=sensorID) 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}) 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