@wiotp/sdk 0.8.3 → 0.8.4
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/package.json +2 -2
- package/dist/BaseClient.js +0 -226
- package/dist/BaseConfig.js +0 -179
- package/dist/api/ApiClient.js +0 -505
- package/dist/api/ApiErrors.js +0 -75
- package/dist/api/DscClient.js +0 -328
- package/dist/api/LecClient.js +0 -47
- package/dist/api/MgmtClient.js +0 -76
- package/dist/api/RegistryClient.js +0 -225
- package/dist/api/RulesClient.js +0 -104
- package/dist/api/StateClient.js +0 -721
- package/dist/application/ApplicationClient.js +0 -356
- package/dist/application/ApplicationConfig.js +0 -240
- package/dist/application/index.js +0 -20
- package/dist/bundled/wiotp-bundle.js +0 -46846
- package/dist/bundled/wiotp-bundle.min.js +0 -41
- package/dist/device/DeviceClient.js +0 -100
- package/dist/device/DeviceConfig.js +0 -201
- package/dist/device/index.js +0 -20
- package/dist/gateway/GatewayClient.js +0 -129
- package/dist/gateway/GatewayConfig.js +0 -44
- package/dist/gateway/index.js +0 -20
- package/dist/index.js +0 -97
- package/dist/util.js +0 -44
package/dist/api/StateClient.js
DELETED
|
@@ -1,721 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _loglevel = _interopRequireDefault(require("loglevel"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
10
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
11
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
12
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
13
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /**
|
|
15
|
-
*****************************************************************************
|
|
16
|
-
Copyright (c) 2014, 2019 IBM Corporation and other Contributors.
|
|
17
|
-
All rights reserved. This program and the accompanying materials
|
|
18
|
-
are made available under the terms of the Eclipse Public License v1.0
|
|
19
|
-
which accompanies this distribution, and is available at
|
|
20
|
-
http://www.eclipse.org/legal/epl-v10.html
|
|
21
|
-
*****************************************************************************
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
var StateClient = exports["default"] = /*#__PURE__*/function () {
|
|
25
|
-
function StateClient(apiClient) {
|
|
26
|
-
_classCallCheck(this, StateClient);
|
|
27
|
-
this.log = _loglevel["default"];
|
|
28
|
-
this.apiClient = apiClient;
|
|
29
|
-
this.draftMode = true;
|
|
30
|
-
|
|
31
|
-
// Create an alias to the apiClient's methods that we use
|
|
32
|
-
this.callApi = this.apiClient.callApi.bind(this.apiClient);
|
|
33
|
-
this.parseSortSpec = this.apiClient.parseSortSpec.bind(this.apiClient);
|
|
34
|
-
this.callFormDataApi = this.apiClient.callFormDataApi.bind(this.apiClient);
|
|
35
|
-
this.invalidOperation = this.apiClient.invalidOperation.bind(this.apiClient);
|
|
36
|
-
}
|
|
37
|
-
return _createClass(StateClient, [{
|
|
38
|
-
key: "workWithActive",
|
|
39
|
-
value: function workWithActive() {
|
|
40
|
-
this.draftMode = false;
|
|
41
|
-
}
|
|
42
|
-
}, {
|
|
43
|
-
key: "workWithDraft",
|
|
44
|
-
value: function workWithDraft() {
|
|
45
|
-
this.draftMode = true;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// IM Device state API
|
|
49
|
-
}, {
|
|
50
|
-
key: "createSchema",
|
|
51
|
-
value: function createSchema(schemaContents, name, description) {
|
|
52
|
-
var body = {
|
|
53
|
-
'schemaFile': schemaContents,
|
|
54
|
-
'schemaType': 'json-schema',
|
|
55
|
-
'name': name
|
|
56
|
-
};
|
|
57
|
-
if (description) {
|
|
58
|
-
body.description = description;
|
|
59
|
-
}
|
|
60
|
-
var base = this.draftMode ? ["draft", "schemas"] : ["schemas"];
|
|
61
|
-
return this.callFormDataApi('POST', 201, true, base, body, null);
|
|
62
|
-
}
|
|
63
|
-
}, {
|
|
64
|
-
key: "getSchema",
|
|
65
|
-
value: function getSchema(schemaId) {
|
|
66
|
-
var base = this.draftMode ? ["draft", "schemas", schemaId] : ["schemas", schemaId];
|
|
67
|
-
return this.callApi('GET', 200, true, base);
|
|
68
|
-
}
|
|
69
|
-
}, {
|
|
70
|
-
key: "getActiveSchema",
|
|
71
|
-
value: function getActiveSchema(schemaId) {
|
|
72
|
-
return this.callApi('GET', 200, true, ["schemas", schemaId]);
|
|
73
|
-
}
|
|
74
|
-
}, {
|
|
75
|
-
key: "getSchemas",
|
|
76
|
-
value: function getSchemas() {
|
|
77
|
-
var base = this.draftMode ? ["draft", "schemas"] : ["schemas"];
|
|
78
|
-
return this.callApi('GET', 200, true, base);
|
|
79
|
-
}
|
|
80
|
-
}, {
|
|
81
|
-
key: "getActiveSchemas",
|
|
82
|
-
value: function getActiveSchemas() {
|
|
83
|
-
return this.callApi('GET', 200, true, ["schemas"]);
|
|
84
|
-
}
|
|
85
|
-
}, {
|
|
86
|
-
key: "updateSchema",
|
|
87
|
-
value: function updateSchema(schemaId, name, description) {
|
|
88
|
-
var body = {
|
|
89
|
-
"id": schemaId,
|
|
90
|
-
"name": name,
|
|
91
|
-
"description": description
|
|
92
|
-
};
|
|
93
|
-
var base = this.draftMode ? ["draft", "schemas", schemaId] : ["schemas", schemaId];
|
|
94
|
-
return this.callApi('PUT', 200, true, base, body);
|
|
95
|
-
}
|
|
96
|
-
}, {
|
|
97
|
-
key: "updateSchemaContent",
|
|
98
|
-
value: function updateSchemaContent(schemaId, schemaContents, filename) {
|
|
99
|
-
var body = {
|
|
100
|
-
'schemaFile': schemaContents,
|
|
101
|
-
'name': filename
|
|
102
|
-
};
|
|
103
|
-
var base = this.draftMode ? ["draft", "schemas", schemaId, "content"] : ["schemas", schemaId, "content"];
|
|
104
|
-
return this.callFormDataApi('PUT', 204, false, base, body, null);
|
|
105
|
-
}
|
|
106
|
-
}, {
|
|
107
|
-
key: "getSchemaContent",
|
|
108
|
-
value: function getSchemaContent(schemaId) {
|
|
109
|
-
var base = this.draftMode ? ["draft", "schemas", schemaId, "content"] : ["schemas", schemaId, "content"];
|
|
110
|
-
return this.callApi('GET', 200, true, base);
|
|
111
|
-
}
|
|
112
|
-
}, {
|
|
113
|
-
key: "getActiveSchemaContent",
|
|
114
|
-
value: function getActiveSchemaContent(schemaId) {
|
|
115
|
-
return this.callApi('GET', 200, true, ["schemas", schemaId, "content"]);
|
|
116
|
-
}
|
|
117
|
-
}, {
|
|
118
|
-
key: "deleteSchema",
|
|
119
|
-
value: function deleteSchema(schemaId) {
|
|
120
|
-
var base = this.draftMode ? ["draft", "schemas", schemaId] : ["schemas", schemaId];
|
|
121
|
-
return this.callApi('DELETE', 204, false, base, null);
|
|
122
|
-
}
|
|
123
|
-
}, {
|
|
124
|
-
key: "createEventType",
|
|
125
|
-
value: function createEventType(name, description, schemaId) {
|
|
126
|
-
var body = {
|
|
127
|
-
'name': name,
|
|
128
|
-
'description': description,
|
|
129
|
-
'schemaId': schemaId
|
|
130
|
-
};
|
|
131
|
-
var base = this.draftMode ? ["draft", "event", "types"] : ["event", "types"];
|
|
132
|
-
return this.callApi('POST', 201, true, base, JSON.stringify(body));
|
|
133
|
-
}
|
|
134
|
-
}, {
|
|
135
|
-
key: "getEventType",
|
|
136
|
-
value: function getEventType(eventTypeId) {
|
|
137
|
-
var base = this.draftMode ? ["draft", "event", "types", eventTypeId] : ["event", "types", eventTypeId];
|
|
138
|
-
return this.callApi('GET', 200, true, base);
|
|
139
|
-
}
|
|
140
|
-
}, {
|
|
141
|
-
key: "getActiveEventType",
|
|
142
|
-
value: function getActiveEventType(eventTypeId) {
|
|
143
|
-
return this.callApi('GET', 200, true, ["event", "types", eventTypeId]);
|
|
144
|
-
}
|
|
145
|
-
}, {
|
|
146
|
-
key: "deleteEventType",
|
|
147
|
-
value: function deleteEventType(eventTypeId) {
|
|
148
|
-
var base = this.draftMode ? ["draft", "event", "types", eventTypeId] : ["event", "types", eventTypeId];
|
|
149
|
-
return this.callApi('DELETE', 204, false, base);
|
|
150
|
-
}
|
|
151
|
-
}, {
|
|
152
|
-
key: "updateEventType",
|
|
153
|
-
value: function updateEventType(eventTypeId, name, description, schemaId) {
|
|
154
|
-
var body = {
|
|
155
|
-
"id": eventTypeId,
|
|
156
|
-
"name": name,
|
|
157
|
-
"description": description,
|
|
158
|
-
"schemaId": schemaId
|
|
159
|
-
};
|
|
160
|
-
var base = this.draftMode ? ["draft", "event", "types", eventTypeId] : ["event", "types", eventTypeId];
|
|
161
|
-
return this.callApi('PUT', 200, true, base, body);
|
|
162
|
-
}
|
|
163
|
-
}, {
|
|
164
|
-
key: "getEventTypes",
|
|
165
|
-
value: function getEventTypes() {
|
|
166
|
-
var base = this.draftMode ? ["draft", "event", "types"] : ["event", "types"];
|
|
167
|
-
return this.callApi('GET', 200, true, base);
|
|
168
|
-
}
|
|
169
|
-
}, {
|
|
170
|
-
key: "getActiveEventTypes",
|
|
171
|
-
value: function getActiveEventTypes() {
|
|
172
|
-
return this.callApi('GET', 200, true, ["event", "types"]);
|
|
173
|
-
}
|
|
174
|
-
}, {
|
|
175
|
-
key: "createPhysicalInterface",
|
|
176
|
-
value: function createPhysicalInterface(name, description) {
|
|
177
|
-
var body = {
|
|
178
|
-
'name': name,
|
|
179
|
-
'description': description
|
|
180
|
-
};
|
|
181
|
-
var base = this.draftMode ? ["draft", "physicalinterfaces"] : ["physicalinterfaces"];
|
|
182
|
-
return this.callApi('POST', 201, true, base, body);
|
|
183
|
-
}
|
|
184
|
-
}, {
|
|
185
|
-
key: "getPhysicalInterface",
|
|
186
|
-
value: function getPhysicalInterface(physicalInterfaceId) {
|
|
187
|
-
var base = this.draftMode ? ["draft", "physicalinterfaces", physicalInterfaceId] : ["physicalinterfaces", physicalInterfaceId];
|
|
188
|
-
return this.callApi('GET', 200, true, base);
|
|
189
|
-
}
|
|
190
|
-
}, {
|
|
191
|
-
key: "getActivePhysicalInterface",
|
|
192
|
-
value: function getActivePhysicalInterface(physicalInterfaceId) {
|
|
193
|
-
return this.callApi('GET', 200, true, ["physicalinterfaces", physicalInterfaceId]);
|
|
194
|
-
}
|
|
195
|
-
}, {
|
|
196
|
-
key: "deletePhysicalInterface",
|
|
197
|
-
value: function deletePhysicalInterface(physicalInterfaceId) {
|
|
198
|
-
var base = this.draftMode ? ["draft", "physicalinterfaces", physicalInterfaceId] : ["physicalinterfaces", physicalInterfaceId];
|
|
199
|
-
return this.callApi('DELETE', 204, false, base);
|
|
200
|
-
}
|
|
201
|
-
}, {
|
|
202
|
-
key: "updatePhysicalInterface",
|
|
203
|
-
value: function updatePhysicalInterface(physicalInterfaceId, name, description) {
|
|
204
|
-
var body = {
|
|
205
|
-
'id': physicalInterfaceId,
|
|
206
|
-
'name': name,
|
|
207
|
-
'description': description
|
|
208
|
-
};
|
|
209
|
-
var base = this.draftMode ? ["draft", "physicalinterfaces", physicalInterfaceId] : ["physicalinterfaces", physicalInterfaceId];
|
|
210
|
-
return this.callApi('PUT', 200, true, base, body);
|
|
211
|
-
}
|
|
212
|
-
}, {
|
|
213
|
-
key: "getPhysicalInterfaces",
|
|
214
|
-
value: function getPhysicalInterfaces() {
|
|
215
|
-
var base = this.draftMode ? ["draft", "physicalinterfaces"] : ["physicalinterfaces"];
|
|
216
|
-
return this.callApi('GET', 200, true, base);
|
|
217
|
-
}
|
|
218
|
-
}, {
|
|
219
|
-
key: "getActivePhysicalInterfaces",
|
|
220
|
-
value: function getActivePhysicalInterfaces() {
|
|
221
|
-
return this.callApi('GET', 200, true, ["physicalinterfaces"]);
|
|
222
|
-
}
|
|
223
|
-
}, {
|
|
224
|
-
key: "createPhysicalInterfaceEventMapping",
|
|
225
|
-
value: function createPhysicalInterfaceEventMapping(physicalInterfaceId, eventId, eventTypeId) {
|
|
226
|
-
var body = {
|
|
227
|
-
"eventId": eventId,
|
|
228
|
-
"eventTypeId": eventTypeId
|
|
229
|
-
};
|
|
230
|
-
var base = this.draftMode ? ["draft", "physicalinterfaces", physicalInterfaceId, "events"] : ["physicalinterfaces", physicalInterfaceId, "events"];
|
|
231
|
-
return this.callApi('POST', 201, true, base, body);
|
|
232
|
-
}
|
|
233
|
-
}, {
|
|
234
|
-
key: "getPhysicalInterfaceEventMappings",
|
|
235
|
-
value: function getPhysicalInterfaceEventMappings(physicalInterfaceId) {
|
|
236
|
-
var base = this.draftMode ? ["draft", "physicalinterfaces", physicalInterfaceId, "events"] : ["physicalinterfaces", physicalInterfaceId, "events"];
|
|
237
|
-
return this.callApi('GET', 200, true, base);
|
|
238
|
-
}
|
|
239
|
-
}, {
|
|
240
|
-
key: "getActivePhysicalInterfaceEventMappings",
|
|
241
|
-
value: function getActivePhysicalInterfaceEventMappings(physicalInterfaceId) {
|
|
242
|
-
return this.callApi('GET', 200, true, ["physicalinterfaces", physicalInterfaceId, "events"]);
|
|
243
|
-
}
|
|
244
|
-
}, {
|
|
245
|
-
key: "deletePhysicalInterfaceEventMapping",
|
|
246
|
-
value: function deletePhysicalInterfaceEventMapping(physicalInterfaceId, eventId) {
|
|
247
|
-
var base = this.draftMode ? ["draft", "physicalinterfaces", physicalInterfaceId, "events", eventId] : ["physicalinterfaces", physicalInterfaceId, "events", eventId];
|
|
248
|
-
return this.callApi('DELETE', 204, false, base);
|
|
249
|
-
}
|
|
250
|
-
}, {
|
|
251
|
-
key: "createLogicalInterface",
|
|
252
|
-
value: function createLogicalInterface(name, description, schemaId, alias) {
|
|
253
|
-
var body = {
|
|
254
|
-
'name': name,
|
|
255
|
-
'description': description,
|
|
256
|
-
'schemaId': schemaId
|
|
257
|
-
};
|
|
258
|
-
if (alias !== undefined) {
|
|
259
|
-
body.alias = alias;
|
|
260
|
-
}
|
|
261
|
-
var base = this.draftMode ? ["draft", "logicalinterfaces"] : ["applicationinterfaces"];
|
|
262
|
-
return this.callApi('POST', 201, true, base, body);
|
|
263
|
-
}
|
|
264
|
-
}, {
|
|
265
|
-
key: "getLogicalInterface",
|
|
266
|
-
value: function getLogicalInterface(logicalInterfaceId) {
|
|
267
|
-
var base = this.draftMode ? ["draft", "logicalinterfaces", logicalInterfaceId] : ["applicationinterfaces", logicalInterfaceId];
|
|
268
|
-
return this.callApi('GET', 200, true, base);
|
|
269
|
-
}
|
|
270
|
-
}, {
|
|
271
|
-
key: "getActiveLogicalInterface",
|
|
272
|
-
value: function getActiveLogicalInterface(logicalInterfaceId) {
|
|
273
|
-
return this.callApi('GET', 200, true, ["logicalinterfaces", logicalInterfaceId]);
|
|
274
|
-
}
|
|
275
|
-
}, {
|
|
276
|
-
key: "deleteLogicalInterface",
|
|
277
|
-
value: function deleteLogicalInterface(logicalInterfaceId) {
|
|
278
|
-
var base = this.draftMode ? ["draft", "logicalinterfaces", logicalInterfaceId] : ["applicationinterfaces", logicalInterfaceId];
|
|
279
|
-
return this.callApi('DELETE', 204, false, base);
|
|
280
|
-
}
|
|
281
|
-
}, {
|
|
282
|
-
key: "updateLogicalInterface",
|
|
283
|
-
value: function updateLogicalInterface(logicalInterfaceId, name, description, schemaId, alias) {
|
|
284
|
-
var body = {
|
|
285
|
-
"id": logicalInterfaceId,
|
|
286
|
-
"name": name,
|
|
287
|
-
"description": description,
|
|
288
|
-
"schemaId": schemaId
|
|
289
|
-
};
|
|
290
|
-
if (alias !== undefined) {
|
|
291
|
-
body.alias = alias;
|
|
292
|
-
}
|
|
293
|
-
var base = this.draftMode ? ["draft", "logicalinterfaces", logicalInterfaceId] : ["applicationinterfaces", logicalInterfaceId];
|
|
294
|
-
return this.callApi('PUT', 200, true, base, body);
|
|
295
|
-
}
|
|
296
|
-
}, {
|
|
297
|
-
key: "getLogicalInterfaces",
|
|
298
|
-
value: function getLogicalInterfaces(bookmark, limit, sort, name) {
|
|
299
|
-
var base = this.draftMode ? ["draft", "logicalinterfaces"] : ["logicalinterfaces"];
|
|
300
|
-
var _sort = this.parseSortSpec(sort);
|
|
301
|
-
return this.callApi('GET', 200, true, base, undefined, {
|
|
302
|
-
_bookmark: bookmark,
|
|
303
|
-
_limit: limit,
|
|
304
|
-
_sort: _sort,
|
|
305
|
-
name: name ? name : undefined
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
}, {
|
|
309
|
-
key: "getActiveLogicalInterfaces",
|
|
310
|
-
value: function getActiveLogicalInterfaces() {
|
|
311
|
-
return this.callApi('GET', 200, true, ["logicalinterfaces"]);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// Application interface patch operation on draft version
|
|
315
|
-
// Acceptable operation id - validate-configuration, activate-configuration, list-differences
|
|
316
|
-
}, {
|
|
317
|
-
key: "patchOperationLogicalInterface",
|
|
318
|
-
value: function patchOperationLogicalInterface(logicalInterfaceId, operationId) {
|
|
319
|
-
var body = {
|
|
320
|
-
"operation": operationId
|
|
321
|
-
};
|
|
322
|
-
if (this.draftMode) {
|
|
323
|
-
switch (operationId) {
|
|
324
|
-
case 'validate-configuration':
|
|
325
|
-
return this.callApi('PATCH', 200, true, ["draft", "logicalinterfaces", logicalInterfaceId], body);
|
|
326
|
-
case 'activate-configuration':
|
|
327
|
-
return this.callApi('PATCH', 202, true, ["draft", "logicalinterfaces", logicalInterfaceId], body);
|
|
328
|
-
case 'deactivate-configuration':
|
|
329
|
-
return this.callApi('PATCH', 202, true, ["draft", "logicalinterfaces", logicalInterfaceId], body);
|
|
330
|
-
case 'list-differences':
|
|
331
|
-
return this.callApi('PATCH', 200, true, ["draft", "logicalinterfaces", logicalInterfaceId], body);
|
|
332
|
-
default:
|
|
333
|
-
return this.callApi('PATCH', 200, true, ["draft", "logicalinterfaces", logicalInterfaceId], body);
|
|
334
|
-
}
|
|
335
|
-
} else {
|
|
336
|
-
return this.invalidOperation("PATCH operation not allowed on active logical interface");
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// Application interface patch operation on active version
|
|
341
|
-
// Acceptable operation id - deactivate-configuration
|
|
342
|
-
}, {
|
|
343
|
-
key: "patchOperationActiveLogicalInterface",
|
|
344
|
-
value: function patchOperationActiveLogicalInterface(logicalInterfaceId, operationId) {
|
|
345
|
-
var body = {
|
|
346
|
-
"operation": operationId
|
|
347
|
-
};
|
|
348
|
-
if (this.draftMode) {
|
|
349
|
-
return this.callApi('PATCH', 202, true, ["logicalinterfaces", logicalInterfaceId], body);
|
|
350
|
-
} else {
|
|
351
|
-
return this.invalidOperation("PATCH operation 'deactivate-configuration' not allowed on logical interface");
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// Application interface patch operation on draft version
|
|
356
|
-
// Acceptable operation id - validate-configuration, activate-configuration, list-differences
|
|
357
|
-
}, {
|
|
358
|
-
key: "patchOperationDeviceType",
|
|
359
|
-
value:
|
|
360
|
-
// Device Type patch operation on draft version
|
|
361
|
-
// Acceptable operation id - validate-configuration, activate-configuration, list-differences
|
|
362
|
-
function patchOperationDeviceType(typeId, operationId) {
|
|
363
|
-
if (!operationId) {
|
|
364
|
-
return invalidOperation("PATCH operation is not allowed. Operation id is expected");
|
|
365
|
-
}
|
|
366
|
-
var body = {
|
|
367
|
-
"operation": operationId
|
|
368
|
-
};
|
|
369
|
-
var base = this.draftMode ? ['draft', 'device', 'types', typeId] : ['device', 'types', typeId];
|
|
370
|
-
if (this.draftMode) {
|
|
371
|
-
switch (operationId) {
|
|
372
|
-
case 'validate-configuration':
|
|
373
|
-
return this.callApi('PATCH', 200, true, base, body);
|
|
374
|
-
break;
|
|
375
|
-
case 'activate-configuration':
|
|
376
|
-
return this.callApi('PATCH', 202, true, base, body);
|
|
377
|
-
break;
|
|
378
|
-
case 'deactivate-configuration':
|
|
379
|
-
return this.callApi('PATCH', 202, true, base, body);
|
|
380
|
-
break;
|
|
381
|
-
case 'list-differences':
|
|
382
|
-
return this.callApi('PATCH', 200, true, base, body);
|
|
383
|
-
break;
|
|
384
|
-
default:
|
|
385
|
-
return this.invalidOperation("PATCH operation is not allowed. Invalid operation id");
|
|
386
|
-
}
|
|
387
|
-
} else {
|
|
388
|
-
switch (operationId) {
|
|
389
|
-
case 'validate-configuration':
|
|
390
|
-
return this.callApi('PATCH', 200, true, base, body);
|
|
391
|
-
break;
|
|
392
|
-
case 'deploy-configuration':
|
|
393
|
-
return this.callApi('PATCH', 202, true, base, body);
|
|
394
|
-
break;
|
|
395
|
-
case 'remove-deployed-configuration':
|
|
396
|
-
return this.callApi('PATCH', 202, true, base, body);
|
|
397
|
-
break;
|
|
398
|
-
case 'list-differences':
|
|
399
|
-
return this.invalidOperation("PATCH operation 'list-differences' is not allowed");
|
|
400
|
-
break;
|
|
401
|
-
default:
|
|
402
|
-
return this.invalidOperation("PATCH operation is not allowed. Invalid operation id");
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
// Device Type patch operation on active version
|
|
408
|
-
// Acceptable operation id - deactivate-configuration
|
|
409
|
-
}, {
|
|
410
|
-
key: "createDeviceType",
|
|
411
|
-
value:
|
|
412
|
-
// Create device type with physical Interface Id
|
|
413
|
-
function createDeviceType(typeId, description, deviceInfo, metadata, classId, physicalInterfaceId) {
|
|
414
|
-
this.log.debug("[ApiClient] registerDeviceType(" + typeId + ", " + description + ", " + deviceInfo + ", " + metadata + ", " + classId + ", " + physicalInterfaceId + ")");
|
|
415
|
-
classId = classId || "Device";
|
|
416
|
-
var body = {
|
|
417
|
-
id: typeId,
|
|
418
|
-
classId: classId,
|
|
419
|
-
deviceInfo: deviceInfo,
|
|
420
|
-
description: description,
|
|
421
|
-
metadata: metadata,
|
|
422
|
-
physicalInterfaceId: physicalInterfaceId
|
|
423
|
-
};
|
|
424
|
-
return this.callApi('POST', 201, true, ['device', 'types'], JSON.stringify(body));
|
|
425
|
-
}
|
|
426
|
-
}, {
|
|
427
|
-
key: "getDeviceTypesByLogicalInterfaceId",
|
|
428
|
-
value: function getDeviceTypesByLogicalInterfaceId(logicalInterfaceId) {
|
|
429
|
-
var bookmark = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
430
|
-
var limit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
|
|
431
|
-
if (this.draftMode) {
|
|
432
|
-
return this.callApi('GET', 200, true, ['draft', 'device', 'types'], null, {
|
|
433
|
-
logicalInterfaceId: logicalInterfaceId,
|
|
434
|
-
'_bookmark': bookmark,
|
|
435
|
-
'_limit': limit
|
|
436
|
-
});
|
|
437
|
-
} else {
|
|
438
|
-
return this.callApi('GET', 200, true, ['device', 'types'], null, {
|
|
439
|
-
'_bookmark': bookmark,
|
|
440
|
-
'_limit': limit
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}, {
|
|
445
|
-
key: "createDeviceTypePhysicalInterfaceAssociation",
|
|
446
|
-
value: function createDeviceTypePhysicalInterfaceAssociation(typeId, physicalInterfaceId) {
|
|
447
|
-
var body = {
|
|
448
|
-
id: physicalInterfaceId
|
|
449
|
-
};
|
|
450
|
-
if (this.draftMode) {
|
|
451
|
-
return this.callApi('POST', 201, true, ['draft', 'device', 'types', typeId, 'physicalinterface'], JSON.stringify(body));
|
|
452
|
-
} else {
|
|
453
|
-
return this.callApi('PUT', 200, true, ['device', 'types', typeId], JSON.stringify({
|
|
454
|
-
physicalInterfaceId: physicalInterfaceId
|
|
455
|
-
}));
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}, {
|
|
459
|
-
key: "getDeviceTypePhysicalInterfaces",
|
|
460
|
-
value: function getDeviceTypePhysicalInterfaces(typeId) {
|
|
461
|
-
if (this.draftMode) {
|
|
462
|
-
return this.callApi('GET', 200, true, ['draft', 'device', 'types', typeId, 'physicalinterface']);
|
|
463
|
-
} else {
|
|
464
|
-
return this.invalidOperation("GET Device type's physical interface is not allowed");
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}, {
|
|
468
|
-
key: "getActiveDeviceTypePhysicalInterfaces",
|
|
469
|
-
value: function getActiveDeviceTypePhysicalInterfaces(typeId) {
|
|
470
|
-
return this.callApi('GET', 200, true, ['device', 'types', typeId, 'physicalinterface']);
|
|
471
|
-
}
|
|
472
|
-
}, {
|
|
473
|
-
key: "deleteDeviceTypePhysicalInterfaceAssociation",
|
|
474
|
-
value: function deleteDeviceTypePhysicalInterfaceAssociation(typeId) {
|
|
475
|
-
if (this.draftMode) {
|
|
476
|
-
return this.callApi('DELETE', 204, false, ['draft', 'device', 'types', typeId, 'physicalinterface']);
|
|
477
|
-
} else {
|
|
478
|
-
return this.invalidOperation("DELETE Device type's physical interface is not allowed");
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
}, {
|
|
482
|
-
key: "createDeviceTypeLogicalInterfaceAssociation",
|
|
483
|
-
value: function createDeviceTypeLogicalInterfaceAssociation(typeId, logicalInterfaceId) {
|
|
484
|
-
var body = {
|
|
485
|
-
'id': logicalInterfaceId
|
|
486
|
-
};
|
|
487
|
-
var base = this.draftMode ? ['draft', 'device', 'types', typeId, 'logicalinterfaces'] : ['device', 'types', typeId, 'applicationinterfaces'];
|
|
488
|
-
return this.callApi('POST', 201, true, base, body);
|
|
489
|
-
}
|
|
490
|
-
}, {
|
|
491
|
-
key: "getDeviceTypeLogicalInterfaces",
|
|
492
|
-
value: function getDeviceTypeLogicalInterfaces(typeId) {
|
|
493
|
-
var base = this.draftMode ? ['draft', 'device', 'types', typeId, 'logicalinterfaces'] : ['device', 'types', typeId, 'applicationinterfaces'];
|
|
494
|
-
return this.callApi('GET', 200, true, base);
|
|
495
|
-
}
|
|
496
|
-
}, {
|
|
497
|
-
key: "getActiveDeviceTypeLogicalInterfaces",
|
|
498
|
-
value: function getActiveDeviceTypeLogicalInterfaces(typeId) {
|
|
499
|
-
return this.callApi('GET', 200, true, ['device', 'types', typeId, 'logicalinterfaces']);
|
|
500
|
-
}
|
|
501
|
-
}, {
|
|
502
|
-
key: "createDeviceTypeLogicalInterfacePropertyMappings",
|
|
503
|
-
value: function createDeviceTypeLogicalInterfacePropertyMappings(typeId, logicalInterfaceId, mappings, notificationStrategy) {
|
|
504
|
-
var body = null,
|
|
505
|
-
base = null;
|
|
506
|
-
if (this.draftMode) {
|
|
507
|
-
body = {
|
|
508
|
-
"logicalInterfaceId": logicalInterfaceId,
|
|
509
|
-
"propertyMappings": mappings,
|
|
510
|
-
"notificationStrategy": "never"
|
|
511
|
-
};
|
|
512
|
-
if (notificationStrategy) {
|
|
513
|
-
body.notificationStrategy = notificationStrategy;
|
|
514
|
-
}
|
|
515
|
-
base = ['draft', 'device', 'types', typeId, 'mappings'];
|
|
516
|
-
} else {
|
|
517
|
-
body = {
|
|
518
|
-
"applicationInterfaceId": logicalInterfaceId,
|
|
519
|
-
"propertyMappings": mappings
|
|
520
|
-
};
|
|
521
|
-
base = ['device', 'types', typeId, 'mappings'];
|
|
522
|
-
}
|
|
523
|
-
return this.callApi('POST', 201, true, base, body);
|
|
524
|
-
}
|
|
525
|
-
}, {
|
|
526
|
-
key: "getDeviceTypePropertyMappings",
|
|
527
|
-
value: function getDeviceTypePropertyMappings(typeId) {
|
|
528
|
-
var base = this.draftMode ? ['draft', 'device', 'types', typeId, 'mappings'] : ['device', 'types', typeId, 'mappings'];
|
|
529
|
-
return this.callApi('GET', 200, true, base);
|
|
530
|
-
}
|
|
531
|
-
}, {
|
|
532
|
-
key: "getActiveDeviceTypePropertyMappings",
|
|
533
|
-
value: function getActiveDeviceTypePropertyMappings(typeId) {
|
|
534
|
-
return this.callApi('GET', 200, true, ['device', 'types', typeId, 'mappings']);
|
|
535
|
-
}
|
|
536
|
-
}, {
|
|
537
|
-
key: "getDeviceTypeLogicalInterfacePropertyMappings",
|
|
538
|
-
value: function getDeviceTypeLogicalInterfacePropertyMappings(typeId, logicalInterfaceId) {
|
|
539
|
-
var base = this.draftMode ? ['draft', 'device', 'types', typeId, 'mappings', logicalInterfaceId] : ['device', 'types', typeId, 'mappings', logicalInterfaceId];
|
|
540
|
-
return this.callApi('GET', 200, true, base);
|
|
541
|
-
}
|
|
542
|
-
}, {
|
|
543
|
-
key: "getActiveDeviceTypeLogicalInterfacePropertyMappings",
|
|
544
|
-
value: function getActiveDeviceTypeLogicalInterfacePropertyMappings(typeId, logicalInterfaceId) {
|
|
545
|
-
return this.callApi('GET', 200, true, ['device', 'types', typeId, 'mappings', logicalInterfaceId]);
|
|
546
|
-
}
|
|
547
|
-
}, {
|
|
548
|
-
key: "updateDeviceTypeLogicalInterfacePropertyMappings",
|
|
549
|
-
value: function updateDeviceTypeLogicalInterfacePropertyMappings(typeId, logicalInterfaceId, mappings, notificationStrategy) {
|
|
550
|
-
var body = null,
|
|
551
|
-
base = null;
|
|
552
|
-
if (this.draftMode) {
|
|
553
|
-
body = {
|
|
554
|
-
"logicalInterfaceId": logicalInterfaceId,
|
|
555
|
-
"propertyMappings": mappings,
|
|
556
|
-
"notificationStrategy": "never"
|
|
557
|
-
};
|
|
558
|
-
if (notificationStrategy) {
|
|
559
|
-
body.notificationStrategy = notificationStrategy;
|
|
560
|
-
}
|
|
561
|
-
base = ['draft', 'device', 'types', typeId, 'mappings', logicalInterfaceId];
|
|
562
|
-
} else {
|
|
563
|
-
body = {
|
|
564
|
-
"applicationInterfaceId": logicalInterfaceId,
|
|
565
|
-
"propertyMappings": mappings
|
|
566
|
-
};
|
|
567
|
-
base = ['device', 'types', typeId, 'mappings', logicalInterfaceId];
|
|
568
|
-
}
|
|
569
|
-
return this.callApi('PUT', 200, false, base, body);
|
|
570
|
-
}
|
|
571
|
-
}, {
|
|
572
|
-
key: "deleteDeviceTypeLogicalInterfacePropertyMappings",
|
|
573
|
-
value: function deleteDeviceTypeLogicalInterfacePropertyMappings(typeId, logicalInterfaceId) {
|
|
574
|
-
var base = this.draftMode ? ['draft', 'device', 'types', typeId, 'mappings', logicalInterfaceId] : ['device', 'types', typeId, 'mappings', logicalInterfaceId];
|
|
575
|
-
return this.callApi('DELETE', 204, false, base);
|
|
576
|
-
}
|
|
577
|
-
}, {
|
|
578
|
-
key: "deleteDeviceTypeLogicalInterfaceAssociation",
|
|
579
|
-
value: function deleteDeviceTypeLogicalInterfaceAssociation(typeId, logicalInterfaceId) {
|
|
580
|
-
var base = this.draftMode ? ['draft', 'device', 'types', typeId, 'logicalinterfaces', logicalInterfaceId] : ['device', 'types', typeId, 'applicationinterfaces', logicalInterfaceId];
|
|
581
|
-
return this.callApi('DELETE', 204, false, base);
|
|
582
|
-
}
|
|
583
|
-
}, {
|
|
584
|
-
key: "patchOperationActiveDeviceType",
|
|
585
|
-
value: function patchOperationActiveDeviceType(typeId, operationId) {
|
|
586
|
-
var body = {
|
|
587
|
-
"operation": operationId
|
|
588
|
-
};
|
|
589
|
-
if (this.draftMode) {
|
|
590
|
-
return this.callApi('PATCH', 202, true, ['device', 'types', typeId], body);
|
|
591
|
-
} else {
|
|
592
|
-
return this.invalidOperation("PATCH operation 'deactivate-configuration' is not allowed");
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}, {
|
|
596
|
-
key: "getDeviceTypeDeployedConfiguration",
|
|
597
|
-
value: function getDeviceTypeDeployedConfiguration(typeId) {
|
|
598
|
-
if (this.draftMode) {
|
|
599
|
-
return this.invalidOperation("GET deployed configuration is not allowed");
|
|
600
|
-
} else {
|
|
601
|
-
return this.callApi('GET', 200, true, ['device', 'types', typeId, 'deployedconfiguration']);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
}, {
|
|
605
|
-
key: "getDeviceState",
|
|
606
|
-
value: function getDeviceState(typeId, deviceId, logicalInterfaceId) {
|
|
607
|
-
return this.callApi('GET', 200, true, ['device', 'types', typeId, 'devices', deviceId, 'state', logicalInterfaceId]);
|
|
608
|
-
}
|
|
609
|
-
}, {
|
|
610
|
-
key: "createSchemaAndEventType",
|
|
611
|
-
value: function createSchemaAndEventType(schemaContents, schemaFileName, eventTypeName, eventDescription) {
|
|
612
|
-
var _this = this;
|
|
613
|
-
var body = {
|
|
614
|
-
'schemaFile': schemaContents,
|
|
615
|
-
'schemaType': 'json-schema',
|
|
616
|
-
'name': schemaFileName
|
|
617
|
-
};
|
|
618
|
-
var createSchema = new Promise(function (resolve, reject) {
|
|
619
|
-
var base = _this.draftMode ? ["draft", "schemas"] : ["schemas"];
|
|
620
|
-
_this.callFormDataApi('POST', 201, true, base, body, null).then(function (result) {
|
|
621
|
-
resolve(result);
|
|
622
|
-
}, function (error) {
|
|
623
|
-
reject(error);
|
|
624
|
-
});
|
|
625
|
-
});
|
|
626
|
-
return createSchema.then(function (value) {
|
|
627
|
-
var schemaId = value["id"];
|
|
628
|
-
return _this.createEventType(eventTypeName, eventDescription, schemaId);
|
|
629
|
-
});
|
|
630
|
-
}
|
|
631
|
-
}, {
|
|
632
|
-
key: "createSchemaAndLogicalInterface",
|
|
633
|
-
value: function createSchemaAndLogicalInterface(schemaContents, schemaFileName, appInterfaceName, appInterfaceDescription, appInterfaceAlias) {
|
|
634
|
-
var _this2 = this;
|
|
635
|
-
var body = {
|
|
636
|
-
'schemaFile': schemaContents,
|
|
637
|
-
'schemaType': 'json-schema',
|
|
638
|
-
'name': schemaFileName
|
|
639
|
-
};
|
|
640
|
-
var createSchema = new Promise(function (resolve, reject) {
|
|
641
|
-
var base = _this2.draftMode ? ["draft", "schemas"] : ["schemas"];
|
|
642
|
-
_this2.callFormDataApi('POST', 201, true, base, body, null).then(function (result) {
|
|
643
|
-
resolve(result);
|
|
644
|
-
}, function (error) {
|
|
645
|
-
reject(error);
|
|
646
|
-
});
|
|
647
|
-
});
|
|
648
|
-
return createSchema.then(function (value) {
|
|
649
|
-
var schemaId = value.id;
|
|
650
|
-
return _this2.createLogicalInterface(appInterfaceName, appInterfaceDescription, schemaId, appInterfaceAlias);
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
}, {
|
|
654
|
-
key: "createPhysicalInterfaceWithEventMapping",
|
|
655
|
-
value: function createPhysicalInterfaceWithEventMapping(physicalInterfaceName, description, eventId, eventTypeId) {
|
|
656
|
-
var _this3 = this;
|
|
657
|
-
var createPhysicalInterface = new Promise(function (resolve, reject) {
|
|
658
|
-
_this3.createPhysicalInterface(physicalInterfaceName, description).then(function (result) {
|
|
659
|
-
resolve(result);
|
|
660
|
-
}, function (error) {
|
|
661
|
-
reject(error);
|
|
662
|
-
});
|
|
663
|
-
});
|
|
664
|
-
return createPhysicalInterface.then(function (value) {
|
|
665
|
-
var physicalInterface = value;
|
|
666
|
-
var PhysicalInterfaceEventMapping = new Promise(function (resolve, reject) {
|
|
667
|
-
_this3.createPhysicalInterfaceEventMapping(physicalInterface.id, eventId, eventTypeId).then(function (result) {
|
|
668
|
-
resolve([physicalInterface, result]);
|
|
669
|
-
}, function (error) {
|
|
670
|
-
reject(error);
|
|
671
|
-
});
|
|
672
|
-
});
|
|
673
|
-
return PhysicalInterfaceEventMapping.then(function (result) {
|
|
674
|
-
return result;
|
|
675
|
-
});
|
|
676
|
-
});
|
|
677
|
-
}
|
|
678
|
-
}, {
|
|
679
|
-
key: "createDeviceTypeLogicalInterfaceEventMapping",
|
|
680
|
-
value: function createDeviceTypeLogicalInterfaceEventMapping(deviceTypeName, description, logicalInterfaceId, eventMapping, notificationStrategy) {
|
|
681
|
-
var _this4 = this;
|
|
682
|
-
var createDeviceType = new Promise(function (resolve, reject) {
|
|
683
|
-
_this4.createDeviceType(deviceTypeName, description).then(function (result) {
|
|
684
|
-
resolve(result);
|
|
685
|
-
}, function (error) {
|
|
686
|
-
reject(error);
|
|
687
|
-
});
|
|
688
|
-
});
|
|
689
|
-
return createDeviceType.then(function (result) {
|
|
690
|
-
var deviceObject = result;
|
|
691
|
-
var deviceTypeLogicalInterface = null;
|
|
692
|
-
var deviceTypeLogicalInterface = new Promise(function (resolve, reject) {
|
|
693
|
-
_this4.createDeviceTypeLogicalInterfaceAssociation(deviceObject.id, logicalInterfaceId).then(function (result) {
|
|
694
|
-
resolve(result);
|
|
695
|
-
}, function (error) {
|
|
696
|
-
reject(error);
|
|
697
|
-
});
|
|
698
|
-
});
|
|
699
|
-
return deviceTypeLogicalInterface.then(function (result) {
|
|
700
|
-
deviceTypeLogicalInterface = result;
|
|
701
|
-
var deviceTypeLogicalInterfacePropertyMappings = new Promise(function (resolve, reject) {
|
|
702
|
-
var notificationstrategy = "never";
|
|
703
|
-
if (notificationStrategy) {
|
|
704
|
-
notificationstrategy = notificationStrategy;
|
|
705
|
-
}
|
|
706
|
-
_this4.createDeviceTypeLogicalInterfacePropertyMappings(deviceObject.id, logicalInterfaceId, eventMapping, notificationstrategy).then(function (result) {
|
|
707
|
-
var arr = [deviceObject, deviceTypeLogicalInterface, result];
|
|
708
|
-
resolve(arr);
|
|
709
|
-
}, function (error) {
|
|
710
|
-
reject(error);
|
|
711
|
-
});
|
|
712
|
-
});
|
|
713
|
-
return deviceTypeLogicalInterfacePropertyMappings.then(function (result) {
|
|
714
|
-
return result;
|
|
715
|
-
});
|
|
716
|
-
});
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
|
-
}]);
|
|
720
|
-
}();
|
|
721
|
-
;
|