Create seed code of svnfm vnfmdriver
[vfc/nfvo/driver/vnfm/svnfm.git] / nokia / vnfmdriver / vfcadaptorservice / vfcadaptor / src / main / java / com / nokia / vfcadaptor / cbam / controller / CbamController.java
1 /*
2  * Copyright 2016-2017, Nokia Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package com.nokia.vfcadaptor.cbam.controller;
18
19 import org.springframework.http.MediaType;
20 import org.springframework.stereotype.Controller;
21 import org.springframework.web.bind.annotation.PathVariable;
22 import org.springframework.web.bind.annotation.RequestMapping;
23 import org.springframework.web.bind.annotation.RequestMethod;
24 import org.springframework.web.bind.annotation.ResponseBody;
25
26 import com.nokia.vfcadaptor.cbam.bo.CBAMCreateVnfResponse;
27 import com.nokia.vfcadaptor.cbam.bo.CBAMHealVnfRequest;
28 import com.nokia.vfcadaptor.cbam.bo.CBAMHealVnfResponse;
29 import com.nokia.vfcadaptor.cbam.bo.CBAMInstantiateVnfRequest;
30 import com.nokia.vfcadaptor.cbam.bo.CBAMInstantiateVnfResponse;
31 import com.nokia.vfcadaptor.cbam.bo.CBAMOperExecutVnfRequest;
32 import com.nokia.vfcadaptor.cbam.bo.CBAMOperExecutVnfResponse;
33 import com.nokia.vfcadaptor.cbam.bo.CBAMQueryVnfResponse;
34 import com.nokia.vfcadaptor.cbam.bo.CBAMScaleVnfRequest;
35 import com.nokia.vfcadaptor.cbam.bo.CBAMScaleVnfResponse;
36 import com.nokia.vfcadaptor.cbam.bo.CBAMTerminateVnfRequest;
37 import com.nokia.vfcadaptor.cbam.bo.CBAMTerminateVnfResponse;
38 import com.nokia.vfcadaptor.cbam.bo.entity.OperationExecution;
39 import com.nokia.vfcadaptor.cbam.bo.entity.ProblemDetails;
40 import com.nokia.vfcadaptor.cbam.bo.entity.VnfInfo;
41
42 @Controller
43 @RequestMapping(value = "/vnfm/lcm/v3")
44 public class CbamController {
45         
46         @RequestMapping(value = "/vnfs", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
47     @ResponseBody
48     public CBAMCreateVnfResponse createVnf(CBAMInstantiateVnfRequest request)
49     {
50                  CBAMCreateVnfResponse response = new  CBAMCreateVnfResponse();
51                  VnfInfo op=new VnfInfo();
52                 op.setName("VNF_001");
53                 ProblemDetails pr=new ProblemDetails();
54                 pr.setStatus(200);
55                 response.setVnfInfo(op);
56                 response.setProblemDetails(pr);
57         return response;
58     }
59         @RequestMapping(value = "/vnfs/{vnfInstanceId}/instantiate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
60     @ResponseBody
61     public CBAMInstantiateVnfResponse initiateVnf(CBAMInstantiateVnfRequest request, @PathVariable("vnfInstanceId") String vnfInstanceId)
62     {
63                 CBAMInstantiateVnfResponse response = new CBAMInstantiateVnfResponse();
64 //              response.setJobid("11234");
65                 
66         return response;
67     }
68         
69         @RequestMapping(value = "/vnfs/{vnfInstanceId}/terminate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
70     @ResponseBody
71     public CBAMTerminateVnfResponse terminateVnf(CBAMTerminateVnfRequest request, @PathVariable("vnfInstanceId") String vnfInstanceId)
72     {
73                 CBAMTerminateVnfResponse response = new CBAMTerminateVnfResponse();
74                 OperationExecution op=new OperationExecution();
75                 op.setGrantId("89");
76                 ProblemDetails pr=new ProblemDetails();
77                 pr.setStatus(200);
78                 response.setOperationExecution(op);
79                 response.setProblemDetails(pr);
80         return response;
81     }
82         
83         @RequestMapping(value = "/vnfs/{vnfInstanceId}/scale", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
84     @ResponseBody
85     public CBAMScaleVnfResponse scaleVnf(CBAMScaleVnfRequest request, @PathVariable("vnfInstanceId") String vnfInstanceId)
86     {
87                 CBAMScaleVnfResponse response = new CBAMScaleVnfResponse();
88                 OperationExecution op=new OperationExecution();
89                 op.setGrantId("89");
90                 ProblemDetails pr=new ProblemDetails();
91                 pr.setStatus(200);
92                 response.setOperationExecution(op);
93                 response.setProblemDetails(pr);
94         return response;
95     }
96
97         @RequestMapping(value = "/vnfs/{vnfInstanceId}/heal", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
98     @ResponseBody
99     public CBAMHealVnfResponse healVnf(CBAMHealVnfRequest request, @PathVariable("vnfInstanceId") String vnfInstanceId)
100     {
101                  CBAMHealVnfResponse response = new  CBAMHealVnfResponse();
102                 OperationExecution op=new OperationExecution();
103                 op.setGrantId("89");
104                 ProblemDetails pr=new ProblemDetails();
105                 pr.setStatus(200);
106                 response.setOperationExecution(op);
107                 response.setProblemDetails(pr);
108         return response;
109     }
110         
111         
112         @RequestMapping(value = "/vnfs/{vnfInstanceId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
113     @ResponseBody
114     public CBAMQueryVnfResponse queryVnf(@PathVariable("vnfInstanceId") String vnfInstanceId)
115     {
116                 CBAMQueryVnfResponse response = new  CBAMQueryVnfResponse();
117                 VnfInfo op=new VnfInfo();
118                 op.setName("VNF_001");
119                 ProblemDetails pr=new ProblemDetails();
120                 pr.setStatus(200);
121                 response.setVnfInfo(op);
122                 response.setProblemDetails(pr);
123         return response;
124     }
125         
126         
127         @RequestMapping(value = "/operation_executions/{operationExecutionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
128     @ResponseBody
129     public CBAMOperExecutVnfResponse operVnf(@PathVariable("operationExecutionId") String operationExecutionId)
130     {
131                 CBAMOperExecutVnfResponse response = new  CBAMOperExecutVnfResponse();
132                 ProblemDetails pr=new ProblemDetails();
133                 pr.setStatus(200);
134                 response.setProblemDetails(pr);
135         return response;
136     }
137         
138         @RequestMapping(value = "/operation_executions/{operationExecutionId}/cancel", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE,consumes = MediaType.APPLICATION_JSON_VALUE)
139     @ResponseBody
140     public CBAMOperExecutVnfResponse operCancelVnf(CBAMOperExecutVnfRequest request,@PathVariable("operationExecutionId") String operationExecutionId)
141     {
142                 CBAMOperExecutVnfResponse response = new  CBAMOperExecutVnfResponse();
143                 ProblemDetails pr=new ProblemDetails();
144                 pr.setStatus(200);
145                 response.setProblemDetails(pr);
146         return response;
147     }
148         
149
150 }