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 getDictionary() {
59 return fetch('restservices/clds/v2/dictionary/', { method: 'GET', credentials: 'same-origin', })
60 .then(function (response) {
61 console.debug("getDictionary response received: ", response.status);
63 return response.json();
65 console.error("getDictionary query failed");
69 .catch(function (error) {
70 console.error("getDictionary error received", error);
75 static getDictionaryElements(dictionaryName) {
76 return fetch('restservices/clds/v2/dictionary/' + dictionaryName, {
79 "Content-Type": "application/json",
81 credentials: 'same-origin',
83 .then(function (response) {
84 console.debug("getDictionaryElements response received: ", response.status);
86 return response.json();
88 console.error("getDictionaryElements query failed");
92 .catch(function (error) {
93 console.error("getDictionaryElements error received", error);
98 static insDictionary(jsonData) {
99 console.log("dictionaryName is", jsonData.name)
100 return fetch('/restservices/clds/v2/dictionary/', {
102 credentials: 'same-origin',
104 "Content-Type": "application/json",
106 body: JSON.stringify(jsonData)
108 .then(function (response) {
109 console.debug("insDictionary response received: ", response.status);
111 return response.status;
113 var errorMessage = response.status;
114 console.error("insDictionary query failed", response.status);
118 .catch(function (error) {
119 console.error("insDictionary error received", error);
124 static insDictionaryElements(jsonData) {
125 console.log("dictionaryName is", jsonData.name)
126 return fetch('/restservices/clds/v2/dictionary/' + jsonData.name, {
128 credentials: 'same-origin',
130 "Content-Type": "application/json",
132 body: JSON.stringify(jsonData)
134 .then(function (response) {
135 console.debug("insDictionary response received: ", response.status);
137 return response.status;
139 var errorMessage = response.status;
140 console.error("insDictionary query failed", response.status);
144 .catch(function (error) {
145 console.error("insDictionary error received", error);
150 static deleteDictionary(dictionaryName) {
151 console.log("inside templaemenu service", dictionaryName)
152 return fetch('restservices/clds/v2/dictionary/' + dictionaryName, {
155 "Content-Type": "application/json",
157 credentials: 'same-origin',
159 .then(function (response) {
160 console.debug("deleteDictionary response received: ", response.status);
162 return response.status;
164 console.error("deleteDictionary query failed");
168 .catch(function (error) {
169 console.error("deleteDictionary error received", error);
174 static deleteDictionaryElements(dictionaryData) {
175 return fetch('restservices/clds/v2/dictionary/' + dictionaryData.name + '/elements/' + dictionaryData.shortName , {
178 "Content-Type": "application/json",
180 credentials: 'same-origin',
182 .then(function (response) {
183 console.debug("deleteDictionary response received: ", response.status);
185 return response.status;
187 console.error("deleteDictionary query failed");
191 .catch(function (error) {
192 console.error("deleteDictionary error received", error);