@itentialopensource/adapter-adtran_mosaic_devicemanager 0.1.1 → 0.3.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 +733 -0
- package/CHANGELOG.md +17 -2
- package/CODE_OF_CONDUCT.md +12 -17
- package/CONTRIBUTING.md +3 -148
- package/ENHANCE.md +14 -14
- package/PROPERTIES.md +483 -89
- package/README.md +156 -67
- package/SUMMARY.md +2 -2
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +4 -3
- package/adapter.js +236 -626
- package/adapterBase.js +647 -494
- package/changelogs/changelog.md +16 -0
- package/entities/.generic/action.json +105 -0
- package/entities/.generic/schema.json +6 -1
- package/metadata.json +47 -0
- package/package.json +24 -24
- package/pronghorn.json +508 -90
- package/propertiesSchema.json +496 -39
- package/refs?service=git-upload-pack +0 -0
- package/report/adapter-openapi.json +7211 -0
- package/report/adapter-openapi.yaml +6459 -0
- package/report/adapterInfo.json +10 -0
- package/report/updateReport1653138377421.json +120 -0
- package/report/updateReport1691507605063.json +120 -0
- package/report/updateReport1692202606613.json +120 -0
- package/report/updateReport1694462023649.json +120 -0
- package/report/updateReport1698421007213.json +120 -0
- package/sampleProperties.json +153 -3
- package/test/integration/adapterTestBasicGet.js +3 -5
- package/test/integration/adapterTestConnectivity.js +91 -42
- package/test/integration/adapterTestIntegration.js +1965 -2493
- package/test/unit/adapterBaseTestUnit.js +388 -306
- package/test/unit/adapterTestUnit.js +364 -231
- package/utils/adapterInfo.js +206 -0
- package/utils/addAuth.js +1 -1
- package/utils/artifactize.js +1 -1
- package/utils/checkMigrate.js +1 -1
- package/utils/entitiesToDB.js +12 -57
- package/utils/findPath.js +1 -1
- package/utils/methodDocumentor.js +273 -0
- package/utils/modify.js +13 -15
- package/utils/packModificationScript.js +1 -1
- package/utils/pre-commit.sh +5 -0
- package/utils/taskMover.js +309 -0
- package/utils/tbScript.js +123 -53
- package/utils/tbUtils.js +84 -59
- package/utils/testRunner.js +17 -17
- package/utils/troubleshootingAdapter.js +9 -6
- package/workflows/README.md +0 -3
package/adapter.js
CHANGED
|
@@ -83,7 +83,12 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
83
83
|
* @iapGetAdapterWorkflowFunctions
|
|
84
84
|
*/
|
|
85
85
|
iapGetAdapterWorkflowFunctions(inIgnore) {
|
|
86
|
-
let myIgnore = [
|
|
86
|
+
let myIgnore = [
|
|
87
|
+
'healthCheck',
|
|
88
|
+
'iapGetAdapterWorkflowFunctions',
|
|
89
|
+
'hasEntities',
|
|
90
|
+
'getAuthorization'
|
|
91
|
+
];
|
|
87
92
|
if (!inIgnore && Array.isArray(inIgnore)) {
|
|
88
93
|
myIgnore = inIgnore;
|
|
89
94
|
} else if (!inIgnore && typeof inIgnore === 'string') {
|
|
@@ -108,25 +113,15 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
108
113
|
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
109
114
|
* @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
|
|
110
115
|
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
116
|
+
* @param {boolean} replace - true to replace entire mock data, false to merge/append
|
|
111
117
|
* @param {Callback} callback - The results of the call
|
|
112
118
|
*/
|
|
113
|
-
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
|
114
|
-
const
|
|
119
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
|
|
120
|
+
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
|
121
|
+
const origin = `${this.id}-${meth}`;
|
|
115
122
|
log.trace(origin);
|
|
116
|
-
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
|
117
|
-
}
|
|
118
123
|
|
|
119
|
-
|
|
120
|
-
* See if the API path provided is found in this adapter
|
|
121
|
-
*
|
|
122
|
-
* @function iapFindAdapterPath
|
|
123
|
-
* @param {string} apiPath - the api path to check on
|
|
124
|
-
* @param {Callback} callback - The results of the call
|
|
125
|
-
*/
|
|
126
|
-
iapFindAdapterPath(apiPath, callback) {
|
|
127
|
-
const origin = `${this.id}-adapter-iapFindAdapterPath`;
|
|
128
|
-
log.trace(origin);
|
|
129
|
-
super.iapFindAdapterPath(apiPath, callback);
|
|
124
|
+
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
|
|
130
125
|
}
|
|
131
126
|
|
|
132
127
|
/**
|
|
@@ -136,8 +131,10 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
136
131
|
* @param {Callback} callback - callback function
|
|
137
132
|
*/
|
|
138
133
|
iapSuspendAdapter(mode, callback) {
|
|
139
|
-
const
|
|
134
|
+
const meth = 'adapter-iapSuspendAdapter';
|
|
135
|
+
const origin = `${this.id}-${meth}`;
|
|
140
136
|
log.trace(origin);
|
|
137
|
+
|
|
141
138
|
try {
|
|
142
139
|
return super.iapSuspendAdapter(mode, callback);
|
|
143
140
|
} catch (error) {
|
|
@@ -153,8 +150,10 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
153
150
|
* @param {Callback} callback - callback function
|
|
154
151
|
*/
|
|
155
152
|
iapUnsuspendAdapter(callback) {
|
|
156
|
-
const
|
|
153
|
+
const meth = 'adapter-iapUnsuspendAdapter';
|
|
154
|
+
const origin = `${this.id}-${meth}`;
|
|
157
155
|
log.trace(origin);
|
|
156
|
+
|
|
158
157
|
try {
|
|
159
158
|
return super.iapUnsuspendAdapter(callback);
|
|
160
159
|
} catch (error) {
|
|
@@ -164,17 +163,35 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
164
163
|
}
|
|
165
164
|
|
|
166
165
|
/**
|
|
167
|
-
* @summary Get the
|
|
166
|
+
* @summary Get the Adapter Queue
|
|
168
167
|
*
|
|
169
168
|
* @function iapGetAdapterQueue
|
|
170
169
|
* @param {Callback} callback - callback function
|
|
171
170
|
*/
|
|
172
171
|
iapGetAdapterQueue(callback) {
|
|
173
|
-
const
|
|
172
|
+
const meth = 'adapter-iapGetAdapterQueue';
|
|
173
|
+
const origin = `${this.id}-${meth}`;
|
|
174
174
|
log.trace(origin);
|
|
175
|
+
|
|
175
176
|
return super.iapGetAdapterQueue(callback);
|
|
176
177
|
}
|
|
177
178
|
|
|
179
|
+
/* SCRIPT CALLS */
|
|
180
|
+
/**
|
|
181
|
+
* See if the API path provided is found in this adapter
|
|
182
|
+
*
|
|
183
|
+
* @function iapFindAdapterPath
|
|
184
|
+
* @param {string} apiPath - the api path to check on
|
|
185
|
+
* @param {Callback} callback - The results of the call
|
|
186
|
+
*/
|
|
187
|
+
iapFindAdapterPath(apiPath, callback) {
|
|
188
|
+
const meth = 'adapter-iapFindAdapterPath';
|
|
189
|
+
const origin = `${this.id}-${meth}`;
|
|
190
|
+
log.trace(origin);
|
|
191
|
+
|
|
192
|
+
super.iapFindAdapterPath(apiPath, callback);
|
|
193
|
+
}
|
|
194
|
+
|
|
178
195
|
/**
|
|
179
196
|
* @summary Runs troubleshoot scripts for adapter
|
|
180
197
|
*
|
|
@@ -185,8 +202,10 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
185
202
|
* @param {Callback} callback - The results of the call
|
|
186
203
|
*/
|
|
187
204
|
iapTroubleshootAdapter(props, persistFlag, callback) {
|
|
188
|
-
const
|
|
205
|
+
const meth = 'adapter-iapTroubleshootAdapter';
|
|
206
|
+
const origin = `${this.id}-${meth}`;
|
|
189
207
|
log.trace(origin);
|
|
208
|
+
|
|
190
209
|
try {
|
|
191
210
|
return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
|
|
192
211
|
} catch (error) {
|
|
@@ -203,8 +222,10 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
203
222
|
* @param {Callback} callback - callback function
|
|
204
223
|
*/
|
|
205
224
|
iapRunAdapterHealthcheck(callback) {
|
|
206
|
-
const
|
|
225
|
+
const meth = 'adapter-iapRunAdapterHealthcheck';
|
|
226
|
+
const origin = `${this.id}-${meth}`;
|
|
207
227
|
log.trace(origin);
|
|
228
|
+
|
|
208
229
|
try {
|
|
209
230
|
return super.iapRunAdapterHealthcheck(this, callback);
|
|
210
231
|
} catch (error) {
|
|
@@ -220,8 +241,10 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
220
241
|
* @param {Callback} callback - callback function
|
|
221
242
|
*/
|
|
222
243
|
iapRunAdapterConnectivity(callback) {
|
|
223
|
-
const
|
|
244
|
+
const meth = 'adapter-iapRunAdapterConnectivity';
|
|
245
|
+
const origin = `${this.id}-${meth}`;
|
|
224
246
|
log.trace(origin);
|
|
247
|
+
|
|
225
248
|
try {
|
|
226
249
|
return super.iapRunAdapterConnectivity(callback);
|
|
227
250
|
} catch (error) {
|
|
@@ -237,8 +260,10 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
237
260
|
* @param {Callback} callback - callback function
|
|
238
261
|
*/
|
|
239
262
|
iapRunAdapterBasicGet(callback) {
|
|
240
|
-
const
|
|
263
|
+
const meth = 'adapter-iapRunAdapterBasicGet';
|
|
264
|
+
const origin = `${this.id}-${meth}`;
|
|
241
265
|
log.trace(origin);
|
|
266
|
+
|
|
242
267
|
try {
|
|
243
268
|
return super.iapRunAdapterBasicGet(callback);
|
|
244
269
|
} catch (error) {
|
|
@@ -255,8 +280,10 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
255
280
|
* or the error
|
|
256
281
|
*/
|
|
257
282
|
iapMoveAdapterEntitiesToDB(callback) {
|
|
258
|
-
const
|
|
283
|
+
const meth = 'adapter-iapMoveAdapterEntitiesToDB';
|
|
284
|
+
const origin = `${this.id}-${meth}`;
|
|
259
285
|
log.trace(origin);
|
|
286
|
+
|
|
260
287
|
try {
|
|
261
288
|
return super.iapMoveAdapterEntitiesToDB(callback);
|
|
262
289
|
} catch (err) {
|
|
@@ -265,176 +292,93 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
265
292
|
}
|
|
266
293
|
}
|
|
267
294
|
|
|
268
|
-
/* BROKER CALLS */
|
|
269
295
|
/**
|
|
270
|
-
* @summary
|
|
296
|
+
* @summary Deactivate adapter tasks
|
|
271
297
|
*
|
|
272
|
-
* @function
|
|
273
|
-
* @param {String} entityType - the entity type to check for
|
|
274
|
-
* @param {String/Array} entityId - the specific entity we are looking for
|
|
298
|
+
* @function iapDeactivateTasks
|
|
275
299
|
*
|
|
276
|
-
* @param {
|
|
277
|
-
*
|
|
300
|
+
* @param {Array} tasks - List of tasks to deactivate
|
|
301
|
+
* @param {Callback} callback
|
|
278
302
|
*/
|
|
279
|
-
|
|
280
|
-
const
|
|
303
|
+
iapDeactivateTasks(tasks, callback) {
|
|
304
|
+
const meth = 'adapter-iapDeactivateTasks';
|
|
305
|
+
const origin = `${this.id}-${meth}`;
|
|
281
306
|
log.trace(origin);
|
|
282
307
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
308
|
+
try {
|
|
309
|
+
return super.iapDeactivateTasks(tasks, callback);
|
|
310
|
+
} catch (err) {
|
|
311
|
+
log.error(`${origin}: ${err}`);
|
|
312
|
+
return callback(null, err);
|
|
313
|
+
}
|
|
286
314
|
}
|
|
287
315
|
|
|
288
316
|
/**
|
|
289
|
-
* @summary
|
|
290
|
-
* whether the adapter supports type, action and specific entity
|
|
317
|
+
* @summary Activate adapter tasks that have previously been deactivated
|
|
291
318
|
*
|
|
292
|
-
* @function
|
|
293
|
-
* @param {String} entityType - the entity type to check for
|
|
294
|
-
* @param {String} actionType - the action type to check for
|
|
295
|
-
* @param {String/Array} entityId - the specific entity we are looking for
|
|
319
|
+
* @function iapActivateTasks
|
|
296
320
|
*
|
|
297
|
-
* @param {
|
|
298
|
-
*
|
|
321
|
+
* @param {Array} tasks - List of tasks to activate
|
|
322
|
+
* @param {Callback} callback
|
|
299
323
|
*/
|
|
300
|
-
|
|
301
|
-
const meth = '
|
|
324
|
+
iapActivateTasks(tasks, callback) {
|
|
325
|
+
const meth = 'adapter-iapActivateTasks';
|
|
302
326
|
const origin = `${this.id}-${meth}`;
|
|
303
327
|
log.trace(origin);
|
|
304
328
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return callback(null, error);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// if the cache needs to be updated, update and try again
|
|
314
|
-
if (results && results[0] === 'needupdate') {
|
|
315
|
-
switch (entityType) {
|
|
316
|
-
case 'template_entity': {
|
|
317
|
-
// if the cache is invalid, update the cache
|
|
318
|
-
return this.getEntities(null, null, null, null, (data, err) => {
|
|
319
|
-
if (err) {
|
|
320
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
321
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
322
|
-
return callback(null, errorObj);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
// need to check the cache again since it has been updated
|
|
326
|
-
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
327
|
-
if (verror) {
|
|
328
|
-
return callback(null, verror);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return this.capabilityResults(vcapable, callback);
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
default: {
|
|
336
|
-
// unsupported entity type
|
|
337
|
-
const result = [false];
|
|
338
|
-
|
|
339
|
-
// put false in array for all entities
|
|
340
|
-
if (Array.isArray(entityId)) {
|
|
341
|
-
for (let e = 1; e < entityId.length; e += 1) {
|
|
342
|
-
result.push(false);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
return callback(result);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
// return the results
|
|
352
|
-
return this.capabilityResults(results, callback);
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
// if no entity id
|
|
357
|
-
if (!entityId) {
|
|
358
|
-
// need to check the cache again since it has been updated
|
|
359
|
-
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
360
|
-
if (verror) {
|
|
361
|
-
return callback(null, verror);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
return this.capabilityResults(vcapable, callback);
|
|
365
|
-
});
|
|
329
|
+
try {
|
|
330
|
+
return super.iapActivateTasks(tasks, callback);
|
|
331
|
+
} catch (err) {
|
|
332
|
+
log.error(`${origin}: ${err}`);
|
|
333
|
+
return callback(null, err);
|
|
366
334
|
}
|
|
335
|
+
}
|
|
367
336
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
return callback(null, verror);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
// is the entity in the list?
|
|
386
|
-
const isEntity = this.entityInList(entityId, data.response, callback);
|
|
387
|
-
const res = [];
|
|
388
|
-
|
|
389
|
-
// not found
|
|
390
|
-
for (let i = 0; i < isEntity.length; i += 1) {
|
|
391
|
-
if (vcapable) {
|
|
392
|
-
res.push(isEntity[i]);
|
|
393
|
-
} else {
|
|
394
|
-
res.push(false);
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
return callback(res);
|
|
399
|
-
});
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
default: {
|
|
403
|
-
// unsupported entity type
|
|
404
|
-
const result = [false];
|
|
405
|
-
|
|
406
|
-
// put false in array for all entities
|
|
407
|
-
if (Array.isArray(entityId)) {
|
|
408
|
-
for (let e = 1; e < entityId.length; e += 1) {
|
|
409
|
-
result.push(false);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
337
|
+
/* CACHE CALLS */
|
|
338
|
+
/**
|
|
339
|
+
* @summary Populate the cache for the given entities
|
|
340
|
+
*
|
|
341
|
+
* @function iapPopulateEntityCache
|
|
342
|
+
* @param {String/Array of Strings} entityType - the entity type(s) to populate
|
|
343
|
+
* @param {Callback} callback - whether the cache was updated or not for each entity type
|
|
344
|
+
*
|
|
345
|
+
* @returns status of the populate
|
|
346
|
+
*/
|
|
347
|
+
iapPopulateEntityCache(entityTypes, callback) {
|
|
348
|
+
const meth = 'adapter-iapPopulateEntityCache';
|
|
349
|
+
const origin = `${this.id}-${meth}`;
|
|
350
|
+
log.trace(origin);
|
|
412
351
|
|
|
413
|
-
|
|
414
|
-
|
|
352
|
+
try {
|
|
353
|
+
return super.iapPopulateEntityCache(entityTypes, callback);
|
|
354
|
+
} catch (err) {
|
|
355
|
+
log.error(`${origin}: ${err}`);
|
|
356
|
+
return callback(null, err);
|
|
415
357
|
}
|
|
416
358
|
}
|
|
417
359
|
|
|
418
360
|
/**
|
|
419
|
-
* @summary
|
|
420
|
-
*
|
|
421
|
-
* @function iapUpdateAdapterEntityCache
|
|
361
|
+
* @summary Retrieves data from cache for specified entity type
|
|
422
362
|
*
|
|
363
|
+
* @function iapRetrieveEntitiesCache
|
|
364
|
+
* @param {String} entityType - entity of which to retrieve
|
|
365
|
+
* @param {Object} options - settings of which data to return and how to return it
|
|
366
|
+
* @param {Callback} callback - the data if it was retrieved
|
|
423
367
|
*/
|
|
424
|
-
|
|
425
|
-
const
|
|
368
|
+
iapRetrieveEntitiesCache(entityType, options, callback) {
|
|
369
|
+
const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
|
|
370
|
+
const origin = `${this.id}-${meth}`;
|
|
426
371
|
log.trace(origin);
|
|
427
372
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
}
|
|
434
|
-
});
|
|
373
|
+
try {
|
|
374
|
+
return super.iapRetrieveEntitiesCache(entityType, options, callback);
|
|
375
|
+
} catch (err) {
|
|
376
|
+
log.error(`${origin}: ${err}`);
|
|
377
|
+
return callback(null, err);
|
|
435
378
|
}
|
|
436
379
|
}
|
|
437
380
|
|
|
381
|
+
/* BROKER CALLS */
|
|
438
382
|
/**
|
|
439
383
|
* @summary Determines if this adapter supports any in a list of entities
|
|
440
384
|
*
|
|
@@ -446,56 +390,18 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
446
390
|
* value is true or false
|
|
447
391
|
*/
|
|
448
392
|
hasEntities(entityType, entityList, callback) {
|
|
449
|
-
const
|
|
393
|
+
const meth = 'adapter-hasEntities';
|
|
394
|
+
const origin = `${this.id}-${meth}`;
|
|
450
395
|
log.trace(origin);
|
|
451
396
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
397
|
+
try {
|
|
398
|
+
return super.hasEntities(entityType, entityList, callback);
|
|
399
|
+
} catch (err) {
|
|
400
|
+
log.error(`${origin}: ${err}`);
|
|
401
|
+
return callback(null, err);
|
|
457
402
|
}
|
|
458
403
|
}
|
|
459
404
|
|
|
460
|
-
/**
|
|
461
|
-
* @summary Helper method for hasEntities for the specific device case
|
|
462
|
-
*
|
|
463
|
-
* @param {Array} deviceList - array of unique device identifiers
|
|
464
|
-
* @param {Callback} callback - A map where the device is the key and the
|
|
465
|
-
* value is true or false
|
|
466
|
-
*/
|
|
467
|
-
hasDevices(deviceList, callback) {
|
|
468
|
-
const origin = `${this.id}-adapter-hasDevices`;
|
|
469
|
-
log.trace(origin);
|
|
470
|
-
|
|
471
|
-
const findings = deviceList.reduce((map, device) => {
|
|
472
|
-
// eslint-disable-next-line no-param-reassign
|
|
473
|
-
map[device] = false;
|
|
474
|
-
log.debug(`In reduce: ${JSON.stringify(map)}`);
|
|
475
|
-
return map;
|
|
476
|
-
}, {});
|
|
477
|
-
const apiCalls = deviceList.map((device) => new Promise((resolve) => {
|
|
478
|
-
this.getDevice(device, (result, error) => {
|
|
479
|
-
if (error) {
|
|
480
|
-
log.debug(`In map error: ${JSON.stringify(device)}`);
|
|
481
|
-
return resolve({ name: device, found: false });
|
|
482
|
-
}
|
|
483
|
-
log.debug(`In map: ${JSON.stringify(device)}`);
|
|
484
|
-
return resolve({ name: device, found: true });
|
|
485
|
-
});
|
|
486
|
-
}));
|
|
487
|
-
Promise.all(apiCalls).then((results) => {
|
|
488
|
-
results.forEach((device) => {
|
|
489
|
-
findings[device.name] = device.found;
|
|
490
|
-
});
|
|
491
|
-
log.debug(`FINDINGS: ${JSON.stringify(findings)}`);
|
|
492
|
-
return callback(findings);
|
|
493
|
-
}).catch((errors) => {
|
|
494
|
-
log.error('Unable to do device lookup.');
|
|
495
|
-
return callback(null, { code: 503, message: 'Unable to do device lookup.', error: errors });
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
|
|
499
405
|
/**
|
|
500
406
|
* @summary Get Appliance that match the deviceName
|
|
501
407
|
*
|
|
@@ -510,75 +416,11 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
510
416
|
const origin = `${this.id}-${meth}`;
|
|
511
417
|
log.trace(origin);
|
|
512
418
|
|
|
513
|
-
// make sure we are set up for device broker getDevice
|
|
514
|
-
if (!this.allProps.devicebroker || !this.allProps.devicebroker.getDevice || this.allProps.devicebroker.getDevice.length === 0 || !this.allProps.devicebroker.getDevice[0].path) {
|
|
515
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getDevice.path'], null, null, null);
|
|
516
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
517
|
-
return callback(null, errorObj);
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
521
|
-
if (deviceName === undefined || deviceName === null || deviceName === '' || deviceName.length === 0) {
|
|
522
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceName'], null, null, null);
|
|
523
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
524
|
-
return callback(null, errorObj);
|
|
525
|
-
}
|
|
526
|
-
|
|
527
419
|
try {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
name: deviceName
|
|
533
|
-
}
|
|
534
|
-
};
|
|
535
|
-
return this.getDevicesFiltered(opts, (devs, ferr) => {
|
|
536
|
-
// if we received an error or their is no response on the results return an error
|
|
537
|
-
if (ferr) {
|
|
538
|
-
return callback(null, ferr);
|
|
539
|
-
}
|
|
540
|
-
if (devs.list.length < 1) {
|
|
541
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Did Not Find Device ${deviceName}`, [], null, null, null);
|
|
542
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
543
|
-
return callback(null, errorObj);
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
const callPromises = [];
|
|
547
|
-
for (let i = 0; i < this.allProps.devicebroker.getDevice.length; i += 1) {
|
|
548
|
-
// Perform component calls here.
|
|
549
|
-
callPromises.push(
|
|
550
|
-
new Promise((resolve, reject) => {
|
|
551
|
-
this.iapMakeBrokerCall('getDevice', this.allProps.devicebroker.getDevice[i], devs.list[0], null, (callRet, callErr) => {
|
|
552
|
-
// return an error
|
|
553
|
-
if (callErr) {
|
|
554
|
-
reject(callErr);
|
|
555
|
-
} else {
|
|
556
|
-
// return the data
|
|
557
|
-
resolve(callRet);
|
|
558
|
-
}
|
|
559
|
-
});
|
|
560
|
-
})
|
|
561
|
-
);
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
// return an array of repsonses
|
|
565
|
-
return Promise.all(callPromises).then((results) => {
|
|
566
|
-
let myResult = {};
|
|
567
|
-
results.forEach((result) => {
|
|
568
|
-
myResult = { ...myResult, ...result };
|
|
569
|
-
});
|
|
570
|
-
|
|
571
|
-
return callback(myResult, null);
|
|
572
|
-
})
|
|
573
|
-
.catch((error) => {
|
|
574
|
-
log.debug(`Caught ${JSON.stringify(error)}`);
|
|
575
|
-
return callback(null, error);
|
|
576
|
-
});
|
|
577
|
-
});
|
|
578
|
-
} catch (ex) {
|
|
579
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
580
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
581
|
-
return callback(null, errorObj);
|
|
420
|
+
return super.getDevice(deviceName, callback);
|
|
421
|
+
} catch (err) {
|
|
422
|
+
log.error(`${origin}: ${err}`);
|
|
423
|
+
return callback(null, err);
|
|
582
424
|
}
|
|
583
425
|
}
|
|
584
426
|
|
|
@@ -596,88 +438,11 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
596
438
|
const origin = `${this.id}-${meth}`;
|
|
597
439
|
log.trace(origin);
|
|
598
440
|
|
|
599
|
-
// make sure we are set up for device broker getDevicesFiltered
|
|
600
|
-
if (!this.allProps.devicebroker || !this.allProps.devicebroker.getDevicesFiltered || this.allProps.devicebroker.getDevicesFiltered.length === 0 || !this.allProps.devicebroker.getDevicesFiltered[0].path) {
|
|
601
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getDevicesFiltered.path'], null, null, null);
|
|
602
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
603
|
-
return callback(null, errorObj);
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
// verify the required fields have been provided
|
|
607
|
-
if (options === undefined || options === null || options === '' || options.length === 0) {
|
|
608
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['options'], null, null, null);
|
|
609
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
610
|
-
return callback(null, errorObj);
|
|
611
|
-
}
|
|
612
|
-
log.debug(`Device Filter Options: ${JSON.stringify(options)}`);
|
|
613
|
-
|
|
614
441
|
try {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
// set up the filter of Device Names
|
|
620
|
-
let filterName = [];
|
|
621
|
-
if (options && options.filter && options.filter.name) {
|
|
622
|
-
// when this hack is removed, remove the lint ignore above
|
|
623
|
-
if (Array.isArray(options.filter.name)) {
|
|
624
|
-
// eslint-disable-next-line prefer-destructuring
|
|
625
|
-
filterName = options.filter.name;
|
|
626
|
-
} else {
|
|
627
|
-
filterName = [options.filter.name];
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
// TODO - get sort and order working
|
|
632
|
-
/*
|
|
633
|
-
if (options && options.sort) {
|
|
634
|
-
reqObj.uriOptions.sort = JSON.stringify(options.sort);
|
|
635
|
-
}
|
|
636
|
-
if (options && options.order) {
|
|
637
|
-
reqObj.uriOptions.order = options.order;
|
|
638
|
-
}
|
|
639
|
-
*/
|
|
640
|
-
const callPromises = [];
|
|
641
|
-
for (let i = 0; i < this.allProps.devicebroker.getDevicesFiltered.length; i += 1) {
|
|
642
|
-
// Perform component calls here.
|
|
643
|
-
callPromises.push(
|
|
644
|
-
new Promise((resolve, reject) => {
|
|
645
|
-
this.iapMakeBrokerCall('getDevicesFiltered', this.allProps.devicebroker.getDevicesFiltered[i], {}, filterName, (callRet, callErr) => {
|
|
646
|
-
// return an error
|
|
647
|
-
if (callErr) {
|
|
648
|
-
reject(callErr);
|
|
649
|
-
} else {
|
|
650
|
-
// return the data
|
|
651
|
-
resolve(callRet);
|
|
652
|
-
}
|
|
653
|
-
});
|
|
654
|
-
})
|
|
655
|
-
);
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
// return an array of repsonses
|
|
659
|
-
return Promise.all(callPromises).then((results) => {
|
|
660
|
-
let myResult = [];
|
|
661
|
-
results.forEach((result) => {
|
|
662
|
-
if (Array.isArray(result)) {
|
|
663
|
-
myResult = [...myResult, ...result];
|
|
664
|
-
} else if (Object.keys(result).length > 0) {
|
|
665
|
-
myResult.push(result);
|
|
666
|
-
}
|
|
667
|
-
});
|
|
668
|
-
|
|
669
|
-
log.debug(`${origin}: Found #${myResult.length} devices.`);
|
|
670
|
-
log.debug(`Devices: ${JSON.stringify(myResult)}`);
|
|
671
|
-
return callback({ total: myResult.length, list: myResult });
|
|
672
|
-
})
|
|
673
|
-
.catch((error) => {
|
|
674
|
-
log.debug(`Caught ${JSON.stringify(error)}`);
|
|
675
|
-
return callback(null, error);
|
|
676
|
-
});
|
|
677
|
-
} catch (ex) {
|
|
678
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
679
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
680
|
-
return callback(null, errorObj);
|
|
442
|
+
return super.getDevicesFiltered(options, callback);
|
|
443
|
+
} catch (err) {
|
|
444
|
+
log.error(`${origin}: ${err}`);
|
|
445
|
+
return callback(null, err);
|
|
681
446
|
}
|
|
682
447
|
}
|
|
683
448
|
|
|
@@ -695,79 +460,11 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
695
460
|
const origin = `${this.id}-${meth}`;
|
|
696
461
|
log.trace(origin);
|
|
697
462
|
|
|
698
|
-
// make sure we are set up for device broker isAlive
|
|
699
|
-
if (!this.allProps.devicebroker || !this.allProps.devicebroker.isAlive || this.allProps.devicebroker.isAlive.length === 0 || !this.allProps.devicebroker.isAlive[0].path) {
|
|
700
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.isAlive.path'], null, null, null);
|
|
701
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
702
|
-
return callback(null, errorObj);
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
// verify the required fields have been provided
|
|
706
|
-
if (deviceName === undefined || deviceName === null || deviceName === '' || deviceName.length === 0) {
|
|
707
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceName'], null, null, null);
|
|
708
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
709
|
-
return callback(null, errorObj);
|
|
710
|
-
}
|
|
711
|
-
|
|
712
463
|
try {
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
name: deviceName
|
|
718
|
-
}
|
|
719
|
-
};
|
|
720
|
-
return this.getDevicesFiltered(opts, (devs, ferr) => {
|
|
721
|
-
// if we received an error or their is no response on the results return an error
|
|
722
|
-
if (ferr) {
|
|
723
|
-
return callback(null, ferr);
|
|
724
|
-
}
|
|
725
|
-
if (devs.list.length < 1) {
|
|
726
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Did Not Find Device ${deviceName}`, [], null, null, null);
|
|
727
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
728
|
-
return callback(null, errorObj);
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
const callPromises = [];
|
|
732
|
-
for (let i = 0; i < this.allProps.devicebroker.isAlive.length; i += 1) {
|
|
733
|
-
// Perform component calls here.
|
|
734
|
-
callPromises.push(
|
|
735
|
-
new Promise((resolve, reject) => {
|
|
736
|
-
this.iapMakeBrokerCall('isAlive', this.allProps.devicebroker.isAlive[i], devs.list[0], null, (callRet, callErr) => {
|
|
737
|
-
// return an error
|
|
738
|
-
if (callErr) {
|
|
739
|
-
reject(callErr);
|
|
740
|
-
} else {
|
|
741
|
-
// return the data
|
|
742
|
-
resolve(callRet);
|
|
743
|
-
}
|
|
744
|
-
});
|
|
745
|
-
})
|
|
746
|
-
);
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
// return an array of repsonses
|
|
750
|
-
return Promise.all(callPromises).then((results) => {
|
|
751
|
-
let myResult = {};
|
|
752
|
-
results.forEach((result) => {
|
|
753
|
-
myResult = { ...myResult, ...result };
|
|
754
|
-
});
|
|
755
|
-
|
|
756
|
-
let response = true;
|
|
757
|
-
if (myResult.isAlive !== null && myResult.isAlive !== undefined && myResult.isAlive === false) {
|
|
758
|
-
response = false;
|
|
759
|
-
}
|
|
760
|
-
return callback(response);
|
|
761
|
-
})
|
|
762
|
-
.catch((error) => {
|
|
763
|
-
log.debug(`Caught ${JSON.stringify(error)}`);
|
|
764
|
-
return callback(null, error);
|
|
765
|
-
});
|
|
766
|
-
});
|
|
767
|
-
} catch (ex) {
|
|
768
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
769
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
770
|
-
return callback(null, errorObj);
|
|
464
|
+
return super.isAlive(deviceName, callback);
|
|
465
|
+
} catch (err) {
|
|
466
|
+
log.error(`${origin}: ${err}`);
|
|
467
|
+
return callback(null, err);
|
|
771
468
|
}
|
|
772
469
|
}
|
|
773
470
|
|
|
@@ -786,79 +483,11 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
786
483
|
const origin = `${this.id}-${meth}`;
|
|
787
484
|
log.trace(origin);
|
|
788
485
|
|
|
789
|
-
// make sure we are set up for device broker getConfig
|
|
790
|
-
if (!this.allProps.devicebroker || !this.allProps.devicebroker.getConfig || this.allProps.devicebroker.getConfig.length === 0 || !this.allProps.devicebroker.getConfig[0].path) {
|
|
791
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getConfig.path'], null, null, null);
|
|
792
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
793
|
-
return callback(null, errorObj);
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
// verify the required fields have been provided
|
|
797
|
-
if (deviceName === undefined || deviceName === null || deviceName === '' || deviceName.length === 0) {
|
|
798
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceName'], null, null, null);
|
|
799
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
800
|
-
return callback(null, errorObj);
|
|
801
|
-
}
|
|
802
|
-
|
|
803
486
|
try {
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
name: deviceName
|
|
809
|
-
}
|
|
810
|
-
};
|
|
811
|
-
return this.getDevicesFiltered(opts, (devs, ferr) => {
|
|
812
|
-
// if we received an error or their is no response on the results return an error
|
|
813
|
-
if (ferr) {
|
|
814
|
-
return callback(null, ferr);
|
|
815
|
-
}
|
|
816
|
-
if (devs.list.length < 1) {
|
|
817
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Did Not Find Device ${deviceName}`, [], null, null, null);
|
|
818
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
819
|
-
return callback(null, errorObj);
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
const callPromises = [];
|
|
823
|
-
for (let i = 0; i < this.allProps.devicebroker.getConfig.length; i += 1) {
|
|
824
|
-
// Perform component calls here.
|
|
825
|
-
callPromises.push(
|
|
826
|
-
new Promise((resolve, reject) => {
|
|
827
|
-
this.iapMakeBrokerCall('getConfig', this.allProps.devicebroker.getConfig[i], devs.list[0], null, (callRet, callErr) => {
|
|
828
|
-
// return an error
|
|
829
|
-
if (callErr) {
|
|
830
|
-
reject(callErr);
|
|
831
|
-
} else {
|
|
832
|
-
// return the data
|
|
833
|
-
resolve(callRet);
|
|
834
|
-
}
|
|
835
|
-
});
|
|
836
|
-
})
|
|
837
|
-
);
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
// return an array of repsonses
|
|
841
|
-
return Promise.all(callPromises).then((results) => {
|
|
842
|
-
let myResult = {};
|
|
843
|
-
results.forEach((result) => {
|
|
844
|
-
myResult = { ...myResult, ...result };
|
|
845
|
-
});
|
|
846
|
-
|
|
847
|
-
// return the result
|
|
848
|
-
const newResponse = {
|
|
849
|
-
response: JSON.stringify(myResult, null, 2)
|
|
850
|
-
};
|
|
851
|
-
return callback(newResponse, null);
|
|
852
|
-
})
|
|
853
|
-
.catch((error) => {
|
|
854
|
-
log.debug(`Caught ${JSON.stringify(error)}`);
|
|
855
|
-
return callback(null, error);
|
|
856
|
-
});
|
|
857
|
-
});
|
|
858
|
-
} catch (ex) {
|
|
859
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
860
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
861
|
-
return callback(null, errorObj);
|
|
487
|
+
return super.getConfig(deviceName, format, callback);
|
|
488
|
+
} catch (err) {
|
|
489
|
+
log.error(`${origin}: ${err}`);
|
|
490
|
+
return callback(null, err);
|
|
862
491
|
}
|
|
863
492
|
}
|
|
864
493
|
|
|
@@ -875,56 +504,47 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
875
504
|
const origin = `${this.id}-${meth}`;
|
|
876
505
|
log.trace(origin);
|
|
877
506
|
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
log.error(`${origin}: ${
|
|
882
|
-
return callback(null,
|
|
507
|
+
try {
|
|
508
|
+
return super.iapGetDeviceCount(callback);
|
|
509
|
+
} catch (err) {
|
|
510
|
+
log.error(`${origin}: ${err}`);
|
|
511
|
+
return callback(null, err);
|
|
883
512
|
}
|
|
513
|
+
}
|
|
884
514
|
|
|
885
|
-
|
|
515
|
+
/* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
|
|
516
|
+
/**
|
|
517
|
+
* Makes the requested generic call
|
|
518
|
+
*
|
|
519
|
+
* @function iapExpandedGenericAdapterRequest
|
|
520
|
+
* @param {Object} metadata - metadata for the call (optional).
|
|
521
|
+
* Can be a stringified Object.
|
|
522
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
|
|
523
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
|
|
524
|
+
* @param {Object} pathVars - the parameters to be put within the url path (optional).
|
|
525
|
+
* Can be a stringified Object.
|
|
526
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
527
|
+
* Can be a stringified Object.
|
|
528
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
529
|
+
* Can be a stringified Object.
|
|
530
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
531
|
+
* Can be a stringified Object.
|
|
532
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
533
|
+
* or the error
|
|
534
|
+
*/
|
|
535
|
+
iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
|
|
536
|
+
const meth = 'adapter-iapExpandedGenericAdapterRequest';
|
|
537
|
+
const origin = `${this.id}-${meth}`;
|
|
538
|
+
log.trace(origin);
|
|
886
539
|
|
|
887
540
|
try {
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
new Promise((resolve, reject) => {
|
|
893
|
-
this.iapMakeBrokerCall('getCount', this.allProps.devicebroker.getCount[i], null, null, (callRet, callErr) => {
|
|
894
|
-
// return an error
|
|
895
|
-
if (callErr) {
|
|
896
|
-
reject(callErr);
|
|
897
|
-
} else {
|
|
898
|
-
// return the data
|
|
899
|
-
resolve(callRet);
|
|
900
|
-
}
|
|
901
|
-
});
|
|
902
|
-
})
|
|
903
|
-
);
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
// return an array of repsonses
|
|
907
|
-
return Promise.all(callPromises).then((results) => {
|
|
908
|
-
let myResult = {};
|
|
909
|
-
results.forEach((result) => {
|
|
910
|
-
myResult = { ...myResult, ...result };
|
|
911
|
-
});
|
|
912
|
-
|
|
913
|
-
// return the result
|
|
914
|
-
return callback({ count: myResult.length });
|
|
915
|
-
})
|
|
916
|
-
.catch((error) => {
|
|
917
|
-
log.debug(`Caught ${JSON.stringify(error)}`);
|
|
918
|
-
return callback(null, error);
|
|
919
|
-
});
|
|
920
|
-
} catch (ex) {
|
|
921
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
922
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
923
|
-
return callback(null, errorObj);
|
|
541
|
+
return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
|
|
542
|
+
} catch (err) {
|
|
543
|
+
log.error(`${origin}: ${err}`);
|
|
544
|
+
return callback(null, err);
|
|
924
545
|
}
|
|
925
546
|
}
|
|
926
547
|
|
|
927
|
-
/* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
|
|
928
548
|
/**
|
|
929
549
|
* Makes the requested generic call
|
|
930
550
|
*
|
|
@@ -945,94 +565,84 @@ class AdtranMosaicDeviceManager extends AdapterBaseCl {
|
|
|
945
565
|
const origin = `${this.id}-${meth}`;
|
|
946
566
|
log.trace(origin);
|
|
947
567
|
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
568
|
+
try {
|
|
569
|
+
return super.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
|
|
570
|
+
} catch (err) {
|
|
571
|
+
log.error(`${origin}: ${err}`);
|
|
572
|
+
return callback(null, err);
|
|
952
573
|
}
|
|
574
|
+
}
|
|
953
575
|
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
576
|
+
/**
|
|
577
|
+
* Makes the requested generic call with no base path or version
|
|
578
|
+
*
|
|
579
|
+
* @function genericAdapterRequestNoBasePath
|
|
580
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
|
581
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
|
582
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
583
|
+
* Can be a stringified Object.
|
|
584
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
585
|
+
* Can be a stringified Object.
|
|
586
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
587
|
+
* Can be a stringified Object.
|
|
588
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
589
|
+
* or the error
|
|
590
|
+
*/
|
|
591
|
+
genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
|
592
|
+
const meth = 'adapter-genericAdapterRequestNoBasePath';
|
|
593
|
+
const origin = `${this.id}-${meth}`;
|
|
594
|
+
log.trace(origin);
|
|
965
595
|
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
596
|
+
try {
|
|
597
|
+
return super.genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
|
|
598
|
+
} catch (err) {
|
|
599
|
+
log.error(`${origin}: ${err}`);
|
|
600
|
+
return callback(null, err);
|
|
971
601
|
}
|
|
972
|
-
|
|
973
|
-
const queryParamsAvailable = queryData;
|
|
974
|
-
const queryParams = {};
|
|
975
|
-
const bodyVars = requestBody;
|
|
602
|
+
}
|
|
976
603
|
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
604
|
+
/* INVENTORY CALLS */
|
|
605
|
+
/**
|
|
606
|
+
* @summary run the adapter lint script to return the results.
|
|
607
|
+
*
|
|
608
|
+
* @function iapRunAdapterLint
|
|
609
|
+
* @param {Callback} callback - callback function
|
|
610
|
+
*/
|
|
611
|
+
iapRunAdapterLint(callback) {
|
|
612
|
+
const meth = 'adapter-iapRunAdapterLint';
|
|
613
|
+
const origin = `${this.id}-${meth}`;
|
|
614
|
+
log.trace(origin);
|
|
984
615
|
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
payload: bodyVars,
|
|
988
|
-
uriPathVars: pathVars,
|
|
989
|
-
uriQuery: queryParams,
|
|
990
|
-
uriOptions: {}
|
|
991
|
-
};
|
|
992
|
-
// add headers if provided
|
|
993
|
-
if (addlHeaders) {
|
|
994
|
-
reqObj.addlHeaders = addlHeaders;
|
|
995
|
-
}
|
|
616
|
+
return super.iapRunAdapterLint(callback);
|
|
617
|
+
}
|
|
996
618
|
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
returnF = false;
|
|
1009
|
-
}
|
|
619
|
+
/**
|
|
620
|
+
* @summary run the adapter test scripts (baseunit and unit) to return the results.
|
|
621
|
+
* can not run integration as there can be implications with that.
|
|
622
|
+
*
|
|
623
|
+
* @function iapRunAdapterTests
|
|
624
|
+
* @param {Callback} callback - callback function
|
|
625
|
+
*/
|
|
626
|
+
iapRunAdapterTests(callback) {
|
|
627
|
+
const meth = 'adapter-iapRunAdapterTests';
|
|
628
|
+
const origin = `${this.id}-${meth}`;
|
|
629
|
+
log.trace(origin);
|
|
1010
630
|
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1014
|
-
return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
|
|
1015
|
-
// if we received an error or their is no response on the results
|
|
1016
|
-
// return an error
|
|
1017
|
-
if (irReturnError) {
|
|
1018
|
-
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1019
|
-
return callback(null, irReturnError);
|
|
1020
|
-
}
|
|
1021
|
-
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1022
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
|
|
1023
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1024
|
-
return callback(null, errorObj);
|
|
1025
|
-
}
|
|
631
|
+
return super.iapRunAdapterTests(callback);
|
|
632
|
+
}
|
|
1026
633
|
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
}
|
|
634
|
+
/**
|
|
635
|
+
* @summary provide inventory information abbout the adapter
|
|
636
|
+
*
|
|
637
|
+
* @function iapGetAdapterInventory
|
|
638
|
+
* @param {Callback} callback - callback function
|
|
639
|
+
*/
|
|
640
|
+
iapGetAdapterInventory(callback) {
|
|
641
|
+
const meth = 'adapter-iapGetAdapterInventory';
|
|
642
|
+
const origin = `${this.id}-${meth}`;
|
|
643
|
+
log.trace(origin);
|
|
644
|
+
|
|
645
|
+
return super.iapGetAdapterInventory(callback);
|
|
1036
646
|
}
|
|
1037
647
|
|
|
1038
648
|
/**
|