2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END============================================
19 * ===================================================================
23 export default class LoopService {
24 static getLoopNames() {
25 return fetch('/restservices/clds/v2/loop/getAllNames', { method: 'GET', credentials: 'same-origin' })
26 .then(function (response) {
27 console.debug("GetLoopNames response received: ", response.status);
29 return response.json();
31 console.error("GetLoopNames query failed");
35 .catch(function (error) {
36 console.error("GetLoopNames error received", error);
41 static createLoop(loopName, templateName) {
42 return fetch('/restservices/clds/v2/loop/create/' + loopName + '?templateName=' + templateName, {
45 "Content-Type": "application/json"
47 credentials: 'same-origin'
49 .then(function (response) {
50 console.debug("CreateLoop response received: ", response.status);
51 return response.json();
53 .catch(function (error) {
54 console.error("CreateLoop error received", error);
59 static getLoop(loopName) {
60 return fetch('/restservices/clds/v2/loop/' + loopName, {
63 "Content-Type": "application/json"
65 credentials: 'same-origin'
67 .then(function (response) {
68 console.debug("GetLoop response received: ", response.status);
70 return response.json();
72 console.error("GetLoop query failed");
76 .catch(function (error) {
77 console.error("GetLoop error received", error);
82 static getSvg(loopName) {
83 return fetch('/restservices/clds/v2/loop/svgRepresentation/' + loopName, {
85 credentials: 'same-origin'
87 .then(function (response) {
88 console.debug("svgRepresentation response received: ", response.status);
90 return response.text();
92 console.error("svgRepresentation query failed");
96 .catch(function (error) {
97 console.error("svgRepresentation error received", error);
102 static setMicroServiceProperties(loopName, jsonData) {
103 return fetch('/restservices/clds/v2/loop/updateMicroservicePolicy/' + loopName, {
105 credentials: 'same-origin',
107 "Content-Type": "application/json"
109 body: JSON.stringify(jsonData)
111 .then(function (response) {
112 console.debug("updateMicroservicePolicy response received: ", response.status);
114 return response.text();
116 console.error("updateMicroservicePolicy query failed");
120 .catch(function (error) {
121 console.error("updateMicroservicePolicy error received", error);
126 static setOperationalPolicyProperties(loopName, jsonData) {
127 return fetch('/restservices/clds/v2/loop/updateOperationalPolicies/' + loopName, {
129 credentials: 'same-origin',
131 "Content-Type": "application/json"
133 body: JSON.stringify(jsonData)
135 .then(function (response) {
136 console.debug("updateOperationalPolicies response received: ", response.status);
138 return response.text();
140 console.error("updateOperationalPolicies query failed");
144 .catch(function (error) {
145 console.error("updateOperationalPolicies error received", error);
150 static updateGlobalProperties(loopName, jsonData) {
151 return fetch('/restservices/clds/v2/loop/updateGlobalProperties/' + loopName, {
153 credentials: 'same-origin',
155 "Content-Type": "application/json"
157 body: JSON.stringify(jsonData)
159 .then(function (response) {
160 console.debug("updateGlobalProperties response received: ", response.status);
162 return response.text();
164 console.error("updateGlobalProperties query failed");
168 .catch(function (error) {
169 console.error("updateGlobalProperties error received", error);
174 static refreshOpPolicyJson(loopName) {
175 return fetch('/restservices/clds/v2/loop/refreshOpPolicyJsonSchema/' + loopName, {
178 "Content-Type": "application/json"
180 credentials: 'same-origin'
182 .then(function (response) {
183 console.debug("Refresh Operational Policy Json Schema response received: ", response.status);
185 return response.json();
187 console.error("Refresh Operational Policy Json Schema query failed");
191 .catch(function (error) {
192 console.error("Refresh Operational Policy Json Schema error received", error);
197 static addOperationalPolicyType(loopName, policyType, policyVersion) {
198 return fetch('/restservices/clds/v2/loop/addOperationaPolicy/' + loopName + '/policyModel/' + policyType +'/' + policyVersion , {
201 "Content-Type": "application/json"
203 credentials: 'same-origin'
205 .then(function (response) {
206 console.debug("Add Operational Policy response received: ", response.status);
208 return response.json();
210 console.error("Add Operational Policy query failed");
214 .catch(function (error) {
215 console.error("Add Operational Policy error received", error);