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.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
26 import java.util.List;
\r
32 @RequestMapping(value = "/api/v1/model-type")
\r
33 public class ModelTypeRest {
\r
35 private ModelTypeService modelTypeService;
\r
38 * This is a ModelTypeResourceImpl, used to save and get the model types stored in database
\r
40 * @param modelTypeService Model Type Service
\r
42 public ModelTypeRest(ModelTypeService modelTypeService) {
\r
43 this.modelTypeService = modelTypeService;
\r
46 @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
\r
47 public ModelType getModelTypeByName(@PathVariable(value = "name") String name) {
\r
48 return modelTypeService.getModelTypeByName(name);
\r
51 @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)
\r
52 public List<ModelType> searchModelTypes(@PathVariable(value = "tags") String tags) {
\r
53 return modelTypeService.searchModelTypes(tags);
\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) {
\r
59 return modelTypeService.getModelTypeByDefinitionType(definitionType);
\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
68 @DeleteMapping(path = "/{name}")
\r
69 public void deleteModelTypeByName(@PathVariable(value = "name") String name) {
\r
70 modelTypeService.deleteByModelName(name);
\r