diff options
author | sebdet <sebastien.determe@intl.att.com> | 2021-02-17 17:53:17 +0100 |
---|---|---|
committer | sebdet <sebastien.determe@intl.att.com> | 2021-02-19 10:09:31 +0100 |
commit | c427e6459d066859e6da068bf50c78a0d120080a (patch) | |
tree | b3b63a7919175a3500f2c26eb02c7cd9a6475ce0 /ui-react/src/api | |
parent | a0a3a03686a386bf6def6f7da6de4d3f6a11ce61 (diff) |
Add code in UI to create new policy version
Add code to call the policy create backend endpoint + alert box to show status of the creation + Fix backend +
Issue-ID: POLICY-2928
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Change-Id: Ia8f2506ecc692ad68111ebe7a55a92579b951908
Diffstat (limited to 'ui-react/src/api')
-rw-r--r-- | ui-react/src/api/PolicyService.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/ui-react/src/api/PolicyService.js b/ui-react/src/api/PolicyService.js index fdbb5d5ea..16cc1f322 100644 --- a/ui-react/src/api/PolicyService.js +++ b/ui-react/src/api/PolicyService.js @@ -40,4 +40,27 @@ export default class PolicyService { return {}; }); } + static createNewPolicy(policyModelType, policyModelVersion, policyJson) { + return fetch(window.location.pathname + 'restservices/clds/v2/policies/' + policyModelType + '/' + policyModelVersion, { + 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) { + return response.text; + } else { + console.error("createNewPolicy query failed"); + return ""; + } + }) + .catch(function (error) { + console.error("createNewPolicy error received", error); + throw new Error(error) + }); + } } |