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.domain.ModelType;
\r
22 import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler;
\r
23 import org.springframework.http.MediaType;
\r
24 import org.springframework.web.bind.annotation.*;
\r
26 import java.util.List;
\r
33 //@RequestMapping(value = "/api/v1/model-type")
\r
34 public class ModelTypeRest {
\r
36 private ModelTypeHandler modelTypeService;
\r
39 * This is a ModelTypeResourceImpl, used to save and get the model types stored in database
\r
41 * @param modelTypeService Model Type Service
\r
43 public ModelTypeRest(ModelTypeHandler modelTypeService) {
\r
44 this.modelTypeService = modelTypeService;
\r
47 @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
\r
48 public ModelType getModelTypeByName(@PathVariable(value = "name") String name) {
\r
49 return modelTypeService.getModelTypeByName(name);
\r
52 @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)
\r
53 public List<ModelType> searchModelTypes(@PathVariable(value = "tags") String tags) {
\r
54 return modelTypeService.searchModelTypes(tags);
\r
57 @GetMapping(path = "/by-definition/{definitionType}", produces = MediaType.APPLICATION_JSON_VALUE)
\r
58 public @ResponseBody
\r
59 List<ModelType> getModelTypeByDefinitionType(@PathVariable(value = "definitionType") String definitionType) {
\r
60 return modelTypeService.getModelTypeByDefinitionType(definitionType);
\r
63 @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
\r
64 public @ResponseBody
\r
65 ModelType saveModelType(@RequestBody ModelType modelType) throws BluePrintException {
\r
66 return modelTypeService.saveModel(modelType);
\r
69 @DeleteMapping(path = "/{name}")
\r
70 public void deleteModelTypeByName(@PathVariable(value = "name") String name) {
\r
71 modelTypeService.deleteByModelName(name);
\r