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