f413d56584cdcf1e2be6da3126cca632378dacfb
[vid.git] / vid-app-common / src / main / java / org / onap / vid / controller / WorkflowsController.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.vid.controller;
22
23 import java.util.List;
24 import org.onap.vid.model.LocalWorkflowParameterDefinitions;
25 import org.onap.vid.model.SOWorkflow;
26 import org.onap.vid.model.SOWorkflowParameterDefinitions;
27 import org.onap.vid.services.ExternalWorkflowsService;
28 import org.onap.vid.services.LocalWorkflowsService;
29 import org.springframework.beans.factory.annotation.Autowired;
30 import org.springframework.web.bind.annotation.PathVariable;
31 import org.springframework.web.bind.annotation.RequestMapping;
32 import org.springframework.web.bind.annotation.RequestMethod;
33 import org.springframework.web.bind.annotation.RequestParam;
34 import org.springframework.web.bind.annotation.RestController;
35
36 @RestController
37 @RequestMapping(WorkflowsController.WORKFLOWS_MANAGEMENT)
38 public class WorkflowsController extends VidRestrictedBaseController {
39     static final String WORKFLOWS_MANAGEMENT = "workflows-management";
40
41     private ExternalWorkflowsService externalWorkflowsService;
42     private LocalWorkflowsService localWorkflowsService;
43
44     @Autowired
45     public WorkflowsController(ExternalWorkflowsService externalWorkflowsService, LocalWorkflowsService localWorkflowsService) {
46         this.externalWorkflowsService = externalWorkflowsService;
47         this.localWorkflowsService = localWorkflowsService;
48     }
49
50     @RequestMapping(value = "workflows", method = RequestMethod.GET)
51     public List<SOWorkflow> getWorkflows(@RequestParam(value = "vnfModelId") String vnfModelId){
52         return externalWorkflowsService.getWorkflows(vnfModelId);
53     }
54
55     @RequestMapping(value = "remote-workflow-parameters/{id}", method = RequestMethod.GET)
56     SOWorkflowParameterDefinitions getParameters(@PathVariable Long id) {
57         return externalWorkflowsService.getWorkflowParameterDefinitions(id);
58     }
59
60     @RequestMapping(value = "local-workflow-parameters/{name}", method = RequestMethod.GET)
61     LocalWorkflowParameterDefinitions getParameters(@PathVariable String name) {
62         return localWorkflowsService.getWorkflowParameterDefinitions(name);
63     }
64
65 }
66