@edgeiq/edgeiq-api-js 1.7.5 → 1.7.6
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/OIDC/index.js +137 -238
- package/dist/OIDC/models.js +1 -2
- package/dist/__tests__/auth.test.js +56 -147
- package/dist/__tests__/command.test.js +80 -202
- package/dist/__tests__/companies.test.js +121 -269
- package/dist/__tests__/deviceErrors.test.js +16 -62
- package/dist/__tests__/deviceTypes.test.js +78 -200
- package/dist/__tests__/devices.test.js +84 -221
- package/dist/__tests__/discoveredDevice.test.js +57 -145
- package/dist/__tests__/files.test.js +58 -152
- package/dist/__tests__/ingestors.test.js +70 -188
- package/dist/__tests__/integrations.test.js +95 -235
- package/dist/__tests__/lwm2m.test.js +17 -62
- package/dist/__tests__/notifications.test.js +16 -62
- package/dist/__tests__/pollableAttributes.test.js +60 -162
- package/dist/__tests__/rules.test.js +60 -162
- package/dist/__tests__/scheduledJobs.test.js +60 -162
- package/dist/__tests__/translators.test.js +60 -162
- package/dist/__tests__/users.test.js +77 -197
- package/dist/auth/index.js +94 -167
- package/dist/bulkResponses/index.js +44 -110
- package/dist/bulkResponses/models.js +1 -2
- package/dist/commandExecutions/index.js +39 -85
- package/dist/commandExecutions/models.js +1 -2
- package/dist/commands/index.js +196 -342
- package/dist/commands/models.js +2 -5
- package/dist/companies/index.js +150 -272
- package/dist/companies/models.js +1 -2
- package/dist/configurations/index.js +172 -310
- package/dist/configurations/models.js +1 -2
- package/dist/constants.js +69 -85
- package/dist/core/ModelClass.js +11 -18
- package/dist/core/handleResponseError.js +77 -81
- package/dist/core/index.js +30 -38
- package/dist/deviceConfigs/index.js +103 -201
- package/dist/deviceConfigs/models.js +1 -2
- package/dist/deviceErrors/index.js +44 -110
- package/dist/deviceErrors/models.js +1 -2
- package/dist/deviceLocationObservations/index.js +82 -164
- package/dist/deviceLocationObservations/models.js +1 -2
- package/dist/deviceTemplates/index.js +105 -203
- package/dist/deviceTemplates/models.js +1 -2
- package/dist/deviceTransferRequests/index.js +116 -222
- package/dist/deviceTransferRequests/models.js +1 -2
- package/dist/deviceTypes/index.js +328 -554
- package/dist/deviceTypes/models.js +1 -2
- package/dist/devices/index.js +630 -971
- package/dist/devices/models.js +1 -2
- package/dist/discoveredDevices/index.js +190 -328
- package/dist/discoveredDevices/models.js +1 -2
- package/dist/downstreamSystems/index.js +87 -177
- package/dist/downstreamSystems/models.js +1 -2
- package/dist/escrowDevices/index.js +103 -201
- package/dist/escrowDevices/models.js +1 -2
- package/dist/files/index.js +137 -251
- package/dist/files/models.js +1 -2
- package/dist/filtersParser.js +12 -17
- package/dist/gatewayCommands/index.js +103 -201
- package/dist/gatewayCommands/models.js +1 -2
- package/dist/helpers.js +10 -16
- package/dist/index.js +86 -142
- package/dist/ingestors/index.js +103 -201
- package/dist/ingestors/models.js +1 -2
- package/dist/integrations/index.js +159 -273
- package/dist/integrations/models.js +1 -2
- package/dist/log/models.js +1 -2
- package/dist/lwm2m/index.js +23 -72
- package/dist/lwm2m/models.js +1 -2
- package/dist/models/index.js +1 -2
- package/dist/models.js +1 -2
- package/dist/notifications/index.js +44 -110
- package/dist/notifications/models.js +1 -2
- package/dist/pollableAttributes/index.js +87 -177
- package/dist/pollableAttributes/models.js +1 -2
- package/dist/regions/index.js +72 -154
- package/dist/regions/models.js +1 -2
- package/dist/reports/index.js +88 -178
- package/dist/reports/models.js +1 -2
- package/dist/retryOptions/models.js +1 -2
- package/dist/rules/index.js +131 -245
- package/dist/rules/models.js +1 -2
- package/dist/scheduledJobs/index.js +183 -321
- package/dist/scheduledJobs/models.js +1 -2
- package/dist/secrets/index.js +88 -178
- package/dist/secrets/models.js +1 -2
- package/dist/settings/index.js +119 -227
- package/dist/settings/models.js +1 -2
- package/dist/settingsApplicationRecord/index.js +27 -65
- package/dist/settingsApplicationRecord/models.js +1 -2
- package/dist/softwareUpdates/index.js +194 -350
- package/dist/softwareUpdates/models.js +1 -2
- package/dist/stats/index.js +64 -126
- package/dist/stats/models.js +1 -2
- package/dist/systemCommandJobs/index.js +72 -154
- package/dist/systemCommandJobs/models.js +1 -2
- package/dist/systemCommands/index.js +87 -177
- package/dist/systemCommands/models.js +1 -2
- package/dist/testConstants.js +57 -71
- package/dist/translators/index.js +103 -201
- package/dist/translators/models.js +1 -2
- package/dist/userTypes/index.js +87 -177
- package/dist/userTypes/models.js +1 -2
- package/dist/users/index.js +149 -271
- package/dist/users/models.js +1 -2
- package/dist/workflowActions/index.js +132 -246
- package/dist/workflowActions/models.js +1 -2
- package/dist/workflowDefinitions/index.js +104 -202
- package/dist/workflowDefinitions/models.js +1 -2
- package/dist/workflowExecutions/index.js +27 -65
- package/dist/workflowExecutions/models.js +1 -2
- package/dist/workflows/index.js +39 -85
- package/dist/workflows/models.js +1 -2
- package/package.json +1 -1
package/dist/devices/index.js
CHANGED
|
@@ -1,30 +1,3 @@
|
|
|
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 __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -34,950 +7,636 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
8
|
});
|
|
36
9
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
op = body.call(thisArg, _);
|
|
60
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
10
|
+
import { EdgeIQAPI, } from '..';
|
|
11
|
+
import { Endpoints, getAttachMessage } from '../constants';
|
|
12
|
+
import { BaseModelClass } from '../core/ModelClass';
|
|
13
|
+
import { parseFilters } from '../filtersParser';
|
|
14
|
+
import { getReturnDeleteMessage, isApiError } from '../helpers';
|
|
15
|
+
export const Devices = class extends BaseModelClass {
|
|
16
|
+
static create(device) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
try {
|
|
19
|
+
this.logAction(`Creating device with unique ID: ${device}`);
|
|
20
|
+
const axios = EdgeIQAPI.getAxios();
|
|
21
|
+
const data = JSON.stringify(device);
|
|
22
|
+
const result = yield axios.post(Endpoints.device, data);
|
|
23
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
if (isApiError(error)) {
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
62
32
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
error_2 = _a.sent();
|
|
122
|
-
if ((0, helpers_1.isApiError)(error_2)) {
|
|
123
|
-
throw error_2;
|
|
124
|
-
}
|
|
125
|
-
throw error_2;
|
|
126
|
-
case 3: return [2];
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
};
|
|
131
|
-
class_1.update = function (device) {
|
|
132
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
133
|
-
var axios, data, result, error_3;
|
|
134
|
-
return __generator(this, function (_a) {
|
|
135
|
-
switch (_a.label) {
|
|
136
|
-
case 0:
|
|
137
|
-
_a.trys.push([0, 2, , 3]);
|
|
138
|
-
this.logAction("Updating device with unique ID: " + device.unique_id);
|
|
139
|
-
axios = __1.EdgeIQAPI.getAxios();
|
|
140
|
-
data = JSON.stringify(device);
|
|
141
|
-
return [4, axios.put(constants_1.Endpoints.device + "/" + device._id, data)];
|
|
142
|
-
case 1:
|
|
143
|
-
result = _a.sent();
|
|
144
|
-
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
145
|
-
case 2:
|
|
146
|
-
error_3 = _a.sent();
|
|
147
|
-
if ((0, helpers_1.isApiError)(error_3)) {
|
|
148
|
-
throw error_3;
|
|
149
|
-
}
|
|
150
|
-
throw error_3;
|
|
151
|
-
case 3: return [2];
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
class_1.deleteMetadata = function (id) {
|
|
157
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
158
|
-
var axios, result, error_4;
|
|
159
|
-
return __generator(this, function (_a) {
|
|
160
|
-
switch (_a.label) {
|
|
161
|
-
case 0:
|
|
162
|
-
_a.trys.push([0, 2, , 3]);
|
|
163
|
-
this.logAction("Delete device metadata with ID: " + id);
|
|
164
|
-
axios = __1.EdgeIQAPI.getAxios();
|
|
165
|
-
return [4, axios.put(constants_1.Endpoints.device + "/" + id, {
|
|
166
|
-
metadata: {},
|
|
167
|
-
})];
|
|
168
|
-
case 1:
|
|
169
|
-
result = _a.sent();
|
|
170
|
-
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
171
|
-
case 2:
|
|
172
|
-
error_4 = _a.sent();
|
|
173
|
-
if ((0, helpers_1.isApiError)(error_4)) {
|
|
174
|
-
throw error_4;
|
|
175
|
-
}
|
|
176
|
-
throw error_4;
|
|
177
|
-
case 3: return [2];
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
};
|
|
182
|
-
class_1.list = function (filters, pagination, boundingBox) {
|
|
33
|
+
static bulkCreate(uniqueIds, deviceTypeId, namePrefix) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
try {
|
|
36
|
+
this.logAction(`Creating ${uniqueIds.length} devices with device type id ${deviceTypeId} and name prefix '${namePrefix}'`);
|
|
37
|
+
const axios = EdgeIQAPI.getAxios();
|
|
38
|
+
const result = yield axios.post(`${Endpoints.device}/bulk`, {
|
|
39
|
+
data: {
|
|
40
|
+
unique_ids: uniqueIds,
|
|
41
|
+
device_type_id: deviceTypeId,
|
|
42
|
+
name_prefix: namePrefix,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (isApiError(error)) {
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
static update(device) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
try {
|
|
58
|
+
this.logAction(`Updating device with unique ID: ${device.unique_id}`);
|
|
59
|
+
const axios = EdgeIQAPI.getAxios();
|
|
60
|
+
const data = JSON.stringify(device);
|
|
61
|
+
const result = yield axios.put(`${Endpoints.device}/${device._id}`, data);
|
|
62
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (isApiError(error)) {
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
static deleteMetadata(id) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
try {
|
|
75
|
+
this.logAction(`Delete device metadata with ID: ${id}`);
|
|
76
|
+
const axios = EdgeIQAPI.getAxios();
|
|
77
|
+
const result = yield axios.put(`${Endpoints.device}/${id}`, {
|
|
78
|
+
metadata: {},
|
|
79
|
+
});
|
|
80
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (isApiError(error)) {
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
static list(filters, pagination, boundingBox) {
|
|
183
91
|
var _a, _b, _c, _d;
|
|
184
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
}
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
throw error_20;
|
|
592
|
-
case 3: return [2];
|
|
593
|
-
}
|
|
594
|
-
});
|
|
595
|
-
});
|
|
596
|
-
};
|
|
597
|
-
class_1.getLogs = function (id) {
|
|
598
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
599
|
-
var axios, result, error_21;
|
|
600
|
-
return __generator(this, function (_a) {
|
|
601
|
-
switch (_a.label) {
|
|
602
|
-
case 0:
|
|
603
|
-
_a.trys.push([0, 2, , 3]);
|
|
604
|
-
this.logAction("Getting logs attached to device with id " + id);
|
|
605
|
-
axios = __1.EdgeIQAPI.getAxios();
|
|
606
|
-
return [4, axios.get(constants_1.Endpoints.device + "/" + id + "/" + constants_1.Endpoints.logs)];
|
|
607
|
-
case 1:
|
|
608
|
-
result = _a.sent();
|
|
609
|
-
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
610
|
-
case 2:
|
|
611
|
-
error_21 = _a.sent();
|
|
612
|
-
if ((0, helpers_1.isApiError)(error_21)) {
|
|
613
|
-
throw error_21;
|
|
614
|
-
}
|
|
615
|
-
throw error_21;
|
|
616
|
-
case 3: return [2];
|
|
617
|
-
}
|
|
618
|
-
});
|
|
619
|
-
});
|
|
620
|
-
};
|
|
621
|
-
class_1.requestLogs = function (id) {
|
|
622
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
623
|
-
var axios, result, error_22;
|
|
624
|
-
return __generator(this, function (_a) {
|
|
625
|
-
switch (_a.label) {
|
|
626
|
-
case 0:
|
|
627
|
-
_a.trys.push([0, 2, , 3]);
|
|
628
|
-
this.logAction("requesting logs for device with " + id);
|
|
629
|
-
axios = __1.EdgeIQAPI.getAxios();
|
|
630
|
-
return [4, axios.post(constants_1.Endpoints.device + "/" + id + "/" + constants_1.Endpoints.gatewayCommand, {
|
|
631
|
-
command_type: 'log_upload',
|
|
632
|
-
schedule: null,
|
|
633
|
-
})];
|
|
634
|
-
case 1:
|
|
635
|
-
result = _a.sent();
|
|
636
|
-
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
637
|
-
case 2:
|
|
638
|
-
error_22 = _a.sent();
|
|
639
|
-
if ((0, helpers_1.isApiError)(error_22)) {
|
|
640
|
-
throw error_22;
|
|
641
|
-
}
|
|
642
|
-
throw error_22;
|
|
643
|
-
case 3: return [2];
|
|
644
|
-
}
|
|
645
|
-
});
|
|
646
|
-
});
|
|
647
|
-
};
|
|
648
|
-
class_1.deviceLwm2mObjetLinks = function (id) {
|
|
649
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
650
|
-
var axios, result, error_23;
|
|
651
|
-
return __generator(this, function (_a) {
|
|
652
|
-
switch (_a.label) {
|
|
653
|
-
case 0:
|
|
654
|
-
_a.trys.push([0, 2, , 3]);
|
|
655
|
-
this.logAction("Getting lwm2m object links attached to device with id " + id);
|
|
656
|
-
axios = __1.EdgeIQAPI.getAxios();
|
|
657
|
-
return [4, axios.get(constants_1.Endpoints.device + "/" + id + "/" + constants_1.Endpoints.deviceLwm2mObjetLinks)];
|
|
658
|
-
case 1:
|
|
659
|
-
result = _a.sent();
|
|
660
|
-
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
661
|
-
case 2:
|
|
662
|
-
error_23 = _a.sent();
|
|
663
|
-
if ((0, helpers_1.isApiError)(error_23)) {
|
|
664
|
-
throw error_23;
|
|
665
|
-
}
|
|
666
|
-
throw error_23;
|
|
667
|
-
case 3: return [2];
|
|
668
|
-
}
|
|
669
|
-
});
|
|
670
|
-
});
|
|
671
|
-
};
|
|
672
|
-
class_1.processGatewayCommand = function (deviceId, gatewayCommandRequest) {
|
|
673
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
674
|
-
var axios, data, result, error_24;
|
|
675
|
-
return __generator(this, function (_a) {
|
|
676
|
-
switch (_a.label) {
|
|
677
|
-
case 0:
|
|
678
|
-
_a.trys.push([0, 2, , 3]);
|
|
679
|
-
this.logAction("Process gateway command: " + gatewayCommandRequest.command_type + ", on device id: " + deviceId);
|
|
680
|
-
axios = __1.EdgeIQAPI.getAxios();
|
|
681
|
-
data = JSON.stringify(gatewayCommandRequest);
|
|
682
|
-
return [4, axios.post(constants_1.Endpoints.device + "/" + deviceId + "/" + gatewayCommandRequest.command_type, data)];
|
|
683
|
-
case 1:
|
|
684
|
-
result = _a.sent();
|
|
685
|
-
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
686
|
-
case 2:
|
|
687
|
-
error_24 = _a.sent();
|
|
688
|
-
if ((0, helpers_1.isApiError)(error_24)) {
|
|
689
|
-
throw error_24;
|
|
690
|
-
}
|
|
691
|
-
throw error_24;
|
|
692
|
-
case 3: return [2];
|
|
693
|
-
}
|
|
694
|
-
});
|
|
695
|
-
});
|
|
696
|
-
};
|
|
697
|
-
class_1.bulkExecuteGatewayCommand = function (ids, gatewayCommandRequest, generateChildCommandExecutions) {
|
|
698
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
699
|
-
var axios, result, error_25;
|
|
700
|
-
return __generator(this, function (_a) {
|
|
701
|
-
switch (_a.label) {
|
|
702
|
-
case 0:
|
|
703
|
-
_a.trys.push([0, 2, , 3]);
|
|
704
|
-
this.logAction("Execute " + gatewayCommandRequest.command_type + " command on devices with IDs: " + ids);
|
|
705
|
-
axios = __1.EdgeIQAPI.getAxios();
|
|
706
|
-
return [4, axios.post(constants_1.Endpoints.device + "/bulk/gateway_command", __assign(__assign({}, gatewayCommandRequest), { generate_child_command_executions: generateChildCommandExecutions !== null && generateChildCommandExecutions !== void 0 ? generateChildCommandExecutions : false, ids: ids }))];
|
|
707
|
-
case 1:
|
|
708
|
-
result = _a.sent();
|
|
709
|
-
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
710
|
-
case 2:
|
|
711
|
-
error_25 = _a.sent();
|
|
712
|
-
if ((0, helpers_1.isApiError)(error_25)) {
|
|
713
|
-
throw error_25;
|
|
714
|
-
}
|
|
715
|
-
throw error_25;
|
|
716
|
-
case 3: return [2];
|
|
717
|
-
}
|
|
718
|
-
});
|
|
719
|
-
});
|
|
720
|
-
};
|
|
721
|
-
class_1.bulkExecuteCommand = function (commandId, ids, options, generateChildCommandExecutions) {
|
|
722
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
723
|
-
var axios, data, result, error_26;
|
|
724
|
-
return __generator(this, function (_a) {
|
|
725
|
-
switch (_a.label) {
|
|
726
|
-
case 0:
|
|
727
|
-
_a.trys.push([0, 2, , 3]);
|
|
728
|
-
this.logAction("Execute command with ID: " + commandId + " on devices with IDs: " + ids);
|
|
729
|
-
axios = __1.EdgeIQAPI.getAxios();
|
|
730
|
-
data = {
|
|
731
|
-
ids: ids,
|
|
732
|
-
generate_child_command_executions: generateChildCommandExecutions !== null && generateChildCommandExecutions !== void 0 ? generateChildCommandExecutions : false,
|
|
733
|
-
};
|
|
734
|
-
return [4, axios.post(constants_1.Endpoints.device + "/bulk/commands/" + commandId + "/execute", options
|
|
735
|
-
? __assign(__assign({}, data), { options: options }) : __assign({}, data))];
|
|
736
|
-
case 1:
|
|
737
|
-
result = _a.sent();
|
|
738
|
-
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
739
|
-
case 2:
|
|
740
|
-
error_26 = _a.sent();
|
|
741
|
-
if ((0, helpers_1.isApiError)(error_26)) {
|
|
742
|
-
throw error_26;
|
|
743
|
-
}
|
|
744
|
-
throw error_26;
|
|
745
|
-
case 3: return [2];
|
|
746
|
-
}
|
|
747
|
-
});
|
|
748
|
-
});
|
|
749
|
-
};
|
|
750
|
-
class_1.getFiles = function (id) {
|
|
751
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
752
|
-
var axios, result, error_27;
|
|
753
|
-
return __generator(this, function (_a) {
|
|
754
|
-
switch (_a.label) {
|
|
755
|
-
case 0:
|
|
756
|
-
_a.trys.push([0, 2, , 3]);
|
|
757
|
-
this.logAction("Getting files attached to device with id " + id);
|
|
758
|
-
axios = __1.EdgeIQAPI.getAxios();
|
|
759
|
-
return [4, axios.get(constants_1.Endpoints.device + "/" + id + "/files")];
|
|
760
|
-
case 1:
|
|
761
|
-
result = _a.sent();
|
|
762
|
-
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
763
|
-
case 2:
|
|
764
|
-
error_27 = _a.sent();
|
|
765
|
-
if ((0, helpers_1.isApiError)(error_27)) {
|
|
766
|
-
throw error_27;
|
|
767
|
-
}
|
|
768
|
-
throw error_27;
|
|
769
|
-
case 3: return [2];
|
|
770
|
-
}
|
|
771
|
-
});
|
|
772
|
-
});
|
|
773
|
-
};
|
|
774
|
-
class_1.getCommandExecutions = function (id, filters, pagination) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
try {
|
|
94
|
+
this.logAction(`Listing devices with following filters: ${filters !== null && filters !== void 0 ? filters : '{}'}.\n And pagination ${pagination !== null && pagination !== void 0 ? pagination : '{}'}`);
|
|
95
|
+
let endpoint = Endpoints.device;
|
|
96
|
+
if ((boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.topLeft) && boundingBox.bottomRight) {
|
|
97
|
+
this.logAction(`With bounding box, top left: ${boundingBox.topLeft}, bottom right: ${boundingBox.bottomRight}`);
|
|
98
|
+
endpoint += `/in_bounding_box/${boundingBox.topLeft}/${boundingBox.bottomRight}`;
|
|
99
|
+
}
|
|
100
|
+
const axios = EdgeIQAPI.getAxios();
|
|
101
|
+
const result = yield axios.get(endpoint, {
|
|
102
|
+
params: parseFilters(filters, pagination),
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
devices: (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.resources,
|
|
106
|
+
pagination: {
|
|
107
|
+
page: (_b = result === null || result === void 0 ? void 0 : result.data) === null || _b === void 0 ? void 0 : _b.page,
|
|
108
|
+
itemsPerPage: (_c = result === null || result === void 0 ? void 0 : result.data) === null || _c === void 0 ? void 0 : _c.per_page,
|
|
109
|
+
total: (_d = result === null || result === void 0 ? void 0 : result.data) === null || _d === void 0 ? void 0 : _d.total,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (isApiError(error)) {
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
static getOneById(id) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
try {
|
|
124
|
+
this.logAction(`Getting device with id: ${id}`);
|
|
125
|
+
const axios = EdgeIQAPI.getAxios();
|
|
126
|
+
const result = yield axios.get(`${Endpoints.device}/${id}`);
|
|
127
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
if (isApiError(error)) {
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
static getOneByUniqueId(uniqueId) {
|
|
138
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
try {
|
|
140
|
+
this.logAction(`Getting device with Unique Id: ${uniqueId}`);
|
|
141
|
+
const axios = EdgeIQAPI.getAxios();
|
|
142
|
+
const result = yield axios.get(Endpoints.device, {
|
|
143
|
+
params: {
|
|
144
|
+
unique_id: uniqueId,
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
return result === null || result === void 0 ? void 0 : result.data[0];
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
if (isApiError(error)) {
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
static delete(id) {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
try {
|
|
160
|
+
this.logAction(`Deleting device with id ${id}`);
|
|
161
|
+
const axios = EdgeIQAPI.getAxios();
|
|
162
|
+
yield axios.delete(`${Endpoints.device}/${id}`);
|
|
163
|
+
return getReturnDeleteMessage('device');
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
if (isApiError(error)) {
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
throw error;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
static deleteMultiple(ids) {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
+
try {
|
|
176
|
+
this.logAction(`Deleting devices with id ${ids.join(', ')}`);
|
|
177
|
+
const axios = EdgeIQAPI.getAxios();
|
|
178
|
+
const result = yield axios.delete(`${Endpoints.device}/bulk`, {
|
|
179
|
+
data: { ids },
|
|
180
|
+
});
|
|
181
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
if (isApiError(error)) {
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
throw error;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
static attachIngestor(id, ingestorId) {
|
|
192
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
+
try {
|
|
194
|
+
this.logAction(`Attach ingestor with id: ${ingestorId} to device with id: ${id}`);
|
|
195
|
+
const axios = EdgeIQAPI.getAxios();
|
|
196
|
+
yield axios.put(`${Endpoints.device}/${id}/ingestors/${ingestorId}`);
|
|
197
|
+
return getAttachMessage('Ingestor', 'attach', 'device');
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
if (isApiError(error)) {
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
static detachIngestor(id, ingestorId) {
|
|
208
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
+
try {
|
|
210
|
+
this.logAction(`Detach ingestor with id: ${ingestorId} from device with id: ${id}`);
|
|
211
|
+
const axios = EdgeIQAPI.getAxios();
|
|
212
|
+
yield axios.delete(`${Endpoints.device}/${id}/ingestors/${ingestorId}`);
|
|
213
|
+
return getAttachMessage('Ingestor', 'detach', 'device');
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
if (isApiError(error)) {
|
|
217
|
+
throw error;
|
|
218
|
+
}
|
|
219
|
+
throw error;
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
static getIngestors(id) {
|
|
224
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
225
|
+
try {
|
|
226
|
+
this.logAction(`Getting ingestors attached to device with id ${id}`);
|
|
227
|
+
const axios = EdgeIQAPI.getAxios();
|
|
228
|
+
const result = yield axios.get(`${Endpoints.device}/${id}/ingestors`);
|
|
229
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
if (isApiError(error)) {
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
235
|
+
throw error;
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
static attachRule(id, ruleId) {
|
|
240
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
241
|
+
try {
|
|
242
|
+
this.logAction(`Attach rule with id: ${ruleId} to device with id: ${id}`);
|
|
243
|
+
const axios = EdgeIQAPI.getAxios();
|
|
244
|
+
yield axios.put(`${Endpoints.device}/${id}/rules/${ruleId}`);
|
|
245
|
+
return getAttachMessage('Rule', 'attach', 'device');
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
if (isApiError(error)) {
|
|
249
|
+
throw error;
|
|
250
|
+
}
|
|
251
|
+
throw error;
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
static bulkAttachRules(id, rulesIds) {
|
|
256
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
+
try {
|
|
258
|
+
this.logAction(`Attaching ${rulesIds.length} rules with to device with id ${id}`);
|
|
259
|
+
const axios = EdgeIQAPI.getAxios();
|
|
260
|
+
const result = yield axios.post(`${Endpoints.device}/${id}/rules/bulk`, {
|
|
261
|
+
ids: rulesIds,
|
|
262
|
+
});
|
|
263
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
if (isApiError(error)) {
|
|
267
|
+
throw error;
|
|
268
|
+
}
|
|
269
|
+
throw error;
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
static detachRule(id, ruleId) {
|
|
274
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
275
|
+
try {
|
|
276
|
+
this.logAction(`Detach rule with id: ${ruleId} from device with id: ${id}`);
|
|
277
|
+
const axios = EdgeIQAPI.getAxios();
|
|
278
|
+
yield axios.delete(`${Endpoints.device}/${id}/rules/${ruleId}`);
|
|
279
|
+
return getAttachMessage('Rule', 'detach', 'device');
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
if (isApiError(error)) {
|
|
283
|
+
throw error;
|
|
284
|
+
}
|
|
285
|
+
throw error;
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
static getRules(id) {
|
|
290
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
291
|
+
try {
|
|
292
|
+
this.logAction(`Getting rules attached to device with id ${id}`);
|
|
293
|
+
const axios = EdgeIQAPI.getAxios();
|
|
294
|
+
const result = yield axios.get(`${Endpoints.device}/${id}/rules`);
|
|
295
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
296
|
+
}
|
|
297
|
+
catch (error) {
|
|
298
|
+
if (isApiError(error)) {
|
|
299
|
+
throw error;
|
|
300
|
+
}
|
|
301
|
+
throw error;
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
static getAwsThingGroups(id) {
|
|
306
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
307
|
+
try {
|
|
308
|
+
this.logAction(`Getting AWS thing groups for device with id: ${id}`);
|
|
309
|
+
const axios = EdgeIQAPI.getAxios();
|
|
310
|
+
const result = yield axios.get(`${Endpoints.device}/${id}/aws_thing_groups`);
|
|
311
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
if (isApiError(error)) {
|
|
315
|
+
throw error;
|
|
316
|
+
}
|
|
317
|
+
throw error;
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
static getCommands(id) {
|
|
322
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
323
|
+
try {
|
|
324
|
+
this.logAction(`Getting commands attached to device with id ${id}`);
|
|
325
|
+
const axios = EdgeIQAPI.getAxios();
|
|
326
|
+
const result = yield axios.get(`${Endpoints.device}/${id}/${Endpoints.command}`);
|
|
327
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
328
|
+
}
|
|
329
|
+
catch (error) {
|
|
330
|
+
if (isApiError(error)) {
|
|
331
|
+
throw error;
|
|
332
|
+
}
|
|
333
|
+
throw error;
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
static csvBulkUpload(file) {
|
|
338
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
339
|
+
try {
|
|
340
|
+
this.logAction(`Uploading CSV file with devices`);
|
|
341
|
+
const axios = EdgeIQAPI.getAxios();
|
|
342
|
+
const form = new FormData();
|
|
343
|
+
form.append('gateway_csv_upload', file);
|
|
344
|
+
const result = yield axios.post(`${Endpoints.device}/csv_bulk_upload`, form, {
|
|
345
|
+
headers: {
|
|
346
|
+
'Content-Type': 'multipart/form-data',
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
350
|
+
}
|
|
351
|
+
catch (error) {
|
|
352
|
+
if (isApiError(error)) {
|
|
353
|
+
throw error;
|
|
354
|
+
}
|
|
355
|
+
throw error;
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
static csvBulkDownload(filters) {
|
|
360
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
361
|
+
try {
|
|
362
|
+
this.logAction(`Listing devices with following filters: ${filters !== null && filters !== void 0 ? filters : '{}'}`);
|
|
363
|
+
const axios = EdgeIQAPI.getAxios();
|
|
364
|
+
const result = yield axios.get(`${Endpoints.device}/csv_bulk_download`, {
|
|
365
|
+
params: parseFilters(filters, undefined, true),
|
|
366
|
+
});
|
|
367
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
368
|
+
}
|
|
369
|
+
catch (error) {
|
|
370
|
+
if (isApiError(error)) {
|
|
371
|
+
throw error;
|
|
372
|
+
}
|
|
373
|
+
throw error;
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
static getLogs(id) {
|
|
378
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
379
|
+
try {
|
|
380
|
+
this.logAction(`Getting logs attached to device with id ${id}`);
|
|
381
|
+
const axios = EdgeIQAPI.getAxios();
|
|
382
|
+
const result = yield axios.get(`${Endpoints.device}/${id}/${Endpoints.logs}`);
|
|
383
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
384
|
+
}
|
|
385
|
+
catch (error) {
|
|
386
|
+
if (isApiError(error)) {
|
|
387
|
+
throw error;
|
|
388
|
+
}
|
|
389
|
+
throw error;
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
static requestLogs(id) {
|
|
394
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
395
|
+
try {
|
|
396
|
+
this.logAction(`requesting logs for device with ${id}`);
|
|
397
|
+
const axios = EdgeIQAPI.getAxios();
|
|
398
|
+
const result = yield axios.post(`${Endpoints.device}/${id}/${Endpoints.gatewayCommand}`, {
|
|
399
|
+
command_type: 'log_upload',
|
|
400
|
+
schedule: null,
|
|
401
|
+
});
|
|
402
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
403
|
+
}
|
|
404
|
+
catch (error) {
|
|
405
|
+
if (isApiError(error)) {
|
|
406
|
+
throw error;
|
|
407
|
+
}
|
|
408
|
+
throw error;
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
static deviceLwm2mObjetLinks(id) {
|
|
413
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
414
|
+
try {
|
|
415
|
+
this.logAction(`Getting lwm2m object links attached to device with id ${id}`);
|
|
416
|
+
const axios = EdgeIQAPI.getAxios();
|
|
417
|
+
const result = yield axios.get(`${Endpoints.device}/${id}/${Endpoints.deviceLwm2mObjetLinks}`);
|
|
418
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
419
|
+
}
|
|
420
|
+
catch (error) {
|
|
421
|
+
if (isApiError(error)) {
|
|
422
|
+
throw error;
|
|
423
|
+
}
|
|
424
|
+
throw error;
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
static processGatewayCommand(deviceId, gatewayCommandRequest) {
|
|
429
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
430
|
+
try {
|
|
431
|
+
this.logAction(`Process gateway command: ${gatewayCommandRequest.command_type}, on device id: ${deviceId}`);
|
|
432
|
+
const axios = EdgeIQAPI.getAxios();
|
|
433
|
+
const data = JSON.stringify(gatewayCommandRequest);
|
|
434
|
+
const result = yield axios.post(`${Endpoints.device}/${deviceId}/${gatewayCommandRequest.command_type}`, data);
|
|
435
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
436
|
+
}
|
|
437
|
+
catch (error) {
|
|
438
|
+
if (isApiError(error)) {
|
|
439
|
+
throw error;
|
|
440
|
+
}
|
|
441
|
+
throw error;
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
static bulkExecuteGatewayCommand(ids, gatewayCommandRequest, generateChildCommandExecutions) {
|
|
446
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
447
|
+
try {
|
|
448
|
+
this.logAction(`Execute ${gatewayCommandRequest.command_type} command on devices with IDs: ${ids}`);
|
|
449
|
+
const axios = EdgeIQAPI.getAxios();
|
|
450
|
+
const result = yield axios.post(`${Endpoints.device}/bulk/gateway_command`, Object.assign(Object.assign({}, gatewayCommandRequest), { generate_child_command_executions: generateChildCommandExecutions !== null && generateChildCommandExecutions !== void 0 ? generateChildCommandExecutions : false, ids }));
|
|
451
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
452
|
+
}
|
|
453
|
+
catch (error) {
|
|
454
|
+
if (isApiError(error)) {
|
|
455
|
+
throw error;
|
|
456
|
+
}
|
|
457
|
+
throw error;
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
static bulkExecuteCommand(commandId, ids, options, generateChildCommandExecutions) {
|
|
462
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
463
|
+
try {
|
|
464
|
+
this.logAction(`Execute command with ID: ${commandId} on devices with IDs: ${ids}`);
|
|
465
|
+
const axios = EdgeIQAPI.getAxios();
|
|
466
|
+
const data = {
|
|
467
|
+
ids,
|
|
468
|
+
generate_child_command_executions: generateChildCommandExecutions !== null && generateChildCommandExecutions !== void 0 ? generateChildCommandExecutions : false,
|
|
469
|
+
};
|
|
470
|
+
const result = yield axios.post(`${Endpoints.device}/bulk/commands/${commandId}/execute`, options
|
|
471
|
+
? Object.assign(Object.assign({}, data), { options }) : Object.assign({}, data));
|
|
472
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
473
|
+
}
|
|
474
|
+
catch (error) {
|
|
475
|
+
if (isApiError(error)) {
|
|
476
|
+
throw error;
|
|
477
|
+
}
|
|
478
|
+
throw error;
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
static getFiles(id) {
|
|
483
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
484
|
+
try {
|
|
485
|
+
this.logAction(`Getting files attached to device with id ${id}`);
|
|
486
|
+
const axios = EdgeIQAPI.getAxios();
|
|
487
|
+
const result = yield axios.get(`${Endpoints.device}/${id}/files`);
|
|
488
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
489
|
+
}
|
|
490
|
+
catch (error) {
|
|
491
|
+
if (isApiError(error)) {
|
|
492
|
+
throw error;
|
|
493
|
+
}
|
|
494
|
+
throw error;
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
static getCommandExecutions(id, filters, pagination) {
|
|
775
499
|
var _a, _b, _c, _d;
|
|
776
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
}
|
|
832
|
-
});
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
}
|
|
880
|
-
});
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
case 2:
|
|
920
|
-
error_33 = _a.sent();
|
|
921
|
-
if ((0, helpers_1.isApiError)(error_33)) {
|
|
922
|
-
throw error_33;
|
|
923
|
-
}
|
|
924
|
-
throw error_33;
|
|
925
|
-
case 3: return [2];
|
|
926
|
-
}
|
|
927
|
-
});
|
|
928
|
-
});
|
|
929
|
-
};
|
|
930
|
-
class_1.dryRunCommand = function (id, commandId, data) {
|
|
931
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
932
|
-
var axios, result, error_34;
|
|
933
|
-
return __generator(this, function (_a) {
|
|
934
|
-
switch (_a.label) {
|
|
935
|
-
case 0:
|
|
936
|
-
_a.trys.push([0, 2, , 3]);
|
|
937
|
-
this.logAction("Dry run command " + commandId + " on device " + id);
|
|
938
|
-
axios = __1.EdgeIQAPI.getAxios();
|
|
939
|
-
return [4, axios.post(constants_1.Endpoints.device + "/" + id + "/commands/" + commandId + "/dry-run", data)];
|
|
940
|
-
case 1:
|
|
941
|
-
result = _a.sent();
|
|
942
|
-
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
943
|
-
case 2:
|
|
944
|
-
error_34 = _a.sent();
|
|
945
|
-
if ((0, helpers_1.isApiError)(error_34)) {
|
|
946
|
-
throw error_34;
|
|
947
|
-
}
|
|
948
|
-
throw error_34;
|
|
949
|
-
case 3: return [2];
|
|
950
|
-
}
|
|
951
|
-
});
|
|
952
|
-
});
|
|
953
|
-
};
|
|
954
|
-
class_1.bulkExecuteWorkflow = function (workflowId, ids) {
|
|
955
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
956
|
-
var axios, data, result, error_35;
|
|
957
|
-
return __generator(this, function (_a) {
|
|
958
|
-
switch (_a.label) {
|
|
959
|
-
case 0:
|
|
960
|
-
_a.trys.push([0, 2, , 3]);
|
|
961
|
-
this.logAction("Execute workflow with ID: " + workflowId + " on devices with IDs: " + ids);
|
|
962
|
-
axios = __1.EdgeIQAPI.getAxios();
|
|
963
|
-
data = {
|
|
964
|
-
ids: ids,
|
|
965
|
-
definition_id: workflowId,
|
|
966
|
-
};
|
|
967
|
-
return [4, axios.post(constants_1.Endpoints.device + "/bulk_workflow", __assign({}, data))];
|
|
968
|
-
case 1:
|
|
969
|
-
result = _a.sent();
|
|
970
|
-
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
971
|
-
case 2:
|
|
972
|
-
error_35 = _a.sent();
|
|
973
|
-
if ((0, helpers_1.isApiError)(error_35)) {
|
|
974
|
-
throw error_35;
|
|
975
|
-
}
|
|
976
|
-
throw error_35;
|
|
977
|
-
case 3: return [2];
|
|
978
|
-
}
|
|
979
|
-
});
|
|
980
|
-
});
|
|
981
|
-
};
|
|
982
|
-
return class_1;
|
|
983
|
-
}(ModelClass_1.BaseModelClass));
|
|
500
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
501
|
+
try {
|
|
502
|
+
this.logAction(`Getting command executions attached to device with id ${id}`);
|
|
503
|
+
const axios = EdgeIQAPI.getAxios();
|
|
504
|
+
const result = yield axios.get(`${Endpoints.command}/${id}/command_executions`, {
|
|
505
|
+
params: parseFilters(filters, pagination),
|
|
506
|
+
});
|
|
507
|
+
return {
|
|
508
|
+
commandExecutions: (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.resources,
|
|
509
|
+
pagination: {
|
|
510
|
+
page: (_b = result === null || result === void 0 ? void 0 : result.data) === null || _b === void 0 ? void 0 : _b.page,
|
|
511
|
+
itemsPerPage: (_c = result === null || result === void 0 ? void 0 : result.data) === null || _c === void 0 ? void 0 : _c.per_page,
|
|
512
|
+
total: (_d = result === null || result === void 0 ? void 0 : result.data) === null || _d === void 0 ? void 0 : _d.total,
|
|
513
|
+
},
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
catch (error) {
|
|
517
|
+
if (isApiError(error)) {
|
|
518
|
+
throw error;
|
|
519
|
+
}
|
|
520
|
+
throw error;
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
static startRemoteTerminal(id, executable) {
|
|
525
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
526
|
+
try {
|
|
527
|
+
this.logAction(`Start remote terminal with device: ${id}`);
|
|
528
|
+
const axios = EdgeIQAPI.getAxios();
|
|
529
|
+
yield axios.post(`${Endpoints.device}/${id}/start_remote_terminal`, {
|
|
530
|
+
executable: executable !== null && executable !== void 0 ? executable : 'sh',
|
|
531
|
+
});
|
|
532
|
+
return `Remote terminal started for device: ${id}`;
|
|
533
|
+
}
|
|
534
|
+
catch (error) {
|
|
535
|
+
if (isApiError(error)) {
|
|
536
|
+
throw error;
|
|
537
|
+
}
|
|
538
|
+
throw error;
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
static stopRemoteTerminal(id) {
|
|
543
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
544
|
+
try {
|
|
545
|
+
this.logAction(`Stops remote terminal with device: ${id}`);
|
|
546
|
+
const axios = EdgeIQAPI.getAxios();
|
|
547
|
+
yield axios.post(`${Endpoints.device}/${id}/stop_remote_terminal`);
|
|
548
|
+
return `Remote terminal stoped for device: ${id}`;
|
|
549
|
+
}
|
|
550
|
+
catch (error) {
|
|
551
|
+
if (isApiError(error)) {
|
|
552
|
+
throw error;
|
|
553
|
+
}
|
|
554
|
+
throw error;
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
static getSettings(id, configId) {
|
|
559
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
560
|
+
try {
|
|
561
|
+
this.logAction(`Getting settings attached to device with id ${id}`);
|
|
562
|
+
const axios = EdgeIQAPI.getAxios();
|
|
563
|
+
const result = yield axios.get(`${Endpoints.device}/${id}/${Endpoints.setting}${configId ? `?configuration_id=${configId}` : ''}`);
|
|
564
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
565
|
+
}
|
|
566
|
+
catch (error) {
|
|
567
|
+
if (isApiError(error)) {
|
|
568
|
+
throw error;
|
|
569
|
+
}
|
|
570
|
+
throw error;
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
static attachSettings(id, sttingsId) {
|
|
575
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
576
|
+
try {
|
|
577
|
+
this.logAction(`Attach settings with id: ${sttingsId} to device with id: ${id}`);
|
|
578
|
+
const axios = EdgeIQAPI.getAxios();
|
|
579
|
+
yield axios.put(`${Endpoints.device}/${id}/settings/${sttingsId}`);
|
|
580
|
+
return getAttachMessage('Settings', 'attach', 'device');
|
|
581
|
+
}
|
|
582
|
+
catch (error) {
|
|
583
|
+
if (isApiError(error)) {
|
|
584
|
+
throw error;
|
|
585
|
+
}
|
|
586
|
+
throw error;
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
static detachSettings(id, sttingsId) {
|
|
591
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
592
|
+
try {
|
|
593
|
+
this.logAction(`Detach settings with id: ${sttingsId} from device with id: ${id}`);
|
|
594
|
+
const axios = EdgeIQAPI.getAxios();
|
|
595
|
+
yield axios.delete(`${Endpoints.device}/${id}/settings/${sttingsId}`);
|
|
596
|
+
return getAttachMessage('Settings', 'detach', 'device');
|
|
597
|
+
}
|
|
598
|
+
catch (error) {
|
|
599
|
+
if (isApiError(error)) {
|
|
600
|
+
throw error;
|
|
601
|
+
}
|
|
602
|
+
throw error;
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
static dryRunCommand(id, commandId, data) {
|
|
607
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
608
|
+
try {
|
|
609
|
+
this.logAction(`Dry run command ${commandId} on device ${id}`);
|
|
610
|
+
const axios = EdgeIQAPI.getAxios();
|
|
611
|
+
const result = yield axios.post(`${Endpoints.device}/${id}/commands/${commandId}/dry-run`, data);
|
|
612
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
613
|
+
}
|
|
614
|
+
catch (error) {
|
|
615
|
+
if (isApiError(error)) {
|
|
616
|
+
throw error;
|
|
617
|
+
}
|
|
618
|
+
throw error;
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
static bulkExecuteWorkflow(workflowId, ids) {
|
|
623
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
624
|
+
try {
|
|
625
|
+
this.logAction(`Execute workflow with ID: ${workflowId} on devices with IDs: ${ids}`);
|
|
626
|
+
const axios = EdgeIQAPI.getAxios();
|
|
627
|
+
const data = {
|
|
628
|
+
ids,
|
|
629
|
+
definition_id: workflowId,
|
|
630
|
+
};
|
|
631
|
+
const result = yield axios.post(`${Endpoints.device}/bulk_workflow`, Object.assign({}, data));
|
|
632
|
+
return result === null || result === void 0 ? void 0 : result.data;
|
|
633
|
+
}
|
|
634
|
+
catch (error) {
|
|
635
|
+
if (isApiError(error)) {
|
|
636
|
+
throw error;
|
|
637
|
+
}
|
|
638
|
+
throw error;
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
};
|