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