b025b2ffa9a5c14e2bfc5bdcd7b96d28ec664e48
[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 @Deprecated\r
31 @RestController\r
32 @RequestMapping(value = "/api/v1/config-model")\r
33 public class ConfigModelRest {\r
34 \r
35     private ConfigModelService configModelService;\r
36 \r
37     /**\r
38      * This is a ConfigModelRest constructor.\r
39      *\r
40      * @param configModelService Config Model Service\r
41      */\r
42     public ConfigModelRest(ConfigModelService configModelService) {\r
43         this.configModelService = configModelService;\r
44 \r
45     }\r
46 \r
47     @GetMapping(path = "/initial/{name}", produces = MediaType.APPLICATION_JSON_VALUE)\r
48     public @ResponseBody\r
49     ConfigModel getInitialConfigModel(@PathVariable(value = "name") String name) throws BluePrintException {\r
50         return this.configModelService.getInitialConfigModel(name);\r
51     }\r
52 \r
53     @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
54     public @ResponseBody\r
55     ConfigModel saveConfigModel(@RequestBody ConfigModel configModel) throws BluePrintException {\r
56         return this.configModelService.saveConfigModel(configModel);\r
57     }\r
58 \r
59     @DeleteMapping(path = "/{id}")\r
60     public void deleteConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {\r
61         this.configModelService.deleteConfigModel(id);\r
62     }\r
63 \r
64     @GetMapping(path = "/publish/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
65     public @ResponseBody\r
66     ConfigModel publishConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {\r
67         return this.configModelService.publishConfigModel(id);\r
68     }\r
69 \r
70     @GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
71     public @ResponseBody\r
72     ConfigModel getConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {\r
73         return this.configModelService.getConfigModel(id);\r
74     }\r
75 \r
76     @GetMapping(path = "/by-name/{name}/version/{version}", produces = MediaType.APPLICATION_JSON_VALUE)\r
77     public @ResponseBody\r
78     ConfigModel getConfigModelByNameAndVersion(@PathVariable(value = "name") String name,\r
79                                                @PathVariable(value = "version") String version) throws BluePrintException {\r
80         return this.configModelService.getConfigModelByNameAndVersion(name, version);\r
81     }\r
82 \r
83     @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)\r
84     public @ResponseBody\r
85     List<ConfigModel> searchConfigModels(@PathVariable(value = "tags") String tags) {\r
86         return this.configModelService.searchConfigModels(tags);\r
87     }\r
88 \r
89     @GetMapping(path = "/clone/{id}", produces = MediaType.APPLICATION_JSON_VALUE)\r
90     public @ResponseBody\r
91     ConfigModel getCloneConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {\r
92         return this.configModelService.getCloneConfigModel(id);\r
93     }\r
94 \r
95 }\r