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.stereotype.Component;
\r
23 import org.springframework.stereotype.Service;
\r
24 import org.springframework.web.bind.annotation.*;
\r
26 import java.util.List;
\r
32 @RequestMapping("/api/v1/config-model")
\r
33 public class ConfigModelRest {
\r
35 private ConfigModelService configModelService;
\r
38 * This is a ConfigModelRest constructor.
\r
40 * @param configModelService Config Model Service
\r
42 public ConfigModelRest(ConfigModelService configModelService) {
\r
43 this.configModelService = configModelService;
\r
47 @GetMapping(path = "/initial/{name}")
\r
48 public @ResponseBody
\r
49 ConfigModel getInitialConfigModel(@PathVariable(value = "name") String name) throws BluePrintException {
\r
51 return this.configModelService.getInitialConfigModel(name);
\r
52 } catch (Exception e) {
\r
53 throw new BluePrintException(2000, e.getMessage(), e);
\r
57 @PostMapping(path = "/")
\r
58 public @ResponseBody
\r
59 ConfigModel saveConfigModel(@RequestBody ConfigModel configModel) throws BluePrintException {
\r
61 return this.configModelService.saveConfigModel(configModel);
\r
62 } catch (Exception e) {
\r
63 throw new BluePrintException(2200, e.getMessage(), e);
\r
67 @DeleteMapping(path = "/{id}")
\r
68 public void deleteConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {
\r
70 this.configModelService.deleteConfigModel(id);
\r
71 } catch (Exception e) {
\r
72 throw new BluePrintException(4000, e.getMessage(), e);
\r
76 @GetMapping(path = "/publish/{id}")
\r
77 public @ResponseBody
\r
78 ConfigModel publishConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {
\r
80 return this.configModelService.publishConfigModel(id);
\r
81 } catch (Exception e) {
\r
82 throw new BluePrintException(2500, e.getMessage(), e);
\r
86 @GetMapping(path = "/{id}")
\r
87 public @ResponseBody
\r
88 ConfigModel getConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {
\r
90 return this.configModelService.getConfigModel(id);
\r
91 } catch (Exception e) {
\r
92 throw new BluePrintException(2001, e.getMessage(), e);
\r
96 @GetMapping(path = "/by-name/{name}/version/{version}")
\r
97 public @ResponseBody
\r
98 ConfigModel getConfigModelByNameAndVersion(@PathVariable(value = "name") String name,
\r
99 @PathVariable(value = "version") String version) throws BluePrintException {
\r
101 return this.configModelService.getConfigModelByNameAndVersion(name, version);
\r
102 } catch (Exception e) {
\r
103 throw new BluePrintException(2002, e.getMessage(), e);
\r
107 @GetMapping(path = "/search/{tags}")
\r
108 public @ResponseBody
\r
109 List<ConfigModel> searchConfigModels(@PathVariable(value = "tags") String tags) throws BluePrintException {
\r
111 return this.configModelService.searchConfigModels(tags);
\r
112 } catch (Exception e) {
\r
113 throw new BluePrintException(2003, e.getMessage(), e);
\r
117 @GetMapping(path = "/clone/{id}")
\r
118 public @ResponseBody
\r
119 ConfigModel getCloneConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException {
\r
121 return this.configModelService.getCloneConfigModel(id);
\r
122 } catch (Exception e) {
\r
123 throw new BluePrintException(2004, e.getMessage(), e);
\r