@itentialopensource/adapter-nokia_nsp_device_configurator 0.1.3

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 (87) 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 +316 -0
  7. package/CHANGELOG.md +24 -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 +3209 -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 +52 -0
  22. package/entities/.system/mockdatafiles/getToken-default.json +3 -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/BasicRESTCONFFlow/action.json +130 -0
  28. package/entities/BasicRESTCONFFlow/mockdatafiles/getagivennetworkdevice-default.json +71 -0
  29. package/entities/BasicRESTCONFFlow/mockdatafiles/getallthenetworkdevices-default.json +140 -0
  30. package/entities/BasicRESTCONFFlow/mockdatafiles/gettheRESTCONFRoot-default.json +8 -0
  31. package/entities/BasicRESTCONFFlow/mockdatafiles/getthedatastore-default.json +6 -0
  32. package/entities/BasicRESTCONFFlow/mockdatafiles/gettheschemamounts-default.json +56 -0
  33. package/entities/BasicRESTCONFFlow/mockdatafiles/gettheyangLibrary-default.json +36 -0
  34. package/entities/BasicRESTCONFFlow/schema.json +24 -0
  35. package/entities/CreateConfigureAndDelete/action.json +64 -0
  36. package/entities/CreateConfigureAndDelete/schema.json +21 -0
  37. package/entities/GetBearerToken/action.json +24 -0
  38. package/entities/GetBearerToken/mockdatafiles/getAuthBearerToken-default.json +6 -0
  39. package/entities/GetBearerToken/schema.json +19 -0
  40. package/entities/PatchForLeafTypeEmpty/action.json +44 -0
  41. package/entities/PatchForLeafTypeEmpty/schema.json +31 -0
  42. package/entities/PlainPatch/action.json +86 -0
  43. package/entities/PlainPatch/mockdatafiles/getthelistofinterfaces-default.json +53 -0
  44. package/entities/PlainPatch/schema.json +33 -0
  45. package/entities/QOSPolicyGetCreateEdit/action.json +86 -0
  46. package/entities/QOSPolicyGetCreateEdit/mockdatafiles/getQOSSAPEgressPolicy-default.json +141 -0
  47. package/entities/QOSPolicyGetCreateEdit/mockdatafiles/getQoS-default.json +295 -0
  48. package/entities/QOSPolicyGetCreateEdit/schema.json +33 -0
  49. package/entities/Search/action.json +67 -0
  50. package/entities/Search/mockdatafiles/fieldquerytoretrieveasinglechildnodeunderthetargetresource-default.json +22 -0
  51. package/entities/Search/mockdatafiles/fieldquerytoselectmultiplefieldsunderthetargetresource-default.json +16 -0
  52. package/entities/Search/mockdatafiles/fieldquerywithsubSelectorsofanodeunderthetargetresource-default.json +17 -0
  53. package/entities/Search/schema.json +21 -0
  54. package/error.json +190 -0
  55. package/package.json +86 -0
  56. package/pronghorn.json +6190 -0
  57. package/propertiesDecorators.json +14 -0
  58. package/propertiesSchema.json +1248 -0
  59. package/refs?service=git-upload-pack +0 -0
  60. package/report/22.11Modeled-DeviceConfiguratorRestCONFAPIs.postman_collection.json-OpenApi3Json.json +10547 -0
  61. package/report/adapterInfo.json +10 -0
  62. package/report/creationReport.json +354 -0
  63. package/sampleProperties.json +195 -0
  64. package/test/integration/adapterTestBasicGet.js +83 -0
  65. package/test/integration/adapterTestConnectivity.js +93 -0
  66. package/test/integration/adapterTestIntegration.js +1026 -0
  67. package/test/unit/adapterBaseTestUnit.js +949 -0
  68. package/test/unit/adapterTestUnit.js +2233 -0
  69. package/utils/adapterInfo.js +206 -0
  70. package/utils/addAuth.js +94 -0
  71. package/utils/artifactize.js +146 -0
  72. package/utils/basicGet.js +50 -0
  73. package/utils/checkMigrate.js +63 -0
  74. package/utils/entitiesToDB.js +178 -0
  75. package/utils/findPath.js +74 -0
  76. package/utils/methodDocumentor.js +225 -0
  77. package/utils/modify.js +154 -0
  78. package/utils/packModificationScript.js +35 -0
  79. package/utils/patches2bundledDeps.js +90 -0
  80. package/utils/pre-commit.sh +32 -0
  81. package/utils/removeHooks.js +20 -0
  82. package/utils/setup.js +33 -0
  83. package/utils/tbScript.js +246 -0
  84. package/utils/tbUtils.js +490 -0
  85. package/utils/testRunner.js +298 -0
  86. package/utils/troubleshootingAdapter.js +195 -0
  87. package/workflows/README.md +3 -0
package/adapter.js ADDED
@@ -0,0 +1,3209 @@
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 Nokia_nsp_device_configurator
17
+ */
18
+
19
+ /* GENERAL ADAPTER FUNCTIONS */
20
+ class NokiaNspDeviceConfigurator extends AdapterBaseCl {
21
+ /**
22
+ * NokiaNspDeviceConfigurator 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 getAuthBearerToken
846
+ * @pronghornType method
847
+ * @name getAuthBearerToken
848
+ * @summary Get Auth Bearer Token
849
+ *
850
+ * @param {object} body - body param
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} /getAuthBearerToken
855
+ * @roles admin
856
+ * @task true
857
+ */
858
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
859
+ getAuthBearerToken(body, callback) {
860
+ const meth = 'adapter-getAuthBearerToken';
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 (body === undefined || body === null || body === '') {
872
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], 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 = body;
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('GetBearerToken', 'getAuthBearerToken', 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', ['getAuthBearerToken'], 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 gettheRESTCONFRoot
928
+ * @pronghornType method
929
+ * @name gettheRESTCONFRoot
930
+ * @summary 1. Get the RESTCONF Root
931
+ *
932
+ * @param {getCallback} callback - a callback function to return the result
933
+ * @return {object} results - An object containing the response of the action
934
+ *
935
+ * @route {GET} /gettheRESTCONFRoot
936
+ * @roles admin
937
+ * @task true
938
+ */
939
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
940
+ gettheRESTCONFRoot(callback) {
941
+ const meth = 'adapter-gettheRESTCONFRoot';
942
+ const origin = `${this.id}-${meth}`;
943
+ log.trace(origin);
944
+
945
+ if (this.suspended && this.suspendMode === 'error') {
946
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
947
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
948
+ return callback(null, errorObj);
949
+ }
950
+
951
+ /* HERE IS WHERE YOU VALIDATE DATA */
952
+
953
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
954
+ const queryParamsAvailable = {};
955
+ const queryParams = {};
956
+ const pathVars = [];
957
+ const bodyVars = {};
958
+
959
+ // loop in template. long callback arg name to avoid identifier conflicts
960
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
961
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
962
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
963
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
964
+ }
965
+ });
966
+
967
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
968
+ let thisHeaderData = null;
969
+ // if the additional headers was passed in as a string parse the json into an object
970
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
971
+ try {
972
+ // parse the additional headers object that was passed in
973
+ thisHeaderData = JSON.parse(thisHeaderData);
974
+ } catch (err) {
975
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
976
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
977
+ return callback(null, errorObj);
978
+ }
979
+ } else if (thisHeaderData === null) {
980
+ thisHeaderData = {};
981
+ }
982
+
983
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
984
+ // see adapter code documentation for more information on the request object's fields
985
+ const reqObj = {
986
+ payload: bodyVars,
987
+ uriPathVars: pathVars,
988
+ uriQuery: queryParams,
989
+ addlHeaders: thisHeaderData
990
+ };
991
+
992
+ try {
993
+ // Make the call -
994
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
995
+ return this.requestHandlerInst.identifyRequest('BasicRESTCONFFlow', 'gettheRESTCONFRoot', reqObj, true, (irReturnData, irReturnError) => {
996
+ // if we received an error or their is no response on the results
997
+ // return an error
998
+ if (irReturnError) {
999
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1000
+ return callback(null, irReturnError);
1001
+ }
1002
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1003
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['gettheRESTCONFRoot'], null, null, null);
1004
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1005
+ return callback(null, errorObj);
1006
+ }
1007
+
1008
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1009
+ // return the response
1010
+ return callback(irReturnData, null);
1011
+ });
1012
+ } catch (ex) {
1013
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1014
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1015
+ return callback(null, errorObj);
1016
+ }
1017
+ }
1018
+
1019
+ /**
1020
+ * @function getthedatastore
1021
+ * @pronghornType method
1022
+ * @name getthedatastore
1023
+ * @summary 2. Get the data store
1024
+ *
1025
+ * @param {getCallback} callback - a callback function to return the result
1026
+ * @return {object} results - An object containing the response of the action
1027
+ *
1028
+ * @route {GET} /getthedatastore
1029
+ * @roles admin
1030
+ * @task true
1031
+ */
1032
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1033
+ getthedatastore(callback) {
1034
+ const meth = 'adapter-getthedatastore';
1035
+ const origin = `${this.id}-${meth}`;
1036
+ log.trace(origin);
1037
+
1038
+ if (this.suspended && this.suspendMode === 'error') {
1039
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1040
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1041
+ return callback(null, errorObj);
1042
+ }
1043
+
1044
+ /* HERE IS WHERE YOU VALIDATE DATA */
1045
+
1046
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1047
+ const queryParamsAvailable = {};
1048
+ const queryParams = {};
1049
+ const pathVars = [];
1050
+ const bodyVars = {};
1051
+
1052
+ // loop in template. long callback arg name to avoid identifier conflicts
1053
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1054
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1055
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1056
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1057
+ }
1058
+ });
1059
+
1060
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1061
+ let thisHeaderData = null;
1062
+ // if the additional headers was passed in as a string parse the json into an object
1063
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1064
+ try {
1065
+ // parse the additional headers object that was passed in
1066
+ thisHeaderData = JSON.parse(thisHeaderData);
1067
+ } catch (err) {
1068
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1069
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1070
+ return callback(null, errorObj);
1071
+ }
1072
+ } else if (thisHeaderData === null) {
1073
+ thisHeaderData = {};
1074
+ }
1075
+
1076
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1077
+ // see adapter code documentation for more information on the request object's fields
1078
+ const reqObj = {
1079
+ payload: bodyVars,
1080
+ uriPathVars: pathVars,
1081
+ uriQuery: queryParams,
1082
+ addlHeaders: thisHeaderData
1083
+ };
1084
+
1085
+ try {
1086
+ // Make the call -
1087
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1088
+ return this.requestHandlerInst.identifyRequest('BasicRESTCONFFlow', 'getthedatastore', reqObj, true, (irReturnData, irReturnError) => {
1089
+ // if we received an error or their is no response on the results
1090
+ // return an error
1091
+ if (irReturnError) {
1092
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1093
+ return callback(null, irReturnError);
1094
+ }
1095
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1096
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getthedatastore'], null, null, null);
1097
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1098
+ return callback(null, errorObj);
1099
+ }
1100
+
1101
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1102
+ // return the response
1103
+ return callback(irReturnData, null);
1104
+ });
1105
+ } catch (ex) {
1106
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1107
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1108
+ return callback(null, errorObj);
1109
+ }
1110
+ }
1111
+
1112
+ /**
1113
+ * @function gettheyangLibrary
1114
+ * @pronghornType method
1115
+ * @name gettheyangLibrary
1116
+ * @summary 3. Get the yang-library
1117
+ *
1118
+ * @param {getCallback} callback - a callback function to return the result
1119
+ * @return {object} results - An object containing the response of the action
1120
+ *
1121
+ * @route {GET} /gettheyangLibrary
1122
+ * @roles admin
1123
+ * @task true
1124
+ */
1125
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1126
+ gettheyangLibrary(callback) {
1127
+ const meth = 'adapter-gettheyangLibrary';
1128
+ const origin = `${this.id}-${meth}`;
1129
+ log.trace(origin);
1130
+
1131
+ if (this.suspended && this.suspendMode === 'error') {
1132
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1133
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1134
+ return callback(null, errorObj);
1135
+ }
1136
+
1137
+ /* HERE IS WHERE YOU VALIDATE DATA */
1138
+
1139
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1140
+ const queryParamsAvailable = {};
1141
+ const queryParams = {};
1142
+ const pathVars = [];
1143
+ const bodyVars = {};
1144
+
1145
+ // loop in template. long callback arg name to avoid identifier conflicts
1146
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1147
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1148
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1149
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1150
+ }
1151
+ });
1152
+
1153
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1154
+ let thisHeaderData = null;
1155
+ // if the additional headers was passed in as a string parse the json into an object
1156
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1157
+ try {
1158
+ // parse the additional headers object that was passed in
1159
+ thisHeaderData = JSON.parse(thisHeaderData);
1160
+ } catch (err) {
1161
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1162
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1163
+ return callback(null, errorObj);
1164
+ }
1165
+ } else if (thisHeaderData === null) {
1166
+ thisHeaderData = {};
1167
+ }
1168
+
1169
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1170
+ // see adapter code documentation for more information on the request object's fields
1171
+ const reqObj = {
1172
+ payload: bodyVars,
1173
+ uriPathVars: pathVars,
1174
+ uriQuery: queryParams,
1175
+ addlHeaders: thisHeaderData
1176
+ };
1177
+
1178
+ try {
1179
+ // Make the call -
1180
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1181
+ return this.requestHandlerInst.identifyRequest('BasicRESTCONFFlow', 'gettheyangLibrary', reqObj, true, (irReturnData, irReturnError) => {
1182
+ // if we received an error or their is no response on the results
1183
+ // return an error
1184
+ if (irReturnError) {
1185
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1186
+ return callback(null, irReturnError);
1187
+ }
1188
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1189
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['gettheyangLibrary'], null, null, null);
1190
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1191
+ return callback(null, errorObj);
1192
+ }
1193
+
1194
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1195
+ // return the response
1196
+ return callback(irReturnData, null);
1197
+ });
1198
+ } catch (ex) {
1199
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1200
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1201
+ return callback(null, errorObj);
1202
+ }
1203
+ }
1204
+
1205
+ /**
1206
+ * @function gettheschemamounts
1207
+ * @pronghornType method
1208
+ * @name gettheschemamounts
1209
+ * @summary 4. Get the schema mounts
1210
+ *
1211
+ * @param {getCallback} callback - a callback function to return the result
1212
+ * @return {object} results - An object containing the response of the action
1213
+ *
1214
+ * @route {GET} /gettheschemamounts
1215
+ * @roles admin
1216
+ * @task true
1217
+ */
1218
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1219
+ gettheschemamounts(callback) {
1220
+ const meth = 'adapter-gettheschemamounts';
1221
+ const origin = `${this.id}-${meth}`;
1222
+ log.trace(origin);
1223
+
1224
+ if (this.suspended && this.suspendMode === 'error') {
1225
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1226
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1227
+ return callback(null, errorObj);
1228
+ }
1229
+
1230
+ /* HERE IS WHERE YOU VALIDATE DATA */
1231
+
1232
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1233
+ const queryParamsAvailable = {};
1234
+ const queryParams = {};
1235
+ const pathVars = [];
1236
+ const bodyVars = {};
1237
+
1238
+ // loop in template. long callback arg name to avoid identifier conflicts
1239
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1240
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1241
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1242
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1243
+ }
1244
+ });
1245
+
1246
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1247
+ let thisHeaderData = null;
1248
+ // if the additional headers was passed in as a string parse the json into an object
1249
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1250
+ try {
1251
+ // parse the additional headers object that was passed in
1252
+ thisHeaderData = JSON.parse(thisHeaderData);
1253
+ } catch (err) {
1254
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1255
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1256
+ return callback(null, errorObj);
1257
+ }
1258
+ } else if (thisHeaderData === null) {
1259
+ thisHeaderData = {};
1260
+ }
1261
+
1262
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1263
+ // see adapter code documentation for more information on the request object's fields
1264
+ const reqObj = {
1265
+ payload: bodyVars,
1266
+ uriPathVars: pathVars,
1267
+ uriQuery: queryParams,
1268
+ addlHeaders: thisHeaderData
1269
+ };
1270
+
1271
+ try {
1272
+ // Make the call -
1273
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1274
+ return this.requestHandlerInst.identifyRequest('BasicRESTCONFFlow', 'gettheschemamounts', reqObj, true, (irReturnData, irReturnError) => {
1275
+ // if we received an error or their is no response on the results
1276
+ // return an error
1277
+ if (irReturnError) {
1278
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1279
+ return callback(null, irReturnError);
1280
+ }
1281
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1282
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['gettheschemamounts'], null, null, null);
1283
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1284
+ return callback(null, errorObj);
1285
+ }
1286
+
1287
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1288
+ // return the response
1289
+ return callback(irReturnData, null);
1290
+ });
1291
+ } catch (ex) {
1292
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1293
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1294
+ return callback(null, errorObj);
1295
+ }
1296
+ }
1297
+
1298
+ /**
1299
+ * @function getallthenetworkdevices
1300
+ * @pronghornType method
1301
+ * @name getallthenetworkdevices
1302
+ * @summary 5. Get all the network devices
1303
+ *
1304
+ * @param {getCallback} callback - a callback function to return the result
1305
+ * @return {object} results - An object containing the response of the action
1306
+ *
1307
+ * @route {GET} /getallthenetworkdevices
1308
+ * @roles admin
1309
+ * @task true
1310
+ */
1311
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1312
+ getallthenetworkdevices(callback) {
1313
+ const meth = 'adapter-getallthenetworkdevices';
1314
+ const origin = `${this.id}-${meth}`;
1315
+ log.trace(origin);
1316
+
1317
+ if (this.suspended && this.suspendMode === 'error') {
1318
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1319
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1320
+ return callback(null, errorObj);
1321
+ }
1322
+
1323
+ /* HERE IS WHERE YOU VALIDATE DATA */
1324
+
1325
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1326
+ const queryParamsAvailable = {};
1327
+ const queryParams = {};
1328
+ const pathVars = [];
1329
+ const bodyVars = {};
1330
+
1331
+ // loop in template. long callback arg name to avoid identifier conflicts
1332
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1333
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1334
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1335
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1336
+ }
1337
+ });
1338
+
1339
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1340
+ let thisHeaderData = null;
1341
+ // if the additional headers was passed in as a string parse the json into an object
1342
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1343
+ try {
1344
+ // parse the additional headers object that was passed in
1345
+ thisHeaderData = JSON.parse(thisHeaderData);
1346
+ } catch (err) {
1347
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1348
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1349
+ return callback(null, errorObj);
1350
+ }
1351
+ } else if (thisHeaderData === null) {
1352
+ thisHeaderData = {};
1353
+ }
1354
+
1355
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1356
+ // see adapter code documentation for more information on the request object's fields
1357
+ const reqObj = {
1358
+ payload: bodyVars,
1359
+ uriPathVars: pathVars,
1360
+ uriQuery: queryParams,
1361
+ addlHeaders: thisHeaderData
1362
+ };
1363
+
1364
+ try {
1365
+ // Make the call -
1366
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1367
+ return this.requestHandlerInst.identifyRequest('BasicRESTCONFFlow', 'getallthenetworkdevices', reqObj, true, (irReturnData, irReturnError) => {
1368
+ // if we received an error or their is no response on the results
1369
+ // return an error
1370
+ if (irReturnError) {
1371
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1372
+ return callback(null, irReturnError);
1373
+ }
1374
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1375
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getallthenetworkdevices'], null, null, null);
1376
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1377
+ return callback(null, errorObj);
1378
+ }
1379
+
1380
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1381
+ // return the response
1382
+ return callback(irReturnData, null);
1383
+ });
1384
+ } catch (ex) {
1385
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1386
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1387
+ return callback(null, errorObj);
1388
+ }
1389
+ }
1390
+
1391
+ /**
1392
+ * @function getagivennetworkdevice
1393
+ * @pronghornType method
1394
+ * @name getagivennetworkdevice
1395
+ * @summary 6. Get a given network device
1396
+ *
1397
+ * @param {string} neId - neId param
1398
+ * @param {getCallback} callback - a callback function to return the result
1399
+ * @return {object} results - An object containing the response of the action
1400
+ *
1401
+ * @route {POST} /getagivennetworkdevice
1402
+ * @roles admin
1403
+ * @task true
1404
+ */
1405
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1406
+ getagivennetworkdevice(neId, callback) {
1407
+ const meth = 'adapter-getagivennetworkdevice';
1408
+ const origin = `${this.id}-${meth}`;
1409
+ log.trace(origin);
1410
+
1411
+ if (this.suspended && this.suspendMode === 'error') {
1412
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1413
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1414
+ return callback(null, errorObj);
1415
+ }
1416
+
1417
+ /* HERE IS WHERE YOU VALIDATE DATA */
1418
+ if (neId === undefined || neId === null || neId === '') {
1419
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['neId'], null, null, null);
1420
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1421
+ return callback(null, errorObj);
1422
+ }
1423
+
1424
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1425
+ const queryParamsAvailable = {};
1426
+ const queryParams = {};
1427
+ const pathVars = [`network-device=${neId}`];
1428
+ const bodyVars = {};
1429
+
1430
+ // loop in template. long callback arg name to avoid identifier conflicts
1431
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1432
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1433
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1434
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1435
+ }
1436
+ });
1437
+
1438
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1439
+ let thisHeaderData = null;
1440
+ // if the additional headers was passed in as a string parse the json into an object
1441
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1442
+ try {
1443
+ // parse the additional headers object that was passed in
1444
+ thisHeaderData = JSON.parse(thisHeaderData);
1445
+ } catch (err) {
1446
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1447
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1448
+ return callback(null, errorObj);
1449
+ }
1450
+ } else if (thisHeaderData === null) {
1451
+ thisHeaderData = {};
1452
+ }
1453
+
1454
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1455
+ // see adapter code documentation for more information on the request object's fields
1456
+ const reqObj = {
1457
+ payload: bodyVars,
1458
+ uriPathVars: pathVars,
1459
+ uriQuery: queryParams,
1460
+ addlHeaders: thisHeaderData
1461
+ };
1462
+
1463
+ try {
1464
+ // Make the call -
1465
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1466
+ return this.requestHandlerInst.identifyRequest('BasicRESTCONFFlow', 'getagivennetworkdevice', reqObj, true, (irReturnData, irReturnError) => {
1467
+ // if we received an error or their is no response on the results
1468
+ // return an error
1469
+ if (irReturnError) {
1470
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1471
+ return callback(null, irReturnError);
1472
+ }
1473
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1474
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getagivennetworkdevice'], null, null, null);
1475
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1476
+ return callback(null, errorObj);
1477
+ }
1478
+
1479
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1480
+ // return the response
1481
+ return callback(irReturnData, null);
1482
+ });
1483
+ } catch (ex) {
1484
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1485
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1486
+ return callback(null, errorObj);
1487
+ }
1488
+ }
1489
+
1490
+ /**
1491
+ * @function createMDA
1492
+ * @pronghornType method
1493
+ * @name createMDA
1494
+ * @summary Create MDA
1495
+ *
1496
+ * @param {string} neId - neId param
1497
+ * @param {string} cardId - cardId param
1498
+ * @param {object} body - body param
1499
+ * @param {getCallback} callback - a callback function to return the result
1500
+ * @return {object} results - An object containing the response of the action
1501
+ *
1502
+ * @route {POST} /createMDA
1503
+ * @roles admin
1504
+ * @task true
1505
+ */
1506
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1507
+ createMDA(neId, cardId, body, callback) {
1508
+ const meth = 'adapter-createMDA';
1509
+ const origin = `${this.id}-${meth}`;
1510
+ log.trace(origin);
1511
+
1512
+ if (this.suspended && this.suspendMode === 'error') {
1513
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1514
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1515
+ return callback(null, errorObj);
1516
+ }
1517
+
1518
+ /* HERE IS WHERE YOU VALIDATE DATA */
1519
+ if (neId === undefined || neId === null || neId === '') {
1520
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['neId'], null, null, null);
1521
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1522
+ return callback(null, errorObj);
1523
+ }
1524
+ if (cardId === undefined || cardId === null || cardId === '') {
1525
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['cardId'], null, null, null);
1526
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1527
+ return callback(null, errorObj);
1528
+ }
1529
+ if (body === undefined || body === null || body === '') {
1530
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1531
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1532
+ return callback(null, errorObj);
1533
+ }
1534
+
1535
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1536
+ const queryParamsAvailable = {};
1537
+ const queryParams = {};
1538
+ const pathVars = [`network-device=${neId}`, `card=${cardId}`];
1539
+ const bodyVars = body;
1540
+
1541
+ // loop in template. long callback arg name to avoid identifier conflicts
1542
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1543
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1544
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1545
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1546
+ }
1547
+ });
1548
+
1549
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1550
+ let thisHeaderData = null;
1551
+ // if the additional headers was passed in as a string parse the json into an object
1552
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1553
+ try {
1554
+ // parse the additional headers object that was passed in
1555
+ thisHeaderData = JSON.parse(thisHeaderData);
1556
+ } catch (err) {
1557
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1558
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1559
+ return callback(null, errorObj);
1560
+ }
1561
+ } else if (thisHeaderData === null) {
1562
+ thisHeaderData = {};
1563
+ }
1564
+
1565
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1566
+ // see adapter code documentation for more information on the request object's fields
1567
+ const reqObj = {
1568
+ payload: bodyVars,
1569
+ uriPathVars: pathVars,
1570
+ uriQuery: queryParams,
1571
+ addlHeaders: thisHeaderData
1572
+ };
1573
+
1574
+ try {
1575
+ // Make the call -
1576
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1577
+ return this.requestHandlerInst.identifyRequest('CreateConfigureAndDelete', 'createMDA', reqObj, true, (irReturnData, irReturnError) => {
1578
+ // if we received an error or their is no response on the results
1579
+ // return an error
1580
+ if (irReturnError) {
1581
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1582
+ return callback(null, irReturnError);
1583
+ }
1584
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1585
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createMDA'], null, null, null);
1586
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1587
+ return callback(null, errorObj);
1588
+ }
1589
+
1590
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1591
+ // return the response
1592
+ return callback(irReturnData, null);
1593
+ });
1594
+ } catch (ex) {
1595
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1596
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1597
+ return callback(null, errorObj);
1598
+ }
1599
+ }
1600
+
1601
+ /**
1602
+ * @function configureMDA
1603
+ * @pronghornType method
1604
+ * @name configureMDA
1605
+ * @summary Configure MDA
1606
+ *
1607
+ * @param {string} neId - neId param
1608
+ * @param {string} cardId - cardId param
1609
+ * @param {string} mdaId - mdaId param
1610
+ * @param {object} body - body param
1611
+ * @param {getCallback} callback - a callback function to return the result
1612
+ * @return {object} results - An object containing the response of the action
1613
+ *
1614
+ * @route {POST} /configureMDA
1615
+ * @roles admin
1616
+ * @task true
1617
+ */
1618
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1619
+ configureMDA(neId, cardId, mdaId, body, callback) {
1620
+ const meth = 'adapter-configureMDA';
1621
+ const origin = `${this.id}-${meth}`;
1622
+ log.trace(origin);
1623
+
1624
+ if (this.suspended && this.suspendMode === 'error') {
1625
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1626
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1627
+ return callback(null, errorObj);
1628
+ }
1629
+
1630
+ /* HERE IS WHERE YOU VALIDATE DATA */
1631
+ if (neId === undefined || neId === null || neId === '') {
1632
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['neId'], null, null, null);
1633
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1634
+ return callback(null, errorObj);
1635
+ }
1636
+ if (cardId === undefined || cardId === null || cardId === '') {
1637
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['cardId'], null, null, null);
1638
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1639
+ return callback(null, errorObj);
1640
+ }
1641
+ if (mdaId === undefined || mdaId === null || mdaId === '') {
1642
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['mdaId'], null, null, null);
1643
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1644
+ return callback(null, errorObj);
1645
+ }
1646
+ if (body === undefined || body === null || body === '') {
1647
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1648
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1649
+ return callback(null, errorObj);
1650
+ }
1651
+
1652
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1653
+ const queryParamsAvailable = {};
1654
+ const queryParams = {};
1655
+ const pathVars = [`network-device=${neId}`, `card=${cardId}`, `mda=${mdaId}`];
1656
+ const bodyVars = body;
1657
+
1658
+ // loop in template. long callback arg name to avoid identifier conflicts
1659
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1660
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1661
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1662
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1663
+ }
1664
+ });
1665
+
1666
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1667
+ let thisHeaderData = null;
1668
+ // if the additional headers was passed in as a string parse the json into an object
1669
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1670
+ try {
1671
+ // parse the additional headers object that was passed in
1672
+ thisHeaderData = JSON.parse(thisHeaderData);
1673
+ } catch (err) {
1674
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1675
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1676
+ return callback(null, errorObj);
1677
+ }
1678
+ } else if (thisHeaderData === null) {
1679
+ thisHeaderData = {};
1680
+ }
1681
+
1682
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1683
+ // see adapter code documentation for more information on the request object's fields
1684
+ const reqObj = {
1685
+ payload: bodyVars,
1686
+ uriPathVars: pathVars,
1687
+ uriQuery: queryParams,
1688
+ addlHeaders: thisHeaderData
1689
+ };
1690
+
1691
+ try {
1692
+ // Make the call -
1693
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1694
+ return this.requestHandlerInst.identifyRequest('CreateConfigureAndDelete', 'configureMDA', reqObj, false, (irReturnData, irReturnError) => {
1695
+ // if we received an error or their is no response on the results
1696
+ // return an error
1697
+ if (irReturnError) {
1698
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1699
+ return callback(null, irReturnError);
1700
+ }
1701
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1702
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['configureMDA'], null, null, null);
1703
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1704
+ return callback(null, errorObj);
1705
+ }
1706
+
1707
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1708
+ // return the response
1709
+ return callback(irReturnData, null);
1710
+ });
1711
+ } catch (ex) {
1712
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1713
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1714
+ return callback(null, errorObj);
1715
+ }
1716
+ }
1717
+
1718
+ /**
1719
+ * @function deleteMDA
1720
+ * @pronghornType method
1721
+ * @name deleteMDA
1722
+ * @summary Delete MDA
1723
+ *
1724
+ * @param {string} neId - neId param
1725
+ * @param {string} cardId - cardId param
1726
+ * @param {string} mdaId - mdaId param
1727
+ * @param {getCallback} callback - a callback function to return the result
1728
+ * @return {object} results - An object containing the response of the action
1729
+ *
1730
+ * @route {POST} /deleteMDA
1731
+ * @roles admin
1732
+ * @task true
1733
+ */
1734
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1735
+ deleteMDA(neId, cardId, mdaId, callback) {
1736
+ const meth = 'adapter-deleteMDA';
1737
+ const origin = `${this.id}-${meth}`;
1738
+ log.trace(origin);
1739
+
1740
+ if (this.suspended && this.suspendMode === 'error') {
1741
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1742
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1743
+ return callback(null, errorObj);
1744
+ }
1745
+
1746
+ /* HERE IS WHERE YOU VALIDATE DATA */
1747
+ if (neId === undefined || neId === null || neId === '') {
1748
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['neId'], null, null, null);
1749
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1750
+ return callback(null, errorObj);
1751
+ }
1752
+ if (cardId === undefined || cardId === null || cardId === '') {
1753
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['cardId'], null, null, null);
1754
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1755
+ return callback(null, errorObj);
1756
+ }
1757
+ if (mdaId === undefined || mdaId === null || mdaId === '') {
1758
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['mdaId'], null, null, null);
1759
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1760
+ return callback(null, errorObj);
1761
+ }
1762
+
1763
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1764
+ const queryParamsAvailable = {};
1765
+ const queryParams = {};
1766
+ const pathVars = [`network-device=${neId}`, `card=${cardId}`, `mda=${mdaId}`];
1767
+ const bodyVars = {};
1768
+
1769
+ // loop in template. long callback arg name to avoid identifier conflicts
1770
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1771
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1772
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1773
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1774
+ }
1775
+ });
1776
+
1777
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1778
+ let thisHeaderData = null;
1779
+ // if the additional headers was passed in as a string parse the json into an object
1780
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1781
+ try {
1782
+ // parse the additional headers object that was passed in
1783
+ thisHeaderData = JSON.parse(thisHeaderData);
1784
+ } catch (err) {
1785
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1786
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1787
+ return callback(null, errorObj);
1788
+ }
1789
+ } else if (thisHeaderData === null) {
1790
+ thisHeaderData = {};
1791
+ }
1792
+
1793
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1794
+ // see adapter code documentation for more information on the request object's fields
1795
+ const reqObj = {
1796
+ payload: bodyVars,
1797
+ uriPathVars: pathVars,
1798
+ uriQuery: queryParams,
1799
+ addlHeaders: thisHeaderData
1800
+ };
1801
+
1802
+ try {
1803
+ // Make the call -
1804
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1805
+ return this.requestHandlerInst.identifyRequest('CreateConfigureAndDelete', 'deleteMDA', reqObj, false, (irReturnData, irReturnError) => {
1806
+ // if we received an error or their is no response on the results
1807
+ // return an error
1808
+ if (irReturnError) {
1809
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1810
+ return callback(null, irReturnError);
1811
+ }
1812
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1813
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteMDA'], null, null, null);
1814
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1815
+ return callback(null, errorObj);
1816
+ }
1817
+
1818
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1819
+ // return the response
1820
+ return callback(irReturnData, null);
1821
+ });
1822
+ } catch (ex) {
1823
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1824
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1825
+ return callback(null, errorObj);
1826
+ }
1827
+ }
1828
+
1829
+ /**
1830
+ * @function createInterface
1831
+ * @pronghornType method
1832
+ * @name createInterface
1833
+ * @summary Create Interface
1834
+ *
1835
+ * @param {string} neId - neId param
1836
+ * @param {string} router - router param
1837
+ * @param {string} interfaceParam - interfaceParam param
1838
+ * @param {object} body - body param
1839
+ * @param {getCallback} callback - a callback function to return the result
1840
+ * @return {object} results - An object containing the response of the action
1841
+ *
1842
+ * @route {POST} /createInterface
1843
+ * @roles admin
1844
+ * @task true
1845
+ */
1846
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1847
+ createInterface(neId, router, interfaceParam, body, callback) {
1848
+ const meth = 'adapter-createInterface';
1849
+ const origin = `${this.id}-${meth}`;
1850
+ log.trace(origin);
1851
+
1852
+ if (this.suspended && this.suspendMode === 'error') {
1853
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1854
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1855
+ return callback(null, errorObj);
1856
+ }
1857
+
1858
+ /* HERE IS WHERE YOU VALIDATE DATA */
1859
+ if (neId === undefined || neId === null || neId === '') {
1860
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['neId'], null, null, null);
1861
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1862
+ return callback(null, errorObj);
1863
+ }
1864
+ if (router === undefined || router === null || router === '') {
1865
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['router'], null, null, null);
1866
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1867
+ return callback(null, errorObj);
1868
+ }
1869
+ if (interfaceParam === undefined || interfaceParam === null || interfaceParam === '') {
1870
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['interfaceParam'], null, null, null);
1871
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1872
+ return callback(null, errorObj);
1873
+ }
1874
+ if (body === undefined || body === null || body === '') {
1875
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1876
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1877
+ return callback(null, errorObj);
1878
+ }
1879
+
1880
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1881
+ const queryParamsAvailable = {};
1882
+ const queryParams = {};
1883
+ const pathVars = [`network-device=${neId}`, `router=${router}`, `interface=${interfaceParam}`];
1884
+ const bodyVars = body;
1885
+
1886
+ // loop in template. long callback arg name to avoid identifier conflicts
1887
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1888
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1889
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1890
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1891
+ }
1892
+ });
1893
+
1894
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1895
+ let thisHeaderData = null;
1896
+ // if the additional headers was passed in as a string parse the json into an object
1897
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1898
+ try {
1899
+ // parse the additional headers object that was passed in
1900
+ thisHeaderData = JSON.parse(thisHeaderData);
1901
+ } catch (err) {
1902
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1903
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1904
+ return callback(null, errorObj);
1905
+ }
1906
+ } else if (thisHeaderData === null) {
1907
+ thisHeaderData = {};
1908
+ }
1909
+
1910
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1911
+ // see adapter code documentation for more information on the request object's fields
1912
+ const reqObj = {
1913
+ payload: bodyVars,
1914
+ uriPathVars: pathVars,
1915
+ uriQuery: queryParams,
1916
+ addlHeaders: thisHeaderData
1917
+ };
1918
+
1919
+ try {
1920
+ // Make the call -
1921
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1922
+ return this.requestHandlerInst.identifyRequest('PlainPatch', 'createInterface', reqObj, false, (irReturnData, irReturnError) => {
1923
+ // if we received an error or their is no response on the results
1924
+ // return an error
1925
+ if (irReturnError) {
1926
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1927
+ return callback(null, irReturnError);
1928
+ }
1929
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1930
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createInterface'], null, null, null);
1931
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1932
+ return callback(null, errorObj);
1933
+ }
1934
+
1935
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1936
+ // return the response
1937
+ return callback(irReturnData, null);
1938
+ });
1939
+ } catch (ex) {
1940
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1941
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1942
+ return callback(null, errorObj);
1943
+ }
1944
+ }
1945
+
1946
+ /**
1947
+ * @function getthelistofinterfaces
1948
+ * @pronghornType method
1949
+ * @name getthelistofinterfaces
1950
+ * @summary Get the list of interfaces
1951
+ *
1952
+ * @param {string} neId - neId param
1953
+ * @param {string} router - router param
1954
+ * @param {getCallback} callback - a callback function to return the result
1955
+ * @return {object} results - An object containing the response of the action
1956
+ *
1957
+ * @route {POST} /getthelistofinterfaces
1958
+ * @roles admin
1959
+ * @task true
1960
+ */
1961
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1962
+ getthelistofinterfaces(neId, router, callback) {
1963
+ const meth = 'adapter-getthelistofinterfaces';
1964
+ const origin = `${this.id}-${meth}`;
1965
+ log.trace(origin);
1966
+
1967
+ if (this.suspended && this.suspendMode === 'error') {
1968
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1969
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1970
+ return callback(null, errorObj);
1971
+ }
1972
+
1973
+ /* HERE IS WHERE YOU VALIDATE DATA */
1974
+ if (neId === undefined || neId === null || neId === '') {
1975
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['neId'], null, null, null);
1976
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1977
+ return callback(null, errorObj);
1978
+ }
1979
+ if (router === undefined || router === null || router === '') {
1980
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['router'], null, null, null);
1981
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1982
+ return callback(null, errorObj);
1983
+ }
1984
+
1985
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1986
+ const queryParamsAvailable = {};
1987
+ const queryParams = {};
1988
+ const pathVars = [`network-device=${neId}`, `router=${router}`];
1989
+ const bodyVars = {};
1990
+
1991
+ // loop in template. long callback arg name to avoid identifier conflicts
1992
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1993
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1994
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1995
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1996
+ }
1997
+ });
1998
+
1999
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2000
+ let thisHeaderData = null;
2001
+ // if the additional headers was passed in as a string parse the json into an object
2002
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2003
+ try {
2004
+ // parse the additional headers object that was passed in
2005
+ thisHeaderData = JSON.parse(thisHeaderData);
2006
+ } catch (err) {
2007
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2008
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2009
+ return callback(null, errorObj);
2010
+ }
2011
+ } else if (thisHeaderData === null) {
2012
+ thisHeaderData = {};
2013
+ }
2014
+
2015
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2016
+ // see adapter code documentation for more information on the request object's fields
2017
+ const reqObj = {
2018
+ payload: bodyVars,
2019
+ uriPathVars: pathVars,
2020
+ uriQuery: queryParams,
2021
+ addlHeaders: thisHeaderData
2022
+ };
2023
+
2024
+ try {
2025
+ // Make the call -
2026
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2027
+ return this.requestHandlerInst.identifyRequest('PlainPatch', 'getthelistofinterfaces', reqObj, true, (irReturnData, irReturnError) => {
2028
+ // if we received an error or their is no response on the results
2029
+ // return an error
2030
+ if (irReturnError) {
2031
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2032
+ return callback(null, irReturnError);
2033
+ }
2034
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2035
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getthelistofinterfaces'], null, null, null);
2036
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2037
+ return callback(null, errorObj);
2038
+ }
2039
+
2040
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2041
+ // return the response
2042
+ return callback(irReturnData, null);
2043
+ });
2044
+ } catch (ex) {
2045
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2046
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2047
+ return callback(null, errorObj);
2048
+ }
2049
+ }
2050
+
2051
+ /**
2052
+ * @function verifyyangDataJsoninAcceptPatchheader
2053
+ * @pronghornType method
2054
+ * @name verifyyangDataJsoninAcceptPatchheader
2055
+ * @summary Verify yang-data+json in Accept-Patch header
2056
+ *
2057
+ * @param {string} neId - neId param
2058
+ * @param {string} router - router param
2059
+ * @param {getCallback} callback - a callback function to return the result
2060
+ * @return {object} results - An object containing the response of the action
2061
+ *
2062
+ * @route {POST} /verifyyangDataJsoninAcceptPatchheader
2063
+ * @roles admin
2064
+ * @task true
2065
+ */
2066
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2067
+ verifyyangDataJsoninAcceptPatchheader(neId, router, callback) {
2068
+ const meth = 'adapter-verifyyangDataJsoninAcceptPatchheader';
2069
+ const origin = `${this.id}-${meth}`;
2070
+ log.trace(origin);
2071
+
2072
+ if (this.suspended && this.suspendMode === 'error') {
2073
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2074
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2075
+ return callback(null, errorObj);
2076
+ }
2077
+
2078
+ /* HERE IS WHERE YOU VALIDATE DATA */
2079
+ if (neId === undefined || neId === null || neId === '') {
2080
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['neId'], null, null, null);
2081
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2082
+ return callback(null, errorObj);
2083
+ }
2084
+ if (router === undefined || router === null || router === '') {
2085
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['router'], null, null, null);
2086
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2087
+ return callback(null, errorObj);
2088
+ }
2089
+
2090
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2091
+ const queryParamsAvailable = {};
2092
+ const queryParams = {};
2093
+ const pathVars = [`network-device=${neId}`, `router=${router}`];
2094
+ const bodyVars = {};
2095
+
2096
+ // loop in template. long callback arg name to avoid identifier conflicts
2097
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2098
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2099
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2100
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2101
+ }
2102
+ });
2103
+
2104
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2105
+ let thisHeaderData = null;
2106
+ // if the additional headers was passed in as a string parse the json into an object
2107
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2108
+ try {
2109
+ // parse the additional headers object that was passed in
2110
+ thisHeaderData = JSON.parse(thisHeaderData);
2111
+ } catch (err) {
2112
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2113
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2114
+ return callback(null, errorObj);
2115
+ }
2116
+ } else if (thisHeaderData === null) {
2117
+ thisHeaderData = {};
2118
+ }
2119
+
2120
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2121
+ // see adapter code documentation for more information on the request object's fields
2122
+ const reqObj = {
2123
+ payload: bodyVars,
2124
+ uriPathVars: pathVars,
2125
+ uriQuery: queryParams,
2126
+ addlHeaders: thisHeaderData
2127
+ };
2128
+
2129
+ try {
2130
+ // Make the call -
2131
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2132
+ return this.requestHandlerInst.identifyRequest('PlainPatch', 'verifyyangDataJsoninAcceptPatchheader', reqObj, true, (irReturnData, irReturnError) => {
2133
+ // if we received an error or their is no response on the results
2134
+ // return an error
2135
+ if (irReturnError) {
2136
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2137
+ return callback(null, irReturnError);
2138
+ }
2139
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2140
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['verifyyangDataJsoninAcceptPatchheader'], null, null, null);
2141
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2142
+ return callback(null, errorObj);
2143
+ }
2144
+
2145
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2146
+ // return the response
2147
+ return callback(irReturnData, null);
2148
+ });
2149
+ } catch (ex) {
2150
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2151
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2152
+ return callback(null, errorObj);
2153
+ }
2154
+ }
2155
+
2156
+ /**
2157
+ * @function patchMultipleinterfaces
2158
+ * @pronghornType method
2159
+ * @name patchMultipleinterfaces
2160
+ * @summary Patch Multiple interfaces
2161
+ *
2162
+ * @param {string} neId - neId param
2163
+ * @param {string} router - router name
2164
+ * @param {object} body - body param
2165
+ * @param {getCallback} callback - a callback function to return the result
2166
+ * @return {object} results - An object containing the response of the action
2167
+ *
2168
+ * @route {POST} /patchMultipleinterfaces
2169
+ * @roles admin
2170
+ * @task true
2171
+ */
2172
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2173
+ patchMultipleinterfaces(neId, router, body, callback) {
2174
+ const meth = 'adapter-patchMultipleinterfaces';
2175
+ const origin = `${this.id}-${meth}`;
2176
+ log.trace(origin);
2177
+
2178
+ if (this.suspended && this.suspendMode === 'error') {
2179
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2180
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2181
+ return callback(null, errorObj);
2182
+ }
2183
+
2184
+ /* HERE IS WHERE YOU VALIDATE DATA */
2185
+ if (neId === undefined || neId === null || neId === '') {
2186
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['neId'], null, null, null);
2187
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2188
+ return callback(null, errorObj);
2189
+ }
2190
+ if (router === undefined || router === null || router === '') {
2191
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['router'], null, null, null);
2192
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2193
+ return callback(null, errorObj);
2194
+ }
2195
+ if (body === undefined || body === null || body === '') {
2196
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
2197
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2198
+ return callback(null, errorObj);
2199
+ }
2200
+
2201
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2202
+ const queryParamsAvailable = {};
2203
+ const queryParams = {};
2204
+ const pathVars = [`network-device=${neId}`, `router=${router}`];
2205
+ const bodyVars = body;
2206
+
2207
+ // loop in template. long callback arg name to avoid identifier conflicts
2208
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2209
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2210
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2211
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2212
+ }
2213
+ });
2214
+
2215
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2216
+ let thisHeaderData = null;
2217
+ // if the additional headers was passed in as a string parse the json into an object
2218
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2219
+ try {
2220
+ // parse the additional headers object that was passed in
2221
+ thisHeaderData = JSON.parse(thisHeaderData);
2222
+ } catch (err) {
2223
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2224
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2225
+ return callback(null, errorObj);
2226
+ }
2227
+ } else if (thisHeaderData === null) {
2228
+ thisHeaderData = {};
2229
+ }
2230
+
2231
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2232
+ // see adapter code documentation for more information on the request object's fields
2233
+ const reqObj = {
2234
+ payload: bodyVars,
2235
+ uriPathVars: pathVars,
2236
+ uriQuery: queryParams,
2237
+ addlHeaders: thisHeaderData
2238
+ };
2239
+
2240
+ try {
2241
+ // Make the call -
2242
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2243
+ return this.requestHandlerInst.identifyRequest('PlainPatch', 'patchMultipleinterfaces', reqObj, false, (irReturnData, irReturnError) => {
2244
+ // if we received an error or their is no response on the results
2245
+ // return an error
2246
+ if (irReturnError) {
2247
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2248
+ return callback(null, irReturnError);
2249
+ }
2250
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2251
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchMultipleinterfaces'], null, null, null);
2252
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2253
+ return callback(null, errorObj);
2254
+ }
2255
+
2256
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2257
+ // return the response
2258
+ return callback(irReturnData, null);
2259
+ });
2260
+ } catch (ex) {
2261
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2262
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2263
+ return callback(null, errorObj);
2264
+ }
2265
+ }
2266
+
2267
+ /**
2268
+ * @function addEmptytype
2269
+ * @pronghornType method
2270
+ * @name addEmptytype
2271
+ * @summary Add - empty type
2272
+ *
2273
+ * @param {string} jneId - jneId param
2274
+ * @param {string} interfaceParam - interfaceParam param
2275
+ * @param {object} body - body param
2276
+ * @param {getCallback} callback - a callback function to return the result
2277
+ * @return {object} results - An object containing the response of the action
2278
+ *
2279
+ * @route {POST} /addEmptytype
2280
+ * @roles admin
2281
+ * @task true
2282
+ */
2283
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2284
+ addEmptytype(jneId, interfaceParam, body, callback) {
2285
+ const meth = 'adapter-addEmptytype';
2286
+ const origin = `${this.id}-${meth}`;
2287
+ log.trace(origin);
2288
+
2289
+ if (this.suspended && this.suspendMode === 'error') {
2290
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2291
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2292
+ return callback(null, errorObj);
2293
+ }
2294
+
2295
+ /* HERE IS WHERE YOU VALIDATE DATA */
2296
+ if (jneId === undefined || jneId === null || jneId === '') {
2297
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['jneId'], null, null, null);
2298
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2299
+ return callback(null, errorObj);
2300
+ }
2301
+ if (interfaceParam === undefined || interfaceParam === null || interfaceParam === '') {
2302
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['interfaceParam'], null, null, null);
2303
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2304
+ return callback(null, errorObj);
2305
+ }
2306
+ if (body === undefined || body === null || body === '') {
2307
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
2308
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2309
+ return callback(null, errorObj);
2310
+ }
2311
+
2312
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2313
+ const queryParamsAvailable = {};
2314
+ const queryParams = {};
2315
+ const pathVars = [`network-device=${jneId}`, `interface=${interfaceParam}`];
2316
+ const bodyVars = body;
2317
+
2318
+ // loop in template. long callback arg name to avoid identifier conflicts
2319
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2320
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2321
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2322
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2323
+ }
2324
+ });
2325
+
2326
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2327
+ let thisHeaderData = null;
2328
+ // if the additional headers was passed in as a string parse the json into an object
2329
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2330
+ try {
2331
+ // parse the additional headers object that was passed in
2332
+ thisHeaderData = JSON.parse(thisHeaderData);
2333
+ } catch (err) {
2334
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2335
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2336
+ return callback(null, errorObj);
2337
+ }
2338
+ } else if (thisHeaderData === null) {
2339
+ thisHeaderData = {};
2340
+ }
2341
+
2342
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2343
+ // see adapter code documentation for more information on the request object's fields
2344
+ const reqObj = {
2345
+ payload: bodyVars,
2346
+ uriPathVars: pathVars,
2347
+ uriQuery: queryParams,
2348
+ addlHeaders: thisHeaderData
2349
+ };
2350
+
2351
+ try {
2352
+ // Make the call -
2353
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2354
+ return this.requestHandlerInst.identifyRequest('PatchForLeafTypeEmpty', 'addEmptytype', reqObj, false, (irReturnData, irReturnError) => {
2355
+ // if we received an error or their is no response on the results
2356
+ // return an error
2357
+ if (irReturnError) {
2358
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2359
+ return callback(null, irReturnError);
2360
+ }
2361
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2362
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['addEmptytype'], null, null, null);
2363
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2364
+ return callback(null, errorObj);
2365
+ }
2366
+
2367
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2368
+ // return the response
2369
+ return callback(irReturnData, null);
2370
+ });
2371
+ } catch (ex) {
2372
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2373
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2374
+ return callback(null, errorObj);
2375
+ }
2376
+ }
2377
+
2378
+ /**
2379
+ * @function removeEmptytype
2380
+ * @pronghornType method
2381
+ * @name removeEmptytype
2382
+ * @summary Remove - empty type
2383
+ *
2384
+ * @param {string} jneId - jneId param
2385
+ * @param {string} interfaceParam - interfaceParam param
2386
+ * @param {getCallback} callback - a callback function to return the result
2387
+ * @return {object} results - An object containing the response of the action
2388
+ *
2389
+ * @route {POST} /removeEmptytype
2390
+ * @roles admin
2391
+ * @task true
2392
+ */
2393
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2394
+ removeEmptytype(jneId, interfaceParam, callback) {
2395
+ const meth = 'adapter-removeEmptytype';
2396
+ const origin = `${this.id}-${meth}`;
2397
+ log.trace(origin);
2398
+
2399
+ if (this.suspended && this.suspendMode === 'error') {
2400
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2401
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2402
+ return callback(null, errorObj);
2403
+ }
2404
+
2405
+ /* HERE IS WHERE YOU VALIDATE DATA */
2406
+ if (jneId === undefined || jneId === null || jneId === '') {
2407
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['jneId'], null, null, null);
2408
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2409
+ return callback(null, errorObj);
2410
+ }
2411
+ if (interfaceParam === undefined || interfaceParam === null || interfaceParam === '') {
2412
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['interfaceParam'], null, null, null);
2413
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2414
+ return callback(null, errorObj);
2415
+ }
2416
+
2417
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2418
+ const queryParamsAvailable = {};
2419
+ const queryParams = {};
2420
+ const pathVars = [`network-device=${jneId}`, `interface=${interfaceParam}`];
2421
+ const bodyVars = {};
2422
+
2423
+ // loop in template. long callback arg name to avoid identifier conflicts
2424
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2425
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2426
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2427
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2428
+ }
2429
+ });
2430
+
2431
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2432
+ let thisHeaderData = null;
2433
+ // if the additional headers was passed in as a string parse the json into an object
2434
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2435
+ try {
2436
+ // parse the additional headers object that was passed in
2437
+ thisHeaderData = JSON.parse(thisHeaderData);
2438
+ } catch (err) {
2439
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2440
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2441
+ return callback(null, errorObj);
2442
+ }
2443
+ } else if (thisHeaderData === null) {
2444
+ thisHeaderData = {};
2445
+ }
2446
+
2447
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2448
+ // see adapter code documentation for more information on the request object's fields
2449
+ const reqObj = {
2450
+ payload: bodyVars,
2451
+ uriPathVars: pathVars,
2452
+ uriQuery: queryParams,
2453
+ addlHeaders: thisHeaderData
2454
+ };
2455
+
2456
+ try {
2457
+ // Make the call -
2458
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2459
+ return this.requestHandlerInst.identifyRequest('PatchForLeafTypeEmpty', 'removeEmptytype', reqObj, false, (irReturnData, irReturnError) => {
2460
+ // if we received an error or their is no response on the results
2461
+ // return an error
2462
+ if (irReturnError) {
2463
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2464
+ return callback(null, irReturnError);
2465
+ }
2466
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2467
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['removeEmptytype'], null, null, null);
2468
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2469
+ return callback(null, errorObj);
2470
+ }
2471
+
2472
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2473
+ // return the response
2474
+ return callback(irReturnData, null);
2475
+ });
2476
+ } catch (ex) {
2477
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2478
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2479
+ return callback(null, errorObj);
2480
+ }
2481
+ }
2482
+
2483
+ /**
2484
+ * @function fieldquerytoselectmultiplefieldsunderthetargetresource
2485
+ * @pronghornType method
2486
+ * @name fieldquerytoselectmultiplefieldsunderthetargetresource
2487
+ * @summary Field query to select multiple fields under the target resource
2488
+ *
2489
+ * @param {string} fields - fields param
2490
+ * @param {string} neId - neId param
2491
+ * @param {getCallback} callback - a callback function to return the result
2492
+ * @return {object} results - An object containing the response of the action
2493
+ *
2494
+ * @route {POST} /fieldquerytoselectmultiplefieldsunderthetargetresource
2495
+ * @roles admin
2496
+ * @task true
2497
+ */
2498
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2499
+ fieldquerytoselectmultiplefieldsunderthetargetresource(fields, neId, callback) {
2500
+ const meth = 'adapter-fieldquerytoselectmultiplefieldsunderthetargetresource';
2501
+ const origin = `${this.id}-${meth}`;
2502
+ log.trace(origin);
2503
+
2504
+ if (this.suspended && this.suspendMode === 'error') {
2505
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2506
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2507
+ return callback(null, errorObj);
2508
+ }
2509
+
2510
+ /* HERE IS WHERE YOU VALIDATE DATA */
2511
+ if (fields === undefined || fields === null || fields === '') {
2512
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['fields'], null, null, null);
2513
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2514
+ return callback(null, errorObj);
2515
+ }
2516
+ if (neId === undefined || neId === null || neId === '') {
2517
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['neId'], null, null, null);
2518
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2519
+ return callback(null, errorObj);
2520
+ }
2521
+
2522
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2523
+ const queryParamsAvailable = { fields };
2524
+ const queryParams = {};
2525
+ const pathVars = [`network-device=${neId}`];
2526
+ const bodyVars = {};
2527
+
2528
+ // loop in template. long callback arg name to avoid identifier conflicts
2529
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2530
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2531
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2532
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2533
+ }
2534
+ });
2535
+
2536
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2537
+ let thisHeaderData = null;
2538
+ // if the additional headers was passed in as a string parse the json into an object
2539
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2540
+ try {
2541
+ // parse the additional headers object that was passed in
2542
+ thisHeaderData = JSON.parse(thisHeaderData);
2543
+ } catch (err) {
2544
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2545
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2546
+ return callback(null, errorObj);
2547
+ }
2548
+ } else if (thisHeaderData === null) {
2549
+ thisHeaderData = {};
2550
+ }
2551
+
2552
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2553
+ // see adapter code documentation for more information on the request object's fields
2554
+ const reqObj = {
2555
+ payload: bodyVars,
2556
+ uriPathVars: pathVars,
2557
+ uriQuery: queryParams,
2558
+ addlHeaders: thisHeaderData
2559
+ };
2560
+
2561
+ try {
2562
+ // Make the call -
2563
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2564
+ return this.requestHandlerInst.identifyRequest('Search', 'fieldquerytoselectmultiplefieldsunderthetargetresource', reqObj, true, (irReturnData, irReturnError) => {
2565
+ // if we received an error or their is no response on the results
2566
+ // return an error
2567
+ if (irReturnError) {
2568
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2569
+ return callback(null, irReturnError);
2570
+ }
2571
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2572
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['fieldquerytoselectmultiplefieldsunderthetargetresource'], null, null, null);
2573
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2574
+ return callback(null, errorObj);
2575
+ }
2576
+
2577
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2578
+ // return the response
2579
+ return callback(irReturnData, null);
2580
+ });
2581
+ } catch (ex) {
2582
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2583
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2584
+ return callback(null, errorObj);
2585
+ }
2586
+ }
2587
+
2588
+ /**
2589
+ * @function fieldquerywithsubSelectorsofanodeunderthetargetresource
2590
+ * @pronghornType method
2591
+ * @name fieldquerywithsubSelectorsofanodeunderthetargetresource
2592
+ * @summary Field query with sub-selectors of a node under the target resource
2593
+ *
2594
+ * @param {string} fields - fields param
2595
+ * @param {string} neId - neId param
2596
+ * @param {string} cardId - cardId param
2597
+ * @param {getCallback} callback - a callback function to return the result
2598
+ * @return {object} results - An object containing the response of the action
2599
+ *
2600
+ * @route {POST} /fieldquerywithsubSelectorsofanodeunderthetargetresource
2601
+ * @roles admin
2602
+ * @task true
2603
+ */
2604
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2605
+ fieldquerywithsubSelectorsofanodeunderthetargetresource(fields, neId, cardId, callback) {
2606
+ const meth = 'adapter-fieldquerywithsubSelectorsofanodeunderthetargetresource';
2607
+ const origin = `${this.id}-${meth}`;
2608
+ log.trace(origin);
2609
+
2610
+ if (this.suspended && this.suspendMode === 'error') {
2611
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2612
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2613
+ return callback(null, errorObj);
2614
+ }
2615
+
2616
+ /* HERE IS WHERE YOU VALIDATE DATA */
2617
+ if (fields === undefined || fields === null || fields === '') {
2618
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['fields'], null, null, null);
2619
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2620
+ return callback(null, errorObj);
2621
+ }
2622
+ if (neId === undefined || neId === null || neId === '') {
2623
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['neId'], null, null, null);
2624
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2625
+ return callback(null, errorObj);
2626
+ }
2627
+ if (cardId === undefined || cardId === null || cardId === '') {
2628
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['cardId'], null, null, null);
2629
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2630
+ return callback(null, errorObj);
2631
+ }
2632
+
2633
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2634
+ const queryParamsAvailable = { fields };
2635
+ const queryParams = {};
2636
+ const pathVars = [`network-device=${neId}`, `card=${cardId}`];
2637
+ const bodyVars = {};
2638
+
2639
+ // loop in template. long callback arg name to avoid identifier conflicts
2640
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2641
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2642
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2643
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2644
+ }
2645
+ });
2646
+
2647
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2648
+ let thisHeaderData = null;
2649
+ // if the additional headers was passed in as a string parse the json into an object
2650
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2651
+ try {
2652
+ // parse the additional headers object that was passed in
2653
+ thisHeaderData = JSON.parse(thisHeaderData);
2654
+ } catch (err) {
2655
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2656
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2657
+ return callback(null, errorObj);
2658
+ }
2659
+ } else if (thisHeaderData === null) {
2660
+ thisHeaderData = {};
2661
+ }
2662
+
2663
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2664
+ // see adapter code documentation for more information on the request object's fields
2665
+ const reqObj = {
2666
+ payload: bodyVars,
2667
+ uriPathVars: pathVars,
2668
+ uriQuery: queryParams,
2669
+ addlHeaders: thisHeaderData
2670
+ };
2671
+
2672
+ try {
2673
+ // Make the call -
2674
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2675
+ return this.requestHandlerInst.identifyRequest('Search', 'fieldquerywithsubSelectorsofanodeunderthetargetresource', reqObj, true, (irReturnData, irReturnError) => {
2676
+ // if we received an error or their is no response on the results
2677
+ // return an error
2678
+ if (irReturnError) {
2679
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2680
+ return callback(null, irReturnError);
2681
+ }
2682
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2683
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['fieldquerywithsubSelectorsofanodeunderthetargetresource'], null, null, null);
2684
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2685
+ return callback(null, errorObj);
2686
+ }
2687
+
2688
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2689
+ // return the response
2690
+ return callback(irReturnData, null);
2691
+ });
2692
+ } catch (ex) {
2693
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2694
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2695
+ return callback(null, errorObj);
2696
+ }
2697
+ }
2698
+
2699
+ /**
2700
+ * @function fieldquerytoretrieveasinglechildnodeunderthetargetresource
2701
+ * @pronghornType method
2702
+ * @name fieldquerytoretrieveasinglechildnodeunderthetargetresource
2703
+ * @summary Field query to retrieve a single child node under the target resource
2704
+ *
2705
+ * @param {string} neType - neType param
2706
+ * @param {string} neVersion - neVersion param
2707
+ * @param {getCallback} callback - a callback function to return the result
2708
+ * @return {object} results - An object containing the response of the action
2709
+ *
2710
+ * @route {POST} /fieldquerytoretrieveasinglechildnodeunderthetargetresource
2711
+ * @roles admin
2712
+ * @task true
2713
+ */
2714
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2715
+ fieldquerytoretrieveasinglechildnodeunderthetargetresource(neType, neVersion, callback) {
2716
+ const meth = 'adapter-fieldquerytoretrieveasinglechildnodeunderthetargetresource';
2717
+ const origin = `${this.id}-${meth}`;
2718
+ log.trace(origin);
2719
+
2720
+ if (this.suspended && this.suspendMode === 'error') {
2721
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2722
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2723
+ return callback(null, errorObj);
2724
+ }
2725
+
2726
+ /* HERE IS WHERE YOU VALIDATE DATA */
2727
+ if (neType === undefined || neType === null || neType === '') {
2728
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['neType'], null, null, null);
2729
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2730
+ return callback(null, errorObj);
2731
+ }
2732
+ if (neVersion === undefined || neVersion === null || neVersion === '') {
2733
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['neVersion'], null, null, null);
2734
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2735
+ return callback(null, errorObj);
2736
+ }
2737
+
2738
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2739
+ const queryParamsAvailable = {};
2740
+ const queryParams = {};
2741
+ const pathVars = [`neType=${neType}`, `neVersion=${neVersion}`];
2742
+ const bodyVars = {};
2743
+
2744
+ // loop in template. long callback arg name to avoid identifier conflicts
2745
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2746
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2747
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2748
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2749
+ }
2750
+ });
2751
+
2752
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2753
+ let thisHeaderData = null;
2754
+ // if the additional headers was passed in as a string parse the json into an object
2755
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2756
+ try {
2757
+ // parse the additional headers object that was passed in
2758
+ thisHeaderData = JSON.parse(thisHeaderData);
2759
+ } catch (err) {
2760
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2761
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2762
+ return callback(null, errorObj);
2763
+ }
2764
+ } else if (thisHeaderData === null) {
2765
+ thisHeaderData = {};
2766
+ }
2767
+
2768
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2769
+ // see adapter code documentation for more information on the request object's fields
2770
+ const reqObj = {
2771
+ payload: bodyVars,
2772
+ uriPathVars: pathVars,
2773
+ uriQuery: queryParams,
2774
+ addlHeaders: thisHeaderData
2775
+ };
2776
+
2777
+ try {
2778
+ // Make the call -
2779
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2780
+ return this.requestHandlerInst.identifyRequest('Search', 'fieldquerytoretrieveasinglechildnodeunderthetargetresource', reqObj, true, (irReturnData, irReturnError) => {
2781
+ // if we received an error or their is no response on the results
2782
+ // return an error
2783
+ if (irReturnError) {
2784
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2785
+ return callback(null, irReturnError);
2786
+ }
2787
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2788
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['fieldquerytoretrieveasinglechildnodeunderthetargetresource'], null, null, null);
2789
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2790
+ return callback(null, errorObj);
2791
+ }
2792
+
2793
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2794
+ // return the response
2795
+ return callback(irReturnData, null);
2796
+ });
2797
+ } catch (ex) {
2798
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2799
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2800
+ return callback(null, errorObj);
2801
+ }
2802
+ }
2803
+
2804
+ /**
2805
+ * @function getQoS
2806
+ * @pronghornType method
2807
+ * @name getQoS
2808
+ * @summary Get QoS
2809
+ *
2810
+ * @param {string} networkDevice - networkDevice param
2811
+ * @param {getCallback} callback - a callback function to return the result
2812
+ * @return {object} results - An object containing the response of the action
2813
+ *
2814
+ * @route {POST} /getQoS
2815
+ * @roles admin
2816
+ * @task true
2817
+ */
2818
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2819
+ getQoS(networkDevice, callback) {
2820
+ const meth = 'adapter-getQoS';
2821
+ const origin = `${this.id}-${meth}`;
2822
+ log.trace(origin);
2823
+
2824
+ if (this.suspended && this.suspendMode === 'error') {
2825
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2826
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2827
+ return callback(null, errorObj);
2828
+ }
2829
+
2830
+ /* HERE IS WHERE YOU VALIDATE DATA */
2831
+ if (networkDevice === undefined || networkDevice === null || networkDevice === '') {
2832
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['networkDevice'], null, null, null);
2833
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2834
+ return callback(null, errorObj);
2835
+ }
2836
+
2837
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2838
+ const queryParamsAvailable = {};
2839
+ const queryParams = {};
2840
+ const pathVars = [`network-device=${networkDevice}`];
2841
+ const bodyVars = {};
2842
+
2843
+ // loop in template. long callback arg name to avoid identifier conflicts
2844
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2845
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2846
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2847
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2848
+ }
2849
+ });
2850
+
2851
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2852
+ let thisHeaderData = null;
2853
+ // if the additional headers was passed in as a string parse the json into an object
2854
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2855
+ try {
2856
+ // parse the additional headers object that was passed in
2857
+ thisHeaderData = JSON.parse(thisHeaderData);
2858
+ } catch (err) {
2859
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2860
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2861
+ return callback(null, errorObj);
2862
+ }
2863
+ } else if (thisHeaderData === null) {
2864
+ thisHeaderData = {};
2865
+ }
2866
+
2867
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2868
+ // see adapter code documentation for more information on the request object's fields
2869
+ const reqObj = {
2870
+ payload: bodyVars,
2871
+ uriPathVars: pathVars,
2872
+ uriQuery: queryParams,
2873
+ addlHeaders: thisHeaderData
2874
+ };
2875
+
2876
+ try {
2877
+ // Make the call -
2878
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2879
+ return this.requestHandlerInst.identifyRequest('QOSPolicyGetCreateEdit', 'getQoS', reqObj, true, (irReturnData, irReturnError) => {
2880
+ // if we received an error or their is no response on the results
2881
+ // return an error
2882
+ if (irReturnError) {
2883
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2884
+ return callback(null, irReturnError);
2885
+ }
2886
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2887
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getQoS'], null, null, null);
2888
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2889
+ return callback(null, errorObj);
2890
+ }
2891
+
2892
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2893
+ // return the response
2894
+ return callback(irReturnData, null);
2895
+ });
2896
+ } catch (ex) {
2897
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2898
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2899
+ return callback(null, errorObj);
2900
+ }
2901
+ }
2902
+
2903
+ /**
2904
+ * @function createQOSPolicy
2905
+ * @pronghornType method
2906
+ * @name createQOSPolicy
2907
+ * @summary Create QOS Policy
2908
+ *
2909
+ * @param {string} neId - network device id
2910
+ * @param {object} body - body param
2911
+ * @param {getCallback} callback - a callback function to return the result
2912
+ * @return {object} results - An object containing the response of the action
2913
+ *
2914
+ * @route {POST} /createQOSPolicy
2915
+ * @roles admin
2916
+ * @task true
2917
+ */
2918
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2919
+ createQOSPolicy(neId, body, callback) {
2920
+ const meth = 'adapter-createQOSPolicy';
2921
+ const origin = `${this.id}-${meth}`;
2922
+ log.trace(origin);
2923
+
2924
+ if (this.suspended && this.suspendMode === 'error') {
2925
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2926
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2927
+ return callback(null, errorObj);
2928
+ }
2929
+
2930
+ /* HERE IS WHERE YOU VALIDATE DATA */
2931
+ if (body === undefined || body === null || body === '') {
2932
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
2933
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2934
+ return callback(null, errorObj);
2935
+ }
2936
+
2937
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2938
+ const queryParamsAvailable = {};
2939
+ const queryParams = {};
2940
+ const pathVars = [`network-device=${neId}`];
2941
+ const bodyVars = body;
2942
+
2943
+ // loop in template. long callback arg name to avoid identifier conflicts
2944
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2945
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2946
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2947
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2948
+ }
2949
+ });
2950
+
2951
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
2952
+ let thisHeaderData = null;
2953
+ // if the additional headers was passed in as a string parse the json into an object
2954
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
2955
+ try {
2956
+ // parse the additional headers object that was passed in
2957
+ thisHeaderData = JSON.parse(thisHeaderData);
2958
+ } catch (err) {
2959
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
2960
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2961
+ return callback(null, errorObj);
2962
+ }
2963
+ } else if (thisHeaderData === null) {
2964
+ thisHeaderData = {};
2965
+ }
2966
+
2967
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2968
+ // see adapter code documentation for more information on the request object's fields
2969
+ const reqObj = {
2970
+ payload: bodyVars,
2971
+ uriPathVars: pathVars,
2972
+ uriQuery: queryParams,
2973
+ addlHeaders: thisHeaderData
2974
+ };
2975
+
2976
+ try {
2977
+ // Make the call -
2978
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2979
+ return this.requestHandlerInst.identifyRequest('QOSPolicyGetCreateEdit', 'createQOSPolicy', reqObj, true, (irReturnData, irReturnError) => {
2980
+ // if we received an error or their is no response on the results
2981
+ // return an error
2982
+ if (irReturnError) {
2983
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2984
+ return callback(null, irReturnError);
2985
+ }
2986
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2987
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createQOSPolicy'], null, null, null);
2988
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2989
+ return callback(null, errorObj);
2990
+ }
2991
+
2992
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2993
+ // return the response
2994
+ return callback(irReturnData, null);
2995
+ });
2996
+ } catch (ex) {
2997
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2998
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2999
+ return callback(null, errorObj);
3000
+ }
3001
+ }
3002
+
3003
+ /**
3004
+ * @function getQOSSAPEgressPolicy
3005
+ * @pronghornType method
3006
+ * @name getQOSSAPEgressPolicy
3007
+ * @summary Get QOS SAP Egress Policy
3008
+ *
3009
+ * @param {string} networkDevice - networkDevice param
3010
+ * @param {getCallback} callback - a callback function to return the result
3011
+ * @return {object} results - An object containing the response of the action
3012
+ *
3013
+ * @route {POST} /getQOSSAPEgressPolicy
3014
+ * @roles admin
3015
+ * @task true
3016
+ */
3017
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3018
+ getQOSSAPEgressPolicy(networkDevice, callback) {
3019
+ const meth = 'adapter-getQOSSAPEgressPolicy';
3020
+ const origin = `${this.id}-${meth}`;
3021
+ log.trace(origin);
3022
+
3023
+ if (this.suspended && this.suspendMode === 'error') {
3024
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3025
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3026
+ return callback(null, errorObj);
3027
+ }
3028
+
3029
+ /* HERE IS WHERE YOU VALIDATE DATA */
3030
+ if (networkDevice === undefined || networkDevice === null || networkDevice === '') {
3031
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['networkDevice'], null, null, null);
3032
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3033
+ return callback(null, errorObj);
3034
+ }
3035
+
3036
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3037
+ const queryParamsAvailable = {};
3038
+ const queryParams = {};
3039
+ const pathVars = [`network-device=${networkDevice}`];
3040
+ const bodyVars = {};
3041
+
3042
+ // loop in template. long callback arg name to avoid identifier conflicts
3043
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3044
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3045
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3046
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3047
+ }
3048
+ });
3049
+
3050
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
3051
+ let thisHeaderData = null;
3052
+ // if the additional headers was passed in as a string parse the json into an object
3053
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
3054
+ try {
3055
+ // parse the additional headers object that was passed in
3056
+ thisHeaderData = JSON.parse(thisHeaderData);
3057
+ } catch (err) {
3058
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
3059
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3060
+ return callback(null, errorObj);
3061
+ }
3062
+ } else if (thisHeaderData === null) {
3063
+ thisHeaderData = {};
3064
+ }
3065
+
3066
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3067
+ // see adapter code documentation for more information on the request object's fields
3068
+ const reqObj = {
3069
+ payload: bodyVars,
3070
+ uriPathVars: pathVars,
3071
+ uriQuery: queryParams,
3072
+ addlHeaders: thisHeaderData
3073
+ };
3074
+
3075
+ try {
3076
+ // Make the call -
3077
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3078
+ return this.requestHandlerInst.identifyRequest('QOSPolicyGetCreateEdit', 'getQOSSAPEgressPolicy', reqObj, true, (irReturnData, irReturnError) => {
3079
+ // if we received an error or their is no response on the results
3080
+ // return an error
3081
+ if (irReturnError) {
3082
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3083
+ return callback(null, irReturnError);
3084
+ }
3085
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3086
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getQOSSAPEgressPolicy'], null, null, null);
3087
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3088
+ return callback(null, errorObj);
3089
+ }
3090
+
3091
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3092
+ // return the response
3093
+ return callback(irReturnData, null);
3094
+ });
3095
+ } catch (ex) {
3096
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3097
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3098
+ return callback(null, errorObj);
3099
+ }
3100
+ }
3101
+
3102
+ /**
3103
+ * @function editQOSPolicy
3104
+ * @pronghornType method
3105
+ * @name editQOSPolicy
3106
+ * @summary Edit QOS Policy
3107
+ *
3108
+ * @param {string} networkDevice - network device id
3109
+ * @param {object} body - body param
3110
+ * @param {getCallback} callback - a callback function to return the result
3111
+ * @return {object} results - An object containing the response of the action
3112
+ *
3113
+ * @route {POST} /editQOSPolicy
3114
+ * @roles admin
3115
+ * @task true
3116
+ */
3117
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3118
+ editQOSPolicy(networkDevice, body, callback) {
3119
+ const meth = 'adapter-editQOSPolicy';
3120
+ const origin = `${this.id}-${meth}`;
3121
+ log.trace(origin);
3122
+
3123
+ if (this.suspended && this.suspendMode === 'error') {
3124
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3125
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3126
+ return callback(null, errorObj);
3127
+ }
3128
+
3129
+ /* HERE IS WHERE YOU VALIDATE DATA */
3130
+ if (body === undefined || body === null || body === '') {
3131
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
3132
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3133
+ return callback(null, errorObj);
3134
+ }
3135
+
3136
+ if (networkDevice === undefined || networkDevice === null || networkDevice === '') {
3137
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['networkDevice'], null, null, null);
3138
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3139
+ return callback(null, errorObj);
3140
+ }
3141
+
3142
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3143
+ const queryParamsAvailable = {};
3144
+ const queryParams = {};
3145
+ const pathVars = [`network-device=${networkDevice}`];
3146
+ const bodyVars = body;
3147
+
3148
+ // loop in template. long callback arg name to avoid identifier conflicts
3149
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3150
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3151
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3152
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3153
+ }
3154
+ });
3155
+
3156
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
3157
+ let thisHeaderData = null;
3158
+ // if the additional headers was passed in as a string parse the json into an object
3159
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
3160
+ try {
3161
+ // parse the additional headers object that was passed in
3162
+ thisHeaderData = JSON.parse(thisHeaderData);
3163
+ } catch (err) {
3164
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
3165
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3166
+ return callback(null, errorObj);
3167
+ }
3168
+ } else if (thisHeaderData === null) {
3169
+ thisHeaderData = {};
3170
+ }
3171
+
3172
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3173
+ // see adapter code documentation for more information on the request object's fields
3174
+ const reqObj = {
3175
+ payload: bodyVars,
3176
+ uriPathVars: pathVars,
3177
+ uriQuery: queryParams,
3178
+ addlHeaders: thisHeaderData
3179
+ };
3180
+
3181
+ try {
3182
+ // Make the call -
3183
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3184
+ return this.requestHandlerInst.identifyRequest('QOSPolicyGetCreateEdit', 'editQOSPolicy', reqObj, false, (irReturnData, irReturnError) => {
3185
+ // if we received an error or their is no response on the results
3186
+ // return an error
3187
+ if (irReturnError) {
3188
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3189
+ return callback(null, irReturnError);
3190
+ }
3191
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3192
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['editQOSPolicy'], null, null, null);
3193
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3194
+ return callback(null, errorObj);
3195
+ }
3196
+
3197
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3198
+ // return the response
3199
+ return callback(irReturnData, null);
3200
+ });
3201
+ } catch (ex) {
3202
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3203
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3204
+ return callback(null, errorObj);
3205
+ }
3206
+ }
3207
+ }
3208
+
3209
+ module.exports = NokiaNspDeviceConfigurator;