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 TemplateService {
24 static getTemplateNames() {
25 return fetch('/restservices/clds/v2/templates/names', { method: 'GET', credentials: 'same-origin' })
26 .then(function (response) {
27 console.debug("GetTemplateNames response received: ", response.status);
29 return response.json();
31 console.error("GetTemplateNames query failed");
35 .catch(function (error) {
36 console.error("GetTemplateNames error received", error);
41 static getBlueprintMicroServiceTemplates() {
42 return fetch('restservices/clds/v2/templates', { method: 'GET', credentials: 'same-origin', })
43 .then(function (response) {
44 console.debug("getBlueprintMicroServiceTemplates response received: ", response.status);
46 return response.json();
48 console.error("getBlueprintMicroServiceTemplates query failed");
52 .catch(function (error) {
53 console.error("getBlueprintMicroServiceTemplates error received", error);
58 static getBlueprintMicroServiceTemplate(templateName) {
59 return fetch('/restservices/clds/v2/templates/' + templateName + ' /svgRepresentation', { method: 'GET', credentials: 'same-origin', })
60 .then(function (response) {
61 console.debug("getBlueprintMicroServiceTemplate response received: ", response.status);
63 return response.text();
65 console.error("getBlueprintMicroServiceTemplates query failed");
69 .catch(function (error) {
70 console.error("getBlueprintMicroServiceTemplate error received", error);
75 static getDictionary() {
76 return fetch('restservices/clds/v2/dictionary/', { method: 'GET', credentials: 'same-origin', })
77 .then(function (response) {
78 console.debug("getDictionary response received: ", response.status);
80 return response.json();
82 console.error("getDictionary query failed");
86 .catch(function (error) {
87 console.error("getDictionary error received", error);
92 static getDictionaryElements(dictionaryName) {
93 return fetch('restservices/clds/v2/dictionary/' + dictionaryName, {
96 "Content-Type": "application/json",
98 credentials: 'same-origin',
100 .then(function (response) {
101 console.debug("getDictionaryElements response received: ", response.status);
103 return response.json();
105 console.error("getDictionaryElements query failed");
109 .catch(function (error) {
110 console.error("getDictionaryElements error received", error);
115 static insDictionary(jsonData) {
116 console.log("dictionaryName is", jsonData.name)
117 return fetch('/restservices/clds/v2/dictionary/', {
119 credentials: 'same-origin',
121 "Content-Type": "application/json",
123 body: JSON.stringify(jsonData)
125 .then(function (response) {
126 console.debug("insDictionary response received: ", response.status);
128 return response.status;
130 var errorMessage = response.status;
131 console.error("insDictionary query failed", response.status);
135 .catch(function (error) {
136 console.error("insDictionary error received", error);
141 static insDictionaryElements(jsonData) {
142 console.log("dictionaryName is", jsonData.name)
143 return fetch('/restservices/clds/v2/dictionary/' + jsonData.name, {
145 credentials: 'same-origin',
147 "Content-Type": "application/json",
149 body: JSON.stringify(jsonData)
151 .then(function (response) {
152 console.debug("insDictionary response received: ", response.status);
154 return response.status;
156 var errorMessage = response.status;
157 console.error("insDictionary query failed", response.status);
161 .catch(function (error) {
162 console.error("insDictionary error received", error);
167 static deleteDictionary(dictionaryName) {
168 console.log("inside templaemenu service", dictionaryName)
169 return fetch('restservices/clds/v2/dictionary/' + dictionaryName, {
172 "Content-Type": "application/json",
174 credentials: 'same-origin',
176 .then(function (response) {
177 console.debug("deleteDictionary response received: ", response.status);
179 return response.status;
181 console.error("deleteDictionary query failed");
185 .catch(function (error) {
186 console.error("deleteDictionary error received", error);
191 static deleteDictionaryElements(dictionaryData) {
192 return fetch('restservices/clds/v2/dictionary/' + dictionaryData.name + '/elements/' + dictionaryData.shortName , {
195 "Content-Type": "application/json",
197 credentials: 'same-origin',
199 .then(function (response) {
200 console.debug("deleteDictionary response received: ", response.status);
202 return response.status;
204 console.error("deleteDictionary query failed");
208 .catch(function (error) {
209 console.error("deleteDictionary error received", error);