Enable blueprintprocessor and vlantag-api
[ccsdk/apps.git] / ms / controllerblueprints / modules / service / src / main / java / org / onap / ccsdk / apps / controllerblueprints / service / rs / ModelTypeRest.java
1 /*\r
2  * Copyright © 2017-2018 AT&T Intellectual Property.\r
3  * Modifications Copyright © 2018 IBM.\r
4  *\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
8  *\r
9  *     http://www.apache.org/licenses/LICENSE-2.0\r
10  *\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
16  */\r
17 \r
18 package org.onap.ccsdk.apps.controllerblueprints.service.rs;\r
19 \r
20 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
21 import org.onap.ccsdk.apps.controllerblueprints.service.ModelTypeService;\r
22 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;\r
23 import org.springframework.http.MediaType;\r
24 import org.springframework.web.bind.annotation.*;\r
25 \r
26 import java.util.List;\r
27 \r
28 /**\r
29  * {@inheritDoc}\r
30  */\r
31 @RestController\r
32 @RequestMapping(value = "/api/v1/model-type")\r
33 public class ModelTypeRest {\r
34 \r
35     private ModelTypeService modelTypeService;\r
36 \r
37     /**\r
38      * This is a ModelTypeResourceImpl, used to save and get the model types stored in database\r
39      *\r
40      * @param modelTypeService Model Type Service\r
41      */\r
42     public ModelTypeRest(ModelTypeService modelTypeService) {\r
43         this.modelTypeService = modelTypeService;\r
44     }\r
45 \r
46     @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)\r
47     public ModelType getModelTypeByName(@PathVariable(value = "name") String name) throws BluePrintException {\r
48         return modelTypeService.getModelTypeByName(name);\r
49     }\r
50 \r
51     @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)\r
52     public List<ModelType> searchModelTypes(@PathVariable(value = "tags") String tags) throws BluePrintException {\r
53         return modelTypeService.searchModelTypes(tags);\r
54     }\r
55 \r
56     @GetMapping(path = "/by-definition/{definitionType}", produces = MediaType.APPLICATION_JSON_VALUE)\r
57     public @ResponseBody\r
58     List<ModelType> getModelTypeByDefinitionType(@PathVariable(value = "definitionType") String definitionType) throws BluePrintException {\r
59         return modelTypeService.getModelTypeByDefinitionType(definitionType);\r
60     }\r
61 \r
62     @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)\r
63     public @ResponseBody\r
64     ModelType saveModelType(@RequestBody ModelType modelType) throws BluePrintException {\r
65         return modelTypeService.saveModel(modelType);\r
66     }\r
67 \r
68     @DeleteMapping(path = "/{name}")\r
69     public void deleteModelTypeByName(@PathVariable(value = "name") String name) throws BluePrintException {\r
70         modelTypeService.deleteByModelName(name);\r
71     }\r
72 }\r