@itentialopensource/adapter-paragon_pathfinder 1.7.0 → 1.7.3
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/TAB2.md +3 -0
- package/adapter.js +636 -0
- package/entities/Authentication/action.json +24 -0
- package/entities/Authentication/schema.json +19 -0
- package/entities/Links/action.json +45 -0
- package/entities/Links/schema.json +20 -0
- package/entities/TELSPs/action.json +65 -0
- package/entities/TELSPs/schema.json +21 -0
- package/package.json +2 -2
- package/pronghorn.json +344 -0
- package/report/auto-adapter-openapi.json +37 -5
- package/test/integration/adapterTestIntegration.js +156 -0
- package/test/unit/adapterTestUnit.js +208 -0
package/TAB2.md
CHANGED
|
@@ -149,6 +149,9 @@ Sample Properties can be used to help you configure the adapter in the Itential
|
|
|
149
149
|
"client_id": "",
|
|
150
150
|
"client_secret": "",
|
|
151
151
|
"grant_type": "",
|
|
152
|
+
"auth_request_datatype": "",
|
|
153
|
+
"auth_response_datatype": "",
|
|
154
|
+
"token_response_placement": "",
|
|
152
155
|
"sensitive": [],
|
|
153
156
|
"sso": {
|
|
154
157
|
"protocol": "",
|
package/adapter.js
CHANGED
|
@@ -13351,6 +13351,642 @@ class ParagonPathfinder extends AdapterBaseCl {
|
|
|
13351
13351
|
return callback(null, errorObj);
|
|
13352
13352
|
}
|
|
13353
13353
|
}
|
|
13354
|
+
|
|
13355
|
+
/**
|
|
13356
|
+
* @function authenticationToken
|
|
13357
|
+
* @pronghornType method
|
|
13358
|
+
* @name authenticationToken
|
|
13359
|
+
* @summary The parameters and request body are for method: authenticationToken. Same endpoint also used in met
|
|
13360
|
+
*
|
|
13361
|
+
* @param {object} [body] - indeterminate body object
|
|
13362
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
13363
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
13364
|
+
* @return {object} results - An object containing the response of the action
|
|
13365
|
+
*
|
|
13366
|
+
* @route {POST} /authenticationToken
|
|
13367
|
+
* @roles admin
|
|
13368
|
+
* @task true
|
|
13369
|
+
*/
|
|
13370
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
13371
|
+
authenticationToken(body, iapMetadata, callback) {
|
|
13372
|
+
const meth = 'adapter-authenticationToken';
|
|
13373
|
+
const origin = `${this.id}-${meth}`;
|
|
13374
|
+
log.trace(origin);
|
|
13375
|
+
|
|
13376
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
13377
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
13378
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13379
|
+
return callback(null, errorObj);
|
|
13380
|
+
}
|
|
13381
|
+
|
|
13382
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
13383
|
+
|
|
13384
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
13385
|
+
const queryParamsAvailable = {};
|
|
13386
|
+
const queryParams = {};
|
|
13387
|
+
const pathVars = [];
|
|
13388
|
+
const bodyVars = body;
|
|
13389
|
+
|
|
13390
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
13391
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
13392
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
13393
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
13394
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
13395
|
+
}
|
|
13396
|
+
});
|
|
13397
|
+
|
|
13398
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
13399
|
+
// see adapter code documentation for more information on the request object's fields
|
|
13400
|
+
const reqObj = {
|
|
13401
|
+
payload: bodyVars,
|
|
13402
|
+
uriPathVars: pathVars,
|
|
13403
|
+
uriQuery: queryParams
|
|
13404
|
+
};
|
|
13405
|
+
|
|
13406
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
13407
|
+
|
|
13408
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
13409
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
13410
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
13411
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
13412
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
13413
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
13414
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
13415
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
13416
|
+
} else {
|
|
13417
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
13418
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
13419
|
+
}
|
|
13420
|
+
}
|
|
13421
|
+
});
|
|
13422
|
+
// Add iapMetadata to reqObj for further work
|
|
13423
|
+
reqObj.iapMetadata = iapMetadata;
|
|
13424
|
+
}
|
|
13425
|
+
|
|
13426
|
+
try {
|
|
13427
|
+
// Make the call -
|
|
13428
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
13429
|
+
return this.requestHandlerInst.identifyRequest('Authentication', 'authenticationToken', reqObj, true, (irReturnData, irReturnError) => {
|
|
13430
|
+
// if we received an error or their is no response on the results
|
|
13431
|
+
// return an error
|
|
13432
|
+
if (irReturnError) {
|
|
13433
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
13434
|
+
return callback(null, irReturnError);
|
|
13435
|
+
}
|
|
13436
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
13437
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['authenticationToken'], null, null, null);
|
|
13438
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13439
|
+
return callback(null, errorObj);
|
|
13440
|
+
}
|
|
13441
|
+
|
|
13442
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
13443
|
+
// return the response
|
|
13444
|
+
return callback(irReturnData, null);
|
|
13445
|
+
});
|
|
13446
|
+
} catch (ex) {
|
|
13447
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
13448
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13449
|
+
return callback(null, errorObj);
|
|
13450
|
+
}
|
|
13451
|
+
}
|
|
13452
|
+
|
|
13453
|
+
/**
|
|
13454
|
+
* @function searchLinks
|
|
13455
|
+
* @pronghornType method
|
|
13456
|
+
* @name searchLinks
|
|
13457
|
+
* @summary The parameters and request body are for method: searchLinks. Same endpoint also used in methods:
|
|
13458
|
+
*
|
|
13459
|
+
* @param {string} topologyId - topologyId param
|
|
13460
|
+
* @param {object} [body] - body param
|
|
13461
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
13462
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
13463
|
+
* @return {object} results - An object containing the response of the action
|
|
13464
|
+
*
|
|
13465
|
+
* @route {POST} /searchLinks
|
|
13466
|
+
* @roles admin
|
|
13467
|
+
* @task true
|
|
13468
|
+
*/
|
|
13469
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
13470
|
+
searchLinks(topologyId, body, iapMetadata, callback) {
|
|
13471
|
+
const meth = 'adapter-searchLinks';
|
|
13472
|
+
const origin = `${this.id}-${meth}`;
|
|
13473
|
+
log.trace(origin);
|
|
13474
|
+
|
|
13475
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
13476
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
13477
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13478
|
+
return callback(null, errorObj);
|
|
13479
|
+
}
|
|
13480
|
+
|
|
13481
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
13482
|
+
if (topologyId === undefined || topologyId === null || topologyId === '') {
|
|
13483
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['topologyId'], null, null, null);
|
|
13484
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13485
|
+
return callback(null, errorObj);
|
|
13486
|
+
}
|
|
13487
|
+
|
|
13488
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
13489
|
+
const queryParamsAvailable = {};
|
|
13490
|
+
const queryParams = {};
|
|
13491
|
+
const pathVars = [topologyId];
|
|
13492
|
+
const bodyVars = body;
|
|
13493
|
+
|
|
13494
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
13495
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
13496
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
13497
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
13498
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
13499
|
+
}
|
|
13500
|
+
});
|
|
13501
|
+
|
|
13502
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
13503
|
+
// see adapter code documentation for more information on the request object's fields
|
|
13504
|
+
const reqObj = {
|
|
13505
|
+
payload: bodyVars,
|
|
13506
|
+
uriPathVars: pathVars,
|
|
13507
|
+
uriQuery: queryParams
|
|
13508
|
+
};
|
|
13509
|
+
|
|
13510
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
13511
|
+
|
|
13512
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
13513
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
13514
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
13515
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
13516
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
13517
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
13518
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
13519
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
13520
|
+
} else {
|
|
13521
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
13522
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
13523
|
+
}
|
|
13524
|
+
}
|
|
13525
|
+
});
|
|
13526
|
+
// Add iapMetadata to reqObj for further work
|
|
13527
|
+
reqObj.iapMetadata = iapMetadata;
|
|
13528
|
+
}
|
|
13529
|
+
|
|
13530
|
+
try {
|
|
13531
|
+
// Make the call -
|
|
13532
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
13533
|
+
return this.requestHandlerInst.identifyRequest('Links', 'searchLinks', reqObj, true, (irReturnData, irReturnError) => {
|
|
13534
|
+
// if we received an error or their is no response on the results
|
|
13535
|
+
// return an error
|
|
13536
|
+
if (irReturnError) {
|
|
13537
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
13538
|
+
return callback(null, irReturnError);
|
|
13539
|
+
}
|
|
13540
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
13541
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['searchLinks'], null, null, null);
|
|
13542
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13543
|
+
return callback(null, errorObj);
|
|
13544
|
+
}
|
|
13545
|
+
|
|
13546
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
13547
|
+
// return the response
|
|
13548
|
+
return callback(irReturnData, null);
|
|
13549
|
+
});
|
|
13550
|
+
} catch (ex) {
|
|
13551
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
13552
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13553
|
+
return callback(null, errorObj);
|
|
13554
|
+
}
|
|
13555
|
+
}
|
|
13556
|
+
|
|
13557
|
+
/**
|
|
13558
|
+
* @function patchLink
|
|
13559
|
+
* @pronghornType method
|
|
13560
|
+
* @name patchLink
|
|
13561
|
+
* @summary The parameters and request body are for method: patchLink. Same endpoint also used in methods:
|
|
13562
|
+
*
|
|
13563
|
+
* @param {string} topologyId - topologyId param
|
|
13564
|
+
* @param {string} linkIndex - linkIndex param
|
|
13565
|
+
* @param {object} [body] - body param
|
|
13566
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
13567
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
13568
|
+
* @return {object} results - An object containing the response of the action
|
|
13569
|
+
*
|
|
13570
|
+
* @route {POST} /patchLink
|
|
13571
|
+
* @roles admin
|
|
13572
|
+
* @task true
|
|
13573
|
+
*/
|
|
13574
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
13575
|
+
patchLink(topologyId, linkIndex, body, iapMetadata, callback) {
|
|
13576
|
+
const meth = 'adapter-patchLink';
|
|
13577
|
+
const origin = `${this.id}-${meth}`;
|
|
13578
|
+
log.trace(origin);
|
|
13579
|
+
|
|
13580
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
13581
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
13582
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13583
|
+
return callback(null, errorObj);
|
|
13584
|
+
}
|
|
13585
|
+
|
|
13586
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
13587
|
+
if (topologyId === undefined || topologyId === null || topologyId === '') {
|
|
13588
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['topologyId'], null, null, null);
|
|
13589
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13590
|
+
return callback(null, errorObj);
|
|
13591
|
+
}
|
|
13592
|
+
if (linkIndex === undefined || linkIndex === null || linkIndex === '') {
|
|
13593
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['linkIndex'], null, null, null);
|
|
13594
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13595
|
+
return callback(null, errorObj);
|
|
13596
|
+
}
|
|
13597
|
+
|
|
13598
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
13599
|
+
const queryParamsAvailable = {};
|
|
13600
|
+
const queryParams = {};
|
|
13601
|
+
const pathVars = [topologyId, linkIndex];
|
|
13602
|
+
const bodyVars = body;
|
|
13603
|
+
|
|
13604
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
13605
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
13606
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
13607
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
13608
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
13609
|
+
}
|
|
13610
|
+
});
|
|
13611
|
+
|
|
13612
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
13613
|
+
// see adapter code documentation for more information on the request object's fields
|
|
13614
|
+
const reqObj = {
|
|
13615
|
+
payload: bodyVars,
|
|
13616
|
+
uriPathVars: pathVars,
|
|
13617
|
+
uriQuery: queryParams
|
|
13618
|
+
};
|
|
13619
|
+
|
|
13620
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
13621
|
+
|
|
13622
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
13623
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
13624
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
13625
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
13626
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
13627
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
13628
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
13629
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
13630
|
+
} else {
|
|
13631
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
13632
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
13633
|
+
}
|
|
13634
|
+
}
|
|
13635
|
+
});
|
|
13636
|
+
// Add iapMetadata to reqObj for further work
|
|
13637
|
+
reqObj.iapMetadata = iapMetadata;
|
|
13638
|
+
}
|
|
13639
|
+
|
|
13640
|
+
try {
|
|
13641
|
+
// Make the call -
|
|
13642
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
13643
|
+
return this.requestHandlerInst.identifyRequest('Links', 'patchLink', reqObj, true, (irReturnData, irReturnError) => {
|
|
13644
|
+
// if we received an error or their is no response on the results
|
|
13645
|
+
// return an error
|
|
13646
|
+
if (irReturnError) {
|
|
13647
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
13648
|
+
return callback(null, irReturnError);
|
|
13649
|
+
}
|
|
13650
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
13651
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchLink'], null, null, null);
|
|
13652
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13653
|
+
return callback(null, errorObj);
|
|
13654
|
+
}
|
|
13655
|
+
|
|
13656
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
13657
|
+
// return the response
|
|
13658
|
+
return callback(irReturnData, null);
|
|
13659
|
+
});
|
|
13660
|
+
} catch (ex) {
|
|
13661
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
13662
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13663
|
+
return callback(null, errorObj);
|
|
13664
|
+
}
|
|
13665
|
+
}
|
|
13666
|
+
|
|
13667
|
+
/**
|
|
13668
|
+
* @function searchLSPs
|
|
13669
|
+
* @pronghornType method
|
|
13670
|
+
* @name searchLSPs
|
|
13671
|
+
* @summary The parameters and request body are for method: searchLSPs. Same endpoint also used in methods:
|
|
13672
|
+
*
|
|
13673
|
+
* @param {string} topologyId - topologyId param
|
|
13674
|
+
* @param {object} [body] - body param
|
|
13675
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
13676
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
13677
|
+
* @return {object} results - An object containing the response of the action
|
|
13678
|
+
*
|
|
13679
|
+
* @route {POST} /searchLSPs
|
|
13680
|
+
* @roles admin
|
|
13681
|
+
* @task true
|
|
13682
|
+
*/
|
|
13683
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
13684
|
+
searchLSPs(topologyId, body, iapMetadata, callback) {
|
|
13685
|
+
const meth = 'adapter-searchLSPs';
|
|
13686
|
+
const origin = `${this.id}-${meth}`;
|
|
13687
|
+
log.trace(origin);
|
|
13688
|
+
|
|
13689
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
13690
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
13691
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13692
|
+
return callback(null, errorObj);
|
|
13693
|
+
}
|
|
13694
|
+
|
|
13695
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
13696
|
+
if (topologyId === undefined || topologyId === null || topologyId === '') {
|
|
13697
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['topologyId'], null, null, null);
|
|
13698
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13699
|
+
return callback(null, errorObj);
|
|
13700
|
+
}
|
|
13701
|
+
|
|
13702
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
13703
|
+
const queryParamsAvailable = {};
|
|
13704
|
+
const queryParams = {};
|
|
13705
|
+
const pathVars = [topologyId];
|
|
13706
|
+
const bodyVars = body;
|
|
13707
|
+
|
|
13708
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
13709
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
13710
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
13711
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
13712
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
13713
|
+
}
|
|
13714
|
+
});
|
|
13715
|
+
|
|
13716
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
13717
|
+
// see adapter code documentation for more information on the request object's fields
|
|
13718
|
+
const reqObj = {
|
|
13719
|
+
payload: bodyVars,
|
|
13720
|
+
uriPathVars: pathVars,
|
|
13721
|
+
uriQuery: queryParams
|
|
13722
|
+
};
|
|
13723
|
+
|
|
13724
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
13725
|
+
|
|
13726
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
13727
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
13728
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
13729
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
13730
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
13731
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
13732
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
13733
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
13734
|
+
} else {
|
|
13735
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
13736
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
13737
|
+
}
|
|
13738
|
+
}
|
|
13739
|
+
});
|
|
13740
|
+
// Add iapMetadata to reqObj for further work
|
|
13741
|
+
reqObj.iapMetadata = iapMetadata;
|
|
13742
|
+
}
|
|
13743
|
+
|
|
13744
|
+
try {
|
|
13745
|
+
// Make the call -
|
|
13746
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
13747
|
+
return this.requestHandlerInst.identifyRequest('TELSPs', 'searchLSPs', reqObj, true, (irReturnData, irReturnError) => {
|
|
13748
|
+
// if we received an error or their is no response on the results
|
|
13749
|
+
// return an error
|
|
13750
|
+
if (irReturnError) {
|
|
13751
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
13752
|
+
return callback(null, irReturnError);
|
|
13753
|
+
}
|
|
13754
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
13755
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['searchLSPs'], null, null, null);
|
|
13756
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13757
|
+
return callback(null, errorObj);
|
|
13758
|
+
}
|
|
13759
|
+
|
|
13760
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
13761
|
+
// return the response
|
|
13762
|
+
return callback(irReturnData, null);
|
|
13763
|
+
});
|
|
13764
|
+
} catch (ex) {
|
|
13765
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
13766
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13767
|
+
return callback(null, errorObj);
|
|
13768
|
+
}
|
|
13769
|
+
}
|
|
13770
|
+
|
|
13771
|
+
/**
|
|
13772
|
+
* @function patchATELSP
|
|
13773
|
+
* @pronghornType method
|
|
13774
|
+
* @name patchATELSP
|
|
13775
|
+
* @summary The parameters and request body are for method: patchATELSP. Same endpoint also used in methods:
|
|
13776
|
+
*
|
|
13777
|
+
* @param {string} topologyId - topologyId param
|
|
13778
|
+
* @param {string} lspIndex - lspIndex param
|
|
13779
|
+
* @param {object} [body] - body param
|
|
13780
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
13781
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
13782
|
+
* @return {object} results - An object containing the response of the action
|
|
13783
|
+
*
|
|
13784
|
+
* @route {POST} /patchATELSP
|
|
13785
|
+
* @roles admin
|
|
13786
|
+
* @task true
|
|
13787
|
+
*/
|
|
13788
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
13789
|
+
patchATELSP(topologyId, lspIndex, body, iapMetadata, callback) {
|
|
13790
|
+
const meth = 'adapter-patchATELSP';
|
|
13791
|
+
const origin = `${this.id}-${meth}`;
|
|
13792
|
+
log.trace(origin);
|
|
13793
|
+
|
|
13794
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
13795
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
13796
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13797
|
+
return callback(null, errorObj);
|
|
13798
|
+
}
|
|
13799
|
+
|
|
13800
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
13801
|
+
if (topologyId === undefined || topologyId === null || topologyId === '') {
|
|
13802
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['topologyId'], null, null, null);
|
|
13803
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13804
|
+
return callback(null, errorObj);
|
|
13805
|
+
}
|
|
13806
|
+
if (lspIndex === undefined || lspIndex === null || lspIndex === '') {
|
|
13807
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['lspIndex'], null, null, null);
|
|
13808
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13809
|
+
return callback(null, errorObj);
|
|
13810
|
+
}
|
|
13811
|
+
|
|
13812
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
13813
|
+
const queryParamsAvailable = {};
|
|
13814
|
+
const queryParams = {};
|
|
13815
|
+
const pathVars = [topologyId, lspIndex];
|
|
13816
|
+
const bodyVars = body;
|
|
13817
|
+
|
|
13818
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
13819
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
13820
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
13821
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
13822
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
13823
|
+
}
|
|
13824
|
+
});
|
|
13825
|
+
|
|
13826
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
13827
|
+
// see adapter code documentation for more information on the request object's fields
|
|
13828
|
+
const reqObj = {
|
|
13829
|
+
payload: bodyVars,
|
|
13830
|
+
uriPathVars: pathVars,
|
|
13831
|
+
uriQuery: queryParams
|
|
13832
|
+
};
|
|
13833
|
+
|
|
13834
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
13835
|
+
|
|
13836
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
13837
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
13838
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
13839
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
13840
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
13841
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
13842
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
13843
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
13844
|
+
} else {
|
|
13845
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
13846
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
13847
|
+
}
|
|
13848
|
+
}
|
|
13849
|
+
});
|
|
13850
|
+
// Add iapMetadata to reqObj for further work
|
|
13851
|
+
reqObj.iapMetadata = iapMetadata;
|
|
13852
|
+
}
|
|
13853
|
+
|
|
13854
|
+
try {
|
|
13855
|
+
// Make the call -
|
|
13856
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
13857
|
+
return this.requestHandlerInst.identifyRequest('TELSPs', 'patchATELSP', reqObj, true, (irReturnData, irReturnError) => {
|
|
13858
|
+
// if we received an error or their is no response on the results
|
|
13859
|
+
// return an error
|
|
13860
|
+
if (irReturnError) {
|
|
13861
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
13862
|
+
return callback(null, irReturnError);
|
|
13863
|
+
}
|
|
13864
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
13865
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchATELSP'], null, null, null);
|
|
13866
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13867
|
+
return callback(null, errorObj);
|
|
13868
|
+
}
|
|
13869
|
+
|
|
13870
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
13871
|
+
// return the response
|
|
13872
|
+
return callback(irReturnData, null);
|
|
13873
|
+
});
|
|
13874
|
+
} catch (ex) {
|
|
13875
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
13876
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13877
|
+
return callback(null, errorObj);
|
|
13878
|
+
}
|
|
13879
|
+
}
|
|
13880
|
+
|
|
13881
|
+
/**
|
|
13882
|
+
* @function deleteATELSP
|
|
13883
|
+
* @pronghornType method
|
|
13884
|
+
* @name deleteATELSP
|
|
13885
|
+
* @summary The parameters and request body are for method: deleteATELSP. Same endpoint also used in methods:
|
|
13886
|
+
*
|
|
13887
|
+
* @param {string} topologyId - topologyId param
|
|
13888
|
+
* @param {string} lspIndex - lspIndex param
|
|
13889
|
+
* @param {object} [body] - body param
|
|
13890
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
13891
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
13892
|
+
* @return {object} results - An object containing the response of the action
|
|
13893
|
+
*
|
|
13894
|
+
* @route {POST} /deleteATELSP
|
|
13895
|
+
* @roles admin
|
|
13896
|
+
* @task true
|
|
13897
|
+
*/
|
|
13898
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
13899
|
+
deleteATELSP(topologyId, lspIndex, body, iapMetadata, callback) {
|
|
13900
|
+
const meth = 'adapter-deleteATELSP';
|
|
13901
|
+
const origin = `${this.id}-${meth}`;
|
|
13902
|
+
log.trace(origin);
|
|
13903
|
+
|
|
13904
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
13905
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
13906
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13907
|
+
return callback(null, errorObj);
|
|
13908
|
+
}
|
|
13909
|
+
|
|
13910
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
13911
|
+
if (topologyId === undefined || topologyId === null || topologyId === '') {
|
|
13912
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['topologyId'], null, null, null);
|
|
13913
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13914
|
+
return callback(null, errorObj);
|
|
13915
|
+
}
|
|
13916
|
+
if (lspIndex === undefined || lspIndex === null || lspIndex === '') {
|
|
13917
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['lspIndex'], null, null, null);
|
|
13918
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13919
|
+
return callback(null, errorObj);
|
|
13920
|
+
}
|
|
13921
|
+
|
|
13922
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
13923
|
+
const queryParamsAvailable = {};
|
|
13924
|
+
const queryParams = {};
|
|
13925
|
+
const pathVars = [topologyId, lspIndex];
|
|
13926
|
+
const bodyVars = body;
|
|
13927
|
+
|
|
13928
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
13929
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
13930
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
13931
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
13932
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
13933
|
+
}
|
|
13934
|
+
});
|
|
13935
|
+
|
|
13936
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
13937
|
+
// see adapter code documentation for more information on the request object's fields
|
|
13938
|
+
const reqObj = {
|
|
13939
|
+
payload: bodyVars,
|
|
13940
|
+
uriPathVars: pathVars,
|
|
13941
|
+
uriQuery: queryParams
|
|
13942
|
+
};
|
|
13943
|
+
|
|
13944
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
13945
|
+
|
|
13946
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
13947
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
13948
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
13949
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
13950
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
13951
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
13952
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
13953
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
13954
|
+
} else {
|
|
13955
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
13956
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
13957
|
+
}
|
|
13958
|
+
}
|
|
13959
|
+
});
|
|
13960
|
+
// Add iapMetadata to reqObj for further work
|
|
13961
|
+
reqObj.iapMetadata = iapMetadata;
|
|
13962
|
+
}
|
|
13963
|
+
|
|
13964
|
+
try {
|
|
13965
|
+
// Make the call -
|
|
13966
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
13967
|
+
return this.requestHandlerInst.identifyRequest('TELSPs', 'deleteATELSP', reqObj, false, (irReturnData, irReturnError) => {
|
|
13968
|
+
// if we received an error or their is no response on the results
|
|
13969
|
+
// return an error
|
|
13970
|
+
if (irReturnError) {
|
|
13971
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
13972
|
+
return callback(null, irReturnError);
|
|
13973
|
+
}
|
|
13974
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
13975
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteATELSP'], null, null, null);
|
|
13976
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13977
|
+
return callback(null, errorObj);
|
|
13978
|
+
}
|
|
13979
|
+
|
|
13980
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
13981
|
+
// return the response
|
|
13982
|
+
return callback(irReturnData, null);
|
|
13983
|
+
});
|
|
13984
|
+
} catch (ex) {
|
|
13985
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
13986
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
13987
|
+
return callback(null, errorObj);
|
|
13988
|
+
}
|
|
13989
|
+
}
|
|
13354
13990
|
}
|
|
13355
13991
|
|
|
13356
13992
|
module.exports = ParagonPathfinder;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"actions": [
|
|
3
|
+
{
|
|
4
|
+
"name": "authenticationToken",
|
|
5
|
+
"protocol": "REST",
|
|
6
|
+
"method": "POST",
|
|
7
|
+
"entitypath": "{base_path}/{version}/iam/authenticate?{query}",
|
|
8
|
+
"requestSchema": "schema.json",
|
|
9
|
+
"responseSchema": "schema.json",
|
|
10
|
+
"timeout": 0,
|
|
11
|
+
"sendEmpty": false,
|
|
12
|
+
"requestDatatype": "JSON",
|
|
13
|
+
"responseDatatype": "JSON",
|
|
14
|
+
"headers": {},
|
|
15
|
+
"responseObjects": [
|
|
16
|
+
{
|
|
17
|
+
"type": "default",
|
|
18
|
+
"key": "",
|
|
19
|
+
"mockFile": ""
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|