From d65bbc53e47dff70597af437e26efc830d272838 Mon Sep 17 00:00:00 2001 From: Othello Maurer Date: Thu, 8 Sep 2022 14:14:48 +0200 Subject: [PATCH] Add "tags" field to DTOs (#13367) --- .../graylog/plugins/sidecar/rest/models/NodeDetails.java | 9 +++++++-- .../graylog/plugins/sidecar/services/SidecarService.java | 9 ++++++--- .../sidecar/collectors/SidecarServiceImplTest.java | 1 + .../sidecar/collectors/rest/SidecarResourceTest.java | 4 ++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/graylog2-server/src/main/java/org/graylog/plugins/sidecar/rest/models/NodeDetails.java b/graylog2-server/src/main/java/org/graylog/plugins/sidecar/rest/models/NodeDetails.java index 202825c47d71..096a1cd1bbd0 100644 --- a/graylog2-server/src/main/java/org/graylog/plugins/sidecar/rest/models/NodeDetails.java +++ b/graylog2-server/src/main/java/org/graylog/plugins/sidecar/rest/models/NodeDetails.java @@ -50,12 +50,17 @@ public abstract class NodeDetails { @Nullable public abstract CollectorStatusList statusList(); + @JsonProperty("tags") + @Nullable + public abstract List tags(); + @JsonCreator public static NodeDetails create(@JsonProperty("operating_system") String operatingSystem, @JsonProperty("ip") @Nullable String ip, @JsonProperty("metrics") @Nullable NodeMetrics metrics, @JsonProperty("log_file_list") @Nullable List logFileList, - @JsonProperty("status") @Nullable CollectorStatusList statusList) { - return new AutoValue_NodeDetails(operatingSystem, ip, metrics, logFileList, statusList); + @JsonProperty("status") @Nullable CollectorStatusList statusList, + @JsonProperty("tags") @Nullable List tags) { + return new AutoValue_NodeDetails(operatingSystem, ip, metrics, logFileList, statusList, tags); } } diff --git a/graylog2-server/src/main/java/org/graylog/plugins/sidecar/services/SidecarService.java b/graylog2-server/src/main/java/org/graylog/plugins/sidecar/services/SidecarService.java index 5646225fdbd3..080e5b68238a 100644 --- a/graylog2-server/src/main/java/org/graylog/plugins/sidecar/services/SidecarService.java +++ b/graylog2-server/src/main/java/org/graylog/plugins/sidecar/services/SidecarService.java @@ -89,8 +89,9 @@ public Sidecar save(Sidecar sidecar) { } else { throw new IllegalArgumentException("Specified object failed validation: " + violations); } - } else + } else { throw new IllegalArgumentException("Specified object is not of correct implementation type (" + sidecar.getClass() + ")!"); + } } public List all() { @@ -168,7 +169,8 @@ public int markExpired(Period period, String message) { nodeDetails.ip(), nodeDetails.metrics(), nodeDetails.logFileList(), - statusListToSave); + statusListToSave, + nodeDetails.tags()); Sidecar toSave = collector.toBuilder() .nodeDetails(nodeDetailsToSave) @@ -194,7 +196,8 @@ public Sidecar fromRequest(String nodeId, RegistrationRequest request, String co request.nodeDetails().ip(), request.nodeDetails().metrics(), request.nodeDetails().logFileList(), - request.nodeDetails().statusList()), + request.nodeDetails().statusList(), + request.nodeDetails().tags()), collectorVersion); } diff --git a/graylog2-server/src/test/java/org/graylog/plugins/sidecar/collectors/SidecarServiceImplTest.java b/graylog2-server/src/test/java/org/graylog/plugins/sidecar/collectors/SidecarServiceImplTest.java index 26f54bca730a..d4357f2dd674 100644 --- a/graylog2-server/src/test/java/org/graylog/plugins/sidecar/collectors/SidecarServiceImplTest.java +++ b/graylog2-server/src/test/java/org/graylog/plugins/sidecar/collectors/SidecarServiceImplTest.java @@ -95,6 +95,7 @@ public void testSaveFirstRecord() throws Exception { null, null, null, + null, null), version ); diff --git a/graylog2-server/src/test/java/org/graylog/plugins/sidecar/collectors/rest/SidecarResourceTest.java b/graylog2-server/src/test/java/org/graylog/plugins/sidecar/collectors/rest/SidecarResourceTest.java index 89d0ea731b45..0e8f8076b954 100644 --- a/graylog2-server/src/test/java/org/graylog/plugins/sidecar/collectors/rest/SidecarResourceTest.java +++ b/graylog2-server/src/test/java/org/graylog/plugins/sidecar/collectors/rest/SidecarResourceTest.java @@ -125,6 +125,7 @@ public void testRegister() throws Exception { null, null, null, + null, null ) ); @@ -144,6 +145,7 @@ public void testRegisterInvalidCollectorId() throws Exception { null, null, null, + null, null ) ); @@ -164,6 +166,7 @@ public void testRegisterInvalidNodeId() throws Exception { null, null, null, + null, null ) ); @@ -198,6 +201,7 @@ public void testRegisterMissingOperatingSystem() throws Exception { null, null, null, + null, null ) );