browser-sdk
Version:
javascript SDK for the lightelligence-platform
79 lines (68 loc) • 3.63 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _apiService = _interopRequireDefault(require("../tools/apiService"));
/**
* Methods for timeseries operations
*/
var Timeseries =
/*#__PURE__*/
function () {
function Timeseries() {
(0, _classCallCheck2["default"])(this, Timeseries);
}
(0, _createClass2["default"])(Timeseries, null, [{
key: "getDeviceLastTimeseries",
/**
* Get data for the last hour reported to the timeseries db by the device with the given uuid in an descending order.
* @param {string} deviceId
* @param {object} params
* @param {string} params.path Path matching to a path defined in the reporting rules of the device's type. (e.g. $.attributes.brightness).
* @returns {Promise}
*/
value: function getDeviceLastTimeseries(deviceId, params) {
var urlParams = new URLSearchParams(params);
return _apiService["default"].call("/devices/".concat(deviceId, "/last-timeseries?").concat(urlParams.toString()));
}
/**
* Delete reported timeseries data of the device belonging to the given uuid.
* @param {string} deviceId
* @param {object} params
* @param {string} params.path Path matching to a path defined in the reporting rules of the device's type. (e.g. $.attributes.brightness).
* @param {string} params.startTime The start time of the time frame to request. (RFC 3339)
* @param {string} params.endTime The end time of the time frame to request. (RFC 3339)
* @returns {Promise}
*/
}, {
key: "deleteDeviceTimeseries",
value: function deleteDeviceTimeseries(deviceId, params) {
var urlParams = new URLSearchParams(params);
return _apiService["default"].call("/devices/".concat(deviceId, "/timeseries?").concat(urlParams.toString()), 'DELETE');
}
/**
* Get data for the last hour reported to the timeseries db by the device with the given uuid in an descending order.
* @param {string} deviceId
* @param {object} params
* @param {string} params.path Path matching to a path defined in the reporting rules of the device's type. (e.g. $.attributes.brightness).
* @param {string} params.startTime The start time of the time frame to request. (RFC 3339)
* @param {string} params.endTime The end time of the time frame to request. (RFC 3339)
* @param {number} params.limit The limit of the points returned in one query.
* @param {string} params.frameSize The time frame size in which the values should be aggregated. In case frameSize is set and the number of points in the response will exceed the limit, an error (400) will be returned. Available values : 1m, 5m, 30m, 1h, 1d
* @param {string} params.aggregation How should the values be aggregated. Supported values: min, max, mean, sum, count, diff, first, last. Available values : min, max, mean, sum, count, diff, first, last
* @returns {Promise}
*/
}, {
key: "getDeviceAggregatedTimeseries",
value: function getDeviceAggregatedTimeseries(deviceId, params) {
var urlParams = new URLSearchParams(params);
return _apiService["default"].call("/devices/".concat(deviceId, "/aggregated-timeseries?").concat(urlParams.toString()));
}
}]);
return Timeseries;
}();
exports["default"] = Timeseries;