mirror of
https://github.com/aljazceru/lnd-manageJ.git
synced 2026-01-21 15:04:22 +01:00
add node warnings functionality (at the moment: only online percentage)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package de.cotto.lndmanagej.controller;
|
||||
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import de.cotto.lndmanagej.controller.dto.NodeWarningsDto;
|
||||
import de.cotto.lndmanagej.controller.dto.ObjectMapperConfiguration;
|
||||
import de.cotto.lndmanagej.model.Pubkey;
|
||||
import de.cotto.lndmanagej.service.NodeWarningsService;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/")
|
||||
@Import(ObjectMapperConfiguration.class)
|
||||
public class WarningsController {
|
||||
private final NodeWarningsService nodeWarningsService;
|
||||
|
||||
public WarningsController(NodeWarningsService nodeWarningsService) {
|
||||
this.nodeWarningsService = nodeWarningsService;
|
||||
}
|
||||
|
||||
@Timed
|
||||
@GetMapping("/node/{pubkey}/warnings")
|
||||
public NodeWarningsDto getWarningsForNode(@PathVariable Pubkey pubkey) {
|
||||
return NodeWarningsDto.createFromModel(nodeWarningsService.getNodeWarnings(pubkey));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import de.cotto.lndmanagej.model.ChannelId;
|
||||
import de.cotto.lndmanagej.model.NodeDetails;
|
||||
import de.cotto.lndmanagej.model.NodeWarning;
|
||||
import de.cotto.lndmanagej.model.Pubkey;
|
||||
|
||||
import java.util.List;
|
||||
@@ -19,7 +20,8 @@ public record NodeDetailsDto(
|
||||
BalanceInformationDto balance,
|
||||
OnlineReportDto onlineReport,
|
||||
FeeReportDto feeReport,
|
||||
RebalanceReportDto rebalanceReport
|
||||
RebalanceReportDto rebalanceReport,
|
||||
List<NodeWarning> nodeWarnings
|
||||
) {
|
||||
public static NodeDetailsDto createFromModel(NodeDetails nodeDetails) {
|
||||
return new NodeDetailsDto(
|
||||
@@ -33,7 +35,8 @@ public record NodeDetailsDto(
|
||||
BalanceInformationDto.createFromModel(nodeDetails.balanceInformation()),
|
||||
OnlineReportDto.createFromModel(nodeDetails.onlineReport()),
|
||||
FeeReportDto.createFromModel(nodeDetails.feeReport()),
|
||||
RebalanceReportDto.createFromModel(nodeDetails.rebalanceReport())
|
||||
RebalanceReportDto.createFromModel(nodeDetails.rebalanceReport()),
|
||||
nodeDetails.nodeWarnings().warnings()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package de.cotto.lndmanagej.controller.dto;
|
||||
|
||||
import de.cotto.lndmanagej.model.NodeWarning;
|
||||
import de.cotto.lndmanagej.model.NodeWarnings;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record NodeWarningsDto(List<NodeWarning> nodeWarnings) {
|
||||
public static NodeWarningsDto createFromModel(NodeWarnings nodeWarnings) {
|
||||
return new NodeWarningsDto(nodeWarnings.warnings());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user