diff options
author | saul.gill <saul.gill@est.tech> | 2021-07-02 17:10:54 +0100 |
---|---|---|
committer | saul.gill <saul.gill@est.tech> | 2021-07-02 17:10:59 +0100 |
commit | 6687b48b58bf1248532de48f3e375b1f663f4015 (patch) | |
tree | 6582070c8db251b85695bcdc902ea98aac573003 /gui-clamp/ui-react/src/api/ControlLoopService.js | |
parent | b908988c81db910d4e2bea3e569e468f5f2c8f85 (diff) |
Changed components to be service-centric
Moved endpoints to ControlLoopService.js
Refactored components and tests
Issue-ID: POLICY-3424
Change-Id: I70d48750250eecd651b845ef0c726617983f75f5
Signed-off-by: saul.gill <saul.gill@est.tech>
Diffstat (limited to 'gui-clamp/ui-react/src/api/ControlLoopService.js')
-rw-r--r-- | gui-clamp/ui-react/src/api/ControlLoopService.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gui-clamp/ui-react/src/api/ControlLoopService.js b/gui-clamp/ui-react/src/api/ControlLoopService.js index 5ef7529..1882f78 100644 --- a/gui-clamp/ui-react/src/api/ControlLoopService.js +++ b/gui-clamp/ui-react/src/api/ControlLoopService.js @@ -44,4 +44,38 @@ export default class ControlLoopService { return undefined; }); } + + static async getToscaTemplate(name, version, windowLocationPathname) { + const params = { + name: name, + version: version + } + + const response = await fetch(windowLocationPathname + + '/restservices/clds/v2/toscaControlLoop/getToscaTemplate' + '?' + (new URLSearchParams(params))); + + if (!response.ok) { + const message = `An error has occurred: ${response.status}`; + throw new Error(message); + } + + const data = await response; + + return data; + } + + static async uploadToscaFile(toscaObject, windowLocationPathName) { + const response = await fetch(windowLocationPathName + + '/restservices/clds/v2/toscaControlLoop/commissionToscaTemplate', { + method: 'POST', + headers: { + "Content-Type": "application/json" + }, + credentials: 'same-origin', + body: JSON.stringify(toscaObject), + }); + + return response + + } } |