Add deployment response DTO
This commit is contained in:
@@ -15,7 +15,10 @@ public class DeploymentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public List<Deployment> getAll() {
|
public List<DeploymentResponse> getAll() {
|
||||||
return repository.findAll();
|
return repository.findAll()
|
||||||
|
.stream()
|
||||||
|
.map(DeploymentResponse::from)
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.litoralregas.openvpn.deployment;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public record DeploymentResponse(
|
||||||
|
UUID id,
|
||||||
|
UUID routerId,
|
||||||
|
String routerName,
|
||||||
|
DeploymentAction action,
|
||||||
|
DeploymentStatus status,
|
||||||
|
LocalDateTime startedAt,
|
||||||
|
LocalDateTime finishedAt,
|
||||||
|
String stdout,
|
||||||
|
String stderr,
|
||||||
|
LocalDateTime createdAt
|
||||||
|
) {
|
||||||
|
public static DeploymentResponse from(Deployment deployment) {
|
||||||
|
return new DeploymentResponse(
|
||||||
|
deployment.getId(),
|
||||||
|
deployment.getRouter().getId(),
|
||||||
|
deployment.getRouter().getName(),
|
||||||
|
deployment.getAction(),
|
||||||
|
deployment.getStatus(),
|
||||||
|
deployment.getStartedAt(),
|
||||||
|
deployment.getFinishedAt(),
|
||||||
|
deployment.getStdout(),
|
||||||
|
deployment.getStderr(),
|
||||||
|
deployment.getCreatedAt()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user