From 6687b48b58bf1248532de48f3e375b1f663f4015 Mon Sep 17 00:00:00 2001 From: "saul.gill" Date: Fri, 2 Jul 2021 17:10:54 +0100 Subject: 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 --- gui-clamp/ui-react/src/api/ControlLoopService.js | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'gui-clamp/ui-react/src/api/ControlLoopService.js') 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 + + } } -- cgit 1.2.3-korg