@itentialopensource/adapter-etsi_sol005 0.1.1 → 0.2.0
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/AUTH.md +39 -0
- package/BROKER.md +199 -0
- package/CALLS.md +169 -0
- package/CHANGELOG.md +9 -2
- package/CODE_OF_CONDUCT.md +12 -17
- package/CONTRIBUTING.md +88 -74
- package/ENHANCE.md +69 -0
- package/PROPERTIES.md +641 -0
- package/README.md +221 -571
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +292 -469
- package/adapterBase.js +1006 -252
- package/entities/.generic/action.json +105 -0
- package/entities/.generic/schema.json +6 -1
- package/error.json +6 -0
- package/package.json +5 -3
- package/pronghorn.json +642 -570
- package/propertiesDecorators.json +14 -0
- package/propertiesSchema.json +421 -0
- package/refs?service=git-upload-pack +0 -0
- package/report/adapterInfo.json +10 -0
- package/report/updateReport1653138350600.json +120 -0
- package/sampleProperties.json +90 -1
- package/test/integration/adapterTestBasicGet.js +1 -1
- package/test/integration/adapterTestIntegration.js +2097 -2747
- package/test/unit/adapterBaseTestUnit.js +30 -25
- package/test/unit/adapterTestUnit.js +90 -177
- package/utils/adapterInfo.js +206 -0
- package/utils/entitiesToDB.js +12 -57
- package/utils/pre-commit.sh +3 -0
- package/utils/tbScript.js +35 -20
- package/utils/tbUtils.js +49 -31
- package/utils/testRunner.js +16 -16
package/adapter.js
CHANGED
|
@@ -80,10 +80,18 @@ class EtsiSol005 extends AdapterBaseCl {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
|
-
* @
|
|
83
|
+
* @iapGetAdapterWorkflowFunctions
|
|
84
84
|
*/
|
|
85
|
-
|
|
86
|
-
let myIgnore = [
|
|
85
|
+
iapGetAdapterWorkflowFunctions(inIgnore) {
|
|
86
|
+
let myIgnore = [
|
|
87
|
+
'healthCheck',
|
|
88
|
+
'iapGetAdapterWorkflowFunctions',
|
|
89
|
+
'iapHasAdapterEntity',
|
|
90
|
+
'iapVerifyAdapterCapability',
|
|
91
|
+
'iapUpdateAdapterEntityCache',
|
|
92
|
+
'hasEntities',
|
|
93
|
+
'getAuthorization'
|
|
94
|
+
];
|
|
87
95
|
if (!inIgnore && Array.isArray(inIgnore)) {
|
|
88
96
|
myIgnore = inIgnore;
|
|
89
97
|
} else if (!inIgnore && typeof inIgnore === 'string') {
|
|
@@ -94,15 +102,15 @@ class EtsiSol005 extends AdapterBaseCl {
|
|
|
94
102
|
// you can add specific methods that you do not want to be workflow functions to ignore like below
|
|
95
103
|
// myIgnore.push('myMethodNotInWorkflow');
|
|
96
104
|
|
|
97
|
-
return super.
|
|
105
|
+
return super.iapGetAdapterWorkflowFunctions(myIgnore);
|
|
98
106
|
}
|
|
99
107
|
|
|
100
108
|
/**
|
|
101
|
-
*
|
|
109
|
+
* iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
|
|
102
110
|
* allows customers to make changes to adapter configuration without having to be on the
|
|
103
111
|
* file system.
|
|
104
112
|
*
|
|
105
|
-
* @function
|
|
113
|
+
* @function iapUpdateAdapterConfiguration
|
|
106
114
|
* @param {string} configFile - the name of the file being updated (required)
|
|
107
115
|
* @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
|
|
108
116
|
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
@@ -110,36 +118,42 @@ class EtsiSol005 extends AdapterBaseCl {
|
|
|
110
118
|
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
111
119
|
* @param {Callback} callback - The results of the call
|
|
112
120
|
*/
|
|
113
|
-
|
|
114
|
-
const
|
|
121
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
|
122
|
+
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
|
123
|
+
const origin = `${this.id}-${meth}`;
|
|
115
124
|
log.trace(origin);
|
|
116
|
-
|
|
125
|
+
|
|
126
|
+
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
|
117
127
|
}
|
|
118
128
|
|
|
119
129
|
/**
|
|
120
130
|
* See if the API path provided is found in this adapter
|
|
121
131
|
*
|
|
122
|
-
* @function
|
|
132
|
+
* @function iapFindAdapterPath
|
|
123
133
|
* @param {string} apiPath - the api path to check on
|
|
124
134
|
* @param {Callback} callback - The results of the call
|
|
125
135
|
*/
|
|
126
|
-
|
|
127
|
-
const
|
|
136
|
+
iapFindAdapterPath(apiPath, callback) {
|
|
137
|
+
const meth = 'adapter-iapFindAdapterPath';
|
|
138
|
+
const origin = `${this.id}-${meth}`;
|
|
128
139
|
log.trace(origin);
|
|
129
|
-
|
|
140
|
+
|
|
141
|
+
super.iapFindAdapterPath(apiPath, callback);
|
|
130
142
|
}
|
|
131
143
|
|
|
132
144
|
/**
|
|
133
145
|
* @summary Suspends adapter
|
|
134
146
|
*
|
|
135
|
-
* @function
|
|
147
|
+
* @function iapSuspendAdapter
|
|
136
148
|
* @param {Callback} callback - callback function
|
|
137
149
|
*/
|
|
138
|
-
|
|
139
|
-
const
|
|
150
|
+
iapSuspendAdapter(mode, callback) {
|
|
151
|
+
const meth = 'adapter-iapSuspendAdapter';
|
|
152
|
+
const origin = `${this.id}-${meth}`;
|
|
140
153
|
log.trace(origin);
|
|
154
|
+
|
|
141
155
|
try {
|
|
142
|
-
return super.
|
|
156
|
+
return super.iapSuspendAdapter(mode, callback);
|
|
143
157
|
} catch (error) {
|
|
144
158
|
log.error(`${origin}: ${error}`);
|
|
145
159
|
return callback(null, error);
|
|
@@ -149,14 +163,16 @@ class EtsiSol005 extends AdapterBaseCl {
|
|
|
149
163
|
/**
|
|
150
164
|
* @summary Unsuspends adapter
|
|
151
165
|
*
|
|
152
|
-
* @function
|
|
166
|
+
* @function iapUnsuspendAdapter
|
|
153
167
|
* @param {Callback} callback - callback function
|
|
154
168
|
*/
|
|
155
|
-
|
|
156
|
-
const
|
|
169
|
+
iapUnsuspendAdapter(callback) {
|
|
170
|
+
const meth = 'adapter-iapUnsuspendAdapter';
|
|
171
|
+
const origin = `${this.id}-${meth}`;
|
|
157
172
|
log.trace(origin);
|
|
173
|
+
|
|
158
174
|
try {
|
|
159
|
-
return super.
|
|
175
|
+
return super.iapUnsuspendAdapter(callback);
|
|
160
176
|
} catch (error) {
|
|
161
177
|
log.error(`${origin}: ${error}`);
|
|
162
178
|
return callback(null, error);
|
|
@@ -166,29 +182,33 @@ class EtsiSol005 extends AdapterBaseCl {
|
|
|
166
182
|
/**
|
|
167
183
|
* @summary Get the Adaoter Queue
|
|
168
184
|
*
|
|
169
|
-
* @function
|
|
185
|
+
* @function iapGetAdapterQueue
|
|
170
186
|
* @param {Callback} callback - callback function
|
|
171
187
|
*/
|
|
172
|
-
|
|
173
|
-
const
|
|
188
|
+
iapGetAdapterQueue(callback) {
|
|
189
|
+
const meth = 'adapter-iapGetAdapterQueue';
|
|
190
|
+
const origin = `${this.id}-${meth}`;
|
|
174
191
|
log.trace(origin);
|
|
175
|
-
|
|
192
|
+
|
|
193
|
+
return super.iapGetAdapterQueue(callback);
|
|
176
194
|
}
|
|
177
195
|
|
|
178
196
|
/**
|
|
179
197
|
* @summary Runs troubleshoot scripts for adapter
|
|
180
198
|
*
|
|
181
|
-
* @function
|
|
199
|
+
* @function iapTroubleshootAdapter
|
|
182
200
|
* @param {Object} props - the connection, healthcheck and authentication properties
|
|
183
201
|
*
|
|
184
202
|
* @param {boolean} persistFlag - whether the adapter properties should be updated
|
|
185
203
|
* @param {Callback} callback - The results of the call
|
|
186
204
|
*/
|
|
187
|
-
|
|
188
|
-
const
|
|
205
|
+
iapTroubleshootAdapter(props, persistFlag, callback) {
|
|
206
|
+
const meth = 'adapter-iapTroubleshootAdapter';
|
|
207
|
+
const origin = `${this.id}-${meth}`;
|
|
189
208
|
log.trace(origin);
|
|
209
|
+
|
|
190
210
|
try {
|
|
191
|
-
return super.
|
|
211
|
+
return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
|
|
192
212
|
} catch (error) {
|
|
193
213
|
log.error(`${origin}: ${error}`);
|
|
194
214
|
return callback(null, error);
|
|
@@ -198,15 +218,17 @@ class EtsiSol005 extends AdapterBaseCl {
|
|
|
198
218
|
/**
|
|
199
219
|
* @summary runs healthcheck script for adapter
|
|
200
220
|
*
|
|
201
|
-
* @function
|
|
221
|
+
* @function iapRunAdapterHealthcheck
|
|
202
222
|
* @param {Adapter} adapter - adapter instance to troubleshoot
|
|
203
223
|
* @param {Callback} callback - callback function
|
|
204
224
|
*/
|
|
205
|
-
|
|
206
|
-
const
|
|
225
|
+
iapRunAdapterHealthcheck(callback) {
|
|
226
|
+
const meth = 'adapter-iapRunAdapterHealthcheck';
|
|
227
|
+
const origin = `${this.id}-${meth}`;
|
|
207
228
|
log.trace(origin);
|
|
229
|
+
|
|
208
230
|
try {
|
|
209
|
-
return super.
|
|
231
|
+
return super.iapRunAdapterHealthcheck(this, callback);
|
|
210
232
|
} catch (error) {
|
|
211
233
|
log.error(`${origin}: ${error}`);
|
|
212
234
|
return callback(null, error);
|
|
@@ -216,14 +238,16 @@ class EtsiSol005 extends AdapterBaseCl {
|
|
|
216
238
|
/**
|
|
217
239
|
* @summary runs connectivity check script for adapter
|
|
218
240
|
*
|
|
219
|
-
* @function
|
|
241
|
+
* @function iapRunAdapterConnectivity
|
|
220
242
|
* @param {Callback} callback - callback function
|
|
221
243
|
*/
|
|
222
|
-
|
|
223
|
-
const
|
|
244
|
+
iapRunAdapterConnectivity(callback) {
|
|
245
|
+
const meth = 'adapter-iapRunAdapterConnectivity';
|
|
246
|
+
const origin = `${this.id}-${meth}`;
|
|
224
247
|
log.trace(origin);
|
|
248
|
+
|
|
225
249
|
try {
|
|
226
|
-
return super.
|
|
250
|
+
return super.iapRunAdapterConnectivity(callback);
|
|
227
251
|
} catch (error) {
|
|
228
252
|
log.error(`${origin}: ${error}`);
|
|
229
253
|
return callback(null, error);
|
|
@@ -233,14 +257,16 @@ class EtsiSol005 extends AdapterBaseCl {
|
|
|
233
257
|
/**
|
|
234
258
|
* @summary runs basicGet script for adapter
|
|
235
259
|
*
|
|
236
|
-
* @function
|
|
260
|
+
* @function iapRunAdapterBasicGet
|
|
237
261
|
* @param {Callback} callback - callback function
|
|
238
262
|
*/
|
|
239
|
-
|
|
240
|
-
const
|
|
263
|
+
iapRunAdapterBasicGet(callback) {
|
|
264
|
+
const meth = 'adapter-iapRunAdapterBasicGet';
|
|
265
|
+
const origin = `${this.id}-${meth}`;
|
|
241
266
|
log.trace(origin);
|
|
267
|
+
|
|
242
268
|
try {
|
|
243
|
-
return super.
|
|
269
|
+
return super.iapRunAdapterBasicGet(callback);
|
|
244
270
|
} catch (error) {
|
|
245
271
|
log.error(`${origin}: ${error}`);
|
|
246
272
|
return callback(null, error);
|
|
@@ -250,45 +276,48 @@ class EtsiSol005 extends AdapterBaseCl {
|
|
|
250
276
|
/**
|
|
251
277
|
* @summary moves entites into Mongo DB
|
|
252
278
|
*
|
|
253
|
-
* @function
|
|
279
|
+
* @function iapMoveAdapterEntitiesToDB
|
|
254
280
|
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
255
281
|
* or the error
|
|
256
282
|
*/
|
|
257
|
-
|
|
258
|
-
const
|
|
283
|
+
iapMoveAdapterEntitiesToDB(callback) {
|
|
284
|
+
const meth = 'adapter-iapMoveAdapterEntitiesToDB';
|
|
285
|
+
const origin = `${this.id}-${meth}`;
|
|
259
286
|
log.trace(origin);
|
|
287
|
+
|
|
260
288
|
try {
|
|
261
|
-
return super.
|
|
289
|
+
return super.iapMoveAdapterEntitiesToDB(callback);
|
|
262
290
|
} catch (err) {
|
|
263
291
|
log.error(`${origin}: ${err}`);
|
|
264
292
|
return callback(null, err);
|
|
265
293
|
}
|
|
266
294
|
}
|
|
267
295
|
|
|
296
|
+
/* BROKER CALLS */
|
|
268
297
|
/**
|
|
269
298
|
* @summary Determines if this adapter supports the specific entity
|
|
270
299
|
*
|
|
271
|
-
* @function
|
|
300
|
+
* @function iapHasAdapterEntity
|
|
272
301
|
* @param {String} entityType - the entity type to check for
|
|
273
302
|
* @param {String/Array} entityId - the specific entity we are looking for
|
|
274
303
|
*
|
|
275
304
|
* @param {Callback} callback - An array of whether the adapter can has the
|
|
276
305
|
* desired capability or an error
|
|
277
306
|
*/
|
|
278
|
-
|
|
279
|
-
const origin = `${this.id}-adapter-
|
|
307
|
+
iapHasAdapterEntity(entityType, entityId, callback) {
|
|
308
|
+
const origin = `${this.id}-adapter-iapHasAdapterEntity`;
|
|
280
309
|
log.trace(origin);
|
|
281
310
|
|
|
282
311
|
// Make the call -
|
|
283
|
-
//
|
|
284
|
-
return this.
|
|
312
|
+
// iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
|
313
|
+
return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
|
|
285
314
|
}
|
|
286
315
|
|
|
287
316
|
/**
|
|
288
317
|
* @summary Provides a way for the adapter to tell north bound integrations
|
|
289
318
|
* whether the adapter supports type, action and specific entity
|
|
290
319
|
*
|
|
291
|
-
* @function
|
|
320
|
+
* @function iapVerifyAdapterCapability
|
|
292
321
|
* @param {String} entityType - the entity type to check for
|
|
293
322
|
* @param {String} actionType - the action type to check for
|
|
294
323
|
* @param {String/Array} entityId - the specific entity we are looking for
|
|
@@ -296,15 +325,15 @@ class EtsiSol005 extends AdapterBaseCl {
|
|
|
296
325
|
* @param {Callback} callback - An array of whether the adapter can has the
|
|
297
326
|
* desired capability or an error
|
|
298
327
|
*/
|
|
299
|
-
|
|
300
|
-
const meth = 'adapterBase-
|
|
328
|
+
iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
|
|
329
|
+
const meth = 'adapterBase-iapVerifyAdapterCapability';
|
|
301
330
|
const origin = `${this.id}-${meth}`;
|
|
302
331
|
log.trace(origin);
|
|
303
332
|
|
|
304
333
|
// if caching
|
|
305
334
|
if (this.caching) {
|
|
306
|
-
// Make the call -
|
|
307
|
-
return this.requestHandlerInst.
|
|
335
|
+
// Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
|
336
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
|
|
308
337
|
if (error) {
|
|
309
338
|
return callback(null, error);
|
|
310
339
|
}
|
|
@@ -322,7 +351,7 @@ class EtsiSol005 extends AdapterBaseCl {
|
|
|
322
351
|
}
|
|
323
352
|
|
|
324
353
|
// need to check the cache again since it has been updated
|
|
325
|
-
return this.requestHandlerInst.
|
|
354
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
326
355
|
if (verror) {
|
|
327
356
|
return callback(null, verror);
|
|
328
357
|
}
|
|
@@ -355,7 +384,7 @@ class EtsiSol005 extends AdapterBaseCl {
|
|
|
355
384
|
// if no entity id
|
|
356
385
|
if (!entityId) {
|
|
357
386
|
// need to check the cache again since it has been updated
|
|
358
|
-
return this.requestHandlerInst.
|
|
387
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
359
388
|
if (verror) {
|
|
360
389
|
return callback(null, verror);
|
|
361
390
|
}
|
|
@@ -376,7 +405,7 @@ class EtsiSol005 extends AdapterBaseCl {
|
|
|
376
405
|
}
|
|
377
406
|
|
|
378
407
|
// need to check the cache again since it has been updated
|
|
379
|
-
return this.requestHandlerInst.
|
|
408
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
380
409
|
if (verror) {
|
|
381
410
|
return callback(null, verror);
|
|
382
411
|
}
|
|
@@ -417,11 +446,11 @@ class EtsiSol005 extends AdapterBaseCl {
|
|
|
417
446
|
/**
|
|
418
447
|
* @summary Updates the cache for all entities by call the get All entity method
|
|
419
448
|
*
|
|
420
|
-
* @function
|
|
449
|
+
* @function iapUpdateAdapterEntityCache
|
|
421
450
|
*
|
|
422
451
|
*/
|
|
423
|
-
|
|
424
|
-
const origin = `${this.id}-adapter-
|
|
452
|
+
iapUpdateAdapterEntityCache() {
|
|
453
|
+
const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
|
|
425
454
|
log.trace(origin);
|
|
426
455
|
|
|
427
456
|
if (this.caching) {
|
|
@@ -434,6 +463,140 @@ class EtsiSol005 extends AdapterBaseCl {
|
|
|
434
463
|
}
|
|
435
464
|
}
|
|
436
465
|
|
|
466
|
+
/**
|
|
467
|
+
* @summary Determines if this adapter supports any in a list of entities
|
|
468
|
+
*
|
|
469
|
+
* @function hasEntities
|
|
470
|
+
* @param {String} entityType - the entity type to check for
|
|
471
|
+
* @param {Array} entityList - the list of entities we are looking for
|
|
472
|
+
*
|
|
473
|
+
* @param {Callback} callback - A map where the entity is the key and the
|
|
474
|
+
* value is true or false
|
|
475
|
+
*/
|
|
476
|
+
hasEntities(entityType, entityList, callback) {
|
|
477
|
+
const meth = 'adapter-hasEntities';
|
|
478
|
+
const origin = `${this.id}-${meth}`;
|
|
479
|
+
log.trace(origin);
|
|
480
|
+
|
|
481
|
+
try {
|
|
482
|
+
return super.hasEntities(entityType, entityList, callback);
|
|
483
|
+
} catch (err) {
|
|
484
|
+
log.error(`${origin}: ${err}`);
|
|
485
|
+
return callback(null, err);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* @summary Get Appliance that match the deviceName
|
|
491
|
+
*
|
|
492
|
+
* @function getDevice
|
|
493
|
+
* @param {String} deviceName - the deviceName to find (required)
|
|
494
|
+
*
|
|
495
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
496
|
+
* (appliance) or the error
|
|
497
|
+
*/
|
|
498
|
+
getDevice(deviceName, callback) {
|
|
499
|
+
const meth = 'adapter-getDevice';
|
|
500
|
+
const origin = `${this.id}-${meth}`;
|
|
501
|
+
log.trace(origin);
|
|
502
|
+
|
|
503
|
+
try {
|
|
504
|
+
return super.getDevice(deviceName, callback);
|
|
505
|
+
} catch (err) {
|
|
506
|
+
log.error(`${origin}: ${err}`);
|
|
507
|
+
return callback(null, err);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* @summary Get Appliances that match the filter
|
|
513
|
+
*
|
|
514
|
+
* @function getDevicesFiltered
|
|
515
|
+
* @param {Object} options - the data to use to filter the appliances (optional)
|
|
516
|
+
*
|
|
517
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
518
|
+
* (appliances) or the error
|
|
519
|
+
*/
|
|
520
|
+
getDevicesFiltered(options, callback) {
|
|
521
|
+
const meth = 'adapter-getDevicesFiltered';
|
|
522
|
+
const origin = `${this.id}-${meth}`;
|
|
523
|
+
log.trace(origin);
|
|
524
|
+
|
|
525
|
+
try {
|
|
526
|
+
return super.getDevicesFiltered(options, callback);
|
|
527
|
+
} catch (err) {
|
|
528
|
+
log.error(`${origin}: ${err}`);
|
|
529
|
+
return callback(null, err);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* @summary Gets the status for the provided appliance
|
|
535
|
+
*
|
|
536
|
+
* @function isAlive
|
|
537
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
538
|
+
*
|
|
539
|
+
* @param {configCallback} callback - callback function to return the result
|
|
540
|
+
* (appliance isAlive) or the error
|
|
541
|
+
*/
|
|
542
|
+
isAlive(deviceName, callback) {
|
|
543
|
+
const meth = 'adapter-isAlive';
|
|
544
|
+
const origin = `${this.id}-${meth}`;
|
|
545
|
+
log.trace(origin);
|
|
546
|
+
|
|
547
|
+
try {
|
|
548
|
+
return super.isAlive(deviceName, callback);
|
|
549
|
+
} catch (err) {
|
|
550
|
+
log.error(`${origin}: ${err}`);
|
|
551
|
+
return callback(null, err);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* @summary Gets a config for the provided Appliance
|
|
557
|
+
*
|
|
558
|
+
* @function getConfig
|
|
559
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
560
|
+
* @param {String} format - the desired format of the config. (optional)
|
|
561
|
+
*
|
|
562
|
+
* @param {configCallback} callback - callback function to return the result
|
|
563
|
+
* (appliance config) or the error
|
|
564
|
+
*/
|
|
565
|
+
getConfig(deviceName, format, callback) {
|
|
566
|
+
const meth = 'adapter-getConfig';
|
|
567
|
+
const origin = `${this.id}-${meth}`;
|
|
568
|
+
log.trace(origin);
|
|
569
|
+
|
|
570
|
+
try {
|
|
571
|
+
return super.getConfig(deviceName, format, callback);
|
|
572
|
+
} catch (err) {
|
|
573
|
+
log.error(`${origin}: ${err}`);
|
|
574
|
+
return callback(null, err);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* @summary Gets the device count from the system
|
|
580
|
+
*
|
|
581
|
+
* @function iapGetDeviceCount
|
|
582
|
+
*
|
|
583
|
+
* @param {getCallback} callback - callback function to return the result
|
|
584
|
+
* (count) or the error
|
|
585
|
+
*/
|
|
586
|
+
iapGetDeviceCount(callback) {
|
|
587
|
+
const meth = 'adapter-iapGetDeviceCount';
|
|
588
|
+
const origin = `${this.id}-${meth}`;
|
|
589
|
+
log.trace(origin);
|
|
590
|
+
|
|
591
|
+
try {
|
|
592
|
+
return super.iapGetDeviceCount(callback);
|
|
593
|
+
} catch (err) {
|
|
594
|
+
log.error(`${origin}: ${err}`);
|
|
595
|
+
return callback(null, err);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
|
|
437
600
|
/**
|
|
438
601
|
* Makes the requested generic call
|
|
439
602
|
*
|
|
@@ -544,79 +707,23 @@ class EtsiSol005 extends AdapterBaseCl {
|
|
|
544
707
|
}
|
|
545
708
|
}
|
|
546
709
|
|
|
547
|
-
/* BROKER CALLS */
|
|
548
710
|
/**
|
|
549
|
-
*
|
|
711
|
+
* Makes the requested generic call with no base path or version
|
|
550
712
|
*
|
|
551
|
-
* @function
|
|
552
|
-
* @param {String}
|
|
553
|
-
* @param {
|
|
554
|
-
*
|
|
555
|
-
*
|
|
556
|
-
*
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
switch (entityType) {
|
|
563
|
-
case 'Device':
|
|
564
|
-
return this.hasDevices(entityList, callback);
|
|
565
|
-
default:
|
|
566
|
-
return callback(null, `${this.id} does not support entity ${entityType}`);
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
/**
|
|
571
|
-
* @summary Helper method for hasEntities for the specific device case
|
|
572
|
-
*
|
|
573
|
-
* @param {Array} deviceList - array of unique device identifiers
|
|
574
|
-
* @param {Callback} callback - A map where the device is the key and the
|
|
575
|
-
* value is true or false
|
|
576
|
-
*/
|
|
577
|
-
hasDevices(deviceList, callback) {
|
|
578
|
-
const origin = `${this.id}-adapter-hasDevices`;
|
|
579
|
-
log.trace(origin);
|
|
580
|
-
|
|
581
|
-
const findings = deviceList.reduce((map, device) => {
|
|
582
|
-
// eslint-disable-next-line no-param-reassign
|
|
583
|
-
map[device] = false;
|
|
584
|
-
log.debug(`In reduce: ${JSON.stringify(map)}`);
|
|
585
|
-
return map;
|
|
586
|
-
}, {});
|
|
587
|
-
const apiCalls = deviceList.map((device) => new Promise((resolve) => {
|
|
588
|
-
this.getDevice(device, (result, error) => {
|
|
589
|
-
if (error) {
|
|
590
|
-
log.debug(`In map error: ${JSON.stringify(device)}`);
|
|
591
|
-
return resolve({ name: device, found: false });
|
|
592
|
-
}
|
|
593
|
-
log.debug(`In map: ${JSON.stringify(device)}`);
|
|
594
|
-
return resolve({ name: device, found: true });
|
|
595
|
-
});
|
|
596
|
-
}));
|
|
597
|
-
Promise.all(apiCalls).then((results) => {
|
|
598
|
-
results.forEach((device) => {
|
|
599
|
-
findings[device.name] = device.found;
|
|
600
|
-
});
|
|
601
|
-
log.debug(`FINDINGS: ${JSON.stringify(findings)}`);
|
|
602
|
-
return callback(findings);
|
|
603
|
-
}).catch((errors) => {
|
|
604
|
-
log.error('Unable to do device lookup.');
|
|
605
|
-
return callback(null, { code: 503, message: 'Unable to do device lookup.', error: errors });
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
/**
|
|
610
|
-
* @summary Get Appliance that match the deviceName
|
|
611
|
-
*
|
|
612
|
-
* @function getDevice
|
|
613
|
-
* @param {String} deviceName - the deviceName to find (required)
|
|
614
|
-
*
|
|
615
|
-
* @param {getCallback} callback - a callback function to return the result
|
|
616
|
-
* (appliance) or the error
|
|
713
|
+
* @function genericAdapterRequestNoBasePath
|
|
714
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
|
715
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
|
716
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
717
|
+
* Can be a stringified Object.
|
|
718
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
719
|
+
* Can be a stringified Object.
|
|
720
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
721
|
+
* Can be a stringified Object.
|
|
722
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
723
|
+
* or the error
|
|
617
724
|
*/
|
|
618
|
-
|
|
619
|
-
const meth = 'adapter-
|
|
725
|
+
genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
|
726
|
+
const meth = 'adapter-genericAdapterRequestNoBasePath';
|
|
620
727
|
const origin = `${this.id}-${meth}`;
|
|
621
728
|
log.trace(origin);
|
|
622
729
|
|
|
@@ -627,365 +734,81 @@ class EtsiSol005 extends AdapterBaseCl {
|
|
|
627
734
|
}
|
|
628
735
|
|
|
629
736
|
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
630
|
-
if (
|
|
631
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['
|
|
737
|
+
if (uriPath === undefined || uriPath === null || uriPath === '') {
|
|
738
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
|
|
632
739
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
633
740
|
return callback(null, errorObj);
|
|
634
741
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
// need to get the device so we can convert the deviceName to an id
|
|
638
|
-
// !! if we can do a lookup by name the getDevicesFiltered may not be necessary
|
|
639
|
-
const opts = {
|
|
640
|
-
filter: {
|
|
641
|
-
name: deviceName
|
|
642
|
-
}
|
|
643
|
-
};
|
|
644
|
-
return this.getDevicesFiltered(opts, (devs, ferr) => {
|
|
645
|
-
// if we received an error or their is no response on the results return an error
|
|
646
|
-
if (ferr) {
|
|
647
|
-
return callback(null, ferr);
|
|
648
|
-
}
|
|
649
|
-
if (devs.list.length < 1) {
|
|
650
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Did Not Find Device ${deviceName}`, [], null, null, null);
|
|
651
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
652
|
-
return callback(null, errorObj);
|
|
653
|
-
}
|
|
654
|
-
// get the uuid from the device
|
|
655
|
-
const { uuid } = devs.list[0];
|
|
656
|
-
|
|
657
|
-
// !! using Generic makes it easier on the Adapter Builder (just need to change the path)
|
|
658
|
-
// !! you can also replace with a specific call if that is easier
|
|
659
|
-
const uriPath = `/call/toget/device/${uuid}`;
|
|
660
|
-
return this.genericAdapterRequest(uriPath, 'GET', {}, {}, {}, (result, error) => {
|
|
661
|
-
// if we received an error or their is no response on the results return an error
|
|
662
|
-
if (error) {
|
|
663
|
-
return callback(null, error);
|
|
664
|
-
}
|
|
665
|
-
if (!result.response || !result.response.applianceMo) {
|
|
666
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevice'], null, null, null);
|
|
667
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
668
|
-
return callback(null, errorObj);
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
// return the response
|
|
672
|
-
// !! format the data we send back
|
|
673
|
-
// !! these fields are config manager fields you need to map to the data we receive
|
|
674
|
-
const thisDevice = result.response;
|
|
675
|
-
thisDevice.name = thisDevice.systemName;
|
|
676
|
-
thisDevice.ostype = `System-${thisDevice.systemType}`;
|
|
677
|
-
thisDevice.port = thisDevice.systemPort;
|
|
678
|
-
thisDevice.ipaddress = thisDevice.systemIP;
|
|
679
|
-
return callback(thisDevice);
|
|
680
|
-
});
|
|
681
|
-
});
|
|
682
|
-
} catch (ex) {
|
|
683
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
742
|
+
if (restMethod === undefined || restMethod === null || restMethod === '') {
|
|
743
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
|
|
684
744
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
685
745
|
return callback(null, errorObj);
|
|
686
746
|
}
|
|
687
|
-
}
|
|
688
747
|
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
*
|
|
695
|
-
* @param {getCallback} callback - a callback function to return the result
|
|
696
|
-
* (appliances) or the error
|
|
697
|
-
*/
|
|
698
|
-
getDevicesFiltered(options, callback) {
|
|
699
|
-
const meth = 'adapter-getDevicesFiltered';
|
|
700
|
-
const origin = `${this.id}-${meth}`;
|
|
701
|
-
log.trace(origin);
|
|
702
|
-
|
|
703
|
-
// verify the required fields have been provided
|
|
704
|
-
if (options === undefined || options === null || options === '' || options.length === 0) {
|
|
705
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['options'], null, null, null);
|
|
706
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
707
|
-
return callback(null, errorObj);
|
|
748
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
749
|
+
// remove any leading / and split the uripath into path variables
|
|
750
|
+
let myPath = uriPath;
|
|
751
|
+
while (myPath.indexOf('/') === 0) {
|
|
752
|
+
myPath = myPath.substring(1);
|
|
708
753
|
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
// const maxResults = options.limit;
|
|
754
|
+
const pathVars = myPath.split('/');
|
|
755
|
+
const queryParamsAvailable = queryData;
|
|
756
|
+
const queryParams = {};
|
|
757
|
+
const bodyVars = requestBody;
|
|
714
758
|
|
|
715
|
-
//
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
// eslint-disable-next-line prefer-destructuring
|
|
721
|
-
filterName = options.filter.name;
|
|
722
|
-
} else {
|
|
723
|
-
filterName = [options.filter.name];
|
|
759
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
760
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
761
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
762
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
763
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
724
764
|
}
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
// TODO - get sort and order working
|
|
728
|
-
/*
|
|
729
|
-
if (options && options.sort) {
|
|
730
|
-
reqObj.uriOptions.sort = JSON.stringify(options.sort);
|
|
731
|
-
}
|
|
732
|
-
if (options && options.order) {
|
|
733
|
-
reqObj.uriOptions.order = options.order;
|
|
734
|
-
}
|
|
735
|
-
*/
|
|
736
|
-
try {
|
|
737
|
-
// !! using Generic makes it easier on the Adapter Builder (just need to change the path)
|
|
738
|
-
// !! you can also replace with a specific call if that is easier
|
|
739
|
-
const uriPath = '/call/toget/devices';
|
|
740
|
-
return this.genericAdapterRequest(uriPath, 'GET', {}, {}, {}, (result, error) => {
|
|
741
|
-
// if we received an error or their is no response on the results return an error
|
|
742
|
-
if (error) {
|
|
743
|
-
return callback(null, error);
|
|
744
|
-
}
|
|
745
|
-
if (!result.response) {
|
|
746
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDevicesFiltered'], null, null, null);
|
|
747
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
748
|
-
return callback(null, errorObj);
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
// !! go through the response - may have to look for sub object
|
|
752
|
-
// handle an array of devices
|
|
753
|
-
if (Array.isArray(result.response)) {
|
|
754
|
-
const myDevices = [];
|
|
755
|
-
|
|
756
|
-
for (let d = 0; d < result.response.length; d += 1) {
|
|
757
|
-
// !! format the data we send back
|
|
758
|
-
// !! these fields are config manager fields you need to map to the data we receive
|
|
759
|
-
const thisDevice = result.response;
|
|
760
|
-
thisDevice.name = thisDevice.systemName;
|
|
761
|
-
thisDevice.ostype = `System-${thisDevice.systemType}`;
|
|
762
|
-
thisDevice.port = thisDevice.systemPort;
|
|
763
|
-
thisDevice.ipaddress = thisDevice.systemIP;
|
|
764
|
-
|
|
765
|
-
// if there is no filter - return the device
|
|
766
|
-
if (filterName.length === 0) {
|
|
767
|
-
myDevices.push(thisDevice);
|
|
768
|
-
} else {
|
|
769
|
-
// if we have to match a filter
|
|
770
|
-
let found = false;
|
|
771
|
-
for (let f = 0; f < filterName.length; f += 1) {
|
|
772
|
-
if (thisDevice.name.indexOf(filterName[f]) >= 0) {
|
|
773
|
-
found = true;
|
|
774
|
-
break;
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
// matching device
|
|
778
|
-
if (found) {
|
|
779
|
-
myDevices.push(thisDevice);
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
log.debug(`${origin}: Found #${myDevices.length} devices.`);
|
|
784
|
-
log.debug(`Devices: ${JSON.stringify(myDevices)}`);
|
|
785
|
-
return callback({ total: myDevices.length, list: myDevices });
|
|
786
|
-
}
|
|
787
|
-
// handle a single device response
|
|
788
|
-
// !! format the data we send back
|
|
789
|
-
// !! these fields are config manager fields you need to map to the data we receive
|
|
790
|
-
const thisDevice = result.response;
|
|
791
|
-
thisDevice.name = thisDevice.systemName;
|
|
792
|
-
thisDevice.ostype = `System-${thisDevice.systemType}`;
|
|
793
|
-
thisDevice.port = thisDevice.systemPort;
|
|
794
|
-
thisDevice.ipaddress = thisDevice.systemIP;
|
|
795
|
-
|
|
796
|
-
// if there is no filter - return the device
|
|
797
|
-
if (filterName.length === 0) {
|
|
798
|
-
log.debug(`${origin}: Found #1 device.`);
|
|
799
|
-
log.debug(`Device: ${JSON.stringify(thisDevice)}`);
|
|
800
|
-
return callback({ total: 1, list: [thisDevice] });
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
// if there is a filter need to check for matching device
|
|
804
|
-
let found = false;
|
|
805
|
-
for (let f = 0; f < filterName.length; f += 1) {
|
|
806
|
-
if (thisDevice.name.indexOf(filterName[f]) >= 0) {
|
|
807
|
-
found = true;
|
|
808
|
-
break;
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
// matching device
|
|
812
|
-
if (found) {
|
|
813
|
-
log.debug(`${origin}: Found #1 device.`);
|
|
814
|
-
log.debug(`Device Found: ${JSON.stringify(thisDevice)}`);
|
|
815
|
-
return callback({ total: 1, list: [thisDevice] });
|
|
816
|
-
}
|
|
817
|
-
// not a matching device
|
|
818
|
-
log.debug(`${origin}: No matching device found.`);
|
|
819
|
-
return callback({ total: 0, list: [] });
|
|
820
|
-
});
|
|
821
|
-
} catch (ex) {
|
|
822
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
823
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
824
|
-
return callback(null, errorObj);
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
/**
|
|
829
|
-
* @summary Gets the status for the provided appliance
|
|
830
|
-
*
|
|
831
|
-
* @function isAlive
|
|
832
|
-
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
833
|
-
*
|
|
834
|
-
* @param {configCallback} callback - callback function to return the result
|
|
835
|
-
* (appliance isAlive) or the error
|
|
836
|
-
*/
|
|
837
|
-
isAlive(deviceName, callback) {
|
|
838
|
-
const meth = 'adapter-isAlive';
|
|
839
|
-
const origin = `${this.id}-${meth}`;
|
|
840
|
-
log.trace(origin);
|
|
841
|
-
|
|
842
|
-
// verify the required fields have been provided
|
|
843
|
-
if (deviceName === undefined || deviceName === null || deviceName === '' || deviceName.length === 0) {
|
|
844
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceName'], null, null, null);
|
|
845
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
846
|
-
return callback(null, errorObj);
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
try {
|
|
850
|
-
// need to get the device so we can convert the deviceName to an id
|
|
851
|
-
// !! if we can do a lookup by name the getDevicesFiltered may not be necessary
|
|
852
|
-
const opts = {
|
|
853
|
-
filter: {
|
|
854
|
-
name: deviceName
|
|
855
|
-
}
|
|
856
|
-
};
|
|
857
|
-
return this.getDevicesFiltered(opts, (devs, ferr) => {
|
|
858
|
-
// if we received an error or their is no response on the results return an error
|
|
859
|
-
if (ferr) {
|
|
860
|
-
return callback(null, ferr);
|
|
861
|
-
}
|
|
862
|
-
if (devs.list.length < 1) {
|
|
863
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Did Not Find Device ${deviceName}`, [], null, null, null);
|
|
864
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
865
|
-
return callback(null, errorObj);
|
|
866
|
-
}
|
|
867
|
-
// get the uuid from the device
|
|
868
|
-
const { uuid } = devs.list[0];
|
|
869
|
-
|
|
870
|
-
// !! using Generic makes it easier on the Adapter Builder (just need to change the path)
|
|
871
|
-
// !! you can also replace with a specific call if that is easier
|
|
872
|
-
const uriPath = `/call/toget/status/${uuid}`;
|
|
873
|
-
return this.genericAdapterRequest(uriPath, 'GET', {}, {}, {}, (result, error) => {
|
|
874
|
-
// if we received an error or their is no response on the results return an error
|
|
875
|
-
if (error) {
|
|
876
|
-
return callback(null, error);
|
|
877
|
-
}
|
|
878
|
-
// !! should update this to make sure we are checking for the appropriate object/field
|
|
879
|
-
if (!result.response || !result.response.returnObj || !Object.hasOwnProperty.call(result.response.returnObj, 'statusField')) {
|
|
880
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['isAlive'], null, null, null);
|
|
881
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
882
|
-
return callback(null, errorObj);
|
|
883
|
-
}
|
|
765
|
+
});
|
|
884
766
|
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
767
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
|
|
768
|
+
const reqObj = {
|
|
769
|
+
payload: bodyVars,
|
|
770
|
+
uriPathVars: pathVars,
|
|
771
|
+
uriQuery: queryParams,
|
|
772
|
+
uriOptions: {}
|
|
773
|
+
};
|
|
774
|
+
// add headers if provided
|
|
775
|
+
if (addlHeaders) {
|
|
776
|
+
reqObj.addlHeaders = addlHeaders;
|
|
893
777
|
}
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
/**
|
|
897
|
-
* @summary Gets a config for the provided Appliance
|
|
898
|
-
*
|
|
899
|
-
* @function getConfig
|
|
900
|
-
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
901
|
-
* @param {String} format - the desired format of the config. (optional)
|
|
902
|
-
*
|
|
903
|
-
* @param {configCallback} callback - callback function to return the result
|
|
904
|
-
* (appliance config) or the error
|
|
905
|
-
*/
|
|
906
|
-
getConfig(deviceName, format, callback) {
|
|
907
|
-
const meth = 'adapter-getConfig';
|
|
908
|
-
const origin = `${this.id}-${meth}`;
|
|
909
|
-
log.trace(origin);
|
|
910
778
|
|
|
911
|
-
//
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
779
|
+
// determine the call and return flag
|
|
780
|
+
let action = 'getGenericsNoBase';
|
|
781
|
+
let returnF = true;
|
|
782
|
+
if (restMethod.toUpperCase() === 'POST') {
|
|
783
|
+
action = 'createGenericNoBase';
|
|
784
|
+
} else if (restMethod.toUpperCase() === 'PUT') {
|
|
785
|
+
action = 'updateGenericNoBase';
|
|
786
|
+
} else if (restMethod.toUpperCase() === 'PATCH') {
|
|
787
|
+
action = 'patchGenericNoBase';
|
|
788
|
+
} else if (restMethod.toUpperCase() === 'DELETE') {
|
|
789
|
+
action = 'deleteGenericNoBase';
|
|
790
|
+
returnF = false;
|
|
916
791
|
}
|
|
917
792
|
|
|
918
793
|
try {
|
|
919
|
-
//
|
|
920
|
-
//
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
// if we received an error or their is no response on the results return an error
|
|
928
|
-
if (ferr) {
|
|
929
|
-
return callback(null, ferr);
|
|
794
|
+
// Make the call -
|
|
795
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
796
|
+
return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
|
|
797
|
+
// if we received an error or their is no response on the results
|
|
798
|
+
// return an error
|
|
799
|
+
if (irReturnError) {
|
|
800
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
801
|
+
return callback(null, irReturnError);
|
|
930
802
|
}
|
|
931
|
-
if (
|
|
932
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth,
|
|
803
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
804
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
|
|
933
805
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
934
806
|
return callback(null, errorObj);
|
|
935
807
|
}
|
|
936
|
-
// get the uuid from the device
|
|
937
|
-
const { uuid } = devs.list[0];
|
|
938
|
-
|
|
939
|
-
// !! using Generic makes it easier on the Adapter Builder (just need to change the path)
|
|
940
|
-
// !! you can also replace with a specific call if that is easier
|
|
941
|
-
const uriPath = `/call/toget/config/${uuid}`;
|
|
942
|
-
return this.genericAdapterRequest(uriPath, 'GET', {}, {}, {}, (result, error) => {
|
|
943
|
-
// if we received an error or their is no response on the results return an error
|
|
944
|
-
if (error) {
|
|
945
|
-
return callback(null, error);
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
// return the result
|
|
949
|
-
const newResponse = {
|
|
950
|
-
response: JSON.stringify(result.response, null, 2)
|
|
951
|
-
};
|
|
952
|
-
return callback(newResponse);
|
|
953
|
-
});
|
|
954
|
-
});
|
|
955
|
-
} catch (ex) {
|
|
956
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
957
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
958
|
-
return callback(null, errorObj);
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
/**
|
|
963
|
-
* @summary Gets the device count from the system
|
|
964
|
-
*
|
|
965
|
-
* @function getCount
|
|
966
|
-
*
|
|
967
|
-
* @param {getCallback} callback - callback function to return the result
|
|
968
|
-
* (count) or the error
|
|
969
|
-
*/
|
|
970
|
-
getCount(callback) {
|
|
971
|
-
const meth = 'adapter-getCount';
|
|
972
|
-
const origin = `${this.id}-${meth}`;
|
|
973
|
-
log.trace(origin);
|
|
974
|
-
|
|
975
|
-
// verify the required fields have been provided
|
|
976
|
-
|
|
977
|
-
try {
|
|
978
|
-
// !! using Generic makes it easier on the Adapter Builder (just need to change the path)
|
|
979
|
-
// !! you can also replace with a specific call if that is easier
|
|
980
|
-
const uriPath = '/call/toget/count';
|
|
981
|
-
return this.genericAdapterRequest(uriPath, 'GET', {}, {}, {}, (result, error) => {
|
|
982
|
-
// if we received an error or their is no response on the results return an error
|
|
983
|
-
if (error) {
|
|
984
|
-
return callback(null, error);
|
|
985
|
-
}
|
|
986
808
|
|
|
987
|
-
|
|
988
|
-
return
|
|
809
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
810
|
+
// return the response
|
|
811
|
+
return callback(irReturnData, null);
|
|
989
812
|
});
|
|
990
813
|
} catch (ex) {
|
|
991
814
|
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|