@edgeiq/edgeiq-api-js 1.3.29 → 1.3.32
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { BaseModelInterface } from '../core/ModelClass';
|
|
2
|
+
import { CommandExecution, CommandExecutionsStatus, CommandExecutionInput, CommandExecutionsFilters, PaginatedCommandExecutions } from './models';
|
|
3
|
+
interface CommandExecutionsInterface extends BaseModelInterface<CommandExecution, CommandExecutionInput, CommandExecutionsFilters, PaginatedCommandExecutions> {
|
|
4
4
|
getStatuses(id: string): Promise<CommandExecutionsStatus[]>;
|
|
5
5
|
}
|
|
6
6
|
export declare const CommandExecutions: CommandExecutionsInterface;
|
|
@@ -54,6 +54,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
54
54
|
exports.CommandExecutions = void 0;
|
|
55
55
|
var constants_1 = require("../constants");
|
|
56
56
|
var ModelClass_1 = require("../core/ModelClass");
|
|
57
|
+
var filtersParser_1 = require("../filtersParser");
|
|
57
58
|
var helpers_1 = require("../helpers");
|
|
58
59
|
var core_1 = require("../core");
|
|
59
60
|
exports.CommandExecutions = (function (_super) {
|
|
@@ -61,15 +62,17 @@ exports.CommandExecutions = (function (_super) {
|
|
|
61
62
|
function class_1() {
|
|
62
63
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
63
64
|
}
|
|
64
|
-
class_1.
|
|
65
|
+
class_1.create = function (commandExecutionRequest) {
|
|
65
66
|
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
-
var axios, result, error_1;
|
|
67
|
+
var axios, data, result, error_1;
|
|
67
68
|
return __generator(this, function (_a) {
|
|
68
69
|
switch (_a.label) {
|
|
69
70
|
case 0:
|
|
70
71
|
_a.trys.push([0, 2, , 3]);
|
|
72
|
+
this.logAction("Creating command execution with unique ID: " + commandExecutionRequest);
|
|
71
73
|
axios = core_1.EdgeIQAPI.getAxios();
|
|
72
|
-
|
|
74
|
+
data = JSON.stringify(commandExecutionRequest);
|
|
75
|
+
return [4, axios.post(constants_1.Endpoints.commandExecution, data)];
|
|
73
76
|
case 1:
|
|
74
77
|
result = _a.sent();
|
|
75
78
|
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
@@ -84,9 +87,90 @@ exports.CommandExecutions = (function (_super) {
|
|
|
84
87
|
});
|
|
85
88
|
});
|
|
86
89
|
};
|
|
87
|
-
class_1.
|
|
90
|
+
class_1.list = function (filters, pagination) {
|
|
91
|
+
var _a, _b, _c, _d;
|
|
88
92
|
return __awaiter(this, void 0, void 0, function () {
|
|
89
93
|
var axios, result, error_2;
|
|
94
|
+
return __generator(this, function (_e) {
|
|
95
|
+
switch (_e.label) {
|
|
96
|
+
case 0:
|
|
97
|
+
_e.trys.push([0, 2, , 3]);
|
|
98
|
+
axios = core_1.EdgeIQAPI.getAxios();
|
|
99
|
+
return [4, axios.get("" + constants_1.Endpoints.commandExecution, {
|
|
100
|
+
params: (0, filtersParser_1.parseFilters)(filters, pagination),
|
|
101
|
+
})];
|
|
102
|
+
case 1:
|
|
103
|
+
result = _e.sent();
|
|
104
|
+
return [2, {
|
|
105
|
+
commandExecutions: (_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
|
+
case 2:
|
|
113
|
+
error_2 = _e.sent();
|
|
114
|
+
if ((0, helpers_1.isApiError)(error_2)) {
|
|
115
|
+
throw error_2;
|
|
116
|
+
}
|
|
117
|
+
throw error_2;
|
|
118
|
+
case 3: return [2];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
class_1.getOneById = function (id) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
125
|
+
var axios, result, error_3;
|
|
126
|
+
return __generator(this, function (_a) {
|
|
127
|
+
switch (_a.label) {
|
|
128
|
+
case 0:
|
|
129
|
+
_a.trys.push([0, 2, , 3]);
|
|
130
|
+
this.logAction("Getting command execution request with id: " + id);
|
|
131
|
+
axios = core_1.EdgeIQAPI.getAxios();
|
|
132
|
+
return [4, axios.get(constants_1.Endpoints.commandExecution + "/" + id)];
|
|
133
|
+
case 1:
|
|
134
|
+
result = _a.sent();
|
|
135
|
+
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
136
|
+
case 2:
|
|
137
|
+
error_3 = _a.sent();
|
|
138
|
+
if ((0, helpers_1.isApiError)(error_3)) {
|
|
139
|
+
throw error_3;
|
|
140
|
+
}
|
|
141
|
+
throw error_3;
|
|
142
|
+
case 3: return [2];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
class_1.delete = function (id) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
149
|
+
var axios, error_4;
|
|
150
|
+
return __generator(this, function (_a) {
|
|
151
|
+
switch (_a.label) {
|
|
152
|
+
case 0:
|
|
153
|
+
_a.trys.push([0, 2, , 3]);
|
|
154
|
+
this.logAction("Deleting command execution request with id " + id);
|
|
155
|
+
axios = core_1.EdgeIQAPI.getAxios();
|
|
156
|
+
return [4, axios.delete(constants_1.Endpoints.commandExecution + "/" + id)];
|
|
157
|
+
case 1:
|
|
158
|
+
_a.sent();
|
|
159
|
+
return [2, (0, helpers_1.getReturnDeleteMessage)('command execution request')];
|
|
160
|
+
case 2:
|
|
161
|
+
error_4 = _a.sent();
|
|
162
|
+
if ((0, helpers_1.isApiError)(error_4)) {
|
|
163
|
+
throw error_4;
|
|
164
|
+
}
|
|
165
|
+
throw error_4;
|
|
166
|
+
case 3: return [2];
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
class_1.getStatuses = function (id) {
|
|
172
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
173
|
+
var axios, result, error_5;
|
|
90
174
|
return __generator(this, function (_a) {
|
|
91
175
|
switch (_a.label) {
|
|
92
176
|
case 0:
|
|
@@ -98,11 +182,11 @@ exports.CommandExecutions = (function (_super) {
|
|
|
98
182
|
result = _a.sent();
|
|
99
183
|
return [2, result === null || result === void 0 ? void 0 : result.data];
|
|
100
184
|
case 2:
|
|
101
|
-
|
|
102
|
-
if ((0, helpers_1.isApiError)(
|
|
103
|
-
throw
|
|
185
|
+
error_5 = _a.sent();
|
|
186
|
+
if ((0, helpers_1.isApiError)(error_5)) {
|
|
187
|
+
throw error_5;
|
|
104
188
|
}
|
|
105
|
-
throw
|
|
189
|
+
throw error_5;
|
|
106
190
|
case 3: return [2];
|
|
107
191
|
}
|
|
108
192
|
});
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { Base, Filter, Filters, Pagination } from '../models';
|
|
2
|
-
export interface
|
|
3
|
-
|
|
2
|
+
export interface CommandExecutionInput {
|
|
3
|
+
command_id: string;
|
|
4
|
+
device_id: string;
|
|
4
5
|
execution_statuses: CommandExecutionsStatus[];
|
|
5
6
|
}
|
|
6
7
|
export declare type CommandExecutionStatus = 'initiated' | 'info' | 'success' | 'error';
|
|
8
|
+
export interface CommandExecutionRequest extends CommandExecutionInput, Base {
|
|
9
|
+
}
|
|
7
10
|
export interface CommandExecutionsStatus extends Base {
|
|
8
11
|
execution_id: string;
|
|
9
12
|
status: CommandExecutionStatus;
|
|
10
13
|
message?: string;
|
|
11
14
|
}
|
|
12
|
-
export interface CommandExecution extends
|
|
15
|
+
export interface CommandExecution extends CommandExecutionInput, Base {
|
|
13
16
|
}
|
|
14
17
|
export interface CommandExecutionsFilters extends Filters {
|
|
15
18
|
command_id?: Filter;
|
|
19
|
+
device_id?: Filter;
|
|
16
20
|
status?: Filter;
|
|
17
21
|
}
|
|
18
22
|
export interface PaginatedCommandExecutions {
|
package/dist/constants.js
CHANGED
|
@@ -71,7 +71,7 @@ exports.BaseEndpoints = {
|
|
|
71
71
|
bulkResponse: 'bulk_responses',
|
|
72
72
|
notification: 'notifications',
|
|
73
73
|
command: 'commands',
|
|
74
|
-
commandExecution: '
|
|
74
|
+
commandExecution: 'command_executions',
|
|
75
75
|
company: 'companies',
|
|
76
76
|
deviceConfig: 'device_configs',
|
|
77
77
|
deviceError: 'device_errors',
|
package/dist/devices/models.d.ts
CHANGED