Skip to content

Commit

Permalink
Modify routing API return value (#21164)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickmann authored Dec 11, 2024
1 parent 414b079 commit 161f282
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit 161f282

Please sign in to comment.