@itentialopensource/adapter-netbrain 1.3.5 → 1.3.6
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/CALLS.md +204 -0
- package/adapter.js +4063 -5
- package/entities/ChangeAnalysisReport/action.json +66 -0
- package/entities/ChangeAnalysisReport/schema.json +21 -0
- package/entities/ChangeManagement/action.json +125 -0
- package/entities/ChangeManagement/schema.json +35 -0
- package/entities/DeviceAccessControl/action.json +187 -0
- package/entities/DeviceAccessControl/schema.json +27 -0
- package/entities/DeviceGroupManagement/action.json +105 -0
- package/entities/DeviceGroupManagement/schema.json +23 -0
- package/entities/DeviceInterfacesManagement/action.json +24 -0
- package/entities/DeviceInterfacesManagement/schema.json +19 -0
- package/entities/DiscoveryTaskManagement/action.json +85 -0
- package/entities/DiscoveryTaskManagement/schema.json +22 -0
- package/entities/EventConsoleManagement/action.json +45 -0
- package/entities/EventConsoleManagement/schema.json +20 -0
- package/entities/IncidentReport/action.json +24 -0
- package/entities/IncidentReport/schema.json +19 -0
- package/entities/NetworkSettings/action.json +42 -0
- package/entities/NetworkSettings/schema.json +3 -1
- package/entities/SiteManagement/action.json +24 -0
- package/entities/SiteManagement/schema.json +19 -0
- package/package.json +1 -1
- package/previousVersion.zip +0 -0
- package/pronghorn.json +1574 -4
- package/report/adapterInfo.json +7 -7
- package/test/integration/adapterTestIntegration.js +866 -0
- package/test/unit/adapterTestUnit.js +935 -17
package/adapter.js
CHANGED
|
@@ -3199,11 +3199,6 @@ class Netbrain extends AdapterBaseCl {
|
|
|
3199
3199
|
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3200
3200
|
return callback(null, errorObj);
|
|
3201
3201
|
}
|
|
3202
|
-
if (interfaceName === undefined || interfaceName === null || interfaceName === '') {
|
|
3203
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['interfaceName'], null, null, null);
|
|
3204
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
3205
|
-
return callback(null, errorObj);
|
|
3206
|
-
}
|
|
3207
3202
|
|
|
3208
3203
|
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
3209
3204
|
const queryParamsAvailable = {
|
|
@@ -8810,6 +8805,4069 @@ class Netbrain extends AdapterBaseCl {
|
|
|
8810
8805
|
return callback(null, errorObj);
|
|
8811
8806
|
}
|
|
8812
8807
|
}
|
|
8808
|
+
|
|
8809
|
+
/**
|
|
8810
|
+
* @function getcmdbChangeAnalysisExportTasksStatus
|
|
8811
|
+
* @pronghornType method
|
|
8812
|
+
* @name getcmdbChangeAnalysisExportTasksStatus
|
|
8813
|
+
* @summary getcmdbChangeAnalysisExportTasksStatus
|
|
8814
|
+
*
|
|
8815
|
+
* @param {string} taskId - taskId param
|
|
8816
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
8817
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
8818
|
+
* @return {object} results - An object containing the response of the action
|
|
8819
|
+
*
|
|
8820
|
+
* @route {POST} /getcmdbChangeAnalysisExportTasksStatus
|
|
8821
|
+
* @roles admin
|
|
8822
|
+
* @task true
|
|
8823
|
+
*/
|
|
8824
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
8825
|
+
getcmdbChangeAnalysisExportTasksStatus(taskId, iapMetadata, callback) {
|
|
8826
|
+
const meth = 'adapter-getcmdbChangeAnalysisExportTasksStatus';
|
|
8827
|
+
const origin = `${this.id}-${meth}`;
|
|
8828
|
+
log.trace(origin);
|
|
8829
|
+
|
|
8830
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
8831
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
8832
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8833
|
+
return callback(null, errorObj);
|
|
8834
|
+
}
|
|
8835
|
+
|
|
8836
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
8837
|
+
if (taskId === undefined || taskId === null || taskId === '') {
|
|
8838
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['taskId'], null, null, null);
|
|
8839
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8840
|
+
return callback(null, errorObj);
|
|
8841
|
+
}
|
|
8842
|
+
|
|
8843
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
8844
|
+
const queryParamsAvailable = {};
|
|
8845
|
+
const queryParams = {};
|
|
8846
|
+
const pathVars = [taskId];
|
|
8847
|
+
const bodyVars = {};
|
|
8848
|
+
|
|
8849
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
8850
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
8851
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
8852
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
8853
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
8854
|
+
}
|
|
8855
|
+
});
|
|
8856
|
+
|
|
8857
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
8858
|
+
let thisHeaderData = null;
|
|
8859
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
8860
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
8861
|
+
try {
|
|
8862
|
+
// parse the additional headers object that was passed in
|
|
8863
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
8864
|
+
} catch (err) {
|
|
8865
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
8866
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8867
|
+
return callback(null, errorObj);
|
|
8868
|
+
}
|
|
8869
|
+
} else if (thisHeaderData === null) {
|
|
8870
|
+
thisHeaderData = { contentType: '', accept: '' };
|
|
8871
|
+
}
|
|
8872
|
+
|
|
8873
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
8874
|
+
// see adapter code documentation for more information on the request object's fields
|
|
8875
|
+
const reqObj = {
|
|
8876
|
+
payload: bodyVars,
|
|
8877
|
+
uriPathVars: pathVars,
|
|
8878
|
+
uriQuery: queryParams,
|
|
8879
|
+
addlHeaders: thisHeaderData
|
|
8880
|
+
};
|
|
8881
|
+
|
|
8882
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
8883
|
+
|
|
8884
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
8885
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
8886
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
8887
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
8888
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
8889
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
8890
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
8891
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
8892
|
+
} else {
|
|
8893
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
8894
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
8895
|
+
}
|
|
8896
|
+
}
|
|
8897
|
+
});
|
|
8898
|
+
// Add iapMetadata to reqObj for further work
|
|
8899
|
+
reqObj.iapMetadata = iapMetadata;
|
|
8900
|
+
}
|
|
8901
|
+
|
|
8902
|
+
try {
|
|
8903
|
+
// Make the call -
|
|
8904
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
8905
|
+
return this.requestHandlerInst.identifyRequest('ChangeAnalysisReport', 'getcmdbChangeAnalysisExportTasksStatus', reqObj, true, (irReturnData, irReturnError) => {
|
|
8906
|
+
// if we received an error or their is no response on the results
|
|
8907
|
+
// return an error
|
|
8908
|
+
if (irReturnError) {
|
|
8909
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
8910
|
+
return callback(null, irReturnError);
|
|
8911
|
+
}
|
|
8912
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
8913
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getcmdbChangeAnalysisExportTasksStatus'], null, null, null);
|
|
8914
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8915
|
+
return callback(null, errorObj);
|
|
8916
|
+
}
|
|
8917
|
+
|
|
8918
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
8919
|
+
// return the response
|
|
8920
|
+
return callback(irReturnData, null);
|
|
8921
|
+
});
|
|
8922
|
+
} catch (ex) {
|
|
8923
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
8924
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8925
|
+
return callback(null, errorObj);
|
|
8926
|
+
}
|
|
8927
|
+
}
|
|
8928
|
+
|
|
8929
|
+
/**
|
|
8930
|
+
* @function postcmdbChangeAnalysisExportTasks
|
|
8931
|
+
* @pronghornType method
|
|
8932
|
+
* @name postcmdbChangeAnalysisExportTasks
|
|
8933
|
+
* @summary postcmdbChangeAnalysisExportTasks
|
|
8934
|
+
*
|
|
8935
|
+
* @param {object} body - body param
|
|
8936
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
8937
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
8938
|
+
* @return {object} results - An object containing the response of the action
|
|
8939
|
+
*
|
|
8940
|
+
* @route {POST} /postcmdbChangeAnalysisExportTasks
|
|
8941
|
+
* @roles admin
|
|
8942
|
+
* @task true
|
|
8943
|
+
*/
|
|
8944
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
8945
|
+
postcmdbChangeAnalysisExportTasks(body, iapMetadata, callback) {
|
|
8946
|
+
const meth = 'adapter-postcmdbChangeAnalysisExportTasks';
|
|
8947
|
+
const origin = `${this.id}-${meth}`;
|
|
8948
|
+
log.trace(origin);
|
|
8949
|
+
|
|
8950
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
8951
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
8952
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8953
|
+
return callback(null, errorObj);
|
|
8954
|
+
}
|
|
8955
|
+
|
|
8956
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
8957
|
+
if (body === undefined || body === null || body === '') {
|
|
8958
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
8959
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8960
|
+
return callback(null, errorObj);
|
|
8961
|
+
}
|
|
8962
|
+
|
|
8963
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
8964
|
+
const queryParamsAvailable = {};
|
|
8965
|
+
const queryParams = {};
|
|
8966
|
+
const pathVars = [];
|
|
8967
|
+
const bodyVars = body;
|
|
8968
|
+
|
|
8969
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
8970
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
8971
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
8972
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
8973
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
8974
|
+
}
|
|
8975
|
+
});
|
|
8976
|
+
|
|
8977
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
8978
|
+
let thisHeaderData = null;
|
|
8979
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
8980
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
8981
|
+
try {
|
|
8982
|
+
// parse the additional headers object that was passed in
|
|
8983
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
8984
|
+
} catch (err) {
|
|
8985
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
8986
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8987
|
+
return callback(null, errorObj);
|
|
8988
|
+
}
|
|
8989
|
+
} else if (thisHeaderData === null) {
|
|
8990
|
+
thisHeaderData = { accept: '' };
|
|
8991
|
+
}
|
|
8992
|
+
|
|
8993
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
8994
|
+
// see adapter code documentation for more information on the request object's fields
|
|
8995
|
+
const reqObj = {
|
|
8996
|
+
payload: bodyVars,
|
|
8997
|
+
uriPathVars: pathVars,
|
|
8998
|
+
uriQuery: queryParams,
|
|
8999
|
+
addlHeaders: thisHeaderData
|
|
9000
|
+
};
|
|
9001
|
+
|
|
9002
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
9003
|
+
|
|
9004
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
9005
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
9006
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
9007
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
9008
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
9009
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
9010
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
9011
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
9012
|
+
} else {
|
|
9013
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
9014
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
9015
|
+
}
|
|
9016
|
+
}
|
|
9017
|
+
});
|
|
9018
|
+
// Add iapMetadata to reqObj for further work
|
|
9019
|
+
reqObj.iapMetadata = iapMetadata;
|
|
9020
|
+
}
|
|
9021
|
+
|
|
9022
|
+
try {
|
|
9023
|
+
// Make the call -
|
|
9024
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
9025
|
+
return this.requestHandlerInst.identifyRequest('ChangeAnalysisReport', 'postcmdbChangeAnalysisExportTasks', reqObj, true, (irReturnData, irReturnError) => {
|
|
9026
|
+
// if we received an error or their is no response on the results
|
|
9027
|
+
// return an error
|
|
9028
|
+
if (irReturnError) {
|
|
9029
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
9030
|
+
return callback(null, irReturnError);
|
|
9031
|
+
}
|
|
9032
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
9033
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postcmdbChangeAnalysisExportTasks'], null, null, null);
|
|
9034
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9035
|
+
return callback(null, errorObj);
|
|
9036
|
+
}
|
|
9037
|
+
|
|
9038
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
9039
|
+
// return the response
|
|
9040
|
+
return callback(irReturnData, null);
|
|
9041
|
+
});
|
|
9042
|
+
} catch (ex) {
|
|
9043
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
9044
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9045
|
+
return callback(null, errorObj);
|
|
9046
|
+
}
|
|
9047
|
+
}
|
|
9048
|
+
|
|
9049
|
+
/**
|
|
9050
|
+
* @function getcmdbChangeAnalysisExportTasks12345Download
|
|
9051
|
+
* @pronghornType method
|
|
9052
|
+
* @name getcmdbChangeAnalysisExportTasks12345Download
|
|
9053
|
+
* @summary getcmdbChangeAnalysisExportTasks12345Download
|
|
9054
|
+
*
|
|
9055
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
9056
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
9057
|
+
* @return {object} results - An object containing the response of the action
|
|
9058
|
+
*
|
|
9059
|
+
* @route {GET} /getcmdbChangeAnalysisExportTasks12345Download
|
|
9060
|
+
* @roles admin
|
|
9061
|
+
* @task true
|
|
9062
|
+
*/
|
|
9063
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
9064
|
+
getcmdbChangeAnalysisExportTasks12345Download(iapMetadata, callback) {
|
|
9065
|
+
const meth = 'adapter-getcmdbChangeAnalysisExportTasks12345Download';
|
|
9066
|
+
const origin = `${this.id}-${meth}`;
|
|
9067
|
+
log.trace(origin);
|
|
9068
|
+
|
|
9069
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
9070
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
9071
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9072
|
+
return callback(null, errorObj);
|
|
9073
|
+
}
|
|
9074
|
+
|
|
9075
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
9076
|
+
|
|
9077
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
9078
|
+
const queryParamsAvailable = {};
|
|
9079
|
+
const queryParams = {};
|
|
9080
|
+
const pathVars = [];
|
|
9081
|
+
const bodyVars = {};
|
|
9082
|
+
|
|
9083
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
9084
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
9085
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
9086
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
9087
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
9088
|
+
}
|
|
9089
|
+
});
|
|
9090
|
+
|
|
9091
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
9092
|
+
let thisHeaderData = null;
|
|
9093
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
9094
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
9095
|
+
try {
|
|
9096
|
+
// parse the additional headers object that was passed in
|
|
9097
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
9098
|
+
} catch (err) {
|
|
9099
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
9100
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9101
|
+
return callback(null, errorObj);
|
|
9102
|
+
}
|
|
9103
|
+
} else if (thisHeaderData === null) {
|
|
9104
|
+
thisHeaderData = { contentType: '', accept: '' };
|
|
9105
|
+
}
|
|
9106
|
+
|
|
9107
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
9108
|
+
// see adapter code documentation for more information on the request object's fields
|
|
9109
|
+
const reqObj = {
|
|
9110
|
+
payload: bodyVars,
|
|
9111
|
+
uriPathVars: pathVars,
|
|
9112
|
+
uriQuery: queryParams,
|
|
9113
|
+
addlHeaders: thisHeaderData
|
|
9114
|
+
};
|
|
9115
|
+
|
|
9116
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
9117
|
+
|
|
9118
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
9119
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
9120
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
9121
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
9122
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
9123
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
9124
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
9125
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
9126
|
+
} else {
|
|
9127
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
9128
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
9129
|
+
}
|
|
9130
|
+
}
|
|
9131
|
+
});
|
|
9132
|
+
// Add iapMetadata to reqObj for further work
|
|
9133
|
+
reqObj.iapMetadata = iapMetadata;
|
|
9134
|
+
}
|
|
9135
|
+
|
|
9136
|
+
try {
|
|
9137
|
+
// Make the call -
|
|
9138
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
9139
|
+
return this.requestHandlerInst.identifyRequest('ChangeAnalysisReport', 'getcmdbChangeAnalysisExportTasks12345Download', reqObj, true, (irReturnData, irReturnError) => {
|
|
9140
|
+
// if we received an error or their is no response on the results
|
|
9141
|
+
// return an error
|
|
9142
|
+
if (irReturnError) {
|
|
9143
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
9144
|
+
return callback(null, irReturnError);
|
|
9145
|
+
}
|
|
9146
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
9147
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getcmdbChangeAnalysisExportTasks12345Download'], null, null, null);
|
|
9148
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9149
|
+
return callback(null, errorObj);
|
|
9150
|
+
}
|
|
9151
|
+
|
|
9152
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
9153
|
+
// return the response
|
|
9154
|
+
return callback(irReturnData, null);
|
|
9155
|
+
});
|
|
9156
|
+
} catch (ex) {
|
|
9157
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
9158
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9159
|
+
return callback(null, errorObj);
|
|
9160
|
+
}
|
|
9161
|
+
}
|
|
9162
|
+
|
|
9163
|
+
/**
|
|
9164
|
+
* @function postcmdbCMTasksScheduledTask
|
|
9165
|
+
* @pronghornType method
|
|
9166
|
+
* @name postcmdbCMTasksScheduledTask
|
|
9167
|
+
* @summary postcmdbCMTasksScheduledTask
|
|
9168
|
+
*
|
|
9169
|
+
* @param {object} body - body param
|
|
9170
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
9171
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
9172
|
+
* @return {object} results - An object containing the response of the action
|
|
9173
|
+
*
|
|
9174
|
+
* @route {POST} /postcmdbCMTasksScheduledTask
|
|
9175
|
+
* @roles admin
|
|
9176
|
+
* @task true
|
|
9177
|
+
*/
|
|
9178
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
9179
|
+
postcmdbCMTasksScheduledTask(body, iapMetadata, callback) {
|
|
9180
|
+
const meth = 'adapter-postcmdbCMTasksScheduledTask';
|
|
9181
|
+
const origin = `${this.id}-${meth}`;
|
|
9182
|
+
log.trace(origin);
|
|
9183
|
+
|
|
9184
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
9185
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
9186
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9187
|
+
return callback(null, errorObj);
|
|
9188
|
+
}
|
|
9189
|
+
|
|
9190
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
9191
|
+
if (body === undefined || body === null || body === '') {
|
|
9192
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
9193
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9194
|
+
return callback(null, errorObj);
|
|
9195
|
+
}
|
|
9196
|
+
|
|
9197
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
9198
|
+
const queryParamsAvailable = {};
|
|
9199
|
+
const queryParams = {};
|
|
9200
|
+
const pathVars = [];
|
|
9201
|
+
const bodyVars = body;
|
|
9202
|
+
|
|
9203
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
9204
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
9205
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
9206
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
9207
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
9208
|
+
}
|
|
9209
|
+
});
|
|
9210
|
+
|
|
9211
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
9212
|
+
let thisHeaderData = null;
|
|
9213
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
9214
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
9215
|
+
try {
|
|
9216
|
+
// parse the additional headers object that was passed in
|
|
9217
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
9218
|
+
} catch (err) {
|
|
9219
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
9220
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9221
|
+
return callback(null, errorObj);
|
|
9222
|
+
}
|
|
9223
|
+
} else if (thisHeaderData === null) {
|
|
9224
|
+
thisHeaderData = { accept: '' };
|
|
9225
|
+
}
|
|
9226
|
+
|
|
9227
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
9228
|
+
// see adapter code documentation for more information on the request object's fields
|
|
9229
|
+
const reqObj = {
|
|
9230
|
+
payload: bodyVars,
|
|
9231
|
+
uriPathVars: pathVars,
|
|
9232
|
+
uriQuery: queryParams,
|
|
9233
|
+
addlHeaders: thisHeaderData
|
|
9234
|
+
};
|
|
9235
|
+
|
|
9236
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
9237
|
+
|
|
9238
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
9239
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
9240
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
9241
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
9242
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
9243
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
9244
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
9245
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
9246
|
+
} else {
|
|
9247
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
9248
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
9249
|
+
}
|
|
9250
|
+
}
|
|
9251
|
+
});
|
|
9252
|
+
// Add iapMetadata to reqObj for further work
|
|
9253
|
+
reqObj.iapMetadata = iapMetadata;
|
|
9254
|
+
}
|
|
9255
|
+
|
|
9256
|
+
try {
|
|
9257
|
+
// Make the call -
|
|
9258
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
9259
|
+
return this.requestHandlerInst.identifyRequest('ChangeManagement', 'postcmdbCMTasksScheduledTask', reqObj, true, (irReturnData, irReturnError) => {
|
|
9260
|
+
// if we received an error or their is no response on the results
|
|
9261
|
+
// return an error
|
|
9262
|
+
if (irReturnError) {
|
|
9263
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
9264
|
+
return callback(null, irReturnError);
|
|
9265
|
+
}
|
|
9266
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
9267
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postcmdbCMTasksScheduledTask'], null, null, null);
|
|
9268
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9269
|
+
return callback(null, errorObj);
|
|
9270
|
+
}
|
|
9271
|
+
|
|
9272
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
9273
|
+
// return the response
|
|
9274
|
+
return callback(irReturnData, null);
|
|
9275
|
+
});
|
|
9276
|
+
} catch (ex) {
|
|
9277
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
9278
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9279
|
+
return callback(null, errorObj);
|
|
9280
|
+
}
|
|
9281
|
+
}
|
|
9282
|
+
|
|
9283
|
+
/**
|
|
9284
|
+
* @function getcmdbCMTasksScheduledTask
|
|
9285
|
+
* @pronghornType method
|
|
9286
|
+
* @name getcmdbCMTasksScheduledTask
|
|
9287
|
+
* @summary getcmdbCMTasksScheduledTask
|
|
9288
|
+
*
|
|
9289
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
9290
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
9291
|
+
* @return {object} results - An object containing the response of the action
|
|
9292
|
+
*
|
|
9293
|
+
* @route {GET} /getcmdbCMTasksScheduledTask
|
|
9294
|
+
* @roles admin
|
|
9295
|
+
* @task true
|
|
9296
|
+
*/
|
|
9297
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
9298
|
+
getcmdbCMTasksScheduledTask(iapMetadata, callback) {
|
|
9299
|
+
const meth = 'adapter-getcmdbCMTasksScheduledTask';
|
|
9300
|
+
const origin = `${this.id}-${meth}`;
|
|
9301
|
+
log.trace(origin);
|
|
9302
|
+
|
|
9303
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
9304
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
9305
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9306
|
+
return callback(null, errorObj);
|
|
9307
|
+
}
|
|
9308
|
+
|
|
9309
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
9310
|
+
|
|
9311
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
9312
|
+
const queryParamsAvailable = {};
|
|
9313
|
+
const queryParams = {};
|
|
9314
|
+
const pathVars = [];
|
|
9315
|
+
const bodyVars = {};
|
|
9316
|
+
|
|
9317
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
9318
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
9319
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
9320
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
9321
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
9322
|
+
}
|
|
9323
|
+
});
|
|
9324
|
+
|
|
9325
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
9326
|
+
let thisHeaderData = null;
|
|
9327
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
9328
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
9329
|
+
try {
|
|
9330
|
+
// parse the additional headers object that was passed in
|
|
9331
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
9332
|
+
} catch (err) {
|
|
9333
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
9334
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9335
|
+
return callback(null, errorObj);
|
|
9336
|
+
}
|
|
9337
|
+
} else if (thisHeaderData === null) {
|
|
9338
|
+
thisHeaderData = { accept: '', contentType: '', token: '' };
|
|
9339
|
+
}
|
|
9340
|
+
|
|
9341
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
9342
|
+
// see adapter code documentation for more information on the request object's fields
|
|
9343
|
+
const reqObj = {
|
|
9344
|
+
payload: bodyVars,
|
|
9345
|
+
uriPathVars: pathVars,
|
|
9346
|
+
uriQuery: queryParams,
|
|
9347
|
+
addlHeaders: thisHeaderData
|
|
9348
|
+
};
|
|
9349
|
+
|
|
9350
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
9351
|
+
|
|
9352
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
9353
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
9354
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
9355
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
9356
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
9357
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
9358
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
9359
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
9360
|
+
} else {
|
|
9361
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
9362
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
9363
|
+
}
|
|
9364
|
+
}
|
|
9365
|
+
});
|
|
9366
|
+
// Add iapMetadata to reqObj for further work
|
|
9367
|
+
reqObj.iapMetadata = iapMetadata;
|
|
9368
|
+
}
|
|
9369
|
+
|
|
9370
|
+
try {
|
|
9371
|
+
// Make the call -
|
|
9372
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
9373
|
+
return this.requestHandlerInst.identifyRequest('ChangeManagement', 'getcmdbCMTasksScheduledTask', reqObj, true, (irReturnData, irReturnError) => {
|
|
9374
|
+
// if we received an error or their is no response on the results
|
|
9375
|
+
// return an error
|
|
9376
|
+
if (irReturnError) {
|
|
9377
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
9378
|
+
return callback(null, irReturnError);
|
|
9379
|
+
}
|
|
9380
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
9381
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getcmdbCMTasksScheduledTask'], null, null, null);
|
|
9382
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9383
|
+
return callback(null, errorObj);
|
|
9384
|
+
}
|
|
9385
|
+
|
|
9386
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
9387
|
+
// return the response
|
|
9388
|
+
return callback(irReturnData, null);
|
|
9389
|
+
});
|
|
9390
|
+
} catch (ex) {
|
|
9391
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
9392
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9393
|
+
return callback(null, errorObj);
|
|
9394
|
+
}
|
|
9395
|
+
}
|
|
9396
|
+
|
|
9397
|
+
/**
|
|
9398
|
+
* @function putcmdbCMTasksScheduledTask
|
|
9399
|
+
* @pronghornType method
|
|
9400
|
+
* @name putcmdbCMTasksScheduledTask
|
|
9401
|
+
* @summary putcmdbCMTasksScheduledTask
|
|
9402
|
+
*
|
|
9403
|
+
* @param {object} body - body param
|
|
9404
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
9405
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
9406
|
+
* @return {object} results - An object containing the response of the action
|
|
9407
|
+
*
|
|
9408
|
+
* @route {POST} /putcmdbCMTasksScheduledTask
|
|
9409
|
+
* @roles admin
|
|
9410
|
+
* @task true
|
|
9411
|
+
*/
|
|
9412
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
9413
|
+
putcmdbCMTasksScheduledTask(body, iapMetadata, callback) {
|
|
9414
|
+
const meth = 'adapter-putcmdbCMTasksScheduledTask';
|
|
9415
|
+
const origin = `${this.id}-${meth}`;
|
|
9416
|
+
log.trace(origin);
|
|
9417
|
+
|
|
9418
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
9419
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
9420
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9421
|
+
return callback(null, errorObj);
|
|
9422
|
+
}
|
|
9423
|
+
|
|
9424
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
9425
|
+
if (body === undefined || body === null || body === '') {
|
|
9426
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
9427
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9428
|
+
return callback(null, errorObj);
|
|
9429
|
+
}
|
|
9430
|
+
|
|
9431
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
9432
|
+
const queryParamsAvailable = {};
|
|
9433
|
+
const queryParams = {};
|
|
9434
|
+
const pathVars = [];
|
|
9435
|
+
const bodyVars = body;
|
|
9436
|
+
|
|
9437
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
9438
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
9439
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
9440
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
9441
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
9442
|
+
}
|
|
9443
|
+
});
|
|
9444
|
+
|
|
9445
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
9446
|
+
let thisHeaderData = null;
|
|
9447
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
9448
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
9449
|
+
try {
|
|
9450
|
+
// parse the additional headers object that was passed in
|
|
9451
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
9452
|
+
} catch (err) {
|
|
9453
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
9454
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9455
|
+
return callback(null, errorObj);
|
|
9456
|
+
}
|
|
9457
|
+
} else if (thisHeaderData === null) {
|
|
9458
|
+
thisHeaderData = { accept: '', token: '' };
|
|
9459
|
+
}
|
|
9460
|
+
|
|
9461
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
9462
|
+
// see adapter code documentation for more information on the request object's fields
|
|
9463
|
+
const reqObj = {
|
|
9464
|
+
payload: bodyVars,
|
|
9465
|
+
uriPathVars: pathVars,
|
|
9466
|
+
uriQuery: queryParams,
|
|
9467
|
+
addlHeaders: thisHeaderData
|
|
9468
|
+
};
|
|
9469
|
+
|
|
9470
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
9471
|
+
|
|
9472
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
9473
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
9474
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
9475
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
9476
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
9477
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
9478
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
9479
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
9480
|
+
} else {
|
|
9481
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
9482
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
9483
|
+
}
|
|
9484
|
+
}
|
|
9485
|
+
});
|
|
9486
|
+
// Add iapMetadata to reqObj for further work
|
|
9487
|
+
reqObj.iapMetadata = iapMetadata;
|
|
9488
|
+
}
|
|
9489
|
+
|
|
9490
|
+
try {
|
|
9491
|
+
// Make the call -
|
|
9492
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
9493
|
+
return this.requestHandlerInst.identifyRequest('ChangeManagement', 'putcmdbCMTasksScheduledTask', reqObj, false, (irReturnData, irReturnError) => {
|
|
9494
|
+
// if we received an error or their is no response on the results
|
|
9495
|
+
// return an error
|
|
9496
|
+
if (irReturnError) {
|
|
9497
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
9498
|
+
return callback(null, irReturnError);
|
|
9499
|
+
}
|
|
9500
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
9501
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['putcmdbCMTasksScheduledTask'], null, null, null);
|
|
9502
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9503
|
+
return callback(null, errorObj);
|
|
9504
|
+
}
|
|
9505
|
+
|
|
9506
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
9507
|
+
// return the response
|
|
9508
|
+
return callback(irReturnData, null);
|
|
9509
|
+
});
|
|
9510
|
+
} catch (ex) {
|
|
9511
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
9512
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9513
|
+
return callback(null, errorObj);
|
|
9514
|
+
}
|
|
9515
|
+
}
|
|
9516
|
+
|
|
9517
|
+
/**
|
|
9518
|
+
* @function deletecmTasksScheduleTask
|
|
9519
|
+
* @pronghornType method
|
|
9520
|
+
* @name deletecmTasksScheduleTask
|
|
9521
|
+
* @summary deletecmTasksScheduleTask
|
|
9522
|
+
*
|
|
9523
|
+
* @param {string} runbookId - runbookId param
|
|
9524
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
9525
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
9526
|
+
* @return {object} results - An object containing the response of the action
|
|
9527
|
+
*
|
|
9528
|
+
* @route {POST} /deletecmTasksScheduleTask
|
|
9529
|
+
* @roles admin
|
|
9530
|
+
* @task true
|
|
9531
|
+
*/
|
|
9532
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
9533
|
+
deletecmTasksScheduleTask(runbookId, iapMetadata, callback) {
|
|
9534
|
+
const meth = 'adapter-deletecmTasksScheduleTask';
|
|
9535
|
+
const origin = `${this.id}-${meth}`;
|
|
9536
|
+
log.trace(origin);
|
|
9537
|
+
|
|
9538
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
9539
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
9540
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9541
|
+
return callback(null, errorObj);
|
|
9542
|
+
}
|
|
9543
|
+
|
|
9544
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
9545
|
+
if (runbookId === undefined || runbookId === null || runbookId === '') {
|
|
9546
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['runbookId'], null, null, null);
|
|
9547
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9548
|
+
return callback(null, errorObj);
|
|
9549
|
+
}
|
|
9550
|
+
|
|
9551
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
9552
|
+
const queryParamsAvailable = { runbookId };
|
|
9553
|
+
const queryParams = {};
|
|
9554
|
+
const pathVars = [];
|
|
9555
|
+
const bodyVars = {};
|
|
9556
|
+
|
|
9557
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
9558
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
9559
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
9560
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
9561
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
9562
|
+
}
|
|
9563
|
+
});
|
|
9564
|
+
|
|
9565
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
9566
|
+
let thisHeaderData = null;
|
|
9567
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
9568
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
9569
|
+
try {
|
|
9570
|
+
// parse the additional headers object that was passed in
|
|
9571
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
9572
|
+
} catch (err) {
|
|
9573
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
9574
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9575
|
+
return callback(null, errorObj);
|
|
9576
|
+
}
|
|
9577
|
+
} else if (thisHeaderData === null) {
|
|
9578
|
+
thisHeaderData = { accept: '', contentType: '', token: '' };
|
|
9579
|
+
}
|
|
9580
|
+
|
|
9581
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
9582
|
+
// see adapter code documentation for more information on the request object's fields
|
|
9583
|
+
const reqObj = {
|
|
9584
|
+
payload: bodyVars,
|
|
9585
|
+
uriPathVars: pathVars,
|
|
9586
|
+
uriQuery: queryParams,
|
|
9587
|
+
addlHeaders: thisHeaderData
|
|
9588
|
+
};
|
|
9589
|
+
|
|
9590
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
9591
|
+
|
|
9592
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
9593
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
9594
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
9595
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
9596
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
9597
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
9598
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
9599
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
9600
|
+
} else {
|
|
9601
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
9602
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
9603
|
+
}
|
|
9604
|
+
}
|
|
9605
|
+
});
|
|
9606
|
+
// Add iapMetadata to reqObj for further work
|
|
9607
|
+
reqObj.iapMetadata = iapMetadata;
|
|
9608
|
+
}
|
|
9609
|
+
|
|
9610
|
+
try {
|
|
9611
|
+
// Make the call -
|
|
9612
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
9613
|
+
return this.requestHandlerInst.identifyRequest('ChangeManagement', 'deletecmTasksScheduleTask', reqObj, false, (irReturnData, irReturnError) => {
|
|
9614
|
+
// if we received an error or their is no response on the results
|
|
9615
|
+
// return an error
|
|
9616
|
+
if (irReturnError) {
|
|
9617
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
9618
|
+
return callback(null, irReturnError);
|
|
9619
|
+
}
|
|
9620
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
9621
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletecmTasksScheduleTask'], null, null, null);
|
|
9622
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9623
|
+
return callback(null, errorObj);
|
|
9624
|
+
}
|
|
9625
|
+
|
|
9626
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
9627
|
+
// return the response
|
|
9628
|
+
return callback(irReturnData, null);
|
|
9629
|
+
});
|
|
9630
|
+
} catch (ex) {
|
|
9631
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
9632
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9633
|
+
return callback(null, errorObj);
|
|
9634
|
+
}
|
|
9635
|
+
}
|
|
9636
|
+
|
|
9637
|
+
/**
|
|
9638
|
+
* @function postcmBinding
|
|
9639
|
+
* @pronghornType method
|
|
9640
|
+
* @name postcmBinding
|
|
9641
|
+
* @summary postcmBinding
|
|
9642
|
+
*
|
|
9643
|
+
* @param {object} body - body param
|
|
9644
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
9645
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
9646
|
+
* @return {object} results - An object containing the response of the action
|
|
9647
|
+
*
|
|
9648
|
+
* @route {POST} /postcmBinding
|
|
9649
|
+
* @roles admin
|
|
9650
|
+
* @task true
|
|
9651
|
+
*/
|
|
9652
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
9653
|
+
postcmBinding(body, iapMetadata, callback) {
|
|
9654
|
+
const meth = 'adapter-postcmBinding';
|
|
9655
|
+
const origin = `${this.id}-${meth}`;
|
|
9656
|
+
log.trace(origin);
|
|
9657
|
+
|
|
9658
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
9659
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
9660
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9661
|
+
return callback(null, errorObj);
|
|
9662
|
+
}
|
|
9663
|
+
|
|
9664
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
9665
|
+
if (body === undefined || body === null || body === '') {
|
|
9666
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
9667
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9668
|
+
return callback(null, errorObj);
|
|
9669
|
+
}
|
|
9670
|
+
|
|
9671
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
9672
|
+
const queryParamsAvailable = {};
|
|
9673
|
+
const queryParams = {};
|
|
9674
|
+
const pathVars = [];
|
|
9675
|
+
const bodyVars = body;
|
|
9676
|
+
|
|
9677
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
9678
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
9679
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
9680
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
9681
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
9682
|
+
}
|
|
9683
|
+
});
|
|
9684
|
+
|
|
9685
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
9686
|
+
let thisHeaderData = null;
|
|
9687
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
9688
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
9689
|
+
try {
|
|
9690
|
+
// parse the additional headers object that was passed in
|
|
9691
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
9692
|
+
} catch (err) {
|
|
9693
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
9694
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9695
|
+
return callback(null, errorObj);
|
|
9696
|
+
}
|
|
9697
|
+
} else if (thisHeaderData === null) {
|
|
9698
|
+
thisHeaderData = { accept: '', token: '' };
|
|
9699
|
+
}
|
|
9700
|
+
|
|
9701
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
9702
|
+
// see adapter code documentation for more information on the request object's fields
|
|
9703
|
+
const reqObj = {
|
|
9704
|
+
payload: bodyVars,
|
|
9705
|
+
uriPathVars: pathVars,
|
|
9706
|
+
uriQuery: queryParams,
|
|
9707
|
+
addlHeaders: thisHeaderData
|
|
9708
|
+
};
|
|
9709
|
+
|
|
9710
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
9711
|
+
|
|
9712
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
9713
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
9714
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
9715
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
9716
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
9717
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
9718
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
9719
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
9720
|
+
} else {
|
|
9721
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
9722
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
9723
|
+
}
|
|
9724
|
+
}
|
|
9725
|
+
});
|
|
9726
|
+
// Add iapMetadata to reqObj for further work
|
|
9727
|
+
reqObj.iapMetadata = iapMetadata;
|
|
9728
|
+
}
|
|
9729
|
+
|
|
9730
|
+
try {
|
|
9731
|
+
// Make the call -
|
|
9732
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
9733
|
+
return this.requestHandlerInst.identifyRequest('ChangeManagement', 'postcmBinding', reqObj, true, (irReturnData, irReturnError) => {
|
|
9734
|
+
// if we received an error or their is no response on the results
|
|
9735
|
+
// return an error
|
|
9736
|
+
if (irReturnError) {
|
|
9737
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
9738
|
+
return callback(null, irReturnError);
|
|
9739
|
+
}
|
|
9740
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
9741
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postcmBinding'], null, null, null);
|
|
9742
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9743
|
+
return callback(null, errorObj);
|
|
9744
|
+
}
|
|
9745
|
+
|
|
9746
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
9747
|
+
// return the response
|
|
9748
|
+
return callback(irReturnData, null);
|
|
9749
|
+
});
|
|
9750
|
+
} catch (ex) {
|
|
9751
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
9752
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9753
|
+
return callback(null, errorObj);
|
|
9754
|
+
}
|
|
9755
|
+
}
|
|
9756
|
+
|
|
9757
|
+
/**
|
|
9758
|
+
* @function postcmApprovalState
|
|
9759
|
+
* @pronghornType method
|
|
9760
|
+
* @name postcmApprovalState
|
|
9761
|
+
* @summary postcmApprovalState
|
|
9762
|
+
*
|
|
9763
|
+
* @param {object} body - body param
|
|
9764
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
9765
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
9766
|
+
* @return {object} results - An object containing the response of the action
|
|
9767
|
+
*
|
|
9768
|
+
* @route {POST} /postcmApprovalState
|
|
9769
|
+
* @roles admin
|
|
9770
|
+
* @task true
|
|
9771
|
+
*/
|
|
9772
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
9773
|
+
postcmApprovalState(body, iapMetadata, callback) {
|
|
9774
|
+
const meth = 'adapter-postcmApprovalState';
|
|
9775
|
+
const origin = `${this.id}-${meth}`;
|
|
9776
|
+
log.trace(origin);
|
|
9777
|
+
|
|
9778
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
9779
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
9780
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9781
|
+
return callback(null, errorObj);
|
|
9782
|
+
}
|
|
9783
|
+
|
|
9784
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
9785
|
+
if (body === undefined || body === null || body === '') {
|
|
9786
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
9787
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9788
|
+
return callback(null, errorObj);
|
|
9789
|
+
}
|
|
9790
|
+
|
|
9791
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
9792
|
+
const queryParamsAvailable = {};
|
|
9793
|
+
const queryParams = {};
|
|
9794
|
+
const pathVars = [];
|
|
9795
|
+
const bodyVars = body;
|
|
9796
|
+
|
|
9797
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
9798
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
9799
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
9800
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
9801
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
9802
|
+
}
|
|
9803
|
+
});
|
|
9804
|
+
|
|
9805
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
9806
|
+
let thisHeaderData = null;
|
|
9807
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
9808
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
9809
|
+
try {
|
|
9810
|
+
// parse the additional headers object that was passed in
|
|
9811
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
9812
|
+
} catch (err) {
|
|
9813
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
9814
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9815
|
+
return callback(null, errorObj);
|
|
9816
|
+
}
|
|
9817
|
+
} else if (thisHeaderData === null) {
|
|
9818
|
+
thisHeaderData = { accept: '', token: '' };
|
|
9819
|
+
}
|
|
9820
|
+
|
|
9821
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
9822
|
+
// see adapter code documentation for more information on the request object's fields
|
|
9823
|
+
const reqObj = {
|
|
9824
|
+
payload: bodyVars,
|
|
9825
|
+
uriPathVars: pathVars,
|
|
9826
|
+
uriQuery: queryParams,
|
|
9827
|
+
addlHeaders: thisHeaderData
|
|
9828
|
+
};
|
|
9829
|
+
|
|
9830
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
9831
|
+
|
|
9832
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
9833
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
9834
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
9835
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
9836
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
9837
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
9838
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
9839
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
9840
|
+
} else {
|
|
9841
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
9842
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
9843
|
+
}
|
|
9844
|
+
}
|
|
9845
|
+
});
|
|
9846
|
+
// Add iapMetadata to reqObj for further work
|
|
9847
|
+
reqObj.iapMetadata = iapMetadata;
|
|
9848
|
+
}
|
|
9849
|
+
|
|
9850
|
+
try {
|
|
9851
|
+
// Make the call -
|
|
9852
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
9853
|
+
return this.requestHandlerInst.identifyRequest('ChangeManagement', 'postcmApprovalState', reqObj, true, (irReturnData, irReturnError) => {
|
|
9854
|
+
// if we received an error or their is no response on the results
|
|
9855
|
+
// return an error
|
|
9856
|
+
if (irReturnError) {
|
|
9857
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
9858
|
+
return callback(null, irReturnError);
|
|
9859
|
+
}
|
|
9860
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
9861
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postcmApprovalState'], null, null, null);
|
|
9862
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9863
|
+
return callback(null, errorObj);
|
|
9864
|
+
}
|
|
9865
|
+
|
|
9866
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
9867
|
+
// return the response
|
|
9868
|
+
return callback(irReturnData, null);
|
|
9869
|
+
});
|
|
9870
|
+
} catch (ex) {
|
|
9871
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
9872
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9873
|
+
return callback(null, errorObj);
|
|
9874
|
+
}
|
|
9875
|
+
}
|
|
9876
|
+
|
|
9877
|
+
/**
|
|
9878
|
+
* @function postcmdbDeviceAccessPolicy
|
|
9879
|
+
* @pronghornType method
|
|
9880
|
+
* @name postcmdbDeviceAccessPolicy
|
|
9881
|
+
* @summary postcmdbDeviceAccessPolicy
|
|
9882
|
+
*
|
|
9883
|
+
* @param {object} body - body param
|
|
9884
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
9885
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
9886
|
+
* @return {object} results - An object containing the response of the action
|
|
9887
|
+
*
|
|
9888
|
+
* @route {POST} /postcmdbDeviceAccessPolicy
|
|
9889
|
+
* @roles admin
|
|
9890
|
+
* @task true
|
|
9891
|
+
*/
|
|
9892
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
9893
|
+
postcmdbDeviceAccessPolicy(body, iapMetadata, callback) {
|
|
9894
|
+
const meth = 'adapter-postcmdbDeviceAccessPolicy';
|
|
9895
|
+
const origin = `${this.id}-${meth}`;
|
|
9896
|
+
log.trace(origin);
|
|
9897
|
+
|
|
9898
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
9899
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
9900
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9901
|
+
return callback(null, errorObj);
|
|
9902
|
+
}
|
|
9903
|
+
|
|
9904
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
9905
|
+
if (body === undefined || body === null || body === '') {
|
|
9906
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
9907
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9908
|
+
return callback(null, errorObj);
|
|
9909
|
+
}
|
|
9910
|
+
|
|
9911
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
9912
|
+
const queryParamsAvailable = {};
|
|
9913
|
+
const queryParams = {};
|
|
9914
|
+
const pathVars = [];
|
|
9915
|
+
const bodyVars = body;
|
|
9916
|
+
|
|
9917
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
9918
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
9919
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
9920
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
9921
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
9922
|
+
}
|
|
9923
|
+
});
|
|
9924
|
+
|
|
9925
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
9926
|
+
let thisHeaderData = null;
|
|
9927
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
9928
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
9929
|
+
try {
|
|
9930
|
+
// parse the additional headers object that was passed in
|
|
9931
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
9932
|
+
} catch (err) {
|
|
9933
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
9934
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9935
|
+
return callback(null, errorObj);
|
|
9936
|
+
}
|
|
9937
|
+
} else if (thisHeaderData === null) {
|
|
9938
|
+
thisHeaderData = { postmanToken: '', cacheControl: '', token: '' };
|
|
9939
|
+
}
|
|
9940
|
+
|
|
9941
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
9942
|
+
// see adapter code documentation for more information on the request object's fields
|
|
9943
|
+
const reqObj = {
|
|
9944
|
+
payload: bodyVars,
|
|
9945
|
+
uriPathVars: pathVars,
|
|
9946
|
+
uriQuery: queryParams,
|
|
9947
|
+
addlHeaders: thisHeaderData
|
|
9948
|
+
};
|
|
9949
|
+
|
|
9950
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
9951
|
+
|
|
9952
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
9953
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
9954
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
9955
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
9956
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
9957
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
9958
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
9959
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
9960
|
+
} else {
|
|
9961
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
9962
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
9963
|
+
}
|
|
9964
|
+
}
|
|
9965
|
+
});
|
|
9966
|
+
// Add iapMetadata to reqObj for further work
|
|
9967
|
+
reqObj.iapMetadata = iapMetadata;
|
|
9968
|
+
}
|
|
9969
|
+
|
|
9970
|
+
try {
|
|
9971
|
+
// Make the call -
|
|
9972
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
9973
|
+
return this.requestHandlerInst.identifyRequest('DeviceAccessControl', 'postcmdbDeviceAccessPolicy', reqObj, true, (irReturnData, irReturnError) => {
|
|
9974
|
+
// if we received an error or their is no response on the results
|
|
9975
|
+
// return an error
|
|
9976
|
+
if (irReturnError) {
|
|
9977
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
9978
|
+
return callback(null, irReturnError);
|
|
9979
|
+
}
|
|
9980
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
9981
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postcmdbDeviceAccessPolicy'], null, null, null);
|
|
9982
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9983
|
+
return callback(null, errorObj);
|
|
9984
|
+
}
|
|
9985
|
+
|
|
9986
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
9987
|
+
// return the response
|
|
9988
|
+
return callback(irReturnData, null);
|
|
9989
|
+
});
|
|
9990
|
+
} catch (ex) {
|
|
9991
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
9992
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
9993
|
+
return callback(null, errorObj);
|
|
9994
|
+
}
|
|
9995
|
+
}
|
|
9996
|
+
|
|
9997
|
+
/**
|
|
9998
|
+
* @function getcmdbDeviceAccessPolicy
|
|
9999
|
+
* @pronghornType method
|
|
10000
|
+
* @name getcmdbDeviceAccessPolicy
|
|
10001
|
+
* @summary getcmdbDeviceAccessPolicy
|
|
10002
|
+
*
|
|
10003
|
+
* @param {string} name - name param
|
|
10004
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
10005
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
10006
|
+
* @return {object} results - An object containing the response of the action
|
|
10007
|
+
*
|
|
10008
|
+
* @route {POST} /getcmdbDeviceAccessPolicy
|
|
10009
|
+
* @roles admin
|
|
10010
|
+
* @task true
|
|
10011
|
+
*/
|
|
10012
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
10013
|
+
getcmdbDeviceAccessPolicy(name, iapMetadata, callback) {
|
|
10014
|
+
const meth = 'adapter-getcmdbDeviceAccessPolicy';
|
|
10015
|
+
const origin = `${this.id}-${meth}`;
|
|
10016
|
+
log.trace(origin);
|
|
10017
|
+
|
|
10018
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
10019
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
10020
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10021
|
+
return callback(null, errorObj);
|
|
10022
|
+
}
|
|
10023
|
+
|
|
10024
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
10025
|
+
if (name === undefined || name === null || name === '') {
|
|
10026
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['name'], null, null, null);
|
|
10027
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10028
|
+
return callback(null, errorObj);
|
|
10029
|
+
}
|
|
10030
|
+
|
|
10031
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
10032
|
+
const queryParamsAvailable = { name };
|
|
10033
|
+
const queryParams = {};
|
|
10034
|
+
const pathVars = [];
|
|
10035
|
+
const bodyVars = {};
|
|
10036
|
+
|
|
10037
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
10038
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
10039
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
10040
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
10041
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
10042
|
+
}
|
|
10043
|
+
});
|
|
10044
|
+
|
|
10045
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
10046
|
+
let thisHeaderData = null;
|
|
10047
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
10048
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
10049
|
+
try {
|
|
10050
|
+
// parse the additional headers object that was passed in
|
|
10051
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
10052
|
+
} catch (err) {
|
|
10053
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
10054
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10055
|
+
return callback(null, errorObj);
|
|
10056
|
+
}
|
|
10057
|
+
} else if (thisHeaderData === null) {
|
|
10058
|
+
thisHeaderData = { postmanToken: '', cacheControl: '', token: '' };
|
|
10059
|
+
}
|
|
10060
|
+
|
|
10061
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
10062
|
+
// see adapter code documentation for more information on the request object's fields
|
|
10063
|
+
const reqObj = {
|
|
10064
|
+
payload: bodyVars,
|
|
10065
|
+
uriPathVars: pathVars,
|
|
10066
|
+
uriQuery: queryParams,
|
|
10067
|
+
addlHeaders: thisHeaderData
|
|
10068
|
+
};
|
|
10069
|
+
|
|
10070
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
10071
|
+
|
|
10072
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
10073
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
10074
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
10075
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
10076
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
10077
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
10078
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
10079
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
10080
|
+
} else {
|
|
10081
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
10082
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
10083
|
+
}
|
|
10084
|
+
}
|
|
10085
|
+
});
|
|
10086
|
+
// Add iapMetadata to reqObj for further work
|
|
10087
|
+
reqObj.iapMetadata = iapMetadata;
|
|
10088
|
+
}
|
|
10089
|
+
|
|
10090
|
+
try {
|
|
10091
|
+
// Make the call -
|
|
10092
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
10093
|
+
return this.requestHandlerInst.identifyRequest('DeviceAccessControl', 'getcmdbDeviceAccessPolicy', reqObj, true, (irReturnData, irReturnError) => {
|
|
10094
|
+
// if we received an error or their is no response on the results
|
|
10095
|
+
// return an error
|
|
10096
|
+
if (irReturnError) {
|
|
10097
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
10098
|
+
return callback(null, irReturnError);
|
|
10099
|
+
}
|
|
10100
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
10101
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getcmdbDeviceAccessPolicy'], null, null, null);
|
|
10102
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10103
|
+
return callback(null, errorObj);
|
|
10104
|
+
}
|
|
10105
|
+
|
|
10106
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
10107
|
+
// return the response
|
|
10108
|
+
return callback(irReturnData, null);
|
|
10109
|
+
});
|
|
10110
|
+
} catch (ex) {
|
|
10111
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
10112
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10113
|
+
return callback(null, errorObj);
|
|
10114
|
+
}
|
|
10115
|
+
}
|
|
10116
|
+
|
|
10117
|
+
/**
|
|
10118
|
+
* @function putcmdbDeviceAccessPolicy
|
|
10119
|
+
* @pronghornType method
|
|
10120
|
+
* @name putcmdbDeviceAccessPolicy
|
|
10121
|
+
* @summary putcmdbDeviceAccessPolicy
|
|
10122
|
+
*
|
|
10123
|
+
* @param {object} body - body param
|
|
10124
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
10125
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
10126
|
+
* @return {object} results - An object containing the response of the action
|
|
10127
|
+
*
|
|
10128
|
+
* @route {POST} /putcmdbDeviceAccessPolicy
|
|
10129
|
+
* @roles admin
|
|
10130
|
+
* @task true
|
|
10131
|
+
*/
|
|
10132
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
10133
|
+
putcmdbDeviceAccessPolicy(body, iapMetadata, callback) {
|
|
10134
|
+
const meth = 'adapter-putcmdbDeviceAccessPolicy';
|
|
10135
|
+
const origin = `${this.id}-${meth}`;
|
|
10136
|
+
log.trace(origin);
|
|
10137
|
+
|
|
10138
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
10139
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
10140
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10141
|
+
return callback(null, errorObj);
|
|
10142
|
+
}
|
|
10143
|
+
|
|
10144
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
10145
|
+
if (body === undefined || body === null || body === '') {
|
|
10146
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
10147
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10148
|
+
return callback(null, errorObj);
|
|
10149
|
+
}
|
|
10150
|
+
|
|
10151
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
10152
|
+
const queryParamsAvailable = {};
|
|
10153
|
+
const queryParams = {};
|
|
10154
|
+
const pathVars = [];
|
|
10155
|
+
const bodyVars = body;
|
|
10156
|
+
|
|
10157
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
10158
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
10159
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
10160
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
10161
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
10162
|
+
}
|
|
10163
|
+
});
|
|
10164
|
+
|
|
10165
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
10166
|
+
let thisHeaderData = null;
|
|
10167
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
10168
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
10169
|
+
try {
|
|
10170
|
+
// parse the additional headers object that was passed in
|
|
10171
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
10172
|
+
} catch (err) {
|
|
10173
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
10174
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10175
|
+
return callback(null, errorObj);
|
|
10176
|
+
}
|
|
10177
|
+
} else if (thisHeaderData === null) {
|
|
10178
|
+
thisHeaderData = { postmanToken: '', cacheControl: '', token: '' };
|
|
10179
|
+
}
|
|
10180
|
+
|
|
10181
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
10182
|
+
// see adapter code documentation for more information on the request object's fields
|
|
10183
|
+
const reqObj = {
|
|
10184
|
+
payload: bodyVars,
|
|
10185
|
+
uriPathVars: pathVars,
|
|
10186
|
+
uriQuery: queryParams,
|
|
10187
|
+
addlHeaders: thisHeaderData
|
|
10188
|
+
};
|
|
10189
|
+
|
|
10190
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
10191
|
+
|
|
10192
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
10193
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
10194
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
10195
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
10196
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
10197
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
10198
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
10199
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
10200
|
+
} else {
|
|
10201
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
10202
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
10203
|
+
}
|
|
10204
|
+
}
|
|
10205
|
+
});
|
|
10206
|
+
// Add iapMetadata to reqObj for further work
|
|
10207
|
+
reqObj.iapMetadata = iapMetadata;
|
|
10208
|
+
}
|
|
10209
|
+
|
|
10210
|
+
try {
|
|
10211
|
+
// Make the call -
|
|
10212
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
10213
|
+
return this.requestHandlerInst.identifyRequest('DeviceAccessControl', 'putcmdbDeviceAccessPolicy', reqObj, false, (irReturnData, irReturnError) => {
|
|
10214
|
+
// if we received an error or their is no response on the results
|
|
10215
|
+
// return an error
|
|
10216
|
+
if (irReturnError) {
|
|
10217
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
10218
|
+
return callback(null, irReturnError);
|
|
10219
|
+
}
|
|
10220
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
10221
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['putcmdbDeviceAccessPolicy'], null, null, null);
|
|
10222
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10223
|
+
return callback(null, errorObj);
|
|
10224
|
+
}
|
|
10225
|
+
|
|
10226
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
10227
|
+
// return the response
|
|
10228
|
+
return callback(irReturnData, null);
|
|
10229
|
+
});
|
|
10230
|
+
} catch (ex) {
|
|
10231
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
10232
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10233
|
+
return callback(null, errorObj);
|
|
10234
|
+
}
|
|
10235
|
+
}
|
|
10236
|
+
|
|
10237
|
+
/**
|
|
10238
|
+
* @function postcmdbUserDeviceAccessPolicyAssignDeviceAccessPolicies
|
|
10239
|
+
* @pronghornType method
|
|
10240
|
+
* @name postcmdbUserDeviceAccessPolicyAssignDeviceAccessPolicies
|
|
10241
|
+
* @summary postcmdbUserDeviceAccessPolicyAssignDeviceAccessPolicies
|
|
10242
|
+
*
|
|
10243
|
+
* @param {object} body - body param
|
|
10244
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
10245
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
10246
|
+
* @return {object} results - An object containing the response of the action
|
|
10247
|
+
*
|
|
10248
|
+
* @route {POST} /postcmdbUserDeviceAccessPolicyAssignDeviceAccessPolicies
|
|
10249
|
+
* @roles admin
|
|
10250
|
+
* @task true
|
|
10251
|
+
*/
|
|
10252
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
10253
|
+
postcmdbUserDeviceAccessPolicyAssignDeviceAccessPolicies(body, iapMetadata, callback) {
|
|
10254
|
+
const meth = 'adapter-postcmdbUserDeviceAccessPolicyAssignDeviceAccessPolicies';
|
|
10255
|
+
const origin = `${this.id}-${meth}`;
|
|
10256
|
+
log.trace(origin);
|
|
10257
|
+
|
|
10258
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
10259
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
10260
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10261
|
+
return callback(null, errorObj);
|
|
10262
|
+
}
|
|
10263
|
+
|
|
10264
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
10265
|
+
if (body === undefined || body === null || body === '') {
|
|
10266
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
10267
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10268
|
+
return callback(null, errorObj);
|
|
10269
|
+
}
|
|
10270
|
+
|
|
10271
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
10272
|
+
const queryParamsAvailable = {};
|
|
10273
|
+
const queryParams = {};
|
|
10274
|
+
const pathVars = [];
|
|
10275
|
+
const bodyVars = body;
|
|
10276
|
+
|
|
10277
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
10278
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
10279
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
10280
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
10281
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
10282
|
+
}
|
|
10283
|
+
});
|
|
10284
|
+
|
|
10285
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
10286
|
+
let thisHeaderData = null;
|
|
10287
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
10288
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
10289
|
+
try {
|
|
10290
|
+
// parse the additional headers object that was passed in
|
|
10291
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
10292
|
+
} catch (err) {
|
|
10293
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
10294
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10295
|
+
return callback(null, errorObj);
|
|
10296
|
+
}
|
|
10297
|
+
} else if (thisHeaderData === null) {
|
|
10298
|
+
thisHeaderData = { postmanToken: '', cacheControl: '', token: '' };
|
|
10299
|
+
}
|
|
10300
|
+
|
|
10301
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
10302
|
+
// see adapter code documentation for more information on the request object's fields
|
|
10303
|
+
const reqObj = {
|
|
10304
|
+
payload: bodyVars,
|
|
10305
|
+
uriPathVars: pathVars,
|
|
10306
|
+
uriQuery: queryParams,
|
|
10307
|
+
addlHeaders: thisHeaderData
|
|
10308
|
+
};
|
|
10309
|
+
|
|
10310
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
10311
|
+
|
|
10312
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
10313
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
10314
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
10315
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
10316
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
10317
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
10318
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
10319
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
10320
|
+
} else {
|
|
10321
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
10322
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
10323
|
+
}
|
|
10324
|
+
}
|
|
10325
|
+
});
|
|
10326
|
+
// Add iapMetadata to reqObj for further work
|
|
10327
|
+
reqObj.iapMetadata = iapMetadata;
|
|
10328
|
+
}
|
|
10329
|
+
|
|
10330
|
+
try {
|
|
10331
|
+
// Make the call -
|
|
10332
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
10333
|
+
return this.requestHandlerInst.identifyRequest('DeviceAccessControl', 'postcmdbUserDeviceAccessPolicyAssignDeviceAccessPolicies', reqObj, true, (irReturnData, irReturnError) => {
|
|
10334
|
+
// if we received an error or their is no response on the results
|
|
10335
|
+
// return an error
|
|
10336
|
+
if (irReturnError) {
|
|
10337
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
10338
|
+
return callback(null, irReturnError);
|
|
10339
|
+
}
|
|
10340
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
10341
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postcmdbUserDeviceAccessPolicyAssignDeviceAccessPolicies'], null, null, null);
|
|
10342
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10343
|
+
return callback(null, errorObj);
|
|
10344
|
+
}
|
|
10345
|
+
|
|
10346
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
10347
|
+
// return the response
|
|
10348
|
+
return callback(irReturnData, null);
|
|
10349
|
+
});
|
|
10350
|
+
} catch (ex) {
|
|
10351
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
10352
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10353
|
+
return callback(null, errorObj);
|
|
10354
|
+
}
|
|
10355
|
+
}
|
|
10356
|
+
|
|
10357
|
+
/**
|
|
10358
|
+
* @function deletecmdbDeviceAccessPolicy
|
|
10359
|
+
* @pronghornType method
|
|
10360
|
+
* @name deletecmdbDeviceAccessPolicy
|
|
10361
|
+
* @summary deletecmdbDeviceAccessPolicy
|
|
10362
|
+
*
|
|
10363
|
+
* @param {string} deviceGroup - Device Group
|
|
10364
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
10365
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
10366
|
+
* @return {object} results - An object containing the response of the action
|
|
10367
|
+
*
|
|
10368
|
+
* @route {GET} /deletecmdbDeviceAccessPolicy
|
|
10369
|
+
* @roles admin
|
|
10370
|
+
* @task true
|
|
10371
|
+
*/
|
|
10372
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
10373
|
+
deletecmdbDeviceAccessPolicy(deviceGroup, iapMetadata, callback) {
|
|
10374
|
+
const meth = 'adapter-deletecmdbDeviceAccessPolicy';
|
|
10375
|
+
const origin = `${this.id}-${meth}`;
|
|
10376
|
+
log.trace(origin);
|
|
10377
|
+
|
|
10378
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
10379
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
10380
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10381
|
+
return callback(null, errorObj);
|
|
10382
|
+
}
|
|
10383
|
+
|
|
10384
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
10385
|
+
|
|
10386
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
10387
|
+
const queryParamsAvailable = {};
|
|
10388
|
+
const queryParams = {};
|
|
10389
|
+
const pathVars = [deviceGroup];
|
|
10390
|
+
const bodyVars = {};
|
|
10391
|
+
|
|
10392
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
10393
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
10394
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
10395
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
10396
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
10397
|
+
}
|
|
10398
|
+
});
|
|
10399
|
+
|
|
10400
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
10401
|
+
let thisHeaderData = null;
|
|
10402
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
10403
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
10404
|
+
try {
|
|
10405
|
+
// parse the additional headers object that was passed in
|
|
10406
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
10407
|
+
} catch (err) {
|
|
10408
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
10409
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10410
|
+
return callback(null, errorObj);
|
|
10411
|
+
}
|
|
10412
|
+
} else if (thisHeaderData === null) {
|
|
10413
|
+
thisHeaderData = { postmanToken: '', cacheControl: '', token: '' };
|
|
10414
|
+
}
|
|
10415
|
+
|
|
10416
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
10417
|
+
// see adapter code documentation for more information on the request object's fields
|
|
10418
|
+
const reqObj = {
|
|
10419
|
+
payload: bodyVars,
|
|
10420
|
+
uriPathVars: pathVars,
|
|
10421
|
+
uriQuery: queryParams,
|
|
10422
|
+
addlHeaders: thisHeaderData
|
|
10423
|
+
};
|
|
10424
|
+
|
|
10425
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
10426
|
+
|
|
10427
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
10428
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
10429
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
10430
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
10431
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
10432
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
10433
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
10434
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
10435
|
+
} else {
|
|
10436
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
10437
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
10438
|
+
}
|
|
10439
|
+
}
|
|
10440
|
+
});
|
|
10441
|
+
// Add iapMetadata to reqObj for further work
|
|
10442
|
+
reqObj.iapMetadata = iapMetadata;
|
|
10443
|
+
}
|
|
10444
|
+
|
|
10445
|
+
try {
|
|
10446
|
+
// Make the call -
|
|
10447
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
10448
|
+
return this.requestHandlerInst.identifyRequest('DeviceAccessControl', 'deletecmdbDeviceAccessPolicy', reqObj, false, (irReturnData, irReturnError) => {
|
|
10449
|
+
// if we received an error or their is no response on the results
|
|
10450
|
+
// return an error
|
|
10451
|
+
if (irReturnError) {
|
|
10452
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
10453
|
+
return callback(null, irReturnError);
|
|
10454
|
+
}
|
|
10455
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
10456
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletecmdbDeviceAccessPolicy'], null, null, null);
|
|
10457
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10458
|
+
return callback(null, errorObj);
|
|
10459
|
+
}
|
|
10460
|
+
|
|
10461
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
10462
|
+
// return the response
|
|
10463
|
+
return callback(irReturnData, null);
|
|
10464
|
+
});
|
|
10465
|
+
} catch (ex) {
|
|
10466
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
10467
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10468
|
+
return callback(null, errorObj);
|
|
10469
|
+
}
|
|
10470
|
+
}
|
|
10471
|
+
|
|
10472
|
+
/**
|
|
10473
|
+
* @function getcmdbUserDeviceAccessPolicy
|
|
10474
|
+
* @pronghornType method
|
|
10475
|
+
* @name getcmdbUserDeviceAccessPolicy
|
|
10476
|
+
* @summary getcmdbUserDeviceAccessPolicy
|
|
10477
|
+
*
|
|
10478
|
+
* @param {string} authenticationServer - authenticationServer param
|
|
10479
|
+
* @param {string} userName - userName param
|
|
10480
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
10481
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
10482
|
+
* @return {object} results - An object containing the response of the action
|
|
10483
|
+
*
|
|
10484
|
+
* @route {POST} /getcmdbUserDeviceAccessPolicy
|
|
10485
|
+
* @roles admin
|
|
10486
|
+
* @task true
|
|
10487
|
+
*/
|
|
10488
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
10489
|
+
getcmdbUserDeviceAccessPolicy(authenticationServer, userName, iapMetadata, callback) {
|
|
10490
|
+
const meth = 'adapter-getcmdbUserDeviceAccessPolicy';
|
|
10491
|
+
const origin = `${this.id}-${meth}`;
|
|
10492
|
+
log.trace(origin);
|
|
10493
|
+
|
|
10494
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
10495
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
10496
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10497
|
+
return callback(null, errorObj);
|
|
10498
|
+
}
|
|
10499
|
+
|
|
10500
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
10501
|
+
if (authenticationServer === undefined || authenticationServer === null || authenticationServer === '') {
|
|
10502
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['authenticationServer'], null, null, null);
|
|
10503
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10504
|
+
return callback(null, errorObj);
|
|
10505
|
+
}
|
|
10506
|
+
if (userName === undefined || userName === null || userName === '') {
|
|
10507
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['userName'], null, null, null);
|
|
10508
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10509
|
+
return callback(null, errorObj);
|
|
10510
|
+
}
|
|
10511
|
+
|
|
10512
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
10513
|
+
const queryParamsAvailable = { authenticationServer, userName };
|
|
10514
|
+
const queryParams = {};
|
|
10515
|
+
const pathVars = [];
|
|
10516
|
+
const bodyVars = {};
|
|
10517
|
+
|
|
10518
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
10519
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
10520
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
10521
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
10522
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
10523
|
+
}
|
|
10524
|
+
});
|
|
10525
|
+
|
|
10526
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
10527
|
+
let thisHeaderData = null;
|
|
10528
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
10529
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
10530
|
+
try {
|
|
10531
|
+
// parse the additional headers object that was passed in
|
|
10532
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
10533
|
+
} catch (err) {
|
|
10534
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
10535
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10536
|
+
return callback(null, errorObj);
|
|
10537
|
+
}
|
|
10538
|
+
} else if (thisHeaderData === null) {
|
|
10539
|
+
thisHeaderData = { postmanToken: '', cacheControl: '', token: '' };
|
|
10540
|
+
}
|
|
10541
|
+
|
|
10542
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
10543
|
+
// see adapter code documentation for more information on the request object's fields
|
|
10544
|
+
const reqObj = {
|
|
10545
|
+
payload: bodyVars,
|
|
10546
|
+
uriPathVars: pathVars,
|
|
10547
|
+
uriQuery: queryParams,
|
|
10548
|
+
addlHeaders: thisHeaderData
|
|
10549
|
+
};
|
|
10550
|
+
|
|
10551
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
10552
|
+
|
|
10553
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
10554
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
10555
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
10556
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
10557
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
10558
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
10559
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
10560
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
10561
|
+
} else {
|
|
10562
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
10563
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
10564
|
+
}
|
|
10565
|
+
}
|
|
10566
|
+
});
|
|
10567
|
+
// Add iapMetadata to reqObj for further work
|
|
10568
|
+
reqObj.iapMetadata = iapMetadata;
|
|
10569
|
+
}
|
|
10570
|
+
|
|
10571
|
+
try {
|
|
10572
|
+
// Make the call -
|
|
10573
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
10574
|
+
return this.requestHandlerInst.identifyRequest('DeviceAccessControl', 'getcmdbUserDeviceAccessPolicy', reqObj, true, (irReturnData, irReturnError) => {
|
|
10575
|
+
// if we received an error or their is no response on the results
|
|
10576
|
+
// return an error
|
|
10577
|
+
if (irReturnError) {
|
|
10578
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
10579
|
+
return callback(null, irReturnError);
|
|
10580
|
+
}
|
|
10581
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
10582
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getcmdbUserDeviceAccessPolicy'], null, null, null);
|
|
10583
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10584
|
+
return callback(null, errorObj);
|
|
10585
|
+
}
|
|
10586
|
+
|
|
10587
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
10588
|
+
// return the response
|
|
10589
|
+
return callback(irReturnData, null);
|
|
10590
|
+
});
|
|
10591
|
+
} catch (ex) {
|
|
10592
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
10593
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10594
|
+
return callback(null, errorObj);
|
|
10595
|
+
}
|
|
10596
|
+
}
|
|
10597
|
+
|
|
10598
|
+
/**
|
|
10599
|
+
* @function deletecmdbUserDeviceAccessPolicy
|
|
10600
|
+
* @pronghornType method
|
|
10601
|
+
* @name deletecmdbUserDeviceAccessPolicy
|
|
10602
|
+
* @summary deletecmdbUserDeviceAccessPolicy
|
|
10603
|
+
*
|
|
10604
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
10605
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
10606
|
+
* @return {object} results - An object containing the response of the action
|
|
10607
|
+
*
|
|
10608
|
+
* @route {GET} /deletecmdbUserDeviceAccessPolicy
|
|
10609
|
+
* @roles admin
|
|
10610
|
+
* @task true
|
|
10611
|
+
*/
|
|
10612
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
10613
|
+
deletecmdbUserDeviceAccessPolicy(iapMetadata, callback) {
|
|
10614
|
+
const meth = 'adapter-deletecmdbUserDeviceAccessPolicy';
|
|
10615
|
+
const origin = `${this.id}-${meth}`;
|
|
10616
|
+
log.trace(origin);
|
|
10617
|
+
|
|
10618
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
10619
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
10620
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10621
|
+
return callback(null, errorObj);
|
|
10622
|
+
}
|
|
10623
|
+
|
|
10624
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
10625
|
+
|
|
10626
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
10627
|
+
const queryParamsAvailable = {};
|
|
10628
|
+
const queryParams = {};
|
|
10629
|
+
const pathVars = [];
|
|
10630
|
+
const bodyVars = {};
|
|
10631
|
+
|
|
10632
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
10633
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
10634
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
10635
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
10636
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
10637
|
+
}
|
|
10638
|
+
});
|
|
10639
|
+
|
|
10640
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
10641
|
+
let thisHeaderData = null;
|
|
10642
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
10643
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
10644
|
+
try {
|
|
10645
|
+
// parse the additional headers object that was passed in
|
|
10646
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
10647
|
+
} catch (err) {
|
|
10648
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
10649
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10650
|
+
return callback(null, errorObj);
|
|
10651
|
+
}
|
|
10652
|
+
} else if (thisHeaderData === null) {
|
|
10653
|
+
thisHeaderData = { contentType: '', postmanToken: '', cacheControl: '', token: '' };
|
|
10654
|
+
}
|
|
10655
|
+
|
|
10656
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
10657
|
+
// see adapter code documentation for more information on the request object's fields
|
|
10658
|
+
const reqObj = {
|
|
10659
|
+
payload: bodyVars,
|
|
10660
|
+
uriPathVars: pathVars,
|
|
10661
|
+
uriQuery: queryParams,
|
|
10662
|
+
addlHeaders: thisHeaderData
|
|
10663
|
+
};
|
|
10664
|
+
|
|
10665
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
10666
|
+
|
|
10667
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
10668
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
10669
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
10670
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
10671
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
10672
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
10673
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
10674
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
10675
|
+
} else {
|
|
10676
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
10677
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
10678
|
+
}
|
|
10679
|
+
}
|
|
10680
|
+
});
|
|
10681
|
+
// Add iapMetadata to reqObj for further work
|
|
10682
|
+
reqObj.iapMetadata = iapMetadata;
|
|
10683
|
+
}
|
|
10684
|
+
|
|
10685
|
+
try {
|
|
10686
|
+
// Make the call -
|
|
10687
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
10688
|
+
return this.requestHandlerInst.identifyRequest('DeviceAccessControl', 'deletecmdbUserDeviceAccessPolicy', reqObj, false, (irReturnData, irReturnError) => {
|
|
10689
|
+
// if we received an error or their is no response on the results
|
|
10690
|
+
// return an error
|
|
10691
|
+
if (irReturnError) {
|
|
10692
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
10693
|
+
return callback(null, irReturnError);
|
|
10694
|
+
}
|
|
10695
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
10696
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletecmdbUserDeviceAccessPolicy'], null, null, null);
|
|
10697
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10698
|
+
return callback(null, errorObj);
|
|
10699
|
+
}
|
|
10700
|
+
|
|
10701
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
10702
|
+
// return the response
|
|
10703
|
+
return callback(irReturnData, null);
|
|
10704
|
+
});
|
|
10705
|
+
} catch (ex) {
|
|
10706
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
10707
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10708
|
+
return callback(null, errorObj);
|
|
10709
|
+
}
|
|
10710
|
+
}
|
|
10711
|
+
|
|
10712
|
+
/**
|
|
10713
|
+
* @function postcmdbUserDeviceAccessPolicy
|
|
10714
|
+
* @pronghornType method
|
|
10715
|
+
* @name postcmdbUserDeviceAccessPolicy
|
|
10716
|
+
* @summary postcmdbUserDeviceAccessPolicy
|
|
10717
|
+
*
|
|
10718
|
+
* @param {object} body - body param
|
|
10719
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
10720
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
10721
|
+
* @return {object} results - An object containing the response of the action
|
|
10722
|
+
*
|
|
10723
|
+
* @route {POST} /postcmdbUserDeviceAccessPolicy
|
|
10724
|
+
* @roles admin
|
|
10725
|
+
* @task true
|
|
10726
|
+
*/
|
|
10727
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
10728
|
+
postcmdbUserDeviceAccessPolicy(body, iapMetadata, callback) {
|
|
10729
|
+
const meth = 'adapter-postcmdbUserDeviceAccessPolicy';
|
|
10730
|
+
const origin = `${this.id}-${meth}`;
|
|
10731
|
+
log.trace(origin);
|
|
10732
|
+
|
|
10733
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
10734
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
10735
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10736
|
+
return callback(null, errorObj);
|
|
10737
|
+
}
|
|
10738
|
+
|
|
10739
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
10740
|
+
if (body === undefined || body === null || body === '') {
|
|
10741
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
10742
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10743
|
+
return callback(null, errorObj);
|
|
10744
|
+
}
|
|
10745
|
+
|
|
10746
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
10747
|
+
const queryParamsAvailable = {};
|
|
10748
|
+
const queryParams = {};
|
|
10749
|
+
const pathVars = [];
|
|
10750
|
+
const bodyVars = body;
|
|
10751
|
+
|
|
10752
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
10753
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
10754
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
10755
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
10756
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
10757
|
+
}
|
|
10758
|
+
});
|
|
10759
|
+
|
|
10760
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
10761
|
+
let thisHeaderData = null;
|
|
10762
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
10763
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
10764
|
+
try {
|
|
10765
|
+
// parse the additional headers object that was passed in
|
|
10766
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
10767
|
+
} catch (err) {
|
|
10768
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
10769
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10770
|
+
return callback(null, errorObj);
|
|
10771
|
+
}
|
|
10772
|
+
} else if (thisHeaderData === null) {
|
|
10773
|
+
thisHeaderData = { postmanToken: '', cacheControl: '', token: '' };
|
|
10774
|
+
}
|
|
10775
|
+
|
|
10776
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
10777
|
+
// see adapter code documentation for more information on the request object's fields
|
|
10778
|
+
const reqObj = {
|
|
10779
|
+
payload: bodyVars,
|
|
10780
|
+
uriPathVars: pathVars,
|
|
10781
|
+
uriQuery: queryParams,
|
|
10782
|
+
addlHeaders: thisHeaderData
|
|
10783
|
+
};
|
|
10784
|
+
|
|
10785
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
10786
|
+
|
|
10787
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
10788
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
10789
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
10790
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
10791
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
10792
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
10793
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
10794
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
10795
|
+
} else {
|
|
10796
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
10797
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
10798
|
+
}
|
|
10799
|
+
}
|
|
10800
|
+
});
|
|
10801
|
+
// Add iapMetadata to reqObj for further work
|
|
10802
|
+
reqObj.iapMetadata = iapMetadata;
|
|
10803
|
+
}
|
|
10804
|
+
|
|
10805
|
+
try {
|
|
10806
|
+
// Make the call -
|
|
10807
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
10808
|
+
return this.requestHandlerInst.identifyRequest('DeviceAccessControl', 'postcmdbUserDeviceAccessPolicy', reqObj, true, (irReturnData, irReturnError) => {
|
|
10809
|
+
// if we received an error or their is no response on the results
|
|
10810
|
+
// return an error
|
|
10811
|
+
if (irReturnError) {
|
|
10812
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
10813
|
+
return callback(null, irReturnError);
|
|
10814
|
+
}
|
|
10815
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
10816
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postcmdbUserDeviceAccessPolicy'], null, null, null);
|
|
10817
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10818
|
+
return callback(null, errorObj);
|
|
10819
|
+
}
|
|
10820
|
+
|
|
10821
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
10822
|
+
// return the response
|
|
10823
|
+
return callback(irReturnData, null);
|
|
10824
|
+
});
|
|
10825
|
+
} catch (ex) {
|
|
10826
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
10827
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10828
|
+
return callback(null, errorObj);
|
|
10829
|
+
}
|
|
10830
|
+
}
|
|
10831
|
+
|
|
10832
|
+
/**
|
|
10833
|
+
* @function getcmdbUserDeviceAccessPolicyUsersOfDeviceAccessPolicy
|
|
10834
|
+
* @pronghornType method
|
|
10835
|
+
* @name getcmdbUserDeviceAccessPolicyUsersOfDeviceAccessPolicy
|
|
10836
|
+
* @summary getcmdbUserDeviceAccessPolicyUsersOfDeviceAccessPolicy
|
|
10837
|
+
*
|
|
10838
|
+
* @param {string} name - name param
|
|
10839
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
10840
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
10841
|
+
* @return {object} results - An object containing the response of the action
|
|
10842
|
+
*
|
|
10843
|
+
* @route {POST} /getcmdbUserDeviceAccessPolicyUsersOfDeviceAccessPolicy
|
|
10844
|
+
* @roles admin
|
|
10845
|
+
* @task true
|
|
10846
|
+
*/
|
|
10847
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
10848
|
+
getcmdbUserDeviceAccessPolicyUsersOfDeviceAccessPolicy(name, iapMetadata, callback) {
|
|
10849
|
+
const meth = 'adapter-getcmdbUserDeviceAccessPolicyUsersOfDeviceAccessPolicy';
|
|
10850
|
+
const origin = `${this.id}-${meth}`;
|
|
10851
|
+
log.trace(origin);
|
|
10852
|
+
|
|
10853
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
10854
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
10855
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10856
|
+
return callback(null, errorObj);
|
|
10857
|
+
}
|
|
10858
|
+
|
|
10859
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
10860
|
+
if (name === undefined || name === null || name === '') {
|
|
10861
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['name'], null, null, null);
|
|
10862
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10863
|
+
return callback(null, errorObj);
|
|
10864
|
+
}
|
|
10865
|
+
|
|
10866
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
10867
|
+
const queryParamsAvailable = { name };
|
|
10868
|
+
const queryParams = {};
|
|
10869
|
+
const pathVars = [];
|
|
10870
|
+
const bodyVars = {};
|
|
10871
|
+
|
|
10872
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
10873
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
10874
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
10875
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
10876
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
10877
|
+
}
|
|
10878
|
+
});
|
|
10879
|
+
|
|
10880
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
10881
|
+
let thisHeaderData = null;
|
|
10882
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
10883
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
10884
|
+
try {
|
|
10885
|
+
// parse the additional headers object that was passed in
|
|
10886
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
10887
|
+
} catch (err) {
|
|
10888
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
10889
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10890
|
+
return callback(null, errorObj);
|
|
10891
|
+
}
|
|
10892
|
+
} else if (thisHeaderData === null) {
|
|
10893
|
+
thisHeaderData = { postmanToken: '', cacheControl: '', token: '' };
|
|
10894
|
+
}
|
|
10895
|
+
|
|
10896
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
10897
|
+
// see adapter code documentation for more information on the request object's fields
|
|
10898
|
+
const reqObj = {
|
|
10899
|
+
payload: bodyVars,
|
|
10900
|
+
uriPathVars: pathVars,
|
|
10901
|
+
uriQuery: queryParams,
|
|
10902
|
+
addlHeaders: thisHeaderData
|
|
10903
|
+
};
|
|
10904
|
+
|
|
10905
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
10906
|
+
|
|
10907
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
10908
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
10909
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
10910
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
10911
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
10912
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
10913
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
10914
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
10915
|
+
} else {
|
|
10916
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
10917
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
10918
|
+
}
|
|
10919
|
+
}
|
|
10920
|
+
});
|
|
10921
|
+
// Add iapMetadata to reqObj for further work
|
|
10922
|
+
reqObj.iapMetadata = iapMetadata;
|
|
10923
|
+
}
|
|
10924
|
+
|
|
10925
|
+
try {
|
|
10926
|
+
// Make the call -
|
|
10927
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
10928
|
+
return this.requestHandlerInst.identifyRequest('DeviceAccessControl', 'getcmdbUserDeviceAccessPolicyUsersOfDeviceAccessPolicy', reqObj, true, (irReturnData, irReturnError) => {
|
|
10929
|
+
// if we received an error or their is no response on the results
|
|
10930
|
+
// return an error
|
|
10931
|
+
if (irReturnError) {
|
|
10932
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
10933
|
+
return callback(null, irReturnError);
|
|
10934
|
+
}
|
|
10935
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
10936
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getcmdbUserDeviceAccessPolicyUsersOfDeviceAccessPolicy'], null, null, null);
|
|
10937
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10938
|
+
return callback(null, errorObj);
|
|
10939
|
+
}
|
|
10940
|
+
|
|
10941
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
10942
|
+
// return the response
|
|
10943
|
+
return callback(irReturnData, null);
|
|
10944
|
+
});
|
|
10945
|
+
} catch (ex) {
|
|
10946
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
10947
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10948
|
+
return callback(null, errorObj);
|
|
10949
|
+
}
|
|
10950
|
+
}
|
|
10951
|
+
|
|
10952
|
+
/**
|
|
10953
|
+
* @function postcmdbDeviceGroups
|
|
10954
|
+
* @pronghornType method
|
|
10955
|
+
* @name postcmdbDeviceGroups
|
|
10956
|
+
* @summary postcmdbDeviceGroups
|
|
10957
|
+
*
|
|
10958
|
+
* @param {object} body - body param
|
|
10959
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
10960
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
10961
|
+
* @return {object} results - An object containing the response of the action
|
|
10962
|
+
*
|
|
10963
|
+
* @route {POST} /postcmdbDeviceGroups
|
|
10964
|
+
* @roles admin
|
|
10965
|
+
* @task true
|
|
10966
|
+
*/
|
|
10967
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
10968
|
+
postcmdbDeviceGroups(body, iapMetadata, callback) {
|
|
10969
|
+
const meth = 'adapter-postcmdbDeviceGroups';
|
|
10970
|
+
const origin = `${this.id}-${meth}`;
|
|
10971
|
+
log.trace(origin);
|
|
10972
|
+
|
|
10973
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
10974
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
10975
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10976
|
+
return callback(null, errorObj);
|
|
10977
|
+
}
|
|
10978
|
+
|
|
10979
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
10980
|
+
if (body === undefined || body === null || body === '') {
|
|
10981
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
10982
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
10983
|
+
return callback(null, errorObj);
|
|
10984
|
+
}
|
|
10985
|
+
|
|
10986
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
10987
|
+
const queryParamsAvailable = {};
|
|
10988
|
+
const queryParams = {};
|
|
10989
|
+
const pathVars = [];
|
|
10990
|
+
const bodyVars = body;
|
|
10991
|
+
|
|
10992
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
10993
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
10994
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
10995
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
10996
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
10997
|
+
}
|
|
10998
|
+
});
|
|
10999
|
+
|
|
11000
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
11001
|
+
let thisHeaderData = null;
|
|
11002
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
11003
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
11004
|
+
try {
|
|
11005
|
+
// parse the additional headers object that was passed in
|
|
11006
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
11007
|
+
} catch (err) {
|
|
11008
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
11009
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11010
|
+
return callback(null, errorObj);
|
|
11011
|
+
}
|
|
11012
|
+
} else if (thisHeaderData === null) {
|
|
11013
|
+
thisHeaderData = { accept: '', token: '' };
|
|
11014
|
+
}
|
|
11015
|
+
|
|
11016
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
11017
|
+
// see adapter code documentation for more information on the request object's fields
|
|
11018
|
+
const reqObj = {
|
|
11019
|
+
payload: bodyVars,
|
|
11020
|
+
uriPathVars: pathVars,
|
|
11021
|
+
uriQuery: queryParams,
|
|
11022
|
+
addlHeaders: thisHeaderData
|
|
11023
|
+
};
|
|
11024
|
+
|
|
11025
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
11026
|
+
|
|
11027
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
11028
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
11029
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
11030
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
11031
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
11032
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
11033
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
11034
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
11035
|
+
} else {
|
|
11036
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
11037
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
11038
|
+
}
|
|
11039
|
+
}
|
|
11040
|
+
});
|
|
11041
|
+
// Add iapMetadata to reqObj for further work
|
|
11042
|
+
reqObj.iapMetadata = iapMetadata;
|
|
11043
|
+
}
|
|
11044
|
+
|
|
11045
|
+
try {
|
|
11046
|
+
// Make the call -
|
|
11047
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
11048
|
+
return this.requestHandlerInst.identifyRequest('DeviceGroupManagement', 'postcmdbDeviceGroups', reqObj, true, (irReturnData, irReturnError) => {
|
|
11049
|
+
// if we received an error or their is no response on the results
|
|
11050
|
+
// return an error
|
|
11051
|
+
if (irReturnError) {
|
|
11052
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
11053
|
+
return callback(null, irReturnError);
|
|
11054
|
+
}
|
|
11055
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
11056
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postcmdbDeviceGroups'], null, null, null);
|
|
11057
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11058
|
+
return callback(null, errorObj);
|
|
11059
|
+
}
|
|
11060
|
+
|
|
11061
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
11062
|
+
// return the response
|
|
11063
|
+
return callback(irReturnData, null);
|
|
11064
|
+
});
|
|
11065
|
+
} catch (ex) {
|
|
11066
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
11067
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11068
|
+
return callback(null, errorObj);
|
|
11069
|
+
}
|
|
11070
|
+
}
|
|
11071
|
+
|
|
11072
|
+
/**
|
|
11073
|
+
* @function postcmdbDeviceGroupsDevices
|
|
11074
|
+
* @pronghornType method
|
|
11075
|
+
* @name postcmdbDeviceGroupsDevices
|
|
11076
|
+
* @summary postcmdbDeviceGroupsDevices
|
|
11077
|
+
*
|
|
11078
|
+
* @param {string} id - id param
|
|
11079
|
+
* @param {object} body - body param
|
|
11080
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
11081
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
11082
|
+
* @return {object} results - An object containing the response of the action
|
|
11083
|
+
*
|
|
11084
|
+
* @route {POST} /postcmdbDeviceGroupsDevices
|
|
11085
|
+
* @roles admin
|
|
11086
|
+
* @task true
|
|
11087
|
+
*/
|
|
11088
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
11089
|
+
postcmdbDeviceGroupsDevices(id, body, iapMetadata, callback) {
|
|
11090
|
+
const meth = 'adapter-postcmdbDeviceGroupsDevices';
|
|
11091
|
+
const origin = `${this.id}-${meth}`;
|
|
11092
|
+
log.trace(origin);
|
|
11093
|
+
|
|
11094
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
11095
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
11096
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11097
|
+
return callback(null, errorObj);
|
|
11098
|
+
}
|
|
11099
|
+
|
|
11100
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
11101
|
+
if (id === undefined || id === null || id === '') {
|
|
11102
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
|
|
11103
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11104
|
+
return callback(null, errorObj);
|
|
11105
|
+
}
|
|
11106
|
+
if (body === undefined || body === null || body === '') {
|
|
11107
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
11108
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11109
|
+
return callback(null, errorObj);
|
|
11110
|
+
}
|
|
11111
|
+
|
|
11112
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
11113
|
+
const queryParamsAvailable = {};
|
|
11114
|
+
const queryParams = {};
|
|
11115
|
+
const pathVars = [id];
|
|
11116
|
+
const bodyVars = body;
|
|
11117
|
+
|
|
11118
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
11119
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
11120
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
11121
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
11122
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
11123
|
+
}
|
|
11124
|
+
});
|
|
11125
|
+
|
|
11126
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
11127
|
+
let thisHeaderData = null;
|
|
11128
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
11129
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
11130
|
+
try {
|
|
11131
|
+
// parse the additional headers object that was passed in
|
|
11132
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
11133
|
+
} catch (err) {
|
|
11134
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
11135
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11136
|
+
return callback(null, errorObj);
|
|
11137
|
+
}
|
|
11138
|
+
} else if (thisHeaderData === null) {
|
|
11139
|
+
thisHeaderData = { accept: '', token: '' };
|
|
11140
|
+
}
|
|
11141
|
+
|
|
11142
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
11143
|
+
// see adapter code documentation for more information on the request object's fields
|
|
11144
|
+
const reqObj = {
|
|
11145
|
+
payload: bodyVars,
|
|
11146
|
+
uriPathVars: pathVars,
|
|
11147
|
+
uriQuery: queryParams,
|
|
11148
|
+
addlHeaders: thisHeaderData
|
|
11149
|
+
};
|
|
11150
|
+
|
|
11151
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
11152
|
+
|
|
11153
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
11154
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
11155
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
11156
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
11157
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
11158
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
11159
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
11160
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
11161
|
+
} else {
|
|
11162
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
11163
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
11164
|
+
}
|
|
11165
|
+
}
|
|
11166
|
+
});
|
|
11167
|
+
// Add iapMetadata to reqObj for further work
|
|
11168
|
+
reqObj.iapMetadata = iapMetadata;
|
|
11169
|
+
}
|
|
11170
|
+
|
|
11171
|
+
try {
|
|
11172
|
+
// Make the call -
|
|
11173
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
11174
|
+
return this.requestHandlerInst.identifyRequest('DeviceGroupManagement', 'postcmdbDeviceGroupsDevices', reqObj, true, (irReturnData, irReturnError) => {
|
|
11175
|
+
// if we received an error or their is no response on the results
|
|
11176
|
+
// return an error
|
|
11177
|
+
if (irReturnError) {
|
|
11178
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
11179
|
+
return callback(null, irReturnError);
|
|
11180
|
+
}
|
|
11181
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
11182
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postcmdbDeviceGroupsDevices'], null, null, null);
|
|
11183
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11184
|
+
return callback(null, errorObj);
|
|
11185
|
+
}
|
|
11186
|
+
|
|
11187
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
11188
|
+
// return the response
|
|
11189
|
+
return callback(irReturnData, null);
|
|
11190
|
+
});
|
|
11191
|
+
} catch (ex) {
|
|
11192
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
11193
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11194
|
+
return callback(null, errorObj);
|
|
11195
|
+
}
|
|
11196
|
+
}
|
|
11197
|
+
|
|
11198
|
+
/**
|
|
11199
|
+
* @function deletecmdbDeviceGroupsDevices
|
|
11200
|
+
* @pronghornType method
|
|
11201
|
+
* @name deletecmdbDeviceGroupsDevices
|
|
11202
|
+
* @summary deletecmdbDeviceGroupsDevices
|
|
11203
|
+
*
|
|
11204
|
+
* @param {string} id - id param
|
|
11205
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
11206
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
11207
|
+
* @return {object} results - An object containing the response of the action
|
|
11208
|
+
*
|
|
11209
|
+
* @route {POST} /deletecmdbDeviceGroupsDevices
|
|
11210
|
+
* @roles admin
|
|
11211
|
+
* @task true
|
|
11212
|
+
*/
|
|
11213
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
11214
|
+
deletecmdbDeviceGroupsDevices(id, iapMetadata, callback) {
|
|
11215
|
+
const meth = 'adapter-deletecmdbDeviceGroupsDevices';
|
|
11216
|
+
const origin = `${this.id}-${meth}`;
|
|
11217
|
+
log.trace(origin);
|
|
11218
|
+
|
|
11219
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
11220
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
11221
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11222
|
+
return callback(null, errorObj);
|
|
11223
|
+
}
|
|
11224
|
+
|
|
11225
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
11226
|
+
if (id === undefined || id === null || id === '') {
|
|
11227
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
|
|
11228
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11229
|
+
return callback(null, errorObj);
|
|
11230
|
+
}
|
|
11231
|
+
|
|
11232
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
11233
|
+
const queryParamsAvailable = {};
|
|
11234
|
+
const queryParams = {};
|
|
11235
|
+
const pathVars = [id];
|
|
11236
|
+
const bodyVars = {};
|
|
11237
|
+
|
|
11238
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
11239
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
11240
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
11241
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
11242
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
11243
|
+
}
|
|
11244
|
+
});
|
|
11245
|
+
|
|
11246
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
11247
|
+
let thisHeaderData = null;
|
|
11248
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
11249
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
11250
|
+
try {
|
|
11251
|
+
// parse the additional headers object that was passed in
|
|
11252
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
11253
|
+
} catch (err) {
|
|
11254
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
11255
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11256
|
+
return callback(null, errorObj);
|
|
11257
|
+
}
|
|
11258
|
+
} else if (thisHeaderData === null) {
|
|
11259
|
+
thisHeaderData = { accept: '', contentType: '', token: '' };
|
|
11260
|
+
}
|
|
11261
|
+
|
|
11262
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
11263
|
+
// see adapter code documentation for more information on the request object's fields
|
|
11264
|
+
const reqObj = {
|
|
11265
|
+
payload: bodyVars,
|
|
11266
|
+
uriPathVars: pathVars,
|
|
11267
|
+
uriQuery: queryParams,
|
|
11268
|
+
addlHeaders: thisHeaderData
|
|
11269
|
+
};
|
|
11270
|
+
|
|
11271
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
11272
|
+
|
|
11273
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
11274
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
11275
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
11276
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
11277
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
11278
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
11279
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
11280
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
11281
|
+
} else {
|
|
11282
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
11283
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
11284
|
+
}
|
|
11285
|
+
}
|
|
11286
|
+
});
|
|
11287
|
+
// Add iapMetadata to reqObj for further work
|
|
11288
|
+
reqObj.iapMetadata = iapMetadata;
|
|
11289
|
+
}
|
|
11290
|
+
|
|
11291
|
+
try {
|
|
11292
|
+
// Make the call -
|
|
11293
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
11294
|
+
return this.requestHandlerInst.identifyRequest('DeviceGroupManagement', 'deletecmdbDeviceGroupsDevices', reqObj, false, (irReturnData, irReturnError) => {
|
|
11295
|
+
// if we received an error or their is no response on the results
|
|
11296
|
+
// return an error
|
|
11297
|
+
if (irReturnError) {
|
|
11298
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
11299
|
+
return callback(null, irReturnError);
|
|
11300
|
+
}
|
|
11301
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
11302
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletecmdbDeviceGroupsDevices'], null, null, null);
|
|
11303
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11304
|
+
return callback(null, errorObj);
|
|
11305
|
+
}
|
|
11306
|
+
|
|
11307
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
11308
|
+
// return the response
|
|
11309
|
+
return callback(irReturnData, null);
|
|
11310
|
+
});
|
|
11311
|
+
} catch (ex) {
|
|
11312
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
11313
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11314
|
+
return callback(null, errorObj);
|
|
11315
|
+
}
|
|
11316
|
+
}
|
|
11317
|
+
|
|
11318
|
+
/**
|
|
11319
|
+
* @function getcmdbDeviceGroupsDevices
|
|
11320
|
+
* @pronghornType method
|
|
11321
|
+
* @name getcmdbDeviceGroupsDevices
|
|
11322
|
+
* @summary getcmdbDeviceGroupsDevices
|
|
11323
|
+
*
|
|
11324
|
+
* @param {string} id - id param
|
|
11325
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
11326
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
11327
|
+
* @return {object} results - An object containing the response of the action
|
|
11328
|
+
*
|
|
11329
|
+
* @route {POST} /getcmdbDeviceGroupsDevices
|
|
11330
|
+
* @roles admin
|
|
11331
|
+
* @task true
|
|
11332
|
+
*/
|
|
11333
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
11334
|
+
getcmdbDeviceGroupsDevices(id, iapMetadata, callback) {
|
|
11335
|
+
const meth = 'adapter-getcmdbDeviceGroupsDevices';
|
|
11336
|
+
const origin = `${this.id}-${meth}`;
|
|
11337
|
+
log.trace(origin);
|
|
11338
|
+
|
|
11339
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
11340
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
11341
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11342
|
+
return callback(null, errorObj);
|
|
11343
|
+
}
|
|
11344
|
+
|
|
11345
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
11346
|
+
if (id === undefined || id === null || id === '') {
|
|
11347
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
|
|
11348
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11349
|
+
return callback(null, errorObj);
|
|
11350
|
+
}
|
|
11351
|
+
|
|
11352
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
11353
|
+
const queryParamsAvailable = {};
|
|
11354
|
+
const queryParams = {};
|
|
11355
|
+
const pathVars = [id];
|
|
11356
|
+
const bodyVars = {};
|
|
11357
|
+
|
|
11358
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
11359
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
11360
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
11361
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
11362
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
11363
|
+
}
|
|
11364
|
+
});
|
|
11365
|
+
|
|
11366
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
11367
|
+
let thisHeaderData = null;
|
|
11368
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
11369
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
11370
|
+
try {
|
|
11371
|
+
// parse the additional headers object that was passed in
|
|
11372
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
11373
|
+
} catch (err) {
|
|
11374
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
11375
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11376
|
+
return callback(null, errorObj);
|
|
11377
|
+
}
|
|
11378
|
+
} else if (thisHeaderData === null) {
|
|
11379
|
+
thisHeaderData = { accept: '', contentType: '', token: '' };
|
|
11380
|
+
}
|
|
11381
|
+
|
|
11382
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
11383
|
+
// see adapter code documentation for more information on the request object's fields
|
|
11384
|
+
const reqObj = {
|
|
11385
|
+
payload: bodyVars,
|
|
11386
|
+
uriPathVars: pathVars,
|
|
11387
|
+
uriQuery: queryParams,
|
|
11388
|
+
addlHeaders: thisHeaderData
|
|
11389
|
+
};
|
|
11390
|
+
|
|
11391
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
11392
|
+
|
|
11393
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
11394
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
11395
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
11396
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
11397
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
11398
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
11399
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
11400
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
11401
|
+
} else {
|
|
11402
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
11403
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
11404
|
+
}
|
|
11405
|
+
}
|
|
11406
|
+
});
|
|
11407
|
+
// Add iapMetadata to reqObj for further work
|
|
11408
|
+
reqObj.iapMetadata = iapMetadata;
|
|
11409
|
+
}
|
|
11410
|
+
|
|
11411
|
+
try {
|
|
11412
|
+
// Make the call -
|
|
11413
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
11414
|
+
return this.requestHandlerInst.identifyRequest('DeviceGroupManagement', 'getcmdbDeviceGroupsDevices', reqObj, true, (irReturnData, irReturnError) => {
|
|
11415
|
+
// if we received an error or their is no response on the results
|
|
11416
|
+
// return an error
|
|
11417
|
+
if (irReturnError) {
|
|
11418
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
11419
|
+
return callback(null, irReturnError);
|
|
11420
|
+
}
|
|
11421
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
11422
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getcmdbDeviceGroupsDevices'], null, null, null);
|
|
11423
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11424
|
+
return callback(null, errorObj);
|
|
11425
|
+
}
|
|
11426
|
+
|
|
11427
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
11428
|
+
// return the response
|
|
11429
|
+
return callback(irReturnData, null);
|
|
11430
|
+
});
|
|
11431
|
+
} catch (ex) {
|
|
11432
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
11433
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11434
|
+
return callback(null, errorObj);
|
|
11435
|
+
}
|
|
11436
|
+
}
|
|
11437
|
+
|
|
11438
|
+
/**
|
|
11439
|
+
* @function deletecmdbDeviceGroups
|
|
11440
|
+
* @pronghornType method
|
|
11441
|
+
* @name deletecmdbDeviceGroups
|
|
11442
|
+
* @summary deletecmdbDeviceGroups
|
|
11443
|
+
*
|
|
11444
|
+
* @param {string} id - id param
|
|
11445
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
11446
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
11447
|
+
* @return {object} results - An object containing the response of the action
|
|
11448
|
+
*
|
|
11449
|
+
* @route {POST} /deletecmdbDeviceGroups
|
|
11450
|
+
* @roles admin
|
|
11451
|
+
* @task true
|
|
11452
|
+
*/
|
|
11453
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
11454
|
+
deletecmdbDeviceGroups(id, iapMetadata, callback) {
|
|
11455
|
+
const meth = 'adapter-deletecmdbDeviceGroups';
|
|
11456
|
+
const origin = `${this.id}-${meth}`;
|
|
11457
|
+
log.trace(origin);
|
|
11458
|
+
|
|
11459
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
11460
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
11461
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11462
|
+
return callback(null, errorObj);
|
|
11463
|
+
}
|
|
11464
|
+
|
|
11465
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
11466
|
+
if (id === undefined || id === null || id === '') {
|
|
11467
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['id'], null, null, null);
|
|
11468
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11469
|
+
return callback(null, errorObj);
|
|
11470
|
+
}
|
|
11471
|
+
|
|
11472
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
11473
|
+
const queryParamsAvailable = {};
|
|
11474
|
+
const queryParams = {};
|
|
11475
|
+
const pathVars = [id];
|
|
11476
|
+
const bodyVars = {};
|
|
11477
|
+
|
|
11478
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
11479
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
11480
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
11481
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
11482
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
11483
|
+
}
|
|
11484
|
+
});
|
|
11485
|
+
|
|
11486
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
11487
|
+
let thisHeaderData = null;
|
|
11488
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
11489
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
11490
|
+
try {
|
|
11491
|
+
// parse the additional headers object that was passed in
|
|
11492
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
11493
|
+
} catch (err) {
|
|
11494
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
11495
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11496
|
+
return callback(null, errorObj);
|
|
11497
|
+
}
|
|
11498
|
+
} else if (thisHeaderData === null) {
|
|
11499
|
+
thisHeaderData = { accept: '', contentType: '', token: '' };
|
|
11500
|
+
}
|
|
11501
|
+
|
|
11502
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
11503
|
+
// see adapter code documentation for more information on the request object's fields
|
|
11504
|
+
const reqObj = {
|
|
11505
|
+
payload: bodyVars,
|
|
11506
|
+
uriPathVars: pathVars,
|
|
11507
|
+
uriQuery: queryParams,
|
|
11508
|
+
addlHeaders: thisHeaderData
|
|
11509
|
+
};
|
|
11510
|
+
|
|
11511
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
11512
|
+
|
|
11513
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
11514
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
11515
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
11516
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
11517
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
11518
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
11519
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
11520
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
11521
|
+
} else {
|
|
11522
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
11523
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
11524
|
+
}
|
|
11525
|
+
}
|
|
11526
|
+
});
|
|
11527
|
+
// Add iapMetadata to reqObj for further work
|
|
11528
|
+
reqObj.iapMetadata = iapMetadata;
|
|
11529
|
+
}
|
|
11530
|
+
|
|
11531
|
+
try {
|
|
11532
|
+
// Make the call -
|
|
11533
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
11534
|
+
return this.requestHandlerInst.identifyRequest('DeviceGroupManagement', 'deletecmdbDeviceGroups', reqObj, false, (irReturnData, irReturnError) => {
|
|
11535
|
+
// if we received an error or their is no response on the results
|
|
11536
|
+
// return an error
|
|
11537
|
+
if (irReturnError) {
|
|
11538
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
11539
|
+
return callback(null, irReturnError);
|
|
11540
|
+
}
|
|
11541
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
11542
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletecmdbDeviceGroups'], null, null, null);
|
|
11543
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11544
|
+
return callback(null, errorObj);
|
|
11545
|
+
}
|
|
11546
|
+
|
|
11547
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
11548
|
+
// return the response
|
|
11549
|
+
return callback(irReturnData, null);
|
|
11550
|
+
});
|
|
11551
|
+
} catch (ex) {
|
|
11552
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
11553
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11554
|
+
return callback(null, errorObj);
|
|
11555
|
+
}
|
|
11556
|
+
}
|
|
11557
|
+
|
|
11558
|
+
/**
|
|
11559
|
+
* @function postcmdbInterfacesAttributes
|
|
11560
|
+
* @pronghornType method
|
|
11561
|
+
* @name postcmdbInterfacesAttributes
|
|
11562
|
+
* @summary postcmdbInterfacesAttributes
|
|
11563
|
+
*
|
|
11564
|
+
* @param {object} body - body param
|
|
11565
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
11566
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
11567
|
+
* @return {object} results - An object containing the response of the action
|
|
11568
|
+
*
|
|
11569
|
+
* @route {POST} /postcmdbInterfacesAttributes
|
|
11570
|
+
* @roles admin
|
|
11571
|
+
* @task true
|
|
11572
|
+
*/
|
|
11573
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
11574
|
+
postcmdbInterfacesAttributes(body, iapMetadata, callback) {
|
|
11575
|
+
const meth = 'adapter-postcmdbInterfacesAttributes';
|
|
11576
|
+
const origin = `${this.id}-${meth}`;
|
|
11577
|
+
log.trace(origin);
|
|
11578
|
+
|
|
11579
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
11580
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
11581
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11582
|
+
return callback(null, errorObj);
|
|
11583
|
+
}
|
|
11584
|
+
|
|
11585
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
11586
|
+
if (body === undefined || body === null || body === '') {
|
|
11587
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
11588
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11589
|
+
return callback(null, errorObj);
|
|
11590
|
+
}
|
|
11591
|
+
|
|
11592
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
11593
|
+
const queryParamsAvailable = {};
|
|
11594
|
+
const queryParams = {};
|
|
11595
|
+
const pathVars = [];
|
|
11596
|
+
const bodyVars = body;
|
|
11597
|
+
|
|
11598
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
11599
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
11600
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
11601
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
11602
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
11603
|
+
}
|
|
11604
|
+
});
|
|
11605
|
+
|
|
11606
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
11607
|
+
let thisHeaderData = null;
|
|
11608
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
11609
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
11610
|
+
try {
|
|
11611
|
+
// parse the additional headers object that was passed in
|
|
11612
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
11613
|
+
} catch (err) {
|
|
11614
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
11615
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11616
|
+
return callback(null, errorObj);
|
|
11617
|
+
}
|
|
11618
|
+
} else if (thisHeaderData === null) {
|
|
11619
|
+
thisHeaderData = { postmanToken: '', cacheControl: '', token: '' };
|
|
11620
|
+
}
|
|
11621
|
+
|
|
11622
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
11623
|
+
// see adapter code documentation for more information on the request object's fields
|
|
11624
|
+
const reqObj = {
|
|
11625
|
+
payload: bodyVars,
|
|
11626
|
+
uriPathVars: pathVars,
|
|
11627
|
+
uriQuery: queryParams,
|
|
11628
|
+
addlHeaders: thisHeaderData
|
|
11629
|
+
};
|
|
11630
|
+
|
|
11631
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
11632
|
+
|
|
11633
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
11634
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
11635
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
11636
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
11637
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
11638
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
11639
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
11640
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
11641
|
+
} else {
|
|
11642
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
11643
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
11644
|
+
}
|
|
11645
|
+
}
|
|
11646
|
+
});
|
|
11647
|
+
// Add iapMetadata to reqObj for further work
|
|
11648
|
+
reqObj.iapMetadata = iapMetadata;
|
|
11649
|
+
}
|
|
11650
|
+
|
|
11651
|
+
try {
|
|
11652
|
+
// Make the call -
|
|
11653
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
11654
|
+
return this.requestHandlerInst.identifyRequest('DeviceInterfacesManagement', 'postcmdbInterfacesAttributes', reqObj, true, (irReturnData, irReturnError) => {
|
|
11655
|
+
// if we received an error or their is no response on the results
|
|
11656
|
+
// return an error
|
|
11657
|
+
if (irReturnError) {
|
|
11658
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
11659
|
+
return callback(null, irReturnError);
|
|
11660
|
+
}
|
|
11661
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
11662
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postcmdbInterfacesAttributes'], null, null, null);
|
|
11663
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11664
|
+
return callback(null, errorObj);
|
|
11665
|
+
}
|
|
11666
|
+
|
|
11667
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
11668
|
+
// return the response
|
|
11669
|
+
return callback(irReturnData, null);
|
|
11670
|
+
});
|
|
11671
|
+
} catch (ex) {
|
|
11672
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
11673
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11674
|
+
return callback(null, errorObj);
|
|
11675
|
+
}
|
|
11676
|
+
}
|
|
11677
|
+
|
|
11678
|
+
/**
|
|
11679
|
+
* @function deletecmdbDiscoveryTasks
|
|
11680
|
+
* @pronghornType method
|
|
11681
|
+
* @name deletecmdbDiscoveryTasks
|
|
11682
|
+
* @summary deletecmdbDiscoveryTasks
|
|
11683
|
+
*
|
|
11684
|
+
* @param {string} task - task param
|
|
11685
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
11686
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
11687
|
+
* @return {object} results - An object containing the response of the action
|
|
11688
|
+
*
|
|
11689
|
+
* @route {POST} /deletecmdbDiscoveryTasks
|
|
11690
|
+
* @roles admin
|
|
11691
|
+
* @task true
|
|
11692
|
+
*/
|
|
11693
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
11694
|
+
deletecmdbDiscoveryTasks(task, iapMetadata, callback) {
|
|
11695
|
+
const meth = 'adapter-deletecmdbDiscoveryTasks';
|
|
11696
|
+
const origin = `${this.id}-${meth}`;
|
|
11697
|
+
log.trace(origin);
|
|
11698
|
+
|
|
11699
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
11700
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
11701
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11702
|
+
return callback(null, errorObj);
|
|
11703
|
+
}
|
|
11704
|
+
|
|
11705
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
11706
|
+
if (task === undefined || task === null || task === '') {
|
|
11707
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['task'], null, null, null);
|
|
11708
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11709
|
+
return callback(null, errorObj);
|
|
11710
|
+
}
|
|
11711
|
+
|
|
11712
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
11713
|
+
const queryParamsAvailable = {};
|
|
11714
|
+
const queryParams = {};
|
|
11715
|
+
const pathVars = [task];
|
|
11716
|
+
const bodyVars = {};
|
|
11717
|
+
|
|
11718
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
11719
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
11720
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
11721
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
11722
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
11723
|
+
}
|
|
11724
|
+
});
|
|
11725
|
+
|
|
11726
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
11727
|
+
let thisHeaderData = null;
|
|
11728
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
11729
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
11730
|
+
try {
|
|
11731
|
+
// parse the additional headers object that was passed in
|
|
11732
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
11733
|
+
} catch (err) {
|
|
11734
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
11735
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11736
|
+
return callback(null, errorObj);
|
|
11737
|
+
}
|
|
11738
|
+
} else if (thisHeaderData === null) {
|
|
11739
|
+
thisHeaderData = { accept: '', cacheControl: '', connection: '', host: '', postmanToken: '', userAgent: '', acceptEncoding: '', contentLength: '', token: '' };
|
|
11740
|
+
}
|
|
11741
|
+
|
|
11742
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
11743
|
+
// see adapter code documentation for more information on the request object's fields
|
|
11744
|
+
const reqObj = {
|
|
11745
|
+
payload: bodyVars,
|
|
11746
|
+
uriPathVars: pathVars,
|
|
11747
|
+
uriQuery: queryParams,
|
|
11748
|
+
addlHeaders: thisHeaderData
|
|
11749
|
+
};
|
|
11750
|
+
|
|
11751
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
11752
|
+
|
|
11753
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
11754
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
11755
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
11756
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
11757
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
11758
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
11759
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
11760
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
11761
|
+
} else {
|
|
11762
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
11763
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
11764
|
+
}
|
|
11765
|
+
}
|
|
11766
|
+
});
|
|
11767
|
+
// Add iapMetadata to reqObj for further work
|
|
11768
|
+
reqObj.iapMetadata = iapMetadata;
|
|
11769
|
+
}
|
|
11770
|
+
|
|
11771
|
+
try {
|
|
11772
|
+
// Make the call -
|
|
11773
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
11774
|
+
return this.requestHandlerInst.identifyRequest('DiscoveryTaskManagement', 'deletecmdbDiscoveryTasks', reqObj, false, (irReturnData, irReturnError) => {
|
|
11775
|
+
// if we received an error or their is no response on the results
|
|
11776
|
+
// return an error
|
|
11777
|
+
if (irReturnError) {
|
|
11778
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
11779
|
+
return callback(null, irReturnError);
|
|
11780
|
+
}
|
|
11781
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
11782
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletecmdbDiscoveryTasks'], null, null, null);
|
|
11783
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11784
|
+
return callback(null, errorObj);
|
|
11785
|
+
}
|
|
11786
|
+
|
|
11787
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
11788
|
+
// return the response
|
|
11789
|
+
return callback(irReturnData, null);
|
|
11790
|
+
});
|
|
11791
|
+
} catch (ex) {
|
|
11792
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
11793
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11794
|
+
return callback(null, errorObj);
|
|
11795
|
+
}
|
|
11796
|
+
}
|
|
11797
|
+
|
|
11798
|
+
/**
|
|
11799
|
+
* @function putcmdbDiscoveryTasks
|
|
11800
|
+
* @pronghornType method
|
|
11801
|
+
* @name putcmdbDiscoveryTasks
|
|
11802
|
+
* @summary putcmdbDiscoveryTasks
|
|
11803
|
+
*
|
|
11804
|
+
* @param {string} body - body param
|
|
11805
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
11806
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
11807
|
+
* @return {object} results - An object containing the response of the action
|
|
11808
|
+
*
|
|
11809
|
+
* @route {POST} /putcmdbDiscoveryTasks
|
|
11810
|
+
* @roles admin
|
|
11811
|
+
* @task true
|
|
11812
|
+
*/
|
|
11813
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
11814
|
+
putcmdbDiscoveryTasks(body, iapMetadata, callback) {
|
|
11815
|
+
const meth = 'adapter-putcmdbDiscoveryTasks';
|
|
11816
|
+
const origin = `${this.id}-${meth}`;
|
|
11817
|
+
log.trace(origin);
|
|
11818
|
+
|
|
11819
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
11820
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
11821
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11822
|
+
return callback(null, errorObj);
|
|
11823
|
+
}
|
|
11824
|
+
|
|
11825
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
11826
|
+
if (body === undefined || body === null || body === '') {
|
|
11827
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
11828
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11829
|
+
return callback(null, errorObj);
|
|
11830
|
+
}
|
|
11831
|
+
|
|
11832
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
11833
|
+
const queryParamsAvailable = {};
|
|
11834
|
+
const queryParams = {};
|
|
11835
|
+
const pathVars = [];
|
|
11836
|
+
const bodyVars = { body };
|
|
11837
|
+
|
|
11838
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
11839
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
11840
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
11841
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
11842
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
11843
|
+
}
|
|
11844
|
+
});
|
|
11845
|
+
|
|
11846
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
11847
|
+
let thisHeaderData = null;
|
|
11848
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
11849
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
11850
|
+
try {
|
|
11851
|
+
// parse the additional headers object that was passed in
|
|
11852
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
11853
|
+
} catch (err) {
|
|
11854
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
11855
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11856
|
+
return callback(null, errorObj);
|
|
11857
|
+
}
|
|
11858
|
+
} else if (thisHeaderData === null) {
|
|
11859
|
+
thisHeaderData = { accept: '', cacheControl: '', connection: '', host: '', postmanToken: '', userAgent: '', acceptEncoding: '', contentLength: '', token: '' };
|
|
11860
|
+
}
|
|
11861
|
+
|
|
11862
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
11863
|
+
// see adapter code documentation for more information on the request object's fields
|
|
11864
|
+
const reqObj = {
|
|
11865
|
+
payload: bodyVars,
|
|
11866
|
+
uriPathVars: pathVars,
|
|
11867
|
+
uriQuery: queryParams,
|
|
11868
|
+
addlHeaders: thisHeaderData
|
|
11869
|
+
};
|
|
11870
|
+
|
|
11871
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
11872
|
+
|
|
11873
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
11874
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
11875
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
11876
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
11877
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
11878
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
11879
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
11880
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
11881
|
+
} else {
|
|
11882
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
11883
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
11884
|
+
}
|
|
11885
|
+
}
|
|
11886
|
+
});
|
|
11887
|
+
// Add iapMetadata to reqObj for further work
|
|
11888
|
+
reqObj.iapMetadata = iapMetadata;
|
|
11889
|
+
}
|
|
11890
|
+
|
|
11891
|
+
try {
|
|
11892
|
+
// Make the call -
|
|
11893
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
11894
|
+
return this.requestHandlerInst.identifyRequest('DiscoveryTaskManagement', 'putcmdbDiscoveryTasks', reqObj, false, (irReturnData, irReturnError) => {
|
|
11895
|
+
// if we received an error or their is no response on the results
|
|
11896
|
+
// return an error
|
|
11897
|
+
if (irReturnError) {
|
|
11898
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
11899
|
+
return callback(null, irReturnError);
|
|
11900
|
+
}
|
|
11901
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
11902
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['putcmdbDiscoveryTasks'], null, null, null);
|
|
11903
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11904
|
+
return callback(null, errorObj);
|
|
11905
|
+
}
|
|
11906
|
+
|
|
11907
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
11908
|
+
// return the response
|
|
11909
|
+
return callback(irReturnData, null);
|
|
11910
|
+
});
|
|
11911
|
+
} catch (ex) {
|
|
11912
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
11913
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11914
|
+
return callback(null, errorObj);
|
|
11915
|
+
}
|
|
11916
|
+
}
|
|
11917
|
+
|
|
11918
|
+
/**
|
|
11919
|
+
* @function postcmdbDiscoveryTasks
|
|
11920
|
+
* @pronghornType method
|
|
11921
|
+
* @name postcmdbDiscoveryTasks
|
|
11922
|
+
* @summary postcmdbDiscoveryTasks
|
|
11923
|
+
*
|
|
11924
|
+
* @param {string} body - body param
|
|
11925
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
11926
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
11927
|
+
* @return {object} results - An object containing the response of the action
|
|
11928
|
+
*
|
|
11929
|
+
* @route {POST} /postcmdbDiscoveryTasks
|
|
11930
|
+
* @roles admin
|
|
11931
|
+
* @task true
|
|
11932
|
+
*/
|
|
11933
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
11934
|
+
postcmdbDiscoveryTasks(body, iapMetadata, callback) {
|
|
11935
|
+
const meth = 'adapter-postcmdbDiscoveryTasks';
|
|
11936
|
+
const origin = `${this.id}-${meth}`;
|
|
11937
|
+
log.trace(origin);
|
|
11938
|
+
|
|
11939
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
11940
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
11941
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11942
|
+
return callback(null, errorObj);
|
|
11943
|
+
}
|
|
11944
|
+
|
|
11945
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
11946
|
+
if (body === undefined || body === null || body === '') {
|
|
11947
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
11948
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11949
|
+
return callback(null, errorObj);
|
|
11950
|
+
}
|
|
11951
|
+
|
|
11952
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
11953
|
+
const queryParamsAvailable = {};
|
|
11954
|
+
const queryParams = {};
|
|
11955
|
+
const pathVars = [];
|
|
11956
|
+
const bodyVars = { body };
|
|
11957
|
+
|
|
11958
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
11959
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
11960
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
11961
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
11962
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
11963
|
+
}
|
|
11964
|
+
});
|
|
11965
|
+
|
|
11966
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
11967
|
+
let thisHeaderData = null;
|
|
11968
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
11969
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
11970
|
+
try {
|
|
11971
|
+
// parse the additional headers object that was passed in
|
|
11972
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
11973
|
+
} catch (err) {
|
|
11974
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
11975
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
11976
|
+
return callback(null, errorObj);
|
|
11977
|
+
}
|
|
11978
|
+
} else if (thisHeaderData === null) {
|
|
11979
|
+
thisHeaderData = { accept: '', cacheControl: '', connection: '', host: '', postmanToken: '', userAgent: '', acceptEncoding: '', contentLength: '', token: '' };
|
|
11980
|
+
}
|
|
11981
|
+
|
|
11982
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
11983
|
+
// see adapter code documentation for more information on the request object's fields
|
|
11984
|
+
const reqObj = {
|
|
11985
|
+
payload: bodyVars,
|
|
11986
|
+
uriPathVars: pathVars,
|
|
11987
|
+
uriQuery: queryParams,
|
|
11988
|
+
addlHeaders: thisHeaderData
|
|
11989
|
+
};
|
|
11990
|
+
|
|
11991
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
11992
|
+
|
|
11993
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
11994
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
11995
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
11996
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
11997
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
11998
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
11999
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
12000
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
12001
|
+
} else {
|
|
12002
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
12003
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
12004
|
+
}
|
|
12005
|
+
}
|
|
12006
|
+
});
|
|
12007
|
+
// Add iapMetadata to reqObj for further work
|
|
12008
|
+
reqObj.iapMetadata = iapMetadata;
|
|
12009
|
+
}
|
|
12010
|
+
|
|
12011
|
+
try {
|
|
12012
|
+
// Make the call -
|
|
12013
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
12014
|
+
return this.requestHandlerInst.identifyRequest('DiscoveryTaskManagement', 'postcmdbDiscoveryTasks', reqObj, true, (irReturnData, irReturnError) => {
|
|
12015
|
+
// if we received an error or their is no response on the results
|
|
12016
|
+
// return an error
|
|
12017
|
+
if (irReturnError) {
|
|
12018
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
12019
|
+
return callback(null, irReturnError);
|
|
12020
|
+
}
|
|
12021
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
12022
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postcmdbDiscoveryTasks'], null, null, null);
|
|
12023
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12024
|
+
return callback(null, errorObj);
|
|
12025
|
+
}
|
|
12026
|
+
|
|
12027
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
12028
|
+
// return the response
|
|
12029
|
+
return callback(irReturnData, null);
|
|
12030
|
+
});
|
|
12031
|
+
} catch (ex) {
|
|
12032
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
12033
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12034
|
+
return callback(null, errorObj);
|
|
12035
|
+
}
|
|
12036
|
+
}
|
|
12037
|
+
|
|
12038
|
+
/**
|
|
12039
|
+
* @function getcmdbDiscoveryTasksResults
|
|
12040
|
+
* @pronghornType method
|
|
12041
|
+
* @name getcmdbDiscoveryTasksResults
|
|
12042
|
+
* @summary getcmdbDiscoveryTasksResults
|
|
12043
|
+
*
|
|
12044
|
+
* @param {string} task - task param
|
|
12045
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
12046
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
12047
|
+
* @return {object} results - An object containing the response of the action
|
|
12048
|
+
*
|
|
12049
|
+
* @route {POST} /getcmdbDiscoveryTasksResults
|
|
12050
|
+
* @roles admin
|
|
12051
|
+
* @task true
|
|
12052
|
+
*/
|
|
12053
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
12054
|
+
getcmdbDiscoveryTasksResults(task, iapMetadata, callback) {
|
|
12055
|
+
const meth = 'adapter-getcmdbDiscoveryTasksResults';
|
|
12056
|
+
const origin = `${this.id}-${meth}`;
|
|
12057
|
+
log.trace(origin);
|
|
12058
|
+
|
|
12059
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
12060
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
12061
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12062
|
+
return callback(null, errorObj);
|
|
12063
|
+
}
|
|
12064
|
+
|
|
12065
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
12066
|
+
if (task === undefined || task === null || task === '') {
|
|
12067
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['task'], null, null, null);
|
|
12068
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12069
|
+
return callback(null, errorObj);
|
|
12070
|
+
}
|
|
12071
|
+
|
|
12072
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
12073
|
+
const queryParamsAvailable = {};
|
|
12074
|
+
const queryParams = {};
|
|
12075
|
+
const pathVars = [task];
|
|
12076
|
+
const bodyVars = {};
|
|
12077
|
+
|
|
12078
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
12079
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
12080
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
12081
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
12082
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
12083
|
+
}
|
|
12084
|
+
});
|
|
12085
|
+
|
|
12086
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
12087
|
+
let thisHeaderData = null;
|
|
12088
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
12089
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
12090
|
+
try {
|
|
12091
|
+
// parse the additional headers object that was passed in
|
|
12092
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
12093
|
+
} catch (err) {
|
|
12094
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
12095
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12096
|
+
return callback(null, errorObj);
|
|
12097
|
+
}
|
|
12098
|
+
} else if (thisHeaderData === null) {
|
|
12099
|
+
thisHeaderData = { postmanToken: '', cacheControl: '', token: '' };
|
|
12100
|
+
}
|
|
12101
|
+
|
|
12102
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
12103
|
+
// see adapter code documentation for more information on the request object's fields
|
|
12104
|
+
const reqObj = {
|
|
12105
|
+
payload: bodyVars,
|
|
12106
|
+
uriPathVars: pathVars,
|
|
12107
|
+
uriQuery: queryParams,
|
|
12108
|
+
addlHeaders: thisHeaderData
|
|
12109
|
+
};
|
|
12110
|
+
|
|
12111
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
12112
|
+
|
|
12113
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
12114
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
12115
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
12116
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
12117
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
12118
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
12119
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
12120
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
12121
|
+
} else {
|
|
12122
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
12123
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
12124
|
+
}
|
|
12125
|
+
}
|
|
12126
|
+
});
|
|
12127
|
+
// Add iapMetadata to reqObj for further work
|
|
12128
|
+
reqObj.iapMetadata = iapMetadata;
|
|
12129
|
+
}
|
|
12130
|
+
|
|
12131
|
+
try {
|
|
12132
|
+
// Make the call -
|
|
12133
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
12134
|
+
return this.requestHandlerInst.identifyRequest('DiscoveryTaskManagement', 'getcmdbDiscoveryTasksResults', reqObj, true, (irReturnData, irReturnError) => {
|
|
12135
|
+
// if we received an error or their is no response on the results
|
|
12136
|
+
// return an error
|
|
12137
|
+
if (irReturnError) {
|
|
12138
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
12139
|
+
return callback(null, irReturnError);
|
|
12140
|
+
}
|
|
12141
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
12142
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getcmdbDiscoveryTasksResults'], null, null, null);
|
|
12143
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12144
|
+
return callback(null, errorObj);
|
|
12145
|
+
}
|
|
12146
|
+
|
|
12147
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
12148
|
+
// return the response
|
|
12149
|
+
return callback(irReturnData, null);
|
|
12150
|
+
});
|
|
12151
|
+
} catch (ex) {
|
|
12152
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
12153
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12154
|
+
return callback(null, errorObj);
|
|
12155
|
+
}
|
|
12156
|
+
}
|
|
12157
|
+
|
|
12158
|
+
/**
|
|
12159
|
+
* @function deletecmdbEventConsole
|
|
12160
|
+
* @pronghornType method
|
|
12161
|
+
* @name deletecmdbEventConsole
|
|
12162
|
+
* @summary deletecmdbEventConsole
|
|
12163
|
+
*
|
|
12164
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
12165
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
12166
|
+
* @return {object} results - An object containing the response of the action
|
|
12167
|
+
*
|
|
12168
|
+
* @route {GET} /deletecmdbEventConsole
|
|
12169
|
+
* @roles admin
|
|
12170
|
+
* @task true
|
|
12171
|
+
*/
|
|
12172
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
12173
|
+
deletecmdbEventConsole(iapMetadata, callback) {
|
|
12174
|
+
const meth = 'adapter-deletecmdbEventConsole';
|
|
12175
|
+
const origin = `${this.id}-${meth}`;
|
|
12176
|
+
log.trace(origin);
|
|
12177
|
+
|
|
12178
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
12179
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
12180
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12181
|
+
return callback(null, errorObj);
|
|
12182
|
+
}
|
|
12183
|
+
|
|
12184
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
12185
|
+
|
|
12186
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
12187
|
+
const queryParamsAvailable = {};
|
|
12188
|
+
const queryParams = {};
|
|
12189
|
+
const pathVars = [];
|
|
12190
|
+
const bodyVars = {};
|
|
12191
|
+
|
|
12192
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
12193
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
12194
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
12195
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
12196
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
12197
|
+
}
|
|
12198
|
+
});
|
|
12199
|
+
|
|
12200
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
12201
|
+
let thisHeaderData = null;
|
|
12202
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
12203
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
12204
|
+
try {
|
|
12205
|
+
// parse the additional headers object that was passed in
|
|
12206
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
12207
|
+
} catch (err) {
|
|
12208
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
12209
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12210
|
+
return callback(null, errorObj);
|
|
12211
|
+
}
|
|
12212
|
+
} else if (thisHeaderData === null) {
|
|
12213
|
+
thisHeaderData = { accept: '', cacheControl: '', connection: '', contentType: '', host: '', postmanToken: '', userAgent: '', acceptEncoding: '', contentLength: '', token: '' };
|
|
12214
|
+
}
|
|
12215
|
+
|
|
12216
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
12217
|
+
// see adapter code documentation for more information on the request object's fields
|
|
12218
|
+
const reqObj = {
|
|
12219
|
+
payload: bodyVars,
|
|
12220
|
+
uriPathVars: pathVars,
|
|
12221
|
+
uriQuery: queryParams,
|
|
12222
|
+
addlHeaders: thisHeaderData
|
|
12223
|
+
};
|
|
12224
|
+
|
|
12225
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
12226
|
+
|
|
12227
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
12228
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
12229
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
12230
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
12231
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
12232
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
12233
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
12234
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
12235
|
+
} else {
|
|
12236
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
12237
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
12238
|
+
}
|
|
12239
|
+
}
|
|
12240
|
+
});
|
|
12241
|
+
// Add iapMetadata to reqObj for further work
|
|
12242
|
+
reqObj.iapMetadata = iapMetadata;
|
|
12243
|
+
}
|
|
12244
|
+
|
|
12245
|
+
try {
|
|
12246
|
+
// Make the call -
|
|
12247
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
12248
|
+
return this.requestHandlerInst.identifyRequest('EventConsoleManagement', 'deletecmdbEventConsole', reqObj, false, (irReturnData, irReturnError) => {
|
|
12249
|
+
// if we received an error or their is no response on the results
|
|
12250
|
+
// return an error
|
|
12251
|
+
if (irReturnError) {
|
|
12252
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
12253
|
+
return callback(null, irReturnError);
|
|
12254
|
+
}
|
|
12255
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
12256
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletecmdbEventConsole'], null, null, null);
|
|
12257
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12258
|
+
return callback(null, errorObj);
|
|
12259
|
+
}
|
|
12260
|
+
|
|
12261
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
12262
|
+
// return the response
|
|
12263
|
+
return callback(irReturnData, null);
|
|
12264
|
+
});
|
|
12265
|
+
} catch (ex) {
|
|
12266
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
12267
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12268
|
+
return callback(null, errorObj);
|
|
12269
|
+
}
|
|
12270
|
+
}
|
|
12271
|
+
|
|
12272
|
+
/**
|
|
12273
|
+
* @function getcmdbEventConsole
|
|
12274
|
+
* @pronghornType method
|
|
12275
|
+
* @name getcmdbEventConsole
|
|
12276
|
+
* @summary getcmdbEventConsole
|
|
12277
|
+
*
|
|
12278
|
+
* @param {string} eventType - eventType param
|
|
12279
|
+
* @param {string} eventLevel - eventLevel param
|
|
12280
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
12281
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
12282
|
+
* @return {object} results - An object containing the response of the action
|
|
12283
|
+
*
|
|
12284
|
+
* @route {POST} /getcmdbEventConsole
|
|
12285
|
+
* @roles admin
|
|
12286
|
+
* @task true
|
|
12287
|
+
*/
|
|
12288
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
12289
|
+
getcmdbEventConsole(eventType, eventLevel, iapMetadata, callback) {
|
|
12290
|
+
const meth = 'adapter-getcmdbEventConsole';
|
|
12291
|
+
const origin = `${this.id}-${meth}`;
|
|
12292
|
+
log.trace(origin);
|
|
12293
|
+
|
|
12294
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
12295
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
12296
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12297
|
+
return callback(null, errorObj);
|
|
12298
|
+
}
|
|
12299
|
+
|
|
12300
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
12301
|
+
if (eventType === undefined || eventType === null || eventType === '') {
|
|
12302
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['eventType'], null, null, null);
|
|
12303
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12304
|
+
return callback(null, errorObj);
|
|
12305
|
+
}
|
|
12306
|
+
if (eventLevel === undefined || eventLevel === null || eventLevel === '') {
|
|
12307
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['eventLevel'], null, null, null);
|
|
12308
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12309
|
+
return callback(null, errorObj);
|
|
12310
|
+
}
|
|
12311
|
+
|
|
12312
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
12313
|
+
const queryParamsAvailable = { eventType, eventLevel };
|
|
12314
|
+
const queryParams = {};
|
|
12315
|
+
const pathVars = [];
|
|
12316
|
+
const bodyVars = {};
|
|
12317
|
+
|
|
12318
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
12319
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
12320
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
12321
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
12322
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
12323
|
+
}
|
|
12324
|
+
});
|
|
12325
|
+
|
|
12326
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
12327
|
+
let thisHeaderData = null;
|
|
12328
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
12329
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
12330
|
+
try {
|
|
12331
|
+
// parse the additional headers object that was passed in
|
|
12332
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
12333
|
+
} catch (err) {
|
|
12334
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
12335
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12336
|
+
return callback(null, errorObj);
|
|
12337
|
+
}
|
|
12338
|
+
} else if (thisHeaderData === null) {
|
|
12339
|
+
thisHeaderData = { accept: '', cacheControl: '', connection: '', host: '', postmanToken: '', userAgent: '', acceptEncoding: '', token: '' };
|
|
12340
|
+
}
|
|
12341
|
+
|
|
12342
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
12343
|
+
// see adapter code documentation for more information on the request object's fields
|
|
12344
|
+
const reqObj = {
|
|
12345
|
+
payload: bodyVars,
|
|
12346
|
+
uriPathVars: pathVars,
|
|
12347
|
+
uriQuery: queryParams,
|
|
12348
|
+
addlHeaders: thisHeaderData
|
|
12349
|
+
};
|
|
12350
|
+
|
|
12351
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
12352
|
+
|
|
12353
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
12354
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
12355
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
12356
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
12357
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
12358
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
12359
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
12360
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
12361
|
+
} else {
|
|
12362
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
12363
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
12364
|
+
}
|
|
12365
|
+
}
|
|
12366
|
+
});
|
|
12367
|
+
// Add iapMetadata to reqObj for further work
|
|
12368
|
+
reqObj.iapMetadata = iapMetadata;
|
|
12369
|
+
}
|
|
12370
|
+
|
|
12371
|
+
try {
|
|
12372
|
+
// Make the call -
|
|
12373
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
12374
|
+
return this.requestHandlerInst.identifyRequest('EventConsoleManagement', 'getcmdbEventConsole', reqObj, true, (irReturnData, irReturnError) => {
|
|
12375
|
+
// if we received an error or their is no response on the results
|
|
12376
|
+
// return an error
|
|
12377
|
+
if (irReturnError) {
|
|
12378
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
12379
|
+
return callback(null, irReturnError);
|
|
12380
|
+
}
|
|
12381
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
12382
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getcmdbEventConsole'], null, null, null);
|
|
12383
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12384
|
+
return callback(null, errorObj);
|
|
12385
|
+
}
|
|
12386
|
+
|
|
12387
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
12388
|
+
// return the response
|
|
12389
|
+
return callback(irReturnData, null);
|
|
12390
|
+
});
|
|
12391
|
+
} catch (ex) {
|
|
12392
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
12393
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12394
|
+
return callback(null, errorObj);
|
|
12395
|
+
}
|
|
12396
|
+
}
|
|
12397
|
+
|
|
12398
|
+
/**
|
|
12399
|
+
* @function postcmdbIncidentList
|
|
12400
|
+
* @pronghornType method
|
|
12401
|
+
* @name postcmdbIncidentList
|
|
12402
|
+
* @summary postcmdbIncidentList
|
|
12403
|
+
*
|
|
12404
|
+
* @param {object} body - body param
|
|
12405
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
12406
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
12407
|
+
* @return {object} results - An object containing the response of the action
|
|
12408
|
+
*
|
|
12409
|
+
* @route {POST} /postcmdbIncidentList
|
|
12410
|
+
* @roles admin
|
|
12411
|
+
* @task true
|
|
12412
|
+
*/
|
|
12413
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
12414
|
+
postcmdbIncidentList(body, iapMetadata, callback) {
|
|
12415
|
+
const meth = 'adapter-postcmdbIncidentList';
|
|
12416
|
+
const origin = `${this.id}-${meth}`;
|
|
12417
|
+
log.trace(origin);
|
|
12418
|
+
|
|
12419
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
12420
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
12421
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12422
|
+
return callback(null, errorObj);
|
|
12423
|
+
}
|
|
12424
|
+
|
|
12425
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
12426
|
+
if (body === undefined || body === null || body === '') {
|
|
12427
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
12428
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12429
|
+
return callback(null, errorObj);
|
|
12430
|
+
}
|
|
12431
|
+
|
|
12432
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
12433
|
+
const queryParamsAvailable = {};
|
|
12434
|
+
const queryParams = {};
|
|
12435
|
+
const pathVars = [];
|
|
12436
|
+
const bodyVars = body;
|
|
12437
|
+
|
|
12438
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
12439
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
12440
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
12441
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
12442
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
12443
|
+
}
|
|
12444
|
+
});
|
|
12445
|
+
|
|
12446
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
12447
|
+
let thisHeaderData = null;
|
|
12448
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
12449
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
12450
|
+
try {
|
|
12451
|
+
// parse the additional headers object that was passed in
|
|
12452
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
12453
|
+
} catch (err) {
|
|
12454
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
12455
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12456
|
+
return callback(null, errorObj);
|
|
12457
|
+
}
|
|
12458
|
+
} else if (thisHeaderData === null) {
|
|
12459
|
+
thisHeaderData = { cacheControl: '', token: '' };
|
|
12460
|
+
}
|
|
12461
|
+
|
|
12462
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
12463
|
+
// see adapter code documentation for more information on the request object's fields
|
|
12464
|
+
const reqObj = {
|
|
12465
|
+
payload: bodyVars,
|
|
12466
|
+
uriPathVars: pathVars,
|
|
12467
|
+
uriQuery: queryParams,
|
|
12468
|
+
addlHeaders: thisHeaderData
|
|
12469
|
+
};
|
|
12470
|
+
|
|
12471
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
12472
|
+
|
|
12473
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
12474
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
12475
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
12476
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
12477
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
12478
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
12479
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
12480
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
12481
|
+
} else {
|
|
12482
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
12483
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
12484
|
+
}
|
|
12485
|
+
}
|
|
12486
|
+
});
|
|
12487
|
+
// Add iapMetadata to reqObj for further work
|
|
12488
|
+
reqObj.iapMetadata = iapMetadata;
|
|
12489
|
+
}
|
|
12490
|
+
|
|
12491
|
+
try {
|
|
12492
|
+
// Make the call -
|
|
12493
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
12494
|
+
return this.requestHandlerInst.identifyRequest('IncidentReport', 'postcmdbIncidentList', reqObj, true, (irReturnData, irReturnError) => {
|
|
12495
|
+
// if we received an error or their is no response on the results
|
|
12496
|
+
// return an error
|
|
12497
|
+
if (irReturnError) {
|
|
12498
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
12499
|
+
return callback(null, irReturnError);
|
|
12500
|
+
}
|
|
12501
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
12502
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postcmdbIncidentList'], null, null, null);
|
|
12503
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12504
|
+
return callback(null, errorObj);
|
|
12505
|
+
}
|
|
12506
|
+
|
|
12507
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
12508
|
+
// return the response
|
|
12509
|
+
return callback(irReturnData, null);
|
|
12510
|
+
});
|
|
12511
|
+
} catch (ex) {
|
|
12512
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
12513
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12514
|
+
return callback(null, errorObj);
|
|
12515
|
+
}
|
|
12516
|
+
}
|
|
12517
|
+
|
|
12518
|
+
/**
|
|
12519
|
+
* @function getcmdbNetworkSettingsTelnetInfoCheckDeviceCount
|
|
12520
|
+
* @pronghornType method
|
|
12521
|
+
* @name getcmdbNetworkSettingsTelnetInfoCheckDeviceCount
|
|
12522
|
+
* @summary getcmdbNetworkSettingsTelnetInfoCheckDeviceCount
|
|
12523
|
+
*
|
|
12524
|
+
* @param {string} alias - alias param
|
|
12525
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
12526
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
12527
|
+
* @return {object} results - An object containing the response of the action
|
|
12528
|
+
*
|
|
12529
|
+
* @route {POST} /getcmdbNetworkSettingsTelnetInfoCheckDeviceCount
|
|
12530
|
+
* @roles admin
|
|
12531
|
+
* @task true
|
|
12532
|
+
*/
|
|
12533
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
12534
|
+
getcmdbNetworkSettingsTelnetInfoCheckDeviceCount(alias, iapMetadata, callback) {
|
|
12535
|
+
const meth = 'adapter-getcmdbNetworkSettingsTelnetInfoCheckDeviceCount';
|
|
12536
|
+
const origin = `${this.id}-${meth}`;
|
|
12537
|
+
log.trace(origin);
|
|
12538
|
+
|
|
12539
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
12540
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
12541
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12542
|
+
return callback(null, errorObj);
|
|
12543
|
+
}
|
|
12544
|
+
|
|
12545
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
12546
|
+
if (alias === undefined || alias === null || alias === '') {
|
|
12547
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['alias'], null, null, null);
|
|
12548
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12549
|
+
return callback(null, errorObj);
|
|
12550
|
+
}
|
|
12551
|
+
|
|
12552
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
12553
|
+
const queryParamsAvailable = { alias };
|
|
12554
|
+
const queryParams = {};
|
|
12555
|
+
const pathVars = [];
|
|
12556
|
+
const bodyVars = {};
|
|
12557
|
+
|
|
12558
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
12559
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
12560
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
12561
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
12562
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
12563
|
+
}
|
|
12564
|
+
});
|
|
12565
|
+
|
|
12566
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
12567
|
+
let thisHeaderData = null;
|
|
12568
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
12569
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
12570
|
+
try {
|
|
12571
|
+
// parse the additional headers object that was passed in
|
|
12572
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
12573
|
+
} catch (err) {
|
|
12574
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
12575
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12576
|
+
return callback(null, errorObj);
|
|
12577
|
+
}
|
|
12578
|
+
} else if (thisHeaderData === null) {
|
|
12579
|
+
thisHeaderData = { accept: '', contentType: '', token: '' };
|
|
12580
|
+
}
|
|
12581
|
+
|
|
12582
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
12583
|
+
// see adapter code documentation for more information on the request object's fields
|
|
12584
|
+
const reqObj = {
|
|
12585
|
+
payload: bodyVars,
|
|
12586
|
+
uriPathVars: pathVars,
|
|
12587
|
+
uriQuery: queryParams,
|
|
12588
|
+
addlHeaders: thisHeaderData
|
|
12589
|
+
};
|
|
12590
|
+
|
|
12591
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
12592
|
+
|
|
12593
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
12594
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
12595
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
12596
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
12597
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
12598
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
12599
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
12600
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
12601
|
+
} else {
|
|
12602
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
12603
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
12604
|
+
}
|
|
12605
|
+
}
|
|
12606
|
+
});
|
|
12607
|
+
// Add iapMetadata to reqObj for further work
|
|
12608
|
+
reqObj.iapMetadata = iapMetadata;
|
|
12609
|
+
}
|
|
12610
|
+
|
|
12611
|
+
try {
|
|
12612
|
+
// Make the call -
|
|
12613
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
12614
|
+
return this.requestHandlerInst.identifyRequest('NetworkSettings', 'getcmdbNetworkSettingsTelnetInfoCheckDeviceCount', reqObj, true, (irReturnData, irReturnError) => {
|
|
12615
|
+
// if we received an error or their is no response on the results
|
|
12616
|
+
// return an error
|
|
12617
|
+
if (irReturnError) {
|
|
12618
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
12619
|
+
return callback(null, irReturnError);
|
|
12620
|
+
}
|
|
12621
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
12622
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getcmdbNetworkSettingsTelnetInfoCheckDeviceCount'], null, null, null);
|
|
12623
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12624
|
+
return callback(null, errorObj);
|
|
12625
|
+
}
|
|
12626
|
+
|
|
12627
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
12628
|
+
// return the response
|
|
12629
|
+
return callback(irReturnData, null);
|
|
12630
|
+
});
|
|
12631
|
+
} catch (ex) {
|
|
12632
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
12633
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12634
|
+
return callback(null, errorObj);
|
|
12635
|
+
}
|
|
12636
|
+
}
|
|
12637
|
+
|
|
12638
|
+
/**
|
|
12639
|
+
* @function getcmdbNetworkSettingsTelnetInfoRefreshDeviceCount
|
|
12640
|
+
* @pronghornType method
|
|
12641
|
+
* @name getcmdbNetworkSettingsTelnetInfoRefreshDeviceCount
|
|
12642
|
+
* @summary getcmdbNetworkSettingsTelnetInfoRefreshDeviceCount
|
|
12643
|
+
*
|
|
12644
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
12645
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
12646
|
+
* @return {object} results - An object containing the response of the action
|
|
12647
|
+
*
|
|
12648
|
+
* @route {GET} /getcmdbNetworkSettingsTelnetInfoRefreshDeviceCount
|
|
12649
|
+
* @roles admin
|
|
12650
|
+
* @task true
|
|
12651
|
+
*/
|
|
12652
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
12653
|
+
getcmdbNetworkSettingsTelnetInfoRefreshDeviceCount(iapMetadata, callback) {
|
|
12654
|
+
const meth = 'adapter-getcmdbNetworkSettingsTelnetInfoRefreshDeviceCount';
|
|
12655
|
+
const origin = `${this.id}-${meth}`;
|
|
12656
|
+
log.trace(origin);
|
|
12657
|
+
|
|
12658
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
12659
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
12660
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12661
|
+
return callback(null, errorObj);
|
|
12662
|
+
}
|
|
12663
|
+
|
|
12664
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
12665
|
+
|
|
12666
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
12667
|
+
const queryParamsAvailable = {};
|
|
12668
|
+
const queryParams = {};
|
|
12669
|
+
const pathVars = [];
|
|
12670
|
+
const bodyVars = {};
|
|
12671
|
+
|
|
12672
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
12673
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
12674
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
12675
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
12676
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
12677
|
+
}
|
|
12678
|
+
});
|
|
12679
|
+
|
|
12680
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
12681
|
+
let thisHeaderData = null;
|
|
12682
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
12683
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
12684
|
+
try {
|
|
12685
|
+
// parse the additional headers object that was passed in
|
|
12686
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
12687
|
+
} catch (err) {
|
|
12688
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
12689
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12690
|
+
return callback(null, errorObj);
|
|
12691
|
+
}
|
|
12692
|
+
} else if (thisHeaderData === null) {
|
|
12693
|
+
thisHeaderData = { contentType: '', cacheControl: '', token: '' };
|
|
12694
|
+
}
|
|
12695
|
+
|
|
12696
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
12697
|
+
// see adapter code documentation for more information on the request object's fields
|
|
12698
|
+
const reqObj = {
|
|
12699
|
+
payload: bodyVars,
|
|
12700
|
+
uriPathVars: pathVars,
|
|
12701
|
+
uriQuery: queryParams,
|
|
12702
|
+
addlHeaders: thisHeaderData
|
|
12703
|
+
};
|
|
12704
|
+
|
|
12705
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
12706
|
+
|
|
12707
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
12708
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
12709
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
12710
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
12711
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
12712
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
12713
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
12714
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
12715
|
+
} else {
|
|
12716
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
12717
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
12718
|
+
}
|
|
12719
|
+
}
|
|
12720
|
+
});
|
|
12721
|
+
// Add iapMetadata to reqObj for further work
|
|
12722
|
+
reqObj.iapMetadata = iapMetadata;
|
|
12723
|
+
}
|
|
12724
|
+
|
|
12725
|
+
try {
|
|
12726
|
+
// Make the call -
|
|
12727
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
12728
|
+
return this.requestHandlerInst.identifyRequest('NetworkSettings', 'getcmdbNetworkSettingsTelnetInfoRefreshDeviceCount', reqObj, true, (irReturnData, irReturnError) => {
|
|
12729
|
+
// if we received an error or their is no response on the results
|
|
12730
|
+
// return an error
|
|
12731
|
+
if (irReturnError) {
|
|
12732
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
12733
|
+
return callback(null, irReturnError);
|
|
12734
|
+
}
|
|
12735
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
12736
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getcmdbNetworkSettingsTelnetInfoRefreshDeviceCount'], null, null, null);
|
|
12737
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12738
|
+
return callback(null, errorObj);
|
|
12739
|
+
}
|
|
12740
|
+
|
|
12741
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
12742
|
+
// return the response
|
|
12743
|
+
return callback(irReturnData, null);
|
|
12744
|
+
});
|
|
12745
|
+
} catch (ex) {
|
|
12746
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
12747
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12748
|
+
return callback(null, errorObj);
|
|
12749
|
+
}
|
|
12750
|
+
}
|
|
12751
|
+
|
|
12752
|
+
/**
|
|
12753
|
+
* @function putcmdbSitesLeafDynamicSearch
|
|
12754
|
+
* @pronghornType method
|
|
12755
|
+
* @name putcmdbSitesLeafDynamicSearch
|
|
12756
|
+
* @summary putcmdbSitesLeafDynamicSearch
|
|
12757
|
+
*
|
|
12758
|
+
* @param {object} body - body param
|
|
12759
|
+
* @param {object} iapMetadata - IAP Metadata object contains additional info needed for the request: payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, etc.
|
|
12760
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
12761
|
+
* @return {object} results - An object containing the response of the action
|
|
12762
|
+
*
|
|
12763
|
+
* @route {POST} /putcmdbSitesLeafDynamicSearch
|
|
12764
|
+
* @roles admin
|
|
12765
|
+
* @task true
|
|
12766
|
+
*/
|
|
12767
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
12768
|
+
putcmdbSitesLeafDynamicSearch(body, iapMetadata, callback) {
|
|
12769
|
+
const meth = 'adapter-putcmdbSitesLeafDynamicSearch';
|
|
12770
|
+
const origin = `${this.id}-${meth}`;
|
|
12771
|
+
log.trace(origin);
|
|
12772
|
+
|
|
12773
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
12774
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
12775
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12776
|
+
return callback(null, errorObj);
|
|
12777
|
+
}
|
|
12778
|
+
|
|
12779
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
12780
|
+
if (body === undefined || body === null || body === '') {
|
|
12781
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
|
|
12782
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12783
|
+
return callback(null, errorObj);
|
|
12784
|
+
}
|
|
12785
|
+
|
|
12786
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
12787
|
+
const queryParamsAvailable = {};
|
|
12788
|
+
const queryParams = {};
|
|
12789
|
+
const pathVars = [];
|
|
12790
|
+
const bodyVars = body;
|
|
12791
|
+
|
|
12792
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
12793
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
12794
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
12795
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
12796
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
12797
|
+
}
|
|
12798
|
+
});
|
|
12799
|
+
|
|
12800
|
+
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
|
|
12801
|
+
let thisHeaderData = null;
|
|
12802
|
+
// if the additional headers was passed in as a string parse the json into an object
|
|
12803
|
+
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
|
|
12804
|
+
try {
|
|
12805
|
+
// parse the additional headers object that was passed in
|
|
12806
|
+
thisHeaderData = JSON.parse(thisHeaderData);
|
|
12807
|
+
} catch (err) {
|
|
12808
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
|
|
12809
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12810
|
+
return callback(null, errorObj);
|
|
12811
|
+
}
|
|
12812
|
+
} else if (thisHeaderData === null) {
|
|
12813
|
+
thisHeaderData = { token: '' };
|
|
12814
|
+
}
|
|
12815
|
+
|
|
12816
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
12817
|
+
// see adapter code documentation for more information on the request object's fields
|
|
12818
|
+
const reqObj = {
|
|
12819
|
+
payload: bodyVars,
|
|
12820
|
+
uriPathVars: pathVars,
|
|
12821
|
+
uriQuery: queryParams,
|
|
12822
|
+
addlHeaders: thisHeaderData
|
|
12823
|
+
};
|
|
12824
|
+
|
|
12825
|
+
const reqFields = ['payload', 'uriPathVars', 'uriQuery', 'uriOptions', 'addlHeaders', 'authData', 'callProperties', 'filter', 'priority', 'event'];
|
|
12826
|
+
|
|
12827
|
+
// Merge and add new iapMetadata fields in reqObj
|
|
12828
|
+
if (iapMetadata && typeof iapMetadata === 'object') {
|
|
12829
|
+
Object.keys(iapMetadata).forEach((iapField) => {
|
|
12830
|
+
if (reqFields.includes(iapField) && iapMetadata[iapField]) {
|
|
12831
|
+
if (typeof reqObj[iapField] === 'object' && typeof iapMetadata[iapField] === 'object') {
|
|
12832
|
+
reqObj[iapField] = { ...reqObj[iapField], ...iapMetadata[iapField] }; // Merge objects
|
|
12833
|
+
} else if (Array.isArray(reqObj[iapField]) && Array.isArray(iapMetadata[iapField])) {
|
|
12834
|
+
reqObj[iapField] = reqObj[iapField].concat(iapMetadata[iapField]); // Merge arrays
|
|
12835
|
+
} else {
|
|
12836
|
+
// Otherwise, add new iapMetadata fields to reqObj
|
|
12837
|
+
reqObj[iapField] = iapMetadata[iapField];
|
|
12838
|
+
}
|
|
12839
|
+
}
|
|
12840
|
+
});
|
|
12841
|
+
// Add iapMetadata to reqObj for further work
|
|
12842
|
+
reqObj.iapMetadata = iapMetadata;
|
|
12843
|
+
}
|
|
12844
|
+
|
|
12845
|
+
try {
|
|
12846
|
+
// Make the call -
|
|
12847
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
12848
|
+
return this.requestHandlerInst.identifyRequest('SiteManagement', 'putcmdbSitesLeafDynamicSearch', reqObj, false, (irReturnData, irReturnError) => {
|
|
12849
|
+
// if we received an error or their is no response on the results
|
|
12850
|
+
// return an error
|
|
12851
|
+
if (irReturnError) {
|
|
12852
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
12853
|
+
return callback(null, irReturnError);
|
|
12854
|
+
}
|
|
12855
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
12856
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['putcmdbSitesLeafDynamicSearch'], null, null, null);
|
|
12857
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12858
|
+
return callback(null, errorObj);
|
|
12859
|
+
}
|
|
12860
|
+
|
|
12861
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
12862
|
+
// return the response
|
|
12863
|
+
return callback(irReturnData, null);
|
|
12864
|
+
});
|
|
12865
|
+
} catch (ex) {
|
|
12866
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
12867
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
12868
|
+
return callback(null, errorObj);
|
|
12869
|
+
}
|
|
12870
|
+
}
|
|
8813
12871
|
}
|
|
8814
12872
|
|
|
8815
12873
|
module.exports = Netbrain;
|