2 * Copyright © 2017-2018 AT&T Intellectual Property.
\r
3 * Modifications Copyright © 2018 IBM.
\r
5 * Licensed under the Apache License, Version 2.0 (the "License");
\r
6 * you may not use this file except in compliance with the License.
\r
7 * You may obtain a copy of the License at
\r
9 * http://www.apache.org/licenses/LICENSE-2.0
\r
11 * Unless required by applicable law or agreed to in writing, software
\r
12 * distributed under the License is distributed on an "AS IS" BASIS,
\r
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 * See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
18 package org.onap.ccsdk.apps.controllerblueprints.service.rs;
\r
20 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
\r
21 import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService;
\r
22 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
\r
23 import org.springframework.http.MediaType;
\r
24 import org.springframework.web.bind.annotation.*;
\r
26 import java.util.List;
\r
32 @RequestMapping(value = "/api/v1/dictionary")
\r
33 public class ResourceDictionaryRest {
\r
36 private ResourceDictionaryService resourceDictionaryService;
\r
39 * This is a DataDictionaryRestImpl, used to save and get the Resource Mapping stored in database
\r
41 * @param dataDictionaryService Data Dictionary Service
\r
43 public ResourceDictionaryRest(ResourceDictionaryService dataDictionaryService) {
\r
44 this.resourceDictionaryService = dataDictionaryService;
\r
47 @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
\r
48 public @ResponseBody
\r
49 ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary)
\r
50 throws BluePrintException {
\r
51 return resourceDictionaryService.saveResourceDictionary(dataDictionary);
\r
54 @DeleteMapping(path = "/{name}")
\r
55 public void deleteResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException {
\r
56 resourceDictionaryService.deleteResourceDictionary(name);
\r
59 @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
\r
60 public @ResponseBody
\r
61 ResourceDictionary getResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException {
\r
62 return resourceDictionaryService.getResourceDictionaryByName(name);
\r
65 @PostMapping(path = "/by-names", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
\r
66 public @ResponseBody
\r
67 List<ResourceDictionary> searchResourceDictionaryByNames(@RequestBody List<String> names)
\r
68 throws BluePrintException {
\r
69 return resourceDictionaryService.searchResourceDictionaryByNames(names);
\r
72 @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)
\r
73 public @ResponseBody
\r
74 List<ResourceDictionary> searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) throws BluePrintException {
\r
75 return resourceDictionaryService.searchResourceDictionaryByTags(tags);
\r