@itentialopensource/adapter-azure_aks 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/AUTH.md +39 -0
  2. package/BROKER.md +199 -0
  3. package/CALLS.md +169 -0
  4. package/CHANGELOG.md +9 -2
  5. package/CODE_OF_CONDUCT.md +12 -17
  6. package/CONTRIBUTING.md +88 -74
  7. package/ENHANCE.md +69 -0
  8. package/PROPERTIES.md +641 -0
  9. package/README.md +221 -571
  10. package/SUMMARY.md +9 -0
  11. package/SYSTEMINFO.md +11 -0
  12. package/TROUBLESHOOT.md +47 -0
  13. package/adapter.js +349 -57
  14. package/adapterBase.js +1021 -245
  15. package/entities/.generic/action.json +110 -5
  16. package/entities/.generic/schema.json +6 -1
  17. package/error.json +6 -0
  18. package/package.json +13 -7
  19. package/pronghorn.json +642 -378
  20. package/propertiesDecorators.json +14 -0
  21. package/propertiesSchema.json +422 -1
  22. package/refs?service=git-upload-pack +0 -0
  23. package/report/adapterInfo.json +10 -0
  24. package/report/updateReport1653089062336.json +120 -0
  25. package/sampleProperties.json +92 -3
  26. package/test/integration/adapterTestBasicGet.js +1 -1
  27. package/test/integration/adapterTestIntegration.js +26 -109
  28. package/test/unit/adapterBaseTestUnit.js +30 -25
  29. package/test/unit/adapterTestUnit.js +174 -163
  30. package/utils/adapterInfo.js +206 -0
  31. package/utils/addAuth.js +94 -0
  32. package/utils/artifactize.js +0 -0
  33. package/utils/basicGet.js +1 -14
  34. package/utils/entitiesToDB.js +179 -0
  35. package/utils/modify.js +1 -1
  36. package/utils/patches2bundledDeps.js +90 -0
  37. package/utils/pre-commit.sh +3 -0
  38. package/utils/removeHooks.js +20 -0
  39. package/utils/tbScript.js +43 -22
  40. package/utils/tbUtils.js +99 -19
  41. package/utils/testRunner.js +16 -16
  42. package/utils/troubleshootingAdapter.js +2 -26
package/SUMMARY.md ADDED
@@ -0,0 +1,9 @@
1
+ ## Overview
2
+
3
+ This adapter is used to integrate the Itential Automation Platform (IAP) with the Azure_aks System. The API that was used to build the adapter for Azure_aks is usually available in the report directory of this adapter. The adapter utilizes the Azure_aks API to provide the integrations that are deemed pertinent to IAP. The ReadMe file is intended to provide information on this adapter it is generated from various other Markdown files.
4
+
5
+ >**Note**: It is possible that some integrations will be supported through the Azure_aks adapter while other integrations will not. If you need additional API calls, you can use the Update capabilities provided by the Adapter Builder or request Itential to add them if the Adapter is an Itential opensourced adapter.
6
+
7
+ Itential provides information on all of its product adapters in the Customer Knowledge Base. Information in the <a href="https://itential.atlassian.net/servicedesk/customer/portals" target="_blank">Customer Knowledge Base</a> is consistently maintained and goes through documentation reviews. As a result, it should be the first place to go for information.
8
+
9
+ For opensourced and custom built adapters, the ReadMe is a starting point to understand what you have built, provide the information for you to be able to update the adapter, and assist you with deploying the adapter into IAP.
package/SYSTEMINFO.md ADDED
@@ -0,0 +1,11 @@
1
+ # Microsoft Azure Kubernetes Service
2
+
3
+ Vendor: Microsoft Azure Kubernetes Service
4
+ Homepage: https://Microsoft Azure Kubernetes Service.com/
5
+
6
+ Product: Microsoft Azure Kubernetes Service
7
+ Product Page: https://Microsoft Azure Kubernetes Service.com/
8
+
9
+ ## Introduction
10
+
11
+ ## Additional Product Documentation
@@ -0,0 +1,47 @@
1
+ ## Troubleshoot
2
+
3
+ Run `npm run troubleshoot` to start the interactive troubleshooting process. The command allows you to verify and update connection, authentication as well as healthcheck configuration. After that it will test these properties by sending HTTP request to the endpoint. If the tests pass, it will persist these changes into IAP.
4
+
5
+ You also have the option to run individual commands to perform specific test:
6
+
7
+ - `npm run healthcheck` will perform a healthcheck request of with current setting.
8
+ - `npm run basicget` will perform some non-parameter GET request with current setting.
9
+ - `npm run connectivity` will perform networking diagnostics of the adatper endpoint.
10
+
11
+ ### Connectivity Issues
12
+
13
+ 1. You can run the adapter troubleshooting script which will check connectivity, run the healthcheck and run basic get calls.
14
+
15
+ ```bash
16
+ npm run troubleshoot
17
+ ```
18
+
19
+ 2. Verify the adapter properties are set up correctly.
20
+
21
+ ```text
22
+ Go into the Itential Platform GUI and verify/update the properties
23
+ ```
24
+
25
+ 3. Verify there is connectivity between the Itential Platform Server and Azure_aks Server.
26
+
27
+ ```text
28
+ ping the ip address of Azure_aks server
29
+ try telnet to the ip address port of Azure_aks
30
+ execute a curl command to the other system
31
+ ```
32
+
33
+ 4. Verify the credentials provided for Azure_aks.
34
+
35
+ ```text
36
+ login to Azure_aks using the provided credentials
37
+ ```
38
+
39
+ 5. Verify the API of the call utilized for Azure_aks Healthcheck.
40
+
41
+ ```text
42
+ Go into the Itential Platform GUI and verify/update the properties
43
+ ```
44
+
45
+ ### Functional Issues
46
+
47
+ Adapter logs are located in `/var/log/pronghorn`. In older releases of the Itential Platform, there is a `pronghorn.log` file which contains logs for all of the Itential Platform. In newer versions, adapters can be configured to log into their own files.
package/adapter.js CHANGED
@@ -82,6 +82,7 @@ class AzureAks extends AdapterBaseCl {
82
82
  * @param {Callback} callback - The results of the call
83
83
  */
84
84
  healthCheck(reqObj, callback) {
85
+ // you can modify what is passed into the healthcheck by changing things in the newReq
85
86
  let newReq = reqObj;
86
87
  if (newReq) {
87
88
  newReq.authData = this.authObject;
@@ -96,10 +97,18 @@ class AzureAks extends AdapterBaseCl {
96
97
  }
97
98
 
98
99
  /**
99
- * @getWorkflowFunctions
100
+ * @iapGetAdapterWorkflowFunctions
100
101
  */
101
- getWorkflowFunctions(inIgnore) {
102
- let myIgnore = ['hasEntities', 'hasDevices'];
102
+ iapGetAdapterWorkflowFunctions(inIgnore) {
103
+ let myIgnore = [
104
+ 'healthCheck',
105
+ 'iapGetAdapterWorkflowFunctions',
106
+ 'iapHasAdapterEntity',
107
+ 'iapVerifyAdapterCapability',
108
+ 'iapUpdateAdapterEntityCache',
109
+ 'hasEntities',
110
+ 'getAuthorization'
111
+ ];
103
112
  if (!inIgnore && Array.isArray(inIgnore)) {
104
113
  myIgnore = inIgnore;
105
114
  } else if (!inIgnore && typeof inIgnore === 'string') {
@@ -110,15 +119,15 @@ class AzureAks extends AdapterBaseCl {
110
119
  // you can add specific methods that you do not want to be workflow functions to ignore like below
111
120
  // myIgnore.push('myMethodNotInWorkflow');
112
121
 
113
- return super.getWorkflowFunctions(myIgnore);
122
+ return super.iapGetAdapterWorkflowFunctions(myIgnore);
114
123
  }
115
124
 
116
125
  /**
117
- * updateAdapterConfiguration is used to update any of the adapter configuration files. This
126
+ * iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
118
127
  * allows customers to make changes to adapter configuration without having to be on the
119
128
  * file system.
120
129
  *
121
- * @function updateAdapterConfiguration
130
+ * @function iapUpdateAdapterConfiguration
122
131
  * @param {string} configFile - the name of the file being updated (required)
123
132
  * @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
124
133
  * @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
@@ -126,36 +135,42 @@ class AzureAks extends AdapterBaseCl {
126
135
  * @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
127
136
  * @param {Callback} callback - The results of the call
128
137
  */
129
- updateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
130
- const origin = `${this.id}-adapter-updateAdapterConfiguration`;
138
+ iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
139
+ const meth = 'adapter-iapUpdateAdapterConfiguration';
140
+ const origin = `${this.id}-${meth}`;
131
141
  log.trace(origin);
132
- super.updateAdapterConfiguration(configFile, changes, entity, type, action, callback);
142
+
143
+ super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
133
144
  }
134
145
 
135
146
  /**
136
147
  * See if the API path provided is found in this adapter
137
148
  *
138
- * @function findPath
149
+ * @function iapFindAdapterPath
139
150
  * @param {string} apiPath - the api path to check on
140
151
  * @param {Callback} callback - The results of the call
141
152
  */
142
- findPath(apiPath, callback) {
143
- const origin = `${this.id}-adapter-findPath`;
153
+ iapFindAdapterPath(apiPath, callback) {
154
+ const meth = 'adapter-iapFindAdapterPath';
155
+ const origin = `${this.id}-${meth}`;
144
156
  log.trace(origin);
145
- super.findPath(apiPath, callback);
157
+
158
+ super.iapFindAdapterPath(apiPath, callback);
146
159
  }
147
160
 
148
161
  /**
149
162
  * @summary Suspends adapter
150
163
  *
151
- * @function suspend
164
+ * @function iapSuspendAdapter
152
165
  * @param {Callback} callback - callback function
153
166
  */
154
- suspend(mode, callback) {
155
- const origin = `${this.id}-adapter-suspend`;
167
+ iapSuspendAdapter(mode, callback) {
168
+ const meth = 'adapter-iapSuspendAdapter';
169
+ const origin = `${this.id}-${meth}`;
156
170
  log.trace(origin);
171
+
157
172
  try {
158
- return super.suspend(mode, callback);
173
+ return super.iapSuspendAdapter(mode, callback);
159
174
  } catch (error) {
160
175
  log.error(`${origin}: ${error}`);
161
176
  return callback(null, error);
@@ -165,14 +180,16 @@ class AzureAks extends AdapterBaseCl {
165
180
  /**
166
181
  * @summary Unsuspends adapter
167
182
  *
168
- * @function unsuspend
183
+ * @function iapUnsuspendAdapter
169
184
  * @param {Callback} callback - callback function
170
185
  */
171
- unsuspend(callback) {
172
- const origin = `${this.id}-adapter-unsuspend`;
186
+ iapUnsuspendAdapter(callback) {
187
+ const meth = 'adapter-iapUnsuspendAdapter';
188
+ const origin = `${this.id}-${meth}`;
173
189
  log.trace(origin);
190
+
174
191
  try {
175
- return super.unsuspend(callback);
192
+ return super.iapUnsuspendAdapter(callback);
176
193
  } catch (error) {
177
194
  log.error(`${origin}: ${error}`);
178
195
  return callback(null, error);
@@ -182,29 +199,33 @@ class AzureAks extends AdapterBaseCl {
182
199
  /**
183
200
  * @summary Get the Adaoter Queue
184
201
  *
185
- * @function getQueue
202
+ * @function iapGetAdapterQueue
186
203
  * @param {Callback} callback - callback function
187
204
  */
188
- getQueue(callback) {
189
- const origin = `${this.id}-adapter-getQueue`;
205
+ iapGetAdapterQueue(callback) {
206
+ const meth = 'adapter-iapGetAdapterQueue';
207
+ const origin = `${this.id}-${meth}`;
190
208
  log.trace(origin);
191
- return super.getQueue(callback);
209
+
210
+ return super.iapGetAdapterQueue(callback);
192
211
  }
193
212
 
194
213
  /**
195
214
  * @summary Runs troubleshoot scripts for adapter
196
215
  *
197
- * @function troubleshoot
216
+ * @function iapTroubleshootAdapter
198
217
  * @param {Object} props - the connection, healthcheck and authentication properties
199
218
  *
200
219
  * @param {boolean} persistFlag - whether the adapter properties should be updated
201
220
  * @param {Callback} callback - The results of the call
202
221
  */
203
- troubleshoot(props, persistFlag, callback) {
204
- const origin = `${this.id}-adapter-troubleshoot`;
222
+ iapTroubleshootAdapter(props, persistFlag, callback) {
223
+ const meth = 'adapter-iapTroubleshootAdapter';
224
+ const origin = `${this.id}-${meth}`;
205
225
  log.trace(origin);
226
+
206
227
  try {
207
- return super.troubleshoot(props, persistFlag, this, callback);
228
+ return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
208
229
  } catch (error) {
209
230
  log.error(`${origin}: ${error}`);
210
231
  return callback(null, error);
@@ -214,15 +235,17 @@ class AzureAks extends AdapterBaseCl {
214
235
  /**
215
236
  * @summary runs healthcheck script for adapter
216
237
  *
217
- * @function runHealthcheck
238
+ * @function iapRunAdapterHealthcheck
218
239
  * @param {Adapter} adapter - adapter instance to troubleshoot
219
240
  * @param {Callback} callback - callback function
220
241
  */
221
- runHealthcheck(callback) {
222
- const origin = `${this.id}-adapter-runHealthcheck`;
242
+ iapRunAdapterHealthcheck(callback) {
243
+ const meth = 'adapter-iapRunAdapterHealthcheck';
244
+ const origin = `${this.id}-${meth}`;
223
245
  log.trace(origin);
246
+
224
247
  try {
225
- return super.runHealthcheck(this, callback);
248
+ return super.iapRunAdapterHealthcheck(this, callback);
226
249
  } catch (error) {
227
250
  log.error(`${origin}: ${error}`);
228
251
  return callback(null, error);
@@ -232,14 +255,16 @@ class AzureAks extends AdapterBaseCl {
232
255
  /**
233
256
  * @summary runs connectivity check script for adapter
234
257
  *
235
- * @function runConnectivity
258
+ * @function iapRunAdapterConnectivity
236
259
  * @param {Callback} callback - callback function
237
260
  */
238
- runConnectivity(callback) {
239
- const origin = `${this.id}-adapter-runConnectivity`;
261
+ iapRunAdapterConnectivity(callback) {
262
+ const meth = 'adapter-iapRunAdapterConnectivity';
263
+ const origin = `${this.id}-${meth}`;
240
264
  log.trace(origin);
265
+
241
266
  try {
242
- return super.runConnectivity(callback);
267
+ return super.iapRunAdapterConnectivity(callback);
243
268
  } catch (error) {
244
269
  log.error(`${origin}: ${error}`);
245
270
  return callback(null, error);
@@ -249,44 +274,67 @@ class AzureAks extends AdapterBaseCl {
249
274
  /**
250
275
  * @summary runs basicGet script for adapter
251
276
  *
252
- * @function runBasicGet
277
+ * @function iapRunAdapterBasicGet
253
278
  * @param {Callback} callback - callback function
254
279
  */
255
- runBasicGet(callback) {
256
- const origin = `${this.id}-adapter-runBasicGet`;
280
+ iapRunAdapterBasicGet(callback) {
281
+ const meth = 'adapter-iapRunAdapterBasicGet';
282
+ const origin = `${this.id}-${meth}`;
257
283
  log.trace(origin);
284
+
258
285
  try {
259
- return super.runBasicGet(callback);
286
+ return super.iapRunAdapterBasicGet(callback);
260
287
  } catch (error) {
261
288
  log.error(`${origin}: ${error}`);
262
289
  return callback(null, error);
263
290
  }
264
291
  }
265
292
 
293
+ /**
294
+ * @summary moves entites into Mongo DB
295
+ *
296
+ * @function iapMoveAdapterEntitiesToDB
297
+ * @param {getCallback} callback - a callback function to return the result (Generics)
298
+ * or the error
299
+ */
300
+ iapMoveAdapterEntitiesToDB(callback) {
301
+ const meth = 'adapter-iapMoveAdapterEntitiesToDB';
302
+ const origin = `${this.id}-${meth}`;
303
+ log.trace(origin);
304
+
305
+ try {
306
+ return super.iapMoveAdapterEntitiesToDB(callback);
307
+ } catch (err) {
308
+ log.error(`${origin}: ${err}`);
309
+ return callback(null, err);
310
+ }
311
+ }
312
+
313
+ /* BROKER CALLS */
266
314
  /**
267
315
  * @summary Determines if this adapter supports the specific entity
268
316
  *
269
- * @function hasEntity
317
+ * @function iapHasAdapterEntity
270
318
  * @param {String} entityType - the entity type to check for
271
319
  * @param {String/Array} entityId - the specific entity we are looking for
272
320
  *
273
321
  * @param {Callback} callback - An array of whether the adapter can has the
274
322
  * desired capability or an error
275
323
  */
276
- hasEntity(entityType, entityId, callback) {
277
- const origin = `${this.id}-adapter-hasEntity`;
324
+ iapHasAdapterEntity(entityType, entityId, callback) {
325
+ const origin = `${this.id}-adapter-iapHasAdapterEntity`;
278
326
  log.trace(origin);
279
327
 
280
328
  // Make the call -
281
- // verifyCapability(entityType, actionType, entityId, callback)
282
- return this.verifyCapability(entityType, null, entityId, callback);
329
+ // iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
330
+ return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
283
331
  }
284
332
 
285
333
  /**
286
334
  * @summary Provides a way for the adapter to tell north bound integrations
287
335
  * whether the adapter supports type, action and specific entity
288
336
  *
289
- * @function verifyCapability
337
+ * @function iapVerifyAdapterCapability
290
338
  * @param {String} entityType - the entity type to check for
291
339
  * @param {String} actionType - the action type to check for
292
340
  * @param {String/Array} entityId - the specific entity we are looking for
@@ -294,15 +342,15 @@ class AzureAks extends AdapterBaseCl {
294
342
  * @param {Callback} callback - An array of whether the adapter can has the
295
343
  * desired capability or an error
296
344
  */
297
- verifyCapability(entityType, actionType, entityId, callback) {
298
- const meth = 'adapterBase-verifyCapability';
345
+ iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
346
+ const meth = 'adapterBase-iapVerifyAdapterCapability';
299
347
  const origin = `${this.id}-${meth}`;
300
348
  log.trace(origin);
301
349
 
302
350
  // if caching
303
351
  if (this.caching) {
304
- // Make the call - verifyCapability(entityType, actionType, entityId, callback)
305
- return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (results, error) => {
352
+ // Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
353
+ return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
306
354
  if (error) {
307
355
  return callback(null, error);
308
356
  }
@@ -320,7 +368,7 @@ class AzureAks extends AdapterBaseCl {
320
368
  }
321
369
 
322
370
  // need to check the cache again since it has been updated
323
- return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (vcapable, verror) => {
371
+ return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
324
372
  if (verror) {
325
373
  return callback(null, verror);
326
374
  }
@@ -353,7 +401,7 @@ class AzureAks extends AdapterBaseCl {
353
401
  // if no entity id
354
402
  if (!entityId) {
355
403
  // need to check the cache again since it has been updated
356
- return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
404
+ return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
357
405
  if (verror) {
358
406
  return callback(null, verror);
359
407
  }
@@ -374,7 +422,7 @@ class AzureAks extends AdapterBaseCl {
374
422
  }
375
423
 
376
424
  // need to check the cache again since it has been updated
377
- return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
425
+ return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
378
426
  if (verror) {
379
427
  return callback(null, verror);
380
428
  }
@@ -415,11 +463,11 @@ class AzureAks extends AdapterBaseCl {
415
463
  /**
416
464
  * @summary Updates the cache for all entities by call the get All entity method
417
465
  *
418
- * @function updateEntityCache
466
+ * @function iapUpdateAdapterEntityCache
419
467
  *
420
468
  */
421
- updateEntityCache() {
422
- const origin = `${this.id}-adapter-updateEntityCache`;
469
+ iapUpdateAdapterEntityCache() {
470
+ const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
423
471
  log.trace(origin);
424
472
 
425
473
  if (this.caching) {
@@ -432,6 +480,140 @@ class AzureAks extends AdapterBaseCl {
432
480
  }
433
481
  }
434
482
 
483
+ /**
484
+ * @summary Determines if this adapter supports any in a list of entities
485
+ *
486
+ * @function hasEntities
487
+ * @param {String} entityType - the entity type to check for
488
+ * @param {Array} entityList - the list of entities we are looking for
489
+ *
490
+ * @param {Callback} callback - A map where the entity is the key and the
491
+ * value is true or false
492
+ */
493
+ hasEntities(entityType, entityList, callback) {
494
+ const meth = 'adapter-hasEntities';
495
+ const origin = `${this.id}-${meth}`;
496
+ log.trace(origin);
497
+
498
+ try {
499
+ return super.hasEntities(entityType, entityList, callback);
500
+ } catch (err) {
501
+ log.error(`${origin}: ${err}`);
502
+ return callback(null, err);
503
+ }
504
+ }
505
+
506
+ /**
507
+ * @summary Get Appliance that match the deviceName
508
+ *
509
+ * @function getDevice
510
+ * @param {String} deviceName - the deviceName to find (required)
511
+ *
512
+ * @param {getCallback} callback - a callback function to return the result
513
+ * (appliance) or the error
514
+ */
515
+ getDevice(deviceName, callback) {
516
+ const meth = 'adapter-getDevice';
517
+ const origin = `${this.id}-${meth}`;
518
+ log.trace(origin);
519
+
520
+ try {
521
+ return super.getDevice(deviceName, callback);
522
+ } catch (err) {
523
+ log.error(`${origin}: ${err}`);
524
+ return callback(null, err);
525
+ }
526
+ }
527
+
528
+ /**
529
+ * @summary Get Appliances that match the filter
530
+ *
531
+ * @function getDevicesFiltered
532
+ * @param {Object} options - the data to use to filter the appliances (optional)
533
+ *
534
+ * @param {getCallback} callback - a callback function to return the result
535
+ * (appliances) or the error
536
+ */
537
+ getDevicesFiltered(options, callback) {
538
+ const meth = 'adapter-getDevicesFiltered';
539
+ const origin = `${this.id}-${meth}`;
540
+ log.trace(origin);
541
+
542
+ try {
543
+ return super.getDevicesFiltered(options, callback);
544
+ } catch (err) {
545
+ log.error(`${origin}: ${err}`);
546
+ return callback(null, err);
547
+ }
548
+ }
549
+
550
+ /**
551
+ * @summary Gets the status for the provided appliance
552
+ *
553
+ * @function isAlive
554
+ * @param {String} deviceName - the deviceName of the appliance. (required)
555
+ *
556
+ * @param {configCallback} callback - callback function to return the result
557
+ * (appliance isAlive) or the error
558
+ */
559
+ isAlive(deviceName, callback) {
560
+ const meth = 'adapter-isAlive';
561
+ const origin = `${this.id}-${meth}`;
562
+ log.trace(origin);
563
+
564
+ try {
565
+ return super.isAlive(deviceName, callback);
566
+ } catch (err) {
567
+ log.error(`${origin}: ${err}`);
568
+ return callback(null, err);
569
+ }
570
+ }
571
+
572
+ /**
573
+ * @summary Gets a config for the provided Appliance
574
+ *
575
+ * @function getConfig
576
+ * @param {String} deviceName - the deviceName of the appliance. (required)
577
+ * @param {String} format - the desired format of the config. (optional)
578
+ *
579
+ * @param {configCallback} callback - callback function to return the result
580
+ * (appliance config) or the error
581
+ */
582
+ getConfig(deviceName, format, callback) {
583
+ const meth = 'adapter-getConfig';
584
+ const origin = `${this.id}-${meth}`;
585
+ log.trace(origin);
586
+
587
+ try {
588
+ return super.getConfig(deviceName, format, callback);
589
+ } catch (err) {
590
+ log.error(`${origin}: ${err}`);
591
+ return callback(null, err);
592
+ }
593
+ }
594
+
595
+ /**
596
+ * @summary Gets the device count from the system
597
+ *
598
+ * @function iapGetDeviceCount
599
+ *
600
+ * @param {getCallback} callback - callback function to return the result
601
+ * (count) or the error
602
+ */
603
+ iapGetDeviceCount(callback) {
604
+ const meth = 'adapter-iapGetDeviceCount';
605
+ const origin = `${this.id}-${meth}`;
606
+ log.trace(origin);
607
+
608
+ try {
609
+ return super.iapGetDeviceCount(callback);
610
+ } catch (err) {
611
+ log.error(`${origin}: ${err}`);
612
+ return callback(null, err);
613
+ }
614
+ }
615
+
616
+ /* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
435
617
  /**
436
618
  * Makes the requested generic call
437
619
  *
@@ -542,6 +724,116 @@ class AzureAks extends AdapterBaseCl {
542
724
  }
543
725
  }
544
726
 
727
+ /**
728
+ * Makes the requested generic call with no base path or version
729
+ *
730
+ * @function genericAdapterRequestNoBasePath
731
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
732
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
733
+ * @param {Object} queryData - the parameters to be put on the url (optional).
734
+ * Can be a stringified Object.
735
+ * @param {Object} requestBody - the body to add to the request (optional).
736
+ * Can be a stringified Object.
737
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
738
+ * Can be a stringified Object.
739
+ * @param {getCallback} callback - a callback function to return the result (Generics)
740
+ * or the error
741
+ */
742
+ genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
743
+ const meth = 'adapter-genericAdapterRequestNoBasePath';
744
+ const origin = `${this.id}-${meth}`;
745
+ log.trace(origin);
746
+
747
+ if (this.suspended && this.suspendMode === 'error') {
748
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
749
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
750
+ return callback(null, errorObj);
751
+ }
752
+
753
+ /* HERE IS WHERE YOU VALIDATE DATA */
754
+ if (uriPath === undefined || uriPath === null || uriPath === '') {
755
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
756
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
757
+ return callback(null, errorObj);
758
+ }
759
+ if (restMethod === undefined || restMethod === null || restMethod === '') {
760
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
761
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
762
+ return callback(null, errorObj);
763
+ }
764
+
765
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
766
+ // remove any leading / and split the uripath into path variables
767
+ let myPath = uriPath;
768
+ while (myPath.indexOf('/') === 0) {
769
+ myPath = myPath.substring(1);
770
+ }
771
+ const pathVars = myPath.split('/');
772
+ const queryParamsAvailable = queryData;
773
+ const queryParams = {};
774
+ const bodyVars = requestBody;
775
+
776
+ // loop in template. long callback arg name to avoid identifier conflicts
777
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
778
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
779
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
780
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
781
+ }
782
+ });
783
+
784
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
785
+ const reqObj = {
786
+ payload: bodyVars,
787
+ uriPathVars: pathVars,
788
+ uriQuery: queryParams,
789
+ uriOptions: {}
790
+ };
791
+ // add headers if provided
792
+ if (addlHeaders) {
793
+ reqObj.addlHeaders = addlHeaders;
794
+ }
795
+
796
+ // determine the call and return flag
797
+ let action = 'getGenericsNoBase';
798
+ let returnF = true;
799
+ if (restMethod.toUpperCase() === 'POST') {
800
+ action = 'createGenericNoBase';
801
+ } else if (restMethod.toUpperCase() === 'PUT') {
802
+ action = 'updateGenericNoBase';
803
+ } else if (restMethod.toUpperCase() === 'PATCH') {
804
+ action = 'patchGenericNoBase';
805
+ } else if (restMethod.toUpperCase() === 'DELETE') {
806
+ action = 'deleteGenericNoBase';
807
+ returnF = false;
808
+ }
809
+
810
+ try {
811
+ // Make the call -
812
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
813
+ return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
814
+ // if we received an error or their is no response on the results
815
+ // return an error
816
+ if (irReturnError) {
817
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
818
+ return callback(null, irReturnError);
819
+ }
820
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
821
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
822
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
823
+ return callback(null, errorObj);
824
+ }
825
+
826
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
827
+ // return the response
828
+ return callback(irReturnData, null);
829
+ });
830
+ } catch (ex) {
831
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
832
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
833
+ return callback(null, errorObj);
834
+ }
835
+ }
836
+
545
837
  /**
546
838
  * @callback healthCallback
547
839
  * @param {Object} result - the result of the get request (contains an id and a status)