Skip to content

Commit

Permalink
Added endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Shailesh Jagannath Padave committed Nov 18, 2024
1 parent c29b2b4 commit d9b623b
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.util.List;

import com.netflix.conductor.model.WorkflowModel;
import org.springframework.validation.annotation.Validated;

import com.netflix.conductor.common.model.BulkResponse;
Expand Down Expand Up @@ -86,4 +87,13 @@ BulkResponse<String> terminateRemove(
List<String> workflowIds,
String reason,
boolean archiveWorkflow);

BulkResponse<WorkflowModel> searchWorkflow(
@NotEmpty(message = "WorkflowIds list cannot be null.")
@Size(
max = MAX_REQUEST_ITEMS,
message =
"Cannot process more than {max} workflows. Please use multiple requests.")
List<String> workflowIds,
boolean includeTasks);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.util.List;

import com.netflix.conductor.model.WorkflowModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -43,7 +44,7 @@ public WorkflowBulkServiceImpl(
*
* @param workflowIds - list of workflow Ids to perform pause operation on
* @return bulk response object containing a list of succeeded workflows and a list of failed
* ones with errors
* ones with errors
*/
public BulkResponse<String> pauseWorkflow(List<String> workflowIds) {

Expand All @@ -70,7 +71,7 @@ public BulkResponse<String> pauseWorkflow(List<String> workflowIds) {
*
* @param workflowIds - list of workflow Ids to perform resume operation on
* @return bulk response object containing a list of succeeded workflows and a list of failed
* ones with errors
* ones with errors
*/
public BulkResponse<String> resumeWorkflow(List<String> workflowIds) {
BulkResponse<String> bulkResponse = new BulkResponse<>();
Expand All @@ -93,10 +94,10 @@ public BulkResponse<String> resumeWorkflow(List<String> workflowIds) {
/**
* Restart the list of workflows.
*
* @param workflowIds - list of workflow Ids to perform restart operation on
* @param workflowIds - list of workflow Ids to perform restart operation on
* @param useLatestDefinitions if true, use latest workflow and task definitions upon restart
* @return bulk response object containing a list of succeeded workflows and a list of failed
* ones with errors
* ones with errors
*/
public BulkResponse<String> restart(List<String> workflowIds, boolean useLatestDefinitions) {
BulkResponse<String> bulkResponse = new BulkResponse<>();
Expand All @@ -121,7 +122,7 @@ public BulkResponse<String> restart(List<String> workflowIds, boolean useLatestD
*
* @param workflowIds - list of workflow Ids to perform retry operation on
* @return bulk response object containing a list of succeeded workflows and a list of failed
* ones with errors
* ones with errors
*/
public BulkResponse<String> retry(List<String> workflowIds) {
BulkResponse<String> bulkResponse = new BulkResponse<>();
Expand All @@ -145,10 +146,10 @@ public BulkResponse<String> retry(List<String> workflowIds) {
* Terminate workflows execution.
*
* @param workflowIds - list of workflow Ids to perform terminate operation on
* @param reason - description to be specified for the terminated workflow for future
* references.
* @param reason - description to be specified for the terminated workflow for future
* references.
* @return bulk response object containing a list of succeeded workflows and a list of failed
* ones with errors
* ones with errors
*/
public BulkResponse<String> terminate(List<String> workflowIds, String reason) {
BulkResponse<String> bulkResponse = new BulkResponse<>();
Expand All @@ -171,7 +172,7 @@ public BulkResponse<String> terminate(List<String> workflowIds, String reason) {
/**
* Removes a list of workflows from the system.
*
* @param workflowIds List of WorkflowIDs of the workflows you want to remove from system.
* @param workflowIds List of WorkflowIDs of the workflows you want to remove from system.
* @param archiveWorkflow Archives the workflow and associated tasks instead of removing them.
*/
public BulkResponse<String> deleteWorkflow(List<String> workflowIds, boolean archiveWorkflow) {
Expand All @@ -197,11 +198,11 @@ public BulkResponse<String> deleteWorkflow(List<String> workflowIds, boolean arc
/**
* Terminates execution for workflows in a list, then removes each workflow.
*
* @param workflowIds List of workflow IDs to terminate and delete.
* @param reason Reason for terminating the workflow.
* @param workflowIds List of workflow IDs to terminate and delete.
* @param reason Reason for terminating the workflow.
* @param archiveWorkflow Archives the workflow and associated tasks instead of removing them.
* @return bulk response object containing a list of succeeded workflows and a list of failed
* ones with errors
* ones with errors
*/
public BulkResponse<String> terminateRemove(
List<String> workflowIds, String reason, boolean archiveWorkflow) {
Expand Down Expand Up @@ -233,4 +234,32 @@ public BulkResponse<String> terminateRemove(
}
return bulkResponse;
}

/**
* Fetch workflow details for given workflowIds.
*
* @param workflowIds List of workflow IDs to terminate and delete.
* @param includeTasks includes tasks from workflow
* @return bulk response object containing a list of workflow details
*/
@Override
public BulkResponse<WorkflowModel> searchWorkflow(List<String> workflowIds, boolean includeTasks) {
BulkResponse<WorkflowModel> bulkResponse = new BulkResponse<>();
for (String workflowId : workflowIds) {
try {
WorkflowModel workflowModel = workflowExecutor.getWorkflow(workflowId, includeTasks);
bulkResponse.appendSuccessResponse(workflowModel);
} catch (Exception e) {
LOGGER.error(
"bulk search exception, workflowId {}, message: {} ",
workflowId,
e.getMessage(),
e);
bulkResponse.appendFailedResponse(workflowId, e.getMessage());
}
}
return bulkResponse;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.util.List;

import com.netflix.conductor.model.WorkflowModel;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
Expand Down Expand Up @@ -141,4 +142,18 @@ public BulkResponse<String> terminateRemove(
@RequestParam(value = "reason", required = false) String reason) {
return workflowBulkService.terminateRemove(workflowIds, reason, archiveWorkflow);
}

/**
* Search workflows for given list of workflows.
*
* @param workflowIds - list of workflow Ids to be searched
* @return bulk response object containing a list of workflows
*/
@PostMapping("/search")
public BulkResponse<WorkflowModel> searchWorkflow(
@RequestBody List<String> workflowIds,
@RequestParam(value = "includeTasks", defaultValue = "true", required = false)
boolean includeTasks) {
return workflowBulkService.searchWorkflow(workflowIds, includeTasks);
}
}

0 comments on commit d9b623b

Please sign in to comment.