@edgeiq/edgeiq-api-js 1.1.1 → 1.1.5
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/devices/index.d.ts +2 -0
- package/dist/devices/index.js +66 -10
- package/dist/devices/models.d.ts +1 -0
- package/dist/escrowDevices/models.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/stats/index.d.ts +3 -2
- package/dist/stats/index.js +9 -4
- package/package.json +1 -1
package/dist/devices/index.d.ts
CHANGED
|
@@ -11,8 +11,10 @@ interface DevicesInterface extends BaseModelInterface<Device, DeviceInput, Devic
|
|
|
11
11
|
detachIngestor(id: string, ingestorId: string): Promise<string>;
|
|
12
12
|
getIngestors(id: string): Promise<Ingestor[]>;
|
|
13
13
|
attachRule(id: string, ruleId: string): Promise<string>;
|
|
14
|
+
bulkAttachRules(id: string, rulesIds: string[]): Promise<BulkActionResponse>;
|
|
14
15
|
detachRule(id: string, ruleId: string): Promise<string>;
|
|
15
16
|
getRules(id: string): Promise<Rule[]>;
|
|
17
|
+
csvBulkUpload(file: File): Promise<BulkActionResponse>;
|
|
16
18
|
}
|
|
17
19
|
export declare const Devices: DevicesInterface;
|
|
18
20
|
export {};
|
package/dist/devices/index.js
CHANGED
|
@@ -379,9 +379,35 @@ exports.Devices = (function (_super) {
|
|
|
379
379
|
});
|
|
380
380
|
});
|
|
381
381
|
};
|
|
382
|
+
class_1.bulkAttachRules = function (id, rulesIds) {
|
|
383
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
384
|
+
var axios, result, error_13;
|
|
385
|
+
return __generator(this, function (_a) {
|
|
386
|
+
switch (_a.label) {
|
|
387
|
+
case 0:
|
|
388
|
+
_a.trys.push([0, 2, , 3]);
|
|
389
|
+
this.logAction("Attaching " + rulesIds.length + " rules with to device with id " + id);
|
|
390
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
391
|
+
return [4, axios.post(constants_1.Endpoints.device + "/" + id + "/rules/bulk", {
|
|
392
|
+
data: { ids: rulesIds },
|
|
393
|
+
})];
|
|
394
|
+
case 1:
|
|
395
|
+
result = _a.sent();
|
|
396
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
397
|
+
case 2:
|
|
398
|
+
error_13 = _a.sent();
|
|
399
|
+
if ((0, helpers_1.isApiError)(error_13)) {
|
|
400
|
+
throw error_13;
|
|
401
|
+
}
|
|
402
|
+
throw error_13;
|
|
403
|
+
case 3: return [2];
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
};
|
|
382
408
|
class_1.detachRule = function (id, ruleId) {
|
|
383
409
|
return __awaiter(this, void 0, void 0, function () {
|
|
384
|
-
var axios,
|
|
410
|
+
var axios, error_14;
|
|
385
411
|
return __generator(this, function (_a) {
|
|
386
412
|
switch (_a.label) {
|
|
387
413
|
case 0:
|
|
@@ -393,11 +419,11 @@ exports.Devices = (function (_super) {
|
|
|
393
419
|
_a.sent();
|
|
394
420
|
return [2, (0, constants_1.getAttachMessage)('Rule', 'detach', 'device')];
|
|
395
421
|
case 2:
|
|
396
|
-
|
|
397
|
-
if ((0, helpers_1.isApiError)(
|
|
398
|
-
throw
|
|
422
|
+
error_14 = _a.sent();
|
|
423
|
+
if ((0, helpers_1.isApiError)(error_14)) {
|
|
424
|
+
throw error_14;
|
|
399
425
|
}
|
|
400
|
-
throw
|
|
426
|
+
throw error_14;
|
|
401
427
|
case 3: return [2];
|
|
402
428
|
}
|
|
403
429
|
});
|
|
@@ -405,7 +431,7 @@ exports.Devices = (function (_super) {
|
|
|
405
431
|
};
|
|
406
432
|
class_1.getRules = function (id) {
|
|
407
433
|
return __awaiter(this, void 0, void 0, function () {
|
|
408
|
-
var axios, result,
|
|
434
|
+
var axios, result, error_15;
|
|
409
435
|
return __generator(this, function (_a) {
|
|
410
436
|
switch (_a.label) {
|
|
411
437
|
case 0:
|
|
@@ -417,11 +443,41 @@ exports.Devices = (function (_super) {
|
|
|
417
443
|
result = _a.sent();
|
|
418
444
|
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
419
445
|
case 2:
|
|
420
|
-
|
|
421
|
-
if ((0, helpers_1.isApiError)(
|
|
422
|
-
throw
|
|
446
|
+
error_15 = _a.sent();
|
|
447
|
+
if ((0, helpers_1.isApiError)(error_15)) {
|
|
448
|
+
throw error_15;
|
|
423
449
|
}
|
|
424
|
-
throw
|
|
450
|
+
throw error_15;
|
|
451
|
+
case 3: return [2];
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
});
|
|
455
|
+
};
|
|
456
|
+
class_1.csvBulkUpload = function (file) {
|
|
457
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
458
|
+
var axios, form, result, error_16;
|
|
459
|
+
return __generator(this, function (_a) {
|
|
460
|
+
switch (_a.label) {
|
|
461
|
+
case 0:
|
|
462
|
+
_a.trys.push([0, 2, , 3]);
|
|
463
|
+
this.logAction("Uploading CSV file with devices");
|
|
464
|
+
axios = __1.EdgeIQAPI.getAxios();
|
|
465
|
+
form = new FormData();
|
|
466
|
+
form.append('gateway_csv_upload', file);
|
|
467
|
+
return [4, axios.post(constants_1.Endpoints.device + "/csv_bulk_upload", form, {
|
|
468
|
+
headers: {
|
|
469
|
+
'Content-Type': 'multipart/form-data',
|
|
470
|
+
},
|
|
471
|
+
})];
|
|
472
|
+
case 1:
|
|
473
|
+
result = _a.sent();
|
|
474
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
475
|
+
case 2:
|
|
476
|
+
error_16 = _a.sent();
|
|
477
|
+
if ((0, helpers_1.isApiError)(error_16)) {
|
|
478
|
+
throw error_16;
|
|
479
|
+
}
|
|
480
|
+
throw error_16;
|
|
425
481
|
case 3: return [2];
|
|
426
482
|
}
|
|
427
483
|
});
|
package/dist/devices/models.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export { Reports } from './reports';
|
|
|
20
20
|
export { Rules } from './rules';
|
|
21
21
|
export { Secrets } from './secrets';
|
|
22
22
|
export { SoftwareUpdates } from './softwareUpdates';
|
|
23
|
+
export { Stats } from './stats';
|
|
23
24
|
export { SystemCommands } from './systemCommands';
|
|
24
25
|
export { SystemCommandJobs } from './systemCommandJobs';
|
|
25
26
|
export { Translators } from './translators';
|
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.SoftwareUpdates = exports.Secrets = exports.Rules = exports.Reports = exports.Regions = exports.PollableAttributes = exports.Integrations = exports.Ingestors = exports.GatewayCommands = exports.EscrowDevices = exports.DownstreamSystems = exports.DeviceTypes = exports.DeviceTransferRequests = exports.DeviceTemplates = exports.Devices = exports.DeviceLocationObservations = exports.DeviceConfigs = exports.Companies = exports.Commands = exports.BulkResponses = exports.Authentication = exports.EdgeIQAPI = void 0;
|
|
13
|
+
exports.UserTypes = exports.Users = exports.Translators = exports.SystemCommandJobs = exports.SystemCommands = exports.Stats = exports.SoftwareUpdates = exports.Secrets = exports.Rules = exports.Reports = exports.Regions = exports.PollableAttributes = exports.Integrations = exports.Ingestors = exports.GatewayCommands = exports.EscrowDevices = exports.DownstreamSystems = exports.DeviceTypes = exports.DeviceTransferRequests = exports.DeviceTemplates = exports.Devices = exports.DeviceLocationObservations = exports.DeviceConfigs = 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");
|
|
@@ -55,6 +55,8 @@ var secrets_1 = require("./secrets");
|
|
|
55
55
|
Object.defineProperty(exports, "Secrets", { enumerable: true, get: function () { return secrets_1.Secrets; } });
|
|
56
56
|
var softwareUpdates_1 = require("./softwareUpdates");
|
|
57
57
|
Object.defineProperty(exports, "SoftwareUpdates", { enumerable: true, get: function () { return softwareUpdates_1.SoftwareUpdates; } });
|
|
58
|
+
var stats_1 = require("./stats");
|
|
59
|
+
Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return stats_1.Stats; } });
|
|
58
60
|
var systemCommands_1 = require("./systemCommands");
|
|
59
61
|
Object.defineProperty(exports, "SystemCommands", { enumerable: true, get: function () { return systemCommands_1.SystemCommands; } });
|
|
60
62
|
var systemCommandJobs_1 = require("./systemCommandJobs");
|
package/dist/stats/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { DevicesFilters } from '..';
|
|
1
2
|
import { CumulativeCellUsage, DevicesCountByHeartbeat, DevicesCountByType } from './models';
|
|
2
3
|
declare const Stats: {
|
|
3
|
-
devicesByHeartbeat: () => Promise<DevicesCountByHeartbeat>;
|
|
4
|
-
devicesByType: () => Promise<DevicesCountByType>;
|
|
4
|
+
devicesByHeartbeat: (filters?: DevicesFilters | undefined) => Promise<DevicesCountByHeartbeat>;
|
|
5
|
+
devicesByType: (filters?: DevicesFilters | undefined) => Promise<DevicesCountByType>;
|
|
5
6
|
cellUsage: () => Promise<CumulativeCellUsage>;
|
|
6
7
|
};
|
|
7
8
|
export { Stats };
|
package/dist/stats/index.js
CHANGED
|
@@ -40,8 +40,9 @@ exports.Stats = void 0;
|
|
|
40
40
|
var __1 = require("..");
|
|
41
41
|
var constants_1 = require("../constants");
|
|
42
42
|
var helpers_1 = require("../helpers");
|
|
43
|
+
var filtersParser_1 = require("../filtersParser");
|
|
43
44
|
var Stats = {
|
|
44
|
-
devicesByHeartbeat: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
+
devicesByHeartbeat: function (filters) { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
46
|
var axios, result, error_1;
|
|
46
47
|
return __generator(this, function (_a) {
|
|
47
48
|
switch (_a.label) {
|
|
@@ -49,7 +50,9 @@ var Stats = {
|
|
|
49
50
|
_a.trys.push([0, 2, , 3]);
|
|
50
51
|
__1.EdgeIQAPI.logAction("Getting devices count by heartbeat status");
|
|
51
52
|
axios = __1.EdgeIQAPI.getAxios();
|
|
52
|
-
return [4, axios.get(constants_1.Endpoints.statsDevicesByHeartbeat
|
|
53
|
+
return [4, axios.get(constants_1.Endpoints.statsDevicesByHeartbeat, {
|
|
54
|
+
params: (0, filtersParser_1.parseFilters)(filters),
|
|
55
|
+
})];
|
|
53
56
|
case 1:
|
|
54
57
|
result = _a.sent();
|
|
55
58
|
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
@@ -63,7 +66,7 @@ var Stats = {
|
|
|
63
66
|
}
|
|
64
67
|
});
|
|
65
68
|
}); },
|
|
66
|
-
devicesByType: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
69
|
+
devicesByType: function (filters) { return __awaiter(void 0, void 0, void 0, function () {
|
|
67
70
|
var axios, result, error_2;
|
|
68
71
|
return __generator(this, function (_a) {
|
|
69
72
|
switch (_a.label) {
|
|
@@ -71,7 +74,9 @@ var Stats = {
|
|
|
71
74
|
_a.trys.push([0, 2, , 3]);
|
|
72
75
|
__1.EdgeIQAPI.logAction("Getting devices count by type");
|
|
73
76
|
axios = __1.EdgeIQAPI.getAxios();
|
|
74
|
-
return [4, axios.get(constants_1.Endpoints.statsDevicesByType
|
|
77
|
+
return [4, axios.get(constants_1.Endpoints.statsDevicesByType, {
|
|
78
|
+
params: (0, filtersParser_1.parseFilters)(filters),
|
|
79
|
+
})];
|
|
75
80
|
case 1:
|
|
76
81
|
result = _a.sent();
|
|
77
82
|
return [2, result === null || result === void 0 ? void 0 : result.data];
|