@itentialopensource/adapter-nokia_netact 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.
- package/.eslintignore +5 -0
- package/.eslintrc.js +18 -0
- package/.jshintrc +3 -0
- package/AUTH.md +32 -0
- package/BROKER.md +211 -0
- package/CALLS.md +447 -0
- package/CODE_OF_CONDUCT.md +43 -0
- package/CONTRIBUTING.md +13 -0
- package/ENHANCE.md +69 -0
- package/LICENSE +201 -0
- package/PROPERTIES.md +646 -0
- package/README.md +343 -0
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +18 -0
- package/TAB1.md +11 -0
- package/TAB2.md +303 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +4743 -0
- package/adapterBase.js +1452 -0
- package/changelogs/CHANGELOG.md +0 -0
- package/entities/.generic/action.json +214 -0
- package/entities/.generic/schema.json +28 -0
- package/entities/.system/action.json +50 -0
- package/entities/.system/mockdatafiles/getToken-default.json +3 -0
- package/entities/.system/mockdatafiles/healthcheck-default.json +3 -0
- package/entities/.system/schema.json +19 -0
- package/entities/.system/schemaTokenReq.json +53 -0
- package/entities/.system/schemaTokenResp.json +53 -0
- package/entities/OpenCmOperationsPortBinding/action.json +64 -0
- package/entities/OpenCmOperationsPortBinding/schema.json +21 -0
- package/entities/OpenCmPersistencyPortBinding/action.json +244 -0
- package/entities/OpenCmPersistencyPortBinding/schema.json +30 -0
- package/entities/Operations/action.json +169 -0
- package/entities/Operations/schema.json +26 -0
- package/entities/Persistency/action.json +348 -0
- package/entities/Persistency/schema.json +35 -0
- package/error.json +190 -0
- package/metadata.json +78 -0
- package/package.json +81 -0
- package/pronghorn.json +2889 -0
- package/propertiesDecorators.json +14 -0
- package/propertiesSchema.json +1574 -0
- package/report/Nokia-NetAct-REST-SOAP-OpenAPI3.v1.json +3014 -0
- package/report/adapter-openapi.json +3014 -0
- package/report/adapter-openapi.yaml +2396 -0
- package/report/adapterInfo.json +10 -0
- package/report/auto-adapter-openapi.json +1420 -0
- package/report/creationReport.json +455 -0
- package/sampleProperties.json +257 -0
- package/test/integration/adapterTestBasicGet.js +83 -0
- package/test/integration/adapterTestConnectivity.js +118 -0
- package/test/integration/adapterTestIntegration.js +1509 -0
- package/test/unit/adapterBaseTestUnit.js +1024 -0
- package/test/unit/adapterTestUnit.js +2477 -0
- package/utils/adapterInfo.js +206 -0
- package/utils/addAuth.js +94 -0
- package/utils/artifactize.js +146 -0
- package/utils/basicGet.js +50 -0
- package/utils/checkMigrate.js +63 -0
- package/utils/entitiesToDB.js +179 -0
- package/utils/findPath.js +74 -0
- package/utils/methodDocumentor.js +273 -0
- package/utils/modify.js +152 -0
- package/utils/packModificationScript.js +35 -0
- package/utils/patches2bundledDeps.js +90 -0
- package/utils/pre-commit.sh +32 -0
- package/utils/removeHooks.js +20 -0
- package/utils/setup.js +33 -0
- package/utils/taskMover.js +309 -0
- package/utils/tbScript.js +239 -0
- package/utils/tbUtils.js +489 -0
- package/utils/testRunner.js +298 -0
- package/utils/troubleshootingAdapter.js +193 -0
package/adapter.js
ADDED
|
@@ -0,0 +1,4743 @@
|
|
|
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 Nokia_netact
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/* GENERAL ADAPTER FUNCTIONS */
|
|
21
|
+
class NokiaNetact extends AdapterBaseCl {
|
|
22
|
+
/**
|
|
23
|
+
* NokiaNetact 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 getConfigurations
|
|
676
|
+
* @pronghornType method
|
|
677
|
+
* @name getConfigurations
|
|
678
|
+
* @summary Retrieve configuration headers
|
|
679
|
+
*
|
|
680
|
+
* @param {string} [type] - type param
|
|
681
|
+
* @param {string} [confId] - confId param
|
|
682
|
+
* @param {string} [name] - name param
|
|
683
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
684
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
685
|
+
* @return {object} results - An object containing the response of the action
|
|
686
|
+
*
|
|
687
|
+
* @route {POST} /getConfigurations
|
|
688
|
+
* @roles admin
|
|
689
|
+
* @task true
|
|
690
|
+
*/
|
|
691
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
692
|
+
getConfigurations(type = 'ACTUAL', confId, name, iapMetadata, callback) {
|
|
693
|
+
const meth = 'adapter-getConfigurations';
|
|
694
|
+
const origin = `${this.id}-${meth}`;
|
|
695
|
+
log.trace(origin);
|
|
696
|
+
|
|
697
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
698
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
699
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
700
|
+
return callback(null, errorObj);
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
704
|
+
|
|
705
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
706
|
+
const queryParamsAvailable = { type, confId, name };
|
|
707
|
+
const queryParams = {};
|
|
708
|
+
const pathVars = [];
|
|
709
|
+
const bodyVars = {};
|
|
710
|
+
|
|
711
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
712
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
713
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
714
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
715
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
716
|
+
}
|
|
717
|
+
});
|
|
718
|
+
|
|
719
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
720
|
+
// see adapter code documentation for more information on the request object's fields
|
|
721
|
+
const reqObj = {
|
|
722
|
+
payload: bodyVars,
|
|
723
|
+
uriPathVars: pathVars,
|
|
724
|
+
uriQuery: queryParams
|
|
725
|
+
};
|
|
726
|
+
|
|
727
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
728
|
+
|
|
729
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
730
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
731
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
732
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
733
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
734
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
735
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
736
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
737
|
+
} else {
|
|
738
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
739
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
// Add iapMetadata to reqObj for further work
|
|
744
|
+
reqObj.iapMetadata = iapMetadata;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
try {
|
|
748
|
+
// Make the call -
|
|
749
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
750
|
+
return this.requestHandlerInst.identifyRequest('Persistency', 'getConfigurations', reqObj, true, (irReturnData, irReturnError) => {
|
|
751
|
+
// if we received an error or their is no response on the results
|
|
752
|
+
// return an error
|
|
753
|
+
if (irReturnError) {
|
|
754
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
755
|
+
return callback(null, irReturnError);
|
|
756
|
+
}
|
|
757
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
758
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getConfigurations'], null, null, null);
|
|
759
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
760
|
+
return callback(null, errorObj);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
764
|
+
// return the response
|
|
765
|
+
return callback(irReturnData, null);
|
|
766
|
+
});
|
|
767
|
+
} catch (ex) {
|
|
768
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
769
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
770
|
+
return callback(null, errorObj);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* @function createConfiguration
|
|
776
|
+
* @pronghornType method
|
|
777
|
+
* @name createConfiguration
|
|
778
|
+
* @summary Create a plan
|
|
779
|
+
*
|
|
780
|
+
* @param {object} body - body param
|
|
781
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
782
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
783
|
+
* @return {object} results - An object containing the response of the action
|
|
784
|
+
*
|
|
785
|
+
* @route {POST} /createConfiguration
|
|
786
|
+
* @roles admin
|
|
787
|
+
* @task true
|
|
788
|
+
*/
|
|
789
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
790
|
+
createConfiguration(body, iapMetadata, callback) {
|
|
791
|
+
const meth = 'adapter-createConfiguration';
|
|
792
|
+
const origin = `${this.id}-${meth}`;
|
|
793
|
+
log.trace(origin);
|
|
794
|
+
|
|
795
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
796
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
797
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
798
|
+
return callback(null, errorObj);
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
802
|
+
if (body === undefined || body === null || body === '') {
|
|
803
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
804
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
805
|
+
return callback(null, errorObj);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
809
|
+
const queryParamsAvailable = {};
|
|
810
|
+
const queryParams = {};
|
|
811
|
+
const pathVars = [];
|
|
812
|
+
const bodyVars = body;
|
|
813
|
+
|
|
814
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
815
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
816
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
817
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
818
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
819
|
+
}
|
|
820
|
+
});
|
|
821
|
+
|
|
822
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
823
|
+
// see adapter code documentation for more information on the request object's fields
|
|
824
|
+
const reqObj = {
|
|
825
|
+
payload: bodyVars,
|
|
826
|
+
uriPathVars: pathVars,
|
|
827
|
+
uriQuery: queryParams
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
831
|
+
|
|
832
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
833
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
834
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
835
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
836
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
837
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
838
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
839
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
840
|
+
} else {
|
|
841
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
842
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
});
|
|
846
|
+
// Add iapMetadata to reqObj for further work
|
|
847
|
+
reqObj.iapMetadata = iapMetadata;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
try {
|
|
851
|
+
// Make the call -
|
|
852
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
853
|
+
return this.requestHandlerInst.identifyRequest('Persistency', 'createConfiguration', reqObj, true, (irReturnData, irReturnError) => {
|
|
854
|
+
// if we received an error or their is no response on the results
|
|
855
|
+
// return an error
|
|
856
|
+
if (irReturnError) {
|
|
857
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
858
|
+
return callback(null, irReturnError);
|
|
859
|
+
}
|
|
860
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
861
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createConfiguration'], null, null, null);
|
|
862
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
863
|
+
return callback(null, errorObj);
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
867
|
+
// return the response
|
|
868
|
+
return callback(irReturnData, null);
|
|
869
|
+
});
|
|
870
|
+
} catch (ex) {
|
|
871
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
872
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
873
|
+
return callback(null, errorObj);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* @function deleteConfiguration
|
|
879
|
+
* @pronghornType method
|
|
880
|
+
* @name deleteConfiguration
|
|
881
|
+
* @summary Delete a plan
|
|
882
|
+
*
|
|
883
|
+
* @param {string} confId - confId param
|
|
884
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
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} /deleteConfiguration
|
|
889
|
+
* @roles admin
|
|
890
|
+
* @task true
|
|
891
|
+
*/
|
|
892
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
893
|
+
deleteConfiguration(confId, iapMetadata, callback) {
|
|
894
|
+
const meth = 'adapter-deleteConfiguration';
|
|
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 (confId === undefined || confId === null || confId === '') {
|
|
906
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['confId'], 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 = { confId };
|
|
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
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
926
|
+
// see adapter code documentation for more information on the request object's fields
|
|
927
|
+
const reqObj = {
|
|
928
|
+
payload: bodyVars,
|
|
929
|
+
uriPathVars: pathVars,
|
|
930
|
+
uriQuery: queryParams
|
|
931
|
+
};
|
|
932
|
+
|
|
933
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
934
|
+
|
|
935
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
936
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
937
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
938
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
939
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
940
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
941
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
942
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
943
|
+
} else {
|
|
944
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
945
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
});
|
|
949
|
+
// Add iapMetadata to reqObj for further work
|
|
950
|
+
reqObj.iapMetadata = iapMetadata;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
try {
|
|
954
|
+
// Make the call -
|
|
955
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
956
|
+
return this.requestHandlerInst.identifyRequest('Persistency', 'deleteConfiguration', reqObj, false, (irReturnData, irReturnError) => {
|
|
957
|
+
// if we received an error or their is no response on the results
|
|
958
|
+
// return an error
|
|
959
|
+
if (irReturnError) {
|
|
960
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
961
|
+
return callback(null, irReturnError);
|
|
962
|
+
}
|
|
963
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
964
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteConfiguration'], null, null, null);
|
|
965
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
966
|
+
return callback(null, errorObj);
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
970
|
+
// return the response
|
|
971
|
+
return callback(irReturnData, null);
|
|
972
|
+
});
|
|
973
|
+
} catch (ex) {
|
|
974
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
975
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
976
|
+
return callback(null, errorObj);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* @function updateConfiguration
|
|
982
|
+
* @pronghornType method
|
|
983
|
+
* @name updateConfiguration
|
|
984
|
+
* @summary Update a plan
|
|
985
|
+
*
|
|
986
|
+
* @param {object} body - body param
|
|
987
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
988
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
989
|
+
* @return {object} results - An object containing the response of the action
|
|
990
|
+
*
|
|
991
|
+
* @route {POST} /updateConfiguration
|
|
992
|
+
* @roles admin
|
|
993
|
+
* @task true
|
|
994
|
+
*/
|
|
995
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
996
|
+
updateConfiguration(body, iapMetadata, callback) {
|
|
997
|
+
const meth = 'adapter-updateConfiguration';
|
|
998
|
+
const origin = `${this.id}-${meth}`;
|
|
999
|
+
log.trace(origin);
|
|
1000
|
+
|
|
1001
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1002
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1003
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1004
|
+
return callback(null, errorObj);
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1008
|
+
if (body === undefined || body === null || body === '') {
|
|
1009
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
1010
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1011
|
+
return callback(null, errorObj);
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1015
|
+
const queryParamsAvailable = {};
|
|
1016
|
+
const queryParams = {};
|
|
1017
|
+
const pathVars = [];
|
|
1018
|
+
const bodyVars = body;
|
|
1019
|
+
|
|
1020
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1021
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1022
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1023
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1024
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
1027
|
+
|
|
1028
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1029
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1030
|
+
const reqObj = {
|
|
1031
|
+
payload: bodyVars,
|
|
1032
|
+
uriPathVars: pathVars,
|
|
1033
|
+
uriQuery: queryParams
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1036
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
1037
|
+
|
|
1038
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
1039
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
1040
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
1041
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
1042
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
1043
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
1044
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
1045
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
1046
|
+
} else {
|
|
1047
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
1048
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
});
|
|
1052
|
+
// Add iapMetadata to reqObj for further work
|
|
1053
|
+
reqObj.iapMetadata = iapMetadata;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
try {
|
|
1057
|
+
// Make the call -
|
|
1058
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1059
|
+
return this.requestHandlerInst.identifyRequest('Persistency', 'updateConfiguration', reqObj, false, (irReturnData, irReturnError) => {
|
|
1060
|
+
// if we received an error or their is no response on the results
|
|
1061
|
+
// return an error
|
|
1062
|
+
if (irReturnError) {
|
|
1063
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1064
|
+
return callback(null, irReturnError);
|
|
1065
|
+
}
|
|
1066
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1067
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['updateConfiguration'], null, null, null);
|
|
1068
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1069
|
+
return callback(null, errorObj);
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1073
|
+
// return the response
|
|
1074
|
+
return callback(irReturnData, null);
|
|
1075
|
+
});
|
|
1076
|
+
} catch (ex) {
|
|
1077
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1078
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1079
|
+
return callback(null, errorObj);
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
/**
|
|
1084
|
+
* @function getDescendantMOLites
|
|
1085
|
+
* @pronghornType method
|
|
1086
|
+
* @name getDescendantMOLites
|
|
1087
|
+
* @summary Retrieve descendant Managed Objects
|
|
1088
|
+
*
|
|
1089
|
+
* @param {object} body - body param
|
|
1090
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
1091
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1092
|
+
* @return {object} results - An object containing the response of the action
|
|
1093
|
+
*
|
|
1094
|
+
* @route {POST} /getDescendantMOLites
|
|
1095
|
+
* @roles admin
|
|
1096
|
+
* @task true
|
|
1097
|
+
*/
|
|
1098
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1099
|
+
getDescendantMOLites(body, iapMetadata, callback) {
|
|
1100
|
+
const meth = 'adapter-getDescendantMOLites';
|
|
1101
|
+
const origin = `${this.id}-${meth}`;
|
|
1102
|
+
log.trace(origin);
|
|
1103
|
+
|
|
1104
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1105
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1106
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1107
|
+
return callback(null, errorObj);
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1111
|
+
if (body === undefined || body === null || body === '') {
|
|
1112
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
1113
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1114
|
+
return callback(null, errorObj);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1118
|
+
const queryParamsAvailable = {};
|
|
1119
|
+
const queryParams = {};
|
|
1120
|
+
const pathVars = [];
|
|
1121
|
+
const bodyVars = body;
|
|
1122
|
+
|
|
1123
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1124
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1125
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1126
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1127
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
1130
|
+
|
|
1131
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1132
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1133
|
+
const reqObj = {
|
|
1134
|
+
payload: bodyVars,
|
|
1135
|
+
uriPathVars: pathVars,
|
|
1136
|
+
uriQuery: queryParams
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1139
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
1140
|
+
|
|
1141
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
1142
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
1143
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
1144
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
1145
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
1146
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
1147
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
1148
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
1149
|
+
} else {
|
|
1150
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
1151
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
});
|
|
1155
|
+
// Add iapMetadata to reqObj for further work
|
|
1156
|
+
reqObj.iapMetadata = iapMetadata;
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
try {
|
|
1160
|
+
// Make the call -
|
|
1161
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1162
|
+
return this.requestHandlerInst.identifyRequest('Persistency', 'getDescendantMOLites', reqObj, true, (irReturnData, irReturnError) => {
|
|
1163
|
+
// if we received an error or their is no response on the results
|
|
1164
|
+
// return an error
|
|
1165
|
+
if (irReturnError) {
|
|
1166
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1167
|
+
return callback(null, irReturnError);
|
|
1168
|
+
}
|
|
1169
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1170
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDescendantMOLites'], null, null, null);
|
|
1171
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1172
|
+
return callback(null, errorObj);
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1176
|
+
// return the response
|
|
1177
|
+
return callback(irReturnData, null);
|
|
1178
|
+
});
|
|
1179
|
+
} catch (ex) {
|
|
1180
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1181
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1182
|
+
return callback(null, errorObj);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
/**
|
|
1187
|
+
* @function getManagedObjects
|
|
1188
|
+
* @pronghornType method
|
|
1189
|
+
* @name getManagedObjects
|
|
1190
|
+
* @summary Retrieve Managed Objects parameters
|
|
1191
|
+
*
|
|
1192
|
+
* @param {object} body - body param
|
|
1193
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
1194
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1195
|
+
* @return {object} results - An object containing the response of the action
|
|
1196
|
+
*
|
|
1197
|
+
* @route {POST} /getManagedObjects
|
|
1198
|
+
* @roles admin
|
|
1199
|
+
* @task true
|
|
1200
|
+
*/
|
|
1201
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1202
|
+
getManagedObjects(body, iapMetadata, callback) {
|
|
1203
|
+
const meth = 'adapter-getManagedObjects';
|
|
1204
|
+
const origin = `${this.id}-${meth}`;
|
|
1205
|
+
log.trace(origin);
|
|
1206
|
+
|
|
1207
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1208
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1209
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1210
|
+
return callback(null, errorObj);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1214
|
+
if (body === undefined || body === null || body === '') {
|
|
1215
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], 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 = [];
|
|
1224
|
+
const bodyVars = body;
|
|
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
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1235
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1236
|
+
const reqObj = {
|
|
1237
|
+
payload: bodyVars,
|
|
1238
|
+
uriPathVars: pathVars,
|
|
1239
|
+
uriQuery: queryParams
|
|
1240
|
+
};
|
|
1241
|
+
|
|
1242
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
1243
|
+
|
|
1244
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
1245
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
1246
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
1247
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
1248
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
1249
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
1250
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
1251
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
1252
|
+
} else {
|
|
1253
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
1254
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
});
|
|
1258
|
+
// Add iapMetadata to reqObj for further work
|
|
1259
|
+
reqObj.iapMetadata = iapMetadata;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
try {
|
|
1263
|
+
// Make the call -
|
|
1264
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1265
|
+
return this.requestHandlerInst.identifyRequest('Persistency', 'getManagedObjects', reqObj, true, (irReturnData, irReturnError) => {
|
|
1266
|
+
// if we received an error or their is no response on the results
|
|
1267
|
+
// return an error
|
|
1268
|
+
if (irReturnError) {
|
|
1269
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1270
|
+
return callback(null, irReturnError);
|
|
1271
|
+
}
|
|
1272
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1273
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getManagedObjects'], null, null, null);
|
|
1274
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1275
|
+
return callback(null, errorObj);
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1279
|
+
// return the response
|
|
1280
|
+
return callback(irReturnData, null);
|
|
1281
|
+
});
|
|
1282
|
+
} catch (ex) {
|
|
1283
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1284
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1285
|
+
return callback(null, errorObj);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
/**
|
|
1290
|
+
* @function updateManagedObjects
|
|
1291
|
+
* @pronghornType method
|
|
1292
|
+
* @name updateManagedObjects
|
|
1293
|
+
* @summary Update Managed Objects in plan configuration
|
|
1294
|
+
*
|
|
1295
|
+
* @param {object} body - body param
|
|
1296
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
1297
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1298
|
+
* @return {object} results - An object containing the response of the action
|
|
1299
|
+
*
|
|
1300
|
+
* @route {POST} /updateManagedObjects
|
|
1301
|
+
* @roles admin
|
|
1302
|
+
* @task true
|
|
1303
|
+
*/
|
|
1304
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1305
|
+
updateManagedObjects(body, iapMetadata, callback) {
|
|
1306
|
+
const meth = 'adapter-updateManagedObjects';
|
|
1307
|
+
const origin = `${this.id}-${meth}`;
|
|
1308
|
+
log.trace(origin);
|
|
1309
|
+
|
|
1310
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1311
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1312
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1313
|
+
return callback(null, errorObj);
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1317
|
+
if (body === undefined || body === null || body === '') {
|
|
1318
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
1319
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1320
|
+
return callback(null, errorObj);
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1324
|
+
const queryParamsAvailable = {};
|
|
1325
|
+
const queryParams = {};
|
|
1326
|
+
const pathVars = [];
|
|
1327
|
+
const bodyVars = body;
|
|
1328
|
+
|
|
1329
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1330
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1331
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1332
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1333
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1334
|
+
}
|
|
1335
|
+
});
|
|
1336
|
+
|
|
1337
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1338
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1339
|
+
const reqObj = {
|
|
1340
|
+
payload: bodyVars,
|
|
1341
|
+
uriPathVars: pathVars,
|
|
1342
|
+
uriQuery: queryParams
|
|
1343
|
+
};
|
|
1344
|
+
|
|
1345
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
1346
|
+
|
|
1347
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
1348
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
1349
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
1350
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
1351
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
1352
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
1353
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
1354
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
1355
|
+
} else {
|
|
1356
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
1357
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1361
|
+
// Add iapMetadata to reqObj for further work
|
|
1362
|
+
reqObj.iapMetadata = iapMetadata;
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
try {
|
|
1366
|
+
// Make the call -
|
|
1367
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1368
|
+
return this.requestHandlerInst.identifyRequest('Persistency', 'updateManagedObjects', reqObj, false, (irReturnData, irReturnError) => {
|
|
1369
|
+
// if we received an error or their is no response on the results
|
|
1370
|
+
// return an error
|
|
1371
|
+
if (irReturnError) {
|
|
1372
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1373
|
+
return callback(null, irReturnError);
|
|
1374
|
+
}
|
|
1375
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1376
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['updateManagedObjects'], null, null, null);
|
|
1377
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1378
|
+
return callback(null, errorObj);
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1382
|
+
// return the response
|
|
1383
|
+
return callback(irReturnData, null);
|
|
1384
|
+
});
|
|
1385
|
+
} catch (ex) {
|
|
1386
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1387
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1388
|
+
return callback(null, errorObj);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
/**
|
|
1393
|
+
* @function addManagedObjects
|
|
1394
|
+
* @pronghornType method
|
|
1395
|
+
* @name addManagedObjects
|
|
1396
|
+
* @summary Add Managed Objects to plan configuration
|
|
1397
|
+
*
|
|
1398
|
+
* @param {object} body - body param
|
|
1399
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
1400
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1401
|
+
* @return {object} results - An object containing the response of the action
|
|
1402
|
+
*
|
|
1403
|
+
* @route {POST} /addManagedObjects
|
|
1404
|
+
* @roles admin
|
|
1405
|
+
* @task true
|
|
1406
|
+
*/
|
|
1407
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1408
|
+
addManagedObjects(body, iapMetadata, callback) {
|
|
1409
|
+
const meth = 'adapter-addManagedObjects';
|
|
1410
|
+
const origin = `${this.id}-${meth}`;
|
|
1411
|
+
log.trace(origin);
|
|
1412
|
+
|
|
1413
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1414
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1415
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1416
|
+
return callback(null, errorObj);
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1420
|
+
if (body === undefined || body === null || body === '') {
|
|
1421
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
1422
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1423
|
+
return callback(null, errorObj);
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1427
|
+
const queryParamsAvailable = {};
|
|
1428
|
+
const queryParams = {};
|
|
1429
|
+
const pathVars = [];
|
|
1430
|
+
const bodyVars = body;
|
|
1431
|
+
|
|
1432
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1433
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1434
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1435
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1436
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1437
|
+
}
|
|
1438
|
+
});
|
|
1439
|
+
|
|
1440
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1441
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1442
|
+
const reqObj = {
|
|
1443
|
+
payload: bodyVars,
|
|
1444
|
+
uriPathVars: pathVars,
|
|
1445
|
+
uriQuery: queryParams
|
|
1446
|
+
};
|
|
1447
|
+
|
|
1448
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
1449
|
+
|
|
1450
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
1451
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
1452
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
1453
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
1454
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
1455
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
1456
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
1457
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
1458
|
+
} else {
|
|
1459
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
1460
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
});
|
|
1464
|
+
// Add iapMetadata to reqObj for further work
|
|
1465
|
+
reqObj.iapMetadata = iapMetadata;
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
try {
|
|
1469
|
+
// Make the call -
|
|
1470
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1471
|
+
return this.requestHandlerInst.identifyRequest('Persistency', 'addManagedObjects', reqObj, true, (irReturnData, irReturnError) => {
|
|
1472
|
+
// if we received an error or their is no response on the results
|
|
1473
|
+
// return an error
|
|
1474
|
+
if (irReturnError) {
|
|
1475
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1476
|
+
return callback(null, irReturnError);
|
|
1477
|
+
}
|
|
1478
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1479
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['addManagedObjects'], null, null, null);
|
|
1480
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1481
|
+
return callback(null, errorObj);
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1485
|
+
// return the response
|
|
1486
|
+
return callback(irReturnData, null);
|
|
1487
|
+
});
|
|
1488
|
+
} catch (ex) {
|
|
1489
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1490
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1491
|
+
return callback(null, errorObj);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
/**
|
|
1496
|
+
* @function removeManagedObjects
|
|
1497
|
+
* @pronghornType method
|
|
1498
|
+
* @name removeManagedObjects
|
|
1499
|
+
* @summary Remove Managed Objects from plan configuration
|
|
1500
|
+
*
|
|
1501
|
+
* @param {object} body - body param
|
|
1502
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
1503
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1504
|
+
* @return {object} results - An object containing the response of the action
|
|
1505
|
+
*
|
|
1506
|
+
* @route {POST} /removeManagedObjects
|
|
1507
|
+
* @roles admin
|
|
1508
|
+
* @task true
|
|
1509
|
+
*/
|
|
1510
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1511
|
+
removeManagedObjects(body, iapMetadata, callback) {
|
|
1512
|
+
const meth = 'adapter-removeManagedObjects';
|
|
1513
|
+
const origin = `${this.id}-${meth}`;
|
|
1514
|
+
log.trace(origin);
|
|
1515
|
+
|
|
1516
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1517
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1518
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1519
|
+
return callback(null, errorObj);
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1523
|
+
if (body === undefined || body === null || body === '') {
|
|
1524
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
1525
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1526
|
+
return callback(null, errorObj);
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1530
|
+
const queryParamsAvailable = {};
|
|
1531
|
+
const queryParams = {};
|
|
1532
|
+
const pathVars = [];
|
|
1533
|
+
const bodyVars = body;
|
|
1534
|
+
|
|
1535
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1536
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1537
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1538
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1539
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1540
|
+
}
|
|
1541
|
+
});
|
|
1542
|
+
|
|
1543
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1544
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1545
|
+
const reqObj = {
|
|
1546
|
+
payload: bodyVars,
|
|
1547
|
+
uriPathVars: pathVars,
|
|
1548
|
+
uriQuery: queryParams
|
|
1549
|
+
};
|
|
1550
|
+
|
|
1551
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
1552
|
+
|
|
1553
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
1554
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
1555
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
1556
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
1557
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
1558
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
1559
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
1560
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
1561
|
+
} else {
|
|
1562
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
1563
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
});
|
|
1567
|
+
// Add iapMetadata to reqObj for further work
|
|
1568
|
+
reqObj.iapMetadata = iapMetadata;
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
try {
|
|
1572
|
+
// Make the call -
|
|
1573
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1574
|
+
return this.requestHandlerInst.identifyRequest('Persistency', 'removeManagedObjects', reqObj, false, (irReturnData, irReturnError) => {
|
|
1575
|
+
// if we received an error or their is no response on the results
|
|
1576
|
+
// return an error
|
|
1577
|
+
if (irReturnError) {
|
|
1578
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1579
|
+
return callback(null, irReturnError);
|
|
1580
|
+
}
|
|
1581
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1582
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['removeManagedObjects'], null, null, null);
|
|
1583
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1584
|
+
return callback(null, errorObj);
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1588
|
+
// return the response
|
|
1589
|
+
return callback(irReturnData, null);
|
|
1590
|
+
});
|
|
1591
|
+
} catch (ex) {
|
|
1592
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1593
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1594
|
+
return callback(null, errorObj);
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
/**
|
|
1599
|
+
* @function getMetaAdaptations
|
|
1600
|
+
* @pronghornType method
|
|
1601
|
+
* @name getMetaAdaptations
|
|
1602
|
+
* @summary Retrieve adaptations
|
|
1603
|
+
*
|
|
1604
|
+
* @param {array} [adaptId] - adaptId param
|
|
1605
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
1606
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1607
|
+
* @return {object} results - An object containing the response of the action
|
|
1608
|
+
*
|
|
1609
|
+
* @route {POST} /getMetaAdaptations
|
|
1610
|
+
* @roles admin
|
|
1611
|
+
* @task true
|
|
1612
|
+
*/
|
|
1613
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1614
|
+
getMetaAdaptations(adaptId, iapMetadata, callback) {
|
|
1615
|
+
const meth = 'adapter-getMetaAdaptations';
|
|
1616
|
+
const origin = `${this.id}-${meth}`;
|
|
1617
|
+
log.trace(origin);
|
|
1618
|
+
|
|
1619
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1620
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1621
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1622
|
+
return callback(null, errorObj);
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1626
|
+
|
|
1627
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1628
|
+
const queryParamsAvailable = { adaptId };
|
|
1629
|
+
const queryParams = {};
|
|
1630
|
+
const pathVars = [];
|
|
1631
|
+
const bodyVars = {};
|
|
1632
|
+
|
|
1633
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1634
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1635
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1636
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1637
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1638
|
+
}
|
|
1639
|
+
});
|
|
1640
|
+
|
|
1641
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1642
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1643
|
+
const reqObj = {
|
|
1644
|
+
payload: bodyVars,
|
|
1645
|
+
uriPathVars: pathVars,
|
|
1646
|
+
uriQuery: queryParams
|
|
1647
|
+
};
|
|
1648
|
+
|
|
1649
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
1650
|
+
|
|
1651
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
1652
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
1653
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
1654
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
1655
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
1656
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
1657
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
1658
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
1659
|
+
} else {
|
|
1660
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
1661
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
});
|
|
1665
|
+
// Add iapMetadata to reqObj for further work
|
|
1666
|
+
reqObj.iapMetadata = iapMetadata;
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
try {
|
|
1670
|
+
// Make the call -
|
|
1671
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1672
|
+
return this.requestHandlerInst.identifyRequest('Persistency', 'getMetaAdaptations', reqObj, true, (irReturnData, irReturnError) => {
|
|
1673
|
+
// if we received an error or their is no response on the results
|
|
1674
|
+
// return an error
|
|
1675
|
+
if (irReturnError) {
|
|
1676
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1677
|
+
return callback(null, irReturnError);
|
|
1678
|
+
}
|
|
1679
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1680
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getMetaAdaptations'], null, null, null);
|
|
1681
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1682
|
+
return callback(null, errorObj);
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1686
|
+
// return the response
|
|
1687
|
+
return callback(irReturnData, null);
|
|
1688
|
+
});
|
|
1689
|
+
} catch (ex) {
|
|
1690
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1691
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1692
|
+
return callback(null, errorObj);
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
/**
|
|
1697
|
+
* @function getMetaClasses
|
|
1698
|
+
* @pronghornType method
|
|
1699
|
+
* @name getMetaClasses
|
|
1700
|
+
* @summary Retrieve Managed Objects classes
|
|
1701
|
+
*
|
|
1702
|
+
* @param {array} [adaptId] - adaptId param
|
|
1703
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
1704
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1705
|
+
* @return {object} results - An object containing the response of the action
|
|
1706
|
+
*
|
|
1707
|
+
* @route {POST} /getMetaClasses
|
|
1708
|
+
* @roles admin
|
|
1709
|
+
* @task true
|
|
1710
|
+
*/
|
|
1711
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1712
|
+
getMetaClasses(adaptId, iapMetadata, callback) {
|
|
1713
|
+
const meth = 'adapter-getMetaClasses';
|
|
1714
|
+
const origin = `${this.id}-${meth}`;
|
|
1715
|
+
log.trace(origin);
|
|
1716
|
+
|
|
1717
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1718
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1719
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1720
|
+
return callback(null, errorObj);
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1724
|
+
|
|
1725
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1726
|
+
const queryParamsAvailable = { adaptId };
|
|
1727
|
+
const queryParams = {};
|
|
1728
|
+
const pathVars = [];
|
|
1729
|
+
const bodyVars = {};
|
|
1730
|
+
|
|
1731
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1732
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1733
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1734
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1735
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1736
|
+
}
|
|
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
|
+
};
|
|
1746
|
+
|
|
1747
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
1748
|
+
|
|
1749
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
1750
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
1751
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
1752
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
1753
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
1754
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
1755
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
1756
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
1757
|
+
} else {
|
|
1758
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
1759
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
});
|
|
1763
|
+
// Add iapMetadata to reqObj for further work
|
|
1764
|
+
reqObj.iapMetadata = iapMetadata;
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
try {
|
|
1768
|
+
// Make the call -
|
|
1769
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1770
|
+
return this.requestHandlerInst.identifyRequest('Persistency', 'getMetaClasses', reqObj, true, (irReturnData, irReturnError) => {
|
|
1771
|
+
// if we received an error or their is no response on the results
|
|
1772
|
+
// return an error
|
|
1773
|
+
if (irReturnError) {
|
|
1774
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1775
|
+
return callback(null, irReturnError);
|
|
1776
|
+
}
|
|
1777
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1778
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getMetaClasses'], null, null, null);
|
|
1779
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1780
|
+
return callback(null, errorObj);
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1784
|
+
// return the response
|
|
1785
|
+
return callback(irReturnData, null);
|
|
1786
|
+
});
|
|
1787
|
+
} catch (ex) {
|
|
1788
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1789
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1790
|
+
return callback(null, errorObj);
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
/**
|
|
1795
|
+
* @function getMetaParameters
|
|
1796
|
+
* @pronghornType method
|
|
1797
|
+
* @name getMetaParameters
|
|
1798
|
+
* @summary Retrieve metadata for given Managed Objects classes
|
|
1799
|
+
*
|
|
1800
|
+
* @param {object} body - body param
|
|
1801
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
1802
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1803
|
+
* @return {object} results - An object containing the response of the action
|
|
1804
|
+
*
|
|
1805
|
+
* @route {POST} /getMetaParameters
|
|
1806
|
+
* @roles admin
|
|
1807
|
+
* @task true
|
|
1808
|
+
*/
|
|
1809
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1810
|
+
getMetaParameters(body, iapMetadata, callback) {
|
|
1811
|
+
const meth = 'adapter-getMetaParameters';
|
|
1812
|
+
const origin = `${this.id}-${meth}`;
|
|
1813
|
+
log.trace(origin);
|
|
1814
|
+
|
|
1815
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1816
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1817
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1818
|
+
return callback(null, errorObj);
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1822
|
+
if (body === undefined || body === null || body === '') {
|
|
1823
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
1824
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1825
|
+
return callback(null, errorObj);
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1829
|
+
const queryParamsAvailable = {};
|
|
1830
|
+
const queryParams = {};
|
|
1831
|
+
const pathVars = [];
|
|
1832
|
+
const bodyVars = body;
|
|
1833
|
+
|
|
1834
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1835
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1836
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1837
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1838
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1839
|
+
}
|
|
1840
|
+
});
|
|
1841
|
+
|
|
1842
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1843
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1844
|
+
const reqObj = {
|
|
1845
|
+
payload: bodyVars,
|
|
1846
|
+
uriPathVars: pathVars,
|
|
1847
|
+
uriQuery: queryParams
|
|
1848
|
+
};
|
|
1849
|
+
|
|
1850
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
1851
|
+
|
|
1852
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
1853
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
1854
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
1855
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
1856
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
1857
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
1858
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
1859
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
1860
|
+
} else {
|
|
1861
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
1862
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
});
|
|
1866
|
+
// Add iapMetadata to reqObj for further work
|
|
1867
|
+
reqObj.iapMetadata = iapMetadata;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
try {
|
|
1871
|
+
// Make the call -
|
|
1872
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1873
|
+
return this.requestHandlerInst.identifyRequest('Persistency', 'getMetaParameters', reqObj, true, (irReturnData, irReturnError) => {
|
|
1874
|
+
// if we received an error or their is no response on the results
|
|
1875
|
+
// return an error
|
|
1876
|
+
if (irReturnError) {
|
|
1877
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1878
|
+
return callback(null, irReturnError);
|
|
1879
|
+
}
|
|
1880
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1881
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getMetaParameters'], null, null, null);
|
|
1882
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1883
|
+
return callback(null, errorObj);
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1887
|
+
// return the response
|
|
1888
|
+
return callback(irReturnData, null);
|
|
1889
|
+
});
|
|
1890
|
+
} catch (ex) {
|
|
1891
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1892
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1893
|
+
return callback(null, errorObj);
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
/**
|
|
1898
|
+
* @function getMOLites
|
|
1899
|
+
* @pronghornType method
|
|
1900
|
+
* @name getMOLites
|
|
1901
|
+
* @summary Retrieve Managed Objects by their DNs
|
|
1902
|
+
*
|
|
1903
|
+
* @param {object} body - body param
|
|
1904
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
1905
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
1906
|
+
* @return {object} results - An object containing the response of the action
|
|
1907
|
+
*
|
|
1908
|
+
* @route {POST} /getMOLites
|
|
1909
|
+
* @roles admin
|
|
1910
|
+
* @task true
|
|
1911
|
+
*/
|
|
1912
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
1913
|
+
getMOLites(body, iapMetadata, callback) {
|
|
1914
|
+
const meth = 'adapter-getMOLites';
|
|
1915
|
+
const origin = `${this.id}-${meth}`;
|
|
1916
|
+
log.trace(origin);
|
|
1917
|
+
|
|
1918
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
1919
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
1920
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1921
|
+
return callback(null, errorObj);
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
1925
|
+
if (body === undefined || body === null || body === '') {
|
|
1926
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
1927
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1928
|
+
return callback(null, errorObj);
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
1932
|
+
const queryParamsAvailable = {};
|
|
1933
|
+
const queryParams = {};
|
|
1934
|
+
const pathVars = [];
|
|
1935
|
+
const bodyVars = body;
|
|
1936
|
+
|
|
1937
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
1938
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
1939
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
1940
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
1941
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
1942
|
+
}
|
|
1943
|
+
});
|
|
1944
|
+
|
|
1945
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
1946
|
+
// see adapter code documentation for more information on the request object's fields
|
|
1947
|
+
const reqObj = {
|
|
1948
|
+
payload: bodyVars,
|
|
1949
|
+
uriPathVars: pathVars,
|
|
1950
|
+
uriQuery: queryParams
|
|
1951
|
+
};
|
|
1952
|
+
|
|
1953
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
1954
|
+
|
|
1955
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
1956
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
1957
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
1958
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
1959
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
1960
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
1961
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
1962
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
1963
|
+
} else {
|
|
1964
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
1965
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
});
|
|
1969
|
+
// Add iapMetadata to reqObj for further work
|
|
1970
|
+
reqObj.iapMetadata = iapMetadata;
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
try {
|
|
1974
|
+
// Make the call -
|
|
1975
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
1976
|
+
return this.requestHandlerInst.identifyRequest('Persistency', 'getMOLites', reqObj, true, (irReturnData, irReturnError) => {
|
|
1977
|
+
// if we received an error or their is no response on the results
|
|
1978
|
+
// return an error
|
|
1979
|
+
if (irReturnError) {
|
|
1980
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
1981
|
+
return callback(null, irReturnError);
|
|
1982
|
+
}
|
|
1983
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
1984
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getMOLites'], null, null, null);
|
|
1985
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1986
|
+
return callback(null, errorObj);
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
1990
|
+
// return the response
|
|
1991
|
+
return callback(irReturnData, null);
|
|
1992
|
+
});
|
|
1993
|
+
} catch (ex) {
|
|
1994
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
1995
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1996
|
+
return callback(null, errorObj);
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
/**
|
|
2001
|
+
* @function query
|
|
2002
|
+
* @pronghornType method
|
|
2003
|
+
* @name query
|
|
2004
|
+
* @summary Retrieve expression values associated with given query
|
|
2005
|
+
*
|
|
2006
|
+
* @param {object} body - body param
|
|
2007
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
2008
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2009
|
+
* @return {object} results - An object containing the response of the action
|
|
2010
|
+
*
|
|
2011
|
+
* @route {POST} /query
|
|
2012
|
+
* @roles admin
|
|
2013
|
+
* @task true
|
|
2014
|
+
*/
|
|
2015
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2016
|
+
query(body, iapMetadata, callback) {
|
|
2017
|
+
const meth = 'adapter-query';
|
|
2018
|
+
const origin = `${this.id}-${meth}`;
|
|
2019
|
+
log.trace(origin);
|
|
2020
|
+
|
|
2021
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2022
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2023
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2024
|
+
return callback(null, errorObj);
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2028
|
+
if (body === undefined || body === null || body === '') {
|
|
2029
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
2030
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2031
|
+
return callback(null, errorObj);
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2035
|
+
const queryParamsAvailable = {};
|
|
2036
|
+
const queryParams = {};
|
|
2037
|
+
const pathVars = [];
|
|
2038
|
+
const bodyVars = body;
|
|
2039
|
+
|
|
2040
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2041
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2042
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2043
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2044
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2045
|
+
}
|
|
2046
|
+
});
|
|
2047
|
+
|
|
2048
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2049
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2050
|
+
const reqObj = {
|
|
2051
|
+
payload: bodyVars,
|
|
2052
|
+
uriPathVars: pathVars,
|
|
2053
|
+
uriQuery: queryParams
|
|
2054
|
+
};
|
|
2055
|
+
|
|
2056
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
2057
|
+
|
|
2058
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
2059
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
2060
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
2061
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
2062
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
2063
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
2064
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
2065
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
2066
|
+
} else {
|
|
2067
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
2068
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
});
|
|
2072
|
+
// Add iapMetadata to reqObj for further work
|
|
2073
|
+
reqObj.iapMetadata = iapMetadata;
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
try {
|
|
2077
|
+
// Make the call -
|
|
2078
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2079
|
+
return this.requestHandlerInst.identifyRequest('Persistency', 'query', reqObj, true, (irReturnData, irReturnError) => {
|
|
2080
|
+
// if we received an error or their is no response on the results
|
|
2081
|
+
// return an error
|
|
2082
|
+
if (irReturnError) {
|
|
2083
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2084
|
+
return callback(null, irReturnError);
|
|
2085
|
+
}
|
|
2086
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2087
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['query'], null, null, null);
|
|
2088
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2089
|
+
return callback(null, errorObj);
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2093
|
+
// return the response
|
|
2094
|
+
return callback(irReturnData, null);
|
|
2095
|
+
});
|
|
2096
|
+
} catch (ex) {
|
|
2097
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2098
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2099
|
+
return callback(null, errorObj);
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
|
|
2103
|
+
/**
|
|
2104
|
+
* @function queryMOLites
|
|
2105
|
+
* @pronghornType method
|
|
2106
|
+
* @name queryMOLites
|
|
2107
|
+
* @summary Retrieve Managed Objects for given search criteria
|
|
2108
|
+
*
|
|
2109
|
+
* @param {object} body - body param
|
|
2110
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
2111
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2112
|
+
* @return {object} results - An object containing the response of the action
|
|
2113
|
+
*
|
|
2114
|
+
* @route {POST} /queryMOLites
|
|
2115
|
+
* @roles admin
|
|
2116
|
+
* @task true
|
|
2117
|
+
*/
|
|
2118
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2119
|
+
queryMOLites(body, iapMetadata, callback) {
|
|
2120
|
+
const meth = 'adapter-queryMOLites';
|
|
2121
|
+
const origin = `${this.id}-${meth}`;
|
|
2122
|
+
log.trace(origin);
|
|
2123
|
+
|
|
2124
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2125
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2126
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2127
|
+
return callback(null, errorObj);
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2131
|
+
if (body === undefined || body === null || body === '') {
|
|
2132
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
2133
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2134
|
+
return callback(null, errorObj);
|
|
2135
|
+
}
|
|
2136
|
+
|
|
2137
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2138
|
+
const queryParamsAvailable = {};
|
|
2139
|
+
const queryParams = {};
|
|
2140
|
+
const pathVars = [];
|
|
2141
|
+
const bodyVars = body;
|
|
2142
|
+
|
|
2143
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2144
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2145
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2146
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2147
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2148
|
+
}
|
|
2149
|
+
});
|
|
2150
|
+
|
|
2151
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2152
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2153
|
+
const reqObj = {
|
|
2154
|
+
payload: bodyVars,
|
|
2155
|
+
uriPathVars: pathVars,
|
|
2156
|
+
uriQuery: queryParams
|
|
2157
|
+
};
|
|
2158
|
+
|
|
2159
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
2160
|
+
|
|
2161
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
2162
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
2163
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
2164
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
2165
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
2166
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
2167
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
2168
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
2169
|
+
} else {
|
|
2170
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
2171
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
});
|
|
2175
|
+
// Add iapMetadata to reqObj for further work
|
|
2176
|
+
reqObj.iapMetadata = iapMetadata;
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
try {
|
|
2180
|
+
// Make the call -
|
|
2181
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2182
|
+
return this.requestHandlerInst.identifyRequest('Persistency', 'queryMOLites', reqObj, true, (irReturnData, irReturnError) => {
|
|
2183
|
+
// if we received an error or their is no response on the results
|
|
2184
|
+
// return an error
|
|
2185
|
+
if (irReturnError) {
|
|
2186
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2187
|
+
return callback(null, irReturnError);
|
|
2188
|
+
}
|
|
2189
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2190
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['queryMOLites'], null, null, null);
|
|
2191
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2192
|
+
return callback(null, errorObj);
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2196
|
+
// return the response
|
|
2197
|
+
return callback(irReturnData, null);
|
|
2198
|
+
});
|
|
2199
|
+
} catch (ex) {
|
|
2200
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2201
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2202
|
+
return callback(null, errorObj);
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
/**
|
|
2207
|
+
* @function getRelatedMOLites
|
|
2208
|
+
* @pronghornType method
|
|
2209
|
+
* @name getRelatedMOLites
|
|
2210
|
+
* @summary Retrieve related Managed Objects
|
|
2211
|
+
*
|
|
2212
|
+
* @param {object} body - body param
|
|
2213
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
2214
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2215
|
+
* @return {object} results - An object containing the response of the action
|
|
2216
|
+
*
|
|
2217
|
+
* @route {POST} /getRelatedMOLites
|
|
2218
|
+
* @roles admin
|
|
2219
|
+
* @task true
|
|
2220
|
+
*/
|
|
2221
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2222
|
+
getRelatedMOLites(body, iapMetadata, callback) {
|
|
2223
|
+
const meth = 'adapter-getRelatedMOLites';
|
|
2224
|
+
const origin = `${this.id}-${meth}`;
|
|
2225
|
+
log.trace(origin);
|
|
2226
|
+
|
|
2227
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2228
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2229
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2230
|
+
return callback(null, errorObj);
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2234
|
+
if (body === undefined || body === null || body === '') {
|
|
2235
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
2236
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2237
|
+
return callback(null, errorObj);
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2241
|
+
const queryParamsAvailable = {};
|
|
2242
|
+
const queryParams = {};
|
|
2243
|
+
const pathVars = [];
|
|
2244
|
+
const bodyVars = body;
|
|
2245
|
+
|
|
2246
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2247
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2248
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2249
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2250
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2251
|
+
}
|
|
2252
|
+
});
|
|
2253
|
+
|
|
2254
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2255
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2256
|
+
const reqObj = {
|
|
2257
|
+
payload: bodyVars,
|
|
2258
|
+
uriPathVars: pathVars,
|
|
2259
|
+
uriQuery: queryParams
|
|
2260
|
+
};
|
|
2261
|
+
|
|
2262
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
2263
|
+
|
|
2264
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
2265
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
2266
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
2267
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
2268
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
2269
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
2270
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
2271
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
2272
|
+
} else {
|
|
2273
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
2274
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
2275
|
+
}
|
|
2276
|
+
}
|
|
2277
|
+
});
|
|
2278
|
+
// Add iapMetadata to reqObj for further work
|
|
2279
|
+
reqObj.iapMetadata = iapMetadata;
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
try {
|
|
2283
|
+
// Make the call -
|
|
2284
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2285
|
+
return this.requestHandlerInst.identifyRequest('Persistency', 'getRelatedMOLites', reqObj, true, (irReturnData, irReturnError) => {
|
|
2286
|
+
// if we received an error or their is no response on the results
|
|
2287
|
+
// return an error
|
|
2288
|
+
if (irReturnError) {
|
|
2289
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2290
|
+
return callback(null, irReturnError);
|
|
2291
|
+
}
|
|
2292
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2293
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getRelatedMOLites'], null, null, null);
|
|
2294
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2295
|
+
return callback(null, errorObj);
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2299
|
+
// return the response
|
|
2300
|
+
return callback(irReturnData, null);
|
|
2301
|
+
});
|
|
2302
|
+
} catch (ex) {
|
|
2303
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2304
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2305
|
+
return callback(null, errorObj);
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
/**
|
|
2310
|
+
* @function getRootMOLites
|
|
2311
|
+
* @pronghornType method
|
|
2312
|
+
* @name getRootMOLites
|
|
2313
|
+
* @summary Retrieve root Managed Objects
|
|
2314
|
+
*
|
|
2315
|
+
* @param {string} [confId] - confId param
|
|
2316
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
2317
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2318
|
+
* @return {object} results - An object containing the response of the action
|
|
2319
|
+
*
|
|
2320
|
+
* @route {POST} /getRootMOLites
|
|
2321
|
+
* @roles admin
|
|
2322
|
+
* @task true
|
|
2323
|
+
*/
|
|
2324
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2325
|
+
getRootMOLites(confId, iapMetadata, callback) {
|
|
2326
|
+
const meth = 'adapter-getRootMOLites';
|
|
2327
|
+
const origin = `${this.id}-${meth}`;
|
|
2328
|
+
log.trace(origin);
|
|
2329
|
+
|
|
2330
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2331
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2332
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2333
|
+
return callback(null, errorObj);
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2337
|
+
|
|
2338
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2339
|
+
const queryParamsAvailable = { confId };
|
|
2340
|
+
const queryParams = {};
|
|
2341
|
+
const pathVars = [];
|
|
2342
|
+
const bodyVars = {};
|
|
2343
|
+
|
|
2344
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2345
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2346
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2347
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2348
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2349
|
+
}
|
|
2350
|
+
});
|
|
2351
|
+
|
|
2352
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2353
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2354
|
+
const reqObj = {
|
|
2355
|
+
payload: bodyVars,
|
|
2356
|
+
uriPathVars: pathVars,
|
|
2357
|
+
uriQuery: queryParams
|
|
2358
|
+
};
|
|
2359
|
+
|
|
2360
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
2361
|
+
|
|
2362
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
2363
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
2364
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
2365
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
2366
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
2367
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
2368
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
2369
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
2370
|
+
} else {
|
|
2371
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
2372
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
});
|
|
2376
|
+
// Add iapMetadata to reqObj for further work
|
|
2377
|
+
reqObj.iapMetadata = iapMetadata;
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2380
|
+
try {
|
|
2381
|
+
// Make the call -
|
|
2382
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2383
|
+
return this.requestHandlerInst.identifyRequest('Persistency', 'getRootMOLites', reqObj, true, (irReturnData, irReturnError) => {
|
|
2384
|
+
// if we received an error or their is no response on the results
|
|
2385
|
+
// return an error
|
|
2386
|
+
if (irReturnError) {
|
|
2387
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2388
|
+
return callback(null, irReturnError);
|
|
2389
|
+
}
|
|
2390
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2391
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getRootMOLites'], null, null, null);
|
|
2392
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2393
|
+
return callback(null, errorObj);
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2397
|
+
// return the response
|
|
2398
|
+
return callback(irReturnData, null);
|
|
2399
|
+
});
|
|
2400
|
+
} catch (ex) {
|
|
2401
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2402
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2403
|
+
return callback(null, errorObj);
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
|
|
2407
|
+
/**
|
|
2408
|
+
* @function readOperationAttributes
|
|
2409
|
+
* @pronghornType method
|
|
2410
|
+
* @name readOperationAttributes
|
|
2411
|
+
* @summary Retrieve operations attributes
|
|
2412
|
+
*
|
|
2413
|
+
* @param {string} [operationIds] - operationIds param
|
|
2414
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
2415
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2416
|
+
* @return {object} results - An object containing the response of the action
|
|
2417
|
+
*
|
|
2418
|
+
* @route {POST} /readOperationAttributes
|
|
2419
|
+
* @roles admin
|
|
2420
|
+
* @task true
|
|
2421
|
+
*/
|
|
2422
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2423
|
+
readOperationAttributes(operationIds, iapMetadata, callback) {
|
|
2424
|
+
const meth = 'adapter-readOperationAttributes';
|
|
2425
|
+
const origin = `${this.id}-${meth}`;
|
|
2426
|
+
log.trace(origin);
|
|
2427
|
+
|
|
2428
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2429
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2430
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2431
|
+
return callback(null, errorObj);
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2435
|
+
|
|
2436
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2437
|
+
const queryParamsAvailable = { operationIds };
|
|
2438
|
+
const queryParams = {};
|
|
2439
|
+
const pathVars = [];
|
|
2440
|
+
const bodyVars = {};
|
|
2441
|
+
|
|
2442
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2443
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2444
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2445
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2446
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2447
|
+
}
|
|
2448
|
+
});
|
|
2449
|
+
|
|
2450
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2451
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2452
|
+
const reqObj = {
|
|
2453
|
+
payload: bodyVars,
|
|
2454
|
+
uriPathVars: pathVars,
|
|
2455
|
+
uriQuery: queryParams
|
|
2456
|
+
};
|
|
2457
|
+
|
|
2458
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
2459
|
+
|
|
2460
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
2461
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
2462
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
2463
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
2464
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
2465
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
2466
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
2467
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
2468
|
+
} else {
|
|
2469
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
2470
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
2471
|
+
}
|
|
2472
|
+
}
|
|
2473
|
+
});
|
|
2474
|
+
// Add iapMetadata to reqObj for further work
|
|
2475
|
+
reqObj.iapMetadata = iapMetadata;
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
try {
|
|
2479
|
+
// Make the call -
|
|
2480
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2481
|
+
return this.requestHandlerInst.identifyRequest('Operations', 'readOperationAttributes', reqObj, true, (irReturnData, irReturnError) => {
|
|
2482
|
+
// if we received an error or their is no response on the results
|
|
2483
|
+
// return an error
|
|
2484
|
+
if (irReturnError) {
|
|
2485
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2486
|
+
return callback(null, irReturnError);
|
|
2487
|
+
}
|
|
2488
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2489
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['readOperationAttributes'], null, null, null);
|
|
2490
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2491
|
+
return callback(null, errorObj);
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2494
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2495
|
+
// return the response
|
|
2496
|
+
return callback(irReturnData, null);
|
|
2497
|
+
});
|
|
2498
|
+
} catch (ex) {
|
|
2499
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2500
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2501
|
+
return callback(null, errorObj);
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
/**
|
|
2506
|
+
* @function readOperationDefinitions
|
|
2507
|
+
* @pronghornType method
|
|
2508
|
+
* @name readOperationDefinitions
|
|
2509
|
+
* @summary Retrieve workflow operation definitions
|
|
2510
|
+
*
|
|
2511
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
2512
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2513
|
+
* @return {object} results - An object containing the response of the action
|
|
2514
|
+
*
|
|
2515
|
+
* @route {GET} /readOperationDefinitions
|
|
2516
|
+
* @roles admin
|
|
2517
|
+
* @task true
|
|
2518
|
+
*/
|
|
2519
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2520
|
+
readOperationDefinitions(iapMetadata, callback) {
|
|
2521
|
+
const meth = 'adapter-readOperationDefinitions';
|
|
2522
|
+
const origin = `${this.id}-${meth}`;
|
|
2523
|
+
log.trace(origin);
|
|
2524
|
+
|
|
2525
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2526
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2527
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2528
|
+
return callback(null, errorObj);
|
|
2529
|
+
}
|
|
2530
|
+
|
|
2531
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2532
|
+
|
|
2533
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2534
|
+
const queryParamsAvailable = {};
|
|
2535
|
+
const queryParams = {};
|
|
2536
|
+
const pathVars = [];
|
|
2537
|
+
const bodyVars = {};
|
|
2538
|
+
|
|
2539
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2540
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2541
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2542
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2543
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2544
|
+
}
|
|
2545
|
+
});
|
|
2546
|
+
|
|
2547
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2548
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2549
|
+
const reqObj = {
|
|
2550
|
+
payload: bodyVars,
|
|
2551
|
+
uriPathVars: pathVars,
|
|
2552
|
+
uriQuery: queryParams
|
|
2553
|
+
};
|
|
2554
|
+
|
|
2555
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
2556
|
+
|
|
2557
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
2558
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
2559
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
2560
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
2561
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
2562
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
2563
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
2564
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
2565
|
+
} else {
|
|
2566
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
2567
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
});
|
|
2571
|
+
// Add iapMetadata to reqObj for further work
|
|
2572
|
+
reqObj.iapMetadata = iapMetadata;
|
|
2573
|
+
}
|
|
2574
|
+
|
|
2575
|
+
try {
|
|
2576
|
+
// Make the call -
|
|
2577
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2578
|
+
return this.requestHandlerInst.identifyRequest('Operations', 'readOperationDefinitions', reqObj, true, (irReturnData, irReturnError) => {
|
|
2579
|
+
// if we received an error or their is no response on the results
|
|
2580
|
+
// return an error
|
|
2581
|
+
if (irReturnError) {
|
|
2582
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2583
|
+
return callback(null, irReturnError);
|
|
2584
|
+
}
|
|
2585
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2586
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['readOperationDefinitions'], null, null, null);
|
|
2587
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2588
|
+
return callback(null, errorObj);
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2592
|
+
// return the response
|
|
2593
|
+
return callback(irReturnData, null);
|
|
2594
|
+
});
|
|
2595
|
+
} catch (ex) {
|
|
2596
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2597
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2598
|
+
return callback(null, errorObj);
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
|
|
2602
|
+
/**
|
|
2603
|
+
* @function readOperationExecutions
|
|
2604
|
+
* @pronghornType method
|
|
2605
|
+
* @name readOperationExecutions
|
|
2606
|
+
* @summary Retrieve operation executions
|
|
2607
|
+
*
|
|
2608
|
+
* @param {string} [before] - before param
|
|
2609
|
+
* @param {string} [after] - after param
|
|
2610
|
+
* @param {string} [operationNames] - operationNames param
|
|
2611
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
2612
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2613
|
+
* @return {object} results - An object containing the response of the action
|
|
2614
|
+
*
|
|
2615
|
+
* @route {POST} /readOperationExecutions
|
|
2616
|
+
* @roles admin
|
|
2617
|
+
* @task true
|
|
2618
|
+
*/
|
|
2619
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2620
|
+
readOperationExecutions(before, after, operationNames, iapMetadata, callback) {
|
|
2621
|
+
const meth = 'adapter-readOperationExecutions';
|
|
2622
|
+
const origin = `${this.id}-${meth}`;
|
|
2623
|
+
log.trace(origin);
|
|
2624
|
+
|
|
2625
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2626
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2627
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2628
|
+
return callback(null, errorObj);
|
|
2629
|
+
}
|
|
2630
|
+
|
|
2631
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2632
|
+
|
|
2633
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2634
|
+
const queryParamsAvailable = { before, after, operationNames };
|
|
2635
|
+
const queryParams = {};
|
|
2636
|
+
const pathVars = [];
|
|
2637
|
+
const bodyVars = {};
|
|
2638
|
+
|
|
2639
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2640
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2641
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2642
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2643
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2644
|
+
}
|
|
2645
|
+
});
|
|
2646
|
+
|
|
2647
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2648
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2649
|
+
const reqObj = {
|
|
2650
|
+
payload: bodyVars,
|
|
2651
|
+
uriPathVars: pathVars,
|
|
2652
|
+
uriQuery: queryParams
|
|
2653
|
+
};
|
|
2654
|
+
|
|
2655
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
2656
|
+
|
|
2657
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
2658
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
2659
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
2660
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
2661
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
2662
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
2663
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
2664
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
2665
|
+
} else {
|
|
2666
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
2667
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
});
|
|
2671
|
+
// Add iapMetadata to reqObj for further work
|
|
2672
|
+
reqObj.iapMetadata = iapMetadata;
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
try {
|
|
2676
|
+
// Make the call -
|
|
2677
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2678
|
+
return this.requestHandlerInst.identifyRequest('Operations', 'readOperationExecutions', reqObj, true, (irReturnData, irReturnError) => {
|
|
2679
|
+
// if we received an error or their is no response on the results
|
|
2680
|
+
// return an error
|
|
2681
|
+
if (irReturnError) {
|
|
2682
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2683
|
+
return callback(null, irReturnError);
|
|
2684
|
+
}
|
|
2685
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2686
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['readOperationExecutions'], null, null, null);
|
|
2687
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2688
|
+
return callback(null, errorObj);
|
|
2689
|
+
}
|
|
2690
|
+
|
|
2691
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2692
|
+
// return the response
|
|
2693
|
+
return callback(irReturnData, null);
|
|
2694
|
+
});
|
|
2695
|
+
} catch (ex) {
|
|
2696
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2697
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2698
|
+
return callback(null, errorObj);
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
|
|
2702
|
+
/**
|
|
2703
|
+
* @function readOperationFeedbacks
|
|
2704
|
+
* @pronghornType method
|
|
2705
|
+
* @name readOperationFeedbacks
|
|
2706
|
+
* @summary Retrieve operation feedbacks
|
|
2707
|
+
*
|
|
2708
|
+
* @param {string} [operationIds] - operationIds param
|
|
2709
|
+
* @param {string} [after] - after param
|
|
2710
|
+
* @param {string} [limit] - limit param
|
|
2711
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
2712
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2713
|
+
* @return {object} results - An object containing the response of the action
|
|
2714
|
+
*
|
|
2715
|
+
* @route {POST} /readOperationFeedbacks
|
|
2716
|
+
* @roles admin
|
|
2717
|
+
* @task true
|
|
2718
|
+
*/
|
|
2719
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2720
|
+
readOperationFeedbacks(operationIds, after, limit, iapMetadata, callback) {
|
|
2721
|
+
const meth = 'adapter-readOperationFeedbacks';
|
|
2722
|
+
const origin = `${this.id}-${meth}`;
|
|
2723
|
+
log.trace(origin);
|
|
2724
|
+
|
|
2725
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2726
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2727
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2728
|
+
return callback(null, errorObj);
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2732
|
+
|
|
2733
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2734
|
+
const queryParamsAvailable = { operationIds, after, limit };
|
|
2735
|
+
const queryParams = {};
|
|
2736
|
+
const pathVars = [];
|
|
2737
|
+
const bodyVars = {};
|
|
2738
|
+
|
|
2739
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2740
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2741
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2742
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2743
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2744
|
+
}
|
|
2745
|
+
});
|
|
2746
|
+
|
|
2747
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2748
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2749
|
+
const reqObj = {
|
|
2750
|
+
payload: bodyVars,
|
|
2751
|
+
uriPathVars: pathVars,
|
|
2752
|
+
uriQuery: queryParams
|
|
2753
|
+
};
|
|
2754
|
+
|
|
2755
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
2756
|
+
|
|
2757
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
2758
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
2759
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
2760
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
2761
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
2762
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
2763
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
2764
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
2765
|
+
} else {
|
|
2766
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
2767
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
});
|
|
2771
|
+
// Add iapMetadata to reqObj for further work
|
|
2772
|
+
reqObj.iapMetadata = iapMetadata;
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2775
|
+
try {
|
|
2776
|
+
// Make the call -
|
|
2777
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2778
|
+
return this.requestHandlerInst.identifyRequest('Operations', 'readOperationFeedbacks', reqObj, true, (irReturnData, irReturnError) => {
|
|
2779
|
+
// if we received an error or their is no response on the results
|
|
2780
|
+
// return an error
|
|
2781
|
+
if (irReturnError) {
|
|
2782
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2783
|
+
return callback(null, irReturnError);
|
|
2784
|
+
}
|
|
2785
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2786
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['readOperationFeedbacks'], null, null, null);
|
|
2787
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2788
|
+
return callback(null, errorObj);
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2792
|
+
// return the response
|
|
2793
|
+
return callback(irReturnData, null);
|
|
2794
|
+
});
|
|
2795
|
+
} catch (ex) {
|
|
2796
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2797
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2798
|
+
return callback(null, errorObj);
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
|
|
2802
|
+
/**
|
|
2803
|
+
* @function interruptOperation
|
|
2804
|
+
* @pronghornType method
|
|
2805
|
+
* @name interruptOperation
|
|
2806
|
+
* @summary Interrupt an operation
|
|
2807
|
+
*
|
|
2808
|
+
* @param {object} body - body param
|
|
2809
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
2810
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2811
|
+
* @return {object} results - An object containing the response of the action
|
|
2812
|
+
*
|
|
2813
|
+
* @route {POST} /interruptOperation
|
|
2814
|
+
* @roles admin
|
|
2815
|
+
* @task true
|
|
2816
|
+
*/
|
|
2817
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2818
|
+
interruptOperation(body, iapMetadata, callback) {
|
|
2819
|
+
const meth = 'adapter-interruptOperation';
|
|
2820
|
+
const origin = `${this.id}-${meth}`;
|
|
2821
|
+
log.trace(origin);
|
|
2822
|
+
|
|
2823
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2824
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2825
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2826
|
+
return callback(null, errorObj);
|
|
2827
|
+
}
|
|
2828
|
+
|
|
2829
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2830
|
+
if (body === undefined || body === null || body === '') {
|
|
2831
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
2832
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2833
|
+
return callback(null, errorObj);
|
|
2834
|
+
}
|
|
2835
|
+
|
|
2836
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2837
|
+
const queryParamsAvailable = {};
|
|
2838
|
+
const queryParams = {};
|
|
2839
|
+
const pathVars = [];
|
|
2840
|
+
const bodyVars = body;
|
|
2841
|
+
|
|
2842
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2843
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2844
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2845
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2846
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2847
|
+
}
|
|
2848
|
+
});
|
|
2849
|
+
|
|
2850
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2851
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2852
|
+
const reqObj = {
|
|
2853
|
+
payload: bodyVars,
|
|
2854
|
+
uriPathVars: pathVars,
|
|
2855
|
+
uriQuery: queryParams
|
|
2856
|
+
};
|
|
2857
|
+
|
|
2858
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
2859
|
+
|
|
2860
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
2861
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
2862
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
2863
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
2864
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
2865
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
2866
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
2867
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
2868
|
+
} else {
|
|
2869
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
2870
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
2871
|
+
}
|
|
2872
|
+
}
|
|
2873
|
+
});
|
|
2874
|
+
// Add iapMetadata to reqObj for further work
|
|
2875
|
+
reqObj.iapMetadata = iapMetadata;
|
|
2876
|
+
}
|
|
2877
|
+
|
|
2878
|
+
try {
|
|
2879
|
+
// Make the call -
|
|
2880
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2881
|
+
return this.requestHandlerInst.identifyRequest('Operations', 'interruptOperation', reqObj, false, (irReturnData, irReturnError) => {
|
|
2882
|
+
// if we received an error or their is no response on the results
|
|
2883
|
+
// return an error
|
|
2884
|
+
if (irReturnError) {
|
|
2885
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2886
|
+
return callback(null, irReturnError);
|
|
2887
|
+
}
|
|
2888
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2889
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['interruptOperation'], null, null, null);
|
|
2890
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2891
|
+
return callback(null, errorObj);
|
|
2892
|
+
}
|
|
2893
|
+
|
|
2894
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2895
|
+
// return the response
|
|
2896
|
+
return callback(irReturnData, null);
|
|
2897
|
+
});
|
|
2898
|
+
} catch (ex) {
|
|
2899
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2900
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2901
|
+
return callback(null, errorObj);
|
|
2902
|
+
}
|
|
2903
|
+
}
|
|
2904
|
+
|
|
2905
|
+
/**
|
|
2906
|
+
* @function scheduleOperation
|
|
2907
|
+
* @pronghornType method
|
|
2908
|
+
* @name scheduleOperation
|
|
2909
|
+
* @summary Schedule an operation
|
|
2910
|
+
*
|
|
2911
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
2912
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
2913
|
+
* @return {object} results - An object containing the response of the action
|
|
2914
|
+
*
|
|
2915
|
+
* @route {GET} /scheduleOperation
|
|
2916
|
+
* @roles admin
|
|
2917
|
+
* @task true
|
|
2918
|
+
*/
|
|
2919
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
2920
|
+
scheduleOperation(iapMetadata, callback) {
|
|
2921
|
+
const meth = 'adapter-scheduleOperation';
|
|
2922
|
+
const origin = `${this.id}-${meth}`;
|
|
2923
|
+
log.trace(origin);
|
|
2924
|
+
|
|
2925
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
2926
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
2927
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2928
|
+
return callback(null, errorObj);
|
|
2929
|
+
}
|
|
2930
|
+
|
|
2931
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
2932
|
+
|
|
2933
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
2934
|
+
const queryParamsAvailable = {};
|
|
2935
|
+
const queryParams = {};
|
|
2936
|
+
const pathVars = [];
|
|
2937
|
+
const bodyVars = {};
|
|
2938
|
+
|
|
2939
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
2940
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
2941
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
2942
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
2943
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
2944
|
+
}
|
|
2945
|
+
});
|
|
2946
|
+
|
|
2947
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
2948
|
+
// see adapter code documentation for more information on the request object's fields
|
|
2949
|
+
const reqObj = {
|
|
2950
|
+
payload: bodyVars,
|
|
2951
|
+
uriPathVars: pathVars,
|
|
2952
|
+
uriQuery: queryParams
|
|
2953
|
+
};
|
|
2954
|
+
|
|
2955
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
2956
|
+
|
|
2957
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
2958
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
2959
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
2960
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
2961
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
2962
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
2963
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
2964
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
2965
|
+
} else {
|
|
2966
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
2967
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
});
|
|
2971
|
+
// Add iapMetadata to reqObj for further work
|
|
2972
|
+
reqObj.iapMetadata = iapMetadata;
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2975
|
+
try {
|
|
2976
|
+
// Make the call -
|
|
2977
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
2978
|
+
return this.requestHandlerInst.identifyRequest('Operations', 'scheduleOperation', reqObj, true, (irReturnData, irReturnError) => {
|
|
2979
|
+
// if we received an error or their is no response on the results
|
|
2980
|
+
// return an error
|
|
2981
|
+
if (irReturnError) {
|
|
2982
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
2983
|
+
return callback(null, irReturnError);
|
|
2984
|
+
}
|
|
2985
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
2986
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['scheduleOperation'], null, null, null);
|
|
2987
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2988
|
+
return callback(null, errorObj);
|
|
2989
|
+
}
|
|
2990
|
+
|
|
2991
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
2992
|
+
// return the response
|
|
2993
|
+
return callback(irReturnData, null);
|
|
2994
|
+
});
|
|
2995
|
+
} catch (ex) {
|
|
2996
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
2997
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
2998
|
+
return callback(null, errorObj);
|
|
2999
|
+
}
|
|
3000
|
+
}
|
|
3001
|
+
|
|
3002
|
+
/**
|
|
3003
|
+
* @function startOperation
|
|
3004
|
+
* @pronghornType method
|
|
3005
|
+
* @name startOperation
|
|
3006
|
+
* @summary Start an operation
|
|
3007
|
+
*
|
|
3008
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
3009
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3010
|
+
* @return {object} results - An object containing the response of the action
|
|
3011
|
+
*
|
|
3012
|
+
* @route {GET} /startOperation
|
|
3013
|
+
* @roles admin
|
|
3014
|
+
* @task true
|
|
3015
|
+
*/
|
|
3016
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3017
|
+
startOperation(iapMetadata, callback) {
|
|
3018
|
+
const meth = 'adapter-startOperation';
|
|
3019
|
+
const origin = `${this.id}-${meth}`;
|
|
3020
|
+
log.trace(origin);
|
|
3021
|
+
|
|
3022
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3023
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3024
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3025
|
+
return callback(null, errorObj);
|
|
3026
|
+
}
|
|
3027
|
+
|
|
3028
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3029
|
+
|
|
3030
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3031
|
+
const queryParamsAvailable = {};
|
|
3032
|
+
const queryParams = {};
|
|
3033
|
+
const pathVars = [];
|
|
3034
|
+
const bodyVars = {};
|
|
3035
|
+
|
|
3036
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3037
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3038
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3039
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3040
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3041
|
+
}
|
|
3042
|
+
});
|
|
3043
|
+
|
|
3044
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3045
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3046
|
+
const reqObj = {
|
|
3047
|
+
payload: bodyVars,
|
|
3048
|
+
uriPathVars: pathVars,
|
|
3049
|
+
uriQuery: queryParams
|
|
3050
|
+
};
|
|
3051
|
+
|
|
3052
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
3053
|
+
|
|
3054
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
3055
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
3056
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
3057
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
3058
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
3059
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
3060
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
3061
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
3062
|
+
} else {
|
|
3063
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
3064
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
3065
|
+
}
|
|
3066
|
+
}
|
|
3067
|
+
});
|
|
3068
|
+
// Add iapMetadata to reqObj for further work
|
|
3069
|
+
reqObj.iapMetadata = iapMetadata;
|
|
3070
|
+
}
|
|
3071
|
+
|
|
3072
|
+
try {
|
|
3073
|
+
// Make the call -
|
|
3074
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3075
|
+
return this.requestHandlerInst.identifyRequest('Operations', 'startOperation', reqObj, true, (irReturnData, irReturnError) => {
|
|
3076
|
+
// if we received an error or their is no response on the results
|
|
3077
|
+
// return an error
|
|
3078
|
+
if (irReturnError) {
|
|
3079
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3080
|
+
return callback(null, irReturnError);
|
|
3081
|
+
}
|
|
3082
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3083
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['startOperation'], null, null, null);
|
|
3084
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3085
|
+
return callback(null, errorObj);
|
|
3086
|
+
}
|
|
3087
|
+
|
|
3088
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3089
|
+
// return the response
|
|
3090
|
+
return callback(irReturnData, null);
|
|
3091
|
+
});
|
|
3092
|
+
} catch (ex) {
|
|
3093
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3094
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3095
|
+
return callback(null, errorObj);
|
|
3096
|
+
}
|
|
3097
|
+
}
|
|
3098
|
+
|
|
3099
|
+
/**
|
|
3100
|
+
* @function readOperationStatuses
|
|
3101
|
+
* @pronghornType method
|
|
3102
|
+
* @name readOperationStatuses
|
|
3103
|
+
* @summary Retrieve operation statuses
|
|
3104
|
+
*
|
|
3105
|
+
* @param {string} [operationIds] - operationIds param
|
|
3106
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
3107
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3108
|
+
* @return {object} results - An object containing the response of the action
|
|
3109
|
+
*
|
|
3110
|
+
* @route {POST} /readOperationStatuses
|
|
3111
|
+
* @roles admin
|
|
3112
|
+
* @task true
|
|
3113
|
+
*/
|
|
3114
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3115
|
+
readOperationStatuses(operationIds, iapMetadata, callback) {
|
|
3116
|
+
const meth = 'adapter-readOperationStatuses';
|
|
3117
|
+
const origin = `${this.id}-${meth}`;
|
|
3118
|
+
log.trace(origin);
|
|
3119
|
+
|
|
3120
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3121
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3122
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3123
|
+
return callback(null, errorObj);
|
|
3124
|
+
}
|
|
3125
|
+
|
|
3126
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3127
|
+
|
|
3128
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3129
|
+
const queryParamsAvailable = { operationIds };
|
|
3130
|
+
const queryParams = {};
|
|
3131
|
+
const pathVars = [];
|
|
3132
|
+
const bodyVars = {};
|
|
3133
|
+
|
|
3134
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3135
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3136
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3137
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3138
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3139
|
+
}
|
|
3140
|
+
});
|
|
3141
|
+
|
|
3142
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3143
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3144
|
+
const reqObj = {
|
|
3145
|
+
payload: bodyVars,
|
|
3146
|
+
uriPathVars: pathVars,
|
|
3147
|
+
uriQuery: queryParams
|
|
3148
|
+
};
|
|
3149
|
+
|
|
3150
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
3151
|
+
|
|
3152
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
3153
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
3154
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
3155
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
3156
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
3157
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
3158
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
3159
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
3160
|
+
} else {
|
|
3161
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
3162
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
3163
|
+
}
|
|
3164
|
+
}
|
|
3165
|
+
});
|
|
3166
|
+
// Add iapMetadata to reqObj for further work
|
|
3167
|
+
reqObj.iapMetadata = iapMetadata;
|
|
3168
|
+
}
|
|
3169
|
+
|
|
3170
|
+
try {
|
|
3171
|
+
// Make the call -
|
|
3172
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3173
|
+
return this.requestHandlerInst.identifyRequest('Operations', 'readOperationStatuses', reqObj, true, (irReturnData, irReturnError) => {
|
|
3174
|
+
// if we received an error or their is no response on the results
|
|
3175
|
+
// return an error
|
|
3176
|
+
if (irReturnError) {
|
|
3177
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3178
|
+
return callback(null, irReturnError);
|
|
3179
|
+
}
|
|
3180
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3181
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['readOperationStatuses'], null, null, null);
|
|
3182
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3183
|
+
return callback(null, errorObj);
|
|
3184
|
+
}
|
|
3185
|
+
|
|
3186
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3187
|
+
// return the response
|
|
3188
|
+
return callback(irReturnData, null);
|
|
3189
|
+
});
|
|
3190
|
+
} catch (ex) {
|
|
3191
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3192
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3193
|
+
return callback(null, errorObj);
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
|
|
3197
|
+
/**
|
|
3198
|
+
* @function getOpenCmManagedObjects
|
|
3199
|
+
* @pronghornType method
|
|
3200
|
+
* @name getOpenCmManagedObjects
|
|
3201
|
+
* @summary getManagedObjects
|
|
3202
|
+
*
|
|
3203
|
+
* @param {object} body - body param
|
|
3204
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
3205
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3206
|
+
* @return {object} results - An object containing the response of the action
|
|
3207
|
+
*
|
|
3208
|
+
* @route {POST} /getOpenCmManagedObjects
|
|
3209
|
+
* @roles admin
|
|
3210
|
+
* @task true
|
|
3211
|
+
*/
|
|
3212
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3213
|
+
getOpenCmManagedObjects(body, iapMetadata, callback) {
|
|
3214
|
+
const meth = 'adapter-getOpenCmManagedObjects';
|
|
3215
|
+
const origin = `${this.id}-${meth}`;
|
|
3216
|
+
log.trace(origin);
|
|
3217
|
+
|
|
3218
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3219
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3220
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3221
|
+
return callback(null, errorObj);
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3225
|
+
if (body === undefined || body === null || body === '') {
|
|
3226
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
3227
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3228
|
+
return callback(null, errorObj);
|
|
3229
|
+
}
|
|
3230
|
+
|
|
3231
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3232
|
+
const queryParamsAvailable = {};
|
|
3233
|
+
const queryParams = {};
|
|
3234
|
+
const pathVars = [];
|
|
3235
|
+
const bodyVars = body;
|
|
3236
|
+
|
|
3237
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3238
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3239
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3240
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3241
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3242
|
+
}
|
|
3243
|
+
});
|
|
3244
|
+
|
|
3245
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3246
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3247
|
+
const reqObj = {
|
|
3248
|
+
payload: bodyVars,
|
|
3249
|
+
uriPathVars: pathVars,
|
|
3250
|
+
uriQuery: queryParams
|
|
3251
|
+
};
|
|
3252
|
+
|
|
3253
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
3254
|
+
|
|
3255
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
3256
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
3257
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
3258
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
3259
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
3260
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
3261
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
3262
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
3263
|
+
} else {
|
|
3264
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
3265
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
});
|
|
3269
|
+
// Add iapMetadata to reqObj for further work
|
|
3270
|
+
reqObj.iapMetadata = iapMetadata;
|
|
3271
|
+
}
|
|
3272
|
+
|
|
3273
|
+
try {
|
|
3274
|
+
// Make the call -
|
|
3275
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3276
|
+
return this.requestHandlerInst.identifyRequest('OpenCmPersistencyPortBinding', 'getOpenCmManagedObjects', reqObj, true, (irReturnData, irReturnError) => {
|
|
3277
|
+
// if we received an error or their is no response on the results
|
|
3278
|
+
// return an error
|
|
3279
|
+
if (irReturnError) {
|
|
3280
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3281
|
+
return callback(null, irReturnError);
|
|
3282
|
+
}
|
|
3283
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3284
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getOpenCmManagedObjects'], null, null, null);
|
|
3285
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3286
|
+
return callback(null, errorObj);
|
|
3287
|
+
}
|
|
3288
|
+
|
|
3289
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3290
|
+
// return the response
|
|
3291
|
+
return callback(irReturnData, null);
|
|
3292
|
+
});
|
|
3293
|
+
} catch (ex) {
|
|
3294
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3295
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3296
|
+
return callback(null, errorObj);
|
|
3297
|
+
}
|
|
3298
|
+
}
|
|
3299
|
+
|
|
3300
|
+
/**
|
|
3301
|
+
* @function createManagedObjects
|
|
3302
|
+
* @pronghornType method
|
|
3303
|
+
* @name createManagedObjects
|
|
3304
|
+
* @summary createManagedObjects
|
|
3305
|
+
*
|
|
3306
|
+
* @param {object} body - body param
|
|
3307
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
3308
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3309
|
+
* @return {object} results - An object containing the response of the action
|
|
3310
|
+
*
|
|
3311
|
+
* @route {POST} /createManagedObjects
|
|
3312
|
+
* @roles admin
|
|
3313
|
+
* @task true
|
|
3314
|
+
*/
|
|
3315
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3316
|
+
createManagedObjects(body, iapMetadata, callback) {
|
|
3317
|
+
const meth = 'adapter-createManagedObjects';
|
|
3318
|
+
const origin = `${this.id}-${meth}`;
|
|
3319
|
+
log.trace(origin);
|
|
3320
|
+
|
|
3321
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3322
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3323
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3324
|
+
return callback(null, errorObj);
|
|
3325
|
+
}
|
|
3326
|
+
|
|
3327
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3328
|
+
if (body === undefined || body === null || body === '') {
|
|
3329
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
3330
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3331
|
+
return callback(null, errorObj);
|
|
3332
|
+
}
|
|
3333
|
+
|
|
3334
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3335
|
+
const queryParamsAvailable = {};
|
|
3336
|
+
const queryParams = {};
|
|
3337
|
+
const pathVars = [];
|
|
3338
|
+
const bodyVars = body;
|
|
3339
|
+
|
|
3340
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3341
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3342
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3343
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3344
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3345
|
+
}
|
|
3346
|
+
});
|
|
3347
|
+
|
|
3348
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3349
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3350
|
+
const reqObj = {
|
|
3351
|
+
payload: bodyVars,
|
|
3352
|
+
uriPathVars: pathVars,
|
|
3353
|
+
uriQuery: queryParams
|
|
3354
|
+
};
|
|
3355
|
+
|
|
3356
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
3357
|
+
|
|
3358
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
3359
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
3360
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
3361
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
3362
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
3363
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
3364
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
3365
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
3366
|
+
} else {
|
|
3367
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
3368
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
3369
|
+
}
|
|
3370
|
+
}
|
|
3371
|
+
});
|
|
3372
|
+
// Add iapMetadata to reqObj for further work
|
|
3373
|
+
reqObj.iapMetadata = iapMetadata;
|
|
3374
|
+
}
|
|
3375
|
+
|
|
3376
|
+
try {
|
|
3377
|
+
// Make the call -
|
|
3378
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3379
|
+
return this.requestHandlerInst.identifyRequest('OpenCmPersistencyPortBinding', 'createManagedObjects', reqObj, true, (irReturnData, irReturnError) => {
|
|
3380
|
+
// if we received an error or their is no response on the results
|
|
3381
|
+
// return an error
|
|
3382
|
+
if (irReturnError) {
|
|
3383
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3384
|
+
return callback(null, irReturnError);
|
|
3385
|
+
}
|
|
3386
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3387
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createManagedObjects'], null, null, null);
|
|
3388
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3389
|
+
return callback(null, errorObj);
|
|
3390
|
+
}
|
|
3391
|
+
|
|
3392
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3393
|
+
// return the response
|
|
3394
|
+
return callback(irReturnData, null);
|
|
3395
|
+
});
|
|
3396
|
+
} catch (ex) {
|
|
3397
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3398
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3399
|
+
return callback(null, errorObj);
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
|
|
3403
|
+
/**
|
|
3404
|
+
* @function updateOpenCmManagedObjects
|
|
3405
|
+
* @pronghornType method
|
|
3406
|
+
* @name updateOpenCmManagedObjects
|
|
3407
|
+
* @summary updateManagedObjects
|
|
3408
|
+
*
|
|
3409
|
+
* @param {object} body - body param
|
|
3410
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
3411
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3412
|
+
* @return {object} results - An object containing the response of the action
|
|
3413
|
+
*
|
|
3414
|
+
* @route {POST} /updateOpenCmManagedObjects
|
|
3415
|
+
* @roles admin
|
|
3416
|
+
* @task true
|
|
3417
|
+
*/
|
|
3418
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3419
|
+
updateOpenCmManagedObjects(body, iapMetadata, callback) {
|
|
3420
|
+
const meth = 'adapter-updateOpenCmManagedObjects';
|
|
3421
|
+
const origin = `${this.id}-${meth}`;
|
|
3422
|
+
log.trace(origin);
|
|
3423
|
+
|
|
3424
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3425
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3426
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3427
|
+
return callback(null, errorObj);
|
|
3428
|
+
}
|
|
3429
|
+
|
|
3430
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3431
|
+
if (body === undefined || body === null || body === '') {
|
|
3432
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
3433
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3434
|
+
return callback(null, errorObj);
|
|
3435
|
+
}
|
|
3436
|
+
|
|
3437
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3438
|
+
const queryParamsAvailable = {};
|
|
3439
|
+
const queryParams = {};
|
|
3440
|
+
const pathVars = [];
|
|
3441
|
+
const bodyVars = body;
|
|
3442
|
+
|
|
3443
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3444
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3445
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3446
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3447
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3448
|
+
}
|
|
3449
|
+
});
|
|
3450
|
+
|
|
3451
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3452
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3453
|
+
const reqObj = {
|
|
3454
|
+
payload: bodyVars,
|
|
3455
|
+
uriPathVars: pathVars,
|
|
3456
|
+
uriQuery: queryParams
|
|
3457
|
+
};
|
|
3458
|
+
|
|
3459
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
3460
|
+
|
|
3461
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
3462
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
3463
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
3464
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
3465
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
3466
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
3467
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
3468
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
3469
|
+
} else {
|
|
3470
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
3471
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
3472
|
+
}
|
|
3473
|
+
}
|
|
3474
|
+
});
|
|
3475
|
+
// Add iapMetadata to reqObj for further work
|
|
3476
|
+
reqObj.iapMetadata = iapMetadata;
|
|
3477
|
+
}
|
|
3478
|
+
|
|
3479
|
+
try {
|
|
3480
|
+
// Make the call -
|
|
3481
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3482
|
+
return this.requestHandlerInst.identifyRequest('OpenCmPersistencyPortBinding', 'updateOpenCmManagedObjects', reqObj, true, (irReturnData, irReturnError) => {
|
|
3483
|
+
// if we received an error or their is no response on the results
|
|
3484
|
+
// return an error
|
|
3485
|
+
if (irReturnError) {
|
|
3486
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3487
|
+
return callback(null, irReturnError);
|
|
3488
|
+
}
|
|
3489
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3490
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['updateOpenCmManagedObjects'], null, null, null);
|
|
3491
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3492
|
+
return callback(null, errorObj);
|
|
3493
|
+
}
|
|
3494
|
+
|
|
3495
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3496
|
+
// return the response
|
|
3497
|
+
return callback(irReturnData, null);
|
|
3498
|
+
});
|
|
3499
|
+
} catch (ex) {
|
|
3500
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3501
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3502
|
+
return callback(null, errorObj);
|
|
3503
|
+
}
|
|
3504
|
+
}
|
|
3505
|
+
|
|
3506
|
+
/**
|
|
3507
|
+
* @function deleteManagedObjects
|
|
3508
|
+
* @pronghornType method
|
|
3509
|
+
* @name deleteManagedObjects
|
|
3510
|
+
* @summary deleteManagedObjects
|
|
3511
|
+
*
|
|
3512
|
+
* @param {object} body - body param
|
|
3513
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
3514
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3515
|
+
* @return {object} results - An object containing the response of the action
|
|
3516
|
+
*
|
|
3517
|
+
* @route {POST} /deleteManagedObjects
|
|
3518
|
+
* @roles admin
|
|
3519
|
+
* @task true
|
|
3520
|
+
*/
|
|
3521
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3522
|
+
deleteManagedObjects(body, iapMetadata, callback) {
|
|
3523
|
+
const meth = 'adapter-deleteManagedObjects';
|
|
3524
|
+
const origin = `${this.id}-${meth}`;
|
|
3525
|
+
log.trace(origin);
|
|
3526
|
+
|
|
3527
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3528
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3529
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3530
|
+
return callback(null, errorObj);
|
|
3531
|
+
}
|
|
3532
|
+
|
|
3533
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3534
|
+
if (body === undefined || body === null || body === '') {
|
|
3535
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
3536
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3537
|
+
return callback(null, errorObj);
|
|
3538
|
+
}
|
|
3539
|
+
|
|
3540
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3541
|
+
const queryParamsAvailable = {};
|
|
3542
|
+
const queryParams = {};
|
|
3543
|
+
const pathVars = [];
|
|
3544
|
+
const bodyVars = body;
|
|
3545
|
+
|
|
3546
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3547
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3548
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3549
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3550
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3551
|
+
}
|
|
3552
|
+
});
|
|
3553
|
+
|
|
3554
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3555
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3556
|
+
const reqObj = {
|
|
3557
|
+
payload: bodyVars,
|
|
3558
|
+
uriPathVars: pathVars,
|
|
3559
|
+
uriQuery: queryParams
|
|
3560
|
+
};
|
|
3561
|
+
|
|
3562
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
3563
|
+
|
|
3564
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
3565
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
3566
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
3567
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
3568
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
3569
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
3570
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
3571
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
3572
|
+
} else {
|
|
3573
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
3574
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3577
|
+
});
|
|
3578
|
+
// Add iapMetadata to reqObj for further work
|
|
3579
|
+
reqObj.iapMetadata = iapMetadata;
|
|
3580
|
+
}
|
|
3581
|
+
|
|
3582
|
+
try {
|
|
3583
|
+
// Make the call -
|
|
3584
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3585
|
+
return this.requestHandlerInst.identifyRequest('OpenCmPersistencyPortBinding', 'deleteManagedObjects', reqObj, true, (irReturnData, irReturnError) => {
|
|
3586
|
+
// if we received an error or their is no response on the results
|
|
3587
|
+
// return an error
|
|
3588
|
+
if (irReturnError) {
|
|
3589
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3590
|
+
return callback(null, irReturnError);
|
|
3591
|
+
}
|
|
3592
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3593
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteManagedObjects'], null, null, null);
|
|
3594
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3595
|
+
return callback(null, errorObj);
|
|
3596
|
+
}
|
|
3597
|
+
|
|
3598
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3599
|
+
// return the response
|
|
3600
|
+
return callback(irReturnData, null);
|
|
3601
|
+
});
|
|
3602
|
+
} catch (ex) {
|
|
3603
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3604
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3605
|
+
return callback(null, errorObj);
|
|
3606
|
+
}
|
|
3607
|
+
}
|
|
3608
|
+
|
|
3609
|
+
/**
|
|
3610
|
+
* @function getOpenCmMOLites
|
|
3611
|
+
* @pronghornType method
|
|
3612
|
+
* @name getOpenCmMOLites
|
|
3613
|
+
* @summary getMOLites
|
|
3614
|
+
*
|
|
3615
|
+
* @param {object} body - body param
|
|
3616
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
3617
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3618
|
+
* @return {object} results - An object containing the response of the action
|
|
3619
|
+
*
|
|
3620
|
+
* @route {POST} /getOpenCmMOLites
|
|
3621
|
+
* @roles admin
|
|
3622
|
+
* @task true
|
|
3623
|
+
*/
|
|
3624
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3625
|
+
getOpenCmMOLites(body, iapMetadata, callback) {
|
|
3626
|
+
const meth = 'adapter-getOpenCmMOLites';
|
|
3627
|
+
const origin = `${this.id}-${meth}`;
|
|
3628
|
+
log.trace(origin);
|
|
3629
|
+
|
|
3630
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3631
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3632
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3633
|
+
return callback(null, errorObj);
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3636
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3637
|
+
if (body === undefined || body === null || body === '') {
|
|
3638
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
3639
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3640
|
+
return callback(null, errorObj);
|
|
3641
|
+
}
|
|
3642
|
+
|
|
3643
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3644
|
+
const queryParamsAvailable = {};
|
|
3645
|
+
const queryParams = {};
|
|
3646
|
+
const pathVars = [];
|
|
3647
|
+
const bodyVars = body;
|
|
3648
|
+
|
|
3649
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3650
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3651
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3652
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3653
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3654
|
+
}
|
|
3655
|
+
});
|
|
3656
|
+
|
|
3657
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3658
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3659
|
+
const reqObj = {
|
|
3660
|
+
payload: bodyVars,
|
|
3661
|
+
uriPathVars: pathVars,
|
|
3662
|
+
uriQuery: queryParams
|
|
3663
|
+
};
|
|
3664
|
+
|
|
3665
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
3666
|
+
|
|
3667
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
3668
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
3669
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
3670
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
3671
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
3672
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
3673
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
3674
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
3675
|
+
} else {
|
|
3676
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
3677
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
3678
|
+
}
|
|
3679
|
+
}
|
|
3680
|
+
});
|
|
3681
|
+
// Add iapMetadata to reqObj for further work
|
|
3682
|
+
reqObj.iapMetadata = iapMetadata;
|
|
3683
|
+
}
|
|
3684
|
+
|
|
3685
|
+
try {
|
|
3686
|
+
// Make the call -
|
|
3687
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3688
|
+
return this.requestHandlerInst.identifyRequest('OpenCmPersistencyPortBinding', 'getOpenCmMOLites', reqObj, true, (irReturnData, irReturnError) => {
|
|
3689
|
+
// if we received an error or their is no response on the results
|
|
3690
|
+
// return an error
|
|
3691
|
+
if (irReturnError) {
|
|
3692
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3693
|
+
return callback(null, irReturnError);
|
|
3694
|
+
}
|
|
3695
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3696
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getOpenCmMOLites'], null, null, null);
|
|
3697
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3698
|
+
return callback(null, errorObj);
|
|
3699
|
+
}
|
|
3700
|
+
|
|
3701
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3702
|
+
// return the response
|
|
3703
|
+
return callback(irReturnData, null);
|
|
3704
|
+
});
|
|
3705
|
+
} catch (ex) {
|
|
3706
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3707
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3708
|
+
return callback(null, errorObj);
|
|
3709
|
+
}
|
|
3710
|
+
}
|
|
3711
|
+
|
|
3712
|
+
/**
|
|
3713
|
+
* @function getOpenCmRelatedMOLites
|
|
3714
|
+
* @pronghornType method
|
|
3715
|
+
* @name getOpenCmRelatedMOLites
|
|
3716
|
+
* @summary getRelatedMOLites
|
|
3717
|
+
*
|
|
3718
|
+
* @param {object} body - body param
|
|
3719
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
3720
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3721
|
+
* @return {object} results - An object containing the response of the action
|
|
3722
|
+
*
|
|
3723
|
+
* @route {POST} /getOpenCmRelatedMOLites
|
|
3724
|
+
* @roles admin
|
|
3725
|
+
* @task true
|
|
3726
|
+
*/
|
|
3727
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3728
|
+
getOpenCmRelatedMOLites(body, iapMetadata, callback) {
|
|
3729
|
+
const meth = 'adapter-getOpenCmRelatedMOLites';
|
|
3730
|
+
const origin = `${this.id}-${meth}`;
|
|
3731
|
+
log.trace(origin);
|
|
3732
|
+
|
|
3733
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3734
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3735
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3736
|
+
return callback(null, errorObj);
|
|
3737
|
+
}
|
|
3738
|
+
|
|
3739
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3740
|
+
if (body === undefined || body === null || body === '') {
|
|
3741
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
3742
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3743
|
+
return callback(null, errorObj);
|
|
3744
|
+
}
|
|
3745
|
+
|
|
3746
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3747
|
+
const queryParamsAvailable = {};
|
|
3748
|
+
const queryParams = {};
|
|
3749
|
+
const pathVars = [];
|
|
3750
|
+
const bodyVars = body;
|
|
3751
|
+
|
|
3752
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3753
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3754
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3755
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3756
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3757
|
+
}
|
|
3758
|
+
});
|
|
3759
|
+
|
|
3760
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3761
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3762
|
+
const reqObj = {
|
|
3763
|
+
payload: bodyVars,
|
|
3764
|
+
uriPathVars: pathVars,
|
|
3765
|
+
uriQuery: queryParams
|
|
3766
|
+
};
|
|
3767
|
+
|
|
3768
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
3769
|
+
|
|
3770
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
3771
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
3772
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
3773
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
3774
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
3775
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
3776
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
3777
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
3778
|
+
} else {
|
|
3779
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
3780
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
3781
|
+
}
|
|
3782
|
+
}
|
|
3783
|
+
});
|
|
3784
|
+
// Add iapMetadata to reqObj for further work
|
|
3785
|
+
reqObj.iapMetadata = iapMetadata;
|
|
3786
|
+
}
|
|
3787
|
+
|
|
3788
|
+
try {
|
|
3789
|
+
// Make the call -
|
|
3790
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3791
|
+
return this.requestHandlerInst.identifyRequest('OpenCmPersistencyPortBinding', 'getOpenCmRelatedMOLites', reqObj, true, (irReturnData, irReturnError) => {
|
|
3792
|
+
// if we received an error or their is no response on the results
|
|
3793
|
+
// return an error
|
|
3794
|
+
if (irReturnError) {
|
|
3795
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3796
|
+
return callback(null, irReturnError);
|
|
3797
|
+
}
|
|
3798
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3799
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getOpenCmRelatedMOLites'], null, null, null);
|
|
3800
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3801
|
+
return callback(null, errorObj);
|
|
3802
|
+
}
|
|
3803
|
+
|
|
3804
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3805
|
+
// return the response
|
|
3806
|
+
return callback(irReturnData, null);
|
|
3807
|
+
});
|
|
3808
|
+
} catch (ex) {
|
|
3809
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3810
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3811
|
+
return callback(null, errorObj);
|
|
3812
|
+
}
|
|
3813
|
+
}
|
|
3814
|
+
|
|
3815
|
+
/**
|
|
3816
|
+
* @function queryOpenCmMOLites
|
|
3817
|
+
* @pronghornType method
|
|
3818
|
+
* @name queryOpenCmMOLites
|
|
3819
|
+
* @summary queryMOLites
|
|
3820
|
+
*
|
|
3821
|
+
* @param {object} body - body param
|
|
3822
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
3823
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3824
|
+
* @return {object} results - An object containing the response of the action
|
|
3825
|
+
*
|
|
3826
|
+
* @route {POST} /queryOpenCmMOLites
|
|
3827
|
+
* @roles admin
|
|
3828
|
+
* @task true
|
|
3829
|
+
*/
|
|
3830
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3831
|
+
queryOpenCmMOLites(body, iapMetadata, callback) {
|
|
3832
|
+
const meth = 'adapter-queryOpenCmMOLites';
|
|
3833
|
+
const origin = `${this.id}-${meth}`;
|
|
3834
|
+
log.trace(origin);
|
|
3835
|
+
|
|
3836
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3837
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3838
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3839
|
+
return callback(null, errorObj);
|
|
3840
|
+
}
|
|
3841
|
+
|
|
3842
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3843
|
+
if (body === undefined || body === null || body === '') {
|
|
3844
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
3845
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3846
|
+
return callback(null, errorObj);
|
|
3847
|
+
}
|
|
3848
|
+
|
|
3849
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3850
|
+
const queryParamsAvailable = {};
|
|
3851
|
+
const queryParams = {};
|
|
3852
|
+
const pathVars = [];
|
|
3853
|
+
const bodyVars = body;
|
|
3854
|
+
|
|
3855
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3856
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3857
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3858
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3859
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3860
|
+
}
|
|
3861
|
+
});
|
|
3862
|
+
|
|
3863
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3864
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3865
|
+
const reqObj = {
|
|
3866
|
+
payload: bodyVars,
|
|
3867
|
+
uriPathVars: pathVars,
|
|
3868
|
+
uriQuery: queryParams
|
|
3869
|
+
};
|
|
3870
|
+
|
|
3871
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
3872
|
+
|
|
3873
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
3874
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
3875
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
3876
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
3877
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
3878
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
3879
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
3880
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
3881
|
+
} else {
|
|
3882
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
3883
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
3884
|
+
}
|
|
3885
|
+
}
|
|
3886
|
+
});
|
|
3887
|
+
// Add iapMetadata to reqObj for further work
|
|
3888
|
+
reqObj.iapMetadata = iapMetadata;
|
|
3889
|
+
}
|
|
3890
|
+
|
|
3891
|
+
try {
|
|
3892
|
+
// Make the call -
|
|
3893
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3894
|
+
return this.requestHandlerInst.identifyRequest('OpenCmPersistencyPortBinding', 'queryOpenCmMOLites', reqObj, true, (irReturnData, irReturnError) => {
|
|
3895
|
+
// if we received an error or their is no response on the results
|
|
3896
|
+
// return an error
|
|
3897
|
+
if (irReturnError) {
|
|
3898
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
3899
|
+
return callback(null, irReturnError);
|
|
3900
|
+
}
|
|
3901
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
3902
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['queryOpenCmMOLites'], null, null, null);
|
|
3903
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3904
|
+
return callback(null, errorObj);
|
|
3905
|
+
}
|
|
3906
|
+
|
|
3907
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
3908
|
+
// return the response
|
|
3909
|
+
return callback(irReturnData, null);
|
|
3910
|
+
});
|
|
3911
|
+
} catch (ex) {
|
|
3912
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
3913
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3914
|
+
return callback(null, errorObj);
|
|
3915
|
+
}
|
|
3916
|
+
}
|
|
3917
|
+
|
|
3918
|
+
/**
|
|
3919
|
+
* @function getPersistencyMetadata
|
|
3920
|
+
* @pronghornType method
|
|
3921
|
+
* @name getPersistencyMetadata
|
|
3922
|
+
* @summary getPersistencyMetadata
|
|
3923
|
+
*
|
|
3924
|
+
* @param {object} body - body param
|
|
3925
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
3926
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
3927
|
+
* @return {object} results - An object containing the response of the action
|
|
3928
|
+
*
|
|
3929
|
+
* @route {POST} /getPersistencyMetadata
|
|
3930
|
+
* @roles admin
|
|
3931
|
+
* @task true
|
|
3932
|
+
*/
|
|
3933
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
3934
|
+
getPersistencyMetadata(body, iapMetadata, callback) {
|
|
3935
|
+
const meth = 'adapter-getPersistencyMetadata';
|
|
3936
|
+
const origin = `${this.id}-${meth}`;
|
|
3937
|
+
log.trace(origin);
|
|
3938
|
+
|
|
3939
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
3940
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
3941
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3942
|
+
return callback(null, errorObj);
|
|
3943
|
+
}
|
|
3944
|
+
|
|
3945
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
3946
|
+
if (body === undefined || body === null || body === '') {
|
|
3947
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
3948
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3949
|
+
return callback(null, errorObj);
|
|
3950
|
+
}
|
|
3951
|
+
|
|
3952
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3953
|
+
const queryParamsAvailable = {};
|
|
3954
|
+
const queryParams = {};
|
|
3955
|
+
const pathVars = [];
|
|
3956
|
+
const bodyVars = body;
|
|
3957
|
+
|
|
3958
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
3959
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
3960
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
3961
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
3962
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
3963
|
+
}
|
|
3964
|
+
});
|
|
3965
|
+
|
|
3966
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
3967
|
+
// see adapter code documentation for more information on the request object's fields
|
|
3968
|
+
const reqObj = {
|
|
3969
|
+
payload: bodyVars,
|
|
3970
|
+
uriPathVars: pathVars,
|
|
3971
|
+
uriQuery: queryParams
|
|
3972
|
+
};
|
|
3973
|
+
|
|
3974
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
3975
|
+
|
|
3976
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
3977
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
3978
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
3979
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
3980
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
3981
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
3982
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
3983
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
3984
|
+
} else {
|
|
3985
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
3986
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
3987
|
+
}
|
|
3988
|
+
}
|
|
3989
|
+
});
|
|
3990
|
+
// Add iapMetadata to reqObj for further work
|
|
3991
|
+
reqObj.iapMetadata = iapMetadata;
|
|
3992
|
+
}
|
|
3993
|
+
|
|
3994
|
+
try {
|
|
3995
|
+
// Make the call -
|
|
3996
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
3997
|
+
return this.requestHandlerInst.identifyRequest('OpenCmPersistencyPortBinding', 'getPersistencyMetadata', reqObj, true, (irReturnData, irReturnError) => {
|
|
3998
|
+
// if we received an error or their is no response on the results
|
|
3999
|
+
// return an error
|
|
4000
|
+
if (irReturnError) {
|
|
4001
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
4002
|
+
return callback(null, irReturnError);
|
|
4003
|
+
}
|
|
4004
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
4005
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPersistencyMetadata'], null, null, null);
|
|
4006
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4007
|
+
return callback(null, errorObj);
|
|
4008
|
+
}
|
|
4009
|
+
|
|
4010
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
4011
|
+
// return the response
|
|
4012
|
+
return callback(irReturnData, null);
|
|
4013
|
+
});
|
|
4014
|
+
} catch (ex) {
|
|
4015
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
4016
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4017
|
+
return callback(null, errorObj);
|
|
4018
|
+
}
|
|
4019
|
+
}
|
|
4020
|
+
|
|
4021
|
+
/**
|
|
4022
|
+
* @function getOpenCmConfigurations
|
|
4023
|
+
* @pronghornType method
|
|
4024
|
+
* @name getOpenCmConfigurations
|
|
4025
|
+
* @summary getConfigurations
|
|
4026
|
+
*
|
|
4027
|
+
* @param {object} body - body param
|
|
4028
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
4029
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
4030
|
+
* @return {object} results - An object containing the response of the action
|
|
4031
|
+
*
|
|
4032
|
+
* @route {POST} /getOpenCmConfigurations
|
|
4033
|
+
* @roles admin
|
|
4034
|
+
* @task true
|
|
4035
|
+
*/
|
|
4036
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
4037
|
+
getOpenCmConfigurations(body, iapMetadata, callback) {
|
|
4038
|
+
const meth = 'adapter-getOpenCmConfigurations';
|
|
4039
|
+
const origin = `${this.id}-${meth}`;
|
|
4040
|
+
log.trace(origin);
|
|
4041
|
+
|
|
4042
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
4043
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
4044
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4045
|
+
return callback(null, errorObj);
|
|
4046
|
+
}
|
|
4047
|
+
|
|
4048
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
4049
|
+
if (body === undefined || body === null || body === '') {
|
|
4050
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
4051
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4052
|
+
return callback(null, errorObj);
|
|
4053
|
+
}
|
|
4054
|
+
|
|
4055
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
4056
|
+
const queryParamsAvailable = {};
|
|
4057
|
+
const queryParams = {};
|
|
4058
|
+
const pathVars = [];
|
|
4059
|
+
const bodyVars = body;
|
|
4060
|
+
|
|
4061
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
4062
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
4063
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
4064
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
4065
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
4066
|
+
}
|
|
4067
|
+
});
|
|
4068
|
+
|
|
4069
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
4070
|
+
// see adapter code documentation for more information on the request object's fields
|
|
4071
|
+
const reqObj = {
|
|
4072
|
+
payload: bodyVars,
|
|
4073
|
+
uriPathVars: pathVars,
|
|
4074
|
+
uriQuery: queryParams
|
|
4075
|
+
};
|
|
4076
|
+
|
|
4077
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
4078
|
+
|
|
4079
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
4080
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
4081
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
4082
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
4083
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
4084
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
4085
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
4086
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
4087
|
+
} else {
|
|
4088
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
4089
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
4090
|
+
}
|
|
4091
|
+
}
|
|
4092
|
+
});
|
|
4093
|
+
// Add iapMetadata to reqObj for further work
|
|
4094
|
+
reqObj.iapMetadata = iapMetadata;
|
|
4095
|
+
}
|
|
4096
|
+
|
|
4097
|
+
try {
|
|
4098
|
+
// Make the call -
|
|
4099
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
4100
|
+
return this.requestHandlerInst.identifyRequest('OpenCmPersistencyPortBinding', 'getOpenCmConfigurations', reqObj, true, (irReturnData, irReturnError) => {
|
|
4101
|
+
// if we received an error or their is no response on the results
|
|
4102
|
+
// return an error
|
|
4103
|
+
if (irReturnError) {
|
|
4104
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
4105
|
+
return callback(null, irReturnError);
|
|
4106
|
+
}
|
|
4107
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
4108
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getOpenCmConfigurations'], null, null, null);
|
|
4109
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4110
|
+
return callback(null, errorObj);
|
|
4111
|
+
}
|
|
4112
|
+
|
|
4113
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
4114
|
+
// return the response
|
|
4115
|
+
return callback(irReturnData, null);
|
|
4116
|
+
});
|
|
4117
|
+
} catch (ex) {
|
|
4118
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
4119
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4120
|
+
return callback(null, errorObj);
|
|
4121
|
+
}
|
|
4122
|
+
}
|
|
4123
|
+
|
|
4124
|
+
/**
|
|
4125
|
+
* @function createOpenCmConfiguration
|
|
4126
|
+
* @pronghornType method
|
|
4127
|
+
* @name createOpenCmConfiguration
|
|
4128
|
+
* @summary createConfiguration
|
|
4129
|
+
*
|
|
4130
|
+
* @param {object} body - body param
|
|
4131
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
4132
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
4133
|
+
* @return {object} results - An object containing the response of the action
|
|
4134
|
+
*
|
|
4135
|
+
* @route {POST} /createOpenCmConfiguration
|
|
4136
|
+
* @roles admin
|
|
4137
|
+
* @task true
|
|
4138
|
+
*/
|
|
4139
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
4140
|
+
createOpenCmConfiguration(body, iapMetadata, callback) {
|
|
4141
|
+
const meth = 'adapter-createOpenCmConfiguration';
|
|
4142
|
+
const origin = `${this.id}-${meth}`;
|
|
4143
|
+
log.trace(origin);
|
|
4144
|
+
|
|
4145
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
4146
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
4147
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4148
|
+
return callback(null, errorObj);
|
|
4149
|
+
}
|
|
4150
|
+
|
|
4151
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
4152
|
+
if (body === undefined || body === null || body === '') {
|
|
4153
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
4154
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4155
|
+
return callback(null, errorObj);
|
|
4156
|
+
}
|
|
4157
|
+
|
|
4158
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
4159
|
+
const queryParamsAvailable = {};
|
|
4160
|
+
const queryParams = {};
|
|
4161
|
+
const pathVars = [];
|
|
4162
|
+
const bodyVars = body;
|
|
4163
|
+
|
|
4164
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
4165
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
4166
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
4167
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
4168
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
4169
|
+
}
|
|
4170
|
+
});
|
|
4171
|
+
|
|
4172
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
4173
|
+
// see adapter code documentation for more information on the request object's fields
|
|
4174
|
+
const reqObj = {
|
|
4175
|
+
payload: bodyVars,
|
|
4176
|
+
uriPathVars: pathVars,
|
|
4177
|
+
uriQuery: queryParams
|
|
4178
|
+
};
|
|
4179
|
+
|
|
4180
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
4181
|
+
|
|
4182
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
4183
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
4184
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
4185
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
4186
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
4187
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
4188
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
4189
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
4190
|
+
} else {
|
|
4191
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
4192
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
4193
|
+
}
|
|
4194
|
+
}
|
|
4195
|
+
});
|
|
4196
|
+
// Add iapMetadata to reqObj for further work
|
|
4197
|
+
reqObj.iapMetadata = iapMetadata;
|
|
4198
|
+
}
|
|
4199
|
+
|
|
4200
|
+
try {
|
|
4201
|
+
// Make the call -
|
|
4202
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
4203
|
+
return this.requestHandlerInst.identifyRequest('OpenCmPersistencyPortBinding', 'createOpenCmConfiguration', reqObj, true, (irReturnData, irReturnError) => {
|
|
4204
|
+
// if we received an error or their is no response on the results
|
|
4205
|
+
// return an error
|
|
4206
|
+
if (irReturnError) {
|
|
4207
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
4208
|
+
return callback(null, irReturnError);
|
|
4209
|
+
}
|
|
4210
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
4211
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createOpenCmConfiguration'], null, null, null);
|
|
4212
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4213
|
+
return callback(null, errorObj);
|
|
4214
|
+
}
|
|
4215
|
+
|
|
4216
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
4217
|
+
// return the response
|
|
4218
|
+
return callback(irReturnData, null);
|
|
4219
|
+
});
|
|
4220
|
+
} catch (ex) {
|
|
4221
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
4222
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4223
|
+
return callback(null, errorObj);
|
|
4224
|
+
}
|
|
4225
|
+
}
|
|
4226
|
+
|
|
4227
|
+
/**
|
|
4228
|
+
* @function postPersistencyOpenCmPersistencyServiceSOAPUpdateConfiguration
|
|
4229
|
+
* @pronghornType method
|
|
4230
|
+
* @name postPersistencyOpenCmPersistencyServiceSOAPUpdateConfiguration
|
|
4231
|
+
* @summary updateConfiguration
|
|
4232
|
+
*
|
|
4233
|
+
* @param {object} body - body param
|
|
4234
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
4235
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
4236
|
+
* @return {object} results - An object containing the response of the action
|
|
4237
|
+
*
|
|
4238
|
+
* @route {POST} /postPersistencyOpenCmPersistencyServiceSOAPUpdateConfiguration
|
|
4239
|
+
* @roles admin
|
|
4240
|
+
* @task true
|
|
4241
|
+
*/
|
|
4242
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
4243
|
+
postPersistencyOpenCmPersistencyServiceSOAPUpdateConfiguration(body, iapMetadata, callback) {
|
|
4244
|
+
const meth = 'adapter-postPersistencyOpenCmPersistencyServiceSOAPUpdateConfiguration';
|
|
4245
|
+
const origin = `${this.id}-${meth}`;
|
|
4246
|
+
log.trace(origin);
|
|
4247
|
+
|
|
4248
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
4249
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
4250
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4251
|
+
return callback(null, errorObj);
|
|
4252
|
+
}
|
|
4253
|
+
|
|
4254
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
4255
|
+
if (body === undefined || body === null || body === '') {
|
|
4256
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
4257
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4258
|
+
return callback(null, errorObj);
|
|
4259
|
+
}
|
|
4260
|
+
|
|
4261
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
4262
|
+
const queryParamsAvailable = {};
|
|
4263
|
+
const queryParams = {};
|
|
4264
|
+
const pathVars = [];
|
|
4265
|
+
const bodyVars = body;
|
|
4266
|
+
|
|
4267
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
4268
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
4269
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
4270
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
4271
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
4272
|
+
}
|
|
4273
|
+
});
|
|
4274
|
+
|
|
4275
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
4276
|
+
// see adapter code documentation for more information on the request object's fields
|
|
4277
|
+
const reqObj = {
|
|
4278
|
+
payload: bodyVars,
|
|
4279
|
+
uriPathVars: pathVars,
|
|
4280
|
+
uriQuery: queryParams
|
|
4281
|
+
};
|
|
4282
|
+
|
|
4283
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
4284
|
+
|
|
4285
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
4286
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
4287
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
4288
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
4289
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
4290
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
4291
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
4292
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
4293
|
+
} else {
|
|
4294
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
4295
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
4296
|
+
}
|
|
4297
|
+
}
|
|
4298
|
+
});
|
|
4299
|
+
// Add iapMetadata to reqObj for further work
|
|
4300
|
+
reqObj.iapMetadata = iapMetadata;
|
|
4301
|
+
}
|
|
4302
|
+
|
|
4303
|
+
try {
|
|
4304
|
+
// Make the call -
|
|
4305
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
4306
|
+
return this.requestHandlerInst.identifyRequest('OpenCmPersistencyPortBinding', 'postPersistencyOpenCmPersistencyServiceSOAPUpdateConfiguration', reqObj, true, (irReturnData, irReturnError) => {
|
|
4307
|
+
// if we received an error or their is no response on the results
|
|
4308
|
+
// return an error
|
|
4309
|
+
if (irReturnError) {
|
|
4310
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
4311
|
+
return callback(null, irReturnError);
|
|
4312
|
+
}
|
|
4313
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
4314
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postPersistencyOpenCmPersistencyServiceSOAPUpdateConfiguration'], null, null, null);
|
|
4315
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4316
|
+
return callback(null, errorObj);
|
|
4317
|
+
}
|
|
4318
|
+
|
|
4319
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
4320
|
+
// return the response
|
|
4321
|
+
return callback(irReturnData, null);
|
|
4322
|
+
});
|
|
4323
|
+
} catch (ex) {
|
|
4324
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
4325
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4326
|
+
return callback(null, errorObj);
|
|
4327
|
+
}
|
|
4328
|
+
}
|
|
4329
|
+
|
|
4330
|
+
/**
|
|
4331
|
+
* @function deleteOpenCmConfiguration
|
|
4332
|
+
* @pronghornType method
|
|
4333
|
+
* @name deleteOpenCmConfiguration
|
|
4334
|
+
* @summary deleteConfiguration
|
|
4335
|
+
*
|
|
4336
|
+
* @param {object} body - body param
|
|
4337
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
4338
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
4339
|
+
* @return {object} results - An object containing the response of the action
|
|
4340
|
+
*
|
|
4341
|
+
* @route {POST} /deleteOpenCmConfiguration
|
|
4342
|
+
* @roles admin
|
|
4343
|
+
* @task true
|
|
4344
|
+
*/
|
|
4345
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
4346
|
+
deleteOpenCmConfiguration(body, iapMetadata, callback) {
|
|
4347
|
+
const meth = 'adapter-deleteOpenCmConfiguration';
|
|
4348
|
+
const origin = `${this.id}-${meth}`;
|
|
4349
|
+
log.trace(origin);
|
|
4350
|
+
|
|
4351
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
4352
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
4353
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4354
|
+
return callback(null, errorObj);
|
|
4355
|
+
}
|
|
4356
|
+
|
|
4357
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
4358
|
+
if (body === undefined || body === null || body === '') {
|
|
4359
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
4360
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4361
|
+
return callback(null, errorObj);
|
|
4362
|
+
}
|
|
4363
|
+
|
|
4364
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
4365
|
+
const queryParamsAvailable = {};
|
|
4366
|
+
const queryParams = {};
|
|
4367
|
+
const pathVars = [];
|
|
4368
|
+
const bodyVars = body;
|
|
4369
|
+
|
|
4370
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
4371
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
4372
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
4373
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
4374
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
4375
|
+
}
|
|
4376
|
+
});
|
|
4377
|
+
|
|
4378
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
4379
|
+
// see adapter code documentation for more information on the request object's fields
|
|
4380
|
+
const reqObj = {
|
|
4381
|
+
payload: bodyVars,
|
|
4382
|
+
uriPathVars: pathVars,
|
|
4383
|
+
uriQuery: queryParams
|
|
4384
|
+
};
|
|
4385
|
+
|
|
4386
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
4387
|
+
|
|
4388
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
4389
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
4390
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
4391
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
4392
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
4393
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
4394
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
4395
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
4396
|
+
} else {
|
|
4397
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
4398
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
4399
|
+
}
|
|
4400
|
+
}
|
|
4401
|
+
});
|
|
4402
|
+
// Add iapMetadata to reqObj for further work
|
|
4403
|
+
reqObj.iapMetadata = iapMetadata;
|
|
4404
|
+
}
|
|
4405
|
+
|
|
4406
|
+
try {
|
|
4407
|
+
// Make the call -
|
|
4408
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
4409
|
+
return this.requestHandlerInst.identifyRequest('OpenCmPersistencyPortBinding', 'deleteOpenCmConfiguration', reqObj, true, (irReturnData, irReturnError) => {
|
|
4410
|
+
// if we received an error or their is no response on the results
|
|
4411
|
+
// return an error
|
|
4412
|
+
if (irReturnError) {
|
|
4413
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
4414
|
+
return callback(null, irReturnError);
|
|
4415
|
+
}
|
|
4416
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
4417
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteOpenCmConfiguration'], null, null, null);
|
|
4418
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4419
|
+
return callback(null, errorObj);
|
|
4420
|
+
}
|
|
4421
|
+
|
|
4422
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
4423
|
+
// return the response
|
|
4424
|
+
return callback(irReturnData, null);
|
|
4425
|
+
});
|
|
4426
|
+
} catch (ex) {
|
|
4427
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
4428
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4429
|
+
return callback(null, errorObj);
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4432
|
+
|
|
4433
|
+
/**
|
|
4434
|
+
* @function getOperationsMetadata
|
|
4435
|
+
* @pronghornType method
|
|
4436
|
+
* @name getOperationsMetadata
|
|
4437
|
+
* @summary getOperationsMetadata
|
|
4438
|
+
*
|
|
4439
|
+
* @param {object} body - body param
|
|
4440
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
4441
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
4442
|
+
* @return {object} results - An object containing the response of the action
|
|
4443
|
+
*
|
|
4444
|
+
* @route {POST} /getOperationsMetadata
|
|
4445
|
+
* @roles admin
|
|
4446
|
+
* @task true
|
|
4447
|
+
*/
|
|
4448
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
4449
|
+
getOperationsMetadata(body, iapMetadata, callback) {
|
|
4450
|
+
const meth = 'adapter-getOperationsMetadata';
|
|
4451
|
+
const origin = `${this.id}-${meth}`;
|
|
4452
|
+
log.trace(origin);
|
|
4453
|
+
|
|
4454
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
4455
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
4456
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4457
|
+
return callback(null, errorObj);
|
|
4458
|
+
}
|
|
4459
|
+
|
|
4460
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
4461
|
+
if (body === undefined || body === null || body === '') {
|
|
4462
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
4463
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4464
|
+
return callback(null, errorObj);
|
|
4465
|
+
}
|
|
4466
|
+
|
|
4467
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
4468
|
+
const queryParamsAvailable = {};
|
|
4469
|
+
const queryParams = {};
|
|
4470
|
+
const pathVars = [];
|
|
4471
|
+
const bodyVars = body;
|
|
4472
|
+
|
|
4473
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
4474
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
4475
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
4476
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
4477
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
4478
|
+
}
|
|
4479
|
+
});
|
|
4480
|
+
|
|
4481
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
4482
|
+
// see adapter code documentation for more information on the request object's fields
|
|
4483
|
+
const reqObj = {
|
|
4484
|
+
payload: bodyVars,
|
|
4485
|
+
uriPathVars: pathVars,
|
|
4486
|
+
uriQuery: queryParams
|
|
4487
|
+
};
|
|
4488
|
+
|
|
4489
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
4490
|
+
|
|
4491
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
4492
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
4493
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
4494
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
4495
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
4496
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
4497
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
4498
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
4499
|
+
} else {
|
|
4500
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
4501
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
4502
|
+
}
|
|
4503
|
+
}
|
|
4504
|
+
});
|
|
4505
|
+
// Add iapMetadata to reqObj for further work
|
|
4506
|
+
reqObj.iapMetadata = iapMetadata;
|
|
4507
|
+
}
|
|
4508
|
+
|
|
4509
|
+
try {
|
|
4510
|
+
// Make the call -
|
|
4511
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
4512
|
+
return this.requestHandlerInst.identifyRequest('OpenCmOperationsPortBinding', 'getOperationsMetadata', reqObj, true, (irReturnData, irReturnError) => {
|
|
4513
|
+
// if we received an error or their is no response on the results
|
|
4514
|
+
// return an error
|
|
4515
|
+
if (irReturnError) {
|
|
4516
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
4517
|
+
return callback(null, irReturnError);
|
|
4518
|
+
}
|
|
4519
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
4520
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getOperationsMetadata'], null, null, null);
|
|
4521
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4522
|
+
return callback(null, errorObj);
|
|
4523
|
+
}
|
|
4524
|
+
|
|
4525
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
4526
|
+
// return the response
|
|
4527
|
+
return callback(irReturnData, null);
|
|
4528
|
+
});
|
|
4529
|
+
} catch (ex) {
|
|
4530
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
4531
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4532
|
+
return callback(null, errorObj);
|
|
4533
|
+
}
|
|
4534
|
+
}
|
|
4535
|
+
|
|
4536
|
+
/**
|
|
4537
|
+
* @function startOpenCmOperation
|
|
4538
|
+
* @pronghornType method
|
|
4539
|
+
* @name startOpenCmOperation
|
|
4540
|
+
* @summary startOperation
|
|
4541
|
+
*
|
|
4542
|
+
* @param {object} body - body param
|
|
4543
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
4544
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
4545
|
+
* @return {object} results - An object containing the response of the action
|
|
4546
|
+
*
|
|
4547
|
+
* @route {POST} /startOpenCmOperation
|
|
4548
|
+
* @roles admin
|
|
4549
|
+
* @task true
|
|
4550
|
+
*/
|
|
4551
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
4552
|
+
startOpenCmOperation(body, iapMetadata, callback) {
|
|
4553
|
+
const meth = 'adapter-startOpenCmOperation';
|
|
4554
|
+
const origin = `${this.id}-${meth}`;
|
|
4555
|
+
log.trace(origin);
|
|
4556
|
+
|
|
4557
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
4558
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
4559
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4560
|
+
return callback(null, errorObj);
|
|
4561
|
+
}
|
|
4562
|
+
|
|
4563
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
4564
|
+
if (body === undefined || body === null || body === '') {
|
|
4565
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
4566
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4567
|
+
return callback(null, errorObj);
|
|
4568
|
+
}
|
|
4569
|
+
|
|
4570
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
4571
|
+
const queryParamsAvailable = {};
|
|
4572
|
+
const queryParams = {};
|
|
4573
|
+
const pathVars = [];
|
|
4574
|
+
const bodyVars = body;
|
|
4575
|
+
|
|
4576
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
4577
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
4578
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
4579
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
4580
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
4581
|
+
}
|
|
4582
|
+
});
|
|
4583
|
+
|
|
4584
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
4585
|
+
// see adapter code documentation for more information on the request object's fields
|
|
4586
|
+
const reqObj = {
|
|
4587
|
+
payload: bodyVars,
|
|
4588
|
+
uriPathVars: pathVars,
|
|
4589
|
+
uriQuery: queryParams
|
|
4590
|
+
};
|
|
4591
|
+
|
|
4592
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
4593
|
+
|
|
4594
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
4595
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
4596
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
4597
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
4598
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
4599
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
4600
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
4601
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
4602
|
+
} else {
|
|
4603
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
4604
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
4605
|
+
}
|
|
4606
|
+
}
|
|
4607
|
+
});
|
|
4608
|
+
// Add iapMetadata to reqObj for further work
|
|
4609
|
+
reqObj.iapMetadata = iapMetadata;
|
|
4610
|
+
}
|
|
4611
|
+
|
|
4612
|
+
try {
|
|
4613
|
+
// Make the call -
|
|
4614
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
4615
|
+
return this.requestHandlerInst.identifyRequest('OpenCmOperationsPortBinding', 'startOpenCmOperation', reqObj, true, (irReturnData, irReturnError) => {
|
|
4616
|
+
// if we received an error or their is no response on the results
|
|
4617
|
+
// return an error
|
|
4618
|
+
if (irReturnError) {
|
|
4619
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
4620
|
+
return callback(null, irReturnError);
|
|
4621
|
+
}
|
|
4622
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
4623
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['startOpenCmOperation'], null, null, null);
|
|
4624
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4625
|
+
return callback(null, errorObj);
|
|
4626
|
+
}
|
|
4627
|
+
|
|
4628
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
4629
|
+
// return the response
|
|
4630
|
+
return callback(irReturnData, null);
|
|
4631
|
+
});
|
|
4632
|
+
} catch (ex) {
|
|
4633
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
4634
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4635
|
+
return callback(null, errorObj);
|
|
4636
|
+
}
|
|
4637
|
+
}
|
|
4638
|
+
|
|
4639
|
+
/**
|
|
4640
|
+
* @function interruptOperationOpenCm
|
|
4641
|
+
* @pronghornType method
|
|
4642
|
+
* @name interruptOperationOpenCm
|
|
4643
|
+
* @summary interruptOperationOpenCm
|
|
4644
|
+
*
|
|
4645
|
+
* @param {object} body - body param
|
|
4646
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
4647
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
4648
|
+
* @return {object} results - An object containing the response of the action
|
|
4649
|
+
*
|
|
4650
|
+
* @route {POST} /interruptOperationOpenCm
|
|
4651
|
+
* @roles admin
|
|
4652
|
+
* @task true
|
|
4653
|
+
*/
|
|
4654
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
4655
|
+
interruptOperationOpenCm(body, iapMetadata, callback) {
|
|
4656
|
+
const meth = 'adapter-interruptOperationOpenCm';
|
|
4657
|
+
const origin = `${this.id}-${meth}`;
|
|
4658
|
+
log.trace(origin);
|
|
4659
|
+
|
|
4660
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
4661
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
4662
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4663
|
+
return callback(null, errorObj);
|
|
4664
|
+
}
|
|
4665
|
+
|
|
4666
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
4667
|
+
if (body === undefined || body === null || body === '') {
|
|
4668
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
4669
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4670
|
+
return callback(null, errorObj);
|
|
4671
|
+
}
|
|
4672
|
+
|
|
4673
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
4674
|
+
const queryParamsAvailable = {};
|
|
4675
|
+
const queryParams = {};
|
|
4676
|
+
const pathVars = [];
|
|
4677
|
+
const bodyVars = body;
|
|
4678
|
+
|
|
4679
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
4680
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
4681
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
4682
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
4683
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
4684
|
+
}
|
|
4685
|
+
});
|
|
4686
|
+
|
|
4687
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
4688
|
+
// see adapter code documentation for more information on the request object's fields
|
|
4689
|
+
const reqObj = {
|
|
4690
|
+
payload: bodyVars,
|
|
4691
|
+
uriPathVars: pathVars,
|
|
4692
|
+
uriQuery: queryParams
|
|
4693
|
+
};
|
|
4694
|
+
|
|
4695
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
4696
|
+
|
|
4697
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
4698
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
4699
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
4700
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
4701
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
4702
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
4703
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
4704
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
4705
|
+
} else {
|
|
4706
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
4707
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
4708
|
+
}
|
|
4709
|
+
}
|
|
4710
|
+
});
|
|
4711
|
+
// Add iapMetadata to reqObj for further work
|
|
4712
|
+
reqObj.iapMetadata = iapMetadata;
|
|
4713
|
+
}
|
|
4714
|
+
|
|
4715
|
+
try {
|
|
4716
|
+
// Make the call -
|
|
4717
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
4718
|
+
return this.requestHandlerInst.identifyRequest('OpenCmOperationsPortBinding', 'interruptOperationOpenCm', reqObj, true, (irReturnData, irReturnError) => {
|
|
4719
|
+
// if we received an error or their is no response on the results
|
|
4720
|
+
// return an error
|
|
4721
|
+
if (irReturnError) {
|
|
4722
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
4723
|
+
return callback(null, irReturnError);
|
|
4724
|
+
}
|
|
4725
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
4726
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['interruptOperationOpenCm'], null, null, null);
|
|
4727
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4728
|
+
return callback(null, errorObj);
|
|
4729
|
+
}
|
|
4730
|
+
|
|
4731
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
4732
|
+
// return the response
|
|
4733
|
+
return callback(irReturnData, null);
|
|
4734
|
+
});
|
|
4735
|
+
} catch (ex) {
|
|
4736
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
4737
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
4738
|
+
return callback(null, errorObj);
|
|
4739
|
+
}
|
|
4740
|
+
}
|
|
4741
|
+
}
|
|
4742
|
+
|
|
4743
|
+
module.exports = NokiaNetact;
|