UNPKG

@itentialopensource/adapter-velocloud

Version:

[Deprecated] This adapter integrates with system Velocloud

1,192 lines (1,063 loc) 424 kB
/* @copyright Itential, LLC 2019 */ /* eslint import/no-dynamic-require: warn */ /* eslint object-curly-newline: warn */ /* eslint no-underscore-dangle: warn */ /* eslint camelcase: warn */ // Set globals /* global log */ /* Required libraries. */ const path = require('path'); // const xmldom = require('xmldom'); /* Fetch in the other needed components for the this Adaptor */ const AdapterBaseCl = require(path.join(__dirname, 'adapterBase.js')); /* * INTERNAL FUNCTION: return stub results based on the path and method */ function setBodyObject(method, body) { const bodyObj = { jsonrpc: '2.0', method, id: 1, params: body }; return bodyObj; } /** * This is the adapter/interface into Velocloud */ /* GENERAL ADAPTER FUNCTIONS */ class Velocloud extends AdapterBaseCl { /** * Velocloud Adapter * @constructor constructor(prongid, properties) { // Instantiate the AdapterBase super class super(prongid, properties); // Uncomment if you have things to add to the constructor like using your own properties. // Otherwise the constructor in the adapterBase will be used. // Capture my own properties - they need to be defined in propertiesSchema.json if (this.allProps && this.allProps.myownproperty) { mypropvariable = this.allProps.myownproperty; } } */ /** * @callback healthCallback * @param {Object} result - the result of the get request (contains an id and a status) */ /** * @callback getCallback * @param {Object} result - the result of the get request (entity/ies) * @param {String} error - any error that occurred */ /** * @callback createCallback * @param {Object} item - the newly created entity * @param {String} error - any error that occurred */ /** * @callback updateCallback * @param {String} status - the status of the update action * @param {String} error - any error that occurred */ /** * @callback deleteCallback * @param {String} status - the status of the delete action * @param {String} error - any error that occurred */ /** * @summary Determines if this adapter supports the specific entity * * @function hasEntity * @param {String} entityType - the entity type to check for * @param {String/Array} entityId - the specific entity we are looking for * * @param {Callback} callback - An array of whether the adapter can has the * desired capability or an error */ hasEntity(entityType, entityId, callback) { const origin = `${this.id}-adapter-hasEntity`; log.trace(origin); // Make the call - // verifyCapability(entityType, actionType, entityId, callback) return this.verifyCapability(entityType, null, entityId, callback); } /** * @summary Provides a way for the adapter to tell north bound integrations * whether the adapter supports type, action and specific entity * * @function verifyCapability * @param {String} entityType - the entity type to check for * @param {String} actionType - the action type to check for * @param {String/Array} entityId - the specific entity we are looking for * * @param {Callback} callback - An array of whether the adapter can has the * desired capability or an error */ verifyCapability(entityType, actionType, entityId, callback) { const meth = 'adapterBase-verifyCapability'; const origin = `${this.id}-${meth}`; log.trace(origin); // if caching if (this.caching) { // Make the call - verifyCapability(entityType, actionType, entityId, callback) return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (results, error) => { if (error) { return callback(null, error); } // if the cache needs to be updated, update and try again if (results && results[0] === 'needupdate') { switch (entityType) { case 'template_entity': { // if the cache is invalid, update the cache return this.getEntities(null, null, null, null, (data, err) => { if (err) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } // need to check the cache again since it has been updated return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (vcapable, verror) => { if (verror) { return callback(null, verror); } return this.capabilityResults(vcapable, callback); }); }); } default: { // unsupported entity type const result = [false]; // put false in array for all entities if (Array.isArray(entityId)) { for (let e = 1; e < entityId.length; e += 1) { result.push(false); } } return callback(result); } } } // return the results return this.capabilityResults(results, callback); }); } // if no entity id if (!entityId) { // need to check the cache again since it has been updated return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => { if (verror) { return callback(null, verror); } return this.capabilityResults(vcapable, callback); }); } // if not caching switch (entityType) { case 'template_entity': { // need to get the entities to check return this.getEntities(null, null, null, null, (data, err) => { if (err) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } // need to check the cache again since it has been updated return this.requestHandlerInst.verifyCapability(entityType, actionType, null, (vcapable, verror) => { if (verror) { return callback(null, verror); } // is the entity in the list? const isEntity = this.entityInList(entityId, data.response, callback); const res = []; // not found for (let i = 0; i < isEntity.length; i += 1) { if (vcapable) { res.push(isEntity[i]); } else { res.push(false); } } return callback(res); }); }); } default: { // unsupported entity type const result = [false]; // put false in array for all entities if (Array.isArray(entityId)) { for (let e = 1; e < entityId.length; e += 1) { result.push(false); } } return callback(result); } } } /** * @summary Updates the cache for all entities by call the get All entity method * * @function updateEntityCache * */ updateEntityCache() { const origin = `${this.id}-adapter-updateEntityCache`; log.trace(origin); if (this.caching) { // if the cache is invalid, update the cache this.getEntities(null, null, null, null, (data, err) => { if (err) { log.trace(`${origin}: Could not load template_entity into cache - ${err}`); } }); } } /** * @summary Authentication for an operator user * * @function postLoginoperatorLogin * @param {object} authorization - authorization param * @param {getCallback} callback - a callback function to return the result */ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */ postLoginoperatorLogin(authorization, callback) { const meth = 'adapter-postLoginoperatorLogin'; const origin = `${this.id}-${meth}`; log.trace(origin); /* HERE IS WHERE YOU VALIDATE DATA */ if (authorization === undefined || authorization === null || authorization === '') { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['authorization'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */ const queryParamsAvailable = {}; const queryParams = {}; const pathVars = []; const bodyVars = authorization; // loop in template. long callback arg name to avoid identifier conflicts Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => { if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') { queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable]; } }); // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders const reqObj = { payload: bodyVars, uriPathVars: pathVars, uriQuery: queryParams }; try { // Make the call - // identifyRequest(entity, action, requestObj, returnDataFlag, callback) return this.requestHandlerInst.identifyRequest('All', 'postLoginoperatorLogin', reqObj, true, (irReturnData, irReturnError) => { // if we received an error or their is no response on the results // return an error if (irReturnError) { /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */ return callback(null, irReturnError); } if (!Object.hasOwnProperty.call(irReturnData, 'response')) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postLoginoperatorLogin'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */ // return the response return callback(irReturnData, null); }); } catch (ex) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } } /** * @summary Authentication for non-operator users * * @function postLoginenterpriseLogin * @param {object} authorization - authorization param * @param {getCallback} callback - a callback function to return the result */ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */ postLoginenterpriseLogin(authorization, callback) { const meth = 'adapter-postLoginenterpriseLogin'; const origin = `${this.id}-${meth}`; log.trace(origin); /* HERE IS WHERE YOU VALIDATE DATA */ if (authorization === undefined || authorization === null || authorization === '') { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['authorization'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */ const queryParamsAvailable = {}; const queryParams = {}; const pathVars = []; const bodyVars = authorization; // loop in template. long callback arg name to avoid identifier conflicts Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => { if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') { queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable]; } }); // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders const reqObj = { payload: bodyVars, uriPathVars: pathVars, uriQuery: queryParams }; try { // Make the call - // identifyRequest(entity, action, requestObj, returnDataFlag, callback) return this.requestHandlerInst.identifyRequest('All', 'postLoginenterpriseLogin', reqObj, true, (irReturnData, irReturnError) => { // if we received an error or their is no response on the results // return an error if (irReturnError) { /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */ return callback(null, irReturnError); } if (!Object.hasOwnProperty.call(irReturnData, 'response')) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postLoginenterpriseLogin'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */ // return the response return callback(irReturnData, null); }); } catch (ex) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } } /** * @summary Deactivate a given authorization cookie * * @function postLogout * @param {getCallback} callback - a callback function to return the result */ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */ postLogout(callback) { const meth = 'adapter-postLogout'; const origin = `${this.id}-${meth}`; log.trace(origin); /* HERE IS WHERE YOU VALIDATE DATA */ /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */ // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders const reqObj = null; try { // Make the call - // identifyRequest(entity, action, requestObj, returnDataFlag, callback) return this.requestHandlerInst.identifyRequest('All', 'postLogout', reqObj, true, (irReturnData, irReturnError) => { // if we received an error or their is no response on the results // return an error if (irReturnError) { /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */ return callback(null, irReturnError); } if (!Object.hasOwnProperty.call(irReturnData, 'response')) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postLogout'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */ // return the response return callback(irReturnData, null); }); } catch (ex) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } } /** * @summary Get meta-data on any other API call * * @function postMetaapiPath * @param {string} apiPath - the path to another api method, starting after \/rest\/ * @param {getCallback} callback - a callback function to return the result */ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */ postMetaapiPath(apiPath, callback) { const meth = 'adapter-postMetaapiPath'; const origin = `${this.id}-${meth}`; log.trace(origin); /* HERE IS WHERE YOU VALIDATE DATA */ if (apiPath === undefined || apiPath === null || apiPath === '') { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['apiPath'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */ const queryParamsAvailable = {}; const queryParams = {}; const pathVars = [apiPath]; const bodyVars = {}; // loop in template. long callback arg name to avoid identifier conflicts Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => { if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') { queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable]; } }); // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders const reqObj = { payload: bodyVars, uriPathVars: pathVars, uriQuery: queryParams }; try { // Make the call - // identifyRequest(entity, action, requestObj, returnDataFlag, callback) return this.requestHandlerInst.identifyRequest('All', 'postMetaapiPath', reqObj, true, (irReturnData, irReturnError) => { // if we received an error or their is no response on the results // return an error if (irReturnError) { /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */ return callback(null, irReturnError); } if (!Object.hasOwnProperty.call(irReturnData, 'response')) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postMetaapiPath'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */ // return the response return callback(irReturnData, null); }); } catch (ex) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } } /** * @summary Clone the default enterprise configuration profile * * @function postConfigurationcloneEnterpriseTemplate * @param {object} body - body param * @param {getCallback} callback - a callback function to return the result */ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */ postConfigurationcloneEnterpriseTemplate(body, callback) { const meth = 'adapter-postConfigurationcloneEnterpriseTemplate'; const origin = `${this.id}-${meth}`; log.trace(origin); /* HERE IS WHERE YOU VALIDATE DATA */ if (body === undefined || body === null || body === '') { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */ const queryParamsAvailable = {}; const queryParams = {}; const pathVars = []; const bodyVars = setBodyObject('configuration/cloneEnterpriseTemplate', body); // loop in template. long callback arg name to avoid identifier conflicts Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => { if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') { queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable]; } }); // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders const reqObj = { payload: bodyVars, uriPathVars: pathVars, uriQuery: queryParams }; try { // Make the call - // identifyRequest(entity, action, requestObj, returnDataFlag, callback) return this.requestHandlerInst.identifyRequest('Portal', 'genericRequest', reqObj, true, (irReturnData, irReturnError) => { // if we received an error or their is no response on the results // return an error if (irReturnError) { /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */ return callback(null, irReturnError); } if (!Object.hasOwnProperty.call(irReturnData, 'response')) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postConfigurationcloneEnterpriseTemplate'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */ // return the response return callback(irReturnData, null); }); } catch (ex) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } } /** * @summary Delete a configuration profile * * @function postConfigurationdeleteConfiguration * @param {object} body - body param * @param {getCallback} callback - a callback function to return the result */ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */ postConfigurationdeleteConfiguration(body, callback) { const meth = 'adapter-postConfigurationdeleteConfiguration'; const origin = `${this.id}-${meth}`; log.trace(origin); /* HERE IS WHERE YOU VALIDATE DATA */ if (body === undefined || body === null || body === '') { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */ const queryParamsAvailable = {}; const queryParams = {}; const pathVars = []; const bodyVars = setBodyObject('configuration/deleteConfiguration', body); // loop in template. long callback arg name to avoid identifier conflicts Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => { if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') { queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable]; } }); // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders const reqObj = { payload: bodyVars, uriPathVars: pathVars, uriQuery: queryParams }; try { // Make the call - // identifyRequest(entity, action, requestObj, returnDataFlag, callback) return this.requestHandlerInst.identifyRequest('Portal', 'genericRequest', reqObj, true, (irReturnData, irReturnError) => { // if we received an error or their is no response on the results // return an error if (irReturnError) { /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */ return callback(null, irReturnError); } if (!Object.hasOwnProperty.call(irReturnData, 'response')) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postConfigurationdeleteConfiguration'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */ // return the response return callback(irReturnData, null); }); } catch (ex) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } } /** * @summary Get a configuration profile * * @function postConfigurationgetConfiguration * @param {object} body - body param * @param {getCallback} callback - a callback function to return the result */ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */ postConfigurationgetConfiguration(body, callback) { const meth = 'adapter-postConfigurationgetConfiguration'; const origin = `${this.id}-${meth}`; log.trace(origin); /* HERE IS WHERE YOU VALIDATE DATA */ if (body === undefined || body === null || body === '') { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */ const queryParamsAvailable = {}; const queryParams = {}; const pathVars = []; const bodyVars = setBodyObject('configuration/getConfiguration', body); // loop in template. long callback arg name to avoid identifier conflicts Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => { if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') { queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable]; } }); // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders const reqObj = { payload: bodyVars, uriPathVars: pathVars, uriQuery: queryParams }; try { // Make the call - // identifyRequest(entity, action, requestObj, returnDataFlag, callback) return this.requestHandlerInst.identifyRequest('Portal', 'genericRequest', reqObj, true, (irReturnData, irReturnError) => { // if we received an error or their is no response on the results // return an error if (irReturnError) { /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */ return callback(null, irReturnError); } if (!Object.hasOwnProperty.call(irReturnData, 'response')) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postConfigurationgetConfiguration'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */ // return the response return callback(irReturnData, null); }); } catch (ex) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } } /** * @summary List applications that are first packet routable * * @function postConfigurationgetRoutableApplications * @param {object} body - body param * @param {getCallback} callback - a callback function to return the result */ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */ postConfigurationgetRoutableApplications(body, callback) { const meth = 'adapter-postConfigurationgetRoutableApplications'; const origin = `${this.id}-${meth}`; log.trace(origin); /* HERE IS WHERE YOU VALIDATE DATA */ if (body === undefined || body === null || body === '') { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */ const queryParamsAvailable = {}; const queryParams = {}; const pathVars = []; const bodyVars = setBodyObject('configuration/getRoutableApplications', body); // loop in template. long callback arg name to avoid identifier conflicts Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => { if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') { queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable]; } }); // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders const reqObj = { payload: bodyVars, uriPathVars: pathVars, uriQuery: queryParams }; try { // Make the call - // identifyRequest(entity, action, requestObj, returnDataFlag, callback) return this.requestHandlerInst.identifyRequest('Portal', 'genericRequest', reqObj, true, (irReturnData, irReturnError) => { // if we received an error or their is no response on the results // return an error if (irReturnError) { /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */ return callback(null, irReturnError); } if (!Object.hasOwnProperty.call(irReturnData, 'response')) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postConfigurationgetRoutableApplications'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */ // return the response return callback(irReturnData, null); }); } catch (ex) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } } /** * @summary Designate a standby VCO for disaster recovery replication * * @function postDisasterRecoveryconfigureActiveForReplication * @param {object} body - body param * @param {getCallback} callback - a callback function to return the result */ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */ postDisasterRecoveryconfigureActiveForReplication(body, callback) { const meth = 'adapter-postDisasterRecoveryconfigureActiveForReplication'; const origin = `${this.id}-${meth}`; log.trace(origin); /* HERE IS WHERE YOU VALIDATE DATA */ if (body === undefined || body === null || body === '') { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */ const queryParamsAvailable = {}; const queryParams = {}; const pathVars = []; const bodyVars = setBodyObject('disasterRecovery/configureActiveForReplication', body); // loop in template. long callback arg name to avoid identifier conflicts Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => { if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') { queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable]; } }); // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders const reqObj = { payload: bodyVars, uriPathVars: pathVars, uriQuery: queryParams }; try { // Make the call - // identifyRequest(entity, action, requestObj, returnDataFlag, callback) return this.requestHandlerInst.identifyRequest('Portal', 'genericRequest', reqObj, true, (irReturnData, irReturnError) => { // if we received an error or their is no response on the results // return an error if (irReturnError) { /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */ return callback(null, irReturnError); } if (!Object.hasOwnProperty.call(irReturnData, 'response')) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postDisasterRecoveryconfigureActiveForReplication'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */ // return the response return callback(irReturnData, null); }); } catch (ex) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } } /** * @summary Demote current server from active to zombie * * @function postDisasterRecoverydemoteActive * @param {object} body - body param * @param {getCallback} callback - a callback function to return the result */ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */ postDisasterRecoverydemoteActive(body, callback) { const meth = 'adapter-postDisasterRecoverydemoteActive'; const origin = `${this.id}-${meth}`; log.trace(origin); /* HERE IS WHERE YOU VALIDATE DATA */ if (body === undefined || body === null || body === '') { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */ const queryParamsAvailable = {}; const queryParams = {}; const pathVars = []; const bodyVars = setBodyObject('disasterRecovery/demoteActive', body); // loop in template. long callback arg name to avoid identifier conflicts Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => { if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') { queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable]; } }); // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders const reqObj = { payload: bodyVars, uriPathVars: pathVars, uriQuery: queryParams }; try { // Make the call - // identifyRequest(entity, action, requestObj, returnDataFlag, callback) return this.requestHandlerInst.identifyRequest('Portal', 'genericRequest', reqObj, true, (irReturnData, irReturnError) => { // if we received an error or their is no response on the results // return an error if (irReturnError) { /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */ return callback(null, irReturnError); } if (!Object.hasOwnProperty.call(irReturnData, 'response')) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postDisasterRecoverydemoteActive'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */ // return the response return callback(irReturnData, null); }); } catch (ex) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } } /** * @summary Get the blob needed to configure VCO replication on the standby * * @function postDisasterRecoverygetReplicationBlob * @param {object} body - body param * @param {getCallback} callback - a callback function to return the result */ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */ postDisasterRecoverygetReplicationBlob(body, callback) { const meth = 'adapter-postDisasterRecoverygetReplicationBlob'; const origin = `${this.id}-${meth}`; log.trace(origin); /* HERE IS WHERE YOU VALIDATE DATA */ if (body === undefined || body === null || body === '') { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */ const queryParamsAvailable = {}; const queryParams = {}; const pathVars = []; const bodyVars = setBodyObject('disasterRecovery/getReplicationBlob', body); // loop in template. long callback arg name to avoid identifier conflicts Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => { if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') { queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable]; } }); // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders const reqObj = { payload: bodyVars, uriPathVars: pathVars, uriQuery: queryParams }; try { // Make the call - // identifyRequest(entity, action, requestObj, returnDataFlag, callback) return this.requestHandlerInst.identifyRequest('Portal', 'genericRequest', reqObj, true, (irReturnData, irReturnError) => { // if we received an error or their is no response on the results // return an error if (irReturnError) { /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */ return callback(null, irReturnError); } if (!Object.hasOwnProperty.call(irReturnData, 'response')) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postDisasterRecoverygetReplicationBlob'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */ // return the response return callback(irReturnData, null); }); } catch (ex) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } } /** * @summary Get VCO disaster recovery status * * @function postDisasterRecoverygetReplicationStatus * @param {object} body - body param * @param {getCallback} callback - a callback function to return the result */ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */ postDisasterRecoverygetReplicationStatus(body, callback) { const meth = 'adapter-postDisasterRecoverygetReplicationStatus'; const origin = `${this.id}-${meth}`; log.trace(origin); /* HERE IS WHERE YOU VALIDATE DATA */ if (body === undefined || body === null || body === '') { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */ const queryParamsAvailable = {}; const queryParams = {}; const pathVars = []; const bodyVars = setBodyObject('disasterRecovery/getReplicationStatus', body); // loop in template. long callback arg name to avoid identifier conflicts Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => { if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') { queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable]; } }); // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders const reqObj = { payload: bodyVars, uriPathVars: pathVars, uriQuery: queryParams }; try { // Make the call - // identifyRequest(entity, action, requestObj, returnDataFlag, callback) return this.requestHandlerInst.identifyRequest('Portal', 'genericRequest', reqObj, true, (irReturnData, irReturnError) => { // if we received an error or their is no response on the results // return an error if (irReturnError) { /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */ return callback(null, irReturnError); } if (!Object.hasOwnProperty.call(irReturnData, 'response')) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postDisasterRecoverygetReplicationStatus'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */ // return the response return callback(irReturnData, null); }); } catch (ex) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } } /** * @summary Prepare current VCO to be configured as a standby system * * @function postDisasterRecoveryprepareForStandby * @param {object} body - body param * @param {getCallback} callback - a callback function to return the result */ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */ postDisasterRecoveryprepareForStandby(body, callback) { const meth = 'adapter-postDisasterRecoveryprepareForStandby'; const origin = `${this.id}-${meth}`; log.trace(origin); /* HERE IS WHERE YOU VALIDATE DATA */ if (body === undefined || body === null || body === '') { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */ const queryParamsAvailable = {}; const queryParams = {}; const pathVars = []; const bodyVars = setBodyObject('disasterRecovery/prepareForStandby', body); // loop in template. long callback arg name to avoid identifier conflicts Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => { if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') { queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable]; } }); // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders const reqObj = { payload: bodyVars, uriPathVars: pathVars, uriQuery: queryParams }; try { // Make the call - // identifyRequest(entity, action, requestObj, returnDataFlag, callback) return this.requestHandlerInst.identifyRequest('Portal', 'genericRequest', reqObj, true, (irReturnData, irReturnError) => { // if we received an error or their is no response on the results // return an error if (irReturnError) { /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */ return callback(null, irReturnError); } if (!Object.hasOwnProperty.call(irReturnData, 'response')) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postDisasterRecoveryprepareForStandby'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */ // return the response return callback(irReturnData, null); }); } catch (ex) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } } /** * @summary Promote the current server to take over as the single standalone VCO * * @function postDisasterRecoverypromoteStandbyToActive * @param {object} body - body param * @param {getCallback} callback - a callback function to return the result */ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */ postDisasterRecoverypromoteStandbyToActive(body, callback) { const meth = 'adapter-postDisasterRecoverypromoteStandbyToActive'; const origin = `${this.id}-${meth}`; log.trace(origin); /* HERE IS WHERE YOU VALIDATE DATA */ if (body === undefined || body === null || body === '') { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */ const queryParamsAvailable = {}; const queryParams = {}; const pathVars = []; const bodyVars = setBodyObject('disasterRecovery/promoteStandbyToActive', body); // loop in template. long callback arg name to avoid identifier conflicts Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => { if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') { queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable]; } }); // set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders const reqObj = { payload: bodyVars, uriPathVars: pathVars, uriQuery: queryParams }; try { // Make the call - // identifyRequest(entity, action, requestObj, returnDataFlag, callback) return this.requestHandlerInst.identifyRequest('Portal', 'genericRequest', reqObj, true, (irReturnData, irReturnError) => { // if we received an error or their is no response on the results // return an error if (irReturnError) { /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */ return callback(null, irReturnError); } if (!Object.hasOwnProperty.call(irReturnData, 'response')) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postDisasterRecoverypromoteStandbyToActive'], null, null, null); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */ // return the response return callback(irReturnData, null); }); } catch (ex) { const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex); log.error(`${origin}: ${errorObj.IAPerror.displayString}`); return callback(null, errorObj); } } /** * @summary Unconfigure VCO disaster recovery on the current server * * @function postDisasterRecoveryremoveStandby * @param {object} body - body param * @param {getCallback} callback - a callback function to return the result */ /* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */ postDisasterRecoveryremoveStandby(body, callback) { const meth = 'adapter-postDisasterRecoveryremoveStandby'; const origin = `${this.id}-${meth}`; log.trace(origin); /* HERE IS WHERE YOU VALIDATE DATA */ if (body === undefined || body === null || body === '') { const errorO