NonRT-RIC A1 Northbound API
[nonrtric.git] / sdnc-a1-controller / oam / configbackuprestore / vnfconfigbackupservice / src / main / java / com / onap / sdnc / vnfbackupservice / controller / VnfBackupServiceController.java
1 /*
2 * ============LICENSE_START=======================================================
3 * ONAP : SDNC-FEATURES
4 * ================================================================================
5 * Copyright 2018 TechMahindra
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 package com.onap.sdnc.vnfbackupservice.controller;
21
22 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.web.bind.annotation.PathVariable;
24 import org.springframework.web.bind.annotation.RequestBody;
25 import org.springframework.web.bind.annotation.RequestMapping;
26 import org.springframework.web.bind.annotation.RequestMethod;
27 import org.springframework.web.bind.annotation.RestController;
28 import org.springframework.web.servlet.ModelAndView;
29
30 import com.onap.sdnc.vnfbackupservice.model.VnfServiceResponse;
31 import com.onap.sdnc.vnfbackupservice.scheduler.VnfConfigBackupScheduler;
32 import com.onap.sdnc.vnfbackupservice.service.VnfbackupService;
33
34 @RestController
35 public class VnfBackupServiceController {
36
37         @Autowired
38         VnfbackupService vnfbackupService;
39         
40         @Autowired      
41         VnfConfigBackupScheduler vnfConfigBackupScheduler;
42         
43         @RequestMapping("/")
44         ModelAndView home(ModelAndView modelAndView) {
45                 modelAndView.setViewName("index");
46                 return modelAndView;
47         }
48         
49         @RequestMapping(value="/getAllVnfIds", method=RequestMethod.GET,produces="application/json")
50         public VnfServiceResponse  getAllVnfIds() {
51                 return vnfbackupService.getAllVnfDetails();
52         }
53         
54         @RequestMapping(value="/backupVnfconfigById/{vnfId}", method=RequestMethod.GET)
55         public String  getAllVnfIds(@PathVariable("vnfId") String vnfId) {
56                 return vnfbackupService.backupVnfconfig(vnfId);         
57         }
58         
59         @RequestMapping(value="/vnf-list/{vnf-Id}", method=RequestMethod.PUT)
60         public String  putOneVnfconfig(@RequestBody String configfile, @PathVariable("vnf-Id") String vnfId) {          
61                 String vnfconfigupdated = vnfbackupService.putVnfconfig(configfile,vnfId);              
62                 return vnfconfigupdated;
63         }
64         
65         @RequestMapping(value="/backup", method=RequestMethod.GET, produces="application/text")
66         public String backupVnfConfigs() {
67                 return "current time:  " + vnfConfigBackupScheduler.initiateBackupService() ;
68         }
69         
70         @RequestMapping(value="/backuptime", method=RequestMethod.GET, produces="application/text")
71         public String lastUpdatedBackuptime() {         
72                 return vnfbackupService.updatedBackuptime();
73         }
74 }