@itentialopensource/adapter-tmf639_resource_inventory_management 1.0.0

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