@itentialopensource/adapter-algosec_fireflow 0.1.1

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 (77) hide show
  1. package/.eslintignore +5 -0
  2. package/.eslintrc.js +18 -0
  3. package/.jshintrc +3 -0
  4. package/AUTH.md +39 -0
  5. package/BROKER.md +199 -0
  6. package/CALLS.md +170 -0
  7. package/CHANGELOG.md +9 -0
  8. package/CODE_OF_CONDUCT.md +43 -0
  9. package/CONTRIBUTING.md +172 -0
  10. package/ENHANCE.md +69 -0
  11. package/LICENSE +201 -0
  12. package/PROPERTIES.md +641 -0
  13. package/README.md +337 -0
  14. package/SUMMARY.md +9 -0
  15. package/SYSTEMINFO.md +11 -0
  16. package/TROUBLESHOOT.md +47 -0
  17. package/adapter.js +1908 -0
  18. package/adapterBase.js +1787 -0
  19. package/entities/.generic/action.json +214 -0
  20. package/entities/.generic/schema.json +28 -0
  21. package/entities/.system/action.json +50 -0
  22. package/entities/.system/mockdatafiles/getToken-default.json +14 -0
  23. package/entities/.system/mockdatafiles/healthcheck-default.json +3 -0
  24. package/entities/.system/schema.json +19 -0
  25. package/entities/.system/schemaTokenReq.json +53 -0
  26. package/entities/.system/schemaTokenResp.json +53 -0
  27. package/entities/ActiveChangeExternalController/action.json +45 -0
  28. package/entities/ActiveChangeExternalController/schema.json +20 -0
  29. package/entities/AuthenticationExternalController/action.json +24 -0
  30. package/entities/AuthenticationExternalController/schema.json +19 -0
  31. package/entities/ObjectChangeRequestExternalController/action.json +24 -0
  32. package/entities/ObjectChangeRequestExternalController/schema.json +19 -0
  33. package/entities/RequestTemplateExternalController/action.json +25 -0
  34. package/entities/RequestTemplateExternalController/schema.json +19 -0
  35. package/entities/RuleRemovalChangeRequestExternalController/action.json +24 -0
  36. package/entities/RuleRemovalChangeRequestExternalController/schema.json +19 -0
  37. package/entities/SavedSearchController/action.json +25 -0
  38. package/entities/SavedSearchController/schema.json +19 -0
  39. package/entities/SessionExternalController/action.json +25 -0
  40. package/entities/SessionExternalController/schema.json +19 -0
  41. package/entities/TrafficChangeRequestExternalController/action.json +65 -0
  42. package/entities/TrafficChangeRequestExternalController/schema.json +21 -0
  43. package/entities/WorkOrderExternalController/action.json +45 -0
  44. package/entities/WorkOrderExternalController/schema.json +20 -0
  45. package/error.json +190 -0
  46. package/package.json +86 -0
  47. package/pronghorn.json +1672 -0
  48. package/propertiesDecorators.json +14 -0
  49. package/propertiesSchema.json +1248 -0
  50. package/refs?service=git-upload-pack +0 -0
  51. package/report/algosec-FireFlow-swagger.json +1476 -0
  52. package/report/creationReport.json +395 -0
  53. package/sampleProperties.json +195 -0
  54. package/test/integration/adapterTestBasicGet.js +83 -0
  55. package/test/integration/adapterTestConnectivity.js +93 -0
  56. package/test/integration/adapterTestIntegration.js +758 -0
  57. package/test/unit/adapterBaseTestUnit.js +949 -0
  58. package/test/unit/adapterTestUnit.js +1671 -0
  59. package/utils/adapterInfo.js +206 -0
  60. package/utils/addAuth.js +94 -0
  61. package/utils/artifactize.js +146 -0
  62. package/utils/basicGet.js +50 -0
  63. package/utils/checkMigrate.js +63 -0
  64. package/utils/entitiesToDB.js +178 -0
  65. package/utils/findPath.js +74 -0
  66. package/utils/methodDocumentor.js +225 -0
  67. package/utils/modify.js +154 -0
  68. package/utils/packModificationScript.js +35 -0
  69. package/utils/patches2bundledDeps.js +90 -0
  70. package/utils/pre-commit.sh +32 -0
  71. package/utils/removeHooks.js +20 -0
  72. package/utils/setup.js +33 -0
  73. package/utils/tbScript.js +246 -0
  74. package/utils/tbUtils.js +490 -0
  75. package/utils/testRunner.js +298 -0
  76. package/utils/troubleshootingAdapter.js +195 -0
  77. package/workflows/README.md +3 -0
package/adapter.js ADDED
@@ -0,0 +1,1908 @@
1
+ /* @copyright Itential, LLC 2019 (pre-modifications) */
2
+
3
+ /* eslint import/no-dynamic-require: warn */
4
+ /* eslint object-curly-newline: warn */
5
+
6
+ // Set globals
7
+ /* global log */
8
+
9
+ /* Required libraries. */
10
+ const path = require('path');
11
+
12
+ /* Fetch in the other needed components for the this Adaptor */
13
+ const AdapterBaseCl = require(path.join(__dirname, 'adapterBase.js'));
14
+
15
+ /**
16
+ * This is the adapter/interface into Algosec_fireflow
17
+ */
18
+
19
+ /* GENERAL ADAPTER FUNCTIONS */
20
+ class AlgosecFireflow extends AdapterBaseCl {
21
+ /**
22
+ * AlgosecFireflow Adapter
23
+ * @constructor
24
+ */
25
+ /* Working on changing the way we do Emit methods due to size and time constrainsts
26
+ constructor(prongid, properties) {
27
+ // Instantiate the AdapterBase super class
28
+ super(prongid, properties);
29
+
30
+ const restFunctionNames = this.iapGetAdapterWorkflowFunctions();
31
+
32
+ // Dynamically bind emit functions
33
+ for (let i = 0; i < restFunctionNames.length; i += 1) {
34
+ // Bind function to have name fnNameEmit for fnName
35
+ const version = restFunctionNames[i].match(/__v[0-9]+/);
36
+ const baseFnName = restFunctionNames[i].replace(/__v[0-9]+/, '');
37
+ const fnNameEmit = version ? `${baseFnName}Emit${version}` : `${baseFnName}Emit`;
38
+ this[fnNameEmit] = function (...args) {
39
+ // extract the callback
40
+ const callback = args[args.length - 1];
41
+ // slice the callback from args so we can insert our own
42
+ const functionArgs = args.slice(0, args.length - 1);
43
+ // create a random name for the listener
44
+ const eventName = `${restFunctionNames[i]}:${Math.random().toString(36)}`;
45
+ // tell the calling class to start listening
46
+ callback({ event: eventName, status: 'received' });
47
+ // store parent for use of this context later
48
+ const parent = this;
49
+ // store emission function
50
+ const func = function (val, err) {
51
+ parent.removeListener(eventName, func);
52
+ parent.emit(eventName, val, err);
53
+ };
54
+ // Use apply to call the function in a specific context
55
+ this[restFunctionNames[i]].apply(this, functionArgs.concat([func])); // eslint-disable-line prefer-spread
56
+ };
57
+ }
58
+
59
+ // Uncomment if you have things to add to the constructor like using your own properties.
60
+ // Otherwise the constructor in the adapterBase will be used.
61
+ // Capture my own properties - they need to be defined in propertiesSchema.json
62
+ // if (this.allProps && this.allProps.myownproperty) {
63
+ // mypropvariable = this.allProps.myownproperty;
64
+ // }
65
+ }
66
+ */
67
+
68
+ /**
69
+ * @callback healthCallback
70
+ * @param {Object} reqObj - the request to send into the healthcheck
71
+ * @param {Callback} callback - The results of the call
72
+ */
73
+ healthCheck(reqObj, callback) {
74
+ // you can modify what is passed into the healthcheck by changing things in the newReq
75
+ let newReq = null;
76
+ if (reqObj) {
77
+ newReq = Object.assign(...reqObj);
78
+ }
79
+ super.healthCheck(newReq, callback);
80
+ }
81
+
82
+ /**
83
+ * @iapGetAdapterWorkflowFunctions
84
+ */
85
+ iapGetAdapterWorkflowFunctions(inIgnore) {
86
+ let myIgnore = [
87
+ 'healthCheck',
88
+ 'iapGetAdapterWorkflowFunctions',
89
+ 'iapHasAdapterEntity',
90
+ 'iapVerifyAdapterCapability',
91
+ 'iapUpdateAdapterEntityCache',
92
+ 'hasEntities'
93
+ ];
94
+ if (!inIgnore && Array.isArray(inIgnore)) {
95
+ myIgnore = inIgnore;
96
+ } else if (!inIgnore && typeof inIgnore === 'string') {
97
+ myIgnore = [inIgnore];
98
+ }
99
+
100
+ // The generic adapter functions should already be ignored (e.g. healthCheck)
101
+ // you can add specific methods that you do not want to be workflow functions to ignore like below
102
+ // myIgnore.push('myMethodNotInWorkflow');
103
+
104
+ return super.iapGetAdapterWorkflowFunctions(myIgnore);
105
+ }
106
+
107
+ /**
108
+ * iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
109
+ * allows customers to make changes to adapter configuration without having to be on the
110
+ * file system.
111
+ *
112
+ * @function iapUpdateAdapterConfiguration
113
+ * @param {string} configFile - the name of the file being updated (required)
114
+ * @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
115
+ * @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
116
+ * @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
117
+ * @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
118
+ * @param {Callback} callback - The results of the call
119
+ */
120
+ iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
121
+ const meth = 'adapter-iapUpdateAdapterConfiguration';
122
+ const origin = `${this.id}-${meth}`;
123
+ log.trace(origin);
124
+
125
+ super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
126
+ }
127
+
128
+ /**
129
+ * See if the API path provided is found in this adapter
130
+ *
131
+ * @function iapFindAdapterPath
132
+ * @param {string} apiPath - the api path to check on
133
+ * @param {Callback} callback - The results of the call
134
+ */
135
+ iapFindAdapterPath(apiPath, callback) {
136
+ const meth = 'adapter-iapFindAdapterPath';
137
+ const origin = `${this.id}-${meth}`;
138
+ log.trace(origin);
139
+
140
+ super.iapFindAdapterPath(apiPath, callback);
141
+ }
142
+
143
+ /**
144
+ * @summary Suspends adapter
145
+ *
146
+ * @function iapSuspendAdapter
147
+ * @param {Callback} callback - callback function
148
+ */
149
+ iapSuspendAdapter(mode, callback) {
150
+ const meth = 'adapter-iapSuspendAdapter';
151
+ const origin = `${this.id}-${meth}`;
152
+ log.trace(origin);
153
+
154
+ try {
155
+ return super.iapSuspendAdapter(mode, callback);
156
+ } catch (error) {
157
+ log.error(`${origin}: ${error}`);
158
+ return callback(null, error);
159
+ }
160
+ }
161
+
162
+ /**
163
+ * @summary Unsuspends adapter
164
+ *
165
+ * @function iapUnsuspendAdapter
166
+ * @param {Callback} callback - callback function
167
+ */
168
+ iapUnsuspendAdapter(callback) {
169
+ const meth = 'adapter-iapUnsuspendAdapter';
170
+ const origin = `${this.id}-${meth}`;
171
+ log.trace(origin);
172
+
173
+ try {
174
+ return super.iapUnsuspendAdapter(callback);
175
+ } catch (error) {
176
+ log.error(`${origin}: ${error}`);
177
+ return callback(null, error);
178
+ }
179
+ }
180
+
181
+ /**
182
+ * @summary Get the Adaoter Queue
183
+ *
184
+ * @function iapGetAdapterQueue
185
+ * @param {Callback} callback - callback function
186
+ */
187
+ iapGetAdapterQueue(callback) {
188
+ const meth = 'adapter-iapGetAdapterQueue';
189
+ const origin = `${this.id}-${meth}`;
190
+ log.trace(origin);
191
+
192
+ return super.iapGetAdapterQueue(callback);
193
+ }
194
+
195
+ /**
196
+ * @summary Runs troubleshoot scripts for adapter
197
+ *
198
+ * @function iapTroubleshootAdapter
199
+ * @param {Object} props - the connection, healthcheck and authentication properties
200
+ *
201
+ * @param {boolean} persistFlag - whether the adapter properties should be updated
202
+ * @param {Callback} callback - The results of the call
203
+ */
204
+ iapTroubleshootAdapter(props, persistFlag, callback) {
205
+ const meth = 'adapter-iapTroubleshootAdapter';
206
+ const origin = `${this.id}-${meth}`;
207
+ log.trace(origin);
208
+
209
+ try {
210
+ return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
211
+ } catch (error) {
212
+ log.error(`${origin}: ${error}`);
213
+ return callback(null, error);
214
+ }
215
+ }
216
+
217
+ /**
218
+ * @summary runs healthcheck script for adapter
219
+ *
220
+ * @function iapRunAdapterHealthcheck
221
+ * @param {Adapter} adapter - adapter instance to troubleshoot
222
+ * @param {Callback} callback - callback function
223
+ */
224
+ iapRunAdapterHealthcheck(callback) {
225
+ const meth = 'adapter-iapRunAdapterHealthcheck';
226
+ const origin = `${this.id}-${meth}`;
227
+ log.trace(origin);
228
+
229
+ try {
230
+ return super.iapRunAdapterHealthcheck(this, callback);
231
+ } catch (error) {
232
+ log.error(`${origin}: ${error}`);
233
+ return callback(null, error);
234
+ }
235
+ }
236
+
237
+ /**
238
+ * @summary runs connectivity check script for adapter
239
+ *
240
+ * @function iapRunAdapterConnectivity
241
+ * @param {Callback} callback - callback function
242
+ */
243
+ iapRunAdapterConnectivity(callback) {
244
+ const meth = 'adapter-iapRunAdapterConnectivity';
245
+ const origin = `${this.id}-${meth}`;
246
+ log.trace(origin);
247
+
248
+ try {
249
+ return super.iapRunAdapterConnectivity(callback);
250
+ } catch (error) {
251
+ log.error(`${origin}: ${error}`);
252
+ return callback(null, error);
253
+ }
254
+ }
255
+
256
+ /**
257
+ * @summary runs basicGet script for adapter
258
+ *
259
+ * @function iapRunAdapterBasicGet
260
+ * @param {Callback} callback - callback function
261
+ */
262
+ iapRunAdapterBasicGet(callback) {
263
+ const meth = 'adapter-iapRunAdapterBasicGet';
264
+ const origin = `${this.id}-${meth}`;
265
+ log.trace(origin);
266
+
267
+ try {
268
+ return super.iapRunAdapterBasicGet(callback);
269
+ } catch (error) {
270
+ log.error(`${origin}: ${error}`);
271
+ return callback(null, error);
272
+ }
273
+ }
274
+
275
+ /**
276
+ * @summary moves entites into Mongo DB
277
+ *
278
+ * @function iapMoveAdapterEntitiesToDB
279
+ * @param {getCallback} callback - a callback function to return the result (Generics)
280
+ * or the error
281
+ */
282
+ iapMoveAdapterEntitiesToDB(callback) {
283
+ const meth = 'adapter-iapMoveAdapterEntitiesToDB';
284
+ const origin = `${this.id}-${meth}`;
285
+ log.trace(origin);
286
+
287
+ try {
288
+ return super.iapMoveAdapterEntitiesToDB(callback);
289
+ } catch (err) {
290
+ log.error(`${origin}: ${err}`);
291
+ return callback(null, err);
292
+ }
293
+ }
294
+
295
+ /* BROKER CALLS */
296
+ /**
297
+ * @summary Determines if this adapter supports the specific entity
298
+ *
299
+ * @function iapHasAdapterEntity
300
+ * @param {String} entityType - the entity type to check for
301
+ * @param {String/Array} entityId - the specific entity we are looking for
302
+ *
303
+ * @param {Callback} callback - An array of whether the adapter can has the
304
+ * desired capability or an error
305
+ */
306
+ iapHasAdapterEntity(entityType, entityId, callback) {
307
+ const origin = `${this.id}-adapter-iapHasAdapterEntity`;
308
+ log.trace(origin);
309
+
310
+ // Make the call -
311
+ // iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
312
+ return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
313
+ }
314
+
315
+ /**
316
+ * @summary Provides a way for the adapter to tell north bound integrations
317
+ * whether the adapter supports type, action and specific entity
318
+ *
319
+ * @function iapVerifyAdapterCapability
320
+ * @param {String} entityType - the entity type to check for
321
+ * @param {String} actionType - the action type to check for
322
+ * @param {String/Array} entityId - the specific entity we are looking for
323
+ *
324
+ * @param {Callback} callback - An array of whether the adapter can has the
325
+ * desired capability or an error
326
+ */
327
+ iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
328
+ const meth = 'adapterBase-iapVerifyAdapterCapability';
329
+ const origin = `${this.id}-${meth}`;
330
+ log.trace(origin);
331
+
332
+ // if caching
333
+ if (this.caching) {
334
+ // Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
335
+ return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
336
+ if (error) {
337
+ return callback(null, error);
338
+ }
339
+
340
+ // if the cache needs to be updated, update and try again
341
+ if (results && results[0] === 'needupdate') {
342
+ switch (entityType) {
343
+ case 'template_entity': {
344
+ // if the cache is invalid, update the cache
345
+ return this.getEntities(null, null, null, null, (data, err) => {
346
+ if (err) {
347
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
348
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
349
+ return callback(null, errorObj);
350
+ }
351
+
352
+ // need to check the cache again since it has been updated
353
+ return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
354
+ if (verror) {
355
+ return callback(null, verror);
356
+ }
357
+
358
+ return this.capabilityResults(vcapable, callback);
359
+ });
360
+ });
361
+ }
362
+ default: {
363
+ // unsupported entity type
364
+ const result = [false];
365
+
366
+ // put false in array for all entities
367
+ if (Array.isArray(entityId)) {
368
+ for (let e = 1; e < entityId.length; e += 1) {
369
+ result.push(false);
370
+ }
371
+ }
372
+
373
+ return callback(result);
374
+ }
375
+ }
376
+ }
377
+
378
+ // return the results
379
+ return this.capabilityResults(results, callback);
380
+ });
381
+ }
382
+
383
+ // if no entity id
384
+ if (!entityId) {
385
+ // need to check the cache again since it has been updated
386
+ return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
387
+ if (verror) {
388
+ return callback(null, verror);
389
+ }
390
+
391
+ return this.capabilityResults(vcapable, callback);
392
+ });
393
+ }
394
+
395
+ // if not caching
396
+ switch (entityType) {
397
+ case 'template_entity': {
398
+ // need to get the entities to check
399
+ return this.getEntities(null, null, null, null, (data, err) => {
400
+ if (err) {
401
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
402
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
403
+ return callback(null, errorObj);
404
+ }
405
+
406
+ // need to check the cache again since it has been updated
407
+ return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
408
+ if (verror) {
409
+ return callback(null, verror);
410
+ }
411
+
412
+ // is the entity in the list?
413
+ const isEntity = this.entityInList(entityId, data.response, callback);
414
+ const res = [];
415
+
416
+ // not found
417
+ for (let i = 0; i < isEntity.length; i += 1) {
418
+ if (vcapable) {
419
+ res.push(isEntity[i]);
420
+ } else {
421
+ res.push(false);
422
+ }
423
+ }
424
+
425
+ return callback(res);
426
+ });
427
+ });
428
+ }
429
+ default: {
430
+ // unsupported entity type
431
+ const result = [false];
432
+
433
+ // put false in array for all entities
434
+ if (Array.isArray(entityId)) {
435
+ for (let e = 1; e < entityId.length; e += 1) {
436
+ result.push(false);
437
+ }
438
+ }
439
+
440
+ return callback(result);
441
+ }
442
+ }
443
+ }
444
+
445
+ /**
446
+ * @summary Updates the cache for all entities by call the get All entity method
447
+ *
448
+ * @function iapUpdateAdapterEntityCache
449
+ *
450
+ */
451
+ iapUpdateAdapterEntityCache() {
452
+ const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
453
+ log.trace(origin);
454
+
455
+ if (this.caching) {
456
+ // if the cache is invalid, update the cache
457
+ this.getEntities(null, null, null, null, (data, err) => {
458
+ if (err) {
459
+ log.trace(`${origin}: Could not load template_entity into cache - ${err}`);
460
+ }
461
+ });
462
+ }
463
+ }
464
+
465
+ /**
466
+ * @summary Determines if this adapter supports any in a list of entities
467
+ *
468
+ * @function hasEntities
469
+ * @param {String} entityType - the entity type to check for
470
+ * @param {Array} entityList - the list of entities we are looking for
471
+ *
472
+ * @param {Callback} callback - A map where the entity is the key and the
473
+ * value is true or false
474
+ */
475
+ hasEntities(entityType, entityList, callback) {
476
+ const meth = 'adapter-hasEntities';
477
+ const origin = `${this.id}-${meth}`;
478
+ log.trace(origin);
479
+
480
+ try {
481
+ return super.hasEntities(entityType, entityList, callback);
482
+ } catch (err) {
483
+ log.error(`${origin}: ${err}`);
484
+ return callback(null, err);
485
+ }
486
+ }
487
+
488
+ /**
489
+ * @summary Get Appliance that match the deviceName
490
+ *
491
+ * @function getDevice
492
+ * @param {String} deviceName - the deviceName to find (required)
493
+ *
494
+ * @param {getCallback} callback - a callback function to return the result
495
+ * (appliance) or the error
496
+ */
497
+ getDevice(deviceName, callback) {
498
+ const meth = 'adapter-getDevice';
499
+ const origin = `${this.id}-${meth}`;
500
+ log.trace(origin);
501
+
502
+ try {
503
+ return super.getDevice(deviceName, callback);
504
+ } catch (err) {
505
+ log.error(`${origin}: ${err}`);
506
+ return callback(null, err);
507
+ }
508
+ }
509
+
510
+ /**
511
+ * @summary Get Appliances that match the filter
512
+ *
513
+ * @function getDevicesFiltered
514
+ * @param {Object} options - the data to use to filter the appliances (optional)
515
+ *
516
+ * @param {getCallback} callback - a callback function to return the result
517
+ * (appliances) or the error
518
+ */
519
+ getDevicesFiltered(options, callback) {
520
+ const meth = 'adapter-getDevicesFiltered';
521
+ const origin = `${this.id}-${meth}`;
522
+ log.trace(origin);
523
+
524
+ try {
525
+ return super.getDevicesFiltered(options, callback);
526
+ } catch (err) {
527
+ log.error(`${origin}: ${err}`);
528
+ return callback(null, err);
529
+ }
530
+ }
531
+
532
+ /**
533
+ * @summary Gets the status for the provided appliance
534
+ *
535
+ * @function isAlive
536
+ * @param {String} deviceName - the deviceName of the appliance. (required)
537
+ *
538
+ * @param {configCallback} callback - callback function to return the result
539
+ * (appliance isAlive) or the error
540
+ */
541
+ isAlive(deviceName, callback) {
542
+ const meth = 'adapter-isAlive';
543
+ const origin = `${this.id}-${meth}`;
544
+ log.trace(origin);
545
+
546
+ try {
547
+ return super.isAlive(deviceName, callback);
548
+ } catch (err) {
549
+ log.error(`${origin}: ${err}`);
550
+ return callback(null, err);
551
+ }
552
+ }
553
+
554
+ /**
555
+ * @summary Gets a config for the provided Appliance
556
+ *
557
+ * @function getConfig
558
+ * @param {String} deviceName - the deviceName of the appliance. (required)
559
+ * @param {String} format - the desired format of the config. (optional)
560
+ *
561
+ * @param {configCallback} callback - callback function to return the result
562
+ * (appliance config) or the error
563
+ */
564
+ getConfig(deviceName, format, callback) {
565
+ const meth = 'adapter-getConfig';
566
+ const origin = `${this.id}-${meth}`;
567
+ log.trace(origin);
568
+
569
+ try {
570
+ return super.getConfig(deviceName, format, callback);
571
+ } catch (err) {
572
+ log.error(`${origin}: ${err}`);
573
+ return callback(null, err);
574
+ }
575
+ }
576
+
577
+ /**
578
+ * @summary Gets the device count from the system
579
+ *
580
+ * @function iapGetDeviceCount
581
+ *
582
+ * @param {getCallback} callback - callback function to return the result
583
+ * (count) or the error
584
+ */
585
+ iapGetDeviceCount(callback) {
586
+ const meth = 'adapter-iapGetDeviceCount';
587
+ const origin = `${this.id}-${meth}`;
588
+ log.trace(origin);
589
+
590
+ try {
591
+ return super.iapGetDeviceCount(callback);
592
+ } catch (err) {
593
+ log.error(`${origin}: ${err}`);
594
+ return callback(null, err);
595
+ }
596
+ }
597
+
598
+ /* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
599
+ /**
600
+ * Makes the requested generic call
601
+ *
602
+ * @function genericAdapterRequest
603
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
604
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
605
+ * @param {Object} queryData - the parameters to be put on the url (optional).
606
+ * Can be a stringified Object.
607
+ * @param {Object} requestBody - the body to add to the request (optional).
608
+ * Can be a stringified Object.
609
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
610
+ * Can be a stringified Object.
611
+ * @param {getCallback} callback - a callback function to return the result (Generics)
612
+ * or the error
613
+ */
614
+ genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
615
+ const meth = 'adapter-genericAdapterRequest';
616
+ const origin = `${this.id}-${meth}`;
617
+ log.trace(origin);
618
+
619
+ if (this.suspended && this.suspendMode === 'error') {
620
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
621
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
622
+ return callback(null, errorObj);
623
+ }
624
+
625
+ /* HERE IS WHERE YOU VALIDATE DATA */
626
+ if (uriPath === undefined || uriPath === null || uriPath === '') {
627
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
628
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
629
+ return callback(null, errorObj);
630
+ }
631
+ if (restMethod === undefined || restMethod === null || restMethod === '') {
632
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
633
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
634
+ return callback(null, errorObj);
635
+ }
636
+
637
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
638
+ // remove any leading / and split the uripath into path variables
639
+ let myPath = uriPath;
640
+ while (myPath.indexOf('/') === 0) {
641
+ myPath = myPath.substring(1);
642
+ }
643
+ const pathVars = myPath.split('/');
644
+ const queryParamsAvailable = queryData;
645
+ const queryParams = {};
646
+ const bodyVars = requestBody;
647
+
648
+ // loop in template. long callback arg name to avoid identifier conflicts
649
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
650
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
651
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
652
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
653
+ }
654
+ });
655
+
656
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
657
+ const reqObj = {
658
+ payload: bodyVars,
659
+ uriPathVars: pathVars,
660
+ uriQuery: queryParams,
661
+ uriOptions: {}
662
+ };
663
+ // add headers if provided
664
+ if (addlHeaders) {
665
+ reqObj.addlHeaders = addlHeaders;
666
+ }
667
+
668
+ // determine the call and return flag
669
+ let action = 'getGenerics';
670
+ let returnF = true;
671
+ if (restMethod.toUpperCase() === 'POST') {
672
+ action = 'createGeneric';
673
+ } else if (restMethod.toUpperCase() === 'PUT') {
674
+ action = 'updateGeneric';
675
+ } else if (restMethod.toUpperCase() === 'PATCH') {
676
+ action = 'patchGeneric';
677
+ } else if (restMethod.toUpperCase() === 'DELETE') {
678
+ action = 'deleteGeneric';
679
+ returnF = false;
680
+ }
681
+
682
+ try {
683
+ // Make the call -
684
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
685
+ return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
686
+ // if we received an error or their is no response on the results
687
+ // return an error
688
+ if (irReturnError) {
689
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
690
+ return callback(null, irReturnError);
691
+ }
692
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
693
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
694
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
695
+ return callback(null, errorObj);
696
+ }
697
+
698
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
699
+ // return the response
700
+ return callback(irReturnData, null);
701
+ });
702
+ } catch (ex) {
703
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
704
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
705
+ return callback(null, errorObj);
706
+ }
707
+ }
708
+
709
+ /**
710
+ * Makes the requested generic call with no base path or version
711
+ *
712
+ * @function genericAdapterRequestNoBasePath
713
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
714
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
715
+ * @param {Object} queryData - the parameters to be put on the url (optional).
716
+ * Can be a stringified Object.
717
+ * @param {Object} requestBody - the body to add to the request (optional).
718
+ * Can be a stringified Object.
719
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
720
+ * Can be a stringified Object.
721
+ * @param {getCallback} callback - a callback function to return the result (Generics)
722
+ * or the error
723
+ */
724
+ genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
725
+ const meth = 'adapter-genericAdapterRequestNoBasePath';
726
+ const origin = `${this.id}-${meth}`;
727
+ log.trace(origin);
728
+
729
+ if (this.suspended && this.suspendMode === 'error') {
730
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
731
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
732
+ return callback(null, errorObj);
733
+ }
734
+
735
+ /* HERE IS WHERE YOU VALIDATE DATA */
736
+ if (uriPath === undefined || uriPath === null || uriPath === '') {
737
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
738
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
739
+ return callback(null, errorObj);
740
+ }
741
+ if (restMethod === undefined || restMethod === null || restMethod === '') {
742
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
743
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
744
+ return callback(null, errorObj);
745
+ }
746
+
747
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
748
+ // remove any leading / and split the uripath into path variables
749
+ let myPath = uriPath;
750
+ while (myPath.indexOf('/') === 0) {
751
+ myPath = myPath.substring(1);
752
+ }
753
+ const pathVars = myPath.split('/');
754
+ const queryParamsAvailable = queryData;
755
+ const queryParams = {};
756
+ const bodyVars = requestBody;
757
+
758
+ // loop in template. long callback arg name to avoid identifier conflicts
759
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
760
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
761
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
762
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
763
+ }
764
+ });
765
+
766
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
767
+ const reqObj = {
768
+ payload: bodyVars,
769
+ uriPathVars: pathVars,
770
+ uriQuery: queryParams,
771
+ uriOptions: {}
772
+ };
773
+ // add headers if provided
774
+ if (addlHeaders) {
775
+ reqObj.addlHeaders = addlHeaders;
776
+ }
777
+
778
+ // determine the call and return flag
779
+ let action = 'getGenericsNoBase';
780
+ let returnF = true;
781
+ if (restMethod.toUpperCase() === 'POST') {
782
+ action = 'createGenericNoBase';
783
+ } else if (restMethod.toUpperCase() === 'PUT') {
784
+ action = 'updateGenericNoBase';
785
+ } else if (restMethod.toUpperCase() === 'PATCH') {
786
+ action = 'patchGenericNoBase';
787
+ } else if (restMethod.toUpperCase() === 'DELETE') {
788
+ action = 'deleteGenericNoBase';
789
+ returnF = false;
790
+ }
791
+
792
+ try {
793
+ // Make the call -
794
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
795
+ return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
796
+ // if we received an error or their is no response on the results
797
+ // return an error
798
+ if (irReturnError) {
799
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
800
+ return callback(null, irReturnError);
801
+ }
802
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
803
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
804
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
805
+ return callback(null, errorObj);
806
+ }
807
+
808
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
809
+ // return the response
810
+ return callback(irReturnData, null);
811
+ });
812
+ } catch (ex) {
813
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
814
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
815
+ return callback(null, errorObj);
816
+ }
817
+ }
818
+
819
+ /**
820
+ * @callback healthCallback
821
+ * @param {Object} result - the result of the get request (contains an id and a status)
822
+ */
823
+ /**
824
+ * @callback getCallback
825
+ * @param {Object} result - the result of the get request (entity/ies)
826
+ * @param {String} error - any error that occurred
827
+ */
828
+ /**
829
+ * @callback createCallback
830
+ * @param {Object} item - the newly created entity
831
+ * @param {String} error - any error that occurred
832
+ */
833
+ /**
834
+ * @callback updateCallback
835
+ * @param {String} status - the status of the update action
836
+ * @param {String} error - any error that occurred
837
+ */
838
+ /**
839
+ * @callback deleteCallback
840
+ * @param {String} status - the status of the delete action
841
+ * @param {String} error - any error that occurred
842
+ */
843
+
844
+ /**
845
+ * @function authenticateUsingPOST
846
+ * @pronghornType method
847
+ * @name authenticateUsingPOST
848
+ * @summary User authentication operation
849
+ *
850
+ * @param {object} authenticationData - AuthenticationData, passed in JSON format
851
+ * @param {getCallback} callback - a callback function to return the result
852
+ * @return {object} results - An object containing the response of the action
853
+ *
854
+ * @route {POST} /authenticateUsingPOST
855
+ * @roles admin
856
+ * @task true
857
+ */
858
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
859
+ authenticateUsingPOST(authenticationData, callback) {
860
+ const meth = 'adapter-authenticateUsingPOST';
861
+ const origin = `${this.id}-${meth}`;
862
+ log.trace(origin);
863
+
864
+ if (this.suspended && this.suspendMode === 'error') {
865
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
866
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
867
+ return callback(null, errorObj);
868
+ }
869
+
870
+ /* HERE IS WHERE YOU VALIDATE DATA */
871
+ if (authenticationData === undefined || authenticationData === null || authenticationData === '') {
872
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['authenticationData'], null, null, null);
873
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
874
+ return callback(null, errorObj);
875
+ }
876
+
877
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
878
+ const queryParamsAvailable = {};
879
+ const queryParams = {};
880
+ const pathVars = [];
881
+ const bodyVars = authenticationData;
882
+
883
+ // loop in template. long callback arg name to avoid identifier conflicts
884
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
885
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
886
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
887
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
888
+ }
889
+ });
890
+
891
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
892
+ // see adapter code documentation for more information on the request object's fields
893
+ const reqObj = {
894
+ payload: bodyVars,
895
+ uriPathVars: pathVars,
896
+ uriQuery: queryParams
897
+ };
898
+
899
+ try {
900
+ // Make the call -
901
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
902
+ return this.requestHandlerInst.identifyRequest('AuthenticationExternalController', 'authenticateUsingPOST', reqObj, true, (irReturnData, irReturnError) => {
903
+ // if we received an error or their is no response on the results
904
+ // return an error
905
+ if (irReturnError) {
906
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
907
+ return callback(null, irReturnError);
908
+ }
909
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
910
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['authenticateUsingPOST'], null, null, null);
911
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
912
+ return callback(null, errorObj);
913
+ }
914
+
915
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
916
+ // return the response
917
+ return callback(irReturnData, null);
918
+ });
919
+ } catch (ex) {
920
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
921
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
922
+ return callback(null, errorObj);
923
+ }
924
+ }
925
+
926
+ /**
927
+ * @function calculateWorkOrderUsingPOST
928
+ * @pronghornType method
929
+ * @name calculateWorkOrderUsingPOST
930
+ * @summary Trigger work order calculation for change request
931
+ *
932
+ * @param {number} changeRequestId - changeRequestId
933
+ * @param {getCallback} callback - a callback function to return the result
934
+ * @return {object} results - An object containing the response of the action
935
+ *
936
+ * @route {POST} /calculateWorkOrderUsingPOST
937
+ * @roles admin
938
+ * @task true
939
+ */
940
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
941
+ calculateWorkOrderUsingPOST(changeRequestId, callback) {
942
+ const meth = 'adapter-calculateWorkOrderUsingPOST';
943
+ const origin = `${this.id}-${meth}`;
944
+ log.trace(origin);
945
+
946
+ if (this.suspended && this.suspendMode === 'error') {
947
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
948
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
949
+ return callback(null, errorObj);
950
+ }
951
+
952
+ /* HERE IS WHERE YOU VALIDATE DATA */
953
+ if (changeRequestId === undefined || changeRequestId === null || changeRequestId === '') {
954
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['changeRequestId'], null, null, null);
955
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
956
+ return callback(null, errorObj);
957
+ }
958
+
959
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
960
+ const queryParamsAvailable = {};
961
+ const queryParams = {};
962
+ const pathVars = [changeRequestId];
963
+ const bodyVars = {};
964
+
965
+ // loop in template. long callback arg name to avoid identifier conflicts
966
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
967
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
968
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
969
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
970
+ }
971
+ });
972
+
973
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
974
+ // see adapter code documentation for more information on the request object's fields
975
+ const reqObj = {
976
+ payload: bodyVars,
977
+ uriPathVars: pathVars,
978
+ uriQuery: queryParams
979
+ };
980
+
981
+ try {
982
+ // Make the call -
983
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
984
+ return this.requestHandlerInst.identifyRequest('WorkOrderExternalController', 'calculateWorkOrderUsingPOST', reqObj, true, (irReturnData, irReturnError) => {
985
+ // if we received an error or their is no response on the results
986
+ // return an error
987
+ if (irReturnError) {
988
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
989
+ return callback(null, irReturnError);
990
+ }
991
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
992
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['calculateWorkOrderUsingPOST'], null, null, null);
993
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
994
+ return callback(null, errorObj);
995
+ }
996
+
997
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
998
+ // return the response
999
+ return callback(irReturnData, null);
1000
+ });
1001
+ } catch (ex) {
1002
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1003
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1004
+ return callback(null, errorObj);
1005
+ }
1006
+ }
1007
+
1008
+ /**
1009
+ * @function getWorkOrderCalculationStatusUsingGET
1010
+ * @pronghornType method
1011
+ * @name getWorkOrderCalculationStatusUsingGET
1012
+ * @summary Get work order calculation status for change request
1013
+ *
1014
+ * @param {number} changeRequestId - changeRequestId
1015
+ * @param {getCallback} callback - a callback function to return the result
1016
+ * @return {object} results - An object containing the response of the action
1017
+ *
1018
+ * @route {POST} /getWorkOrderCalculationStatusUsingGET
1019
+ * @roles admin
1020
+ * @task true
1021
+ */
1022
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1023
+ getWorkOrderCalculationStatusUsingGET(changeRequestId, callback) {
1024
+ const meth = 'adapter-getWorkOrderCalculationStatusUsingGET';
1025
+ const origin = `${this.id}-${meth}`;
1026
+ log.trace(origin);
1027
+
1028
+ if (this.suspended && this.suspendMode === 'error') {
1029
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1030
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1031
+ return callback(null, errorObj);
1032
+ }
1033
+
1034
+ /* HERE IS WHERE YOU VALIDATE DATA */
1035
+ if (changeRequestId === undefined || changeRequestId === null || changeRequestId === '') {
1036
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['changeRequestId'], null, null, null);
1037
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1038
+ return callback(null, errorObj);
1039
+ }
1040
+
1041
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1042
+ const queryParamsAvailable = {};
1043
+ const queryParams = {};
1044
+ const pathVars = [changeRequestId];
1045
+ const bodyVars = {};
1046
+
1047
+ // loop in template. long callback arg name to avoid identifier conflicts
1048
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1049
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1050
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1051
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1052
+ }
1053
+ });
1054
+
1055
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1056
+ // see adapter code documentation for more information on the request object's fields
1057
+ const reqObj = {
1058
+ payload: bodyVars,
1059
+ uriPathVars: pathVars,
1060
+ uriQuery: queryParams
1061
+ };
1062
+
1063
+ try {
1064
+ // Make the call -
1065
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1066
+ return this.requestHandlerInst.identifyRequest('WorkOrderExternalController', 'getWorkOrderCalculationStatusUsingGET', reqObj, true, (irReturnData, irReturnError) => {
1067
+ // if we received an error or their is no response on the results
1068
+ // return an error
1069
+ if (irReturnError) {
1070
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1071
+ return callback(null, irReturnError);
1072
+ }
1073
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1074
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getWorkOrderCalculationStatusUsingGET'], null, null, null);
1075
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1076
+ return callback(null, errorObj);
1077
+ }
1078
+
1079
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1080
+ // return the response
1081
+ return callback(irReturnData, null);
1082
+ });
1083
+ } catch (ex) {
1084
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1085
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1086
+ return callback(null, errorObj);
1087
+ }
1088
+ }
1089
+
1090
+ /**
1091
+ * @function createRuleRemovalRequestUsingPOST
1092
+ * @pronghornType method
1093
+ * @name createRuleRemovalRequestUsingPOST
1094
+ * @summary Create Rule Removal Change Request
1095
+ *
1096
+ * @param {object} ruleRemovalChangeRequest - RuleRemovalChangeRequest, passed in JSON format
1097
+
1098
+ Required fields: You must include a devices field, with a single device listed.
1099
+ Multiple devices are not supported.
1100
+ * @param {getCallback} callback - a callback function to return the result
1101
+ * @return {object} results - An object containing the response of the action
1102
+ *
1103
+ * @route {POST} /createRuleRemovalRequestUsingPOST
1104
+ * @roles admin
1105
+ * @task true
1106
+ */
1107
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1108
+ createRuleRemovalRequestUsingPOST(ruleRemovalChangeRequest, callback) {
1109
+ const meth = 'adapter-createRuleRemovalRequestUsingPOST';
1110
+ const origin = `${this.id}-${meth}`;
1111
+ log.trace(origin);
1112
+
1113
+ if (this.suspended && this.suspendMode === 'error') {
1114
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1115
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1116
+ return callback(null, errorObj);
1117
+ }
1118
+
1119
+ /* HERE IS WHERE YOU VALIDATE DATA */
1120
+ if (ruleRemovalChangeRequest === undefined || ruleRemovalChangeRequest === null || ruleRemovalChangeRequest === '') {
1121
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['ruleRemovalChangeRequest'], null, null, null);
1122
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1123
+ return callback(null, errorObj);
1124
+ }
1125
+
1126
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1127
+ const queryParamsAvailable = {};
1128
+ const queryParams = {};
1129
+ const pathVars = [];
1130
+ const bodyVars = ruleRemovalChangeRequest;
1131
+
1132
+ // loop in template. long callback arg name to avoid identifier conflicts
1133
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1134
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1135
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1136
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1137
+ }
1138
+ });
1139
+
1140
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1141
+ // see adapter code documentation for more information on the request object's fields
1142
+ const reqObj = {
1143
+ payload: bodyVars,
1144
+ uriPathVars: pathVars,
1145
+ uriQuery: queryParams
1146
+ };
1147
+
1148
+ try {
1149
+ // Make the call -
1150
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1151
+ return this.requestHandlerInst.identifyRequest('RuleRemovalChangeRequestExternalController', 'createRuleRemovalRequestUsingPOST', reqObj, true, (irReturnData, irReturnError) => {
1152
+ // if we received an error or their is no response on the results
1153
+ // return an error
1154
+ if (irReturnError) {
1155
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1156
+ return callback(null, irReturnError);
1157
+ }
1158
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1159
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createRuleRemovalRequestUsingPOST'], null, null, null);
1160
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1161
+ return callback(null, errorObj);
1162
+ }
1163
+
1164
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1165
+ // return the response
1166
+ return callback(irReturnData, null);
1167
+ });
1168
+ } catch (ex) {
1169
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1170
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1171
+ return callback(null, errorObj);
1172
+ }
1173
+ }
1174
+
1175
+ /**
1176
+ * @function createTrafficChangeRequestUsingPOST
1177
+ * @pronghornType method
1178
+ * @name createTrafficChangeRequestUsingPOST
1179
+ * @summary Create Traffic Change request
1180
+ *
1181
+ * @param {object} trafficChangeRequest - TrafficChangeRequest, passed in JSON format
1182
+ * @param {getCallback} callback - a callback function to return the result
1183
+ * @return {object} results - An object containing the response of the action
1184
+ *
1185
+ * @route {POST} /createTrafficChangeRequestUsingPOST
1186
+ * @roles admin
1187
+ * @task true
1188
+ */
1189
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1190
+ createTrafficChangeRequestUsingPOST(trafficChangeRequest, callback) {
1191
+ const meth = 'adapter-createTrafficChangeRequestUsingPOST';
1192
+ const origin = `${this.id}-${meth}`;
1193
+ log.trace(origin);
1194
+
1195
+ if (this.suspended && this.suspendMode === 'error') {
1196
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1197
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1198
+ return callback(null, errorObj);
1199
+ }
1200
+
1201
+ /* HERE IS WHERE YOU VALIDATE DATA */
1202
+ if (trafficChangeRequest === undefined || trafficChangeRequest === null || trafficChangeRequest === '') {
1203
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['trafficChangeRequest'], null, null, null);
1204
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1205
+ return callback(null, errorObj);
1206
+ }
1207
+
1208
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1209
+ const queryParamsAvailable = {};
1210
+ const queryParams = {};
1211
+ const pathVars = [];
1212
+ const bodyVars = trafficChangeRequest;
1213
+
1214
+ // loop in template. long callback arg name to avoid identifier conflicts
1215
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1216
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1217
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1218
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1219
+ }
1220
+ });
1221
+
1222
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1223
+ // see adapter code documentation for more information on the request object's fields
1224
+ const reqObj = {
1225
+ payload: bodyVars,
1226
+ uriPathVars: pathVars,
1227
+ uriQuery: queryParams
1228
+ };
1229
+
1230
+ try {
1231
+ // Make the call -
1232
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1233
+ return this.requestHandlerInst.identifyRequest('TrafficChangeRequestExternalController', 'createTrafficChangeRequestUsingPOST', reqObj, true, (irReturnData, irReturnError) => {
1234
+ // if we received an error or their is no response on the results
1235
+ // return an error
1236
+ if (irReturnError) {
1237
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1238
+ return callback(null, irReturnError);
1239
+ }
1240
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1241
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createTrafficChangeRequestUsingPOST'], null, null, null);
1242
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1243
+ return callback(null, errorObj);
1244
+ }
1245
+
1246
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1247
+ // return the response
1248
+ return callback(irReturnData, null);
1249
+ });
1250
+ } catch (ex) {
1251
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1252
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1253
+ return callback(null, errorObj);
1254
+ }
1255
+ }
1256
+
1257
+ /**
1258
+ * @function getTicketUsingGET
1259
+ * @pronghornType method
1260
+ * @name getTicketUsingGET
1261
+ * @summary Get Ticket details by change request id number
1262
+ *
1263
+ * @param {number} changeRequestId - Id of the Change Request
1264
+ * @param {getCallback} callback - a callback function to return the result
1265
+ * @return {object} results - An object containing the response of the action
1266
+ *
1267
+ * @route {POST} /getTicketUsingGET
1268
+ * @roles admin
1269
+ * @task true
1270
+ */
1271
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1272
+ getTicketUsingGET(changeRequestId, callback) {
1273
+ const meth = 'adapter-getTicketUsingGET';
1274
+ const origin = `${this.id}-${meth}`;
1275
+ log.trace(origin);
1276
+
1277
+ if (this.suspended && this.suspendMode === 'error') {
1278
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1279
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1280
+ return callback(null, errorObj);
1281
+ }
1282
+
1283
+ /* HERE IS WHERE YOU VALIDATE DATA */
1284
+ if (changeRequestId === undefined || changeRequestId === null || changeRequestId === '') {
1285
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['changeRequestId'], null, null, null);
1286
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1287
+ return callback(null, errorObj);
1288
+ }
1289
+
1290
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1291
+ const queryParamsAvailable = {};
1292
+ const queryParams = {};
1293
+ const pathVars = [changeRequestId];
1294
+ const bodyVars = {};
1295
+
1296
+ // loop in template. long callback arg name to avoid identifier conflicts
1297
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1298
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1299
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1300
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1301
+ }
1302
+ });
1303
+
1304
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1305
+ // see adapter code documentation for more information on the request object's fields
1306
+ const reqObj = {
1307
+ payload: bodyVars,
1308
+ uriPathVars: pathVars,
1309
+ uriQuery: queryParams
1310
+ };
1311
+
1312
+ try {
1313
+ // Make the call -
1314
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1315
+ return this.requestHandlerInst.identifyRequest('TrafficChangeRequestExternalController', 'getTicketUsingGET', reqObj, true, (irReturnData, irReturnError) => {
1316
+ // if we received an error or their is no response on the results
1317
+ // return an error
1318
+ if (irReturnError) {
1319
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1320
+ return callback(null, irReturnError);
1321
+ }
1322
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1323
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getTicketUsingGET'], null, null, null);
1324
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1325
+ return callback(null, errorObj);
1326
+ }
1327
+
1328
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1329
+ // return the response
1330
+ return callback(irReturnData, null);
1331
+ });
1332
+ } catch (ex) {
1333
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1334
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1335
+ return callback(null, errorObj);
1336
+ }
1337
+ }
1338
+
1339
+ /**
1340
+ * @function updateTrafficChangeRequestCustomFieldsUsingPUT
1341
+ * @pronghornType method
1342
+ * @name updateTrafficChangeRequestCustomFieldsUsingPUT
1343
+ * @summary Update Traffic Change request&#39;s custom fields
1344
+ *
1345
+ * @param {number} changeRequestId - Id of the Change request
1346
+ * @param {array} trafficChangeRequestFields - List of fields, passed in JSON format
1347
+ * @param {getCallback} callback - a callback function to return the result
1348
+ * @return {object} results - An object containing the response of the action
1349
+ *
1350
+ * @route {POST} /updateTrafficChangeRequestCustomFieldsUsingPUT
1351
+ * @roles admin
1352
+ * @task true
1353
+ */
1354
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1355
+ updateTrafficChangeRequestCustomFieldsUsingPUT(changeRequestId, trafficChangeRequestFields, callback) {
1356
+ const meth = 'adapter-updateTrafficChangeRequestCustomFieldsUsingPUT';
1357
+ const origin = `${this.id}-${meth}`;
1358
+ log.trace(origin);
1359
+
1360
+ if (this.suspended && this.suspendMode === 'error') {
1361
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1362
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1363
+ return callback(null, errorObj);
1364
+ }
1365
+
1366
+ /* HERE IS WHERE YOU VALIDATE DATA */
1367
+ if (changeRequestId === undefined || changeRequestId === null || changeRequestId === '') {
1368
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['changeRequestId'], null, null, null);
1369
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1370
+ return callback(null, errorObj);
1371
+ }
1372
+ if (trafficChangeRequestFields === undefined || trafficChangeRequestFields === null || trafficChangeRequestFields === '') {
1373
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['trafficChangeRequestFields'], null, null, null);
1374
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1375
+ return callback(null, errorObj);
1376
+ }
1377
+
1378
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1379
+ const queryParamsAvailable = {};
1380
+ const queryParams = {};
1381
+ const pathVars = [changeRequestId];
1382
+ const bodyVars = { trafficChangeRequestFields };
1383
+
1384
+ // loop in template. long callback arg name to avoid identifier conflicts
1385
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1386
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1387
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1388
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1389
+ }
1390
+ });
1391
+
1392
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1393
+ // see adapter code documentation for more information on the request object's fields
1394
+ const reqObj = {
1395
+ payload: bodyVars,
1396
+ uriPathVars: pathVars,
1397
+ uriQuery: queryParams
1398
+ };
1399
+
1400
+ try {
1401
+ // Make the call -
1402
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1403
+ return this.requestHandlerInst.identifyRequest('TrafficChangeRequestExternalController', 'updateTrafficChangeRequestCustomFieldsUsingPUT', reqObj, false, (irReturnData, irReturnError) => {
1404
+ // if we received an error or their is no response on the results
1405
+ // return an error
1406
+ if (irReturnError) {
1407
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1408
+ return callback(null, irReturnError);
1409
+ }
1410
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1411
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['updateTrafficChangeRequestCustomFieldsUsingPUT'], null, null, null);
1412
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1413
+ return callback(null, errorObj);
1414
+ }
1415
+
1416
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1417
+ // return the response
1418
+ return callback(irReturnData, null);
1419
+ });
1420
+ } catch (ex) {
1421
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1422
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1423
+ return callback(null, errorObj);
1424
+ }
1425
+ }
1426
+
1427
+ /**
1428
+ * @function calculateActiveChangeUsingPOST
1429
+ * @pronghornType method
1430
+ * @name calculateActiveChangeUsingPOST
1431
+ * @summary Implement work-order recommendations of the given change request, using ActiveChange
1432
+ *
1433
+ * @param {number} changeRequestId - changeRequestId
1434
+ * @param {getCallback} callback - a callback function to return the result
1435
+ * @return {object} results - An object containing the response of the action
1436
+ *
1437
+ * @route {POST} /calculateActiveChangeUsingPOST
1438
+ * @roles admin
1439
+ * @task true
1440
+ */
1441
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1442
+ calculateActiveChangeUsingPOST(changeRequestId, callback) {
1443
+ const meth = 'adapter-calculateActiveChangeUsingPOST';
1444
+ const origin = `${this.id}-${meth}`;
1445
+ log.trace(origin);
1446
+
1447
+ if (this.suspended && this.suspendMode === 'error') {
1448
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1449
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1450
+ return callback(null, errorObj);
1451
+ }
1452
+
1453
+ /* HERE IS WHERE YOU VALIDATE DATA */
1454
+ if (changeRequestId === undefined || changeRequestId === null || changeRequestId === '') {
1455
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['changeRequestId'], null, null, null);
1456
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1457
+ return callback(null, errorObj);
1458
+ }
1459
+
1460
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1461
+ const queryParamsAvailable = {};
1462
+ const queryParams = {};
1463
+ const pathVars = [changeRequestId];
1464
+ const bodyVars = {};
1465
+
1466
+ // loop in template. long callback arg name to avoid identifier conflicts
1467
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1468
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1469
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1470
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1471
+ }
1472
+ });
1473
+
1474
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1475
+ // see adapter code documentation for more information on the request object's fields
1476
+ const reqObj = {
1477
+ payload: bodyVars,
1478
+ uriPathVars: pathVars,
1479
+ uriQuery: queryParams
1480
+ };
1481
+
1482
+ try {
1483
+ // Make the call -
1484
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1485
+ return this.requestHandlerInst.identifyRequest('ActiveChangeExternalController', 'calculateActiveChangeUsingPOST', reqObj, true, (irReturnData, irReturnError) => {
1486
+ // if we received an error or their is no response on the results
1487
+ // return an error
1488
+ if (irReturnError) {
1489
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1490
+ return callback(null, irReturnError);
1491
+ }
1492
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1493
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['calculateActiveChangeUsingPOST'], null, null, null);
1494
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1495
+ return callback(null, errorObj);
1496
+ }
1497
+
1498
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1499
+ // return the response
1500
+ return callback(irReturnData, null);
1501
+ });
1502
+ } catch (ex) {
1503
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1504
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1505
+ return callback(null, errorObj);
1506
+ }
1507
+ }
1508
+
1509
+ /**
1510
+ * @function getActiveChangeStatusUsingGET
1511
+ * @pronghornType method
1512
+ * @name getActiveChangeStatusUsingGET
1513
+ * @summary Get ActiveChange results of the given change request
1514
+ *
1515
+ * @param {number} changeRequestId - changeRequestId
1516
+ * @param {getCallback} callback - a callback function to return the result
1517
+ * @return {object} results - An object containing the response of the action
1518
+ *
1519
+ * @route {POST} /getActiveChangeStatusUsingGET
1520
+ * @roles admin
1521
+ * @task true
1522
+ */
1523
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1524
+ getActiveChangeStatusUsingGET(changeRequestId, callback) {
1525
+ const meth = 'adapter-getActiveChangeStatusUsingGET';
1526
+ const origin = `${this.id}-${meth}`;
1527
+ log.trace(origin);
1528
+
1529
+ if (this.suspended && this.suspendMode === 'error') {
1530
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1531
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1532
+ return callback(null, errorObj);
1533
+ }
1534
+
1535
+ /* HERE IS WHERE YOU VALIDATE DATA */
1536
+ if (changeRequestId === undefined || changeRequestId === null || changeRequestId === '') {
1537
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['changeRequestId'], null, null, null);
1538
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1539
+ return callback(null, errorObj);
1540
+ }
1541
+
1542
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1543
+ const queryParamsAvailable = {};
1544
+ const queryParams = {};
1545
+ const pathVars = [changeRequestId];
1546
+ const bodyVars = {};
1547
+
1548
+ // loop in template. long callback arg name to avoid identifier conflicts
1549
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1550
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1551
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1552
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1553
+ }
1554
+ });
1555
+
1556
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1557
+ // see adapter code documentation for more information on the request object's fields
1558
+ const reqObj = {
1559
+ payload: bodyVars,
1560
+ uriPathVars: pathVars,
1561
+ uriQuery: queryParams
1562
+ };
1563
+
1564
+ try {
1565
+ // Make the call -
1566
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1567
+ return this.requestHandlerInst.identifyRequest('ActiveChangeExternalController', 'getActiveChangeStatusUsingGET', reqObj, true, (irReturnData, irReturnError) => {
1568
+ // if we received an error or their is no response on the results
1569
+ // return an error
1570
+ if (irReturnError) {
1571
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1572
+ return callback(null, irReturnError);
1573
+ }
1574
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1575
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getActiveChangeStatusUsingGET'], null, null, null);
1576
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1577
+ return callback(null, errorObj);
1578
+ }
1579
+
1580
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1581
+ // return the response
1582
+ return callback(irReturnData, null);
1583
+ });
1584
+ } catch (ex) {
1585
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1586
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1587
+ return callback(null, errorObj);
1588
+ }
1589
+ }
1590
+
1591
+ /**
1592
+ * @function createObjectChangeRequestUsingPOST
1593
+ * @pronghornType method
1594
+ * @name createObjectChangeRequestUsingPOST
1595
+ * @summary Create Object Change request
1596
+ *
1597
+ * @param {object} objectChangeRequestDetails - ObjectChangeRequestDetails, passed in JSON format
1598
+ * @param {getCallback} callback - a callback function to return the result
1599
+ * @return {object} results - An object containing the response of the action
1600
+ *
1601
+ * @route {POST} /createObjectChangeRequestUsingPOST
1602
+ * @roles admin
1603
+ * @task true
1604
+ */
1605
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1606
+ createObjectChangeRequestUsingPOST(objectChangeRequestDetails, callback) {
1607
+ const meth = 'adapter-createObjectChangeRequestUsingPOST';
1608
+ const origin = `${this.id}-${meth}`;
1609
+ log.trace(origin);
1610
+
1611
+ if (this.suspended && this.suspendMode === 'error') {
1612
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1613
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1614
+ return callback(null, errorObj);
1615
+ }
1616
+
1617
+ /* HERE IS WHERE YOU VALIDATE DATA */
1618
+ if (objectChangeRequestDetails === undefined || objectChangeRequestDetails === null || objectChangeRequestDetails === '') {
1619
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['objectChangeRequestDetails'], null, null, null);
1620
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1621
+ return callback(null, errorObj);
1622
+ }
1623
+
1624
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1625
+ const queryParamsAvailable = {};
1626
+ const queryParams = {};
1627
+ const pathVars = [];
1628
+ const bodyVars = objectChangeRequestDetails;
1629
+
1630
+ // loop in template. long callback arg name to avoid identifier conflicts
1631
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1632
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1633
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1634
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1635
+ }
1636
+ });
1637
+
1638
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1639
+ // see adapter code documentation for more information on the request object's fields
1640
+ const reqObj = {
1641
+ payload: bodyVars,
1642
+ uriPathVars: pathVars,
1643
+ uriQuery: queryParams
1644
+ };
1645
+
1646
+ try {
1647
+ // Make the call -
1648
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1649
+ return this.requestHandlerInst.identifyRequest('ObjectChangeRequestExternalController', 'createObjectChangeRequestUsingPOST', reqObj, true, (irReturnData, irReturnError) => {
1650
+ // if we received an error or their is no response on the results
1651
+ // return an error
1652
+ if (irReturnError) {
1653
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1654
+ return callback(null, irReturnError);
1655
+ }
1656
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1657
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createObjectChangeRequestUsingPOST'], null, null, null);
1658
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1659
+ return callback(null, errorObj);
1660
+ }
1661
+
1662
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1663
+ // return the response
1664
+ return callback(irReturnData, null);
1665
+ });
1666
+ } catch (ex) {
1667
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1668
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1669
+ return callback(null, errorObj);
1670
+ }
1671
+ }
1672
+
1673
+ /**
1674
+ * @function getSavedSearchByNameProxyUsingGET
1675
+ * @pronghornType method
1676
+ * @name getSavedSearchByNameProxyUsingGET
1677
+ * @summary Find Saved Search results by name
1678
+ *
1679
+ * @param {string} savedSearchName - Name of Saved Search
1680
+ * @param {getCallback} callback - a callback function to return the result
1681
+ * @return {object} results - An object containing the response of the action
1682
+ *
1683
+ * @route {POST} /getSavedSearchByNameProxyUsingGET
1684
+ * @roles admin
1685
+ * @task true
1686
+ */
1687
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1688
+ getSavedSearchByNameProxyUsingGET(savedSearchName, callback) {
1689
+ const meth = 'adapter-getSavedSearchByNameProxyUsingGET';
1690
+ const origin = `${this.id}-${meth}`;
1691
+ log.trace(origin);
1692
+
1693
+ if (this.suspended && this.suspendMode === 'error') {
1694
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1695
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1696
+ return callback(null, errorObj);
1697
+ }
1698
+
1699
+ /* HERE IS WHERE YOU VALIDATE DATA */
1700
+ if (savedSearchName === undefined || savedSearchName === null || savedSearchName === '') {
1701
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['savedSearchName'], null, null, null);
1702
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1703
+ return callback(null, errorObj);
1704
+ }
1705
+
1706
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1707
+ const queryParamsAvailable = { savedSearchName };
1708
+ const queryParams = {};
1709
+ const pathVars = [];
1710
+ const bodyVars = {};
1711
+
1712
+ // loop in template. long callback arg name to avoid identifier conflicts
1713
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1714
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1715
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1716
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1717
+ }
1718
+ });
1719
+
1720
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1721
+ // see adapter code documentation for more information on the request object's fields
1722
+ const reqObj = {
1723
+ payload: bodyVars,
1724
+ uriPathVars: pathVars,
1725
+ uriQuery: queryParams
1726
+ };
1727
+
1728
+ try {
1729
+ // Make the call -
1730
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1731
+ return this.requestHandlerInst.identifyRequest('SavedSearchController', 'getSavedSearchByNameProxyUsingGET', reqObj, true, (irReturnData, irReturnError) => {
1732
+ // if we received an error or their is no response on the results
1733
+ // return an error
1734
+ if (irReturnError) {
1735
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1736
+ return callback(null, irReturnError);
1737
+ }
1738
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1739
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getSavedSearchByNameProxyUsingGET'], null, null, null);
1740
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1741
+ return callback(null, errorObj);
1742
+ }
1743
+
1744
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1745
+ // return the response
1746
+ return callback(irReturnData, null);
1747
+ });
1748
+ } catch (ex) {
1749
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1750
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1751
+ return callback(null, errorObj);
1752
+ }
1753
+ }
1754
+
1755
+ /**
1756
+ * @function verifySessionStatusUsingGET
1757
+ * @pronghornType method
1758
+ * @name verifySessionStatusUsingGET
1759
+ * @summary Checks if a session is alive by entering a session cookie in the request header. This endpoint cannot be tested from the swagger client. Use other REST clients.
1760
+ *
1761
+ * @param {getCallback} callback - a callback function to return the result
1762
+ * @return {object} results - An object containing the response of the action
1763
+ *
1764
+ * @route {GET} /verifySessionStatusUsingGET
1765
+ * @roles admin
1766
+ * @task true
1767
+ */
1768
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1769
+ verifySessionStatusUsingGET(callback) {
1770
+ const meth = 'adapter-verifySessionStatusUsingGET';
1771
+ const origin = `${this.id}-${meth}`;
1772
+ log.trace(origin);
1773
+
1774
+ if (this.suspended && this.suspendMode === 'error') {
1775
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1776
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1777
+ return callback(null, errorObj);
1778
+ }
1779
+
1780
+ /* HERE IS WHERE YOU VALIDATE DATA */
1781
+
1782
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1783
+ const queryParamsAvailable = {};
1784
+ const queryParams = {};
1785
+ const pathVars = [];
1786
+ const bodyVars = {};
1787
+
1788
+ // loop in template. long callback arg name to avoid identifier conflicts
1789
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1790
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1791
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1792
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1793
+ }
1794
+ });
1795
+
1796
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1797
+ // see adapter code documentation for more information on the request object's fields
1798
+ const reqObj = {
1799
+ payload: bodyVars,
1800
+ uriPathVars: pathVars,
1801
+ uriQuery: queryParams
1802
+ };
1803
+
1804
+ try {
1805
+ // Make the call -
1806
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1807
+ return this.requestHandlerInst.identifyRequest('SessionExternalController', 'verifySessionStatusUsingGET', reqObj, true, (irReturnData, irReturnError) => {
1808
+ // if we received an error or their is no response on the results
1809
+ // return an error
1810
+ if (irReturnError) {
1811
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1812
+ return callback(null, irReturnError);
1813
+ }
1814
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1815
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['verifySessionStatusUsingGET'], null, null, null);
1816
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1817
+ return callback(null, errorObj);
1818
+ }
1819
+
1820
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1821
+ // return the response
1822
+ return callback(irReturnData, null);
1823
+ });
1824
+ } catch (ex) {
1825
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1826
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1827
+ return callback(null, errorObj);
1828
+ }
1829
+ }
1830
+
1831
+ /**
1832
+ * @function getTemplatesUsingGET
1833
+ * @pronghornType method
1834
+ * @name getTemplatesUsingGET
1835
+ * @summary List all permitted request templates
1836
+ *
1837
+ * @param {getCallback} callback - a callback function to return the result
1838
+ * @return {object} results - An object containing the response of the action
1839
+ *
1840
+ * @route {GET} /getTemplatesUsingGET
1841
+ * @roles admin
1842
+ * @task true
1843
+ */
1844
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1845
+ getTemplatesUsingGET(callback) {
1846
+ const meth = 'adapter-getTemplatesUsingGET';
1847
+ const origin = `${this.id}-${meth}`;
1848
+ log.trace(origin);
1849
+
1850
+ if (this.suspended && this.suspendMode === 'error') {
1851
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1852
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1853
+ return callback(null, errorObj);
1854
+ }
1855
+
1856
+ /* HERE IS WHERE YOU VALIDATE DATA */
1857
+
1858
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1859
+ const queryParamsAvailable = {};
1860
+ const queryParams = {};
1861
+ const pathVars = [];
1862
+ const bodyVars = {};
1863
+
1864
+ // loop in template. long callback arg name to avoid identifier conflicts
1865
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1866
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1867
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1868
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1869
+ }
1870
+ });
1871
+
1872
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1873
+ // see adapter code documentation for more information on the request object's fields
1874
+ const reqObj = {
1875
+ payload: bodyVars,
1876
+ uriPathVars: pathVars,
1877
+ uriQuery: queryParams
1878
+ };
1879
+
1880
+ try {
1881
+ // Make the call -
1882
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1883
+ return this.requestHandlerInst.identifyRequest('RequestTemplateExternalController', 'getTemplatesUsingGET', reqObj, true, (irReturnData, irReturnError) => {
1884
+ // if we received an error or their is no response on the results
1885
+ // return an error
1886
+ if (irReturnError) {
1887
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1888
+ return callback(null, irReturnError);
1889
+ }
1890
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1891
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getTemplatesUsingGET'], null, null, null);
1892
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1893
+ return callback(null, errorObj);
1894
+ }
1895
+
1896
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1897
+ // return the response
1898
+ return callback(irReturnData, null);
1899
+ });
1900
+ } catch (ex) {
1901
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1902
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1903
+ return callback(null, errorObj);
1904
+ }
1905
+ }
1906
+ }
1907
+
1908
+ module.exports = AlgosecFireflow;