1 package org.edgegallery.example_app.controller;
3 import io.swagger.annotations.ApiOperation;
4 import io.swagger.annotations.ApiParam;
5 import io.swagger.annotations.ApiResponse;
6 import io.swagger.annotations.ApiResponses;
8 import javax.validation.Valid;
9 import javax.validation.constraints.NotNull;
10 import javax.ws.rs.core.MediaType;
11 import org.hibernate.validator.constraints.Length;
12 import org.edgegallery.example_app.model.EALTEdgeBackupRestore;
13 import org.edgegallery.example_app.service.backupServiceHandler;
14 import org.edgegallery.example_app.service.createParam;
15 import org.edgegallery.example_app.service.createParamRestore;
16 import org.springframework.beans.factory.annotation.Autowired;
17 import org.springframework.http.ResponseEntity;
18 import org.springframework.stereotype.Controller;
19 import org.springframework.validation.annotation.Validated;
20 import org.springframework.web.bind.annotation.CrossOrigin;
21 import org.springframework.web.bind.annotation.GetMapping;
22 import org.springframework.web.bind.annotation.PostMapping;
23 import org.springframework.web.bind.annotation.RequestBody;
24 import org.springframework.web.bind.annotation.RequestMapping;
25 import org.springframework.web.bind.annotation.RequestPart;
26 import org.springframework.web.bind.annotation.RestController;
30 @RequestMapping("/v1/robo")
32 public class backupController {
33 private static final int MAX_COMMON_STRING_LENGTH = 255;
35 private static final int MAX_DETAILS_STRING_LENGTH = 1024;
38 private backupServiceHandler BackupServiceHandler;
40 @GetMapping(value = "/backup-restore", produces = MediaType.APPLICATION_JSON)
41 @ApiOperation(value = "get backup and restore tables.", response = EALTEdgeBackupRestore.class,
42 responseContainer = "List")
43 @ApiResponses(value = {
44 @ApiResponse(code = 404, message = "microservice not found", response = String.class),
45 @ApiResponse(code = 415, message = "Unprocessable " + "MicroServiceInfo Entity ",
46 response = String.class),
47 @ApiResponse(code = 500, message = "resource grant " + "error", response = String.class)
49 public ResponseEntity<EALTEdgeBackupRestore> getBackupRestoreDetails() {
50 return BackupServiceHandler.getBackupRestoreDetails();
53 @PostMapping(value = "/backup", produces = MediaType.APPLICATION_JSON)
54 @ApiOperation(value = "create backup.", response = String.class)
55 @ApiResponses(value = {
56 @ApiResponse(code = 404, message = "microservice not found", response = String.class),
57 @ApiResponse(code = 415, message = "Unprocessable " + "MicroServiceInfo Entity ",
58 response = String.class),
59 @ApiResponse(code = 500, message = "resource grant " + "error", response = String.class)
61 public ResponseEntity<String> getBackupRestoreDetails(@ApiParam(value = "create backup instance")
62 @Valid @RequestBody createParam CreateParam) {
63 BackupServiceHandler.createBackup(CreateParam.getBackupName(), CreateParam.getNamespace());
64 return ResponseEntity.ok("create backup success.");
68 /* @PostMapping(value = "/v1/robo/backup", produces = MediaType.APPLICATION_JSON)
69 public ResponseEntity<String> getBackupRestoreDetails( @ApiParam(value = "create backup instance")
70 @Valid @RequestBody createParam CreateParam) {
71 BackupServiceHandler.createBackup(CreateParam.getBackupName(), CreateParam.getNamespace());
72 return ResponseEntity.ok("create backup success.");
75 @PostMapping(value = "/restore", produces = MediaType.APPLICATION_JSON)
76 @ApiOperation(value = "create restore.", response = String.class)
77 @ApiResponses(value = {
78 @ApiResponse(code = 404, message = "microservice not found", response = String.class),
79 @ApiResponse(code = 415, message = "Unprocessable " + "MicroServiceInfo Entity ",
80 response = String.class),
81 @ApiResponse(code = 500, message = "resource grant " + "error", response = String.class)
83 public ResponseEntity<String> createRestore(@ApiParam(value = "create restore instance")
84 @Valid @RequestBody createParamRestore CreateParam) {
85 BackupServiceHandler.createRestore(CreateParam.getRestoreName(), CreateParam.getBackupName());
86 return ResponseEntity.ok("create restore success.");