Expose REST API endpoint to list workflow run events#1753
Conversation
9f60d1d to
72b0f50
Compare
There was a problem hiding this comment.
Pull request overview
This PR exposes a new REST API endpoint to list workflow run events (history). It refactors the internal API to return WorkflowRunHistoryEntry objects (which include both sequence numbers and events) rather than just WorkflowEvent objects, and adds support for sorting, pagination, and polling via a from_sequence_number parameter.
Changes:
- Added REST API endpoint
/workflow-runs/{id}/eventswith support for pagination, sorting (ASC/DESC), and continuous polling viafrom_sequence_number - Refactored
WorkflowRunHistoryEntryfrom internal persistence model to public API class, exposing sequence numbers alongside events - Enhanced
listRunHistoryto support descending order and filtering from a specific sequence number - Updated all existing tests to use the new
listRunHistoryAPI returningWorkflowRunHistoryEntryinstead of justWorkflowEvent
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| api/src/main/openapi/openapi.yaml | Added route definition for new events endpoint |
| api/src/main/openapi/paths/workflow-runs__id__events.yaml | OpenAPI specification for listing workflow run events with pagination and sorting |
| api/src/main/openapi/components/schemas/list-workflow-run-events-response.yaml | Response schema for events list |
| api/src/main/openapi/components/schemas/list-workflow-run-events-response-item.yaml | Schema for individual event items with sequence numbers |
| apiserver/src/main/java/org/dependencytrack/resources/v2/ResourceConfig.java | Registered ObjectMapper for dependency injection |
| apiserver/src/main/java/org/dependencytrack/resources/v2/WorkflowsResource.java | Implemented REST endpoint handler with protobuf-to-JSON conversion |
| apiserver/src/test/java/org/dependencytrack/resources/v2/WorkflowsResourceTest.java | Added basic test for new endpoint |
| dex/engine-api/src/main/java/org/dependencytrack/dex/engine/api/DexEngine.java | Updated interface signature from listRunEvents to listRunHistory |
| dex/engine-api/src/main/java/org/dependencytrack/dex/engine/api/WorkflowRunHistoryEntry.java | Moved from persistence layer to API layer, removed workflowRunId field |
| dex/engine-api/src/main/java/org/dependencytrack/dex/engine/api/request/ListWorkflowRunEventsRequest.java | Removed old request class |
| dex/engine-api/src/main/java/org/dependencytrack/dex/engine/api/request/ListWorkflowRunHistoryRequest.java | New request class with support for fromSequenceNumber and sortDirection |
| dex/engine/src/main/java/org/dependencytrack/dex/engine/DexEngineImpl.java | Updated to use new API, converting history entries to events internally where needed |
| dex/engine/src/main/java/org/dependencytrack/dex/engine/persistence/WorkflowRunDao.java | Enhanced SQL query with FreeMarker template for DESC sorting and fromSequenceNumber filtering |
| dex/engine/src/main/java/org/dependencytrack/dex/engine/persistence/jdbi/JdbiFactory.java | Updated import from persistence model to API |
| dex/engine/src/main/java/org/dependencytrack/dex/engine/persistence/jdbi/WorkflowRunHistoryEntryRowMapper.java | Updated to map to API class, removed workflowRunId mapping |
| dex/engine/src/test/java/org/dependencytrack/dex/engine/DexEngineImplTest.java | Updated all tests to use listRunHistory API and added comprehensive tests for pagination, DESC ordering, and fromSequenceNumber |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
72b0f50 to
de57054
Compare
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0dd638d to
85f51d4
Compare
Signed-off-by: nscuro <nscuro@protonmail.com>
85f51d4 to
7d59856
Compare
Description
Exposes REST API endpoint to list workflow run events.
Addressed Issue
N/A
Additional Details
N/A
Checklist
This PR fixes a defect, and I have provided tests to verify that the fix is effectiveThis PR introduces changes to the database model, and I have updated the migration changelog accordinglyThis PR introduces new or alters existing behavior, and I have updated the documentation accordingly