2 * ============LICENSE_START=======================================================
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
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=========================================================
20 package com.onap.sdnc.vnfbackupservice.controller;
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;
30 import com.onap.sdnc.vnfbackupservice.model.VnfServiceResponse;
31 import com.onap.sdnc.vnfbackupservice.scheduler.VnfConfigBackupScheduler;
32 import com.onap.sdnc.vnfbackupservice.service.VnfbackupService;
35 public class VnfBackupServiceController {
38 VnfbackupService vnfbackupService;
41 VnfConfigBackupScheduler vnfConfigBackupScheduler;
44 ModelAndView home(ModelAndView modelAndView) {
45 modelAndView.setViewName("index");
49 @RequestMapping(value="/getAllVnfIds", method=RequestMethod.GET,produces="application/json")
50 public VnfServiceResponse getAllVnfIds() {
51 return vnfbackupService.getAllVnfDetails();
54 @RequestMapping(value="/backupVnfconfigById/{vnfId}", method=RequestMethod.GET)
55 public String getAllVnfIds(@PathVariable("vnfId") String vnfId) {
56 return vnfbackupService.backupVnfconfig(vnfId);
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;
65 @RequestMapping(value="/backup", method=RequestMethod.GET, produces="application/text")
66 public String backupVnfConfigs() {
67 return "current time: " + vnfConfigBackupScheduler.initiateBackupService() ;
70 @RequestMapping(value="/backuptime", method=RequestMethod.GET, produces="application/text")
71 public String lastUpdatedBackuptime() {
72 return vnfbackupService.updatedBackuptime();