@itentialopensource/adapter-selector_ai 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/.eslintignore +5 -0
  2. package/.eslintrc.js +19 -0
  3. package/.jshintrc +3 -0
  4. package/AUTH.md +39 -0
  5. package/BROKER.md +211 -0
  6. package/CALLS.md +405 -0
  7. package/CODE_OF_CONDUCT.md +43 -0
  8. package/CONTRIBUTING.md +13 -0
  9. package/ENHANCE.md +69 -0
  10. package/LICENSE +201 -0
  11. package/PROPERTIES.md +661 -0
  12. package/README.md +344 -0
  13. package/SUMMARY.md +9 -0
  14. package/SYSTEMINFO.md +14 -0
  15. package/TAB1.md +8 -0
  16. package/TAB2.md +314 -0
  17. package/TROUBLESHOOT.md +56 -0
  18. package/UTILITIES.md +473 -0
  19. package/adapter.js +4039 -0
  20. package/adapterBase.js +1488 -0
  21. package/entities/.generic/action.json +214 -0
  22. package/entities/.generic/schema.json +28 -0
  23. package/entities/.system/action.json +50 -0
  24. package/entities/.system/mockdatafiles/getToken-default.json +3 -0
  25. package/entities/.system/mockdatafiles/healthcheck-default.json +3 -0
  26. package/entities/.system/schema.json +19 -0
  27. package/entities/.system/schemaTokenReq.json +53 -0
  28. package/entities/.system/schemaTokenResp.json +53 -0
  29. package/entities/InventorySchemaCreation/action.json +24 -0
  30. package/entities/InventorySchemaCreation/schema.json +19 -0
  31. package/entities/InventorySchemaDelete/action.json +24 -0
  32. package/entities/InventorySchemaDelete/schema.json +19 -0
  33. package/entities/InventorySchemaDeleteType/action.json +24 -0
  34. package/entities/InventorySchemaDeleteType/schema.json +19 -0
  35. package/entities/InventorySchemaFileDownload/action.json +24 -0
  36. package/entities/InventorySchemaFileDownload/schema.json +19 -0
  37. package/entities/InventorySchemaFileUpload/action.json +24 -0
  38. package/entities/InventorySchemaFileUpload/schema.json +19 -0
  39. package/entities/InventorySchemaUpdate/action.json +24 -0
  40. package/entities/InventorySchemaUpdate/schema.json +19 -0
  41. package/entities/InventoryV2SchemaDeleteAll/action.json +24 -0
  42. package/entities/InventoryV2SchemaDeleteAll/schema.json +19 -0
  43. package/entities/InventoryV2SchemaDeleteType/action.json +24 -0
  44. package/entities/InventoryV2SchemaDeleteType/schema.json +19 -0
  45. package/entities/InventoryV2SchemaUpdate/action.json +24 -0
  46. package/entities/InventoryV2SchemaUpdate/schema.json +19 -0
  47. package/entities/InventoryV2SchemaUpload/action.json +24 -0
  48. package/entities/InventoryV2SchemaUpload/schema.json +19 -0
  49. package/entities/MetastoreInventoryBulkDataUpload/action.json +24 -0
  50. package/entities/MetastoreInventoryBulkDataUpload/schema.json +19 -0
  51. package/entities/MetastoreInventoryCSVDataUpload/action.json +24 -0
  52. package/entities/MetastoreInventoryCSVDataUpload/schema.json +19 -0
  53. package/entities/MetastoreInventoryCsvFileExport/action.json +25 -0
  54. package/entities/MetastoreInventoryCsvFileExport/schema.json +19 -0
  55. package/entities/MetastoreInventoryDataDelete/action.json +24 -0
  56. package/entities/MetastoreInventoryDataDelete/schema.json +19 -0
  57. package/entities/MetastoreInventoryDataDownload/action.json +46 -0
  58. package/entities/MetastoreInventoryDataDownload/schema.json +20 -0
  59. package/entities/MetastoreInventoryDataEdit/action.json +24 -0
  60. package/entities/MetastoreInventoryDataEdit/schema.json +19 -0
  61. package/entities/MetastoreInventoryDataUpload/action.json +24 -0
  62. package/entities/MetastoreInventoryDataUpload/schema.json +19 -0
  63. package/entities/MetastoreInventoryFilesExport/action.json +24 -0
  64. package/entities/MetastoreInventoryFilesExport/schema.json +19 -0
  65. package/entities/MetastoreInventoryFilesImport/action.json +24 -0
  66. package/entities/MetastoreInventoryFilesImport/schema.json +30 -0
  67. package/entities/MetastoreInventoryItems/action.json +25 -0
  68. package/entities/MetastoreInventoryItems/schema.json +19 -0
  69. package/entities/MetastoreInventoryNameDelete/action.json +24 -0
  70. package/entities/MetastoreInventoryNameDelete/schema.json +19 -0
  71. package/entities/MetastoreInventoryNameUpdate/action.json +24 -0
  72. package/entities/MetastoreInventoryNameUpdate/schema.json +19 -0
  73. package/entities/MetastoreInventoryNameUpload/action.json +24 -0
  74. package/entities/MetastoreInventoryNameUpload/schema.json +19 -0
  75. package/entities/MetastoreInventoryNamesDownload/action.json +25 -0
  76. package/entities/MetastoreInventoryNamesDownload/schema.json +19 -0
  77. package/entities/MetastoreInventorySchemaGet/action.json +25 -0
  78. package/entities/MetastoreInventorySchemaGet/schema.json +19 -0
  79. package/entities/MetastoreInventorySystem/action.json +130 -0
  80. package/entities/MetastoreInventorySystem/schema.json +24 -0
  81. package/entities/MetastoreV2InventorySchemaGet/action.json +25 -0
  82. package/entities/MetastoreV2InventorySchemaGet/schema.json +19 -0
  83. package/error.json +190 -0
  84. package/metadata.json +58 -0
  85. package/package.json +77 -0
  86. package/pronghorn.json +2508 -0
  87. package/propertiesDecorators.json +14 -0
  88. package/propertiesSchema.json +1635 -0
  89. package/report/adapterInfo.json +10 -0
  90. package/report/auto-adapter-openapi.json +1330 -0
  91. package/report/creationReport.json +765 -0
  92. package/report/metastore-inventory-manager.yaml-OpenApi3Json.json +2366 -0
  93. package/sampleProperties.json +260 -0
  94. package/test/integration/adapterTestBasicGet.js +117 -0
  95. package/test/integration/adapterTestConnectivity.js +117 -0
  96. package/test/integration/adapterTestIntegration.js +1295 -0
  97. package/test/unit/adapterBaseTestUnit.js +1626 -0
  98. package/test/unit/adapterTestUnit.js +2288 -0
  99. package/utils/adapterInfo.js +156 -0
  100. package/utils/argParser.js +44 -0
  101. package/utils/checkMigrate.js +102 -0
  102. package/utils/entitiesToDB.js +190 -0
  103. package/utils/findPath.js +74 -0
  104. package/utils/logger.js +26 -0
  105. package/utils/methodDocumentor.js +273 -0
  106. package/utils/modify.js +153 -0
  107. package/utils/mongoDbConnection.js +79 -0
  108. package/utils/mongoUtils.js +162 -0
  109. package/utils/pre-commit.sh +32 -0
  110. package/utils/removeHooks.js +20 -0
  111. package/utils/setup.js +33 -0
  112. package/utils/taskMover.js +308 -0
  113. package/utils/tbScript.js +103 -0
  114. package/utils/tbUtils.js +347 -0
  115. package/utils/testRunner.js +298 -0
  116. package/utils/troubleshootingAdapter.js +177 -0
  117. package/utils/updateAdapterConfig.js +158 -0
package/adapter.js ADDED
@@ -0,0 +1,4039 @@
1
+ /* @copyright Itential, LLC 2019 (pre-modifications) */
2
+
3
+ /* eslint import/no-dynamic-require: warn */
4
+ /* eslint object-curly-newline: warn */
5
+ /* eslint default-param-last: warn */
6
+
7
+ // Set globals
8
+ /* global log */
9
+
10
+ /* Required libraries. */
11
+ const path = require('path');
12
+
13
+ /* Fetch in the other needed components for the this Adaptor */
14
+ const AdapterBaseCl = require(path.join(__dirname, 'adapterBase.js'));
15
+
16
+ /**
17
+ * This is the adapter/interface into Selector_ai
18
+ */
19
+
20
+ /* GENERAL ADAPTER FUNCTIONS */
21
+ class SelectorAi extends AdapterBaseCl {
22
+ /**
23
+ * SelectorAi Adapter
24
+ * @constructor
25
+ */
26
+ /* Working on changing the way we do Emit methods due to size and time constrainsts
27
+ constructor(prongid, properties) {
28
+ // Instantiate the AdapterBase super class
29
+ super(prongid, properties);
30
+
31
+ const restFunctionNames = this.iapGetAdapterWorkflowFunctions();
32
+
33
+ // Dynamically bind emit functions
34
+ for (let i = 0; i < restFunctionNames.length; i += 1) {
35
+ // Bind function to have name fnNameEmit for fnName
36
+ const version = restFunctionNames[i].match(/__v[0-9]+/);
37
+ const baseFnName = restFunctionNames[i].replace(/__v[0-9]+/, '');
38
+ const fnNameEmit = version ? `${baseFnName}Emit${version}` : `${baseFnName}Emit`;
39
+ this[fnNameEmit] = function (...args) {
40
+ // extract the callback
41
+ const callback = args[args.length - 1];
42
+ // slice the callback from args so we can insert our own
43
+ const functionArgs = args.slice(0, args.length - 1);
44
+ // create a random name for the listener
45
+ const eventName = `${restFunctionNames[i]}:${Math.random().toString(36)}`;
46
+ // tell the calling class to start listening
47
+ callback({ event: eventName, status: 'received' });
48
+ // store parent for use of this context later
49
+ const parent = this;
50
+ // store emission function
51
+ const func = function (val, err) {
52
+ parent.removeListener(eventName, func);
53
+ parent.emit(eventName, val, err);
54
+ };
55
+ // Use apply to call the function in a specific context
56
+ this[restFunctionNames[i]].apply(this, functionArgs.concat([func])); // eslint-disable-line prefer-spread
57
+ };
58
+ }
59
+
60
+ // Uncomment if you have things to add to the constructor like using your own properties.
61
+ // Otherwise the constructor in the adapterBase will be used.
62
+ // Capture my own properties - they need to be defined in propertiesSchema.json
63
+ // if (this.allProps && this.allProps.myownproperty) {
64
+ // mypropvariable = this.allProps.myownproperty;
65
+ // }
66
+ }
67
+ */
68
+
69
+ /**
70
+ * @callback healthCallback
71
+ * @param {Object} reqObj - the request to send into the healthcheck
72
+ * @param {Callback} callback - The results of the call
73
+ */
74
+ healthCheck(reqObj, callback) {
75
+ // you can modify what is passed into the healthcheck by changing things in the newReq
76
+ let newReq = null;
77
+ if (reqObj) {
78
+ newReq = Object.assign(...reqObj);
79
+ }
80
+ super.healthCheck(newReq, callback);
81
+ }
82
+
83
+ /**
84
+ * @iapGetAdapterWorkflowFunctions
85
+ */
86
+ iapGetAdapterWorkflowFunctions(inIgnore) {
87
+ let myIgnore = [
88
+ 'healthCheck',
89
+ 'iapGetAdapterWorkflowFunctions',
90
+ 'hasEntities',
91
+ 'getAuthorization'
92
+ ];
93
+ if (!inIgnore && Array.isArray(inIgnore)) {
94
+ myIgnore = inIgnore;
95
+ } else if (!inIgnore && typeof inIgnore === 'string') {
96
+ myIgnore = [inIgnore];
97
+ }
98
+
99
+ // The generic adapter functions should already be ignored (e.g. healthCheck)
100
+ // you can add specific methods that you do not want to be workflow functions to ignore like below
101
+ // myIgnore.push('myMethodNotInWorkflow');
102
+
103
+ return super.iapGetAdapterWorkflowFunctions(myIgnore);
104
+ }
105
+
106
+ /**
107
+ * iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
108
+ * allows customers to make changes to adapter configuration without having to be on the
109
+ * file system.
110
+ *
111
+ * @function iapUpdateAdapterConfiguration
112
+ * @param {string} configFile - the name of the file being updated (required)
113
+ * @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
114
+ * @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
115
+ * @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
116
+ * @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
117
+ * @param {boolean} replace - true to replace entire mock data, false to merge/append
118
+ * @param {Callback} callback - The results of the call
119
+ */
120
+ iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, 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, replace, callback);
126
+ }
127
+
128
+ /**
129
+ * @summary Suspends adapter
130
+ *
131
+ * @function iapSuspendAdapter
132
+ * @param {Callback} callback - callback function
133
+ */
134
+ iapSuspendAdapter(mode, callback) {
135
+ const meth = 'adapter-iapSuspendAdapter';
136
+ const origin = `${this.id}-${meth}`;
137
+ log.trace(origin);
138
+
139
+ try {
140
+ return super.iapSuspendAdapter(mode, callback);
141
+ } catch (error) {
142
+ log.error(`${origin}: ${error}`);
143
+ return callback(null, error);
144
+ }
145
+ }
146
+
147
+ /**
148
+ * @summary Unsuspends adapter
149
+ *
150
+ * @function iapUnsuspendAdapter
151
+ * @param {Callback} callback - callback function
152
+ */
153
+ iapUnsuspendAdapter(callback) {
154
+ const meth = 'adapter-iapUnsuspendAdapter';
155
+ const origin = `${this.id}-${meth}`;
156
+ log.trace(origin);
157
+
158
+ try {
159
+ return super.iapUnsuspendAdapter(callback);
160
+ } catch (error) {
161
+ log.error(`${origin}: ${error}`);
162
+ return callback(null, error);
163
+ }
164
+ }
165
+
166
+ /**
167
+ * @summary Get the Adapter Queue
168
+ *
169
+ * @function iapGetAdapterQueue
170
+ * @param {Callback} callback - callback function
171
+ */
172
+ iapGetAdapterQueue(callback) {
173
+ const meth = 'adapter-iapGetAdapterQueue';
174
+ const origin = `${this.id}-${meth}`;
175
+ log.trace(origin);
176
+
177
+ return super.iapGetAdapterQueue(callback);
178
+ }
179
+
180
+ /* SCRIPT CALLS */
181
+ /**
182
+ * See if the API path provided is found in this adapter
183
+ *
184
+ * @function iapFindAdapterPath
185
+ * @param {string} apiPath - the api path to check on
186
+ * @param {Callback} callback - The results of the call
187
+ */
188
+ iapFindAdapterPath(apiPath, callback) {
189
+ const meth = 'adapter-iapFindAdapterPath';
190
+ const origin = `${this.id}-${meth}`;
191
+ log.trace(origin);
192
+
193
+ super.iapFindAdapterPath(apiPath, callback);
194
+ }
195
+
196
+ /**
197
+ * @summary Runs troubleshoot scripts for adapter
198
+ *
199
+ * @function iapTroubleshootAdapter
200
+ * @param {Object} props - the connection, healthcheck and authentication properties
201
+ *
202
+ * @param {Callback} callback - The results of the call
203
+ */
204
+ iapTroubleshootAdapter(props, callback) {
205
+ const meth = 'adapter-iapTroubleshootAdapter';
206
+ const origin = `${this.id}-${meth}`;
207
+ log.trace(origin);
208
+
209
+ try {
210
+ return super.iapTroubleshootAdapter(props, 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 {number} maxCalls - how many GET endpoints to test (optional)
261
+ * @param {Callback} callback - callback function
262
+ */
263
+ iapRunAdapterBasicGet(maxCalls, callback) {
264
+ const meth = 'adapter-iapRunAdapterBasicGet';
265
+ const origin = `${this.id}-${meth}`;
266
+ log.trace(origin);
267
+
268
+ try {
269
+ return super.iapRunAdapterBasicGet(maxCalls, callback);
270
+ } catch (error) {
271
+ log.error(`${origin}: ${error}`);
272
+ return callback(null, error);
273
+ }
274
+ }
275
+
276
+ /**
277
+ * @summary moves entites into Mongo DB
278
+ *
279
+ * @function iapMoveAdapterEntitiesToDB
280
+ * @param {getCallback} callback - a callback function to return the result (Generics)
281
+ * or the error
282
+ */
283
+ iapMoveAdapterEntitiesToDB(callback) {
284
+ const meth = 'adapter-iapMoveAdapterEntitiesToDB';
285
+ const origin = `${this.id}-${meth}`;
286
+ log.trace(origin);
287
+
288
+ try {
289
+ return super.iapMoveAdapterEntitiesToDB(callback);
290
+ } catch (err) {
291
+ log.error(`${origin}: ${err}`);
292
+ return callback(null, err);
293
+ }
294
+ }
295
+
296
+ /**
297
+ * @summary Deactivate adapter tasks
298
+ *
299
+ * @function iapDeactivateTasks
300
+ *
301
+ * @param {Array} tasks - List of tasks to deactivate
302
+ * @param {Callback} callback
303
+ */
304
+ iapDeactivateTasks(tasks, callback) {
305
+ const meth = 'adapter-iapDeactivateTasks';
306
+ const origin = `${this.id}-${meth}`;
307
+ log.trace(origin);
308
+
309
+ try {
310
+ return super.iapDeactivateTasks(tasks, callback);
311
+ } catch (err) {
312
+ log.error(`${origin}: ${err}`);
313
+ return callback(null, err);
314
+ }
315
+ }
316
+
317
+ /**
318
+ * @summary Activate adapter tasks that have previously been deactivated
319
+ *
320
+ * @function iapActivateTasks
321
+ *
322
+ * @param {Array} tasks - List of tasks to activate
323
+ * @param {Callback} callback
324
+ */
325
+ iapActivateTasks(tasks, callback) {
326
+ const meth = 'adapter-iapActivateTasks';
327
+ const origin = `${this.id}-${meth}`;
328
+ log.trace(origin);
329
+
330
+ try {
331
+ return super.iapActivateTasks(tasks, callback);
332
+ } catch (err) {
333
+ log.error(`${origin}: ${err}`);
334
+ return callback(null, err);
335
+ }
336
+ }
337
+
338
+ /* CACHE CALLS */
339
+ /**
340
+ * @summary Populate the cache for the given entities
341
+ *
342
+ * @function iapPopulateEntityCache
343
+ * @param {String/Array of Strings} entityType - the entity type(s) to populate
344
+ * @param {Callback} callback - whether the cache was updated or not for each entity type
345
+ *
346
+ * @returns status of the populate
347
+ */
348
+ iapPopulateEntityCache(entityTypes, callback) {
349
+ const meth = 'adapter-iapPopulateEntityCache';
350
+ const origin = `${this.id}-${meth}`;
351
+ log.trace(origin);
352
+
353
+ try {
354
+ return super.iapPopulateEntityCache(entityTypes, callback);
355
+ } catch (err) {
356
+ log.error(`${origin}: ${err}`);
357
+ return callback(null, err);
358
+ }
359
+ }
360
+
361
+ /**
362
+ * @summary Retrieves data from cache for specified entity type
363
+ *
364
+ * @function iapRetrieveEntitiesCache
365
+ * @param {String} entityType - entity of which to retrieve
366
+ * @param {Object} options - settings of which data to return and how to return it
367
+ * @param {Callback} callback - the data if it was retrieved
368
+ */
369
+ iapRetrieveEntitiesCache(entityType, options, callback) {
370
+ const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
371
+ const origin = `${this.id}-${meth}`;
372
+ log.trace(origin);
373
+
374
+ try {
375
+ return super.iapRetrieveEntitiesCache(entityType, options, callback);
376
+ } catch (err) {
377
+ log.error(`${origin}: ${err}`);
378
+ return callback(null, err);
379
+ }
380
+ }
381
+
382
+ /* BROKER CALLS */
383
+ /**
384
+ * @summary Determines if this adapter supports any in a list of entities
385
+ *
386
+ * @function hasEntities
387
+ * @param {String} entityType - the entity type to check for
388
+ * @param {Array} entityList - the list of entities we are looking for
389
+ *
390
+ * @param {Callback} callback - A map where the entity is the key and the
391
+ * value is true or false
392
+ */
393
+ hasEntities(entityType, entityList, callback) {
394
+ const meth = 'adapter-hasEntities';
395
+ const origin = `${this.id}-${meth}`;
396
+ log.trace(origin);
397
+
398
+ try {
399
+ return super.hasEntities(entityType, entityList, callback);
400
+ } catch (err) {
401
+ log.error(`${origin}: ${err}`);
402
+ return callback(null, err);
403
+ }
404
+ }
405
+
406
+ /**
407
+ * @summary Get Appliance that match the deviceName
408
+ *
409
+ * @function getDevice
410
+ * @param {String} deviceName - the deviceName to find (required)
411
+ *
412
+ * @param {getCallback} callback - a callback function to return the result
413
+ * (appliance) or the error
414
+ */
415
+ getDevice(deviceName, callback) {
416
+ const meth = 'adapter-getDevice';
417
+ const origin = `${this.id}-${meth}`;
418
+ log.trace(origin);
419
+
420
+ try {
421
+ return super.getDevice(deviceName, callback);
422
+ } catch (err) {
423
+ log.error(`${origin}: ${err}`);
424
+ return callback(null, err);
425
+ }
426
+ }
427
+
428
+ /**
429
+ * @summary Get Appliances that match the filter
430
+ *
431
+ * @function getDevicesFiltered
432
+ * @param {Object} options - the data to use to filter the appliances (optional)
433
+ *
434
+ * @param {getCallback} callback - a callback function to return the result
435
+ * (appliances) or the error
436
+ */
437
+ getDevicesFiltered(options, callback) {
438
+ const meth = 'adapter-getDevicesFiltered';
439
+ const origin = `${this.id}-${meth}`;
440
+ log.trace(origin);
441
+
442
+ try {
443
+ return super.getDevicesFiltered(options, callback);
444
+ } catch (err) {
445
+ log.error(`${origin}: ${err}`);
446
+ return callback(null, err);
447
+ }
448
+ }
449
+
450
+ /**
451
+ * @summary Gets the status for the provided appliance
452
+ *
453
+ * @function isAlive
454
+ * @param {String} deviceName - the deviceName of the appliance. (required)
455
+ *
456
+ * @param {configCallback} callback - callback function to return the result
457
+ * (appliance isAlive) or the error
458
+ */
459
+ isAlive(deviceName, callback) {
460
+ const meth = 'adapter-isAlive';
461
+ const origin = `${this.id}-${meth}`;
462
+ log.trace(origin);
463
+
464
+ try {
465
+ return super.isAlive(deviceName, callback);
466
+ } catch (err) {
467
+ log.error(`${origin}: ${err}`);
468
+ return callback(null, err);
469
+ }
470
+ }
471
+
472
+ /**
473
+ * @summary Gets a config for the provided Appliance
474
+ *
475
+ * @function getConfig
476
+ * @param {String} deviceName - the deviceName of the appliance. (required)
477
+ * @param {String} format - the desired format of the config. (optional)
478
+ *
479
+ * @param {configCallback} callback - callback function to return the result
480
+ * (appliance config) or the error
481
+ */
482
+ getConfig(deviceName, format, callback) {
483
+ const meth = 'adapter-getConfig';
484
+ const origin = `${this.id}-${meth}`;
485
+ log.trace(origin);
486
+
487
+ try {
488
+ return super.getConfig(deviceName, format, callback);
489
+ } catch (err) {
490
+ log.error(`${origin}: ${err}`);
491
+ return callback(null, err);
492
+ }
493
+ }
494
+
495
+ /**
496
+ * @summary Gets the device count from the system
497
+ *
498
+ * @function iapGetDeviceCount
499
+ *
500
+ * @param {getCallback} callback - callback function to return the result
501
+ * (count) or the error
502
+ */
503
+ iapGetDeviceCount(callback) {
504
+ const meth = 'adapter-iapGetDeviceCount';
505
+ const origin = `${this.id}-${meth}`;
506
+ log.trace(origin);
507
+
508
+ try {
509
+ return super.iapGetDeviceCount(callback);
510
+ } catch (err) {
511
+ log.error(`${origin}: ${err}`);
512
+ return callback(null, err);
513
+ }
514
+ }
515
+
516
+ /* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
517
+ /**
518
+ * Makes the requested generic call
519
+ *
520
+ * @function iapExpandedGenericAdapterRequest
521
+ * @param {Object} metadata - metadata for the call (optional).
522
+ * Can be a stringified Object.
523
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
524
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
525
+ * @param {Object} pathVars - the parameters to be put within the url path (optional).
526
+ * Can be a stringified Object.
527
+ * @param {Object} queryData - the parameters to be put on the url (optional).
528
+ * Can be a stringified Object.
529
+ * @param {Object} requestBody - the body to add to the request (optional).
530
+ * Can be a stringified Object.
531
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
532
+ * Can be a stringified Object.
533
+ * @param {getCallback} callback - a callback function to return the result (Generics)
534
+ * or the error
535
+ */
536
+ iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
537
+ const meth = 'adapter-iapExpandedGenericAdapterRequest';
538
+ const origin = `${this.id}-${meth}`;
539
+ log.trace(origin);
540
+
541
+ try {
542
+ return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
543
+ } catch (err) {
544
+ log.error(`${origin}: ${err}`);
545
+ return callback(null, err);
546
+ }
547
+ }
548
+
549
+ /**
550
+ * Makes the requested generic call
551
+ *
552
+ * @function genericAdapterRequest
553
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
554
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
555
+ * @param {Object} queryData - the parameters to be put on the url (optional).
556
+ * Can be a stringified Object.
557
+ * @param {Object} requestBody - the body to add to the request (optional).
558
+ * Can be a stringified Object.
559
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
560
+ * Can be a stringified Object.
561
+ * @param {getCallback} callback - a callback function to return the result (Generics)
562
+ * or the error
563
+ */
564
+ genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
565
+ const meth = 'adapter-genericAdapterRequest';
566
+ const origin = `${this.id}-${meth}`;
567
+ log.trace(origin);
568
+
569
+ try {
570
+ return super.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
571
+ } catch (err) {
572
+ log.error(`${origin}: ${err}`);
573
+ return callback(null, err);
574
+ }
575
+ }
576
+
577
+ /**
578
+ * Makes the requested generic call with no base path or version
579
+ *
580
+ * @function genericAdapterRequestNoBasePath
581
+ * @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
582
+ * @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
583
+ * @param {Object} queryData - the parameters to be put on the url (optional).
584
+ * Can be a stringified Object.
585
+ * @param {Object} requestBody - the body to add to the request (optional).
586
+ * Can be a stringified Object.
587
+ * @param {Object} addlHeaders - additional headers to be put on the call (optional).
588
+ * Can be a stringified Object.
589
+ * @param {getCallback} callback - a callback function to return the result (Generics)
590
+ * or the error
591
+ */
592
+ genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
593
+ const meth = 'adapter-genericAdapterRequestNoBasePath';
594
+ const origin = `${this.id}-${meth}`;
595
+ log.trace(origin);
596
+
597
+ try {
598
+ return super.genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
599
+ } catch (err) {
600
+ log.error(`${origin}: ${err}`);
601
+ return callback(null, err);
602
+ }
603
+ }
604
+
605
+ /* INVENTORY CALLS */
606
+ /**
607
+ * @summary run the adapter lint script to return the results.
608
+ *
609
+ * @function iapRunAdapterLint
610
+ * @param {Callback} callback - callback function
611
+ */
612
+ iapRunAdapterLint(callback) {
613
+ const meth = 'adapter-iapRunAdapterLint';
614
+ const origin = `${this.id}-${meth}`;
615
+ log.trace(origin);
616
+
617
+ return super.iapRunAdapterLint(callback);
618
+ }
619
+
620
+ /**
621
+ * @summary run the adapter test scripts (baseunit and unit) to return the results.
622
+ * can not run integration as there can be implications with that.
623
+ *
624
+ * @function iapRunAdapterTests
625
+ * @param {Callback} callback - callback function
626
+ */
627
+ iapRunAdapterTests(callback) {
628
+ const meth = 'adapter-iapRunAdapterTests';
629
+ const origin = `${this.id}-${meth}`;
630
+ log.trace(origin);
631
+
632
+ return super.iapRunAdapterTests(callback);
633
+ }
634
+
635
+ /**
636
+ * @summary provide inventory information abbout the adapter
637
+ *
638
+ * @function iapGetAdapterInventory
639
+ * @param {Callback} callback - callback function
640
+ */
641
+ iapGetAdapterInventory(callback) {
642
+ const meth = 'adapter-iapGetAdapterInventory';
643
+ const origin = `${this.id}-${meth}`;
644
+ log.trace(origin);
645
+
646
+ return super.iapGetAdapterInventory(callback);
647
+ }
648
+
649
+ /**
650
+ * @callback healthCallback
651
+ * @param {Object} result - the result of the get request (contains an id and a status)
652
+ */
653
+ /**
654
+ * @callback getCallback
655
+ * @param {Object} result - the result of the get request (entity/ies)
656
+ * @param {String} error - any error that occurred
657
+ */
658
+ /**
659
+ * @callback createCallback
660
+ * @param {Object} item - the newly created entity
661
+ * @param {String} error - any error that occurred
662
+ */
663
+ /**
664
+ * @callback updateCallback
665
+ * @param {String} status - the status of the update action
666
+ * @param {String} error - any error that occurred
667
+ */
668
+ /**
669
+ * @callback deleteCallback
670
+ * @param {String} status - the status of the delete action
671
+ * @param {String} error - any error that occurred
672
+ */
673
+
674
+ /**
675
+ * @function getAllInventoryV1InventoryGet
676
+ * @pronghornType method
677
+ * @name getAllInventoryV1InventoryGet
678
+ * @summary Get_all_inventory_v1_inventory_get
679
+ *
680
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
681
+ * @param {getCallback} callback - a callback function to return the result
682
+ * @return {object} results - An object containing the response of the action
683
+ *
684
+ * @route {GET} /getAllInventoryV1InventoryGet
685
+ * @roles admin
686
+ * @task true
687
+ */
688
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
689
+ getAllInventoryV1InventoryGet(iapMetadata, callback) {
690
+ const meth = 'adapter-getAllInventoryV1InventoryGet';
691
+ const origin = `${this.id}-${meth}`;
692
+ log.trace(origin);
693
+
694
+ if (this.suspended && this.suspendMode === 'error') {
695
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
696
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
697
+ return callback(null, errorObj);
698
+ }
699
+
700
+ /* HERE IS WHERE YOU VALIDATE DATA */
701
+
702
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
703
+ const queryParamsAvailable = {};
704
+ const queryParams = {};
705
+ const pathVars = [];
706
+ const bodyVars = {};
707
+
708
+ // loop in template. long callback arg name to avoid identifier conflicts
709
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
710
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
711
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
712
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
713
+ }
714
+ });
715
+
716
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
717
+ // see adapter code documentation for more information on the request object's fields
718
+ const reqObj = {
719
+ payload: bodyVars,
720
+ uriPathVars: pathVars,
721
+ uriQuery: queryParams
722
+ };
723
+
724
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
725
+
726
+ // Merge and add new iapMetadata fields in reqObj
727
+ if (iapMetadata && typeof iapMetadata === 'object') {
728
+ Object.keys(iapMetadata).forEach((iapField) => {
729
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
730
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
731
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
732
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
733
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
734
+ } else {
735
+ // Otherwise, add new iapMetadata fields to reqObj
736
+ reqObj[iapField] = iapMetadata[iapField];
737
+ }
738
+ }
739
+ });
740
+ // Add iapMetadata to reqObj for further work
741
+ reqObj.iapMetadata = iapMetadata;
742
+ }
743
+
744
+ try {
745
+ // Make the call -
746
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
747
+ return this.requestHandlerInst.identifyRequest('MetastoreInventoryNamesDownload', 'getAllInventoryV1InventoryGet', reqObj, true, (irReturnData, irReturnError) => {
748
+ // if we received an error or their is no response on the results
749
+ // return an error
750
+ if (irReturnError) {
751
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
752
+ return callback(null, irReturnError);
753
+ }
754
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
755
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getAllInventoryV1InventoryGet'], null, null, null);
756
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
757
+ return callback(null, errorObj);
758
+ }
759
+
760
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
761
+ // return the response
762
+ return callback(irReturnData, null);
763
+ });
764
+ } catch (ex) {
765
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
766
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
767
+ return callback(null, errorObj);
768
+ }
769
+ }
770
+
771
+ /**
772
+ * @function inventoryCreationV1InventoryPost
773
+ * @pronghornType method
774
+ * @name inventoryCreationV1InventoryPost
775
+ * @summary Inventory_creation_v1_inventory_post
776
+ *
777
+ * @param {object} body - body param
778
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
779
+ * @param {getCallback} callback - a callback function to return the result
780
+ * @return {object} results - An object containing the response of the action
781
+ *
782
+ * @route {POST} /inventoryCreationV1InventoryPost
783
+ * @roles admin
784
+ * @task true
785
+ */
786
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
787
+ inventoryCreationV1InventoryPost(body, iapMetadata, callback) {
788
+ const meth = 'adapter-inventoryCreationV1InventoryPost';
789
+ const origin = `${this.id}-${meth}`;
790
+ log.trace(origin);
791
+
792
+ if (this.suspended && this.suspendMode === 'error') {
793
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
794
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
795
+ return callback(null, errorObj);
796
+ }
797
+
798
+ /* HERE IS WHERE YOU VALIDATE DATA */
799
+ if (body === undefined || body === null || body === '') {
800
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
801
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
802
+ return callback(null, errorObj);
803
+ }
804
+
805
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
806
+ const queryParamsAvailable = {};
807
+ const queryParams = {};
808
+ const pathVars = [];
809
+ const bodyVars = body;
810
+
811
+ // loop in template. long callback arg name to avoid identifier conflicts
812
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
813
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
814
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
815
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
816
+ }
817
+ });
818
+
819
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
820
+ // see adapter code documentation for more information on the request object's fields
821
+ const reqObj = {
822
+ payload: bodyVars,
823
+ uriPathVars: pathVars,
824
+ uriQuery: queryParams
825
+ };
826
+
827
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
828
+
829
+ // Merge and add new iapMetadata fields in reqObj
830
+ if (iapMetadata && typeof iapMetadata === 'object') {
831
+ Object.keys(iapMetadata).forEach((iapField) => {
832
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
833
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
834
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
835
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
836
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
837
+ } else {
838
+ // Otherwise, add new iapMetadata fields to reqObj
839
+ reqObj[iapField] = iapMetadata[iapField];
840
+ }
841
+ }
842
+ });
843
+ // Add iapMetadata to reqObj for further work
844
+ reqObj.iapMetadata = iapMetadata;
845
+ }
846
+
847
+ try {
848
+ // Make the call -
849
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
850
+ return this.requestHandlerInst.identifyRequest('MetastoreInventoryNameUpload', 'inventoryCreationV1InventoryPost', reqObj, true, (irReturnData, irReturnError) => {
851
+ // if we received an error or their is no response on the results
852
+ // return an error
853
+ if (irReturnError) {
854
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
855
+ return callback(null, irReturnError);
856
+ }
857
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
858
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['inventoryCreationV1InventoryPost'], null, null, null);
859
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
860
+ return callback(null, errorObj);
861
+ }
862
+
863
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
864
+ // return the response
865
+ return callback(irReturnData, null);
866
+ });
867
+ } catch (ex) {
868
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
869
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
870
+ return callback(null, errorObj);
871
+ }
872
+ }
873
+
874
+ /**
875
+ * @function inventoryUpdateV1InventoryNamePut
876
+ * @pronghornType method
877
+ * @name inventoryUpdateV1InventoryNamePut
878
+ * @summary Inventory_update_v1_inventory__name__put
879
+ *
880
+ * @param {string} name - Name of the inventory to delete
881
+ * @param {object} body - body param
882
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
883
+ * @param {getCallback} callback - a callback function to return the result
884
+ * @return {object} results - An object containing the response of the action
885
+ *
886
+ * @route {POST} /inventoryUpdateV1InventoryNamePut
887
+ * @roles admin
888
+ * @task true
889
+ */
890
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
891
+ inventoryUpdateV1InventoryNamePut(name, body, iapMetadata, callback) {
892
+ const meth = 'adapter-inventoryUpdateV1InventoryNamePut';
893
+ const origin = `${this.id}-${meth}`;
894
+ log.trace(origin);
895
+
896
+ if (this.suspended && this.suspendMode === 'error') {
897
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
898
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
899
+ return callback(null, errorObj);
900
+ }
901
+
902
+ /* HERE IS WHERE YOU VALIDATE DATA */
903
+ if (name === undefined || name === null || name === '') {
904
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['name'], null, null, null);
905
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
906
+ return callback(null, errorObj);
907
+ }
908
+ if (body === undefined || body === null || body === '') {
909
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
910
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
911
+ return callback(null, errorObj);
912
+ }
913
+
914
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
915
+ const queryParamsAvailable = {};
916
+ const queryParams = {};
917
+ const pathVars = [name];
918
+ const bodyVars = body;
919
+
920
+ // loop in template. long callback arg name to avoid identifier conflicts
921
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
922
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
923
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
924
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
925
+ }
926
+ });
927
+
928
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
929
+ // see adapter code documentation for more information on the request object's fields
930
+ const reqObj = {
931
+ payload: bodyVars,
932
+ uriPathVars: pathVars,
933
+ uriQuery: queryParams
934
+ };
935
+
936
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
937
+
938
+ // Merge and add new iapMetadata fields in reqObj
939
+ if (iapMetadata && typeof iapMetadata === 'object') {
940
+ Object.keys(iapMetadata).forEach((iapField) => {
941
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
942
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
943
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
944
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
945
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
946
+ } else {
947
+ // Otherwise, add new iapMetadata fields to reqObj
948
+ reqObj[iapField] = iapMetadata[iapField];
949
+ }
950
+ }
951
+ });
952
+ // Add iapMetadata to reqObj for further work
953
+ reqObj.iapMetadata = iapMetadata;
954
+ }
955
+
956
+ try {
957
+ // Make the call -
958
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
959
+ return this.requestHandlerInst.identifyRequest('MetastoreInventoryNameUpdate', 'inventoryUpdateV1InventoryNamePut', reqObj, true, (irReturnData, irReturnError) => {
960
+ // if we received an error or their is no response on the results
961
+ // return an error
962
+ if (irReturnError) {
963
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
964
+ return callback(null, irReturnError);
965
+ }
966
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
967
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['inventoryUpdateV1InventoryNamePut'], null, null, null);
968
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
969
+ return callback(null, errorObj);
970
+ }
971
+
972
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
973
+ // return the response
974
+ return callback(irReturnData, null);
975
+ });
976
+ } catch (ex) {
977
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
978
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
979
+ return callback(null, errorObj);
980
+ }
981
+ }
982
+
983
+ /**
984
+ * @function deletingSpecificInventoryV1InventoryNameDelete
985
+ * @pronghornType method
986
+ * @name deletingSpecificInventoryV1InventoryNameDelete
987
+ * @summary Deleting_Specific_Inventory_v1_inventory__name__delete
988
+ *
989
+ * @param {string} name - Name of the inventory to delete
990
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
991
+ * @param {getCallback} callback - a callback function to return the result
992
+ * @return {object} results - An object containing the response of the action
993
+ *
994
+ * @route {POST} /deletingSpecificInventoryV1InventoryNameDelete
995
+ * @roles admin
996
+ * @task true
997
+ */
998
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
999
+ deletingSpecificInventoryV1InventoryNameDelete(name, iapMetadata, callback) {
1000
+ const meth = 'adapter-deletingSpecificInventoryV1InventoryNameDelete';
1001
+ const origin = `${this.id}-${meth}`;
1002
+ log.trace(origin);
1003
+
1004
+ if (this.suspended && this.suspendMode === 'error') {
1005
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1006
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1007
+ return callback(null, errorObj);
1008
+ }
1009
+
1010
+ /* HERE IS WHERE YOU VALIDATE DATA */
1011
+ if (name === undefined || name === null || name === '') {
1012
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['name'], null, null, null);
1013
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1014
+ return callback(null, errorObj);
1015
+ }
1016
+
1017
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1018
+ const queryParamsAvailable = {};
1019
+ const queryParams = {};
1020
+ const pathVars = [name];
1021
+ const bodyVars = {};
1022
+
1023
+ // loop in template. long callback arg name to avoid identifier conflicts
1024
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1025
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1026
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1027
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1028
+ }
1029
+ });
1030
+
1031
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1032
+ // see adapter code documentation for more information on the request object's fields
1033
+ const reqObj = {
1034
+ payload: bodyVars,
1035
+ uriPathVars: pathVars,
1036
+ uriQuery: queryParams
1037
+ };
1038
+
1039
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
1040
+
1041
+ // Merge and add new iapMetadata fields in reqObj
1042
+ if (iapMetadata && typeof iapMetadata === 'object') {
1043
+ Object.keys(iapMetadata).forEach((iapField) => {
1044
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
1045
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
1046
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
1047
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
1048
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
1049
+ } else {
1050
+ // Otherwise, add new iapMetadata fields to reqObj
1051
+ reqObj[iapField] = iapMetadata[iapField];
1052
+ }
1053
+ }
1054
+ });
1055
+ // Add iapMetadata to reqObj for further work
1056
+ reqObj.iapMetadata = iapMetadata;
1057
+ }
1058
+
1059
+ try {
1060
+ // Make the call -
1061
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1062
+ return this.requestHandlerInst.identifyRequest('MetastoreInventoryNameDelete', 'deletingSpecificInventoryV1InventoryNameDelete', reqObj, false, (irReturnData, irReturnError) => {
1063
+ // if we received an error or their is no response on the results
1064
+ // return an error
1065
+ if (irReturnError) {
1066
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1067
+ return callback(null, irReturnError);
1068
+ }
1069
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1070
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletingSpecificInventoryV1InventoryNameDelete'], null, null, null);
1071
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1072
+ return callback(null, errorObj);
1073
+ }
1074
+
1075
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1076
+ // return the response
1077
+ return callback(irReturnData, null);
1078
+ });
1079
+ } catch (ex) {
1080
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1081
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1082
+ return callback(null, errorObj);
1083
+ }
1084
+ }
1085
+
1086
+ /**
1087
+ * @function inventoryItemGetV1InventoryNameGet
1088
+ * @pronghornType method
1089
+ * @name inventoryItemGetV1InventoryNameGet
1090
+ * @summary Inventory_Item_get_v1_inventory__name__get
1091
+ *
1092
+ * @param {string} name - name param
1093
+ * @param {string} [pattern] - pattern param
1094
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
1095
+ * @param {getCallback} callback - a callback function to return the result
1096
+ * @return {object} results - An object containing the response of the action
1097
+ *
1098
+ * @route {POST} /inventoryItemGetV1InventoryNameGet
1099
+ * @roles admin
1100
+ * @task true
1101
+ */
1102
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1103
+ inventoryItemGetV1InventoryNameGet(name, pattern, iapMetadata, callback) {
1104
+ const meth = 'adapter-inventoryItemGetV1InventoryNameGet';
1105
+ const origin = `${this.id}-${meth}`;
1106
+ log.trace(origin);
1107
+
1108
+ if (this.suspended && this.suspendMode === 'error') {
1109
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1110
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1111
+ return callback(null, errorObj);
1112
+ }
1113
+
1114
+ /* HERE IS WHERE YOU VALIDATE DATA */
1115
+ if (name === undefined || name === null || name === '') {
1116
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['name'], null, null, null);
1117
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1118
+ return callback(null, errorObj);
1119
+ }
1120
+
1121
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1122
+ const queryParamsAvailable = { pattern };
1123
+ const queryParams = {};
1124
+ const pathVars = [name];
1125
+ const bodyVars = {};
1126
+
1127
+ // loop in template. long callback arg name to avoid identifier conflicts
1128
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1129
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1130
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1131
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1132
+ }
1133
+ });
1134
+
1135
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1136
+ // see adapter code documentation for more information on the request object's fields
1137
+ const reqObj = {
1138
+ payload: bodyVars,
1139
+ uriPathVars: pathVars,
1140
+ uriQuery: queryParams
1141
+ };
1142
+
1143
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
1144
+
1145
+ // Merge and add new iapMetadata fields in reqObj
1146
+ if (iapMetadata && typeof iapMetadata === 'object') {
1147
+ Object.keys(iapMetadata).forEach((iapField) => {
1148
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
1149
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
1150
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
1151
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
1152
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
1153
+ } else {
1154
+ // Otherwise, add new iapMetadata fields to reqObj
1155
+ reqObj[iapField] = iapMetadata[iapField];
1156
+ }
1157
+ }
1158
+ });
1159
+ // Add iapMetadata to reqObj for further work
1160
+ reqObj.iapMetadata = iapMetadata;
1161
+ }
1162
+
1163
+ try {
1164
+ // Make the call -
1165
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1166
+ return this.requestHandlerInst.identifyRequest('MetastoreInventoryDataDownload', 'inventoryItemGetV1InventoryNameGet', reqObj, true, (irReturnData, irReturnError) => {
1167
+ // if we received an error or their is no response on the results
1168
+ // return an error
1169
+ if (irReturnError) {
1170
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1171
+ return callback(null, irReturnError);
1172
+ }
1173
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1174
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['inventoryItemGetV1InventoryNameGet'], null, null, null);
1175
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1176
+ return callback(null, errorObj);
1177
+ }
1178
+
1179
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1180
+ // return the response
1181
+ return callback(irReturnData, null);
1182
+ });
1183
+ } catch (ex) {
1184
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1185
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1186
+ return callback(null, errorObj);
1187
+ }
1188
+ }
1189
+
1190
+ /**
1191
+ * @function inventoryItemGetV1InventoryNameIdGet
1192
+ * @pronghornType method
1193
+ * @name inventoryItemGetV1InventoryNameIdGet
1194
+ * @summary Inventory_Item_get_v1_inventory__name___id__get
1195
+ *
1196
+ * @param {string} name - name param
1197
+ * @param {string} id - id param
1198
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
1199
+ * @param {getCallback} callback - a callback function to return the result
1200
+ * @return {object} results - An object containing the response of the action
1201
+ *
1202
+ * @route {POST} /inventoryItemGetV1InventoryNameIdGet
1203
+ * @roles admin
1204
+ * @task true
1205
+ */
1206
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1207
+ inventoryItemGetV1InventoryNameIdGet(name, id, iapMetadata, callback) {
1208
+ const meth = 'adapter-inventoryItemGetV1InventoryNameIdGet';
1209
+ const origin = `${this.id}-${meth}`;
1210
+ log.trace(origin);
1211
+
1212
+ if (this.suspended && this.suspendMode === 'error') {
1213
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1214
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1215
+ return callback(null, errorObj);
1216
+ }
1217
+
1218
+ /* HERE IS WHERE YOU VALIDATE DATA */
1219
+ if (name === undefined || name === null || name === '') {
1220
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['name'], null, null, null);
1221
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1222
+ return callback(null, errorObj);
1223
+ }
1224
+ if (id === undefined || id === null || id === '') {
1225
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
1226
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1227
+ return callback(null, errorObj);
1228
+ }
1229
+
1230
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1231
+ const queryParamsAvailable = {};
1232
+ const queryParams = {};
1233
+ const pathVars = [name, id];
1234
+ const bodyVars = {};
1235
+
1236
+ // loop in template. long callback arg name to avoid identifier conflicts
1237
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1238
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1239
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1240
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1241
+ }
1242
+ });
1243
+
1244
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1245
+ // see adapter code documentation for more information on the request object's fields
1246
+ const reqObj = {
1247
+ payload: bodyVars,
1248
+ uriPathVars: pathVars,
1249
+ uriQuery: queryParams
1250
+ };
1251
+
1252
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
1253
+
1254
+ // Merge and add new iapMetadata fields in reqObj
1255
+ if (iapMetadata && typeof iapMetadata === 'object') {
1256
+ Object.keys(iapMetadata).forEach((iapField) => {
1257
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
1258
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
1259
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
1260
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
1261
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
1262
+ } else {
1263
+ // Otherwise, add new iapMetadata fields to reqObj
1264
+ reqObj[iapField] = iapMetadata[iapField];
1265
+ }
1266
+ }
1267
+ });
1268
+ // Add iapMetadata to reqObj for further work
1269
+ reqObj.iapMetadata = iapMetadata;
1270
+ }
1271
+
1272
+ try {
1273
+ // Make the call -
1274
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1275
+ return this.requestHandlerInst.identifyRequest('MetastoreInventoryDataDownload', 'inventoryItemGetV1InventoryNameIdGet', reqObj, true, (irReturnData, irReturnError) => {
1276
+ // if we received an error or their is no response on the results
1277
+ // return an error
1278
+ if (irReturnError) {
1279
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1280
+ return callback(null, irReturnError);
1281
+ }
1282
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1283
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['inventoryItemGetV1InventoryNameIdGet'], null, null, null);
1284
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1285
+ return callback(null, errorObj);
1286
+ }
1287
+
1288
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1289
+ // return the response
1290
+ return callback(irReturnData, null);
1291
+ });
1292
+ } catch (ex) {
1293
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1294
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1295
+ return callback(null, errorObj);
1296
+ }
1297
+ }
1298
+
1299
+ /**
1300
+ * @function inventoryItemCreationV1InventoryNamePost
1301
+ * @pronghornType method
1302
+ * @name inventoryItemCreationV1InventoryNamePost
1303
+ * @summary Inventory_Item_creation_v1_inventory__name__post
1304
+ *
1305
+ * @param {string} name - name param
1306
+ * @param {object} body - body param
1307
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
1308
+ * @param {getCallback} callback - a callback function to return the result
1309
+ * @return {object} results - An object containing the response of the action
1310
+ *
1311
+ * @route {POST} /inventoryItemCreationV1InventoryNamePost
1312
+ * @roles admin
1313
+ * @task true
1314
+ */
1315
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1316
+ inventoryItemCreationV1InventoryNamePost(name, body, iapMetadata, callback) {
1317
+ const meth = 'adapter-inventoryItemCreationV1InventoryNamePost';
1318
+ const origin = `${this.id}-${meth}`;
1319
+ log.trace(origin);
1320
+
1321
+ if (this.suspended && this.suspendMode === 'error') {
1322
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1323
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1324
+ return callback(null, errorObj);
1325
+ }
1326
+
1327
+ /* HERE IS WHERE YOU VALIDATE DATA */
1328
+ if (name === undefined || name === null || name === '') {
1329
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['name'], null, null, null);
1330
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1331
+ return callback(null, errorObj);
1332
+ }
1333
+ if (body === undefined || body === null || body === '') {
1334
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1335
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1336
+ return callback(null, errorObj);
1337
+ }
1338
+
1339
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1340
+ const queryParamsAvailable = {};
1341
+ const queryParams = {};
1342
+ const pathVars = [name];
1343
+ const bodyVars = body;
1344
+
1345
+ // loop in template. long callback arg name to avoid identifier conflicts
1346
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1347
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1348
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1349
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1350
+ }
1351
+ });
1352
+
1353
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1354
+ // see adapter code documentation for more information on the request object's fields
1355
+ const reqObj = {
1356
+ payload: bodyVars,
1357
+ uriPathVars: pathVars,
1358
+ uriQuery: queryParams
1359
+ };
1360
+
1361
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
1362
+
1363
+ // Merge and add new iapMetadata fields in reqObj
1364
+ if (iapMetadata && typeof iapMetadata === 'object') {
1365
+ Object.keys(iapMetadata).forEach((iapField) => {
1366
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
1367
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
1368
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
1369
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
1370
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
1371
+ } else {
1372
+ // Otherwise, add new iapMetadata fields to reqObj
1373
+ reqObj[iapField] = iapMetadata[iapField];
1374
+ }
1375
+ }
1376
+ });
1377
+ // Add iapMetadata to reqObj for further work
1378
+ reqObj.iapMetadata = iapMetadata;
1379
+ }
1380
+
1381
+ try {
1382
+ // Make the call -
1383
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1384
+ return this.requestHandlerInst.identifyRequest('MetastoreInventoryDataUpload', 'inventoryItemCreationV1InventoryNamePost', reqObj, true, (irReturnData, irReturnError) => {
1385
+ // if we received an error or their is no response on the results
1386
+ // return an error
1387
+ if (irReturnError) {
1388
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1389
+ return callback(null, irReturnError);
1390
+ }
1391
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1392
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['inventoryItemCreationV1InventoryNamePost'], null, null, null);
1393
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1394
+ return callback(null, errorObj);
1395
+ }
1396
+
1397
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1398
+ // return the response
1399
+ return callback(irReturnData, null);
1400
+ });
1401
+ } catch (ex) {
1402
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1403
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1404
+ return callback(null, errorObj);
1405
+ }
1406
+ }
1407
+
1408
+ /**
1409
+ * @function inventoryItemCreationV1InventoryNameIdPut
1410
+ * @pronghornType method
1411
+ * @name inventoryItemCreationV1InventoryNameIdPut
1412
+ * @summary Inventory_Item_creation_v1_inventory__name___id__put
1413
+ *
1414
+ * @param {string} name - name param
1415
+ * @param {string} id - id param
1416
+ * @param {object} body - body param
1417
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
1418
+ * @param {getCallback} callback - a callback function to return the result
1419
+ * @return {object} results - An object containing the response of the action
1420
+ *
1421
+ * @route {POST} /inventoryItemCreationV1InventoryNameIdPut
1422
+ * @roles admin
1423
+ * @task true
1424
+ */
1425
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1426
+ inventoryItemCreationV1InventoryNameIdPut(name, id, body, iapMetadata, callback) {
1427
+ const meth = 'adapter-inventoryItemCreationV1InventoryNameIdPut';
1428
+ const origin = `${this.id}-${meth}`;
1429
+ log.trace(origin);
1430
+
1431
+ if (this.suspended && this.suspendMode === 'error') {
1432
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1433
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1434
+ return callback(null, errorObj);
1435
+ }
1436
+
1437
+ /* HERE IS WHERE YOU VALIDATE DATA */
1438
+ if (name === undefined || name === null || name === '') {
1439
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['name'], null, null, null);
1440
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1441
+ return callback(null, errorObj);
1442
+ }
1443
+ if (id === undefined || id === null || id === '') {
1444
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
1445
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1446
+ return callback(null, errorObj);
1447
+ }
1448
+ if (body === undefined || body === null || body === '') {
1449
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1450
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1451
+ return callback(null, errorObj);
1452
+ }
1453
+
1454
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1455
+ const queryParamsAvailable = {};
1456
+ const queryParams = {};
1457
+ const pathVars = [name, id];
1458
+ const bodyVars = body;
1459
+
1460
+ // loop in template. long callback arg name to avoid identifier conflicts
1461
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1462
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1463
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1464
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1465
+ }
1466
+ });
1467
+
1468
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1469
+ // see adapter code documentation for more information on the request object's fields
1470
+ const reqObj = {
1471
+ payload: bodyVars,
1472
+ uriPathVars: pathVars,
1473
+ uriQuery: queryParams
1474
+ };
1475
+
1476
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
1477
+
1478
+ // Merge and add new iapMetadata fields in reqObj
1479
+ if (iapMetadata && typeof iapMetadata === 'object') {
1480
+ Object.keys(iapMetadata).forEach((iapField) => {
1481
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
1482
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
1483
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
1484
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
1485
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
1486
+ } else {
1487
+ // Otherwise, add new iapMetadata fields to reqObj
1488
+ reqObj[iapField] = iapMetadata[iapField];
1489
+ }
1490
+ }
1491
+ });
1492
+ // Add iapMetadata to reqObj for further work
1493
+ reqObj.iapMetadata = iapMetadata;
1494
+ }
1495
+
1496
+ try {
1497
+ // Make the call -
1498
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1499
+ return this.requestHandlerInst.identifyRequest('MetastoreInventoryDataEdit', 'inventoryItemCreationV1InventoryNameIdPut', reqObj, true, (irReturnData, irReturnError) => {
1500
+ // if we received an error or their is no response on the results
1501
+ // return an error
1502
+ if (irReturnError) {
1503
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1504
+ return callback(null, irReturnError);
1505
+ }
1506
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1507
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['inventoryItemCreationV1InventoryNameIdPut'], null, null, null);
1508
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1509
+ return callback(null, errorObj);
1510
+ }
1511
+
1512
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1513
+ // return the response
1514
+ return callback(irReturnData, null);
1515
+ });
1516
+ } catch (ex) {
1517
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1518
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1519
+ return callback(null, errorObj);
1520
+ }
1521
+ }
1522
+
1523
+ /**
1524
+ * @function inventoryItemDeletionV1InventoryNameIdDelete
1525
+ * @pronghornType method
1526
+ * @name inventoryItemDeletionV1InventoryNameIdDelete
1527
+ * @summary Inventory_Item_deletion_v1_inventory__name___id__delete
1528
+ *
1529
+ * @param {string} name - name param
1530
+ * @param {string} id - id param
1531
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
1532
+ * @param {getCallback} callback - a callback function to return the result
1533
+ * @return {object} results - An object containing the response of the action
1534
+ *
1535
+ * @route {POST} /inventoryItemDeletionV1InventoryNameIdDelete
1536
+ * @roles admin
1537
+ * @task true
1538
+ */
1539
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1540
+ inventoryItemDeletionV1InventoryNameIdDelete(name, id, iapMetadata, callback) {
1541
+ const meth = 'adapter-inventoryItemDeletionV1InventoryNameIdDelete';
1542
+ const origin = `${this.id}-${meth}`;
1543
+ log.trace(origin);
1544
+
1545
+ if (this.suspended && this.suspendMode === 'error') {
1546
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1547
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1548
+ return callback(null, errorObj);
1549
+ }
1550
+
1551
+ /* HERE IS WHERE YOU VALIDATE DATA */
1552
+ if (name === undefined || name === null || name === '') {
1553
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['name'], null, null, null);
1554
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1555
+ return callback(null, errorObj);
1556
+ }
1557
+ if (id === undefined || id === null || id === '') {
1558
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
1559
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1560
+ return callback(null, errorObj);
1561
+ }
1562
+
1563
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1564
+ const queryParamsAvailable = {};
1565
+ const queryParams = {};
1566
+ const pathVars = [name, id];
1567
+ const bodyVars = {};
1568
+
1569
+ // loop in template. long callback arg name to avoid identifier conflicts
1570
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1571
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1572
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1573
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1574
+ }
1575
+ });
1576
+
1577
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1578
+ // see adapter code documentation for more information on the request object's fields
1579
+ const reqObj = {
1580
+ payload: bodyVars,
1581
+ uriPathVars: pathVars,
1582
+ uriQuery: queryParams
1583
+ };
1584
+
1585
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
1586
+
1587
+ // Merge and add new iapMetadata fields in reqObj
1588
+ if (iapMetadata && typeof iapMetadata === 'object') {
1589
+ Object.keys(iapMetadata).forEach((iapField) => {
1590
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
1591
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
1592
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
1593
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
1594
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
1595
+ } else {
1596
+ // Otherwise, add new iapMetadata fields to reqObj
1597
+ reqObj[iapField] = iapMetadata[iapField];
1598
+ }
1599
+ }
1600
+ });
1601
+ // Add iapMetadata to reqObj for further work
1602
+ reqObj.iapMetadata = iapMetadata;
1603
+ }
1604
+
1605
+ try {
1606
+ // Make the call -
1607
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1608
+ return this.requestHandlerInst.identifyRequest('MetastoreInventoryDataDelete', 'inventoryItemDeletionV1InventoryNameIdDelete', reqObj, false, (irReturnData, irReturnError) => {
1609
+ // if we received an error or their is no response on the results
1610
+ // return an error
1611
+ if (irReturnError) {
1612
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1613
+ return callback(null, irReturnError);
1614
+ }
1615
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1616
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['inventoryItemDeletionV1InventoryNameIdDelete'], null, null, null);
1617
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1618
+ return callback(null, errorObj);
1619
+ }
1620
+
1621
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1622
+ // return the response
1623
+ return callback(irReturnData, null);
1624
+ });
1625
+ } catch (ex) {
1626
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1627
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1628
+ return callback(null, errorObj);
1629
+ }
1630
+ }
1631
+
1632
+ /**
1633
+ * @function inventoryItemCreationV1InventoryBulkNamePost
1634
+ * @pronghornType method
1635
+ * @name inventoryItemCreationV1InventoryBulkNamePost
1636
+ * @summary Inventory_Item_creation_v1_inventory_bulk__name__post
1637
+ *
1638
+ * @param {string} name - name param
1639
+ * @param {boolean} [merge] - merge param
1640
+ * @param {array} body - body param
1641
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
1642
+ * @param {getCallback} callback - a callback function to return the result
1643
+ * @return {object} results - An object containing the response of the action
1644
+ *
1645
+ * @route {POST} /inventoryItemCreationV1InventoryBulkNamePost
1646
+ * @roles admin
1647
+ * @task true
1648
+ */
1649
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1650
+ inventoryItemCreationV1InventoryBulkNamePost(name, merge, body, iapMetadata, callback) {
1651
+ const meth = 'adapter-inventoryItemCreationV1InventoryBulkNamePost';
1652
+ const origin = `${this.id}-${meth}`;
1653
+ log.trace(origin);
1654
+
1655
+ if (this.suspended && this.suspendMode === 'error') {
1656
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1657
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1658
+ return callback(null, errorObj);
1659
+ }
1660
+
1661
+ /* HERE IS WHERE YOU VALIDATE DATA */
1662
+ if (name === undefined || name === null || name === '') {
1663
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['name'], null, null, null);
1664
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1665
+ return callback(null, errorObj);
1666
+ }
1667
+ if (body === undefined || body === null || body === '') {
1668
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1669
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1670
+ return callback(null, errorObj);
1671
+ }
1672
+
1673
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1674
+ const queryParamsAvailable = { merge };
1675
+ const queryParams = {};
1676
+ const pathVars = [name];
1677
+ const bodyVars = { body };
1678
+
1679
+ // loop in template. long callback arg name to avoid identifier conflicts
1680
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1681
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1682
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1683
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1684
+ }
1685
+ });
1686
+
1687
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1688
+ // see adapter code documentation for more information on the request object's fields
1689
+ const reqObj = {
1690
+ payload: bodyVars,
1691
+ uriPathVars: pathVars,
1692
+ uriQuery: queryParams
1693
+ };
1694
+
1695
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
1696
+
1697
+ // Merge and add new iapMetadata fields in reqObj
1698
+ if (iapMetadata && typeof iapMetadata === 'object') {
1699
+ Object.keys(iapMetadata).forEach((iapField) => {
1700
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
1701
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
1702
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
1703
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
1704
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
1705
+ } else {
1706
+ // Otherwise, add new iapMetadata fields to reqObj
1707
+ reqObj[iapField] = iapMetadata[iapField];
1708
+ }
1709
+ }
1710
+ });
1711
+ // Add iapMetadata to reqObj for further work
1712
+ reqObj.iapMetadata = iapMetadata;
1713
+ }
1714
+
1715
+ try {
1716
+ // Make the call -
1717
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1718
+ return this.requestHandlerInst.identifyRequest('MetastoreInventoryBulkDataUpload', 'inventoryItemCreationV1InventoryBulkNamePost', reqObj, true, (irReturnData, irReturnError) => {
1719
+ // if we received an error or their is no response on the results
1720
+ // return an error
1721
+ if (irReturnError) {
1722
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1723
+ return callback(null, irReturnError);
1724
+ }
1725
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1726
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['inventoryItemCreationV1InventoryBulkNamePost'], null, null, null);
1727
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1728
+ return callback(null, errorObj);
1729
+ }
1730
+
1731
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1732
+ // return the response
1733
+ return callback(irReturnData, null);
1734
+ });
1735
+ } catch (ex) {
1736
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1737
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1738
+ return callback(null, errorObj);
1739
+ }
1740
+ }
1741
+
1742
+ /**
1743
+ * @function inventoryItemCreationV1InventoryCsvNamePost
1744
+ * @pronghornType method
1745
+ * @name inventoryItemCreationV1InventoryCsvNamePost
1746
+ * @summary Inventory_Item_creation_v1_inventory_csv__name__post
1747
+ *
1748
+ * @param {string} name - name param
1749
+ * @param {boolean} [merge] - merge param
1750
+ * @param {string} file - file param
1751
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
1752
+ * @param {getCallback} callback - a callback function to return the result
1753
+ * @return {object} results - An object containing the response of the action
1754
+ *
1755
+ * @route {POST} /inventoryItemCreationV1InventoryCsvNamePost
1756
+ * @roles admin
1757
+ * @task true
1758
+ */
1759
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1760
+ inventoryItemCreationV1InventoryCsvNamePost(name, merge, file, iapMetadata, callback) {
1761
+ const meth = 'adapter-inventoryItemCreationV1InventoryCsvNamePost';
1762
+ const origin = `${this.id}-${meth}`;
1763
+ log.trace(origin);
1764
+
1765
+ if (this.suspended && this.suspendMode === 'error') {
1766
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1767
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1768
+ return callback(null, errorObj);
1769
+ }
1770
+
1771
+ /* HERE IS WHERE YOU VALIDATE DATA */
1772
+ if (name === undefined || name === null || name === '') {
1773
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['name'], null, null, null);
1774
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1775
+ return callback(null, errorObj);
1776
+ }
1777
+ if (file === undefined || file === null || file === '') {
1778
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['file'], null, null, null);
1779
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1780
+ return callback(null, errorObj);
1781
+ }
1782
+
1783
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1784
+ const queryParamsAvailable = { merge };
1785
+ const queryParams = {};
1786
+ const pathVars = [name];
1787
+ const bodyVars = { file };
1788
+
1789
+ // loop in template. long callback arg name to avoid identifier conflicts
1790
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1791
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1792
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1793
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1794
+ }
1795
+ });
1796
+
1797
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1798
+ // see adapter code documentation for more information on the request object's fields
1799
+ const reqObj = {
1800
+ payload: bodyVars,
1801
+ uriPathVars: pathVars,
1802
+ uriQuery: queryParams
1803
+ };
1804
+
1805
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
1806
+
1807
+ // Merge and add new iapMetadata fields in reqObj
1808
+ if (iapMetadata && typeof iapMetadata === 'object') {
1809
+ Object.keys(iapMetadata).forEach((iapField) => {
1810
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
1811
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
1812
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
1813
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
1814
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
1815
+ } else {
1816
+ // Otherwise, add new iapMetadata fields to reqObj
1817
+ reqObj[iapField] = iapMetadata[iapField];
1818
+ }
1819
+ }
1820
+ });
1821
+ // Add iapMetadata to reqObj for further work
1822
+ reqObj.iapMetadata = iapMetadata;
1823
+ }
1824
+
1825
+ try {
1826
+ // Make the call -
1827
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1828
+ return this.requestHandlerInst.identifyRequest('MetastoreInventoryCSVDataUpload', 'inventoryItemCreationV1InventoryCsvNamePost', reqObj, true, (irReturnData, irReturnError) => {
1829
+ // if we received an error or their is no response on the results
1830
+ // return an error
1831
+ if (irReturnError) {
1832
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1833
+ return callback(null, irReturnError);
1834
+ }
1835
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1836
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['inventoryItemCreationV1InventoryCsvNamePost'], null, null, null);
1837
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1838
+ return callback(null, errorObj);
1839
+ }
1840
+
1841
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1842
+ // return the response
1843
+ return callback(irReturnData, null);
1844
+ });
1845
+ } catch (ex) {
1846
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1847
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1848
+ return callback(null, errorObj);
1849
+ }
1850
+ }
1851
+
1852
+ /**
1853
+ * @function inventoryItemGetV1InventoryItemsGet
1854
+ * @pronghornType method
1855
+ * @name inventoryItemGetV1InventoryItemsGet
1856
+ * @summary Inventory_Item_get_v1_inventory_items_get
1857
+ *
1858
+ * @param {string} [type] - type param
1859
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
1860
+ * @param {getCallback} callback - a callback function to return the result
1861
+ * @return {object} results - An object containing the response of the action
1862
+ *
1863
+ * @route {POST} /inventoryItemGetV1InventoryItemsGet
1864
+ * @roles admin
1865
+ * @task true
1866
+ */
1867
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1868
+ inventoryItemGetV1InventoryItemsGet(type, iapMetadata, callback) {
1869
+ const meth = 'adapter-inventoryItemGetV1InventoryItemsGet';
1870
+ const origin = `${this.id}-${meth}`;
1871
+ log.trace(origin);
1872
+
1873
+ if (this.suspended && this.suspendMode === 'error') {
1874
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1875
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1876
+ return callback(null, errorObj);
1877
+ }
1878
+
1879
+ /* HERE IS WHERE YOU VALIDATE DATA */
1880
+
1881
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1882
+ const queryParamsAvailable = { type };
1883
+ const queryParams = {};
1884
+ const pathVars = [];
1885
+ const bodyVars = {};
1886
+
1887
+ // loop in template. long callback arg name to avoid identifier conflicts
1888
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1889
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1890
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1891
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1892
+ }
1893
+ });
1894
+
1895
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1896
+ // see adapter code documentation for more information on the request object's fields
1897
+ const reqObj = {
1898
+ payload: bodyVars,
1899
+ uriPathVars: pathVars,
1900
+ uriQuery: queryParams
1901
+ };
1902
+
1903
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
1904
+
1905
+ // Merge and add new iapMetadata fields in reqObj
1906
+ if (iapMetadata && typeof iapMetadata === 'object') {
1907
+ Object.keys(iapMetadata).forEach((iapField) => {
1908
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
1909
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
1910
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
1911
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
1912
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
1913
+ } else {
1914
+ // Otherwise, add new iapMetadata fields to reqObj
1915
+ reqObj[iapField] = iapMetadata[iapField];
1916
+ }
1917
+ }
1918
+ });
1919
+ // Add iapMetadata to reqObj for further work
1920
+ reqObj.iapMetadata = iapMetadata;
1921
+ }
1922
+
1923
+ try {
1924
+ // Make the call -
1925
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1926
+ return this.requestHandlerInst.identifyRequest('MetastoreInventoryItems', 'inventoryItemGetV1InventoryItemsGet', reqObj, true, (irReturnData, irReturnError) => {
1927
+ // if we received an error or their is no response on the results
1928
+ // return an error
1929
+ if (irReturnError) {
1930
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1931
+ return callback(null, irReturnError);
1932
+ }
1933
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1934
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['inventoryItemGetV1InventoryItemsGet'], null, null, null);
1935
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1936
+ return callback(null, errorObj);
1937
+ }
1938
+
1939
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1940
+ // return the response
1941
+ return callback(irReturnData, null);
1942
+ });
1943
+ } catch (ex) {
1944
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1945
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1946
+ return callback(null, errorObj);
1947
+ }
1948
+ }
1949
+
1950
+ /**
1951
+ * @function getAllInventoryV1InventorySchemaGet
1952
+ * @pronghornType method
1953
+ * @name getAllInventoryV1InventorySchemaGet
1954
+ * @summary Get_all_inventory_v1_inventory_schema_get
1955
+ *
1956
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
1957
+ * @param {getCallback} callback - a callback function to return the result
1958
+ * @return {object} results - An object containing the response of the action
1959
+ *
1960
+ * @route {GET} /getAllInventoryV1InventorySchemaGet
1961
+ * @roles admin
1962
+ * @task true
1963
+ */
1964
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1965
+ getAllInventoryV1InventorySchemaGet(iapMetadata, callback) {
1966
+ const meth = 'adapter-getAllInventoryV1InventorySchemaGet';
1967
+ const origin = `${this.id}-${meth}`;
1968
+ log.trace(origin);
1969
+
1970
+ if (this.suspended && this.suspendMode === 'error') {
1971
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1972
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1973
+ return callback(null, errorObj);
1974
+ }
1975
+
1976
+ /* HERE IS WHERE YOU VALIDATE DATA */
1977
+
1978
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1979
+ const queryParamsAvailable = {};
1980
+ const queryParams = {};
1981
+ const pathVars = [];
1982
+ const bodyVars = {};
1983
+
1984
+ // loop in template. long callback arg name to avoid identifier conflicts
1985
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1986
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1987
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1988
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1989
+ }
1990
+ });
1991
+
1992
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1993
+ // see adapter code documentation for more information on the request object's fields
1994
+ const reqObj = {
1995
+ payload: bodyVars,
1996
+ uriPathVars: pathVars,
1997
+ uriQuery: queryParams
1998
+ };
1999
+
2000
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
2001
+
2002
+ // Merge and add new iapMetadata fields in reqObj
2003
+ if (iapMetadata && typeof iapMetadata === 'object') {
2004
+ Object.keys(iapMetadata).forEach((iapField) => {
2005
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
2006
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
2007
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
2008
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
2009
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
2010
+ } else {
2011
+ // Otherwise, add new iapMetadata fields to reqObj
2012
+ reqObj[iapField] = iapMetadata[iapField];
2013
+ }
2014
+ }
2015
+ });
2016
+ // Add iapMetadata to reqObj for further work
2017
+ reqObj.iapMetadata = iapMetadata;
2018
+ }
2019
+
2020
+ try {
2021
+ // Make the call -
2022
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2023
+ return this.requestHandlerInst.identifyRequest('MetastoreInventorySchemaGet', 'getAllInventoryV1InventorySchemaGet', reqObj, true, (irReturnData, irReturnError) => {
2024
+ // if we received an error or their is no response on the results
2025
+ // return an error
2026
+ if (irReturnError) {
2027
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2028
+ return callback(null, irReturnError);
2029
+ }
2030
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2031
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getAllInventoryV1InventorySchemaGet'], null, null, null);
2032
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2033
+ return callback(null, errorObj);
2034
+ }
2035
+
2036
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2037
+ // return the response
2038
+ return callback(irReturnData, null);
2039
+ });
2040
+ } catch (ex) {
2041
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2042
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2043
+ return callback(null, errorObj);
2044
+ }
2045
+ }
2046
+
2047
+ /**
2048
+ * @function postInventoryV1InventorySchema
2049
+ * @pronghornType method
2050
+ * @name postInventoryV1InventorySchema
2051
+ * @summary Post_inventory_v1_inventory_schema
2052
+ *
2053
+ * @param {string} [file] - The YAML file to be uploaded
2054
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
2055
+ * @param {getCallback} callback - a callback function to return the result
2056
+ * @return {object} results - An object containing the response of the action
2057
+ *
2058
+ * @route {POST} /postInventoryV1InventorySchema
2059
+ * @roles admin
2060
+ * @task true
2061
+ */
2062
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2063
+ postInventoryV1InventorySchema(file, iapMetadata, callback) {
2064
+ const meth = 'adapter-postInventoryV1InventorySchema';
2065
+ const origin = `${this.id}-${meth}`;
2066
+ log.trace(origin);
2067
+
2068
+ if (this.suspended && this.suspendMode === 'error') {
2069
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2070
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2071
+ return callback(null, errorObj);
2072
+ }
2073
+
2074
+ /* HERE IS WHERE YOU VALIDATE DATA */
2075
+
2076
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2077
+ const queryParamsAvailable = {};
2078
+ const queryParams = {};
2079
+ const pathVars = [];
2080
+ const bodyVars = { file };
2081
+
2082
+ // loop in template. long callback arg name to avoid identifier conflicts
2083
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2084
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2085
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2086
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2087
+ }
2088
+ });
2089
+
2090
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2091
+ // see adapter code documentation for more information on the request object's fields
2092
+ const reqObj = {
2093
+ payload: bodyVars,
2094
+ uriPathVars: pathVars,
2095
+ uriQuery: queryParams
2096
+ };
2097
+
2098
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
2099
+
2100
+ // Merge and add new iapMetadata fields in reqObj
2101
+ if (iapMetadata && typeof iapMetadata === 'object') {
2102
+ Object.keys(iapMetadata).forEach((iapField) => {
2103
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
2104
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
2105
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
2106
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
2107
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
2108
+ } else {
2109
+ // Otherwise, add new iapMetadata fields to reqObj
2110
+ reqObj[iapField] = iapMetadata[iapField];
2111
+ }
2112
+ }
2113
+ });
2114
+ // Add iapMetadata to reqObj for further work
2115
+ reqObj.iapMetadata = iapMetadata;
2116
+ }
2117
+
2118
+ try {
2119
+ // Make the call -
2120
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2121
+ return this.requestHandlerInst.identifyRequest('InventorySchemaCreation', 'postInventoryV1InventorySchema', reqObj, true, (irReturnData, irReturnError) => {
2122
+ // if we received an error or their is no response on the results
2123
+ // return an error
2124
+ if (irReturnError) {
2125
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2126
+ return callback(null, irReturnError);
2127
+ }
2128
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2129
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postInventoryV1InventorySchema'], null, null, null);
2130
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2131
+ return callback(null, errorObj);
2132
+ }
2133
+
2134
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2135
+ // return the response
2136
+ return callback(irReturnData, null);
2137
+ });
2138
+ } catch (ex) {
2139
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2140
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2141
+ return callback(null, errorObj);
2142
+ }
2143
+ }
2144
+
2145
+ /**
2146
+ * @function putInventoryV1InventorySchema
2147
+ * @pronghornType method
2148
+ * @name putInventoryV1InventorySchema
2149
+ * @summary Put_inventory_v1_inventory_schema
2150
+ *
2151
+ * @param {string} [file] - The YAML file to be uploaded
2152
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
2153
+ * @param {getCallback} callback - a callback function to return the result
2154
+ * @return {object} results - An object containing the response of the action
2155
+ *
2156
+ * @route {POST} /putInventoryV1InventorySchema
2157
+ * @roles admin
2158
+ * @task true
2159
+ */
2160
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2161
+ putInventoryV1InventorySchema(file, iapMetadata, callback) {
2162
+ const meth = 'adapter-putInventoryV1InventorySchema';
2163
+ const origin = `${this.id}-${meth}`;
2164
+ log.trace(origin);
2165
+
2166
+ if (this.suspended && this.suspendMode === 'error') {
2167
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2168
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2169
+ return callback(null, errorObj);
2170
+ }
2171
+
2172
+ /* HERE IS WHERE YOU VALIDATE DATA */
2173
+
2174
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2175
+ const queryParamsAvailable = {};
2176
+ const queryParams = {};
2177
+ const pathVars = [];
2178
+ const bodyVars = { file };
2179
+
2180
+ // loop in template. long callback arg name to avoid identifier conflicts
2181
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2182
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2183
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2184
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2185
+ }
2186
+ });
2187
+
2188
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2189
+ // see adapter code documentation for more information on the request object's fields
2190
+ const reqObj = {
2191
+ payload: bodyVars,
2192
+ uriPathVars: pathVars,
2193
+ uriQuery: queryParams
2194
+ };
2195
+
2196
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
2197
+
2198
+ // Merge and add new iapMetadata fields in reqObj
2199
+ if (iapMetadata && typeof iapMetadata === 'object') {
2200
+ Object.keys(iapMetadata).forEach((iapField) => {
2201
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
2202
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
2203
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
2204
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
2205
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
2206
+ } else {
2207
+ // Otherwise, add new iapMetadata fields to reqObj
2208
+ reqObj[iapField] = iapMetadata[iapField];
2209
+ }
2210
+ }
2211
+ });
2212
+ // Add iapMetadata to reqObj for further work
2213
+ reqObj.iapMetadata = iapMetadata;
2214
+ }
2215
+
2216
+ try {
2217
+ // Make the call -
2218
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2219
+ return this.requestHandlerInst.identifyRequest('InventorySchemaUpdate', 'putInventoryV1InventorySchema', reqObj, true, (irReturnData, irReturnError) => {
2220
+ // if we received an error or their is no response on the results
2221
+ // return an error
2222
+ if (irReturnError) {
2223
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2224
+ return callback(null, irReturnError);
2225
+ }
2226
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2227
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['putInventoryV1InventorySchema'], null, null, null);
2228
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2229
+ return callback(null, errorObj);
2230
+ }
2231
+
2232
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2233
+ // return the response
2234
+ return callback(irReturnData, null);
2235
+ });
2236
+ } catch (ex) {
2237
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2238
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2239
+ return callback(null, errorObj);
2240
+ }
2241
+ }
2242
+
2243
+ /**
2244
+ * @function processinventoryschemadelete
2245
+ * @pronghornType method
2246
+ * @name processinventoryschemadelete
2247
+ * @summary Process inventory schema delete
2248
+ *
2249
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
2250
+ * @param {getCallback} callback - a callback function to return the result
2251
+ * @return {object} results - An object containing the response of the action
2252
+ *
2253
+ * @route {GET} /processinventoryschemadelete
2254
+ * @roles admin
2255
+ * @task true
2256
+ */
2257
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2258
+ processinventoryschemadelete(iapMetadata, callback) {
2259
+ const meth = 'adapter-processinventoryschemadelete';
2260
+ const origin = `${this.id}-${meth}`;
2261
+ log.trace(origin);
2262
+
2263
+ if (this.suspended && this.suspendMode === 'error') {
2264
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2265
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2266
+ return callback(null, errorObj);
2267
+ }
2268
+
2269
+ /* HERE IS WHERE YOU VALIDATE DATA */
2270
+
2271
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2272
+ const queryParamsAvailable = {};
2273
+ const queryParams = {};
2274
+ const pathVars = [];
2275
+ const bodyVars = {};
2276
+
2277
+ // loop in template. long callback arg name to avoid identifier conflicts
2278
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2279
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2280
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2281
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2282
+ }
2283
+ });
2284
+
2285
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2286
+ // see adapter code documentation for more information on the request object's fields
2287
+ const reqObj = {
2288
+ payload: bodyVars,
2289
+ uriPathVars: pathVars,
2290
+ uriQuery: queryParams
2291
+ };
2292
+
2293
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
2294
+
2295
+ // Merge and add new iapMetadata fields in reqObj
2296
+ if (iapMetadata && typeof iapMetadata === 'object') {
2297
+ Object.keys(iapMetadata).forEach((iapField) => {
2298
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
2299
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
2300
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
2301
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
2302
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
2303
+ } else {
2304
+ // Otherwise, add new iapMetadata fields to reqObj
2305
+ reqObj[iapField] = iapMetadata[iapField];
2306
+ }
2307
+ }
2308
+ });
2309
+ // Add iapMetadata to reqObj for further work
2310
+ reqObj.iapMetadata = iapMetadata;
2311
+ }
2312
+
2313
+ try {
2314
+ // Make the call -
2315
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2316
+ return this.requestHandlerInst.identifyRequest('InventorySchemaDelete', 'processinventoryschemadelete', reqObj, false, (irReturnData, irReturnError) => {
2317
+ // if we received an error or their is no response on the results
2318
+ // return an error
2319
+ if (irReturnError) {
2320
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2321
+ return callback(null, irReturnError);
2322
+ }
2323
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2324
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['processinventoryschemadelete'], null, null, null);
2325
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2326
+ return callback(null, errorObj);
2327
+ }
2328
+
2329
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2330
+ // return the response
2331
+ return callback(irReturnData, null);
2332
+ });
2333
+ } catch (ex) {
2334
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2335
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2336
+ return callback(null, errorObj);
2337
+ }
2338
+ }
2339
+
2340
+ /**
2341
+ * @function deleteProcessinventoryschemadelete
2342
+ * @pronghornType method
2343
+ * @name deleteProcessinventoryschemadelete
2344
+ * @summary Process inventory schema delete
2345
+ *
2346
+ * @param {string} type - type param
2347
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
2348
+ * @param {getCallback} callback - a callback function to return the result
2349
+ * @return {object} results - An object containing the response of the action
2350
+ *
2351
+ * @route {POST} /deleteProcessinventoryschemadelete
2352
+ * @roles admin
2353
+ * @task true
2354
+ */
2355
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2356
+ deleteProcessinventoryschemadelete(type, iapMetadata, callback) {
2357
+ const meth = 'adapter-deleteProcessinventoryschemadelete';
2358
+ const origin = `${this.id}-${meth}`;
2359
+ log.trace(origin);
2360
+
2361
+ if (this.suspended && this.suspendMode === 'error') {
2362
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2363
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2364
+ return callback(null, errorObj);
2365
+ }
2366
+
2367
+ /* HERE IS WHERE YOU VALIDATE DATA */
2368
+ if (type === undefined || type === null || type === '') {
2369
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['type'], null, null, null);
2370
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2371
+ return callback(null, errorObj);
2372
+ }
2373
+
2374
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2375
+ const queryParamsAvailable = {};
2376
+ const queryParams = {};
2377
+ const pathVars = [type];
2378
+ const bodyVars = {};
2379
+
2380
+ // loop in template. long callback arg name to avoid identifier conflicts
2381
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2382
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2383
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2384
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2385
+ }
2386
+ });
2387
+
2388
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2389
+ // see adapter code documentation for more information on the request object's fields
2390
+ const reqObj = {
2391
+ payload: bodyVars,
2392
+ uriPathVars: pathVars,
2393
+ uriQuery: queryParams
2394
+ };
2395
+
2396
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
2397
+
2398
+ // Merge and add new iapMetadata fields in reqObj
2399
+ if (iapMetadata && typeof iapMetadata === 'object') {
2400
+ Object.keys(iapMetadata).forEach((iapField) => {
2401
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
2402
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
2403
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
2404
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
2405
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
2406
+ } else {
2407
+ // Otherwise, add new iapMetadata fields to reqObj
2408
+ reqObj[iapField] = iapMetadata[iapField];
2409
+ }
2410
+ }
2411
+ });
2412
+ // Add iapMetadata to reqObj for further work
2413
+ reqObj.iapMetadata = iapMetadata;
2414
+ }
2415
+
2416
+ try {
2417
+ // Make the call -
2418
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2419
+ return this.requestHandlerInst.identifyRequest('InventorySchemaDeleteType', 'deleteProcessinventoryschemadelete', reqObj, false, (irReturnData, irReturnError) => {
2420
+ // if we received an error or their is no response on the results
2421
+ // return an error
2422
+ if (irReturnError) {
2423
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2424
+ return callback(null, irReturnError);
2425
+ }
2426
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2427
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteProcessinventoryschemadelete'], null, null, null);
2428
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2429
+ return callback(null, errorObj);
2430
+ }
2431
+
2432
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2433
+ // return the response
2434
+ return callback(irReturnData, null);
2435
+ });
2436
+ } catch (ex) {
2437
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2438
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2439
+ return callback(null, errorObj);
2440
+ }
2441
+ }
2442
+
2443
+ /**
2444
+ * @function getsAllInventoryschema
2445
+ * @pronghornType method
2446
+ * @name getsAllInventoryschema
2447
+ * @summary Gets All Inventory schema
2448
+ *
2449
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
2450
+ * @param {getCallback} callback - a callback function to return the result
2451
+ * @return {object} results - An object containing the response of the action
2452
+ *
2453
+ * @route {GET} /getsAllInventoryschema
2454
+ * @roles admin
2455
+ * @task true
2456
+ */
2457
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2458
+ getsAllInventoryschema(iapMetadata, callback) {
2459
+ const meth = 'adapter-getsAllInventoryschema';
2460
+ const origin = `${this.id}-${meth}`;
2461
+ log.trace(origin);
2462
+
2463
+ if (this.suspended && this.suspendMode === 'error') {
2464
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2465
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2466
+ return callback(null, errorObj);
2467
+ }
2468
+
2469
+ /* HERE IS WHERE YOU VALIDATE DATA */
2470
+
2471
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2472
+ const queryParamsAvailable = {};
2473
+ const queryParams = {};
2474
+ const pathVars = [];
2475
+ const bodyVars = {};
2476
+
2477
+ // loop in template. long callback arg name to avoid identifier conflicts
2478
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2479
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2480
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2481
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2482
+ }
2483
+ });
2484
+
2485
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2486
+ // see adapter code documentation for more information on the request object's fields
2487
+ const reqObj = {
2488
+ payload: bodyVars,
2489
+ uriPathVars: pathVars,
2490
+ uriQuery: queryParams
2491
+ };
2492
+
2493
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
2494
+
2495
+ // Merge and add new iapMetadata fields in reqObj
2496
+ if (iapMetadata && typeof iapMetadata === 'object') {
2497
+ Object.keys(iapMetadata).forEach((iapField) => {
2498
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
2499
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
2500
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
2501
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
2502
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
2503
+ } else {
2504
+ // Otherwise, add new iapMetadata fields to reqObj
2505
+ reqObj[iapField] = iapMetadata[iapField];
2506
+ }
2507
+ }
2508
+ });
2509
+ // Add iapMetadata to reqObj for further work
2510
+ reqObj.iapMetadata = iapMetadata;
2511
+ }
2512
+
2513
+ try {
2514
+ // Make the call -
2515
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2516
+ return this.requestHandlerInst.identifyRequest('MetastoreV2InventorySchemaGet', 'getsAllInventoryschema', reqObj, true, (irReturnData, irReturnError) => {
2517
+ // if we received an error or their is no response on the results
2518
+ // return an error
2519
+ if (irReturnError) {
2520
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2521
+ return callback(null, irReturnError);
2522
+ }
2523
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2524
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getsAllInventoryschema'], null, null, null);
2525
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2526
+ return callback(null, errorObj);
2527
+ }
2528
+
2529
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2530
+ // return the response
2531
+ return callback(irReturnData, null);
2532
+ });
2533
+ } catch (ex) {
2534
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2535
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2536
+ return callback(null, errorObj);
2537
+ }
2538
+ }
2539
+
2540
+ /**
2541
+ * @function processinventoryschemaJSONinput
2542
+ * @pronghornType method
2543
+ * @name processinventoryschemaJSONinput
2544
+ * @summary Process inventory schema JSON input
2545
+ *
2546
+ * @param {object} body - body param
2547
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
2548
+ * @param {getCallback} callback - a callback function to return the result
2549
+ * @return {object} results - An object containing the response of the action
2550
+ *
2551
+ * @route {POST} /processinventoryschemaJSONinput
2552
+ * @roles admin
2553
+ * @task true
2554
+ */
2555
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2556
+ processinventoryschemaJSONinput(body, iapMetadata, callback) {
2557
+ const meth = 'adapter-processinventoryschemaJSONinput';
2558
+ const origin = `${this.id}-${meth}`;
2559
+ log.trace(origin);
2560
+
2561
+ if (this.suspended && this.suspendMode === 'error') {
2562
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2563
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2564
+ return callback(null, errorObj);
2565
+ }
2566
+
2567
+ /* HERE IS WHERE YOU VALIDATE DATA */
2568
+ if (body === undefined || body === null || body === '') {
2569
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
2570
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2571
+ return callback(null, errorObj);
2572
+ }
2573
+
2574
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2575
+ const queryParamsAvailable = {};
2576
+ const queryParams = {};
2577
+ const pathVars = [];
2578
+ const bodyVars = body;
2579
+
2580
+ // loop in template. long callback arg name to avoid identifier conflicts
2581
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2582
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2583
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2584
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2585
+ }
2586
+ });
2587
+
2588
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2589
+ // see adapter code documentation for more information on the request object's fields
2590
+ const reqObj = {
2591
+ payload: bodyVars,
2592
+ uriPathVars: pathVars,
2593
+ uriQuery: queryParams
2594
+ };
2595
+
2596
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
2597
+
2598
+ // Merge and add new iapMetadata fields in reqObj
2599
+ if (iapMetadata && typeof iapMetadata === 'object') {
2600
+ Object.keys(iapMetadata).forEach((iapField) => {
2601
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
2602
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
2603
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
2604
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
2605
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
2606
+ } else {
2607
+ // Otherwise, add new iapMetadata fields to reqObj
2608
+ reqObj[iapField] = iapMetadata[iapField];
2609
+ }
2610
+ }
2611
+ });
2612
+ // Add iapMetadata to reqObj for further work
2613
+ reqObj.iapMetadata = iapMetadata;
2614
+ }
2615
+
2616
+ try {
2617
+ // Make the call -
2618
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2619
+ return this.requestHandlerInst.identifyRequest('InventoryV2SchemaUpload', 'processinventoryschemaJSONinput', reqObj, true, (irReturnData, irReturnError) => {
2620
+ // if we received an error or their is no response on the results
2621
+ // return an error
2622
+ if (irReturnError) {
2623
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2624
+ return callback(null, irReturnError);
2625
+ }
2626
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2627
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['processinventoryschemaJSONinput'], null, null, null);
2628
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2629
+ return callback(null, errorObj);
2630
+ }
2631
+
2632
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2633
+ // return the response
2634
+ return callback(irReturnData, null);
2635
+ });
2636
+ } catch (ex) {
2637
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2638
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2639
+ return callback(null, errorObj);
2640
+ }
2641
+ }
2642
+
2643
+ /**
2644
+ * @function deleteProcessinventoryschemadelete1
2645
+ * @pronghornType method
2646
+ * @name deleteProcessinventoryschemadelete1
2647
+ * @summary Process inventory schema delete
2648
+ *
2649
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
2650
+ * @param {getCallback} callback - a callback function to return the result
2651
+ * @return {object} results - An object containing the response of the action
2652
+ *
2653
+ * @route {GET} /deleteProcessinventoryschemadelete1
2654
+ * @roles admin
2655
+ * @task true
2656
+ */
2657
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2658
+ deleteProcessinventoryschemadelete1(iapMetadata, callback) {
2659
+ const meth = 'adapter-deleteProcessinventoryschemadelete1';
2660
+ const origin = `${this.id}-${meth}`;
2661
+ log.trace(origin);
2662
+
2663
+ if (this.suspended && this.suspendMode === 'error') {
2664
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2665
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2666
+ return callback(null, errorObj);
2667
+ }
2668
+
2669
+ /* HERE IS WHERE YOU VALIDATE DATA */
2670
+
2671
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2672
+ const queryParamsAvailable = {};
2673
+ const queryParams = {};
2674
+ const pathVars = [];
2675
+ const bodyVars = {};
2676
+
2677
+ // loop in template. long callback arg name to avoid identifier conflicts
2678
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2679
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2680
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2681
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2682
+ }
2683
+ });
2684
+
2685
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2686
+ // see adapter code documentation for more information on the request object's fields
2687
+ const reqObj = {
2688
+ payload: bodyVars,
2689
+ uriPathVars: pathVars,
2690
+ uriQuery: queryParams
2691
+ };
2692
+
2693
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
2694
+
2695
+ // Merge and add new iapMetadata fields in reqObj
2696
+ if (iapMetadata && typeof iapMetadata === 'object') {
2697
+ Object.keys(iapMetadata).forEach((iapField) => {
2698
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
2699
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
2700
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
2701
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
2702
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
2703
+ } else {
2704
+ // Otherwise, add new iapMetadata fields to reqObj
2705
+ reqObj[iapField] = iapMetadata[iapField];
2706
+ }
2707
+ }
2708
+ });
2709
+ // Add iapMetadata to reqObj for further work
2710
+ reqObj.iapMetadata = iapMetadata;
2711
+ }
2712
+
2713
+ try {
2714
+ // Make the call -
2715
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2716
+ return this.requestHandlerInst.identifyRequest('InventoryV2SchemaDeleteAll', 'deleteProcessinventoryschemadelete1', reqObj, false, (irReturnData, irReturnError) => {
2717
+ // if we received an error or their is no response on the results
2718
+ // return an error
2719
+ if (irReturnError) {
2720
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2721
+ return callback(null, irReturnError);
2722
+ }
2723
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2724
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteProcessinventoryschemadelete1'], null, null, null);
2725
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2726
+ return callback(null, errorObj);
2727
+ }
2728
+
2729
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2730
+ // return the response
2731
+ return callback(irReturnData, null);
2732
+ });
2733
+ } catch (ex) {
2734
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2735
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2736
+ return callback(null, errorObj);
2737
+ }
2738
+ }
2739
+
2740
+ /**
2741
+ * @function putProcessinventoryschemaJSONinput
2742
+ * @pronghornType method
2743
+ * @name putProcessinventoryschemaJSONinput
2744
+ * @summary Process inventory schema JSON input
2745
+ *
2746
+ * @param {string} type - type param
2747
+ * @param {object} body - body param
2748
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
2749
+ * @param {getCallback} callback - a callback function to return the result
2750
+ * @return {object} results - An object containing the response of the action
2751
+ *
2752
+ * @route {POST} /putProcessinventoryschemaJSONinput
2753
+ * @roles admin
2754
+ * @task true
2755
+ */
2756
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2757
+ putProcessinventoryschemaJSONinput(type, body, iapMetadata, callback) {
2758
+ const meth = 'adapter-putProcessinventoryschemaJSONinput';
2759
+ const origin = `${this.id}-${meth}`;
2760
+ log.trace(origin);
2761
+
2762
+ if (this.suspended && this.suspendMode === 'error') {
2763
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2764
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2765
+ return callback(null, errorObj);
2766
+ }
2767
+
2768
+ /* HERE IS WHERE YOU VALIDATE DATA */
2769
+ if (type === undefined || type === null || type === '') {
2770
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['type'], null, null, null);
2771
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2772
+ return callback(null, errorObj);
2773
+ }
2774
+ if (body === undefined || body === null || body === '') {
2775
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
2776
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2777
+ return callback(null, errorObj);
2778
+ }
2779
+
2780
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2781
+ const queryParamsAvailable = {};
2782
+ const queryParams = {};
2783
+ const pathVars = [type];
2784
+ const bodyVars = body;
2785
+
2786
+ // loop in template. long callback arg name to avoid identifier conflicts
2787
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2788
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2789
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2790
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2791
+ }
2792
+ });
2793
+
2794
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2795
+ // see adapter code documentation for more information on the request object's fields
2796
+ const reqObj = {
2797
+ payload: bodyVars,
2798
+ uriPathVars: pathVars,
2799
+ uriQuery: queryParams
2800
+ };
2801
+
2802
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
2803
+
2804
+ // Merge and add new iapMetadata fields in reqObj
2805
+ if (iapMetadata && typeof iapMetadata === 'object') {
2806
+ Object.keys(iapMetadata).forEach((iapField) => {
2807
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
2808
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
2809
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
2810
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
2811
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
2812
+ } else {
2813
+ // Otherwise, add new iapMetadata fields to reqObj
2814
+ reqObj[iapField] = iapMetadata[iapField];
2815
+ }
2816
+ }
2817
+ });
2818
+ // Add iapMetadata to reqObj for further work
2819
+ reqObj.iapMetadata = iapMetadata;
2820
+ }
2821
+
2822
+ try {
2823
+ // Make the call -
2824
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2825
+ return this.requestHandlerInst.identifyRequest('InventoryV2SchemaUpdate', 'putProcessinventoryschemaJSONinput', reqObj, true, (irReturnData, irReturnError) => {
2826
+ // if we received an error or their is no response on the results
2827
+ // return an error
2828
+ if (irReturnError) {
2829
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2830
+ return callback(null, irReturnError);
2831
+ }
2832
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2833
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['putProcessinventoryschemaJSONinput'], null, null, null);
2834
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2835
+ return callback(null, errorObj);
2836
+ }
2837
+
2838
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2839
+ // return the response
2840
+ return callback(irReturnData, null);
2841
+ });
2842
+ } catch (ex) {
2843
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2844
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2845
+ return callback(null, errorObj);
2846
+ }
2847
+ }
2848
+
2849
+ /**
2850
+ * @function deleteProcessinventoryschemadelete2
2851
+ * @pronghornType method
2852
+ * @name deleteProcessinventoryschemadelete2
2853
+ * @summary Process inventory schema delete
2854
+ *
2855
+ * @param {string} type - type param
2856
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
2857
+ * @param {getCallback} callback - a callback function to return the result
2858
+ * @return {object} results - An object containing the response of the action
2859
+ *
2860
+ * @route {POST} /deleteProcessinventoryschemadelete2
2861
+ * @roles admin
2862
+ * @task true
2863
+ */
2864
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2865
+ deleteProcessinventoryschemadelete2(type, iapMetadata, callback) {
2866
+ const meth = 'adapter-deleteProcessinventoryschemadelete2';
2867
+ const origin = `${this.id}-${meth}`;
2868
+ log.trace(origin);
2869
+
2870
+ if (this.suspended && this.suspendMode === 'error') {
2871
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2872
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2873
+ return callback(null, errorObj);
2874
+ }
2875
+
2876
+ /* HERE IS WHERE YOU VALIDATE DATA */
2877
+ if (type === undefined || type === null || type === '') {
2878
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['type'], null, null, null);
2879
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2880
+ return callback(null, errorObj);
2881
+ }
2882
+
2883
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2884
+ const queryParamsAvailable = {};
2885
+ const queryParams = {};
2886
+ const pathVars = [type];
2887
+ const bodyVars = {};
2888
+
2889
+ // loop in template. long callback arg name to avoid identifier conflicts
2890
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2891
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2892
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2893
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2894
+ }
2895
+ });
2896
+
2897
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2898
+ // see adapter code documentation for more information on the request object's fields
2899
+ const reqObj = {
2900
+ payload: bodyVars,
2901
+ uriPathVars: pathVars,
2902
+ uriQuery: queryParams
2903
+ };
2904
+
2905
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
2906
+
2907
+ // Merge and add new iapMetadata fields in reqObj
2908
+ if (iapMetadata && typeof iapMetadata === 'object') {
2909
+ Object.keys(iapMetadata).forEach((iapField) => {
2910
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
2911
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
2912
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
2913
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
2914
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
2915
+ } else {
2916
+ // Otherwise, add new iapMetadata fields to reqObj
2917
+ reqObj[iapField] = iapMetadata[iapField];
2918
+ }
2919
+ }
2920
+ });
2921
+ // Add iapMetadata to reqObj for further work
2922
+ reqObj.iapMetadata = iapMetadata;
2923
+ }
2924
+
2925
+ try {
2926
+ // Make the call -
2927
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
2928
+ return this.requestHandlerInst.identifyRequest('InventoryV2SchemaDeleteType', 'deleteProcessinventoryschemadelete2', reqObj, false, (irReturnData, irReturnError) => {
2929
+ // if we received an error or their is no response on the results
2930
+ // return an error
2931
+ if (irReturnError) {
2932
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
2933
+ return callback(null, irReturnError);
2934
+ }
2935
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
2936
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteProcessinventoryschemadelete2'], null, null, null);
2937
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2938
+ return callback(null, errorObj);
2939
+ }
2940
+
2941
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
2942
+ // return the response
2943
+ return callback(irReturnData, null);
2944
+ });
2945
+ } catch (ex) {
2946
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
2947
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2948
+ return callback(null, errorObj);
2949
+ }
2950
+ }
2951
+
2952
+ /**
2953
+ * @function porcessuploadJSONfile
2954
+ * @pronghornType method
2955
+ * @name porcessuploadJSONfile
2956
+ * @summary Porcess upload JSON file
2957
+ *
2958
+ * @param {string} [encodeType] - encodeType param
2959
+ * @param {string} [file] - file param
2960
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
2961
+ * @param {getCallback} callback - a callback function to return the result
2962
+ * @return {object} results - An object containing the response of the action
2963
+ *
2964
+ * @route {POST} /porcessuploadJSONfile
2965
+ * @roles admin
2966
+ * @task true
2967
+ */
2968
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
2969
+ porcessuploadJSONfile(encodeType = 'json', file, iapMetadata, callback) {
2970
+ const meth = 'adapter-porcessuploadJSONfile';
2971
+ const origin = `${this.id}-${meth}`;
2972
+ log.trace(origin);
2973
+
2974
+ if (this.suspended && this.suspendMode === 'error') {
2975
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
2976
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
2977
+ return callback(null, errorObj);
2978
+ }
2979
+
2980
+ /* HERE IS WHERE YOU VALIDATE DATA */
2981
+
2982
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
2983
+ const queryParamsAvailable = { encodeType };
2984
+ const queryParams = {};
2985
+ const pathVars = [];
2986
+ const bodyVars = { file };
2987
+
2988
+ // loop in template. long callback arg name to avoid identifier conflicts
2989
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
2990
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
2991
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
2992
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
2993
+ }
2994
+ });
2995
+
2996
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
2997
+ // see adapter code documentation for more information on the request object's fields
2998
+ const reqObj = {
2999
+ payload: bodyVars,
3000
+ uriPathVars: pathVars,
3001
+ uriQuery: queryParams
3002
+ };
3003
+
3004
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
3005
+
3006
+ // Merge and add new iapMetadata fields in reqObj
3007
+ if (iapMetadata && typeof iapMetadata === 'object') {
3008
+ Object.keys(iapMetadata).forEach((iapField) => {
3009
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
3010
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
3011
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
3012
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
3013
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
3014
+ } else {
3015
+ // Otherwise, add new iapMetadata fields to reqObj
3016
+ reqObj[iapField] = iapMetadata[iapField];
3017
+ }
3018
+ }
3019
+ });
3020
+ // Add iapMetadata to reqObj for further work
3021
+ reqObj.iapMetadata = iapMetadata;
3022
+ }
3023
+
3024
+ try {
3025
+ // Make the call -
3026
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3027
+ return this.requestHandlerInst.identifyRequest('InventorySchemaFileUpload', 'porcessuploadJSONfile', reqObj, true, (irReturnData, irReturnError) => {
3028
+ // if we received an error or their is no response on the results
3029
+ // return an error
3030
+ if (irReturnError) {
3031
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3032
+ return callback(null, irReturnError);
3033
+ }
3034
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3035
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['porcessuploadJSONfile'], null, null, null);
3036
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3037
+ return callback(null, errorObj);
3038
+ }
3039
+
3040
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3041
+ // return the response
3042
+ return callback(irReturnData, null);
3043
+ });
3044
+ } catch (ex) {
3045
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3046
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3047
+ return callback(null, errorObj);
3048
+ }
3049
+ }
3050
+
3051
+ /**
3052
+ * @function downloadinventoryschemaJSONfile
3053
+ * @pronghornType method
3054
+ * @name downloadinventoryschemaJSONfile
3055
+ * @summary Download inventory schema JSON file
3056
+ *
3057
+ * @param {string} [encodeType] - encodeType param
3058
+ * @param {object} [body] - body param
3059
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
3060
+ * @param {getCallback} callback - a callback function to return the result
3061
+ * @return {object} results - An object containing the response of the action
3062
+ *
3063
+ * @route {POST} /downloadinventoryschemaJSONfile
3064
+ * @roles admin
3065
+ * @task true
3066
+ */
3067
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3068
+ downloadinventoryschemaJSONfile(encodeType = 'json', body, iapMetadata, callback) {
3069
+ const meth = 'adapter-downloadinventoryschemaJSONfile';
3070
+ const origin = `${this.id}-${meth}`;
3071
+ log.trace(origin);
3072
+
3073
+ if (this.suspended && this.suspendMode === 'error') {
3074
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3075
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3076
+ return callback(null, errorObj);
3077
+ }
3078
+
3079
+ /* HERE IS WHERE YOU VALIDATE DATA */
3080
+
3081
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3082
+ const queryParamsAvailable = { encodeType };
3083
+ const queryParams = {};
3084
+ const pathVars = [];
3085
+ const bodyVars = body;
3086
+
3087
+ // loop in template. long callback arg name to avoid identifier conflicts
3088
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3089
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3090
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3091
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3092
+ }
3093
+ });
3094
+
3095
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3096
+ // see adapter code documentation for more information on the request object's fields
3097
+ const reqObj = {
3098
+ payload: bodyVars,
3099
+ uriPathVars: pathVars,
3100
+ uriQuery: queryParams
3101
+ };
3102
+
3103
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
3104
+
3105
+ // Merge and add new iapMetadata fields in reqObj
3106
+ if (iapMetadata && typeof iapMetadata === 'object') {
3107
+ Object.keys(iapMetadata).forEach((iapField) => {
3108
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
3109
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
3110
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
3111
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
3112
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
3113
+ } else {
3114
+ // Otherwise, add new iapMetadata fields to reqObj
3115
+ reqObj[iapField] = iapMetadata[iapField];
3116
+ }
3117
+ }
3118
+ });
3119
+ // Add iapMetadata to reqObj for further work
3120
+ reqObj.iapMetadata = iapMetadata;
3121
+ }
3122
+
3123
+ try {
3124
+ // Make the call -
3125
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3126
+ return this.requestHandlerInst.identifyRequest('InventorySchemaFileDownload', 'downloadinventoryschemaJSONfile', reqObj, true, (irReturnData, irReturnError) => {
3127
+ // if we received an error or their is no response on the results
3128
+ // return an error
3129
+ if (irReturnError) {
3130
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3131
+ return callback(null, irReturnError);
3132
+ }
3133
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3134
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['downloadinventoryschemaJSONfile'], null, null, null);
3135
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3136
+ return callback(null, errorObj);
3137
+ }
3138
+
3139
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3140
+ // return the response
3141
+ return callback(irReturnData, null);
3142
+ });
3143
+ } catch (ex) {
3144
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3145
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3146
+ return callback(null, errorObj);
3147
+ }
3148
+ }
3149
+
3150
+ /**
3151
+ * @function handleInventoryFilesPostInventoryFilesImportPost
3152
+ * @pronghornType method
3153
+ * @name handleInventoryFilesPostInventoryFilesImportPost
3154
+ * @summary handle_inventory_files_post_inventory_files_import_post
3155
+ *
3156
+ * @param {string} [encodeType] - encodeType param
3157
+ * @param {string} [zipFile] - zipFile param
3158
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
3159
+ * @param {getCallback} callback - a callback function to return the result
3160
+ * @return {object} results - An object containing the response of the action
3161
+ *
3162
+ * @route {POST} /handleInventoryFilesPostInventoryFilesImportPost
3163
+ * @roles admin
3164
+ * @task true
3165
+ */
3166
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3167
+ handleInventoryFilesPostInventoryFilesImportPost(encodeType, zipFile, iapMetadata, callback) {
3168
+ const meth = 'adapter-handleInventoryFilesPostInventoryFilesImportPost';
3169
+ const origin = `${this.id}-${meth}`;
3170
+ log.trace(origin);
3171
+
3172
+ if (this.suspended && this.suspendMode === 'error') {
3173
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3174
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3175
+ return callback(null, errorObj);
3176
+ }
3177
+
3178
+ /* HERE IS WHERE YOU VALIDATE DATA */
3179
+
3180
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3181
+ const queryParamsAvailable = { encodeType };
3182
+ const queryParams = {};
3183
+ const pathVars = [];
3184
+ const bodyVars = { zipFile };
3185
+
3186
+ // loop in template. long callback arg name to avoid identifier conflicts
3187
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3188
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3189
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3190
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3191
+ }
3192
+ });
3193
+
3194
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3195
+ // see adapter code documentation for more information on the request object's fields
3196
+ const reqObj = {
3197
+ payload: bodyVars,
3198
+ uriPathVars: pathVars,
3199
+ uriQuery: queryParams
3200
+ };
3201
+
3202
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
3203
+
3204
+ // Merge and add new iapMetadata fields in reqObj
3205
+ if (iapMetadata && typeof iapMetadata === 'object') {
3206
+ Object.keys(iapMetadata).forEach((iapField) => {
3207
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
3208
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
3209
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
3210
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
3211
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
3212
+ } else {
3213
+ // Otherwise, add new iapMetadata fields to reqObj
3214
+ reqObj[iapField] = iapMetadata[iapField];
3215
+ }
3216
+ }
3217
+ });
3218
+ // Add iapMetadata to reqObj for further work
3219
+ reqObj.iapMetadata = iapMetadata;
3220
+ }
3221
+
3222
+ try {
3223
+ // Make the call -
3224
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3225
+ return this.requestHandlerInst.identifyRequest('MetastoreInventoryFilesImport', 'handleInventoryFilesPostInventoryFilesImportPost', reqObj, true, (irReturnData, irReturnError) => {
3226
+ // if we received an error or their is no response on the results
3227
+ // return an error
3228
+ if (irReturnError) {
3229
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3230
+ return callback(null, irReturnError);
3231
+ }
3232
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3233
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['handleInventoryFilesPostInventoryFilesImportPost'], null, null, null);
3234
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3235
+ return callback(null, errorObj);
3236
+ }
3237
+
3238
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3239
+ // return the response
3240
+ return callback(irReturnData, null);
3241
+ });
3242
+ } catch (ex) {
3243
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3244
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3245
+ return callback(null, errorObj);
3246
+ }
3247
+ }
3248
+
3249
+ /**
3250
+ * @function handleInventoryFilesGetInventoryFilesExportPost
3251
+ * @pronghornType method
3252
+ * @name handleInventoryFilesGetInventoryFilesExportPost
3253
+ * @summary handle_inventory_files_get_inventory_files_export_post
3254
+ *
3255
+ * @param {string} [encodeType] - encodeType param
3256
+ * @param {object} body - body param
3257
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
3258
+ * @param {getCallback} callback - a callback function to return the result
3259
+ * @return {object} results - An object containing the response of the action
3260
+ *
3261
+ * @route {POST} /handleInventoryFilesGetInventoryFilesExportPost
3262
+ * @roles admin
3263
+ * @task true
3264
+ */
3265
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3266
+ handleInventoryFilesGetInventoryFilesExportPost(encodeType, body, iapMetadata, callback) {
3267
+ const meth = 'adapter-handleInventoryFilesGetInventoryFilesExportPost';
3268
+ const origin = `${this.id}-${meth}`;
3269
+ log.trace(origin);
3270
+
3271
+ if (this.suspended && this.suspendMode === 'error') {
3272
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3273
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3274
+ return callback(null, errorObj);
3275
+ }
3276
+
3277
+ /* HERE IS WHERE YOU VALIDATE DATA */
3278
+ if (body === undefined || body === null || body === '') {
3279
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
3280
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3281
+ return callback(null, errorObj);
3282
+ }
3283
+
3284
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3285
+ const queryParamsAvailable = { encodeType };
3286
+ const queryParams = {};
3287
+ const pathVars = [];
3288
+ const bodyVars = body;
3289
+
3290
+ // loop in template. long callback arg name to avoid identifier conflicts
3291
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3292
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3293
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3294
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3295
+ }
3296
+ });
3297
+
3298
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3299
+ // see adapter code documentation for more information on the request object's fields
3300
+ const reqObj = {
3301
+ payload: bodyVars,
3302
+ uriPathVars: pathVars,
3303
+ uriQuery: queryParams
3304
+ };
3305
+
3306
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
3307
+
3308
+ // Merge and add new iapMetadata fields in reqObj
3309
+ if (iapMetadata && typeof iapMetadata === 'object') {
3310
+ Object.keys(iapMetadata).forEach((iapField) => {
3311
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
3312
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
3313
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
3314
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
3315
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
3316
+ } else {
3317
+ // Otherwise, add new iapMetadata fields to reqObj
3318
+ reqObj[iapField] = iapMetadata[iapField];
3319
+ }
3320
+ }
3321
+ });
3322
+ // Add iapMetadata to reqObj for further work
3323
+ reqObj.iapMetadata = iapMetadata;
3324
+ }
3325
+
3326
+ try {
3327
+ // Make the call -
3328
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3329
+ return this.requestHandlerInst.identifyRequest('MetastoreInventoryFilesExport', 'handleInventoryFilesGetInventoryFilesExportPost', reqObj, true, (irReturnData, irReturnError) => {
3330
+ // if we received an error or their is no response on the results
3331
+ // return an error
3332
+ if (irReturnError) {
3333
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3334
+ return callback(null, irReturnError);
3335
+ }
3336
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3337
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['handleInventoryFilesGetInventoryFilesExportPost'], null, null, null);
3338
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3339
+ return callback(null, errorObj);
3340
+ }
3341
+
3342
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3343
+ // return the response
3344
+ return callback(irReturnData, null);
3345
+ });
3346
+ } catch (ex) {
3347
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3348
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3349
+ return callback(null, errorObj);
3350
+ }
3351
+ }
3352
+
3353
+ /**
3354
+ * @function handleInventoryCsvFileGet
3355
+ * @pronghornType method
3356
+ * @name handleInventoryCsvFileGet
3357
+ * @summary handle_inventory_csv_file_get
3358
+ *
3359
+ * @param {string} name - The name of the inventory item
3360
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
3361
+ * @param {getCallback} callback - a callback function to return the result
3362
+ * @return {object} results - An object containing the response of the action
3363
+ *
3364
+ * @route {POST} /handleInventoryCsvFileGet
3365
+ * @roles admin
3366
+ * @task true
3367
+ */
3368
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3369
+ handleInventoryCsvFileGet(name, iapMetadata, callback) {
3370
+ const meth = 'adapter-handleInventoryCsvFileGet';
3371
+ const origin = `${this.id}-${meth}`;
3372
+ log.trace(origin);
3373
+
3374
+ if (this.suspended && this.suspendMode === 'error') {
3375
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3376
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3377
+ return callback(null, errorObj);
3378
+ }
3379
+
3380
+ /* HERE IS WHERE YOU VALIDATE DATA */
3381
+ if (name === undefined || name === null || name === '') {
3382
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['name'], null, null, null);
3383
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3384
+ return callback(null, errorObj);
3385
+ }
3386
+
3387
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3388
+ const queryParamsAvailable = {};
3389
+ const queryParams = {};
3390
+ const pathVars = [name];
3391
+ const bodyVars = {};
3392
+
3393
+ // loop in template. long callback arg name to avoid identifier conflicts
3394
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3395
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3396
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3397
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3398
+ }
3399
+ });
3400
+
3401
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3402
+ // see adapter code documentation for more information on the request object's fields
3403
+ const reqObj = {
3404
+ payload: bodyVars,
3405
+ uriPathVars: pathVars,
3406
+ uriQuery: queryParams
3407
+ };
3408
+
3409
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
3410
+
3411
+ // Merge and add new iapMetadata fields in reqObj
3412
+ if (iapMetadata && typeof iapMetadata === 'object') {
3413
+ Object.keys(iapMetadata).forEach((iapField) => {
3414
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
3415
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
3416
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
3417
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
3418
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
3419
+ } else {
3420
+ // Otherwise, add new iapMetadata fields to reqObj
3421
+ reqObj[iapField] = iapMetadata[iapField];
3422
+ }
3423
+ }
3424
+ });
3425
+ // Add iapMetadata to reqObj for further work
3426
+ reqObj.iapMetadata = iapMetadata;
3427
+ }
3428
+
3429
+ try {
3430
+ // Make the call -
3431
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3432
+ return this.requestHandlerInst.identifyRequest('MetastoreInventoryCsvFileExport', 'handleInventoryCsvFileGet', reqObj, true, (irReturnData, irReturnError) => {
3433
+ // if we received an error or their is no response on the results
3434
+ // return an error
3435
+ if (irReturnError) {
3436
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3437
+ return callback(null, irReturnError);
3438
+ }
3439
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3440
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['handleInventoryCsvFileGet'], null, null, null);
3441
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3442
+ return callback(null, errorObj);
3443
+ }
3444
+
3445
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3446
+ // return the response
3447
+ return callback(irReturnData, null);
3448
+ });
3449
+ } catch (ex) {
3450
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3451
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3452
+ return callback(null, errorObj);
3453
+ }
3454
+ }
3455
+
3456
+ /**
3457
+ * @function get
3458
+ * @pronghornType method
3459
+ * @name get
3460
+ * @summary home_page__get
3461
+ *
3462
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
3463
+ * @param {getCallback} callback - a callback function to return the result
3464
+ * @return {object} results - An object containing the response of the action
3465
+ *
3466
+ * @route {GET} /get
3467
+ * @roles admin
3468
+ * @task true
3469
+ */
3470
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3471
+ get(iapMetadata, callback) {
3472
+ const meth = 'adapter-get';
3473
+ const origin = `${this.id}-${meth}`;
3474
+ log.trace(origin);
3475
+
3476
+ if (this.suspended && this.suspendMode === 'error') {
3477
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3478
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3479
+ return callback(null, errorObj);
3480
+ }
3481
+
3482
+ /* HERE IS WHERE YOU VALIDATE DATA */
3483
+
3484
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3485
+ const queryParamsAvailable = {};
3486
+ const queryParams = {};
3487
+ const pathVars = [];
3488
+ const bodyVars = {};
3489
+
3490
+ // loop in template. long callback arg name to avoid identifier conflicts
3491
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3492
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3493
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3494
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3495
+ }
3496
+ });
3497
+
3498
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3499
+ // see adapter code documentation for more information on the request object's fields
3500
+ const reqObj = {
3501
+ payload: bodyVars,
3502
+ uriPathVars: pathVars,
3503
+ uriQuery: queryParams
3504
+ };
3505
+
3506
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
3507
+
3508
+ // Merge and add new iapMetadata fields in reqObj
3509
+ if (iapMetadata && typeof iapMetadata === 'object') {
3510
+ Object.keys(iapMetadata).forEach((iapField) => {
3511
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
3512
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
3513
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
3514
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
3515
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
3516
+ } else {
3517
+ // Otherwise, add new iapMetadata fields to reqObj
3518
+ reqObj[iapField] = iapMetadata[iapField];
3519
+ }
3520
+ }
3521
+ });
3522
+ // Add iapMetadata to reqObj for further work
3523
+ reqObj.iapMetadata = iapMetadata;
3524
+ }
3525
+
3526
+ try {
3527
+ // Make the call -
3528
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3529
+ return this.requestHandlerInst.identifyRequest('MetastoreInventorySystem', 'get', reqObj, true, (irReturnData, irReturnError) => {
3530
+ // if we received an error or their is no response on the results
3531
+ // return an error
3532
+ if (irReturnError) {
3533
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3534
+ return callback(null, irReturnError);
3535
+ }
3536
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3537
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['get'], null, null, null);
3538
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3539
+ return callback(null, errorObj);
3540
+ }
3541
+
3542
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3543
+ // return the response
3544
+ return callback(irReturnData, null);
3545
+ });
3546
+ } catch (ex) {
3547
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3548
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3549
+ return callback(null, errorObj);
3550
+ }
3551
+ }
3552
+
3553
+ /**
3554
+ * @function getOpstats
3555
+ * @pronghornType method
3556
+ * @name getOpstats
3557
+ * @summary opstats_opstats_get
3558
+ *
3559
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
3560
+ * @param {getCallback} callback - a callback function to return the result
3561
+ * @return {object} results - An object containing the response of the action
3562
+ *
3563
+ * @route {GET} /getOpstats
3564
+ * @roles admin
3565
+ * @task true
3566
+ */
3567
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3568
+ getOpstats(iapMetadata, callback) {
3569
+ const meth = 'adapter-getOpstats';
3570
+ const origin = `${this.id}-${meth}`;
3571
+ log.trace(origin);
3572
+
3573
+ if (this.suspended && this.suspendMode === 'error') {
3574
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3575
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3576
+ return callback(null, errorObj);
3577
+ }
3578
+
3579
+ /* HERE IS WHERE YOU VALIDATE DATA */
3580
+
3581
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3582
+ const queryParamsAvailable = {};
3583
+ const queryParams = {};
3584
+ const pathVars = [];
3585
+ const bodyVars = {};
3586
+
3587
+ // loop in template. long callback arg name to avoid identifier conflicts
3588
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3589
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3590
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3591
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3592
+ }
3593
+ });
3594
+
3595
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3596
+ // see adapter code documentation for more information on the request object's fields
3597
+ const reqObj = {
3598
+ payload: bodyVars,
3599
+ uriPathVars: pathVars,
3600
+ uriQuery: queryParams
3601
+ };
3602
+
3603
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
3604
+
3605
+ // Merge and add new iapMetadata fields in reqObj
3606
+ if (iapMetadata && typeof iapMetadata === 'object') {
3607
+ Object.keys(iapMetadata).forEach((iapField) => {
3608
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
3609
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
3610
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
3611
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
3612
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
3613
+ } else {
3614
+ // Otherwise, add new iapMetadata fields to reqObj
3615
+ reqObj[iapField] = iapMetadata[iapField];
3616
+ }
3617
+ }
3618
+ });
3619
+ // Add iapMetadata to reqObj for further work
3620
+ reqObj.iapMetadata = iapMetadata;
3621
+ }
3622
+
3623
+ try {
3624
+ // Make the call -
3625
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3626
+ return this.requestHandlerInst.identifyRequest('MetastoreInventorySystem', 'getOpstats', reqObj, true, (irReturnData, irReturnError) => {
3627
+ // if we received an error or their is no response on the results
3628
+ // return an error
3629
+ if (irReturnError) {
3630
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3631
+ return callback(null, irReturnError);
3632
+ }
3633
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3634
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getOpstats'], null, null, null);
3635
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3636
+ return callback(null, errorObj);
3637
+ }
3638
+
3639
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3640
+ // return the response
3641
+ return callback(irReturnData, null);
3642
+ });
3643
+ } catch (ex) {
3644
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3645
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3646
+ return callback(null, errorObj);
3647
+ }
3648
+ }
3649
+
3650
+ /**
3651
+ * @function getVersion
3652
+ * @pronghornType method
3653
+ * @name getVersion
3654
+ * @summary version_version_get
3655
+ *
3656
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
3657
+ * @param {getCallback} callback - a callback function to return the result
3658
+ * @return {object} results - An object containing the response of the action
3659
+ *
3660
+ * @route {GET} /getVersion
3661
+ * @roles admin
3662
+ * @task true
3663
+ */
3664
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3665
+ getVersion(iapMetadata, callback) {
3666
+ const meth = 'adapter-getVersion';
3667
+ const origin = `${this.id}-${meth}`;
3668
+ log.trace(origin);
3669
+
3670
+ if (this.suspended && this.suspendMode === 'error') {
3671
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3672
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3673
+ return callback(null, errorObj);
3674
+ }
3675
+
3676
+ /* HERE IS WHERE YOU VALIDATE DATA */
3677
+
3678
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3679
+ const queryParamsAvailable = {};
3680
+ const queryParams = {};
3681
+ const pathVars = [];
3682
+ const bodyVars = {};
3683
+
3684
+ // loop in template. long callback arg name to avoid identifier conflicts
3685
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3686
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3687
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3688
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3689
+ }
3690
+ });
3691
+
3692
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3693
+ // see adapter code documentation for more information on the request object's fields
3694
+ const reqObj = {
3695
+ payload: bodyVars,
3696
+ uriPathVars: pathVars,
3697
+ uriQuery: queryParams
3698
+ };
3699
+
3700
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
3701
+
3702
+ // Merge and add new iapMetadata fields in reqObj
3703
+ if (iapMetadata && typeof iapMetadata === 'object') {
3704
+ Object.keys(iapMetadata).forEach((iapField) => {
3705
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
3706
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
3707
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
3708
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
3709
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
3710
+ } else {
3711
+ // Otherwise, add new iapMetadata fields to reqObj
3712
+ reqObj[iapField] = iapMetadata[iapField];
3713
+ }
3714
+ }
3715
+ });
3716
+ // Add iapMetadata to reqObj for further work
3717
+ reqObj.iapMetadata = iapMetadata;
3718
+ }
3719
+
3720
+ try {
3721
+ // Make the call -
3722
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3723
+ return this.requestHandlerInst.identifyRequest('MetastoreInventorySystem', 'getVersion', reqObj, true, (irReturnData, irReturnError) => {
3724
+ // if we received an error or their is no response on the results
3725
+ // return an error
3726
+ if (irReturnError) {
3727
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3728
+ return callback(null, irReturnError);
3729
+ }
3730
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3731
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getVersion'], null, null, null);
3732
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3733
+ return callback(null, errorObj);
3734
+ }
3735
+
3736
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3737
+ // return the response
3738
+ return callback(irReturnData, null);
3739
+ });
3740
+ } catch (ex) {
3741
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3742
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3743
+ return callback(null, errorObj);
3744
+ }
3745
+ }
3746
+
3747
+ /**
3748
+ * @function getAIConfig
3749
+ * @pronghornType method
3750
+ * @name getAIConfig
3751
+ * @summary config_config_get
3752
+ *
3753
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
3754
+ * @param {getCallback} callback - a callback function to return the result
3755
+ * @return {object} results - An object containing the response of the action
3756
+ *
3757
+ * @route {GET} /getAIConfig
3758
+ * @roles admin
3759
+ * @task true
3760
+ */
3761
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3762
+ getAIConfig(iapMetadata, callback) {
3763
+ const meth = 'adapter-getAIConfig';
3764
+ const origin = `${this.id}-${meth}`;
3765
+ log.trace(origin);
3766
+
3767
+ if (this.suspended && this.suspendMode === 'error') {
3768
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3769
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3770
+ return callback(null, errorObj);
3771
+ }
3772
+
3773
+ /* HERE IS WHERE YOU VALIDATE DATA */
3774
+
3775
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3776
+ const queryParamsAvailable = {};
3777
+ const queryParams = {};
3778
+ const pathVars = [];
3779
+ const bodyVars = {};
3780
+
3781
+ // loop in template. long callback arg name to avoid identifier conflicts
3782
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3783
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3784
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3785
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3786
+ }
3787
+ });
3788
+
3789
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3790
+ // see adapter code documentation for more information on the request object's fields
3791
+ const reqObj = {
3792
+ payload: bodyVars,
3793
+ uriPathVars: pathVars,
3794
+ uriQuery: queryParams
3795
+ };
3796
+
3797
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
3798
+
3799
+ // Merge and add new iapMetadata fields in reqObj
3800
+ if (iapMetadata && typeof iapMetadata === 'object') {
3801
+ Object.keys(iapMetadata).forEach((iapField) => {
3802
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
3803
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
3804
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
3805
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
3806
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
3807
+ } else {
3808
+ // Otherwise, add new iapMetadata fields to reqObj
3809
+ reqObj[iapField] = iapMetadata[iapField];
3810
+ }
3811
+ }
3812
+ });
3813
+ // Add iapMetadata to reqObj for further work
3814
+ reqObj.iapMetadata = iapMetadata;
3815
+ }
3816
+
3817
+ try {
3818
+ // Make the call -
3819
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3820
+ return this.requestHandlerInst.identifyRequest('MetastoreInventorySystem', 'getConfig', reqObj, true, (irReturnData, irReturnError) => {
3821
+ // if we received an error or their is no response on the results
3822
+ // return an error
3823
+ if (irReturnError) {
3824
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3825
+ return callback(null, irReturnError);
3826
+ }
3827
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3828
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getAIConfig'], null, null, null);
3829
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3830
+ return callback(null, errorObj);
3831
+ }
3832
+
3833
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3834
+ // return the response
3835
+ return callback(irReturnData, null);
3836
+ });
3837
+ } catch (ex) {
3838
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3839
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3840
+ return callback(null, errorObj);
3841
+ }
3842
+ }
3843
+
3844
+ /**
3845
+ * @function getHealth
3846
+ * @pronghornType method
3847
+ * @name getHealth
3848
+ * @summary health_health_get
3849
+ *
3850
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
3851
+ * @param {getCallback} callback - a callback function to return the result
3852
+ * @return {object} results - An object containing the response of the action
3853
+ *
3854
+ * @route {GET} /getHealth
3855
+ * @roles admin
3856
+ * @task true
3857
+ */
3858
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3859
+ getHealth(iapMetadata, callback) {
3860
+ const meth = 'adapter-getHealth';
3861
+ const origin = `${this.id}-${meth}`;
3862
+ log.trace(origin);
3863
+
3864
+ if (this.suspended && this.suspendMode === 'error') {
3865
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3866
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3867
+ return callback(null, errorObj);
3868
+ }
3869
+
3870
+ /* HERE IS WHERE YOU VALIDATE DATA */
3871
+
3872
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3873
+ const queryParamsAvailable = {};
3874
+ const queryParams = {};
3875
+ const pathVars = [];
3876
+ const bodyVars = {};
3877
+
3878
+ // loop in template. long callback arg name to avoid identifier conflicts
3879
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3880
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3881
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3882
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3883
+ }
3884
+ });
3885
+
3886
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3887
+ // see adapter code documentation for more information on the request object's fields
3888
+ const reqObj = {
3889
+ payload: bodyVars,
3890
+ uriPathVars: pathVars,
3891
+ uriQuery: queryParams
3892
+ };
3893
+
3894
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
3895
+
3896
+ // Merge and add new iapMetadata fields in reqObj
3897
+ if (iapMetadata && typeof iapMetadata === 'object') {
3898
+ Object.keys(iapMetadata).forEach((iapField) => {
3899
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
3900
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
3901
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
3902
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
3903
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
3904
+ } else {
3905
+ // Otherwise, add new iapMetadata fields to reqObj
3906
+ reqObj[iapField] = iapMetadata[iapField];
3907
+ }
3908
+ }
3909
+ });
3910
+ // Add iapMetadata to reqObj for further work
3911
+ reqObj.iapMetadata = iapMetadata;
3912
+ }
3913
+
3914
+ try {
3915
+ // Make the call -
3916
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
3917
+ return this.requestHandlerInst.identifyRequest('MetastoreInventorySystem', 'getHealth', reqObj, true, (irReturnData, irReturnError) => {
3918
+ // if we received an error or their is no response on the results
3919
+ // return an error
3920
+ if (irReturnError) {
3921
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
3922
+ return callback(null, irReturnError);
3923
+ }
3924
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
3925
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getHealth'], null, null, null);
3926
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3927
+ return callback(null, errorObj);
3928
+ }
3929
+
3930
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
3931
+ // return the response
3932
+ return callback(irReturnData, null);
3933
+ });
3934
+ } catch (ex) {
3935
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
3936
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3937
+ return callback(null, errorObj);
3938
+ }
3939
+ }
3940
+
3941
+ /**
3942
+ * @function healthLogsGet
3943
+ * @pronghornType method
3944
+ * @name healthLogsGet
3945
+ * @summary health_logs_get
3946
+ *
3947
+ * @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
3948
+ * @param {getCallback} callback - a callback function to return the result
3949
+ * @return {object} results - An object containing the response of the action
3950
+ *
3951
+ * @route {GET} /healthLogsGet
3952
+ * @roles admin
3953
+ * @task true
3954
+ */
3955
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
3956
+ healthLogsGet(iapMetadata, callback) {
3957
+ const meth = 'adapter-healthLogsGet';
3958
+ const origin = `${this.id}-${meth}`;
3959
+ log.trace(origin);
3960
+
3961
+ if (this.suspended && this.suspendMode === 'error') {
3962
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
3963
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
3964
+ return callback(null, errorObj);
3965
+ }
3966
+
3967
+ /* HERE IS WHERE YOU VALIDATE DATA */
3968
+
3969
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
3970
+ const queryParamsAvailable = {};
3971
+ const queryParams = {};
3972
+ const pathVars = [];
3973
+ const bodyVars = {};
3974
+
3975
+ // loop in template. long callback arg name to avoid identifier conflicts
3976
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
3977
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
3978
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
3979
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
3980
+ }
3981
+ });
3982
+
3983
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
3984
+ // see adapter code documentation for more information on the request object's fields
3985
+ const reqObj = {
3986
+ payload: bodyVars,
3987
+ uriPathVars: pathVars,
3988
+ uriQuery: queryParams
3989
+ };
3990
+
3991
+ const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
3992
+
3993
+ // Merge and add new iapMetadata fields in reqObj
3994
+ if (iapMetadata && typeof iapMetadata === 'object') {
3995
+ Object.keys(iapMetadata).forEach((iapField) => {
3996
+ if (reqFields.includes(iapField) && iapMetadata[iapField]) {
3997
+ if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
3998
+ reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
3999
+ } else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
4000
+ reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
4001
+ } else {
4002
+ // Otherwise, add new iapMetadata fields to reqObj
4003
+ reqObj[iapField] = iapMetadata[iapField];
4004
+ }
4005
+ }
4006
+ });
4007
+ // Add iapMetadata to reqObj for further work
4008
+ reqObj.iapMetadata = iapMetadata;
4009
+ }
4010
+
4011
+ try {
4012
+ // Make the call -
4013
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
4014
+ return this.requestHandlerInst.identifyRequest('MetastoreInventorySystem', 'healthLogsGet', reqObj, true, (irReturnData, irReturnError) => {
4015
+ // if we received an error or their is no response on the results
4016
+ // return an error
4017
+ if (irReturnError) {
4018
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
4019
+ return callback(null, irReturnError);
4020
+ }
4021
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
4022
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['healthLogsGet'], null, null, null);
4023
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
4024
+ return callback(null, errorObj);
4025
+ }
4026
+
4027
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
4028
+ // return the response
4029
+ return callback(irReturnData, null);
4030
+ });
4031
+ } catch (ex) {
4032
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
4033
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
4034
+ return callback(null, errorObj);
4035
+ }
4036
+ }
4037
+ }
4038
+
4039
+ module.exports = SelectorAi;