95e551b14e70231ecad7153da784947b229f5c36
[ccsdk/cds.git] /
1 /*\r
2  * Copyright © 2017-2018 AT&T Intellectual Property.\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 package org.onap.ccsdk.apps.controllerblueprints.service.rs;\r
18 \r
19 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
20 import org.onap.ccsdk.apps.controllerblueprints.service.ConfigModelService;\r
21 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;\r
22 import org.springframework.http.MediaType;\r
23 import org.springframework.web.bind.annotation.*;\r
24 \r
25 import java.util.List;\r
26 \r
27 /**\r
28  * {@inheritDoc}\r
29  */\r
30 @RestController\r
31 @RequestMapping(value = "/api/v1/config-model")\r
32 public class ConfigModelRest {\r
33 \r
34     private ConfigModelService configModelService;\r
35 \r
36     /**\r
37      * This is a ConfigModelRest constructor.\r
38      *\r
39      * @param configModelService Config Model Service\r
40      */\r
41     public ConfigModelRest(ConfigModelService configModelService) {\r
42         this.configModelService = configModelService;\r
43 \r
44     }\r
45 \r
46     @GetMapping(path = "/initial/{name}", produces = MediaType.APPLICATION_JSON_VALUE)\r
47     public @ResponseBody\r
48     ConfigModel getInitialConfigModel(@PathVariable(value = "name") String name) throws BluePrintException {\r
49         return this.configModelService.getInitialConfigModel(name);\r
50     }\r
51 \r
52     @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
53     public @ResponseBody\r
54     ConfigModel saveConfigModel(@RequestBody ConfigModel configModel) throws BluePrintException {\r
55         return this.configModelService.saveConfigModel(configModel);\r
56     }\r
57 \r
58     @DeleteMapping(path = "/{id}")\r
59     public void deleteConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {\r
60         this.configModelService.deleteConfigModel(id);\r
61     }\r
62 \r
63     @GetMapping(path = "/publish/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
64     public @ResponseBody\r
65     ConfigModel publishConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {\r
66         return this.configModelService.publishConfigModel(id);\r
67     }\r
68 \r
69     @GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
70     public @ResponseBody\r
71     ConfigModel getConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {\r
72         return this.configModelService.getConfigModel(id);\r
73     }\r
74 \r
75     @GetMapping(path = "/by-name/{name}/version/{version}", produces = MediaType.APPLICATION_JSON_VALUE)\r
76     public @ResponseBody\r
77     ConfigModel getConfigModelByNameAndVersion(@PathVariable(value = "name") String name,\r
78                                                @PathVariable(value = "version") String version) throws BluePrintException {\r
79         return this.configModelService.getConfigModelByNameAndVersion(name, version);\r
80     }\r
81 \r
82     @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)\r
83     public @ResponseBody\r
84     List<ConfigModel> searchConfigModels(@PathVariable(value = "tags") String tags) {\r
85         return this.configModelService.searchConfigModels(tags);\r
86     }\r
87 \r
88     @GetMapping(path = "/clone/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
89     public @ResponseBody\r
90     ConfigModel getCloneConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {\r
91         return this.configModelService.getCloneConfigModel(id);\r
92     }\r
93 \r
94 }\r