@itentialopensource/adapter-efficientip_solidserver 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 +348 -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/updateReport1653233995404.json +120 -0
  25. package/sampleProperties.json +90 -1
  26. package/test/integration/adapterTestBasicGet.js +1 -1
  27. package/test/integration/adapterTestIntegration.js +26 -105
  28. package/test/unit/adapterBaseTestUnit.js +30 -25
  29. package/test/unit/adapterTestUnit.js +174 -159
  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 Efficientip_solidserver System. The API that was used to build the adapter for Efficientip_solidserver is usually available in the report directory of this adapter. The adapter utilizes the Efficientip_solidserver 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 Efficientip_solidserver 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
+ # Efficient iP SOLIDserver
2
+
3
+ Vendor: Efficient iP SOLIDserver
4
+ Homepage: https://Efficient iP SOLIDserver.com/
5
+
6
+ Product: Efficient iP SOLIDserver
7
+ Product Page: https://Efficient iP SOLIDserver.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 Efficientip_solidserver Server.
26
+
27
+ ```text
28
+ ping the ip address of Efficientip_solidserver server
29
+ try telnet to the ip address port of Efficientip_solidserver
30
+ execute a curl command to the other system
31
+ ```
32
+
33
+ 4. Verify the credentials provided for Efficientip_solidserver.
34
+
35
+ ```text
36
+ login to Efficientip_solidserver using the provided credentials
37
+ ```
38
+
39
+ 5. Verify the API of the call utilized for Efficientip_solidserver 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
@@ -80,10 +80,18 @@ class EfficientipSolidserver extends AdapterBaseCl {
80
80
  }
81
81
 
82
82
  /**
83
- * @getWorkflowFunctions
83
+ * @iapGetAdapterWorkflowFunctions
84
84
  */
85
- getWorkflowFunctions(inIgnore) {
86
- let myIgnore = [];
85
+ iapGetAdapterWorkflowFunctions(inIgnore) {
86
+ let myIgnore = [
87
+ 'healthCheck',
88
+ 'iapGetAdapterWorkflowFunctions',
89
+ 'iapHasAdapterEntity',
90
+ 'iapVerifyAdapterCapability',
91
+ 'iapUpdateAdapterEntityCache',
92
+ 'hasEntities',
93
+ 'getAuthorization'
94
+ ];
87
95
  if (!inIgnore && Array.isArray(inIgnore)) {
88
96
  myIgnore = inIgnore;
89
97
  } else if (!inIgnore && typeof inIgnore === 'string') {
@@ -94,15 +102,15 @@ class EfficientipSolidserver extends AdapterBaseCl {
94
102
  // you can add specific methods that you do not want to be workflow functions to ignore like below
95
103
  // myIgnore.push('myMethodNotInWorkflow');
96
104
 
97
- return super.getWorkflowFunctions(myIgnore);
105
+ return super.iapGetAdapterWorkflowFunctions(myIgnore);
98
106
  }
99
107
 
100
108
  /**
101
- * 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
102
110
  * allows customers to make changes to adapter configuration without having to be on the
103
111
  * file system.
104
112
  *
105
- * @function updateAdapterConfiguration
113
+ * @function iapUpdateAdapterConfiguration
106
114
  * @param {string} configFile - the name of the file being updated (required)
107
115
  * @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
108
116
  * @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
@@ -110,36 +118,42 @@ class EfficientipSolidserver extends AdapterBaseCl {
110
118
  * @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
111
119
  * @param {Callback} callback - The results of the call
112
120
  */
113
- updateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
114
- const origin = `${this.id}-adapter-updateAdapterConfiguration`;
121
+ iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
122
+ const meth = 'adapter-iapUpdateAdapterConfiguration';
123
+ const origin = `${this.id}-${meth}`;
115
124
  log.trace(origin);
116
- super.updateAdapterConfiguration(configFile, changes, entity, type, action, callback);
125
+
126
+ super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
117
127
  }
118
128
 
119
129
  /**
120
130
  * See if the API path provided is found in this adapter
121
131
  *
122
- * @function findPath
132
+ * @function iapFindAdapterPath
123
133
  * @param {string} apiPath - the api path to check on
124
134
  * @param {Callback} callback - The results of the call
125
135
  */
126
- findPath(apiPath, callback) {
127
- const origin = `${this.id}-adapter-findPath`;
136
+ iapFindAdapterPath(apiPath, callback) {
137
+ const meth = 'adapter-iapFindAdapterPath';
138
+ const origin = `${this.id}-${meth}`;
128
139
  log.trace(origin);
129
- super.findPath(apiPath, callback);
140
+
141
+ super.iapFindAdapterPath(apiPath, callback);
130
142
  }
131
143
 
132
144
  /**
133
145
  * @summary Suspends adapter
134
146
  *
135
- * @function suspend
147
+ * @function iapSuspendAdapter
136
148
  * @param {Callback} callback - callback function
137
149
  */
138
- suspend(mode, callback) {
139
- const origin = `${this.id}-adapter-suspend`;
150
+ iapSuspendAdapter(mode, callback) {
151
+ const meth = 'adapter-iapSuspendAdapter';
152
+ const origin = `${this.id}-${meth}`;
140
153
  log.trace(origin);
154
+
141
155
  try {
142
- return super.suspend(mode, callback);
156
+ return super.iapSuspendAdapter(mode, callback);
143
157
  } catch (error) {
144
158
  log.error(`${origin}: ${error}`);
145
159
  return callback(null, error);
@@ -149,14 +163,16 @@ class EfficientipSolidserver extends AdapterBaseCl {
149
163
  /**
150
164
  * @summary Unsuspends adapter
151
165
  *
152
- * @function unsuspend
166
+ * @function iapUnsuspendAdapter
153
167
  * @param {Callback} callback - callback function
154
168
  */
155
- unsuspend(callback) {
156
- const origin = `${this.id}-adapter-unsuspend`;
169
+ iapUnsuspendAdapter(callback) {
170
+ const meth = 'adapter-iapUnsuspendAdapter';
171
+ const origin = `${this.id}-${meth}`;
157
172
  log.trace(origin);
173
+
158
174
  try {
159
- return super.unsuspend(callback);
175
+ return super.iapUnsuspendAdapter(callback);
160
176
  } catch (error) {
161
177
  log.error(`${origin}: ${error}`);
162
178
  return callback(null, error);
@@ -166,29 +182,33 @@ class EfficientipSolidserver extends AdapterBaseCl {
166
182
  /**
167
183
  * @summary Get the Adaoter Queue
168
184
  *
169
- * @function getQueue
185
+ * @function iapGetAdapterQueue
170
186
  * @param {Callback} callback - callback function
171
187
  */
172
- getQueue(callback) {
173
- const origin = `${this.id}-adapter-getQueue`;
188
+ iapGetAdapterQueue(callback) {
189
+ const meth = 'adapter-iapGetAdapterQueue';
190
+ const origin = `${this.id}-${meth}`;
174
191
  log.trace(origin);
175
- return super.getQueue(callback);
192
+
193
+ return super.iapGetAdapterQueue(callback);
176
194
  }
177
195
 
178
196
  /**
179
197
  * @summary Runs troubleshoot scripts for adapter
180
198
  *
181
- * @function troubleshoot
199
+ * @function iapTroubleshootAdapter
182
200
  * @param {Object} props - the connection, healthcheck and authentication properties
183
201
  *
184
202
  * @param {boolean} persistFlag - whether the adapter properties should be updated
185
203
  * @param {Callback} callback - The results of the call
186
204
  */
187
- troubleshoot(props, persistFlag, callback) {
188
- const origin = `${this.id}-adapter-troubleshoot`;
205
+ iapTroubleshootAdapter(props, persistFlag, callback) {
206
+ const meth = 'adapter-iapTroubleshootAdapter';
207
+ const origin = `${this.id}-${meth}`;
189
208
  log.trace(origin);
209
+
190
210
  try {
191
- return super.troubleshoot(props, persistFlag, this, callback);
211
+ return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
192
212
  } catch (error) {
193
213
  log.error(`${origin}: ${error}`);
194
214
  return callback(null, error);
@@ -198,15 +218,17 @@ class EfficientipSolidserver extends AdapterBaseCl {
198
218
  /**
199
219
  * @summary runs healthcheck script for adapter
200
220
  *
201
- * @function runHealthcheck
221
+ * @function iapRunAdapterHealthcheck
202
222
  * @param {Adapter} adapter - adapter instance to troubleshoot
203
223
  * @param {Callback} callback - callback function
204
224
  */
205
- runHealthcheck(callback) {
206
- const origin = `${this.id}-adapter-runHealthcheck`;
225
+ iapRunAdapterHealthcheck(callback) {
226
+ const meth = 'adapter-iapRunAdapterHealthcheck';
227
+ const origin = `${this.id}-${meth}`;
207
228
  log.trace(origin);
229
+
208
230
  try {
209
- return super.runHealthcheck(this, callback);
231
+ return super.iapRunAdapterHealthcheck(this, callback);
210
232
  } catch (error) {
211
233
  log.error(`${origin}: ${error}`);
212
234
  return callback(null, error);
@@ -216,14 +238,16 @@ class EfficientipSolidserver extends AdapterBaseCl {
216
238
  /**
217
239
  * @summary runs connectivity check script for adapter
218
240
  *
219
- * @function runConnectivity
241
+ * @function iapRunAdapterConnectivity
220
242
  * @param {Callback} callback - callback function
221
243
  */
222
- runConnectivity(callback) {
223
- const origin = `${this.id}-adapter-runConnectivity`;
244
+ iapRunAdapterConnectivity(callback) {
245
+ const meth = 'adapter-iapRunAdapterConnectivity';
246
+ const origin = `${this.id}-${meth}`;
224
247
  log.trace(origin);
248
+
225
249
  try {
226
- return super.runConnectivity(callback);
250
+ return super.iapRunAdapterConnectivity(callback);
227
251
  } catch (error) {
228
252
  log.error(`${origin}: ${error}`);
229
253
  return callback(null, error);
@@ -233,44 +257,67 @@ class EfficientipSolidserver extends AdapterBaseCl {
233
257
  /**
234
258
  * @summary runs basicGet script for adapter
235
259
  *
236
- * @function runBasicGet
260
+ * @function iapRunAdapterBasicGet
237
261
  * @param {Callback} callback - callback function
238
262
  */
239
- runBasicGet(callback) {
240
- const origin = `${this.id}-adapter-runBasicGet`;
263
+ iapRunAdapterBasicGet(callback) {
264
+ const meth = 'adapter-iapRunAdapterBasicGet';
265
+ const origin = `${this.id}-${meth}`;
241
266
  log.trace(origin);
267
+
242
268
  try {
243
- return super.runBasicGet(callback);
269
+ return super.iapRunAdapterBasicGet(callback);
244
270
  } catch (error) {
245
271
  log.error(`${origin}: ${error}`);
246
272
  return callback(null, error);
247
273
  }
248
274
  }
249
275
 
276
+ /**
277
+ * @summary moves entites into Mongo DB
278
+ *
279
+ * @function iapMoveAdapterEntitiesToDB
280
+ * @param {getCallback} callback - a callback function to return the result (Generics)
281
+ * or the error
282
+ */
283
+ iapMoveAdapterEntitiesToDB(callback) {
284
+ const meth = 'adapter-iapMoveAdapterEntitiesToDB';
285
+ const origin = `${this.id}-${meth}`;
286
+ log.trace(origin);
287
+
288
+ try {
289
+ return super.iapMoveAdapterEntitiesToDB(callback);
290
+ } catch (err) {
291
+ log.error(`${origin}: ${err}`);
292
+ return callback(null, err);
293
+ }
294
+ }
295
+
296
+ /* BROKER CALLS */
250
297
  /**
251
298
  * @summary Determines if this adapter supports the specific entity
252
299
  *
253
- * @function hasEntity
300
+ * @function iapHasAdapterEntity
254
301
  * @param {String} entityType - the entity type to check for
255
302
  * @param {String/Array} entityId - the specific entity we are looking for
256
303
  *
257
304
  * @param {Callback} callback - An array of whether the adapter can has the
258
305
  * desired capability or an error
259
306
  */
260
- hasEntity(entityType, entityId, callback) {
261
- const origin = `${this.id}-adapter-hasEntity`;
307
+ iapHasAdapterEntity(entityType, entityId, callback) {
308
+ const origin = `${this.id}-adapter-iapHasAdapterEntity`;
262
309
  log.trace(origin);
263
310
 
264
311
  // Make the call -
265
- // verifyCapability(entityType, actionType, entityId, callback)
266
- return this.verifyCapability(entityType, null, entityId, callback);
312
+ // iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
313
+ return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
267
314
  }
268
315
 
269
316
  /**
270
317
  * @summary Provides a way for the adapter to tell north bound integrations
271
318
  * whether the adapter supports type, action and specific entity
272
319
  *
273
- * @function verifyCapability
320
+ * @function iapVerifyAdapterCapability
274
321
  * @param {String} entityType - the entity type to check for
275
322
  * @param {String} actionType - the action type to check for
276
323
  * @param {String/Array} entityId - the specific entity we are looking for
@@ -278,15 +325,15 @@ class EfficientipSolidserver extends AdapterBaseCl {
278
325
  * @param {Callback} callback - An array of whether the adapter can has the
279
326
  * desired capability or an error
280
327
  */
281
- verifyCapability(entityType, actionType, entityId, callback) {
282
- const meth = 'adapterBase-verifyCapability';
328
+ iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
329
+ const meth = 'adapterBase-iapVerifyAdapterCapability';
283
330
  const origin = `${this.id}-${meth}`;
284
331
  log.trace(origin);
285
332
 
286
333
  // if caching
287
334
  if (this.caching) {
288
- // Make the call - verifyCapability(entityType, actionType, entityId, callback)
289
- return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (results, error) => {
335
+ // Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
336
+ return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
290
337
  if (error) {
291
338
  return callback(null, error);
292
339
  }
@@ -304,7 +351,7 @@ class EfficientipSolidserver extends AdapterBaseCl {
304
351
  }
305
352
 
306
353
  // need to check the cache again since it has been updated
307
- return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (vcapable, verror) => {
354
+ return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
308
355
  if (verror) {
309
356
  return callback(null, verror);
310
357
  }
@@ -337,7 +384,7 @@ class EfficientipSolidserver extends AdapterBaseCl {
337
384
  // if no entity id
338
385
  if (!entityId) {
339
386
  // need to check the cache again since it has been updated
340
- return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
387
+ return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
341
388
  if (verror) {
342
389
  return callback(null, verror);
343
390
  }
@@ -358,7 +405,7 @@ class EfficientipSolidserver extends AdapterBaseCl {
358
405
  }
359
406
 
360
407
  // need to check the cache again since it has been updated
361
- return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => {
408
+ return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
362
409
  if (verror) {
363
410
  return callback(null, verror);
364
411
  }
@@ -399,11 +446,11 @@ class EfficientipSolidserver extends AdapterBaseCl {
399
446
  /**
400
447
  * @summary Updates the cache for all entities by call the get All entity method
401
448
  *
402
- * @function updateEntityCache
449
+ * @function iapUpdateAdapterEntityCache
403
450
  *
404
451
  */
405
- updateEntityCache() {
406
- const origin = `${this.id}-adapter-updateEntityCache`;
452
+ iapUpdateAdapterEntityCache() {
453
+ const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
407
454
  log.trace(origin);
408
455
 
409
456
  if (this.caching) {
@@ -416,6 +463,140 @@ class EfficientipSolidserver extends AdapterBaseCl {
416
463
  }
417
464
  }
418
465
 
466
+ /**
467
+ * @summary Determines if this adapter supports any in a list of entities
468
+ *
469
+ * @function hasEntities
470
+ * @param {String} entityType - the entity type to check for
471
+ * @param {Array} entityList - the list of entities we are looking for
472
+ *
473
+ * @param {Callback} callback - A map where the entity is the key and the
474
+ * value is true or false
475
+ */
476
+ hasEntities(entityType, entityList, callback) {
477
+ const meth = 'adapter-hasEntities';
478
+ const origin = `${this.id}-${meth}`;
479
+ log.trace(origin);
480
+
481
+ try {
482
+ return super.hasEntities(entityType, entityList, callback);
483
+ } catch (err) {
484
+ log.error(`${origin}: ${err}`);
485
+ return callback(null, err);
486
+ }
487
+ }
488
+
489
+ /**
490
+ * @summary Get Appliance that match the deviceName
491
+ *
492
+ * @function getDevice
493
+ * @param {String} deviceName - the deviceName to find (required)
494
+ *
495
+ * @param {getCallback} callback - a callback function to return the result
496
+ * (appliance) or the error
497
+ */
498
+ getDevice(deviceName, callback) {
499
+ const meth = 'adapter-getDevice';
500
+ const origin = `${this.id}-${meth}`;
501
+ log.trace(origin);
502
+
503
+ try {
504
+ return super.getDevice(deviceName, callback);
505
+ } catch (err) {
506
+ log.error(`${origin}: ${err}`);
507
+ return callback(null, err);
508
+ }
509
+ }
510
+
511
+ /**
512
+ * @summary Get Appliances that match the filter
513
+ *
514
+ * @function getDevicesFiltered
515
+ * @param {Object} options - the data to use to filter the appliances (optional)
516
+ *
517
+ * @param {getCallback} callback - a callback function to return the result
518
+ * (appliances) or the error
519
+ */
520
+ getDevicesFiltered(options, callback) {
521
+ const meth = 'adapter-getDevicesFiltered';
522
+ const origin = `${this.id}-${meth}`;
523
+ log.trace(origin);
524
+
525
+ try {
526
+ return super.getDevicesFiltered(options, callback);
527
+ } catch (err) {
528
+ log.error(`${origin}: ${err}`);
529
+ return callback(null, err);
530
+ }
531
+ }
532
+
533
+ /**
534
+ * @summary Gets the status for the provided appliance
535
+ *
536
+ * @function isAlive
537
+ * @param {String} deviceName - the deviceName of the appliance. (required)
538
+ *
539
+ * @param {configCallback} callback - callback function to return the result
540
+ * (appliance isAlive) or the error
541
+ */
542
+ isAlive(deviceName, callback) {
543
+ const meth = 'adapter-isAlive';
544
+ const origin = `${this.id}-${meth}`;
545
+ log.trace(origin);
546
+
547
+ try {
548
+ return super.isAlive(deviceName, callback);
549
+ } catch (err) {
550
+ log.error(`${origin}: ${err}`);
551
+ return callback(null, err);
552
+ }
553
+ }
554
+
555
+ /**
556
+ * @summary Gets a config for the provided Appliance
557
+ *
558
+ * @function getConfig
559
+ * @param {String} deviceName - the deviceName of the appliance. (required)
560
+ * @param {String} format - the desired format of the config. (optional)
561
+ *
562
+ * @param {configCallback} callback - callback function to return the result
563
+ * (appliance config) or the error
564
+ */
565
+ getConfig(deviceName, format, callback) {
566
+ const meth = 'adapter-getConfig';
567
+ const origin = `${this.id}-${meth}`;
568
+ log.trace(origin);
569
+
570
+ try {
571
+ return super.getConfig(deviceName, format, callback);
572
+ } catch (err) {
573
+ log.error(`${origin}: ${err}`);
574
+ return callback(null, err);
575
+ }
576
+ }
577
+
578
+ /**
579
+ * @summary Gets the device count from the system
580
+ *
581
+ * @function iapGetDeviceCount
582
+ *
583
+ * @param {getCallback} callback - callback function to return the result
584
+ * (count) or the error
585
+ */
586
+ iapGetDeviceCount(callback) {
587
+ const meth = 'adapter-iapGetDeviceCount';
588
+ const origin = `${this.id}-${meth}`;
589
+ log.trace(origin);
590
+
591
+ try {
592
+ return super.iapGetDeviceCount(callback);
593
+ } catch (err) {
594
+ log.error(`${origin}: ${err}`);
595
+ return callback(null, err);
596
+ }
597
+ }
598
+
599
+ /* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
419
600
  /**
420
601
  * Makes the requested generic call
421
602
  *
@@ -526,6 +707,116 @@ class EfficientipSolidserver extends AdapterBaseCl {
526
707
  }
527
708
  }
528
709
 
710
+ /**
711
+ * Makes the requested generic call with no base path or version
712
+ *
713
+ * @function genericAdapterRequestNoBasePath
714
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
715
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
716
+ * @param {Object} queryData - the parameters to be put on the url (optional).
717
+ * Can be a stringified Object.
718
+ * @param {Object} requestBody - the body to add to the request (optional).
719
+ * Can be a stringified Object.
720
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
721
+ * Can be a stringified Object.
722
+ * @param {getCallback} callback - a callback function to return the result (Generics)
723
+ * or the error
724
+ */
725
+ genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
726
+ const meth = 'adapter-genericAdapterRequestNoBasePath';
727
+ const origin = `${this.id}-${meth}`;
728
+ log.trace(origin);
729
+
730
+ if (this.suspended && this.suspendMode === 'error') {
731
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
732
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
733
+ return callback(null, errorObj);
734
+ }
735
+
736
+ /* HERE IS WHERE YOU VALIDATE DATA */
737
+ if (uriPath === undefined || uriPath === null || uriPath === '') {
738
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
739
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
740
+ return callback(null, errorObj);
741
+ }
742
+ if (restMethod === undefined || restMethod === null || restMethod === '') {
743
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
744
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
745
+ return callback(null, errorObj);
746
+ }
747
+
748
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
749
+ // remove any leading / and split the uripath into path variables
750
+ let myPath = uriPath;
751
+ while (myPath.indexOf('/') === 0) {
752
+ myPath = myPath.substring(1);
753
+ }
754
+ const pathVars = myPath.split('/');
755
+ const queryParamsAvailable = queryData;
756
+ const queryParams = {};
757
+ const bodyVars = requestBody;
758
+
759
+ // loop in template. long callback arg name to avoid identifier conflicts
760
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
761
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
762
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
763
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
764
+ }
765
+ });
766
+
767
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
768
+ const reqObj = {
769
+ payload: bodyVars,
770
+ uriPathVars: pathVars,
771
+ uriQuery: queryParams,
772
+ uriOptions: {}
773
+ };
774
+ // add headers if provided
775
+ if (addlHeaders) {
776
+ reqObj.addlHeaders = addlHeaders;
777
+ }
778
+
779
+ // determine the call and return flag
780
+ let action = 'getGenericsNoBase';
781
+ let returnF = true;
782
+ if (restMethod.toUpperCase() === 'POST') {
783
+ action = 'createGenericNoBase';
784
+ } else if (restMethod.toUpperCase() === 'PUT') {
785
+ action = 'updateGenericNoBase';
786
+ } else if (restMethod.toUpperCase() === 'PATCH') {
787
+ action = 'patchGenericNoBase';
788
+ } else if (restMethod.toUpperCase() === 'DELETE') {
789
+ action = 'deleteGenericNoBase';
790
+ returnF = false;
791
+ }
792
+
793
+ try {
794
+ // Make the call -
795
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
796
+ return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
797
+ // if we received an error or their is no response on the results
798
+ // return an error
799
+ if (irReturnError) {
800
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
801
+ return callback(null, irReturnError);
802
+ }
803
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
804
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
805
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
806
+ return callback(null, errorObj);
807
+ }
808
+
809
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
810
+ // return the response
811
+ return callback(irReturnData, null);
812
+ });
813
+ } catch (ex) {
814
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
815
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
816
+ return callback(null, errorObj);
817
+ }
818
+ }
819
+
529
820
  /**
530
821
  * @callback healthCallback
531
822
  * @param {Object} result - the result of the get request (contains an id and a status)