From 161f2828f541f46c11716c6da5677b27f86217bf Mon Sep 17 00:00:00 2001 From: Patrick Mann Date: Wed, 11 Dec 2024 17:21:08 +0100 Subject: [PATCH] Modify routing API return value (#21164) --- .../pipelineprocessor/rest/PipelineResource.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/graylog2-server/src/main/java/org/graylog/plugins/pipelineprocessor/rest/PipelineResource.java b/graylog2-server/src/main/java/org/graylog/plugins/pipelineprocessor/rest/PipelineResource.java index a825d28894ae..289ad20483fb 100644 --- a/graylog2-server/src/main/java/org/graylog/plugins/pipelineprocessor/rest/PipelineResource.java +++ b/graylog2-server/src/main/java/org/graylog/plugins/pipelineprocessor/rest/PipelineResource.java @@ -277,11 +277,14 @@ public record RoutingRequest( @Nullable @JsonProperty(value = "remove_from_default") Boolean removeFromDefault ) {} + public record RoutingResponse(@JsonProperty(value = "rule_id") String ruleId) {} + @ApiOperation(value = "Add a stream routing rule to the default routing pipeline.") + @Produces(MediaType.APPLICATION_JSON) @Path("/routing") @PUT @AuditEvent(type = PipelineProcessorAuditEventTypes.PIPELINE_UPDATE) - public PipelineSource routing(@ApiParam(name = "body", required = true) @NotNull RoutingRequest request) throws NotFoundException { + public RoutingResponse routing(@ApiParam(name = "body", required = true) @NotNull RoutingRequest request) throws NotFoundException { checkPermission(RestPermissions.STREAMS_EDIT, request.streamId()); checkPermission(PipelineRestPermissions.PIPELINE_RULE_CREATE); @@ -304,7 +307,8 @@ public PipelineSource routing(@ApiParam(name = "body", required = true) @NotNull ensurePipelineConnection(pipelineDao.id(), DEFAULT_STREAM_ID); } catch (NotFoundException e) { // Create pipeline with first rule - return createRoutingPipeline(ruleDao); + createRoutingPipeline(ruleDao); + return new RoutingResponse(ruleDao.id()); } // Add rule to existing pipeline @@ -320,7 +324,7 @@ public PipelineSource routing(@ApiParam(name = "body", required = true) @NotNull log.info(f("Routing for input <%s> already exists - skipping", request.inputId())); } - return pipelineSource; + return new RoutingResponse(ruleDao.id()); } private PipelineSource createRoutingPipeline(RuleDao ruleDao) {