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