2 * Copyright © 2017-2018 AT&T Intellectual Property.
\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
8 * http://www.apache.org/licenses/LICENSE-2.0
\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
17 package org.onap.ccsdk.apps.controllerblueprints.service.rs;
\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
25 import java.util.List;
\r
31 @RequestMapping(value = "/api/v1/config-model")
\r
32 public class ConfigModelRest {
\r
34 private ConfigModelService configModelService;
\r
37 * This is a ConfigModelRest constructor.
\r
39 * @param configModelService Config Model Service
\r
41 public ConfigModelRest(ConfigModelService configModelService) {
\r
42 this.configModelService = configModelService;
\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
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
58 @DeleteMapping(path = "/{id}")
\r
59 public void deleteConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {
\r
60 this.configModelService.deleteConfigModel(id);
\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
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
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
82 @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)
\r
83 public @ResponseBody
\r
84 List<ConfigModel> searchConfigModels(@PathVariable(value = "tags") String tags) throws BluePrintException {
\r
85 return this.configModelService.searchConfigModels(tags);
\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