From bdc4cc9d4a75bfdd2f5656f102d2f6ac7817e4ef Mon Sep 17 00:00:00 2001 From: brunomilitzer Date: Tue, 27 Jul 2021 17:47:25 +0100 Subject: Add Instance Properties Form Added save button to update paramaters Added service to retrieve paramaters; Added service to upload instance paramaters Issue-ID: POLICY-3436 Change-Id: I82e7545b12160f2e7937db2fdb3857c66ea0b858 Signed-off-by: brunomilitzer --- gui-clamp/ui-react/src/api/ControlLoopService.js | 64 ++++++++++-------------- 1 file changed, 27 insertions(+), 37 deletions(-) (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 5938bd2..513fe68 100644 --- a/gui-clamp/ui-react/src/api/ControlLoopService.js +++ b/gui-clamp/ui-react/src/api/ControlLoopService.js @@ -19,7 +19,7 @@ export default class ControlLoopService { - static async fetchControlLoopInstantiation(windowLocationPathname) { + static async getControlLoopInstantiation(windowLocationPathname) { return await fetch(windowLocationPathname + '/restservices/clds/v2/toscaControlLoop/getToscaInstantiation', { method: 'GET', @@ -45,18 +45,33 @@ export default class ControlLoopService { }); } - static async uploadToscaInstantiation(toscaObject, windowLocationPathname) { + static async getInstanceProperties(name, version, windowLocationPathname) { + const params = { + name: name, + version: version, + common: "false" + } + + const response = await fetch(windowLocationPathname + '/restservices/clds/v2/toscaControlLoop/getCommonOrInstanceProperties' + '?' + (new URLSearchParams(params))); + + this.checkResponseForError(response); + + return response; + } + + static async createInstanceProperties(instancePropertiesTemplate, windowLocationPathname) { - const response = await fetch(windowLocationPathname + '/restservices/clds/v2/toscaControlLoop/postToscaInstantiation', { + const response = await fetch(windowLocationPathname + + '/restservices/clds/v2/toscaControlLoop/postToscaInstanceProperties', { method: 'POST', headers: { - 'Content-Type': 'application/json', + "Content-Type": "application/json" }, credentials: 'same-origin', - body: JSON.stringify(toscaObject) + body: JSON.stringify(instancePropertiesTemplate), }); - return response; + return response } static async getToscaTemplate(name, version, windowLocationPathname) { @@ -68,37 +83,11 @@ export default class ControlLoopService { const response = await fetch(windowLocationPathname + '/restservices/clds/v2/toscaControlLoop/getToscaTemplate' + '?' + (new URLSearchParams(params))); - const data = await response; - - return data; - } - - static async deleteToscaTemplate(name, version, windowLocationPathname) { - const params = { - name: name, - version: version + if (!response.ok) { + const message = `An error has occurred: ${ response.status }`; + throw new Error(message); } - const response = await fetch(windowLocationPathname + - '/restservices/clds/v2/toscaControlLoop/decommissionToscaTemplate' + '?' + (new URLSearchParams(params)), - { - method: 'DELETE' - }); - - this.checkResponseForError(response); - - const data = await response; - - return data; - } - - static async getToscaControlLoopDefinitions(windowLocationPathname) { - - const response = await fetch(windowLocationPathname + - '/restservices/clds/v2/toscaControlLoop/getElementDefinitions'); - - this.checkResponseForError(response); - const data = await response; return data; @@ -149,10 +138,11 @@ export default class ControlLoopService { return response; } - static checkResponseForError (response) { + static checkResponseForError(response) { if (!response.ok) { - const message = `An error has occurred: ${response.status}`; + const message = `An error has occurred: ${ response.status }`; throw new Error(message); } } + } -- cgit 1.2.3-korg