feat: 新增工作流相关接口 by tcsp · Pull Request #124 · coze-dev/coze-java
Walkthrough
Adds workflow listing and retrieval: new Retrofit WorkflowAPI, request/response DTOs and models, integrates WorkflowAPI into WorkflowService and CozeAPI builder, bumps artifact to 0.4.3, and adds unit tests for WorkflowService list/get.
Changes
| Cohort / File(s) | Summary |
|---|---|
Version bumpapi/pom.xml |
Update artifact version from 0.4.2 to 0.4.3. |
Workflow Retrofit APIapi/src/main/java/com/coze/openapi/api/WorkflowAPI.java |
New Retrofit interface exposing GET /v1/workflows (list) and GET /v1/workflows/{workflow_id} (get). |
Workflow requestsapi/src/main/java/com/coze/openapi/client/workflows/WorkflowListReq.java, api/src/main/java/com/coze/openapi/client/workflows/WorkflowGetReq.java |
New request DTOs extending BaseReq with Jackson mappings and Lombok builders/constructors. |
Workflow responsesapi/src/main/java/com/coze/openapi/client/workflows/WorkflowListResp.java, api/src/main/java/com/coze/openapi/client/workflows/WorkflowGetResp.java |
New response DTOs for list/get with Jackson mappings and Lombok-generated boilerplate. |
Workflow modelsapi/src/main/java/com/coze/openapi/client/workflows/model/WorkflowDetail.java, .../WorkflowCreator.java, .../WorkflowInput.java, .../WorkflowOutput.java, .../WorkflowParameter.java |
New model classes for workflow detail, creator, input/output schemas, and parameter metadata. |
Service wiringapi/src/main/java/com/coze/openapi/service/service/CozeAPI.java, api/src/main/java/com/coze/openapi/service/service/workflow/WorkflowService.java |
CozeAPI.Builder.build now creates WorkflowAPI; WorkflowService constructor updated to accept WorkflowAPI and adds list and get methods delegating to Retrofit calls. |
Unit testsapi/src/test/java/com/coze/openapi/service/service/workflow/WorkFlowServiceTest.java |
New tests mocking WorkflowAPI calls and asserting WorkflowService.list and WorkflowService.get behaviors. |
Sequence Diagram(s)
sequenceDiagram
autonumber
actor Client
participant WorkflowService
participant WorkflowAPI as Retrofit:WorkflowAPI
participant Server as HTTP
Client->>WorkflowService: list(WorkflowListReq)
WorkflowService->>WorkflowAPI: list(workspace_id, page_num, page_size, workflow_mode, app_id, publish_status, BaseReq)
WorkflowAPI->>Server: GET /v1/workflows?...
Server-->>WorkflowAPI: 200 BaseResponse<WorkflowListResp>
WorkflowAPI-->>WorkflowService: Response<BaseResponse<...>>
WorkflowService-->>Client: BaseResponse<WorkflowListResp>
alt get workflow
Client->>WorkflowService: get(WorkflowGetReq)
WorkflowService->>WorkflowAPI: get(workflow_id, include_input_output, BaseReq)
WorkflowAPI->>Server: GET /v1/workflows/{workflow_id}?include_input_output=...
Server-->>WorkflowAPI: 200 BaseResponse<WorkflowGetResp>
WorkflowAPI-->>WorkflowService: Response<BaseResponse<...>>
WorkflowService-->>Client: BaseResponse<WorkflowGetResp>
end
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
- chore: Bump version to 0.3.0 #66 — related version bump in
api/pom.xml. - feat: Enhance SDK with new features, improve documentation, and transition to Maven #7 — touches
CozeAPIbuilder/initialization logic similar to this change.
Suggested labels
feature
Poem
I hop through code with eager paws,
New endpoints stitched in tidy laws.
List and get now dance in place,
Retrofit hums a steady pace.
Tests applaud — I thump with glee! 🐇✨
📜 Recent review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
api/src/test/java/com/coze/openapi/service/service/workflow/WorkFlowServiceTest.java(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- api/src/test/java/com/coze/openapi/service/service/workflow/WorkFlowServiceTest.java
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: test (Java 17 on Windows)
- GitHub Check: test (Java 11 on macOS)
✨ Finishing Touches
- 📝 Generate Docstrings
🧪 Generate unit tests
- Create PR with unit tests
- Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.