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
21 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
\r
22 import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
\r
23 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
\r
24 import org.onap.ccsdk.apps.controllerblueprints.service.ServiceTemplateService;
\r
25 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent;
\r
26 import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse;
\r
27 import org.springframework.http.MediaType;
\r
28 import org.springframework.web.bind.annotation.*;
\r
30 import java.util.List;
\r
36 @RequestMapping(value = "/api/v1/service-template")
\r
37 public class ServiceTemplateRest {
\r
39 private ServiceTemplateService serviceTemplateService;
\r
42 * This is a ServiceTemplateRest constructor
\r
44 * @param serviceTemplateService Service Template Service
\r
46 public ServiceTemplateRest(ServiceTemplateService serviceTemplateService) {
\r
47 this.serviceTemplateService = serviceTemplateService;
\r
50 @PostMapping(path = "/enrich", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
\r
51 public @ResponseBody
\r
52 ServiceTemplate enrichServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException {
\r
53 return serviceTemplateService.enrichServiceTemplate(serviceTemplate);
\r
56 @PostMapping(path = "/validate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
\r
57 public @ResponseBody
\r
58 ServiceTemplate validateServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException {
\r
59 return serviceTemplateService.validateServiceTemplate(serviceTemplate);
\r
62 @PostMapping(path = "/resource-assignment/auto-map", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
\r
63 public @ResponseBody
\r
64 AutoMapResponse autoMap(@RequestBody List<ResourceAssignment> resourceAssignments) throws BluePrintException {
\r
65 return serviceTemplateService.autoMap(resourceAssignments);
\r
68 @PostMapping(path = "/resource-assignment/validate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
\r
69 public @ResponseBody
\r
70 List<ResourceAssignment> validateResourceAssignments(@RequestBody List<ResourceAssignment> resourceAssignments)
\r
71 throws BluePrintException {
\r
72 return serviceTemplateService.validateResourceAssignments(resourceAssignments);
\r
75 @PostMapping(path = "/resource-assignment/generate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
\r
76 public @ResponseBody
\r
77 List<ResourceAssignment> generateResourceAssignments(@RequestBody ConfigModelContent templateContent)
\r
78 throws BluePrintException {
\r
79 return serviceTemplateService.generateResourceAssignments(templateContent);
\r