Add deployment system and provision simulation
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.litoralregas.openvpn.router;
|
||||
|
||||
import com.litoralregas.openvpn.deployment.DeploymentAction;
|
||||
import com.litoralregas.openvpn.deployment.DeploymentService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -11,9 +13,11 @@ import java.util.UUID;
|
||||
public class RouterController {
|
||||
|
||||
private final RouterService service;
|
||||
private final DeploymentService deploymentService;
|
||||
|
||||
public RouterController(RouterService service) {
|
||||
public RouterController(RouterService service, DeploymentService deploymentService) {
|
||||
this.service = service;
|
||||
this.deploymentService = deploymentService;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@@ -43,4 +47,16 @@ public class RouterController {
|
||||
public void delete(@PathVariable UUID id) {
|
||||
service.delete(id);
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/provision")
|
||||
public String provision(@PathVariable UUID id) {
|
||||
Router router = service.findById(id);
|
||||
|
||||
var deployment = deploymentService.startDeployment(router, DeploymentAction.PROVISION);
|
||||
|
||||
// simulate success
|
||||
deploymentService.finishSuccess(deployment, "Provision completed");
|
||||
|
||||
return "Provision simulated";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user