2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.vid.controller;
23 import java.util.List;
24 import java.util.UUID;
26 import org.onap.vid.changeManagement.UIWorkflowsRequest;
27 import org.onap.vid.model.LocalWorkflowParameterDefinitions;
28 import org.onap.vid.model.SOWorkflow;
29 import org.onap.vid.model.SOWorkflowParameterDefinitions;
30 import org.onap.vid.mso.MsoResponseWrapper;
31 import org.onap.vid.services.ChangeManagementService;
32 import org.onap.vid.services.ExternalWorkflowsService;
33 import org.onap.vid.services.LocalWorkflowsService;
34 import org.springframework.beans.factory.annotation.Autowired;
35 import org.springframework.web.bind.annotation.PathVariable;
36 import org.springframework.web.bind.annotation.RequestBody;
37 import org.springframework.web.bind.annotation.RequestMapping;
38 import org.springframework.web.bind.annotation.RequestMethod;
39 import org.springframework.web.bind.annotation.RequestParam;
40 import org.springframework.web.bind.annotation.RestController;
42 import javax.servlet.http.HttpServletRequest;
45 @RequestMapping(WorkflowsController.WORKFLOWS_MANAGEMENT)
46 public class WorkflowsController extends VidRestrictedBaseController {
47 static final String WORKFLOWS_MANAGEMENT = "workflows-management";
49 private ExternalWorkflowsService externalWorkflowsService;
50 private LocalWorkflowsService localWorkflowsService;
51 private ChangeManagementService changeManagementService;
54 public WorkflowsController(ExternalWorkflowsService externalWorkflowsService, LocalWorkflowsService localWorkflowsService,ChangeManagementService changeManagementService) {
55 this.externalWorkflowsService = externalWorkflowsService;
56 this.localWorkflowsService = localWorkflowsService;
57 this.changeManagementService = changeManagementService;
60 @RequestMapping(value = "workflows", method = RequestMethod.GET)
61 public List<SOWorkflow> getWorkflows(@RequestParam(value = "vnfModelId") String vnfModelId){
62 return externalWorkflowsService.getWorkflows(vnfModelId);
66 @RequestMapping(value = "local-workflow-parameters/{name}", method = RequestMethod.GET)
67 LocalWorkflowParameterDefinitions getParameters(@PathVariable String name) {
68 return localWorkflowsService.getWorkflowParameterDefinitions(name);
71 @RequestMapping(value = "{serviceInstanceId}/{vnfInstanceId}/{workflow_UUID}", method = RequestMethod.POST)
72 public MsoResponseWrapper getWorkflowFromUI(HttpServletRequest request, @PathVariable("serviceInstanceId") UUID serviceInstanceId, @PathVariable("vnfInstanceId") UUID vnfInstanceId, @PathVariable("workflow_UUID") UUID workflow_UUID, @RequestBody UIWorkflowsRequest requestBody) {
73 return changeManagementService.invokeVnfWorkflow(request,requestBody.getRequestDetails(), serviceInstanceId, vnfInstanceId, workflow_UUID);