From 72d2649cabb764d600499b382e47ad57c87bbe8b Mon Sep 17 00:00:00 2001 From: Pablo Lacerda de Miranda Date: Fri, 23 Feb 2018 15:02:13 -0800 Subject: [PATCH] adds a batch API to fetch workflows based on a correlation id list --- .../server/resources/WorkflowResource.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/jersey/src/main/java/com/netflix/conductor/server/resources/WorkflowResource.java b/jersey/src/main/java/com/netflix/conductor/server/resources/WorkflowResource.java index 20060935e8..2c53cb1858 100644 --- a/jersey/src/main/java/com/netflix/conductor/server/resources/WorkflowResource.java +++ b/jersey/src/main/java/com/netflix/conductor/server/resources/WorkflowResource.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -117,6 +118,21 @@ public List getWorkflows(@PathParam("name") String name, @PathParam("c @QueryParam("includeTasks") @DefaultValue("false") boolean includeTasks) throws Exception { return service.getWorkflowInstances(name, correlationId, includeClosed, includeTasks); } + + @POST + @Path("/{name}/correlated") + @ApiOperation("Lists workflows for the given correlation id list") + @Consumes(MediaType.WILDCARD) + public Map> getWorkflows(@PathParam("name") String name, + @QueryParam("includeClosed") @DefaultValue("false") boolean includeClosed, + @QueryParam("includeTasks") @DefaultValue("false") boolean includeTasks, List correlationIds) throws Exception { + Map> workflows = new HashMap<>(); + for(String correlationId : correlationIds) { + List ws = service.getWorkflowInstances(name, correlationId, includeClosed, includeTasks); + workflows.put(correlationId, ws); + } + return workflows; + } @GET @Path("/{workflowId}")