@itentialopensource/adapter-starburst 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 (71) hide show
  1. package/.eslintignore +5 -0
  2. package/.eslintrc.js +18 -0
  3. package/.gitlab/.gitkeep +0 -0
  4. package/.gitlab/issue_templates/.gitkeep +0 -0
  5. package/.gitlab/issue_templates/Default.md +17 -0
  6. package/.gitlab/issue_templates/bugReportTemplate.md +76 -0
  7. package/.gitlab/issue_templates/featureRequestTemplate.md +14 -0
  8. package/.jshintrc +3 -0
  9. package/AUTH.md +33 -0
  10. package/BROKER.md +211 -0
  11. package/CALLS.md +236 -0
  12. package/CHANGELOG.md +9 -0
  13. package/CODE_OF_CONDUCT.md +43 -0
  14. package/CONTRIBUTING.md +13 -0
  15. package/ENHANCE.md +69 -0
  16. package/LICENSE +201 -0
  17. package/PROPERTIES.md +646 -0
  18. package/README.md +343 -0
  19. package/SUMMARY.md +9 -0
  20. package/SYSTEMINFO.md +19 -0
  21. package/TAB1.md +5 -0
  22. package/TAB2.md +310 -0
  23. package/TROUBLESHOOT.md +47 -0
  24. package/adapter.js +1776 -0
  25. package/adapterBase.js +1452 -0
  26. package/entities/.generic/action.json +214 -0
  27. package/entities/.generic/schema.json +28 -0
  28. package/entities/.system/action.json +50 -0
  29. package/entities/.system/mockdatafiles/getToken-default.json +3 -0
  30. package/entities/.system/mockdatafiles/healthcheck-default.json +3 -0
  31. package/entities/.system/schema.json +19 -0
  32. package/entities/.system/schemaTokenReq.json +53 -0
  33. package/entities/.system/schemaTokenResp.json +53 -0
  34. package/entities/Dataproduct/action.json +230 -0
  35. package/entities/Dataproduct/schema.json +29 -0
  36. package/error.json +190 -0
  37. package/metadata.json +72 -0
  38. package/package.json +82 -0
  39. package/pronghorn.json +1391 -0
  40. package/propertiesDecorators.json +14 -0
  41. package/propertiesSchema.json +1666 -0
  42. package/refs?service=git-upload-pack +0 -0
  43. package/report/Starburst.postman_collection.json-OpenApi3Json.json +481 -0
  44. package/report/adapterInfo.json +10 -0
  45. package/report/auto-adapter-openapi.json +443 -0
  46. package/report/creationReport.json +265 -0
  47. package/sampleProperties.json +256 -0
  48. package/test/integration/adapterTestBasicGet.js +83 -0
  49. package/test/integration/adapterTestConnectivity.js +118 -0
  50. package/test/integration/adapterTestIntegration.js +763 -0
  51. package/test/unit/adapterBaseTestUnit.js +1024 -0
  52. package/test/unit/adapterTestUnit.js +1863 -0
  53. package/utils/adapterInfo.js +206 -0
  54. package/utils/addAuth.js +94 -0
  55. package/utils/artifactize.js +146 -0
  56. package/utils/basicGet.js +50 -0
  57. package/utils/checkMigrate.js +63 -0
  58. package/utils/entitiesToDB.js +179 -0
  59. package/utils/findPath.js +74 -0
  60. package/utils/methodDocumentor.js +273 -0
  61. package/utils/modify.js +152 -0
  62. package/utils/packModificationScript.js +35 -0
  63. package/utils/patches2bundledDeps.js +90 -0
  64. package/utils/pre-commit.sh +32 -0
  65. package/utils/removeHooks.js +20 -0
  66. package/utils/setup.js +33 -0
  67. package/utils/taskMover.js +309 -0
  68. package/utils/tbScript.js +239 -0
  69. package/utils/tbUtils.js +489 -0
  70. package/utils/testRunner.js +298 -0
  71. package/utils/troubleshootingAdapter.js +193 -0
package/adapter.js ADDED
@@ -0,0 +1,1776 @@
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 Starburst
18
+ */
19
+
20
+ /* GENERAL ADAPTER FUNCTIONS */
21
+ class Starburst extends AdapterBaseCl {
22
+ /**
23
+ * Starburst 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 {boolean} persistFlag - whether the adapter properties should be updated
203
+ * @param {Callback} callback - The results of the call
204
+ */
205
+ iapTroubleshootAdapter(props, persistFlag, callback) {
206
+ const meth = 'adapter-iapTroubleshootAdapter';
207
+ const origin = `${this.id}-${meth}`;
208
+ log.trace(origin);
209
+
210
+ try {
211
+ return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
212
+ } catch (error) {
213
+ log.error(`${origin}: ${error}`);
214
+ return callback(null, error);
215
+ }
216
+ }
217
+
218
+ /**
219
+ * @summary runs healthcheck script for adapter
220
+ *
221
+ * @function iapRunAdapterHealthcheck
222
+ * @param {Adapter} adapter - adapter instance to troubleshoot
223
+ * @param {Callback} callback - callback function
224
+ */
225
+ iapRunAdapterHealthcheck(callback) {
226
+ const meth = 'adapter-iapRunAdapterHealthcheck';
227
+ const origin = `${this.id}-${meth}`;
228
+ log.trace(origin);
229
+
230
+ try {
231
+ return super.iapRunAdapterHealthcheck(this, callback);
232
+ } catch (error) {
233
+ log.error(`${origin}: ${error}`);
234
+ return callback(null, error);
235
+ }
236
+ }
237
+
238
+ /**
239
+ * @summary runs connectivity check script for adapter
240
+ *
241
+ * @function iapRunAdapterConnectivity
242
+ * @param {Callback} callback - callback function
243
+ */
244
+ iapRunAdapterConnectivity(callback) {
245
+ const meth = 'adapter-iapRunAdapterConnectivity';
246
+ const origin = `${this.id}-${meth}`;
247
+ log.trace(origin);
248
+
249
+ try {
250
+ return super.iapRunAdapterConnectivity(callback);
251
+ } catch (error) {
252
+ log.error(`${origin}: ${error}`);
253
+ return callback(null, error);
254
+ }
255
+ }
256
+
257
+ /**
258
+ * @summary runs basicGet script for adapter
259
+ *
260
+ * @function iapRunAdapterBasicGet
261
+ * @param {Callback} callback - callback function
262
+ */
263
+ iapRunAdapterBasicGet(callback) {
264
+ const meth = 'adapter-iapRunAdapterBasicGet';
265
+ const origin = `${this.id}-${meth}`;
266
+ log.trace(origin);
267
+
268
+ try {
269
+ return super.iapRunAdapterBasicGet(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 cloneDataProduct
676
+ * @pronghornType method
677
+ * @name cloneDataProduct
678
+ * @summary cloneDataProduct
679
+ *
680
+ * @param {string} dataProductId - dataProductId param
681
+ * @param {object} body - body param
682
+ * @param {getCallback} callback - a callback function to return the result
683
+ * @return {object} results - An object containing the response of the action
684
+ *
685
+ * @route {POST} /cloneDataProduct
686
+ * @roles admin
687
+ * @task true
688
+ */
689
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
690
+ cloneDataProduct(dataProductId, body, callback) {
691
+ const meth = 'adapter-cloneDataProduct';
692
+ const origin = `${this.id}-${meth}`;
693
+ log.trace(origin);
694
+
695
+ if (this.suspended && this.suspendMode === 'error') {
696
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
697
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
698
+ return callback(null, errorObj);
699
+ }
700
+
701
+ /* HERE IS WHERE YOU VALIDATE DATA */
702
+ if (dataProductId === undefined || dataProductId === null || dataProductId === '') {
703
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dataProductId'], null, null, null);
704
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
705
+ return callback(null, errorObj);
706
+ }
707
+ if (body === undefined || body === null || body === '') {
708
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
709
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
710
+ return callback(null, errorObj);
711
+ }
712
+
713
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
714
+ const queryParamsAvailable = {};
715
+ const queryParams = {};
716
+ const pathVars = [dataProductId];
717
+ const bodyVars = body;
718
+
719
+ // loop in template. long callback arg name to avoid identifier conflicts
720
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
721
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
722
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
723
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
724
+ }
725
+ });
726
+
727
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
728
+ let thisHeaderData = null;
729
+ // if the additional headers was passed in as a string parse the json into an object
730
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
731
+ try {
732
+ // parse the additional headers object that was passed in
733
+ thisHeaderData = JSON.parse(thisHeaderData);
734
+ } catch (err) {
735
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
736
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
737
+ return callback(null, errorObj);
738
+ }
739
+ } else if (thisHeaderData === null) {
740
+ thisHeaderData = { accept: '' };
741
+ }
742
+
743
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
744
+ // see adapter code documentation for more information on the request object's fields
745
+ const reqObj = {
746
+ payload: bodyVars,
747
+ uriPathVars: pathVars,
748
+ uriQuery: queryParams,
749
+ addlHeaders: thisHeaderData
750
+ };
751
+
752
+ try {
753
+ // Make the call -
754
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
755
+ return this.requestHandlerInst.identifyRequest('Dataproduct', 'cloneDataProduct', reqObj, true, (irReturnData, irReturnError) => {
756
+ // if we received an error or their is no response on the results
757
+ // return an error
758
+ if (irReturnError) {
759
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
760
+ return callback(null, irReturnError);
761
+ }
762
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
763
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['cloneDataProduct'], null, null, null);
764
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
765
+ return callback(null, errorObj);
766
+ }
767
+
768
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
769
+ // return the response
770
+ return callback(irReturnData, null);
771
+ });
772
+ } catch (ex) {
773
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
774
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
775
+ return callback(null, errorObj);
776
+ }
777
+ }
778
+
779
+ /**
780
+ * @function createDataProduct
781
+ * @pronghornType method
782
+ * @name createDataProduct
783
+ * @summary createDataProduct
784
+ *
785
+ * @param {object} body - body param
786
+ * @param {getCallback} callback - a callback function to return the result
787
+ * @return {object} results - An object containing the response of the action
788
+ *
789
+ * @route {POST} /createDataProduct
790
+ * @roles admin
791
+ * @task true
792
+ */
793
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
794
+ createDataProduct(body, callback) {
795
+ const meth = 'adapter-createDataProduct';
796
+ const origin = `${this.id}-${meth}`;
797
+ log.trace(origin);
798
+
799
+ if (this.suspended && this.suspendMode === 'error') {
800
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
801
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
802
+ return callback(null, errorObj);
803
+ }
804
+
805
+ /* HERE IS WHERE YOU VALIDATE DATA */
806
+ if (body === undefined || body === null || body === '') {
807
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
808
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
809
+ return callback(null, errorObj);
810
+ }
811
+
812
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
813
+ const queryParamsAvailable = {};
814
+ const queryParams = {};
815
+ const pathVars = [];
816
+ const bodyVars = body;
817
+
818
+ // loop in template. long callback arg name to avoid identifier conflicts
819
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
820
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
821
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
822
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
823
+ }
824
+ });
825
+
826
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
827
+ let thisHeaderData = null;
828
+ // if the additional headers was passed in as a string parse the json into an object
829
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
830
+ try {
831
+ // parse the additional headers object that was passed in
832
+ thisHeaderData = JSON.parse(thisHeaderData);
833
+ } catch (err) {
834
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
835
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
836
+ return callback(null, errorObj);
837
+ }
838
+ } else if (thisHeaderData === null) {
839
+ thisHeaderData = { accept: '' };
840
+ }
841
+
842
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
843
+ // see adapter code documentation for more information on the request object's fields
844
+ const reqObj = {
845
+ payload: bodyVars,
846
+ uriPathVars: pathVars,
847
+ uriQuery: queryParams,
848
+ addlHeaders: thisHeaderData
849
+ };
850
+
851
+ try {
852
+ // Make the call -
853
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
854
+ return this.requestHandlerInst.identifyRequest('Dataproduct', 'createDataProduct', reqObj, true, (irReturnData, irReturnError) => {
855
+ // if we received an error or their is no response on the results
856
+ // return an error
857
+ if (irReturnError) {
858
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
859
+ return callback(null, irReturnError);
860
+ }
861
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
862
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createDataProduct'], null, null, null);
863
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
864
+ return callback(null, errorObj);
865
+ }
866
+
867
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
868
+ // return the response
869
+ return callback(irReturnData, null);
870
+ });
871
+ } catch (ex) {
872
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
873
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
874
+ return callback(null, errorObj);
875
+ }
876
+ }
877
+
878
+ /**
879
+ * @function searchDataProducts
880
+ * @pronghornType method
881
+ * @name searchDataProducts
882
+ * @summary searchDataProducts
883
+ *
884
+ * @param {string} searchOptions - searchOptions param
885
+ * @param {getCallback} callback - a callback function to return the result
886
+ * @return {object} results - An object containing the response of the action
887
+ *
888
+ * @route {POST} /searchDataProducts
889
+ * @roles admin
890
+ * @task true
891
+ */
892
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
893
+ searchDataProducts(searchOptions, callback) {
894
+ const meth = 'adapter-searchDataProducts';
895
+ const origin = `${this.id}-${meth}`;
896
+ log.trace(origin);
897
+
898
+ if (this.suspended && this.suspendMode === 'error') {
899
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
900
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
901
+ return callback(null, errorObj);
902
+ }
903
+
904
+ /* HERE IS WHERE YOU VALIDATE DATA */
905
+ if (searchOptions === undefined || searchOptions === null || searchOptions === '') {
906
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['searchOptions'], null, null, null);
907
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
908
+ return callback(null, errorObj);
909
+ }
910
+
911
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
912
+ const queryParamsAvailable = { searchOptions };
913
+ const queryParams = {};
914
+ const pathVars = [];
915
+ const bodyVars = {};
916
+
917
+ // loop in template. long callback arg name to avoid identifier conflicts
918
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
919
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
920
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
921
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
922
+ }
923
+ });
924
+
925
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
926
+ let thisHeaderData = null;
927
+ // if the additional headers was passed in as a string parse the json into an object
928
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
929
+ try {
930
+ // parse the additional headers object that was passed in
931
+ thisHeaderData = JSON.parse(thisHeaderData);
932
+ } catch (err) {
933
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
934
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
935
+ return callback(null, errorObj);
936
+ }
937
+ } else if (thisHeaderData === null) {
938
+ thisHeaderData = { accept: '' };
939
+ }
940
+
941
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
942
+ // see adapter code documentation for more information on the request object's fields
943
+ const reqObj = {
944
+ payload: bodyVars,
945
+ uriPathVars: pathVars,
946
+ uriQuery: queryParams,
947
+ addlHeaders: thisHeaderData
948
+ };
949
+
950
+ try {
951
+ // Make the call -
952
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
953
+ return this.requestHandlerInst.identifyRequest('Dataproduct', 'searchDataProducts', reqObj, true, (irReturnData, irReturnError) => {
954
+ // if we received an error or their is no response on the results
955
+ // return an error
956
+ if (irReturnError) {
957
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
958
+ return callback(null, irReturnError);
959
+ }
960
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
961
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['searchDataProducts'], null, null, null);
962
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
963
+ return callback(null, errorObj);
964
+ }
965
+
966
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
967
+ // return the response
968
+ return callback(irReturnData, null);
969
+ });
970
+ } catch (ex) {
971
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
972
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
973
+ return callback(null, errorObj);
974
+ }
975
+ }
976
+
977
+ /**
978
+ * @function getDataProduct
979
+ * @pronghornType method
980
+ * @name getDataProduct
981
+ * @summary getDataProduct
982
+ *
983
+ * @param {string} dataProductId - dataProductId param
984
+ * @param {getCallback} callback - a callback function to return the result
985
+ * @return {object} results - An object containing the response of the action
986
+ *
987
+ * @route {POST} /getDataProduct
988
+ * @roles admin
989
+ * @task true
990
+ */
991
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
992
+ getDataProduct(dataProductId, callback) {
993
+ const meth = 'adapter-getDataProduct';
994
+ const origin = `${this.id}-${meth}`;
995
+ log.trace(origin);
996
+
997
+ if (this.suspended && this.suspendMode === 'error') {
998
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
999
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1000
+ return callback(null, errorObj);
1001
+ }
1002
+
1003
+ /* HERE IS WHERE YOU VALIDATE DATA */
1004
+ if (dataProductId === undefined || dataProductId === null || dataProductId === '') {
1005
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dataProductId'], null, null, null);
1006
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1007
+ return callback(null, errorObj);
1008
+ }
1009
+
1010
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1011
+ const queryParamsAvailable = {};
1012
+ const queryParams = {};
1013
+ const pathVars = [dataProductId];
1014
+ const bodyVars = {};
1015
+
1016
+ // loop in template. long callback arg name to avoid identifier conflicts
1017
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1018
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1019
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1020
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1021
+ }
1022
+ });
1023
+
1024
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1025
+ let thisHeaderData = null;
1026
+ // if the additional headers was passed in as a string parse the json into an object
1027
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1028
+ try {
1029
+ // parse the additional headers object that was passed in
1030
+ thisHeaderData = JSON.parse(thisHeaderData);
1031
+ } catch (err) {
1032
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1033
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1034
+ return callback(null, errorObj);
1035
+ }
1036
+ } else if (thisHeaderData === null) {
1037
+ thisHeaderData = { accept: '' };
1038
+ }
1039
+
1040
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1041
+ // see adapter code documentation for more information on the request object's fields
1042
+ const reqObj = {
1043
+ payload: bodyVars,
1044
+ uriPathVars: pathVars,
1045
+ uriQuery: queryParams,
1046
+ addlHeaders: thisHeaderData
1047
+ };
1048
+
1049
+ try {
1050
+ // Make the call -
1051
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1052
+ return this.requestHandlerInst.identifyRequest('Dataproduct', 'getDataProduct', reqObj, true, (irReturnData, irReturnError) => {
1053
+ // if we received an error or their is no response on the results
1054
+ // return an error
1055
+ if (irReturnError) {
1056
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1057
+ return callback(null, irReturnError);
1058
+ }
1059
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1060
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDataProduct'], null, null, null);
1061
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1062
+ return callback(null, errorObj);
1063
+ }
1064
+
1065
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1066
+ // return the response
1067
+ return callback(irReturnData, null);
1068
+ });
1069
+ } catch (ex) {
1070
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1071
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1072
+ return callback(null, errorObj);
1073
+ }
1074
+ }
1075
+
1076
+ /**
1077
+ * @function updateDataProduct
1078
+ * @pronghornType method
1079
+ * @name updateDataProduct
1080
+ * @summary updateDataProduct
1081
+ *
1082
+ * @param {string} dataProductId - dataProductId param
1083
+ * @param {object} body - body param
1084
+ * @param {getCallback} callback - a callback function to return the result
1085
+ * @return {object} results - An object containing the response of the action
1086
+ *
1087
+ * @route {POST} /updateDataProduct
1088
+ * @roles admin
1089
+ * @task true
1090
+ */
1091
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1092
+ updateDataProduct(dataProductId, body, callback) {
1093
+ const meth = 'adapter-updateDataProduct';
1094
+ const origin = `${this.id}-${meth}`;
1095
+ log.trace(origin);
1096
+
1097
+ if (this.suspended && this.suspendMode === 'error') {
1098
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1099
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1100
+ return callback(null, errorObj);
1101
+ }
1102
+
1103
+ /* HERE IS WHERE YOU VALIDATE DATA */
1104
+ if (dataProductId === undefined || dataProductId === null || dataProductId === '') {
1105
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dataProductId'], null, null, null);
1106
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1107
+ return callback(null, errorObj);
1108
+ }
1109
+ if (body === undefined || body === null || body === '') {
1110
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1111
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1112
+ return callback(null, errorObj);
1113
+ }
1114
+
1115
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1116
+ const queryParamsAvailable = {};
1117
+ const queryParams = {};
1118
+ const pathVars = [dataProductId];
1119
+ const bodyVars = body;
1120
+
1121
+ // loop in template. long callback arg name to avoid identifier conflicts
1122
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1123
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1124
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1125
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1126
+ }
1127
+ });
1128
+
1129
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1130
+ let thisHeaderData = null;
1131
+ // if the additional headers was passed in as a string parse the json into an object
1132
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1133
+ try {
1134
+ // parse the additional headers object that was passed in
1135
+ thisHeaderData = JSON.parse(thisHeaderData);
1136
+ } catch (err) {
1137
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1138
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1139
+ return callback(null, errorObj);
1140
+ }
1141
+ } else if (thisHeaderData === null) {
1142
+ thisHeaderData = { accept: '' };
1143
+ }
1144
+
1145
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1146
+ // see adapter code documentation for more information on the request object's fields
1147
+ const reqObj = {
1148
+ payload: bodyVars,
1149
+ uriPathVars: pathVars,
1150
+ uriQuery: queryParams,
1151
+ addlHeaders: thisHeaderData
1152
+ };
1153
+
1154
+ try {
1155
+ // Make the call -
1156
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1157
+ return this.requestHandlerInst.identifyRequest('Dataproduct', 'updateDataProduct', reqObj, false, (irReturnData, irReturnError) => {
1158
+ // if we received an error or their is no response on the results
1159
+ // return an error
1160
+ if (irReturnError) {
1161
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1162
+ return callback(null, irReturnError);
1163
+ }
1164
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1165
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['updateDataProduct'], null, null, null);
1166
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1167
+ return callback(null, errorObj);
1168
+ }
1169
+
1170
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1171
+ // return the response
1172
+ return callback(irReturnData, null);
1173
+ });
1174
+ } catch (ex) {
1175
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1176
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1177
+ return callback(null, errorObj);
1178
+ }
1179
+ }
1180
+
1181
+ /**
1182
+ * @function getMaterializedViewRefreshMetadata
1183
+ * @pronghornType method
1184
+ * @name getMaterializedViewRefreshMetadata
1185
+ * @summary getMaterializedViewRefreshMetadata
1186
+ *
1187
+ * @param {string} dataProductId - dataProductId param
1188
+ * @param {string} viewName - viewName param
1189
+ * @param {getCallback} callback - a callback function to return the result
1190
+ * @return {object} results - An object containing the response of the action
1191
+ *
1192
+ * @route {POST} /getMaterializedViewRefreshMetadata
1193
+ * @roles admin
1194
+ * @task true
1195
+ */
1196
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1197
+ getMaterializedViewRefreshMetadata(dataProductId, viewName, callback) {
1198
+ const meth = 'adapter-getMaterializedViewRefreshMetadata';
1199
+ const origin = `${this.id}-${meth}`;
1200
+ log.trace(origin);
1201
+
1202
+ if (this.suspended && this.suspendMode === 'error') {
1203
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1204
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1205
+ return callback(null, errorObj);
1206
+ }
1207
+
1208
+ /* HERE IS WHERE YOU VALIDATE DATA */
1209
+ if (dataProductId === undefined || dataProductId === null || dataProductId === '') {
1210
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dataProductId'], null, null, null);
1211
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1212
+ return callback(null, errorObj);
1213
+ }
1214
+ if (viewName === undefined || viewName === null || viewName === '') {
1215
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['viewName'], null, null, null);
1216
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1217
+ return callback(null, errorObj);
1218
+ }
1219
+
1220
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1221
+ const queryParamsAvailable = {};
1222
+ const queryParams = {};
1223
+ const pathVars = [dataProductId, viewName];
1224
+ const bodyVars = {};
1225
+
1226
+ // loop in template. long callback arg name to avoid identifier conflicts
1227
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1228
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1229
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1230
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1231
+ }
1232
+ });
1233
+
1234
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1235
+ let thisHeaderData = null;
1236
+ // if the additional headers was passed in as a string parse the json into an object
1237
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1238
+ try {
1239
+ // parse the additional headers object that was passed in
1240
+ thisHeaderData = JSON.parse(thisHeaderData);
1241
+ } catch (err) {
1242
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1243
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1244
+ return callback(null, errorObj);
1245
+ }
1246
+ } else if (thisHeaderData === null) {
1247
+ thisHeaderData = { accept: '' };
1248
+ }
1249
+
1250
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1251
+ // see adapter code documentation for more information on the request object's fields
1252
+ const reqObj = {
1253
+ payload: bodyVars,
1254
+ uriPathVars: pathVars,
1255
+ uriQuery: queryParams,
1256
+ addlHeaders: thisHeaderData
1257
+ };
1258
+
1259
+ try {
1260
+ // Make the call -
1261
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1262
+ return this.requestHandlerInst.identifyRequest('Dataproduct', 'getMaterializedViewRefreshMetadata', reqObj, true, (irReturnData, irReturnError) => {
1263
+ // if we received an error or their is no response on the results
1264
+ // return an error
1265
+ if (irReturnError) {
1266
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1267
+ return callback(null, irReturnError);
1268
+ }
1269
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1270
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getMaterializedViewRefreshMetadata'], null, null, null);
1271
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1272
+ return callback(null, errorObj);
1273
+ }
1274
+
1275
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1276
+ // return the response
1277
+ return callback(irReturnData, null);
1278
+ });
1279
+ } catch (ex) {
1280
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1281
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1282
+ return callback(null, errorObj);
1283
+ }
1284
+ }
1285
+
1286
+ /**
1287
+ * @function getOpenApi
1288
+ * @pronghornType method
1289
+ * @name getOpenApi
1290
+ * @summary getOpenApi
1291
+ *
1292
+ * @param {getCallback} callback - a callback function to return the result
1293
+ * @return {object} results - An object containing the response of the action
1294
+ *
1295
+ * @route {GET} /getOpenApi
1296
+ * @roles admin
1297
+ * @task true
1298
+ */
1299
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1300
+ getOpenApi(callback) {
1301
+ const meth = 'adapter-getOpenApi';
1302
+ const origin = `${this.id}-${meth}`;
1303
+ log.trace(origin);
1304
+
1305
+ if (this.suspended && this.suspendMode === 'error') {
1306
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1307
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1308
+ return callback(null, errorObj);
1309
+ }
1310
+
1311
+ /* HERE IS WHERE YOU VALIDATE DATA */
1312
+
1313
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1314
+ const queryParamsAvailable = {};
1315
+ const queryParams = {};
1316
+ const pathVars = [];
1317
+ const bodyVars = {};
1318
+
1319
+ // loop in template. long callback arg name to avoid identifier conflicts
1320
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1321
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1322
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1323
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1324
+ }
1325
+ });
1326
+
1327
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1328
+ let thisHeaderData = null;
1329
+ // if the additional headers was passed in as a string parse the json into an object
1330
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1331
+ try {
1332
+ // parse the additional headers object that was passed in
1333
+ thisHeaderData = JSON.parse(thisHeaderData);
1334
+ } catch (err) {
1335
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1336
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1337
+ return callback(null, errorObj);
1338
+ }
1339
+ } else if (thisHeaderData === null) {
1340
+ thisHeaderData = { accept: '' };
1341
+ }
1342
+
1343
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1344
+ // see adapter code documentation for more information on the request object's fields
1345
+ const reqObj = {
1346
+ payload: bodyVars,
1347
+ uriPathVars: pathVars,
1348
+ uriQuery: queryParams,
1349
+ addlHeaders: thisHeaderData
1350
+ };
1351
+
1352
+ try {
1353
+ // Make the call -
1354
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1355
+ return this.requestHandlerInst.identifyRequest('Dataproduct', 'getOpenApi', reqObj, true, (irReturnData, irReturnError) => {
1356
+ // if we received an error or their is no response on the results
1357
+ // return an error
1358
+ if (irReturnError) {
1359
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1360
+ return callback(null, irReturnError);
1361
+ }
1362
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1363
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getOpenApi'], null, null, null);
1364
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1365
+ return callback(null, errorObj);
1366
+ }
1367
+
1368
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1369
+ // return the response
1370
+ return callback(irReturnData, null);
1371
+ });
1372
+ } catch (ex) {
1373
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1374
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1375
+ return callback(null, errorObj);
1376
+ }
1377
+ }
1378
+
1379
+ /**
1380
+ * @function getTargetCatalogs
1381
+ * @pronghornType method
1382
+ * @name getTargetCatalogs
1383
+ * @summary getTargetCatalogs
1384
+ *
1385
+ * @param {getCallback} callback - a callback function to return the result
1386
+ * @return {object} results - An object containing the response of the action
1387
+ *
1388
+ * @route {GET} /getTargetCatalogs
1389
+ * @roles admin
1390
+ * @task true
1391
+ */
1392
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1393
+ getTargetCatalogs(callback) {
1394
+ const meth = 'adapter-getTargetCatalogs';
1395
+ const origin = `${this.id}-${meth}`;
1396
+ log.trace(origin);
1397
+
1398
+ if (this.suspended && this.suspendMode === 'error') {
1399
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1400
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1401
+ return callback(null, errorObj);
1402
+ }
1403
+
1404
+ /* HERE IS WHERE YOU VALIDATE DATA */
1405
+
1406
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1407
+ const queryParamsAvailable = {};
1408
+ const queryParams = {};
1409
+ const pathVars = [];
1410
+ const bodyVars = {};
1411
+
1412
+ // loop in template. long callback arg name to avoid identifier conflicts
1413
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1414
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1415
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1416
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1417
+ }
1418
+ });
1419
+
1420
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1421
+ let thisHeaderData = null;
1422
+ // if the additional headers was passed in as a string parse the json into an object
1423
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1424
+ try {
1425
+ // parse the additional headers object that was passed in
1426
+ thisHeaderData = JSON.parse(thisHeaderData);
1427
+ } catch (err) {
1428
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1429
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1430
+ return callback(null, errorObj);
1431
+ }
1432
+ } else if (thisHeaderData === null) {
1433
+ thisHeaderData = { accept: '' };
1434
+ }
1435
+
1436
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1437
+ // see adapter code documentation for more information on the request object's fields
1438
+ const reqObj = {
1439
+ payload: bodyVars,
1440
+ uriPathVars: pathVars,
1441
+ uriQuery: queryParams,
1442
+ addlHeaders: thisHeaderData
1443
+ };
1444
+
1445
+ try {
1446
+ // Make the call -
1447
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1448
+ return this.requestHandlerInst.identifyRequest('Dataproduct', 'getTargetCatalogs', reqObj, true, (irReturnData, irReturnError) => {
1449
+ // if we received an error or their is no response on the results
1450
+ // return an error
1451
+ if (irReturnError) {
1452
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1453
+ return callback(null, irReturnError);
1454
+ }
1455
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1456
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getTargetCatalogs'], null, null, null);
1457
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1458
+ return callback(null, errorObj);
1459
+ }
1460
+
1461
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1462
+ // return the response
1463
+ return callback(irReturnData, null);
1464
+ });
1465
+ } catch (ex) {
1466
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1467
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1468
+ return callback(null, errorObj);
1469
+ }
1470
+ }
1471
+
1472
+ /**
1473
+ * @function listSampleQueries
1474
+ * @pronghornType method
1475
+ * @name listSampleQueries
1476
+ * @summary listSampleQueries
1477
+ *
1478
+ * @param {string} dataProductId - dataProductId param
1479
+ * @param {getCallback} callback - a callback function to return the result
1480
+ * @return {object} results - An object containing the response of the action
1481
+ *
1482
+ * @route {POST} /listSampleQueries
1483
+ * @roles admin
1484
+ * @task true
1485
+ */
1486
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1487
+ listSampleQueries(dataProductId, callback) {
1488
+ const meth = 'adapter-listSampleQueries';
1489
+ const origin = `${this.id}-${meth}`;
1490
+ log.trace(origin);
1491
+
1492
+ if (this.suspended && this.suspendMode === 'error') {
1493
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1494
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1495
+ return callback(null, errorObj);
1496
+ }
1497
+
1498
+ /* HERE IS WHERE YOU VALIDATE DATA */
1499
+ if (dataProductId === undefined || dataProductId === null || dataProductId === '') {
1500
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dataProductId'], null, null, null);
1501
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1502
+ return callback(null, errorObj);
1503
+ }
1504
+
1505
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1506
+ const queryParamsAvailable = {};
1507
+ const queryParams = {};
1508
+ const pathVars = [dataProductId];
1509
+ const bodyVars = {};
1510
+
1511
+ // loop in template. long callback arg name to avoid identifier conflicts
1512
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1513
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1514
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1515
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1516
+ }
1517
+ });
1518
+
1519
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1520
+ let thisHeaderData = null;
1521
+ // if the additional headers was passed in as a string parse the json into an object
1522
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1523
+ try {
1524
+ // parse the additional headers object that was passed in
1525
+ thisHeaderData = JSON.parse(thisHeaderData);
1526
+ } catch (err) {
1527
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1528
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1529
+ return callback(null, errorObj);
1530
+ }
1531
+ } else if (thisHeaderData === null) {
1532
+ thisHeaderData = { accept: '' };
1533
+ }
1534
+
1535
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1536
+ // see adapter code documentation for more information on the request object's fields
1537
+ const reqObj = {
1538
+ payload: bodyVars,
1539
+ uriPathVars: pathVars,
1540
+ uriQuery: queryParams,
1541
+ addlHeaders: thisHeaderData
1542
+ };
1543
+
1544
+ try {
1545
+ // Make the call -
1546
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1547
+ return this.requestHandlerInst.identifyRequest('Dataproduct', 'listSampleQueries', reqObj, true, (irReturnData, irReturnError) => {
1548
+ // if we received an error or their is no response on the results
1549
+ // return an error
1550
+ if (irReturnError) {
1551
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1552
+ return callback(null, irReturnError);
1553
+ }
1554
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1555
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listSampleQueries'], null, null, null);
1556
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1557
+ return callback(null, errorObj);
1558
+ }
1559
+
1560
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1561
+ // return the response
1562
+ return callback(irReturnData, null);
1563
+ });
1564
+ } catch (ex) {
1565
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1566
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1567
+ return callback(null, errorObj);
1568
+ }
1569
+ }
1570
+
1571
+ /**
1572
+ * @function updateSampleQueries
1573
+ * @pronghornType method
1574
+ * @name updateSampleQueries
1575
+ * @summary updateSampleQueries
1576
+ *
1577
+ * @param {string} dataProductId - dataProductId param
1578
+ * @param {object} body - body param
1579
+ * @param {getCallback} callback - a callback function to return the result
1580
+ * @return {object} results - An object containing the response of the action
1581
+ *
1582
+ * @route {POST} /updateSampleQueries
1583
+ * @roles admin
1584
+ * @task true
1585
+ */
1586
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1587
+ updateSampleQueries(dataProductId, body, callback) {
1588
+ const meth = 'adapter-updateSampleQueries';
1589
+ const origin = `${this.id}-${meth}`;
1590
+ log.trace(origin);
1591
+
1592
+ if (this.suspended && this.suspendMode === 'error') {
1593
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1594
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1595
+ return callback(null, errorObj);
1596
+ }
1597
+
1598
+ /* HERE IS WHERE YOU VALIDATE DATA */
1599
+ if (dataProductId === undefined || dataProductId === null || dataProductId === '') {
1600
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dataProductId'], null, null, null);
1601
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1602
+ return callback(null, errorObj);
1603
+ }
1604
+ if (body === undefined || body === null || body === '') {
1605
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1606
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1607
+ return callback(null, errorObj);
1608
+ }
1609
+
1610
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1611
+ const queryParamsAvailable = {};
1612
+ const queryParams = {};
1613
+ const pathVars = [dataProductId];
1614
+ const bodyVars = body;
1615
+
1616
+ // loop in template. long callback arg name to avoid identifier conflicts
1617
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1618
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1619
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1620
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1621
+ }
1622
+ });
1623
+
1624
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1625
+ let thisHeaderData = null;
1626
+ // if the additional headers was passed in as a string parse the json into an object
1627
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1628
+ try {
1629
+ // parse the additional headers object that was passed in
1630
+ thisHeaderData = JSON.parse(thisHeaderData);
1631
+ } catch (err) {
1632
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1633
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1634
+ return callback(null, errorObj);
1635
+ }
1636
+ } else if (thisHeaderData === null) {
1637
+ thisHeaderData = { accept: '' };
1638
+ }
1639
+
1640
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1641
+ // see adapter code documentation for more information on the request object's fields
1642
+ const reqObj = {
1643
+ payload: bodyVars,
1644
+ uriPathVars: pathVars,
1645
+ uriQuery: queryParams,
1646
+ addlHeaders: thisHeaderData
1647
+ };
1648
+
1649
+ try {
1650
+ // Make the call -
1651
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1652
+ return this.requestHandlerInst.identifyRequest('Dataproduct', 'updateSampleQueries', reqObj, false, (irReturnData, irReturnError) => {
1653
+ // if we received an error or their is no response on the results
1654
+ // return an error
1655
+ if (irReturnError) {
1656
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1657
+ return callback(null, irReturnError);
1658
+ }
1659
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1660
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['updateSampleQueries'], null, null, null);
1661
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1662
+ return callback(null, errorObj);
1663
+ }
1664
+
1665
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1666
+ // return the response
1667
+ return callback(irReturnData, null);
1668
+ });
1669
+ } catch (ex) {
1670
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1671
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1672
+ return callback(null, errorObj);
1673
+ }
1674
+ }
1675
+
1676
+ /**
1677
+ * @function reassignDomainForDataProducts
1678
+ * @pronghornType method
1679
+ * @name reassignDomainForDataProducts
1680
+ * @summary reassignDomainForDataProducts
1681
+ *
1682
+ * @param {object} body - body param
1683
+ * @param {getCallback} callback - a callback function to return the result
1684
+ * @return {object} results - An object containing the response of the action
1685
+ *
1686
+ * @route {POST} /reassignDomainForDataProducts
1687
+ * @roles admin
1688
+ * @task true
1689
+ */
1690
+ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
1691
+ reassignDomainForDataProducts(body, callback) {
1692
+ const meth = 'adapter-reassignDomainForDataProducts';
1693
+ const origin = `${this.id}-${meth}`;
1694
+ log.trace(origin);
1695
+
1696
+ if (this.suspended && this.suspendMode === 'error') {
1697
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
1698
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1699
+ return callback(null, errorObj);
1700
+ }
1701
+
1702
+ /* HERE IS WHERE YOU VALIDATE DATA */
1703
+ if (body === undefined || body === null || body === '') {
1704
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
1705
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1706
+ return callback(null, errorObj);
1707
+ }
1708
+
1709
+ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
1710
+ const queryParamsAvailable = {};
1711
+ const queryParams = {};
1712
+ const pathVars = [];
1713
+ const bodyVars = body;
1714
+
1715
+ // loop in template. long callback arg name to avoid identifier conflicts
1716
+ Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
1717
+ if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
1718
+ && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
1719
+ queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
1720
+ }
1721
+ });
1722
+
1723
+ // if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
1724
+ let thisHeaderData = null;
1725
+ // if the additional headers was passed in as a string parse the json into an object
1726
+ if (thisHeaderData !== null && thisHeaderData.constructor === String) {
1727
+ try {
1728
+ // parse the additional headers object that was passed in
1729
+ thisHeaderData = JSON.parse(thisHeaderData);
1730
+ } catch (err) {
1731
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
1732
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1733
+ return callback(null, errorObj);
1734
+ }
1735
+ } else if (thisHeaderData === null) {
1736
+ thisHeaderData = { accept: '' };
1737
+ }
1738
+
1739
+ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
1740
+ // see adapter code documentation for more information on the request object's fields
1741
+ const reqObj = {
1742
+ payload: bodyVars,
1743
+ uriPathVars: pathVars,
1744
+ uriQuery: queryParams,
1745
+ addlHeaders: thisHeaderData
1746
+ };
1747
+
1748
+ try {
1749
+ // Make the call -
1750
+ // identifyRequest(entity, action, requestObj, returnDataFlag, callback)
1751
+ return this.requestHandlerInst.identifyRequest('Dataproduct', 'reassignDomainForDataProducts', reqObj, true, (irReturnData, irReturnError) => {
1752
+ // if we received an error or their is no response on the results
1753
+ // return an error
1754
+ if (irReturnError) {
1755
+ /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
1756
+ return callback(null, irReturnError);
1757
+ }
1758
+ if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
1759
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['reassignDomainForDataProducts'], null, null, null);
1760
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1761
+ return callback(null, errorObj);
1762
+ }
1763
+
1764
+ /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
1765
+ // return the response
1766
+ return callback(irReturnData, null);
1767
+ });
1768
+ } catch (ex) {
1769
+ const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
1770
+ log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
1771
+ return callback(null, errorObj);
1772
+ }
1773
+ }
1774
+ }
1775
+
1776
+ module.exports = Starburst;