diff options
author | liamfallon <liam.fallon@est.tech> | 2021-11-09 15:22:22 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2021-11-10 08:57:23 +0000 |
commit | 2022e5ce5a03788a6edc5761c495cfadc5ded485 (patch) | |
tree | 2df93f088fb323440945ce93ce67be1f2208c9bf /runtime/ui-react/src/api/PolicyService.js | |
parent | 579085240812aa593ebafe787d97868e16fc3318 (diff) |
Align ui-react file in policy-clamp and policy-gui
When the ui-react code was transferred to policy-gui, the white space
was cleaned up and reformatted. This makes it difficult to track the
real functional changes if any between ui-react in policy-clamp and
policy-gui.
This review brings the white space changes into ui-react in policy-clamp
to make file comparisons easier.
Issue-ID: POLICY-3358
Change-Id: Ic303e71b341e5c0f7ca0de0ed4c4962ebf2f988a
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'runtime/ui-react/src/api/PolicyService.js')
-rw-r--r-- | runtime/ui-react/src/api/PolicyService.js | 224 |
1 files changed, 114 insertions, 110 deletions
diff --git a/runtime/ui-react/src/api/PolicyService.js b/runtime/ui-react/src/api/PolicyService.js index f2886b30a..cf4f0fdba 100644 --- a/runtime/ui-react/src/api/PolicyService.js +++ b/runtime/ui-react/src/api/PolicyService.js @@ -23,126 +23,130 @@ export default class PolicyService { static getPoliciesList() { return fetch(window.location.pathname + 'restservices/clds/v2/policies', { - method: 'GET', - credentials: 'same-origin' - }) - .then(function(response) { - console.debug("getPoliciesList response received: ", response.status); - if (response.ok) { - console.info("getPoliciesList query successful"); - return response.json(); - } else { - return response.text().then(responseBody => { - throw new Error("HTTP " + response.status + "," + responseBody); - }) - } - }) - .catch(function(error) { - console.error("getPoliciesList error occurred ", error); - alert("getPoliciesList error occurred " + error); - return undefined; - }); + method: 'GET', + credentials: 'same-origin' + }) + .then(function (response) { + console.debug("getPoliciesList response received: ", response.status); + if (response.ok) { + console.info("getPoliciesList query successful"); + return response.json(); + } else { + return response.text().then(responseBody => { + throw new Error("HTTP " + response.status + "," + responseBody); + }) + } + }) + .catch(function (error) { + console.error("getPoliciesList error occurred ", error); + alert("getPoliciesList error occurred " + error); + return undefined; + }); } + static createNewPolicy(policyModelType, policyModelVersion, policyName, policyVersion, policyJson) { return fetch(window.location.pathname + 'restservices/clds/v2/policies/' + policyModelType + '/' - + policyModelVersion + '/' + policyName + '/' + policyVersion, { - method: 'POST', - credentials: 'same-origin', - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify(policyJson) - }) - .then(function (response) { - console.debug("createNewPolicy response received: ", response.status); - if (response.ok) { - console.info("createNewPolicy query successful"); - return response.text(); - } else { - return response.text().then(responseBody => { - throw new Error("HTTP " + response.status + "," + responseBody); - }) - } - }) - .catch(function (error) { - console.error("createNewPolicy error occurred ", error); - alert ("createNewPolicy error occurred " + error); - return undefined; - }); + + policyModelVersion + '/' + policyName + '/' + policyVersion, { + method: 'POST', + credentials: 'same-origin', + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(policyJson) + }) + .then(function (response) { + console.debug("createNewPolicy response received: ", response.status); + if (response.ok) { + console.info("createNewPolicy query successful"); + return response.text(); + } else { + return response.text().then(responseBody => { + throw new Error("HTTP " + response.status + "," + responseBody); + }) + } + }) + .catch(function (error) { + console.error("createNewPolicy error occurred ", error); + alert("createNewPolicy error occurred " + error); + return undefined; + }); } + static deletePolicy(policyModelType, policyModelVersion, policyName, policyVersion) { return fetch(window.location.pathname + 'restservices/clds/v2/policies/' + policyModelType + '/' - + policyModelVersion + '/' + policyName + '/' + policyVersion, { - method: 'DELETE', - credentials: 'same-origin' - }) - .then(function (response) { - console.debug("deletePolicy response received: ", response.status); - if (response.ok) { - console.info("deletePolicy query successful"); - return response.text(); - } else { - return response.text().then(responseBody => { - throw new Error("HTTP " + response.status + "," + responseBody); - }) - } - }) - .catch(function (error) { - console.error("deletePolicy error occurred ", error); - alert ("deletePolicy error occurred " + error); - return undefined; - }); + + policyModelVersion + '/' + policyName + '/' + policyVersion, { + method: 'DELETE', + credentials: 'same-origin' + }) + .then(function (response) { + console.debug("deletePolicy response received: ", response.status); + if (response.ok) { + console.info("deletePolicy query successful"); + return response.text(); + } else { + return response.text().then(responseBody => { + throw new Error("HTTP " + response.status + "," + responseBody); + }) + } + }) + .catch(function (error) { + console.error("deletePolicy error occurred ", error); + alert("deletePolicy error occurred " + error); + return undefined; + }); } + static updatePdpDeployment(pdpOperationsList) { return fetch(window.location.pathname + 'restservices/clds/v2/policies/pdpDeployment', { - method: 'PUT', - credentials: 'same-origin', - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify(pdpOperationsList) - }) - .then(function (response) { - console.debug("updatePdpDeployment response received: ", response.status); - if (response.ok) { - console.info("updatePdpDeployment query successful"); - return response.text(); - } else { - return response.text().then(responseBody => { - throw new Error("HTTP " + response.status + "," + responseBody); - }) - } - }) - .catch(function (error) { - console.error("updatePdpDeployment error occurred ", error); - alert ("updatePdpDeployment error occurred " + error); - return undefined; - }); + method: 'PUT', + credentials: 'same-origin', + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(pdpOperationsList) + }) + .then(function (response) { + console.debug("updatePdpDeployment response received: ", response.status); + if (response.ok) { + console.info("updatePdpDeployment query successful"); + return response.text(); + } else { + return response.text().then(responseBody => { + throw new Error("HTTP " + response.status + "," + responseBody); + }) + } + }) + .catch(function (error) { + console.error("updatePdpDeployment error occurred ", error); + alert("updatePdpDeployment error occurred " + error); + return undefined; + }); } + static sendNewPolicyModel(newPolicyModel) { - return fetch(window.location.pathname + 'restservices/clds/v2/policies/policytype', { - method: 'POST', - credentials: 'same-origin', - headers: { - "Content-Type": "plain/text" - }, - body: newPolicyModel + return fetch(window.location.pathname + 'restservices/clds/v2/policies/policytype', { + method: 'POST', + credentials: 'same-origin', + headers: { + "Content-Type": "plain/text" + }, + body: newPolicyModel + }) + .then(function (response) { + console.debug("sendNewPolicyModel response received: ", response.status); + if (response.ok) { + console.info("sendNewPolicyModel query successful"); + return response.text(); + } else { + return response.text().then(responseBody => { + throw new Error("HTTP " + response.status + "," + responseBody); }) - .then(function (response) { - console.debug("sendNewPolicyModel response received: ", response.status); - if (response.ok) { - console.info("sendNewPolicyModel query successful"); - return response.text(); - } else { - return response.text().then(responseBody => { - throw new Error("HTTP " + response.status + "," + responseBody); - }) - } - }) - .catch(function (error) { - console.error("sendNewPolicyModel error occurred ", error); - alert ("sendNewPolicyModel error occurred " + error); - return undefined; - }); - } + } + }) + .catch(function (error) { + console.error("sendNewPolicyModel error occurred ", error); + alert("sendNewPolicyModel error occurred " + error); + return undefined; + }); + } } |