@edgeiq/edgeiq-api-js 1.4.14 → 1.4.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/scheduledJobs.test.d.ts +1 -0
- package/dist/__tests__/scheduledJobs.test.js +172 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/devices/models.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -1
- package/dist/scheduledJobs/index.d.ts +15 -0
- package/dist/scheduledJobs/index.js +354 -0
- package/dist/scheduledJobs/models.d.ts +27 -0
- package/dist/scheduledJobs/models.js +2 -0
- package/dist/testConstants.d.ts +4 -1
- package/dist/testConstants.js +17 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
var __1 = require("..");
|
|
51
|
+
var __2 = require("..");
|
|
52
|
+
var constants_1 = require("../constants");
|
|
53
|
+
var helpers_1 = require("../helpers");
|
|
54
|
+
var testConstants_1 = require("../testConstants");
|
|
55
|
+
describe('ScheduledJobs', function () {
|
|
56
|
+
__1.EdgeIQAPI.init(testConstants_1.stageURL);
|
|
57
|
+
it('Given an authenticated user', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
|
+
var result;
|
|
59
|
+
return __generator(this, function (_a) {
|
|
60
|
+
switch (_a.label) {
|
|
61
|
+
case 0: return [4, __2.Authentication.login(testConstants_1.TestAuth.username, testConstants_1.TestAuth.pass)];
|
|
62
|
+
case 1:
|
|
63
|
+
result = _a.sent();
|
|
64
|
+
expect(result.session_token).not.toBeNull();
|
|
65
|
+
return [2];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}); });
|
|
69
|
+
var scheduledJob = testConstants_1.EmptyScheduledJob;
|
|
70
|
+
var scheduledJob2 = testConstants_1.EmptyScheduledJob;
|
|
71
|
+
it('Creates a scheduled job', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
+
var result;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0: return [4, __1.ScheduledJobs.create(testConstants_1.TestScheduledJob)];
|
|
76
|
+
case 1:
|
|
77
|
+
result = _a.sent();
|
|
78
|
+
expect(result._id).not.toBeNull();
|
|
79
|
+
expect(result.job_name).toBe(testConstants_1.TestScheduledJob.job_name);
|
|
80
|
+
scheduledJob = result;
|
|
81
|
+
return [2];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}); });
|
|
85
|
+
it('Creates a second scheduled job', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
86
|
+
var result;
|
|
87
|
+
return __generator(this, function (_a) {
|
|
88
|
+
switch (_a.label) {
|
|
89
|
+
case 0: return [4, __1.ScheduledJobs.create(testConstants_1.TestScheduledJob)];
|
|
90
|
+
case 1:
|
|
91
|
+
result = _a.sent();
|
|
92
|
+
expect(result._id).not.toBeNull();
|
|
93
|
+
expect(result.job_name).toBe(testConstants_1.TestScheduledJob.job_name);
|
|
94
|
+
scheduledJob2 = result;
|
|
95
|
+
return [2];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}); });
|
|
99
|
+
it('Gets the first scheduled job created by _id', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
100
|
+
var result;
|
|
101
|
+
return __generator(this, function (_a) {
|
|
102
|
+
switch (_a.label) {
|
|
103
|
+
case 0: return [4, __1.ScheduledJobs.getOneById(scheduledJob._id)];
|
|
104
|
+
case 1:
|
|
105
|
+
result = _a.sent();
|
|
106
|
+
expect(result.job_name).toBe(scheduledJob.job_name);
|
|
107
|
+
return [2];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}); });
|
|
111
|
+
it('Updates a scheduled job', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
112
|
+
var result;
|
|
113
|
+
return __generator(this, function (_a) {
|
|
114
|
+
switch (_a.label) {
|
|
115
|
+
case 0:
|
|
116
|
+
if (!scheduledJob._id) return [3, 2];
|
|
117
|
+
return [4, __1.ScheduledJobs.update(__assign(__assign({}, scheduledJob), { job_name: testConstants_1.NewTestScheduledJob }))];
|
|
118
|
+
case 1:
|
|
119
|
+
result = _a.sent();
|
|
120
|
+
expect(result.job_name).toBe(testConstants_1.NewTestScheduledJob);
|
|
121
|
+
_a.label = 2;
|
|
122
|
+
case 2: return [2];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}); });
|
|
126
|
+
it('List the scheduled jobs created', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
127
|
+
var filters, result;
|
|
128
|
+
return __generator(this, function (_a) {
|
|
129
|
+
switch (_a.label) {
|
|
130
|
+
case 0:
|
|
131
|
+
filters = {
|
|
132
|
+
name: {
|
|
133
|
+
operator: 'like',
|
|
134
|
+
value: testConstants_1.TestScheduledJob.job_name,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
return [4, __1.ScheduledJobs.list(filters)];
|
|
138
|
+
case 1:
|
|
139
|
+
result = _a.sent();
|
|
140
|
+
expect(result.scheduledJobs).toBeDefined();
|
|
141
|
+
expect(result.scheduledJobs).toBeInstanceOf(Array);
|
|
142
|
+
expect(result.scheduledJobs).toHaveLength(2);
|
|
143
|
+
expect(result.pagination.page).toBe(constants_1.DefaultPagination.page);
|
|
144
|
+
expect(result.pagination.total).toBe(2);
|
|
145
|
+
expect(result.pagination.itemsPerPage).toBe(constants_1.DefaultPagination.itemsPerPage);
|
|
146
|
+
return [2];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}); });
|
|
150
|
+
it('Deletes the scheduled jobs created', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
151
|
+
var result, result;
|
|
152
|
+
return __generator(this, function (_a) {
|
|
153
|
+
switch (_a.label) {
|
|
154
|
+
case 0:
|
|
155
|
+
if (!scheduledJob._id) return [3, 2];
|
|
156
|
+
return [4, __1.ScheduledJobs.delete(scheduledJob._id)];
|
|
157
|
+
case 1:
|
|
158
|
+
result = _a.sent();
|
|
159
|
+
expect(result).toBe((0, helpers_1.getReturnDeleteMessage)('scheduled job'));
|
|
160
|
+
_a.label = 2;
|
|
161
|
+
case 2:
|
|
162
|
+
if (!scheduledJob2._id) return [3, 4];
|
|
163
|
+
return [4, __1.ScheduledJobs.delete(scheduledJob2._id)];
|
|
164
|
+
case 3:
|
|
165
|
+
result = _a.sent();
|
|
166
|
+
expect(result).toBe((0, helpers_1.getReturnDeleteMessage)('scheduled job'));
|
|
167
|
+
_a.label = 4;
|
|
168
|
+
case 4: return [2];
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}); });
|
|
172
|
+
});
|
package/dist/constants.d.ts
CHANGED
|
@@ -91,6 +91,7 @@ export declare const BaseEndpoints: {
|
|
|
91
91
|
userType: string;
|
|
92
92
|
user: string;
|
|
93
93
|
logs: string;
|
|
94
|
+
scheduledJobs: string;
|
|
94
95
|
};
|
|
95
96
|
export declare const Endpoints: {
|
|
96
97
|
me: string;
|
|
@@ -140,6 +141,7 @@ export declare const Endpoints: {
|
|
|
140
141
|
translator: string;
|
|
141
142
|
userType: string;
|
|
142
143
|
user: string;
|
|
144
|
+
scheduledJobs: string;
|
|
143
145
|
};
|
|
144
146
|
export declare const MethodsActions: {
|
|
145
147
|
post: string;
|
package/dist/constants.js
CHANGED
|
@@ -107,6 +107,7 @@ exports.BaseEndpoints = {
|
|
|
107
107
|
userType: 'user_types',
|
|
108
108
|
user: 'users',
|
|
109
109
|
logs: 'logs',
|
|
110
|
+
scheduledJobs: 'scheduled_jobs',
|
|
110
111
|
};
|
|
111
112
|
exports.Endpoints = {
|
|
112
113
|
me: 'me',
|
|
@@ -156,6 +157,7 @@ exports.Endpoints = {
|
|
|
156
157
|
translator: "" + exports.BaseEndpoints.translator,
|
|
157
158
|
userType: "" + exports.BaseEndpoints.userType,
|
|
158
159
|
user: "" + exports.BaseEndpoints.user,
|
|
160
|
+
scheduledJobs: "" + exports.BaseEndpoints.scheduledJobs,
|
|
159
161
|
};
|
|
160
162
|
exports.MethodsActions = {
|
|
161
163
|
post: 'creating',
|
package/dist/devices/models.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export { SystemCommandJobs } from './systemCommandJobs';
|
|
|
35
35
|
export { Translators } from './translators';
|
|
36
36
|
export { Users } from './users';
|
|
37
37
|
export { UserTypes } from './userTypes';
|
|
38
|
+
export { ScheduledJobs } from './scheduledJobs';
|
|
38
39
|
export * from './models';
|
|
39
40
|
export * from './bulkResponses/models';
|
|
40
41
|
export * from './commands/models';
|
|
@@ -72,3 +73,4 @@ export * from './systemCommandJobs/models';
|
|
|
72
73
|
export * from './translators/models';
|
|
73
74
|
export * from './users/models';
|
|
74
75
|
export * from './userTypes/models';
|
|
76
|
+
export * from './scheduledJobs/models';
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.UserTypes = exports.Users = exports.Translators = exports.SystemCommandJobs = exports.SystemCommands = exports.Stats = exports.SoftwareUpdates = exports.SettingApplicationRecords = exports.Settings = exports.Secrets = exports.Rules = exports.Reports = exports.Regions = exports.PollableAttributes = exports.Notifications = exports.LWM2M = exports.Integrations = exports.Ingestors = exports.GatewayCommands = exports.EscrowDevices = exports.DownstreamSystems = exports.EIQFiles = exports.DiscoveredDevices = exports.DeviceTypes = exports.DeviceTransferRequests = exports.DeviceTemplates = exports.DeviceErrors = exports.Devices = exports.DeviceLocationObservations = exports.DeviceConfigs = exports.Configurations = exports.CommandExecutions = exports.Companies = exports.Commands = exports.BulkResponses = exports.Authentication = exports.EdgeIQAPI = void 0;
|
|
13
|
+
exports.ScheduledJobs = exports.UserTypes = exports.Users = exports.Translators = exports.SystemCommandJobs = exports.SystemCommands = exports.Stats = exports.SoftwareUpdates = exports.SettingApplicationRecords = exports.Settings = exports.Secrets = exports.Rules = exports.Reports = exports.Regions = exports.PollableAttributes = exports.Notifications = exports.LWM2M = exports.Integrations = exports.Ingestors = exports.GatewayCommands = exports.EscrowDevices = exports.DownstreamSystems = exports.EIQFiles = exports.DiscoveredDevices = exports.DeviceTypes = exports.DeviceTransferRequests = exports.DeviceTemplates = exports.DeviceErrors = exports.Devices = exports.DeviceLocationObservations = exports.DeviceConfigs = exports.Configurations = exports.CommandExecutions = exports.Companies = exports.Commands = exports.BulkResponses = exports.Authentication = exports.EdgeIQAPI = void 0;
|
|
14
14
|
var core_1 = require("./core");
|
|
15
15
|
Object.defineProperty(exports, "EdgeIQAPI", { enumerable: true, get: function () { return core_1.EdgeIQAPI; } });
|
|
16
16
|
var auth_1 = require("./auth");
|
|
@@ -85,6 +85,8 @@ var users_1 = require("./users");
|
|
|
85
85
|
Object.defineProperty(exports, "Users", { enumerable: true, get: function () { return users_1.Users; } });
|
|
86
86
|
var userTypes_1 = require("./userTypes");
|
|
87
87
|
Object.defineProperty(exports, "UserTypes", { enumerable: true, get: function () { return userTypes_1.UserTypes; } });
|
|
88
|
+
var scheduledJobs_1 = require("./scheduledJobs");
|
|
89
|
+
Object.defineProperty(exports, "ScheduledJobs", { enumerable: true, get: function () { return scheduledJobs_1.ScheduledJobs; } });
|
|
88
90
|
__exportStar(require("./models"), exports);
|
|
89
91
|
__exportStar(require("./bulkResponses/models"), exports);
|
|
90
92
|
__exportStar(require("./commands/models"), exports);
|
|
@@ -122,3 +124,4 @@ __exportStar(require("./systemCommandJobs/models"), exports);
|
|
|
122
124
|
__exportStar(require("./translators/models"), exports);
|
|
123
125
|
__exportStar(require("./users/models"), exports);
|
|
124
126
|
__exportStar(require("./userTypes/models"), exports);
|
|
127
|
+
__exportStar(require("./scheduledJobs/models"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Device, DeviceType } from '..';
|
|
2
|
+
import { BaseModelInterface } from '../core/ModelClass';
|
|
3
|
+
import { BulkActionResponse } from '../models';
|
|
4
|
+
import { ScheduledJob, ScheduledJobInput, ScheduledJobsFilters, PaginatedScheduledJobs } from './models';
|
|
5
|
+
interface ScheduledJobsInterface extends BaseModelInterface<ScheduledJob, ScheduledJobInput, ScheduledJobsFilters, PaginatedScheduledJobs> {
|
|
6
|
+
update(scheduledJob: ScheduledJob): Promise<ScheduledJob>;
|
|
7
|
+
bulkAttachDevices(id: string, deviceIds: string[]): Promise<BulkActionResponse>;
|
|
8
|
+
bulkDetachDevices(id: string, deviceIds: string[]): Promise<BulkActionResponse>;
|
|
9
|
+
bulkAttachDeviceTypes(id: string, deviceTypeIds: string[]): Promise<BulkActionResponse>;
|
|
10
|
+
bulkDetachDeviceTypes(id: string, deviceTypeIds: string[]): Promise<BulkActionResponse>;
|
|
11
|
+
getDevices(id: string): Promise<Device[]>;
|
|
12
|
+
getDeviceTypes(id: string): Promise<DeviceType[]>;
|
|
13
|
+
}
|
|
14
|
+
export declare const ScheduledJobs: ScheduledJobsInterface;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (_) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.ScheduledJobs = void 0;
|
|
55
|
+
var __1 = require("..");
|
|
56
|
+
var constants_1 = require("../constants");
|
|
57
|
+
var ModelClass_1 = require("../core/ModelClass");
|
|
58
|
+
var filtersParser_1 = require("../filtersParser");
|
|
59
|
+
var helpers_1 = require("../helpers");
|
|
60
|
+
exports.ScheduledJobs = (function (_super) {
|
|
61
|
+
__extends(class_1, _super);
|
|
62
|
+
function class_1() {
|
|
63
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
64
|
+
}
|
|
65
|
+
class_1.create = function (scheduledJob) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
var axios, data, result, error_1;
|
|
68
|
+
return __generator(this, function (_a) {
|
|
69
|
+
switch (_a.label) {
|
|
70
|
+
case 0:
|
|
71
|
+
_a.trys.push([0, 2, , 3]);
|
|
72
|
+
this.logAction("Creating scheduled job with name: " + scheduledJob.job_name);
|
|
73
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
74
|
+
data = JSON.stringify(scheduledJob);
|
|
75
|
+
return [4, axios.post(constants_1.Endpoints.scheduledJobs, data)];
|
|
76
|
+
case 1:
|
|
77
|
+
result = _a.sent();
|
|
78
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
79
|
+
case 2:
|
|
80
|
+
error_1 = _a.sent();
|
|
81
|
+
if ((0, helpers_1.isApiError)(error_1)) {
|
|
82
|
+
throw error_1;
|
|
83
|
+
}
|
|
84
|
+
throw error_1;
|
|
85
|
+
case 3: return [2];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
class_1.update = function (scheduledJob) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
+
var axios, data, result, error_2;
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
switch (_a.label) {
|
|
95
|
+
case 0:
|
|
96
|
+
_a.trys.push([0, 2, , 3]);
|
|
97
|
+
this.logAction("Updating scheduled job with unique ID: " + scheduledJob._id);
|
|
98
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
99
|
+
data = JSON.stringify(scheduledJob);
|
|
100
|
+
return [4, axios.put(constants_1.Endpoints.scheduledJobs + "/" + scheduledJob._id, data)];
|
|
101
|
+
case 1:
|
|
102
|
+
result = _a.sent();
|
|
103
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
104
|
+
case 2:
|
|
105
|
+
error_2 = _a.sent();
|
|
106
|
+
if ((0, helpers_1.isApiError)(error_2)) {
|
|
107
|
+
throw error_2;
|
|
108
|
+
}
|
|
109
|
+
throw error_2;
|
|
110
|
+
case 3: return [2];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
class_1.list = function (filters, pagination) {
|
|
116
|
+
var _a, _b, _c, _d;
|
|
117
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
+
var axios, result, error_3;
|
|
119
|
+
return __generator(this, function (_e) {
|
|
120
|
+
switch (_e.label) {
|
|
121
|
+
case 0:
|
|
122
|
+
_e.trys.push([0, 2, , 3]);
|
|
123
|
+
this.logAction("Listing scheduled jobs with following filters: " + (filters !== null && filters !== void 0 ? filters : '{}') + ".\n And pagination " + (pagination !== null && pagination !== void 0 ? pagination : '{}'));
|
|
124
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
125
|
+
return [4, axios.get(constants_1.Endpoints.scheduledJobs, {
|
|
126
|
+
params: (0, filtersParser_1.parseFilters)(filters, pagination),
|
|
127
|
+
})];
|
|
128
|
+
case 1:
|
|
129
|
+
result = _e.sent();
|
|
130
|
+
return [2, {
|
|
131
|
+
scheduledJobs: (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.resources,
|
|
132
|
+
pagination: {
|
|
133
|
+
page: (_b = result === null || result === void 0 ? void 0 : result.data) === null || _b === void 0 ? void 0 : _b.page,
|
|
134
|
+
itemsPerPage: (_c = result === null || result === void 0 ? void 0 : result.data) === null || _c === void 0 ? void 0 : _c.per_page,
|
|
135
|
+
total: (_d = result === null || result === void 0 ? void 0 : result.data) === null || _d === void 0 ? void 0 : _d.total,
|
|
136
|
+
},
|
|
137
|
+
}];
|
|
138
|
+
case 2:
|
|
139
|
+
error_3 = _e.sent();
|
|
140
|
+
if ((0, helpers_1.isApiError)(error_3)) {
|
|
141
|
+
throw error_3;
|
|
142
|
+
}
|
|
143
|
+
throw error_3;
|
|
144
|
+
case 3: return [2];
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
class_1.getOneById = function (id) {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
+
var axios, result, error_4;
|
|
152
|
+
return __generator(this, function (_a) {
|
|
153
|
+
switch (_a.label) {
|
|
154
|
+
case 0:
|
|
155
|
+
_a.trys.push([0, 2, , 3]);
|
|
156
|
+
this.logAction("Getting scheduled job with id: " + id);
|
|
157
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
158
|
+
return [4, axios.get(constants_1.Endpoints.scheduledJobs + "/" + id)];
|
|
159
|
+
case 1:
|
|
160
|
+
result = _a.sent();
|
|
161
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
162
|
+
case 2:
|
|
163
|
+
error_4 = _a.sent();
|
|
164
|
+
if ((0, helpers_1.isApiError)(error_4)) {
|
|
165
|
+
throw error_4;
|
|
166
|
+
}
|
|
167
|
+
throw error_4;
|
|
168
|
+
case 3: return [2];
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
class_1.delete = function (id) {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175
|
+
var axios, error_5;
|
|
176
|
+
return __generator(this, function (_a) {
|
|
177
|
+
switch (_a.label) {
|
|
178
|
+
case 0:
|
|
179
|
+
_a.trys.push([0, 2, , 3]);
|
|
180
|
+
this.logAction("Deleting scheduled job with id " + id);
|
|
181
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
182
|
+
return [4, axios.delete(constants_1.Endpoints.scheduledJobs + "/" + id)];
|
|
183
|
+
case 1:
|
|
184
|
+
_a.sent();
|
|
185
|
+
return [2, (0, helpers_1.getReturnDeleteMessage)('scheduled job')];
|
|
186
|
+
case 2:
|
|
187
|
+
error_5 = _a.sent();
|
|
188
|
+
if ((0, helpers_1.isApiError)(error_5)) {
|
|
189
|
+
throw error_5;
|
|
190
|
+
}
|
|
191
|
+
throw error_5;
|
|
192
|
+
case 3: return [2];
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
class_1.bulkAttachDevices = function (id, deviceIds) {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
+
var axios, result, error_6;
|
|
200
|
+
return __generator(this, function (_a) {
|
|
201
|
+
switch (_a.label) {
|
|
202
|
+
case 0:
|
|
203
|
+
_a.trys.push([0, 2, , 3]);
|
|
204
|
+
this.logAction("Attaching " + deviceIds.length + " devices with to job with id " + id);
|
|
205
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
206
|
+
return [4, axios.put(constants_1.Endpoints.scheduledJobs + "/" + id + "/devices/bulk", {
|
|
207
|
+
ids: deviceIds,
|
|
208
|
+
})];
|
|
209
|
+
case 1:
|
|
210
|
+
result = _a.sent();
|
|
211
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
212
|
+
case 2:
|
|
213
|
+
error_6 = _a.sent();
|
|
214
|
+
if ((0, helpers_1.isApiError)(error_6)) {
|
|
215
|
+
throw error_6;
|
|
216
|
+
}
|
|
217
|
+
throw error_6;
|
|
218
|
+
case 3: return [2];
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
class_1.bulkDetachDevices = function (id, deviceIds) {
|
|
224
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
225
|
+
var axios, result, error_7;
|
|
226
|
+
return __generator(this, function (_a) {
|
|
227
|
+
switch (_a.label) {
|
|
228
|
+
case 0:
|
|
229
|
+
_a.trys.push([0, 2, , 3]);
|
|
230
|
+
this.logAction("Detach " + deviceIds.length + " devices from job with id " + id);
|
|
231
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
232
|
+
return [4, axios.delete(constants_1.Endpoints.scheduledJobs + "/" + id + "/devices/bulk", {
|
|
233
|
+
data: {
|
|
234
|
+
ids: deviceIds,
|
|
235
|
+
},
|
|
236
|
+
})];
|
|
237
|
+
case 1:
|
|
238
|
+
result = _a.sent();
|
|
239
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
240
|
+
case 2:
|
|
241
|
+
error_7 = _a.sent();
|
|
242
|
+
if ((0, helpers_1.isApiError)(error_7)) {
|
|
243
|
+
throw error_7;
|
|
244
|
+
}
|
|
245
|
+
throw error_7;
|
|
246
|
+
case 3: return [2];
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
class_1.bulkAttachDeviceTypes = function (id, deviceTypeIds) {
|
|
252
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
253
|
+
var axios, result, error_8;
|
|
254
|
+
return __generator(this, function (_a) {
|
|
255
|
+
switch (_a.label) {
|
|
256
|
+
case 0:
|
|
257
|
+
_a.trys.push([0, 2, , 3]);
|
|
258
|
+
this.logAction("Attaching " + deviceTypeIds.length + " device types with to job with id " + id);
|
|
259
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
260
|
+
return [4, axios.put(constants_1.Endpoints.scheduledJobs + "/" + id + "/device_types/bulk", {
|
|
261
|
+
ids: deviceTypeIds,
|
|
262
|
+
})];
|
|
263
|
+
case 1:
|
|
264
|
+
result = _a.sent();
|
|
265
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
266
|
+
case 2:
|
|
267
|
+
error_8 = _a.sent();
|
|
268
|
+
if ((0, helpers_1.isApiError)(error_8)) {
|
|
269
|
+
throw error_8;
|
|
270
|
+
}
|
|
271
|
+
throw error_8;
|
|
272
|
+
case 3: return [2];
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
class_1.bulkDetachDeviceTypes = function (id, deviceTypeIds) {
|
|
278
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
279
|
+
var axios, result, error_9;
|
|
280
|
+
return __generator(this, function (_a) {
|
|
281
|
+
switch (_a.label) {
|
|
282
|
+
case 0:
|
|
283
|
+
_a.trys.push([0, 2, , 3]);
|
|
284
|
+
this.logAction("Detach " + deviceTypeIds.length + " device types from job with id " + id);
|
|
285
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
286
|
+
return [4, axios.delete(constants_1.Endpoints.scheduledJobs + "/" + id + "/device_types/bulk", {
|
|
287
|
+
data: {
|
|
288
|
+
ids: deviceTypeIds,
|
|
289
|
+
},
|
|
290
|
+
})];
|
|
291
|
+
case 1:
|
|
292
|
+
result = _a.sent();
|
|
293
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
294
|
+
case 2:
|
|
295
|
+
error_9 = _a.sent();
|
|
296
|
+
if ((0, helpers_1.isApiError)(error_9)) {
|
|
297
|
+
throw error_9;
|
|
298
|
+
}
|
|
299
|
+
throw error_9;
|
|
300
|
+
case 3: return [2];
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
};
|
|
305
|
+
class_1.getDevices = function (id) {
|
|
306
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
307
|
+
var axios, result, error_10;
|
|
308
|
+
return __generator(this, function (_a) {
|
|
309
|
+
switch (_a.label) {
|
|
310
|
+
case 0:
|
|
311
|
+
_a.trys.push([0, 2, , 3]);
|
|
312
|
+
this.logAction("Getting Devices attached to job with id " + id);
|
|
313
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
314
|
+
return [4, axios.get(constants_1.Endpoints.scheduledJobs + "/" + id + "/devices")];
|
|
315
|
+
case 1:
|
|
316
|
+
result = _a.sent();
|
|
317
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
318
|
+
case 2:
|
|
319
|
+
error_10 = _a.sent();
|
|
320
|
+
if ((0, helpers_1.isApiError)(error_10)) {
|
|
321
|
+
throw error_10;
|
|
322
|
+
}
|
|
323
|
+
throw error_10;
|
|
324
|
+
case 3: return [2];
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
};
|
|
329
|
+
class_1.getDeviceTypes = function (id) {
|
|
330
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
331
|
+
var axios, result, error_11;
|
|
332
|
+
return __generator(this, function (_a) {
|
|
333
|
+
switch (_a.label) {
|
|
334
|
+
case 0:
|
|
335
|
+
_a.trys.push([0, 2, , 3]);
|
|
336
|
+
this.logAction("Getting Device types attached to job with id " + id);
|
|
337
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
338
|
+
return [4, axios.get(constants_1.Endpoints.scheduledJobs + "/" + id + "/device_types")];
|
|
339
|
+
case 1:
|
|
340
|
+
result = _a.sent();
|
|
341
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
342
|
+
case 2:
|
|
343
|
+
error_11 = _a.sent();
|
|
344
|
+
if ((0, helpers_1.isApiError)(error_11)) {
|
|
345
|
+
throw error_11;
|
|
346
|
+
}
|
|
347
|
+
throw error_11;
|
|
348
|
+
case 3: return [2];
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
};
|
|
353
|
+
return class_1;
|
|
354
|
+
}(ModelClass_1.BaseModelClass));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Base, Filter, Filters, Pagination } from '../models';
|
|
2
|
+
export interface ScheduledJobInput {
|
|
3
|
+
job_name: string;
|
|
4
|
+
schedule: string;
|
|
5
|
+
job_type: string;
|
|
6
|
+
details: {
|
|
7
|
+
command_options?: {
|
|
8
|
+
[key: string]: string;
|
|
9
|
+
};
|
|
10
|
+
workflow_options?: {
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
command_id: string;
|
|
16
|
+
company_id: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ScheduledJob extends ScheduledJobInput, Base {
|
|
19
|
+
}
|
|
20
|
+
export interface ScheduledJobsFilters extends Filters {
|
|
21
|
+
name?: Filter;
|
|
22
|
+
job_type?: Filter;
|
|
23
|
+
}
|
|
24
|
+
export interface PaginatedScheduledJobs {
|
|
25
|
+
scheduledJobs: ScheduledJob[];
|
|
26
|
+
pagination: Pagination;
|
|
27
|
+
}
|
package/dist/testConstants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IntegrationInput, Company, CompanyInput, CommandInput, Device, DeviceInput, DiscoveredDeviceInput, DeviceType, DeviceTypeInput, User, UserInput, Integration, Ingestor, IngestorInput, PollableAttribute, PollableAttributeInput, Translator, TranslatorInput, Rule, RuleInput, FileInput } from '.';
|
|
1
|
+
import { IntegrationInput, Company, CompanyInput, CommandInput, Device, DeviceInput, DiscoveredDeviceInput, DeviceType, DeviceTypeInput, User, UserInput, Integration, Ingestor, IngestorInput, PollableAttribute, PollableAttributeInput, Translator, TranslatorInput, Rule, RuleInput, FileInput, ScheduledJobInput, ScheduledJob } from '.';
|
|
2
2
|
import { Notification } from './notifications/models';
|
|
3
3
|
export declare const stageURL: {
|
|
4
4
|
url: string;
|
|
@@ -49,3 +49,6 @@ export declare const TestDiscoveredDevice: DiscoveredDeviceInput;
|
|
|
49
49
|
export declare const TestCommand: CommandInput;
|
|
50
50
|
export declare const EmptyNotificationType: Notification;
|
|
51
51
|
export declare const TestFile: FileInput;
|
|
52
|
+
export declare const NewTestScheduledJob = "New Test Schedule";
|
|
53
|
+
export declare const TestScheduledJob: ScheduledJobInput;
|
|
54
|
+
export declare const EmptyScheduledJob: ScheduledJob;
|
package/dist/testConstants.js
CHANGED
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.TestFile = exports.EmptyNotificationType = exports.TestCommand = exports.TestDiscoveredDevice = exports.NewTestRuleDescription = exports.TestRule2 = exports.TestRule = exports.EmptyRule = exports.NewTestTranslatorName = exports.TestTranslator2 = exports.TestTranslator = exports.EmptyTranslator = exports.NewTestPollableAttributeName = exports.TestPollableAttribute2 = exports.TestPollableAttribute = exports.EmptyPollableAttribute = exports.NewTestIngestorName = exports.TestIngestor2 = exports.TestIngestor = exports.EmptyIngestor = exports.NewIntegrationName = exports.TestIntegration3 = exports.TestIntegration2 = exports.TestIntegration = exports.EmptyIntegration = exports.NewTestDeviceTypeName = exports.TestDeviceType2 = exports.TestDeviceType = exports.EmptyDeviceType = exports.NewTestCompanyName = exports.TestCompany2 = exports.TestCompany = exports.EmptyCompany = exports.NewTestUserName = exports.EmptyUser = exports.TestUser2 = exports.TestUser = exports.NewTestDeviceName = exports.EmptyDevice = exports.TestDevice2 = exports.TestDevice = exports.TestAuth = exports.stageURL = void 0;
|
|
14
|
+
exports.EmptyScheduledJob = exports.TestScheduledJob = exports.NewTestScheduledJob = exports.TestFile = exports.EmptyNotificationType = exports.TestCommand = exports.TestDiscoveredDevice = exports.NewTestRuleDescription = exports.TestRule2 = exports.TestRule = exports.EmptyRule = exports.NewTestTranslatorName = exports.TestTranslator2 = exports.TestTranslator = exports.EmptyTranslator = exports.NewTestPollableAttributeName = exports.TestPollableAttribute2 = exports.TestPollableAttribute = exports.EmptyPollableAttribute = exports.NewTestIngestorName = exports.TestIngestor2 = exports.TestIngestor = exports.EmptyIngestor = exports.NewIntegrationName = exports.TestIntegration3 = exports.TestIntegration2 = exports.TestIntegration = exports.EmptyIntegration = exports.NewTestDeviceTypeName = exports.TestDeviceType2 = exports.TestDeviceType = exports.EmptyDeviceType = exports.NewTestCompanyName = exports.TestCompany2 = exports.TestCompany = exports.EmptyCompany = exports.NewTestUserName = exports.EmptyUser = exports.TestUser2 = exports.TestUser = exports.NewTestDeviceName = exports.EmptyDevice = exports.TestDevice2 = exports.TestDevice = exports.TestAuth = exports.stageURL = void 0;
|
|
15
15
|
var _1 = require(".");
|
|
16
16
|
exports.stageURL = {
|
|
17
17
|
url: 'https://api.stage.edgeiq.io/api/v1/platform/',
|
|
@@ -341,3 +341,19 @@ exports.TestFile = {
|
|
|
341
341
|
mime_type: 'text/plain',
|
|
342
342
|
name: 'Test File',
|
|
343
343
|
};
|
|
344
|
+
exports.NewTestScheduledJob = 'New Test Schedule';
|
|
345
|
+
exports.TestScheduledJob = {
|
|
346
|
+
job_name: exports.NewTestScheduledJob,
|
|
347
|
+
schedule: '*/1 * * * *',
|
|
348
|
+
job_type: 'user-defined-command',
|
|
349
|
+
details: {
|
|
350
|
+
command_options: {
|
|
351
|
+
test: 'Test',
|
|
352
|
+
},
|
|
353
|
+
workflow_options: {},
|
|
354
|
+
},
|
|
355
|
+
enabled: true,
|
|
356
|
+
command_id: '648a07c58fc32100018b1d34',
|
|
357
|
+
company_id: parentCompanyId,
|
|
358
|
+
};
|
|
359
|
+
exports.EmptyScheduledJob = __assign(__assign({}, exports.TestScheduledJob), baseModel);
|