@edgeiq/edgeiq-api-js 1.7.5 → 1.7.7

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.
Files changed (115) hide show
  1. package/dist/OIDC/index.js +137 -238
  2. package/dist/OIDC/models.js +1 -2
  3. package/dist/__tests__/auth.test.js +56 -147
  4. package/dist/__tests__/command.test.js +80 -202
  5. package/dist/__tests__/companies.test.js +121 -269
  6. package/dist/__tests__/deviceErrors.test.js +16 -62
  7. package/dist/__tests__/deviceTypes.test.js +78 -200
  8. package/dist/__tests__/devices.test.js +84 -221
  9. package/dist/__tests__/discoveredDevice.test.js +57 -145
  10. package/dist/__tests__/files.test.js +58 -152
  11. package/dist/__tests__/ingestors.test.js +70 -188
  12. package/dist/__tests__/integrations.test.js +95 -235
  13. package/dist/__tests__/lwm2m.test.js +17 -62
  14. package/dist/__tests__/notifications.test.js +16 -62
  15. package/dist/__tests__/pollableAttributes.test.js +60 -162
  16. package/dist/__tests__/rules.test.js +60 -162
  17. package/dist/__tests__/scheduledJobs.test.js +60 -162
  18. package/dist/__tests__/translators.test.js +60 -162
  19. package/dist/__tests__/users.test.js +77 -197
  20. package/dist/auth/index.js +94 -167
  21. package/dist/bulkResponses/index.js +44 -110
  22. package/dist/bulkResponses/models.js +1 -2
  23. package/dist/commandExecutions/index.js +39 -85
  24. package/dist/commandExecutions/models.d.ts +3 -0
  25. package/dist/commandExecutions/models.js +1 -2
  26. package/dist/commands/index.d.ts +2 -2
  27. package/dist/commands/index.js +196 -342
  28. package/dist/commands/models.js +2 -5
  29. package/dist/companies/index.js +150 -272
  30. package/dist/companies/models.js +1 -2
  31. package/dist/configurations/index.js +172 -310
  32. package/dist/configurations/models.js +1 -2
  33. package/dist/constants.js +69 -85
  34. package/dist/core/ModelClass.js +11 -18
  35. package/dist/core/handleResponseError.js +77 -81
  36. package/dist/core/index.js +30 -38
  37. package/dist/deviceConfigs/index.js +103 -201
  38. package/dist/deviceConfigs/models.js +1 -2
  39. package/dist/deviceErrors/index.js +44 -110
  40. package/dist/deviceErrors/models.js +1 -2
  41. package/dist/deviceLocationObservations/index.js +82 -164
  42. package/dist/deviceLocationObservations/models.js +1 -2
  43. package/dist/deviceTemplates/index.js +105 -203
  44. package/dist/deviceTemplates/models.js +1 -2
  45. package/dist/deviceTransferRequests/index.js +116 -222
  46. package/dist/deviceTransferRequests/models.js +1 -2
  47. package/dist/deviceTypes/index.js +328 -554
  48. package/dist/deviceTypes/models.js +1 -2
  49. package/dist/devices/index.js +630 -971
  50. package/dist/devices/models.js +1 -2
  51. package/dist/discoveredDevices/index.js +190 -328
  52. package/dist/discoveredDevices/models.js +1 -2
  53. package/dist/downstreamSystems/index.js +87 -177
  54. package/dist/downstreamSystems/models.js +1 -2
  55. package/dist/escrowDevices/index.js +103 -201
  56. package/dist/escrowDevices/models.js +1 -2
  57. package/dist/files/index.js +137 -251
  58. package/dist/files/models.js +1 -2
  59. package/dist/filtersParser.js +12 -17
  60. package/dist/gatewayCommands/index.js +103 -201
  61. package/dist/gatewayCommands/models.js +1 -2
  62. package/dist/helpers.js +10 -16
  63. package/dist/index.js +86 -142
  64. package/dist/ingestors/index.js +103 -201
  65. package/dist/ingestors/models.js +1 -2
  66. package/dist/integrations/index.js +159 -273
  67. package/dist/integrations/models.js +1 -2
  68. package/dist/log/models.js +1 -2
  69. package/dist/lwm2m/index.js +23 -72
  70. package/dist/lwm2m/models.js +1 -2
  71. package/dist/models/index.js +1 -2
  72. package/dist/models.js +1 -2
  73. package/dist/notifications/index.js +44 -110
  74. package/dist/notifications/models.js +1 -2
  75. package/dist/pollableAttributes/index.js +87 -177
  76. package/dist/pollableAttributes/models.js +1 -2
  77. package/dist/regions/index.js +72 -154
  78. package/dist/regions/models.js +1 -2
  79. package/dist/reports/index.js +88 -178
  80. package/dist/reports/models.js +1 -2
  81. package/dist/retryOptions/models.js +1 -2
  82. package/dist/rules/index.js +131 -245
  83. package/dist/rules/models.js +1 -2
  84. package/dist/scheduledJobs/index.js +183 -321
  85. package/dist/scheduledJobs/models.js +1 -2
  86. package/dist/secrets/index.js +88 -178
  87. package/dist/secrets/models.js +1 -2
  88. package/dist/settings/index.js +119 -227
  89. package/dist/settings/models.js +1 -2
  90. package/dist/settingsApplicationRecord/index.js +27 -65
  91. package/dist/settingsApplicationRecord/models.js +1 -2
  92. package/dist/softwareUpdates/index.js +194 -350
  93. package/dist/softwareUpdates/models.js +1 -2
  94. package/dist/stats/index.js +64 -126
  95. package/dist/stats/models.js +1 -2
  96. package/dist/systemCommandJobs/index.js +72 -154
  97. package/dist/systemCommandJobs/models.js +1 -2
  98. package/dist/systemCommands/index.js +87 -177
  99. package/dist/systemCommands/models.js +1 -2
  100. package/dist/testConstants.js +57 -71
  101. package/dist/translators/index.js +103 -201
  102. package/dist/translators/models.js +1 -2
  103. package/dist/userTypes/index.js +87 -177
  104. package/dist/userTypes/models.js +1 -2
  105. package/dist/users/index.js +149 -271
  106. package/dist/users/models.js +1 -2
  107. package/dist/workflowActions/index.js +132 -246
  108. package/dist/workflowActions/models.js +1 -2
  109. package/dist/workflowDefinitions/index.js +104 -202
  110. package/dist/workflowDefinitions/models.js +1 -2
  111. package/dist/workflowExecutions/index.js +27 -65
  112. package/dist/workflowExecutions/models.js +1 -2
  113. package/dist/workflows/index.js +39 -85
  114. package/dist/workflows/models.js +1 -2
  115. package/package.json +1 -1
@@ -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,352 +7,223 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
34
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
35
8
  });
36
9
  };
37
- var __generator = (this && this.__generator) || function (thisArg, body) {
38
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
- function verb(n) { return function (v) { return step([n, v]); }; }
41
- function step(op) {
42
- if (f) throw new TypeError("Generator is already executing.");
43
- while (_) try {
44
- 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;
45
- if (y = 0, t) op = [op[0] & 2, t.value];
46
- switch (op[0]) {
47
- case 0: case 1: t = op; break;
48
- case 4: _.label++; return { value: op[1], done: false };
49
- case 5: _.label++; y = op[1]; op = [0]; continue;
50
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
51
- default:
52
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
53
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
54
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
55
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
56
- if (t[2]) _.ops.pop();
57
- _.trys.pop(); continue;
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 SoftwareUpdates = class extends BaseModelClass {
16
+ static create(softwareUpdate) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ try {
19
+ this.logAction(`Creating software update with name: ${softwareUpdate.name}`);
20
+ const axios = EdgeIQAPI.getAxios();
21
+ const data = JSON.stringify(softwareUpdate);
22
+ const result = yield axios.post(Endpoints.softwareUpdate, data);
23
+ return result === null || result === void 0 ? void 0 : result.data;
58
24
  }
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 };
62
- }
63
- };
64
- Object.defineProperty(exports, "__esModule", { value: true });
65
- exports.SoftwareUpdates = void 0;
66
- var __1 = require("..");
67
- var constants_1 = require("../constants");
68
- var ModelClass_1 = require("../core/ModelClass");
69
- var filtersParser_1 = require("../filtersParser");
70
- var helpers_1 = require("../helpers");
71
- exports.SoftwareUpdates = (function (_super) {
72
- __extends(class_1, _super);
73
- function class_1() {
74
- return _super !== null && _super.apply(this, arguments) || this;
75
- }
76
- class_1.create = function (softwareUpdate) {
77
- return __awaiter(this, void 0, void 0, function () {
78
- var axios, data, result, error_1;
79
- return __generator(this, function (_a) {
80
- switch (_a.label) {
81
- case 0:
82
- _a.trys.push([0, 2, , 3]);
83
- this.logAction("Creating software update with name: " + softwareUpdate.name);
84
- axios = __1.EdgeIQAPI.getAxios();
85
- data = JSON.stringify(softwareUpdate);
86
- return [4, axios.post(constants_1.Endpoints.softwareUpdate, data)];
87
- case 1:
88
- result = _a.sent();
89
- return [2, result === null || result === void 0 ? void 0 : result.data];
90
- case 2:
91
- error_1 = _a.sent();
92
- if ((0, helpers_1.isApiError)(error_1)) {
93
- throw error_1;
94
- }
95
- throw error_1;
96
- case 3: return [2];
25
+ catch (error) {
26
+ if (isApiError(error)) {
27
+ throw error;
97
28
  }
98
- });
29
+ throw error;
30
+ }
99
31
  });
100
- };
101
- class_1.update = function (softwareUpdate) {
102
- return __awaiter(this, void 0, void 0, function () {
103
- var axios, data, result, error_2;
104
- return __generator(this, function (_a) {
105
- switch (_a.label) {
106
- case 0:
107
- _a.trys.push([0, 2, , 3]);
108
- this.logAction("Updating software update with unique ID: " + softwareUpdate._id);
109
- axios = __1.EdgeIQAPI.getAxios();
110
- data = JSON.stringify(softwareUpdate);
111
- return [4, axios.put(constants_1.Endpoints.softwareUpdate + "/" + softwareUpdate._id, data)];
112
- case 1:
113
- result = _a.sent();
114
- return [2, result === null || result === void 0 ? void 0 : result.data];
115
- case 2:
116
- error_2 = _a.sent();
117
- if ((0, helpers_1.isApiError)(error_2)) {
118
- throw error_2;
119
- }
120
- throw error_2;
121
- case 3: return [2];
32
+ }
33
+ static update(softwareUpdate) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ try {
36
+ this.logAction(`Updating software update with unique ID: ${softwareUpdate._id}`);
37
+ const axios = EdgeIQAPI.getAxios();
38
+ const data = JSON.stringify(softwareUpdate);
39
+ const result = yield axios.put(`${Endpoints.softwareUpdate}/${softwareUpdate._id}`, data);
40
+ return result === null || result === void 0 ? void 0 : result.data;
41
+ }
42
+ catch (error) {
43
+ if (isApiError(error)) {
44
+ throw error;
122
45
  }
123
- });
46
+ throw error;
47
+ }
124
48
  });
125
- };
126
- class_1.list = function (filters, pagination) {
49
+ }
50
+ static list(filters, pagination) {
127
51
  var _a, _b, _c, _d;
128
- return __awaiter(this, void 0, void 0, function () {
129
- var axios, result, error_3;
130
- return __generator(this, function (_e) {
131
- switch (_e.label) {
132
- case 0:
133
- _e.trys.push([0, 2, , 3]);
134
- this.logAction("Listing software updates with following filters: " + (filters !== null && filters !== void 0 ? filters : '{}') + ".\n And pagination " + (pagination !== null && pagination !== void 0 ? pagination : '{}'));
135
- axios = __1.EdgeIQAPI.getAxios();
136
- return [4, axios.get(constants_1.Endpoints.softwareUpdate, {
137
- params: (0, filtersParser_1.parseFilters)(filters, pagination),
138
- })];
139
- case 1:
140
- result = _e.sent();
141
- return [2, {
142
- softwareUpdates: (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.resources,
143
- pagination: {
144
- page: (_b = result === null || result === void 0 ? void 0 : result.data) === null || _b === void 0 ? void 0 : _b.page,
145
- itemsPerPage: (_c = result === null || result === void 0 ? void 0 : result.data) === null || _c === void 0 ? void 0 : _c.per_page,
146
- total: (_d = result === null || result === void 0 ? void 0 : result.data) === null || _d === void 0 ? void 0 : _d.total,
147
- },
148
- }];
149
- case 2:
150
- error_3 = _e.sent();
151
- if ((0, helpers_1.isApiError)(error_3)) {
152
- throw error_3;
153
- }
154
- throw error_3;
155
- case 3: return [2];
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ try {
54
+ this.logAction(`Listing software updates with following filters: ${filters !== null && filters !== void 0 ? filters : '{}'}.\n And pagination ${pagination !== null && pagination !== void 0 ? pagination : '{}'}`);
55
+ const axios = EdgeIQAPI.getAxios();
56
+ const result = yield axios.get(Endpoints.softwareUpdate, {
57
+ params: parseFilters(filters, pagination),
58
+ });
59
+ return {
60
+ softwareUpdates: (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.resources,
61
+ pagination: {
62
+ page: (_b = result === null || result === void 0 ? void 0 : result.data) === null || _b === void 0 ? void 0 : _b.page,
63
+ itemsPerPage: (_c = result === null || result === void 0 ? void 0 : result.data) === null || _c === void 0 ? void 0 : _c.per_page,
64
+ total: (_d = result === null || result === void 0 ? void 0 : result.data) === null || _d === void 0 ? void 0 : _d.total,
65
+ },
66
+ };
67
+ }
68
+ catch (error) {
69
+ if (isApiError(error)) {
70
+ throw error;
156
71
  }
157
- });
72
+ throw error;
73
+ }
158
74
  });
159
- };
160
- class_1.getOneById = function (id) {
161
- return __awaiter(this, void 0, void 0, function () {
162
- var axios, result, error_4;
163
- return __generator(this, function (_a) {
164
- switch (_a.label) {
165
- case 0:
166
- _a.trys.push([0, 2, , 3]);
167
- this.logAction("Getting software update with id: " + id);
168
- axios = __1.EdgeIQAPI.getAxios();
169
- return [4, axios.get(constants_1.Endpoints.softwareUpdate + "/" + id)];
170
- case 1:
171
- result = _a.sent();
172
- return [2, result === null || result === void 0 ? void 0 : result.data];
173
- case 2:
174
- error_4 = _a.sent();
175
- if ((0, helpers_1.isApiError)(error_4)) {
176
- throw error_4;
177
- }
178
- throw error_4;
179
- case 3: return [2];
75
+ }
76
+ static getOneById(id) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ try {
79
+ this.logAction(`Getting software update with id: ${id}`);
80
+ const axios = EdgeIQAPI.getAxios();
81
+ const result = yield axios.get(`${Endpoints.softwareUpdate}/${id}`);
82
+ return result === null || result === void 0 ? void 0 : result.data;
83
+ }
84
+ catch (error) {
85
+ if (isApiError(error)) {
86
+ throw error;
180
87
  }
181
- });
88
+ throw error;
89
+ }
182
90
  });
183
- };
184
- class_1.delete = function (id) {
185
- return __awaiter(this, void 0, void 0, function () {
186
- var axios, error_5;
187
- return __generator(this, function (_a) {
188
- switch (_a.label) {
189
- case 0:
190
- _a.trys.push([0, 2, , 3]);
191
- this.logAction("Deleting software update with id " + id);
192
- axios = __1.EdgeIQAPI.getAxios();
193
- return [4, axios.delete(constants_1.Endpoints.softwareUpdate + "/" + id)];
194
- case 1:
195
- _a.sent();
196
- return [2, (0, helpers_1.getReturnDeleteMessage)('software update')];
197
- case 2:
198
- error_5 = _a.sent();
199
- if ((0, helpers_1.isApiError)(error_5)) {
200
- throw error_5;
201
- }
202
- throw error_5;
203
- case 3: return [2];
91
+ }
92
+ static delete(id) {
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ try {
95
+ this.logAction(`Deleting software update with id ${id}`);
96
+ const axios = EdgeIQAPI.getAxios();
97
+ yield axios.delete(`${Endpoints.softwareUpdate}/${id}`);
98
+ return getReturnDeleteMessage('software update');
99
+ }
100
+ catch (error) {
101
+ if (isApiError(error)) {
102
+ throw error;
204
103
  }
205
- });
104
+ throw error;
105
+ }
206
106
  });
207
- };
208
- class_1.deleteMultiple = function (ids) {
209
- return __awaiter(this, void 0, void 0, function () {
210
- var axios, result, error_6;
211
- return __generator(this, function (_a) {
212
- switch (_a.label) {
213
- case 0:
214
- _a.trys.push([0, 2, , 3]);
215
- this.logAction("Deleting software updates with ids " + ids.join(', '));
216
- axios = __1.EdgeIQAPI.getAxios();
217
- return [4, axios.delete(constants_1.Endpoints.softwareUpdate + "/bulk", {
218
- data: { ids: ids },
219
- })];
220
- case 1:
221
- result = _a.sent();
222
- return [2, result === null || result === void 0 ? void 0 : result.data];
223
- case 2:
224
- error_6 = _a.sent();
225
- if ((0, helpers_1.isApiError)(error_6)) {
226
- throw error_6;
227
- }
228
- throw error_6;
229
- case 3: return [2];
107
+ }
108
+ static deleteMultiple(ids) {
109
+ return __awaiter(this, void 0, void 0, function* () {
110
+ try {
111
+ this.logAction(`Deleting software updates with ids ${ids.join(', ')}`);
112
+ const axios = EdgeIQAPI.getAxios();
113
+ const result = yield axios.delete(`${Endpoints.softwareUpdate}/bulk`, {
114
+ data: { ids },
115
+ });
116
+ return result === null || result === void 0 ? void 0 : result.data;
117
+ }
118
+ catch (error) {
119
+ if (isApiError(error)) {
120
+ throw error;
230
121
  }
231
- });
122
+ throw error;
123
+ }
232
124
  });
233
- };
234
- class_1.assignToDevice = function (softwareUpdateId, deviceId) {
235
- return __awaiter(this, void 0, void 0, function () {
236
- var axios, error_7;
237
- return __generator(this, function (_a) {
238
- switch (_a.label) {
239
- case 0:
240
- _a.trys.push([0, 2, , 3]);
241
- this.logAction("assigning softwareUpdate " + softwareUpdateId + " \n to device " + deviceId);
242
- axios = __1.EdgeIQAPI.getAxios();
243
- return [4, axios.put(constants_1.Endpoints.softwareUpdate + "/" + softwareUpdateId + "/" + constants_1.Endpoints.device + "/" + deviceId)];
244
- case 1:
245
- _a.sent();
246
- return [2, (0, constants_1.getAttachMessage)('SoftwareUpdate', 'attach', 'device')];
247
- case 2:
248
- error_7 = _a.sent();
249
- if ((0, helpers_1.isApiError)(error_7)) {
250
- throw error_7;
251
- }
252
- throw error_7;
253
- case 3: return [2];
125
+ }
126
+ static assignToDevice(softwareUpdateId, deviceId) {
127
+ return __awaiter(this, void 0, void 0, function* () {
128
+ try {
129
+ this.logAction(`assigning softwareUpdate ${softwareUpdateId}
130
+ to device ${deviceId}`);
131
+ const axios = EdgeIQAPI.getAxios();
132
+ yield axios.put(`${Endpoints.softwareUpdate}/${softwareUpdateId}/${Endpoints.device}/${deviceId}`);
133
+ return getAttachMessage('SoftwareUpdate', 'attach', 'device');
134
+ }
135
+ catch (error) {
136
+ if (isApiError(error)) {
137
+ throw error;
254
138
  }
255
- });
139
+ throw error;
140
+ }
256
141
  });
257
- };
258
- class_1.assignToDeviceType = function (softwareUpdateId, deviceTypeId) {
259
- return __awaiter(this, void 0, void 0, function () {
260
- var axios, error_8;
261
- return __generator(this, function (_a) {
262
- switch (_a.label) {
263
- case 0:
264
- _a.trys.push([0, 2, , 3]);
265
- this.logAction("assigning softwareUpdate " + softwareUpdateId + " to device type " + deviceTypeId);
266
- axios = __1.EdgeIQAPI.getAxios();
267
- return [4, axios.put(constants_1.Endpoints.softwareUpdate + "/" + softwareUpdateId + "/" + constants_1.Endpoints.deviceType + "/" + deviceTypeId)];
268
- case 1:
269
- _a.sent();
270
- return [2, (0, constants_1.getAttachMessage)('SoftwareUpdate', 'attach', 'device type')];
271
- case 2:
272
- error_8 = _a.sent();
273
- if ((0, helpers_1.isApiError)(error_8)) {
274
- throw error_8;
275
- }
276
- throw error_8;
277
- case 3: return [2];
142
+ }
143
+ static assignToDeviceType(softwareUpdateId, deviceTypeId) {
144
+ return __awaiter(this, void 0, void 0, function* () {
145
+ try {
146
+ this.logAction(`assigning softwareUpdate ${softwareUpdateId} to device type ${deviceTypeId}`);
147
+ const axios = EdgeIQAPI.getAxios();
148
+ yield axios.put(`${Endpoints.softwareUpdate}/${softwareUpdateId}/${Endpoints.deviceType}/${deviceTypeId}`);
149
+ return getAttachMessage('SoftwareUpdate', 'attach', 'device type');
150
+ }
151
+ catch (error) {
152
+ if (isApiError(error)) {
153
+ throw error;
278
154
  }
279
- });
155
+ throw error;
156
+ }
280
157
  });
281
- };
282
- class_1.removeFromDevice = function (softwareUpdateId, deviceId) {
283
- return __awaiter(this, void 0, void 0, function () {
284
- var axios, error_9;
285
- return __generator(this, function (_a) {
286
- switch (_a.label) {
287
- case 0:
288
- _a.trys.push([0, 2, , 3]);
289
- this.logAction("detaching softwareUpdate " + softwareUpdateId + " from device " + deviceId);
290
- axios = __1.EdgeIQAPI.getAxios();
291
- return [4, axios.delete(constants_1.Endpoints.softwareUpdate + "/" + softwareUpdateId + "/" + constants_1.Endpoints.device + "/" + deviceId)];
292
- case 1:
293
- _a.sent();
294
- return [2, (0, constants_1.getAttachMessage)('SoftwareUpdate', 'detach', 'device')];
295
- case 2:
296
- error_9 = _a.sent();
297
- if ((0, helpers_1.isApiError)(error_9)) {
298
- throw error_9;
299
- }
300
- throw error_9;
301
- case 3: return [2];
158
+ }
159
+ static removeFromDevice(softwareUpdateId, deviceId) {
160
+ return __awaiter(this, void 0, void 0, function* () {
161
+ try {
162
+ this.logAction(`detaching softwareUpdate ${softwareUpdateId} from device ${deviceId}`);
163
+ const axios = EdgeIQAPI.getAxios();
164
+ yield axios.delete(`${Endpoints.softwareUpdate}/${softwareUpdateId}/${Endpoints.device}/${deviceId}`);
165
+ return getAttachMessage('SoftwareUpdate', 'detach', 'device');
166
+ }
167
+ catch (error) {
168
+ if (isApiError(error)) {
169
+ throw error;
302
170
  }
303
- });
171
+ throw error;
172
+ }
304
173
  });
305
- };
306
- class_1.removeFromDeviceType = function (softwareUpdateId, deviceTypeId) {
307
- return __awaiter(this, void 0, void 0, function () {
308
- var axios, error_10;
309
- return __generator(this, function (_a) {
310
- switch (_a.label) {
311
- case 0:
312
- _a.trys.push([0, 2, , 3]);
313
- this.logAction("detaching softwareUpdate " + softwareUpdateId + " from device type " + deviceTypeId);
314
- axios = __1.EdgeIQAPI.getAxios();
315
- return [4, axios.delete(constants_1.Endpoints.softwareUpdate + "/" + softwareUpdateId + "/" + constants_1.Endpoints.deviceType + "/" + deviceTypeId)];
316
- case 1:
317
- _a.sent();
318
- return [2, (0, constants_1.getAttachMessage)('SoftwareUpdate', 'detach', 'device type')];
319
- case 2:
320
- error_10 = _a.sent();
321
- if ((0, helpers_1.isApiError)(error_10)) {
322
- throw error_10;
323
- }
324
- throw error_10;
325
- case 3: return [2];
174
+ }
175
+ static removeFromDeviceType(softwareUpdateId, deviceTypeId) {
176
+ return __awaiter(this, void 0, void 0, function* () {
177
+ try {
178
+ this.logAction(`detaching softwareUpdate ${softwareUpdateId} from device type ${deviceTypeId}`);
179
+ const axios = EdgeIQAPI.getAxios();
180
+ yield axios.delete(`${Endpoints.softwareUpdate}/${softwareUpdateId}/${Endpoints.deviceType}/${deviceTypeId}`);
181
+ return getAttachMessage('SoftwareUpdate', 'detach', 'device type');
182
+ }
183
+ catch (error) {
184
+ if (isApiError(error)) {
185
+ throw error;
326
186
  }
327
- });
187
+ throw error;
188
+ }
328
189
  });
329
- };
330
- class_1.bulkSoftwareUpdate = function (payload, generateChildCommandExecutions) {
331
- return __awaiter(this, void 0, void 0, function () {
332
- var axios, result, error_11;
333
- return __generator(this, function (_a) {
334
- switch (_a.label) {
335
- case 0:
336
- _a.trys.push([0, 2, , 3]);
337
- this.logAction("Issuing software updates with payload " + payload);
338
- axios = __1.EdgeIQAPI.getAxios();
339
- return [4, axios.post(constants_1.Endpoints.device + "/bulk/software_update", __assign(__assign({}, payload), { generate_child_command_executions: generateChildCommandExecutions !== null && generateChildCommandExecutions !== void 0 ? generateChildCommandExecutions : false }))];
340
- case 1:
341
- result = _a.sent();
342
- return [2, result === null || result === void 0 ? void 0 : result.data];
343
- case 2:
344
- error_11 = _a.sent();
345
- if ((0, helpers_1.isApiError)(error_11)) {
346
- throw error_11;
347
- }
348
- throw error_11;
349
- case 3: return [2];
190
+ }
191
+ static bulkSoftwareUpdate(payload, generateChildCommandExecutions) {
192
+ return __awaiter(this, void 0, void 0, function* () {
193
+ try {
194
+ this.logAction(`Issuing software updates with payload ${payload}`);
195
+ const axios = EdgeIQAPI.getAxios();
196
+ const result = yield axios.post(`${Endpoints.device}/bulk/software_update`, Object.assign(Object.assign({}, payload), { generate_child_command_executions: generateChildCommandExecutions !== null && generateChildCommandExecutions !== void 0 ? generateChildCommandExecutions : false }));
197
+ return result === null || result === void 0 ? void 0 : result.data;
198
+ }
199
+ catch (error) {
200
+ if (isApiError(error)) {
201
+ throw error;
350
202
  }
351
- });
203
+ throw error;
204
+ }
352
205
  });
353
- };
354
- class_1.uploadFile = function (id, files) {
355
- return __awaiter(this, void 0, void 0, function () {
356
- var axios, form_1, result, error_12;
357
- return __generator(this, function (_a) {
358
- switch (_a.label) {
359
- case 0:
360
- _a.trys.push([0, 2, , 3]);
361
- this.logAction("Uploading file to software update");
362
- axios = __1.EdgeIQAPI.getAxios();
363
- form_1 = new FormData();
364
- files.forEach(function (file) { return form_1.append('files[]', file); });
365
- return [4, axios.post(constants_1.Endpoints.softwareUpdate + "/" + id + "/upload", form_1, {
366
- headers: {
367
- 'Content-Type': 'multipart/form-data',
368
- },
369
- })];
370
- case 1:
371
- result = _a.sent();
372
- return [2, result === null || result === void 0 ? void 0 : result.data];
373
- case 2:
374
- error_12 = _a.sent();
375
- if ((0, helpers_1.isApiError)(error_12)) {
376
- throw error_12;
377
- }
378
- throw error_12;
379
- case 3: return [2];
206
+ }
207
+ static uploadFile(id, files) {
208
+ return __awaiter(this, void 0, void 0, function* () {
209
+ try {
210
+ this.logAction(`Uploading file to software update`);
211
+ const axios = EdgeIQAPI.getAxios();
212
+ const form = new FormData();
213
+ files.forEach((file) => form.append('files[]', file));
214
+ const result = yield axios.post(`${Endpoints.softwareUpdate}/${id}/upload`, form, {
215
+ headers: {
216
+ 'Content-Type': 'multipart/form-data',
217
+ },
218
+ });
219
+ return result === null || result === void 0 ? void 0 : result.data;
220
+ }
221
+ catch (error) {
222
+ if (isApiError(error)) {
223
+ throw error;
380
224
  }
381
- });
225
+ throw error;
226
+ }
382
227
  });
383
- };
384
- return class_1;
385
- }(ModelClass_1.BaseModelClass));
228
+ }
229
+ };
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};