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 {
25 static getAllLoopTemplates() {
26 return fetch('restservices/clds/v2/templates', { method: 'GET', credentials: 'same-origin', })
27 .then(function (response) {
28 console.debug("getAllLoopTemplates response received: ", response.status);
30 return response.json();
32 console.error("getAllLoopTemplates query failed");
36 .catch(function (error) {
37 console.error("getAllLoopTemplates error received", error);
42 static getDictionary() {
43 return fetch('restservices/clds/v2/dictionary/', { method: 'GET', credentials: 'same-origin', })
44 .then(function (response) {
45 console.debug("getDictionary response received: ", response.status);
47 return response.json();
49 console.error("getDictionary query failed");
53 .catch(function (error) {
54 console.error("getDictionary error received", error);
59 static getDictionaryElements(dictionaryName) {
60 return fetch('restservices/clds/v2/dictionary/' + dictionaryName, {
63 "Content-Type": "application/json",
65 credentials: 'same-origin',
67 .then(function (response) {
68 console.debug("getDictionaryElements response received: ", response.status);
70 return response.json();
72 console.error("getDictionaryElements query failed");
76 .catch(function (error) {
77 console.error("getDictionaryElements error received", error);
82 static insDictionary(jsonData) {
83 console.log("dictionaryName is", jsonData.name)
84 return fetch('/restservices/clds/v2/dictionary/', {
86 credentials: 'same-origin',
88 "Content-Type": "application/json",
90 body: JSON.stringify(jsonData)
92 .then(function (response) {
93 console.debug("insDictionary response received: ", response.status);
95 return response.status;
97 var errorMessage = response.status;
98 console.error("insDictionary query failed", response.status);
102 .catch(function (error) {
103 console.error("insDictionary error received", error);
108 static insDictionaryElements(jsonData) {
109 console.log("dictionaryName is", jsonData.name)
110 return fetch('/restservices/clds/v2/dictionary/' + jsonData.name, {
112 credentials: 'same-origin',
114 "Content-Type": "application/json",
116 body: JSON.stringify(jsonData)
118 .then(function (response) {
119 console.debug("insDictionary response received: ", response.status);
121 return response.status;
123 var errorMessage = response.status;
124 console.error("insDictionary query failed", response.status);
128 .catch(function (error) {
129 console.error("insDictionary error received", error);
134 static deleteDictionary(dictionaryName) {
135 console.log("inside templaemenu service", dictionaryName)
136 return fetch('restservices/clds/v2/dictionary/' + dictionaryName, {
139 "Content-Type": "application/json",
141 credentials: 'same-origin',
143 .then(function (response) {
144 console.debug("deleteDictionary response received: ", response.status);
146 return response.status;
148 console.error("deleteDictionary query failed");
152 .catch(function (error) {
153 console.error("deleteDictionary error received", error);
158 static deleteDictionaryElements(dictionaryData) {
159 return fetch('restservices/clds/v2/dictionary/' + dictionaryData.name + '/elements/' + dictionaryData.shortName , {
162 "Content-Type": "application/json",
164 credentials: 'same-origin',
166 .then(function (response) {
167 console.debug("deleteDictionary response received: ", response.status);
169 return response.status;
171 console.error("deleteDictionary query failed");
175 .catch(function (error) {
176 console.error("deleteDictionary error received", error);