limacharlie
Version:
An API for limacharlie.io, a cloud hosted endpoint detection and response platform.
92 lines (74 loc) • 3.43 kB
JavaScript
;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Job = function () {
function Job(manager, data) {
_classCallCheck(this, Job);
this._man = manager;
this.data = data;
}
_createClass(Job, [{
key: "reload",
value: function () {
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(withData) {
var data;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return this._man._apiCall("job/" + this._man._oid + "/" + this.data.job_id, "GET", {
is_compressed: "true",
with_data: "" + !!withData
});
case 2:
data = _context.sent;
_context.next = 5;
return this._man._unzip(Buffer.from(data.job, "base64"));
case 5:
data.job = _context.sent;
data.job = JSON.parse(data.job);
this.data = data.job;
case 8:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
function reload(_x) {
return _ref.apply(this, arguments);
}
return reload;
}()
}, {
key: "delete",
value: function () {
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
var data;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return this._man._apiCall("job/" + this._man._oid + "/" + this.data.job_id, "DELETE");
case 2:
data = _context2.sent;
return _context2.abrupt("return", data);
case 4:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}));
function _delete() {
return _ref2.apply(this, arguments);
}
return _delete;
}()
}]);
return Job;
}();
module.exports = Job;