@itentialopensource/adapter-viptela 0.10.6 → 0.10.7
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/CHANGELOG.md +8 -0
- package/adapter.js +489 -0
- package/entities/Template/action.json +9 -173
- package/entities/Template/mockdatafiles/editVSmartTemplate-default.json +6 -0
- package/entities/Template/mockdatafiles/generateMasterTemplateList-default.json +5 -0
- package/entities/Template/schema.json +6 -14
- package/package.json +1 -1
- package/pronghorn.json +318 -0
- package/refs?service=git-upload-pack +0 -0
- package/test/integration/adapterTestIntegration.js +158 -0
- package/test/unit/adapterTestUnit.js +157 -0
package/CHANGELOG.md
CHANGED
package/adapter.js
CHANGED
|
@@ -7812,6 +7812,495 @@ class Viptela extends AdapterBaseCl {
|
|
|
7812
7812
|
}
|
|
7813
7813
|
}
|
|
7814
7814
|
|
|
7815
|
+
/**
|
|
7816
|
+
* @function generateMasterTemplateList
|
|
7817
|
+
* @pronghornType method
|
|
7818
|
+
* @name generateMasterTemplateList
|
|
7819
|
+
* @summary generateMasterTemplateList
|
|
7820
|
+
*
|
|
7821
|
+
* @param {string} feature - Feature
|
|
7822
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
7823
|
+
* @return {object} results - An object containing the response of the action
|
|
7824
|
+
*
|
|
7825
|
+
* @route {POST} /generateMasterTemplateList
|
|
7826
|
+
* @roles admin
|
|
7827
|
+
* @task true
|
|
7828
|
+
*/
|
|
7829
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
7830
|
+
generateMasterTemplateList(feature, callback) {
|
|
7831
|
+
const meth = 'adapter-generateMasterTemplateList';
|
|
7832
|
+
const origin = `${this.id}-${meth}`;
|
|
7833
|
+
log.trace(origin);
|
|
7834
|
+
|
|
7835
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
7836
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
7837
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
7838
|
+
return callback(null, errorObj);
|
|
7839
|
+
}
|
|
7840
|
+
|
|
7841
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
7842
|
+
if (feature === undefined || feature === null || feature === '') {
|
|
7843
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['feature'], null, null, null);
|
|
7844
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
7845
|
+
return callback(null, errorObj);
|
|
7846
|
+
}
|
|
7847
|
+
|
|
7848
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
7849
|
+
const queryParamsAvailable = { feature };
|
|
7850
|
+
const queryParams = {};
|
|
7851
|
+
const pathVars = [];
|
|
7852
|
+
const bodyVars = {};
|
|
7853
|
+
|
|
7854
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
7855
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
7856
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
7857
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
7858
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
7859
|
+
}
|
|
7860
|
+
});
|
|
7861
|
+
|
|
7862
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
7863
|
+
// see adapter code documentation for more information on the request object's fields
|
|
7864
|
+
const reqObj = {
|
|
7865
|
+
payload: bodyVars,
|
|
7866
|
+
uriPathVars: pathVars,
|
|
7867
|
+
uriQuery: queryParams
|
|
7868
|
+
};
|
|
7869
|
+
|
|
7870
|
+
try {
|
|
7871
|
+
// Make the call -
|
|
7872
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
7873
|
+
return this.requestHandlerInst.identifyRequest('Template', 'generateMasterTemplateList', reqObj, true, (irReturnData, irReturnError) => {
|
|
7874
|
+
// if we received an error or their is no response on the results
|
|
7875
|
+
// return an error
|
|
7876
|
+
if (irReturnError) {
|
|
7877
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
7878
|
+
return callback(null, irReturnError);
|
|
7879
|
+
}
|
|
7880
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
7881
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['generateMasterTemplateList'], null, null, null);
|
|
7882
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
7883
|
+
return callback(null, errorObj);
|
|
7884
|
+
}
|
|
7885
|
+
|
|
7886
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
7887
|
+
// return the response
|
|
7888
|
+
return callback(irReturnData, null);
|
|
7889
|
+
});
|
|
7890
|
+
} catch (ex) {
|
|
7891
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
7892
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
7893
|
+
return callback(null, errorObj);
|
|
7894
|
+
}
|
|
7895
|
+
}
|
|
7896
|
+
|
|
7897
|
+
/**
|
|
7898
|
+
* @function editMasterTemplate
|
|
7899
|
+
* @pronghornType method
|
|
7900
|
+
* @name editMasterTemplate
|
|
7901
|
+
* @summary editMasterTemplate
|
|
7902
|
+
*
|
|
7903
|
+
* @param {string} templateId - Template Id
|
|
7904
|
+
* @param {object} [body] - Template
|
|
7905
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
7906
|
+
* @return {object} results - An object containing the response of the action
|
|
7907
|
+
*
|
|
7908
|
+
* @route {POST} /editMasterTemplate
|
|
7909
|
+
* @roles admin
|
|
7910
|
+
* @task true
|
|
7911
|
+
*/
|
|
7912
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
7913
|
+
editMasterTemplate(templateId, body, callback) {
|
|
7914
|
+
const meth = 'adapter-editMasterTemplate';
|
|
7915
|
+
const origin = `${this.id}-${meth}`;
|
|
7916
|
+
log.trace(origin);
|
|
7917
|
+
|
|
7918
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
7919
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
7920
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
7921
|
+
return callback(null, errorObj);
|
|
7922
|
+
}
|
|
7923
|
+
|
|
7924
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
7925
|
+
if (templateId === undefined || templateId === null || templateId === '') {
|
|
7926
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['templateId'], null, null, null);
|
|
7927
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
7928
|
+
return callback(null, errorObj);
|
|
7929
|
+
}
|
|
7930
|
+
|
|
7931
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
7932
|
+
const queryParamsAvailable = {};
|
|
7933
|
+
const queryParams = {};
|
|
7934
|
+
const pathVars = [templateId];
|
|
7935
|
+
const bodyVars = body;
|
|
7936
|
+
|
|
7937
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
7938
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
7939
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
7940
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
7941
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
7942
|
+
}
|
|
7943
|
+
});
|
|
7944
|
+
|
|
7945
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
7946
|
+
// see adapter code documentation for more information on the request object's fields
|
|
7947
|
+
const reqObj = {
|
|
7948
|
+
payload: bodyVars,
|
|
7949
|
+
uriPathVars: pathVars,
|
|
7950
|
+
uriQuery: queryParams
|
|
7951
|
+
};
|
|
7952
|
+
|
|
7953
|
+
try {
|
|
7954
|
+
// Make the call -
|
|
7955
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
7956
|
+
return this.requestHandlerInst.identifyRequest('Template', 'editMasterTemplate', reqObj, false, (irReturnData, irReturnError) => {
|
|
7957
|
+
// if we received an error or their is no response on the results
|
|
7958
|
+
// return an error
|
|
7959
|
+
if (irReturnError) {
|
|
7960
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
7961
|
+
return callback(null, irReturnError);
|
|
7962
|
+
}
|
|
7963
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
7964
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['editMasterTemplate'], null, null, null);
|
|
7965
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
7966
|
+
return callback(null, errorObj);
|
|
7967
|
+
}
|
|
7968
|
+
|
|
7969
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
7970
|
+
// return the response
|
|
7971
|
+
return callback(irReturnData, null);
|
|
7972
|
+
});
|
|
7973
|
+
} catch (ex) {
|
|
7974
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
7975
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
7976
|
+
return callback(null, errorObj);
|
|
7977
|
+
}
|
|
7978
|
+
}
|
|
7979
|
+
|
|
7980
|
+
/**
|
|
7981
|
+
* @function createVSmartTemplate
|
|
7982
|
+
* @pronghornType method
|
|
7983
|
+
* @name createVSmartTemplate
|
|
7984
|
+
* @summary createVSmartTemplate
|
|
7985
|
+
*
|
|
7986
|
+
* @param {object} [body] - Template policy
|
|
7987
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
7988
|
+
* @return {object} results - An object containing the response of the action
|
|
7989
|
+
*
|
|
7990
|
+
* @route {POST} /createVSmartTemplate
|
|
7991
|
+
* @roles admin
|
|
7992
|
+
* @task true
|
|
7993
|
+
*/
|
|
7994
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
7995
|
+
createVSmartTemplate(body, callback) {
|
|
7996
|
+
const meth = 'adapter-createVSmartTemplate';
|
|
7997
|
+
const origin = `${this.id}-${meth}`;
|
|
7998
|
+
log.trace(origin);
|
|
7999
|
+
|
|
8000
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
8001
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
8002
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8003
|
+
return callback(null, errorObj);
|
|
8004
|
+
}
|
|
8005
|
+
|
|
8006
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
8007
|
+
|
|
8008
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
8009
|
+
const queryParamsAvailable = {};
|
|
8010
|
+
const queryParams = {};
|
|
8011
|
+
const pathVars = [];
|
|
8012
|
+
const bodyVars = body;
|
|
8013
|
+
|
|
8014
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
8015
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
8016
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
8017
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
8018
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
8019
|
+
}
|
|
8020
|
+
});
|
|
8021
|
+
|
|
8022
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
8023
|
+
// see adapter code documentation for more information on the request object's fields
|
|
8024
|
+
const reqObj = {
|
|
8025
|
+
payload: bodyVars,
|
|
8026
|
+
uriPathVars: pathVars,
|
|
8027
|
+
uriQuery: queryParams
|
|
8028
|
+
};
|
|
8029
|
+
|
|
8030
|
+
try {
|
|
8031
|
+
// Make the call -
|
|
8032
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
8033
|
+
return this.requestHandlerInst.identifyRequest('Template', 'createVSmartTemplate', reqObj, true, (irReturnData, irReturnError) => {
|
|
8034
|
+
// if we received an error or their is no response on the results
|
|
8035
|
+
// return an error
|
|
8036
|
+
if (irReturnError) {
|
|
8037
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
8038
|
+
return callback(null, irReturnError);
|
|
8039
|
+
}
|
|
8040
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
8041
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['createVSmartTemplate'], null, null, null);
|
|
8042
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8043
|
+
return callback(null, errorObj);
|
|
8044
|
+
}
|
|
8045
|
+
|
|
8046
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
8047
|
+
// return the response
|
|
8048
|
+
return callback(irReturnData, null);
|
|
8049
|
+
});
|
|
8050
|
+
} catch (ex) {
|
|
8051
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
8052
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8053
|
+
return callback(null, errorObj);
|
|
8054
|
+
}
|
|
8055
|
+
}
|
|
8056
|
+
|
|
8057
|
+
/**
|
|
8058
|
+
* @function getTemplateByPolicyId
|
|
8059
|
+
* @pronghornType method
|
|
8060
|
+
* @name getTemplateByPolicyId
|
|
8061
|
+
* @summary getTemplateByPolicyId
|
|
8062
|
+
*
|
|
8063
|
+
* @param {string} policyId - Policy Id
|
|
8064
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
8065
|
+
* @return {object} results - An object containing the response of the action
|
|
8066
|
+
*
|
|
8067
|
+
* @route {POST} /getTemplateByPolicyId
|
|
8068
|
+
* @roles admin
|
|
8069
|
+
* @task true
|
|
8070
|
+
*/
|
|
8071
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
8072
|
+
getTemplateByPolicyId(policyId, callback) {
|
|
8073
|
+
const meth = 'adapter-getTemplateByPolicyId';
|
|
8074
|
+
const origin = `${this.id}-${meth}`;
|
|
8075
|
+
log.trace(origin);
|
|
8076
|
+
|
|
8077
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
8078
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
8079
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8080
|
+
return callback(null, errorObj);
|
|
8081
|
+
}
|
|
8082
|
+
|
|
8083
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
8084
|
+
if (policyId === undefined || policyId === null || policyId === '') {
|
|
8085
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['policyId'], null, null, null);
|
|
8086
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8087
|
+
return callback(null, errorObj);
|
|
8088
|
+
}
|
|
8089
|
+
|
|
8090
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
8091
|
+
const queryParamsAvailable = {};
|
|
8092
|
+
const queryParams = {};
|
|
8093
|
+
const pathVars = [policyId];
|
|
8094
|
+
const bodyVars = {};
|
|
8095
|
+
|
|
8096
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
8097
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
8098
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
8099
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
8100
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
8101
|
+
}
|
|
8102
|
+
});
|
|
8103
|
+
|
|
8104
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
8105
|
+
// see adapter code documentation for more information on the request object's fields
|
|
8106
|
+
const reqObj = {
|
|
8107
|
+
payload: bodyVars,
|
|
8108
|
+
uriPathVars: pathVars,
|
|
8109
|
+
uriQuery: queryParams
|
|
8110
|
+
};
|
|
8111
|
+
|
|
8112
|
+
try {
|
|
8113
|
+
// Make the call -
|
|
8114
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
8115
|
+
return this.requestHandlerInst.identifyRequest('Template', 'getTemplateByPolicyId', reqObj, true, (irReturnData, irReturnError) => {
|
|
8116
|
+
// if we received an error or their is no response on the results
|
|
8117
|
+
// return an error
|
|
8118
|
+
if (irReturnError) {
|
|
8119
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
8120
|
+
return callback(null, irReturnError);
|
|
8121
|
+
}
|
|
8122
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
8123
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getTemplateByPolicyId'], null, null, null);
|
|
8124
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8125
|
+
return callback(null, errorObj);
|
|
8126
|
+
}
|
|
8127
|
+
|
|
8128
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
8129
|
+
// return the response
|
|
8130
|
+
return callback(irReturnData, null);
|
|
8131
|
+
});
|
|
8132
|
+
} catch (ex) {
|
|
8133
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
8134
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8135
|
+
return callback(null, errorObj);
|
|
8136
|
+
}
|
|
8137
|
+
}
|
|
8138
|
+
|
|
8139
|
+
/**
|
|
8140
|
+
* @function editVSmartTemplate
|
|
8141
|
+
* @pronghornType method
|
|
8142
|
+
* @name editVSmartTemplate
|
|
8143
|
+
* @summary editVSmartTemplate
|
|
8144
|
+
*
|
|
8145
|
+
* @param {string} policyId - Policy Id
|
|
8146
|
+
* @param {object} [body] - Template policy
|
|
8147
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
8148
|
+
* @return {object} results - An object containing the response of the action
|
|
8149
|
+
*
|
|
8150
|
+
* @route {POST} /editVSmartTemplate
|
|
8151
|
+
* @roles admin
|
|
8152
|
+
* @task true
|
|
8153
|
+
*/
|
|
8154
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
8155
|
+
editVSmartTemplate(policyId, body, callback) {
|
|
8156
|
+
const meth = 'adapter-editVSmartTemplate';
|
|
8157
|
+
const origin = `${this.id}-${meth}`;
|
|
8158
|
+
log.trace(origin);
|
|
8159
|
+
|
|
8160
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
8161
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
8162
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8163
|
+
return callback(null, errorObj);
|
|
8164
|
+
}
|
|
8165
|
+
|
|
8166
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
8167
|
+
if (policyId === undefined || policyId === null || policyId === '') {
|
|
8168
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['policyId'], null, null, null);
|
|
8169
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8170
|
+
return callback(null, errorObj);
|
|
8171
|
+
}
|
|
8172
|
+
|
|
8173
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
8174
|
+
const queryParamsAvailable = {};
|
|
8175
|
+
const queryParams = {};
|
|
8176
|
+
const pathVars = [policyId];
|
|
8177
|
+
const bodyVars = body;
|
|
8178
|
+
|
|
8179
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
8180
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
8181
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
8182
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
8183
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
8184
|
+
}
|
|
8185
|
+
});
|
|
8186
|
+
|
|
8187
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
8188
|
+
// see adapter code documentation for more information on the request object's fields
|
|
8189
|
+
const reqObj = {
|
|
8190
|
+
payload: bodyVars,
|
|
8191
|
+
uriPathVars: pathVars,
|
|
8192
|
+
uriQuery: queryParams
|
|
8193
|
+
};
|
|
8194
|
+
|
|
8195
|
+
try {
|
|
8196
|
+
// Make the call -
|
|
8197
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
8198
|
+
return this.requestHandlerInst.identifyRequest('Template', 'editVSmartTemplate', reqObj, false, (irReturnData, irReturnError) => {
|
|
8199
|
+
// if we received an error or their is no response on the results
|
|
8200
|
+
// return an error
|
|
8201
|
+
if (irReturnError) {
|
|
8202
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
8203
|
+
return callback(null, irReturnError);
|
|
8204
|
+
}
|
|
8205
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
8206
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['editVSmartTemplate'], null, null, null);
|
|
8207
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8208
|
+
return callback(null, errorObj);
|
|
8209
|
+
}
|
|
8210
|
+
|
|
8211
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
8212
|
+
// return the response
|
|
8213
|
+
return callback(irReturnData, null);
|
|
8214
|
+
});
|
|
8215
|
+
} catch (ex) {
|
|
8216
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
8217
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8218
|
+
return callback(null, errorObj);
|
|
8219
|
+
}
|
|
8220
|
+
}
|
|
8221
|
+
|
|
8222
|
+
/**
|
|
8223
|
+
* @function deleteVSmartTemplate
|
|
8224
|
+
* @pronghornType method
|
|
8225
|
+
* @name deleteVSmartTemplate
|
|
8226
|
+
* @summary deleteVSmartTemplate
|
|
8227
|
+
*
|
|
8228
|
+
* @param {string} policyId - Policy Id
|
|
8229
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
8230
|
+
* @return {object} results - An object containing the response of the action
|
|
8231
|
+
*
|
|
8232
|
+
* @route {POST} /deleteVSmartTemplate
|
|
8233
|
+
* @roles admin
|
|
8234
|
+
* @task true
|
|
8235
|
+
*/
|
|
8236
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
8237
|
+
deleteVSmartTemplate(policyId, callback) {
|
|
8238
|
+
const meth = 'adapter-deleteVSmartTemplate';
|
|
8239
|
+
const origin = `${this.id}-${meth}`;
|
|
8240
|
+
log.trace(origin);
|
|
8241
|
+
|
|
8242
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
8243
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
8244
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8245
|
+
return callback(null, errorObj);
|
|
8246
|
+
}
|
|
8247
|
+
|
|
8248
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
8249
|
+
if (policyId === undefined || policyId === null || policyId === '') {
|
|
8250
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['policyId'], null, null, null);
|
|
8251
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8252
|
+
return callback(null, errorObj);
|
|
8253
|
+
}
|
|
8254
|
+
|
|
8255
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
8256
|
+
const queryParamsAvailable = {};
|
|
8257
|
+
const queryParams = {};
|
|
8258
|
+
const pathVars = [policyId];
|
|
8259
|
+
const bodyVars = {};
|
|
8260
|
+
|
|
8261
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
8262
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
8263
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
8264
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
8265
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
8266
|
+
}
|
|
8267
|
+
});
|
|
8268
|
+
|
|
8269
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
|
|
8270
|
+
// see adapter code documentation for more information on the request object's fields
|
|
8271
|
+
const reqObj = {
|
|
8272
|
+
payload: bodyVars,
|
|
8273
|
+
uriPathVars: pathVars,
|
|
8274
|
+
uriQuery: queryParams
|
|
8275
|
+
};
|
|
8276
|
+
|
|
8277
|
+
try {
|
|
8278
|
+
// Make the call -
|
|
8279
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
8280
|
+
return this.requestHandlerInst.identifyRequest('Template', 'deleteVSmartTemplate', reqObj, false, (irReturnData, irReturnError) => {
|
|
8281
|
+
// if we received an error or their is no response on the results
|
|
8282
|
+
// return an error
|
|
8283
|
+
if (irReturnError) {
|
|
8284
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
8285
|
+
return callback(null, irReturnError);
|
|
8286
|
+
}
|
|
8287
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
8288
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteVSmartTemplate'], null, null, null);
|
|
8289
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8290
|
+
return callback(null, errorObj);
|
|
8291
|
+
}
|
|
8292
|
+
|
|
8293
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
8294
|
+
// return the response
|
|
8295
|
+
return callback(irReturnData, null);
|
|
8296
|
+
});
|
|
8297
|
+
} catch (ex) {
|
|
8298
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
8299
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8300
|
+
return callback(null, errorObj);
|
|
8301
|
+
}
|
|
8302
|
+
}
|
|
8303
|
+
|
|
7815
8304
|
/**
|
|
7816
8305
|
* @function resetVedgeCloud
|
|
7817
8306
|
* @pronghornType method
|