@itentialopensource/adapter-efficientip_solidserver 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.
Files changed (57) hide show
  1. package/AUTH.md +39 -0
  2. package/BROKER.md +199 -0
  3. package/CALLS.md +1465 -0
  4. package/CHANGELOG.md +17 -2
  5. package/CODE_OF_CONDUCT.md +12 -17
  6. package/CONTRIBUTING.md +3 -148
  7. package/ENHANCE.md +69 -0
  8. package/PROPERTIES.md +641 -0
  9. package/README.md +235 -576
  10. package/SUMMARY.md +9 -0
  11. package/SYSTEMINFO.md +11 -0
  12. package/TROUBLESHOOT.md +47 -0
  13. package/adapter.js +383 -263
  14. package/adapterBase.js +854 -408
  15. package/changelogs/changelog.md +16 -0
  16. package/entities/.generic/action.json +110 -5
  17. package/entities/.generic/schema.json +6 -1
  18. package/error.json +6 -0
  19. package/metadata.json +49 -0
  20. package/package.json +27 -22
  21. package/pronghorn.json +691 -88
  22. package/propertiesDecorators.json +14 -0
  23. package/propertiesSchema.json +828 -7
  24. package/refs?service=git-upload-pack +0 -0
  25. package/report/adapter-openapi.json +41906 -0
  26. package/report/adapter-openapi.yaml +23138 -0
  27. package/report/adapterInfo.json +10 -0
  28. package/report/updateReport1653233995404.json +120 -0
  29. package/report/updateReport1691508450223.json +120 -0
  30. package/report/updateReport1692202927301.json +120 -0
  31. package/report/updateReport1694465845842.json +120 -0
  32. package/report/updateReport1698421858198.json +120 -0
  33. package/sampleProperties.json +153 -3
  34. package/test/integration/adapterTestBasicGet.js +3 -5
  35. package/test/integration/adapterTestConnectivity.js +91 -42
  36. package/test/integration/adapterTestIntegration.js +155 -106
  37. package/test/unit/adapterBaseTestUnit.js +388 -308
  38. package/test/unit/adapterTestUnit.js +484 -243
  39. package/utils/adapterInfo.js +206 -0
  40. package/utils/addAuth.js +94 -0
  41. package/utils/artifactize.js +1 -1
  42. package/utils/basicGet.js +1 -14
  43. package/utils/checkMigrate.js +1 -1
  44. package/utils/entitiesToDB.js +179 -0
  45. package/utils/findPath.js +1 -1
  46. package/utils/methodDocumentor.js +273 -0
  47. package/utils/modify.js +14 -16
  48. package/utils/packModificationScript.js +1 -1
  49. package/utils/patches2bundledDeps.js +90 -0
  50. package/utils/pre-commit.sh +5 -0
  51. package/utils/removeHooks.js +20 -0
  52. package/utils/taskMover.js +309 -0
  53. package/utils/tbScript.js +129 -53
  54. package/utils/tbUtils.js +125 -25
  55. package/utils/testRunner.js +17 -17
  56. package/utils/troubleshootingAdapter.js +10 -31
  57. package/workflows/README.md +0 -3
package/adapter.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  /* eslint import/no-dynamic-require: warn */
4
4
  /* eslint object-curly-newline: warn */
5
+ /* eslint default-param-last: warn */
5
6
 
6
7
  // Set globals
7
8
  /* global log */
@@ -80,10 +81,15 @@ class EfficientipSolidserver extends AdapterBaseCl {
80
81
  }
81
82
 
82
83
  /**
83
- * @getWorkflowFunctions
84
+ * @iapGetAdapterWorkflowFunctions
84
85
  */
85
- getWorkflowFunctions(inIgnore) {
86
- let myIgnore = [];
86
+ iapGetAdapterWorkflowFunctions(inIgnore) {
87
+ let myIgnore = [
88
+ 'healthCheck',
89
+ 'iapGetAdapterWorkflowFunctions',
90
+ 'hasEntities',
91
+ 'getAuthorization'
92
+ ];
87
93
  if (!inIgnore && Array.isArray(inIgnore)) {
88
94
  myIgnore = inIgnore;
89
95
  } else if (!inIgnore && typeof inIgnore === 'string') {
@@ -94,52 +100,44 @@ class EfficientipSolidserver extends AdapterBaseCl {
94
100
  // you can add specific methods that you do not want to be workflow functions to ignore like below
95
101
  // myIgnore.push('myMethodNotInWorkflow');
96
102
 
97
- return super.getWorkflowFunctions(myIgnore);
103
+ return super.iapGetAdapterWorkflowFunctions(myIgnore);
98
104
  }
99
105
 
100
106
  /**
101
- * updateAdapterConfiguration is used to update any of the adapter configuration files. This
107
+ * iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
102
108
  * allows customers to make changes to adapter configuration without having to be on the
103
109
  * file system.
104
110
  *
105
- * @function updateAdapterConfiguration
111
+ * @function iapUpdateAdapterConfiguration
106
112
  * @param {string} configFile - the name of the file being updated (required)
107
113
  * @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
108
114
  * @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
109
115
  * @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
110
116
  * @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
117
+ * @param {boolean} replace - true to replace entire mock data, false to merge/append
111
118
  * @param {Callback} callback - The results of the call
112
119
  */
113
- updateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
114
- const origin = `${this.id}-adapter-updateAdapterConfiguration`;
120
+ iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
121
+ const meth = 'adapter-iapUpdateAdapterConfiguration';
122
+ const origin = `${this.id}-${meth}`;
115
123
  log.trace(origin);
116
- super.updateAdapterConfiguration(configFile, changes, entity, type, action, callback);
117
- }
118
124
 
119
- /**
120
- * See if the API path provided is found in this adapter
121
- *
122
- * @function findPath
123
- * @param {string} apiPath - the api path to check on
124
- * @param {Callback} callback - The results of the call
125
- */
126
- findPath(apiPath, callback) {
127
- const origin = `${this.id}-adapter-findPath`;
128
- log.trace(origin);
129
- super.findPath(apiPath, callback);
125
+ super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
130
126
  }
131
127
 
132
128
  /**
133
129
  * @summary Suspends adapter
134
130
  *
135
- * @function suspend
131
+ * @function iapSuspendAdapter
136
132
  * @param {Callback} callback - callback function
137
133
  */
138
- suspend(mode, callback) {
139
- const origin = `${this.id}-adapter-suspend`;
134
+ iapSuspendAdapter(mode, callback) {
135
+ const meth = 'adapter-iapSuspendAdapter';
136
+ const origin = `${this.id}-${meth}`;
140
137
  log.trace(origin);
138
+
141
139
  try {
142
- return super.suspend(mode, callback);
140
+ return super.iapSuspendAdapter(mode, callback);
143
141
  } catch (error) {
144
142
  log.error(`${origin}: ${error}`);
145
143
  return callback(null, error);
@@ -149,14 +147,16 @@ class EfficientipSolidserver extends AdapterBaseCl {
149
147
  /**
150
148
  * @summary Unsuspends adapter
151
149
  *
152
- * @function unsuspend
150
+ * @function iapUnsuspendAdapter
153
151
  * @param {Callback} callback - callback function
154
152
  */
155
- unsuspend(callback) {
156
- const origin = `${this.id}-adapter-unsuspend`;
153
+ iapUnsuspendAdapter(callback) {
154
+ const meth = 'adapter-iapUnsuspendAdapter';
155
+ const origin = `${this.id}-${meth}`;
157
156
  log.trace(origin);
157
+
158
158
  try {
159
- return super.unsuspend(callback);
159
+ return super.iapUnsuspendAdapter(callback);
160
160
  } catch (error) {
161
161
  log.error(`${origin}: ${error}`);
162
162
  return callback(null, error);
@@ -164,31 +164,51 @@ class EfficientipSolidserver extends AdapterBaseCl {
164
164
  }
165
165
 
166
166
  /**
167
- * @summary Get the Adaoter Queue
167
+ * @summary Get the Adapter Queue
168
168
  *
169
- * @function getQueue
169
+ * @function iapGetAdapterQueue
170
170
  * @param {Callback} callback - callback function
171
171
  */
172
- getQueue(callback) {
173
- const origin = `${this.id}-adapter-getQueue`;
172
+ iapGetAdapterQueue(callback) {
173
+ const meth = 'adapter-iapGetAdapterQueue';
174
+ const origin = `${this.id}-${meth}`;
175
+ log.trace(origin);
176
+
177
+ return super.iapGetAdapterQueue(callback);
178
+ }
179
+
180
+ /* SCRIPT CALLS */
181
+ /**
182
+ * See if the API path provided is found in this adapter
183
+ *
184
+ * @function iapFindAdapterPath
185
+ * @param {string} apiPath - the api path to check on
186
+ * @param {Callback} callback - The results of the call
187
+ */
188
+ iapFindAdapterPath(apiPath, callback) {
189
+ const meth = 'adapter-iapFindAdapterPath';
190
+ const origin = `${this.id}-${meth}`;
174
191
  log.trace(origin);
175
- return super.getQueue(callback);
192
+
193
+ super.iapFindAdapterPath(apiPath, callback);
176
194
  }
177
195
 
178
196
  /**
179
197
  * @summary Runs troubleshoot scripts for adapter
180
198
  *
181
- * @function troubleshoot
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
- troubleshoot(props, persistFlag, callback) {
188
- const origin = `${this.id}-adapter-troubleshoot`;
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.troubleshoot(props, persistFlag, this, callback);
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 EfficientipSolidserver extends AdapterBaseCl {
198
218
  /**
199
219
  * @summary runs healthcheck script for adapter
200
220
  *
201
- * @function runHealthcheck
221
+ * @function iapRunAdapterHealthcheck
202
222
  * @param {Adapter} adapter - adapter instance to troubleshoot
203
223
  * @param {Callback} callback - callback function
204
224
  */
205
- runHealthcheck(callback) {
206
- const origin = `${this.id}-adapter-runHealthcheck`;
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.runHealthcheck(this, callback);
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 EfficientipSolidserver extends AdapterBaseCl {
216
238
  /**
217
239
  * @summary runs connectivity check script for adapter
218
240
  *
219
- * @function runConnectivity
241
+ * @function iapRunAdapterConnectivity
220
242
  * @param {Callback} callback - callback function
221
243
  */
222
- runConnectivity(callback) {
223
- const origin = `${this.id}-adapter-runConnectivity`;
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.runConnectivity(callback);
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 EfficientipSolidserver extends AdapterBaseCl {
233
257
  /**
234
258
  * @summary runs basicGet script for adapter
235
259
  *
236
- * @function runBasicGet
260
+ * @function iapRunAdapterBasicGet
237
261
  * @param {Callback} callback - callback function
238
262
  */
239
- runBasicGet(callback) {
240
- const origin = `${this.id}-adapter-runBasicGet`;
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.runBasicGet(callback);
269
+ return super.iapRunAdapterBasicGet(callback);
244
270
  } catch (error) {
245
271
  log.error(`${origin}: ${error}`);
246
272
  return callback(null, error);
@@ -248,171 +274,275 @@ class EfficientipSolidserver extends AdapterBaseCl {
248
274
  }
249
275
 
250
276
  /**
251
- * @summary Determines if this adapter supports the specific entity
277
+ * @summary moves entites into Mongo DB
252
278
  *
253
- * @function hasEntity
254
- * @param {String} entityType - the entity type to check for
255
- * @param {String/Array} entityId - the specific entity we are looking for
279
+ * @function iapMoveAdapterEntitiesToDB
280
+ * @param {getCallback} callback - a callback function to return the result (Generics)
281
+ * or the error
282
+ */
283
+ iapMoveAdapterEntitiesToDB(callback) {
284
+ const meth = 'adapter-iapMoveAdapterEntitiesToDB';
285
+ const origin = `${this.id}-${meth}`;
286
+ log.trace(origin);
287
+
288
+ try {
289
+ return super.iapMoveAdapterEntitiesToDB(callback);
290
+ } catch (err) {
291
+ log.error(`${origin}: ${err}`);
292
+ return callback(null, err);
293
+ }
294
+ }
295
+
296
+ /**
297
+ * @summary Deactivate adapter tasks
256
298
  *
257
- * @param {Callback} callback - An array of whether the adapter can has the
258
- * desired capability or an error
299
+ * @function iapDeactivateTasks
300
+ *
301
+ * @param {Array} tasks - List of tasks to deactivate
302
+ * @param {Callback} callback
259
303
  */
260
- hasEntity(entityType, entityId, callback) {
261
- const origin = `${this.id}-adapter-hasEntity`;
304
+ iapDeactivateTasks(tasks, callback) {
305
+ const meth = 'adapter-iapDeactivateTasks';
306
+ const origin = `${this.id}-${meth}`;
262
307
  log.trace(origin);
263
308
 
264
- // Make the call -
265
- // verifyCapability(entityType, actionType, entityId, callback)
266
- return this.verifyCapability(entityType, null, entityId, callback);
309
+ try {
310
+ return super.iapDeactivateTasks(tasks, callback);
311
+ } catch (err) {
312
+ log.error(`${origin}: ${err}`);
313
+ return callback(null, err);
314
+ }
315
+ }
316
+
317
+ /**
318
+ * @summary Activate adapter tasks that have previously been deactivated
319
+ *
320
+ * @function iapActivateTasks
321
+ *
322
+ * @param {Array} tasks - List of tasks to activate
323
+ * @param {Callback} callback
324
+ */
325
+ iapActivateTasks(tasks, callback) {
326
+ const meth = 'adapter-iapActivateTasks';
327
+ const origin = `${this.id}-${meth}`;
328
+ log.trace(origin);
329
+
330
+ try {
331
+ return super.iapActivateTasks(tasks, callback);
332
+ } catch (err) {
333
+ log.error(`${origin}: ${err}`);
334
+ return callback(null, err);
335
+ }
267
336
  }
268
337
 
338
+ /* CACHE CALLS */
269
339
  /**
270
- * @summary Provides a way for the adapter to tell north bound integrations
271
- * whether the adapter supports type, action and specific entity
340
+ * @summary Populate the cache for the given entities
272
341
  *
273
- * @function verifyCapability
342
+ * @function iapPopulateEntityCache
343
+ * @param {String/Array of Strings} entityType - the entity type(s) to populate
344
+ * @param {Callback} callback - whether the cache was updated or not for each entity type
345
+ *
346
+ * @returns status of the populate
347
+ */
348
+ iapPopulateEntityCache(entityTypes, callback) {
349
+ const meth = 'adapter-iapPopulateEntityCache';
350
+ const origin = `${this.id}-${meth}`;
351
+ log.trace(origin);
352
+
353
+ try {
354
+ return super.iapPopulateEntityCache(entityTypes, callback);
355
+ } catch (err) {
356
+ log.error(`${origin}: ${err}`);
357
+ return callback(null, err);
358
+ }
359
+ }
360
+
361
+ /**
362
+ * @summary Retrieves data from cache for specified entity type
363
+ *
364
+ * @function iapRetrieveEntitiesCache
365
+ * @param {String} entityType - entity of which to retrieve
366
+ * @param {Object} options - settings of which data to return and how to return it
367
+ * @param {Callback} callback - the data if it was retrieved
368
+ */
369
+ iapRetrieveEntitiesCache(entityType, options, callback) {
370
+ const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
371
+ const origin = `${this.id}-${meth}`;
372
+ log.trace(origin);
373
+
374
+ try {
375
+ return super.iapRetrieveEntitiesCache(entityType, options, callback);
376
+ } catch (err) {
377
+ log.error(`${origin}: ${err}`);
378
+ return callback(null, err);
379
+ }
380
+ }
381
+
382
+ /* BROKER CALLS */
383
+ /**
384
+ * @summary Determines if this adapter supports any in a list of entities
385
+ *
386
+ * @function hasEntities
274
387
  * @param {String} entityType - the entity type to check for
275
- * @param {String} actionType - the action type to check for
276
- * @param {String/Array} entityId - the specific entity we are looking for
388
+ * @param {Array} entityList - the list of entities we are looking for
277
389
  *
278
- * @param {Callback} callback - An array of whether the adapter can has the
279
- * desired capability or an error
390
+ * @param {Callback} callback - A map where the entity is the key and the
391
+ * value is true or false
280
392
  */
281
- verifyCapability(entityType, actionType, entityId, callback) {
282
- const meth = 'adapterBase-verifyCapability';
393
+ hasEntities(entityType, entityList, callback) {
394
+ const meth = 'adapter-hasEntities';
283
395
  const origin = `${this.id}-${meth}`;
284
396
  log.trace(origin);
285
397
 
286
- // if caching
287
- if (this.caching) {
288
- // Make the call - verifyCapability(entityType, actionType, entityId, callback)
289
- return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (results, error) => {
290
- if (error) {
291
- return callback(null, error);
292
- }
293
-
294
- // if the cache needs to be updated, update and try again
295
- if (results && results[0] === 'needupdate') {
296
- switch (entityType) {
297
- case 'template_entity': {
298
- // if the cache is invalid, update the cache
299
- return this.getEntities(null, null, null, null, (data, err) => {
300
- if (err) {
301
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
302
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
303
- return callback(null, errorObj);
304
- }
305
-
306
- // need to check the cache again since it has been updated
307
- return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (vcapable, verror) => {
308
- if (verror) {
309
- return callback(null, verror);
310
- }
311
-
312
- return this.capabilityResults(vcapable, callback);
313
- });
314
- });
315
- }
316
- default: {
317
- // unsupported entity type
318
- const result = [false];
319
-
320
- // put false in array for all entities
321
- if (Array.isArray(entityId)) {
322
- for (let e = 1; e < entityId.length; e += 1) {
323
- result.push(false);
324
- }
325
- }
326
-
327
- return callback(result);
328
- }
329
- }
330
- }
331
-
332
- // return the results
333
- return this.capabilityResults(results, callback);
334
- });
398
+ try {
399
+ return super.hasEntities(entityType, entityList, callback);
400
+ } catch (err) {
401
+ log.error(`${origin}: ${err}`);
402
+ return callback(null, err);
335
403
  }
404
+ }
336
405
 
337
- // if no entity id
338
- if (!entityId) {
339
- // need to check the cache again since it has been updated
340
- return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
341
- if (verror) {
342
- return callback(null, verror);
343
- }
406
+ /**
407
+ * @summary Get Appliance that match the deviceName
408
+ *
409
+ * @function getDevice
410
+ * @param {String} deviceName - the deviceName to find (required)
411
+ *
412
+ * @param {getCallback} callback - a callback function to return the result
413
+ * (appliance) or the error
414
+ */
415
+ getDevice(deviceName, callback) {
416
+ const meth = 'adapter-getDevice';
417
+ const origin = `${this.id}-${meth}`;
418
+ log.trace(origin);
344
419
 
345
- return this.capabilityResults(vcapable, callback);
346
- });
420
+ try {
421
+ return super.getDevice(deviceName, callback);
422
+ } catch (err) {
423
+ log.error(`${origin}: ${err}`);
424
+ return callback(null, err);
347
425
  }
426
+ }
348
427
 
349
- // if not caching
350
- switch (entityType) {
351
- case 'template_entity': {
352
- // need to get the entities to check
353
- return this.getEntities(null, null, null, null, (data, err) => {
354
- if (err) {
355
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
356
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
357
- return callback(null, errorObj);
358
- }
359
-
360
- // need to check the cache again since it has been updated
361
- return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
362
- if (verror) {
363
- return callback(null, verror);
364
- }
365
-
366
- // is the entity in the list?
367
- const isEntity = this.entityInList(entityId, data.response, callback);
368
- const res = [];
369
-
370
- // not found
371
- for (let i = 0; i < isEntity.length; i += 1) {
372
- if (vcapable) {
373
- res.push(isEntity[i]);
374
- } else {
375
- res.push(false);
376
- }
377
- }
378
-
379
- return callback(res);
380
- });
381
- });
382
- }
383
- default: {
384
- // unsupported entity type
385
- const result = [false];
428
+ /**
429
+ * @summary Get Appliances that match the filter
430
+ *
431
+ * @function getDevicesFiltered
432
+ * @param {Object} options - the data to use to filter the appliances (optional)
433
+ *
434
+ * @param {getCallback} callback - a callback function to return the result
435
+ * (appliances) or the error
436
+ */
437
+ getDevicesFiltered(options, callback) {
438
+ const meth = 'adapter-getDevicesFiltered';
439
+ const origin = `${this.id}-${meth}`;
440
+ log.trace(origin);
386
441
 
387
- // put false in array for all entities
388
- if (Array.isArray(entityId)) {
389
- for (let e = 1; e < entityId.length; e += 1) {
390
- result.push(false);
391
- }
392
- }
442
+ try {
443
+ return super.getDevicesFiltered(options, callback);
444
+ } catch (err) {
445
+ log.error(`${origin}: ${err}`);
446
+ return callback(null, err);
447
+ }
448
+ }
393
449
 
394
- return callback(result);
395
- }
450
+ /**
451
+ * @summary Gets the status for the provided appliance
452
+ *
453
+ * @function isAlive
454
+ * @param {String} deviceName - the deviceName of the appliance. (required)
455
+ *
456
+ * @param {configCallback} callback - callback function to return the result
457
+ * (appliance isAlive) or the error
458
+ */
459
+ isAlive(deviceName, callback) {
460
+ const meth = 'adapter-isAlive';
461
+ const origin = `${this.id}-${meth}`;
462
+ log.trace(origin);
463
+
464
+ try {
465
+ return super.isAlive(deviceName, callback);
466
+ } catch (err) {
467
+ log.error(`${origin}: ${err}`);
468
+ return callback(null, err);
396
469
  }
397
470
  }
398
471
 
399
472
  /**
400
- * @summary Updates the cache for all entities by call the get All entity method
473
+ * @summary Gets a config for the provided Appliance
401
474
  *
402
- * @function updateEntityCache
475
+ * @function getConfig
476
+ * @param {String} deviceName - the deviceName of the appliance. (required)
477
+ * @param {String} format - the desired format of the config. (optional)
403
478
  *
479
+ * @param {configCallback} callback - callback function to return the result
480
+ * (appliance config) or the error
404
481
  */
405
- updateEntityCache() {
406
- const origin = `${this.id}-adapter-updateEntityCache`;
482
+ getConfig(deviceName, format, callback) {
483
+ const meth = 'adapter-getConfig';
484
+ const origin = `${this.id}-${meth}`;
407
485
  log.trace(origin);
408
486
 
409
- if (this.caching) {
410
- // if the cache is invalid, update the cache
411
- this.getEntities(null, null, null, null, (data, err) => {
412
- if (err) {
413
- log.trace(`${origin}: Could not load template_entity into cache - ${err}`);
414
- }
415
- });
487
+ try {
488
+ return super.getConfig(deviceName, format, callback);
489
+ } catch (err) {
490
+ log.error(`${origin}: ${err}`);
491
+ return callback(null, err);
492
+ }
493
+ }
494
+
495
+ /**
496
+ * @summary Gets the device count from the system
497
+ *
498
+ * @function iapGetDeviceCount
499
+ *
500
+ * @param {getCallback} callback - callback function to return the result
501
+ * (count) or the error
502
+ */
503
+ iapGetDeviceCount(callback) {
504
+ const meth = 'adapter-iapGetDeviceCount';
505
+ const origin = `${this.id}-${meth}`;
506
+ log.trace(origin);
507
+
508
+ try {
509
+ return super.iapGetDeviceCount(callback);
510
+ } catch (err) {
511
+ log.error(`${origin}: ${err}`);
512
+ return callback(null, err);
513
+ }
514
+ }
515
+
516
+ /* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
517
+ /**
518
+ * Makes the requested generic call
519
+ *
520
+ * @function iapExpandedGenericAdapterRequest
521
+ * @param {Object} metadata - metadata for the call (optional).
522
+ * Can be a stringified Object.
523
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
524
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
525
+ * @param {Object} pathVars - the parameters to be put within the url path (optional).
526
+ * Can be a stringified Object.
527
+ * @param {Object} queryData - the parameters to be put on the url (optional).
528
+ * Can be a stringified Object.
529
+ * @param {Object} requestBody - the body to add to the request (optional).
530
+ * Can be a stringified Object.
531
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
532
+ * Can be a stringified Object.
533
+ * @param {getCallback} callback - a callback function to return the result (Generics)
534
+ * or the error
535
+ */
536
+ iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
537
+ const meth = 'adapter-iapExpandedGenericAdapterRequest';
538
+ const origin = `${this.id}-${meth}`;
539
+ log.trace(origin);
540
+
541
+ try {
542
+ return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
543
+ } catch (err) {
544
+ log.error(`${origin}: ${err}`);
545
+ return callback(null, err);
416
546
  }
417
547
  }
418
548
 
@@ -436,94 +566,84 @@ class EfficientipSolidserver extends AdapterBaseCl {
436
566
  const origin = `${this.id}-${meth}`;
437
567
  log.trace(origin);
438
568
 
439
- if (this.suspended && this.suspendMode === 'error') {
440
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
441
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
442
- return callback(null, errorObj);
569
+ try {
570
+ return super.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
571
+ } catch (err) {
572
+ log.error(`${origin}: ${err}`);
573
+ return callback(null, err);
443
574
  }
575
+ }
444
576
 
445
- /* HERE IS WHERE YOU VALIDATE DATA */
446
- if (uriPath === undefined || uriPath === null || uriPath === '') {
447
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
448
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
449
- return callback(null, errorObj);
450
- }
451
- if (restMethod === undefined || restMethod === null || restMethod === '') {
452
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
453
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
454
- return callback(null, errorObj);
455
- }
577
+ /**
578
+ * Makes the requested generic call with no base path or version
579
+ *
580
+ * @function genericAdapterRequestNoBasePath
581
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
582
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
583
+ * @param {Object} queryData - the parameters to be put on the url (optional).
584
+ * Can be a stringified Object.
585
+ * @param {Object} requestBody - the body to add to the request (optional).
586
+ * Can be a stringified Object.
587
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
588
+ * Can be a stringified Object.
589
+ * @param {getCallback} callback - a callback function to return the result (Generics)
590
+ * or the error
591
+ */
592
+ genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
593
+ const meth = 'adapter-genericAdapterRequestNoBasePath';
594
+ const origin = `${this.id}-${meth}`;
595
+ log.trace(origin);
456
596
 
457
- /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
458
- // remove any leading / and split the uripath into path variables
459
- let myPath = uriPath;
460
- while (myPath.indexOf('/') === 0) {
461
- myPath = myPath.substring(1);
597
+ try {
598
+ return super.genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
599
+ } catch (err) {
600
+ log.error(`${origin}: ${err}`);
601
+ return callback(null, err);
462
602
  }
463
- const pathVars = myPath.split('/');
464
- const queryParamsAvailable = queryData;
465
- const queryParams = {};
466
- const bodyVars = requestBody;
603
+ }
467
604
 
468
- // loop in template. long callback arg name to avoid identifier conflicts
469
- Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
470
- if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
471
- && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
472
- queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
473
- }
474
- });
605
+ /* INVENTORY CALLS */
606
+ /**
607
+ * @summary run the adapter lint script to return the results.
608
+ *
609
+ * @function iapRunAdapterLint
610
+ * @param {Callback} callback - callback function
611
+ */
612
+ iapRunAdapterLint(callback) {
613
+ const meth = 'adapter-iapRunAdapterLint';
614
+ const origin = `${this.id}-${meth}`;
615
+ log.trace(origin);
475
616
 
476
- // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
477
- const reqObj = {
478
- payload: bodyVars,
479
- uriPathVars: pathVars,
480
- uriQuery: queryParams,
481
- uriOptions: {}
482
- };
483
- // add headers if provided
484
- if (addlHeaders) {
485
- reqObj.addlHeaders = addlHeaders;
486
- }
617
+ return super.iapRunAdapterLint(callback);
618
+ }
487
619
 
488
- // determine the call and return flag
489
- let action = 'getGenerics';
490
- let returnF = true;
491
- if (restMethod.toUpperCase() === 'POST') {
492
- action = 'createGeneric';
493
- } else if (restMethod.toUpperCase() === 'PUT') {
494
- action = 'updateGeneric';
495
- } else if (restMethod.toUpperCase() === 'PATCH') {
496
- action = 'patchGeneric';
497
- } else if (restMethod.toUpperCase() === 'DELETE') {
498
- action = 'deleteGeneric';
499
- returnF = false;
500
- }
620
+ /**
621
+ * @summary run the adapter test scripts (baseunit and unit) to return the results.
622
+ * can not run integration as there can be implications with that.
623
+ *
624
+ * @function iapRunAdapterTests
625
+ * @param {Callback} callback - callback function
626
+ */
627
+ iapRunAdapterTests(callback) {
628
+ const meth = 'adapter-iapRunAdapterTests';
629
+ const origin = `${this.id}-${meth}`;
630
+ log.trace(origin);
501
631
 
502
- try {
503
- // Make the call -
504
- // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
505
- return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
506
- // if we received an error or their is no response on the results
507
- // return an error
508
- if (irReturnError) {
509
- /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
510
- return callback(null, irReturnError);
511
- }
512
- if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
513
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
514
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
515
- return callback(null, errorObj);
516
- }
632
+ return super.iapRunAdapterTests(callback);
633
+ }
517
634
 
518
- /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
519
- // return the response
520
- return callback(irReturnData, null);
521
- });
522
- } catch (ex) {
523
- const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
524
- log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
525
- return callback(null, errorObj);
526
- }
635
+ /**
636
+ * @summary provide inventory information abbout the adapter
637
+ *
638
+ * @function iapGetAdapterInventory
639
+ * @param {Callback} callback - callback function
640
+ */
641
+ iapGetAdapterInventory(callback) {
642
+ const meth = 'adapter-iapGetAdapterInventory';
643
+ const origin = `${this.id}-${meth}`;
644
+ log.trace(origin);
645
+
646
+ return super.iapGetAdapterInventory(callback);
527
647
  }
528
648
 
529
649
  /**