feat(cases)!: add timeline and restructure comments as a subgroup#510
Open
avidal wants to merge 1 commit into
Open
feat(cases)!: add timeline and restructure comments as a subgroup#510avidal wants to merge 1 commit into
avidal wants to merge 1 commit into
Conversation
Adds `pup cases timeline <case-id>` for the full activity feed
(comments, attribute updates, status transitions) and reorganizes
comment ops into a noun-subgroup that aligns with the existing
`projects` precedent:
pup cases comments list <case-id>
pup cases comments get <case-id> --comment-id <id>
pup cases comments create <case-id> --body "..."
pup cases comments update <case-id> --comment-id <id> --body "..."
pup cases comments delete <case-id> --comment-id <id>
`list` and `get` derive from `GET /api/v2/cases/{id}/timelines` by
filtering for `COMMENT` cells. `update` calls
`PUT /api/v2/cases/{id}/comment/{cell_id}` — both endpoints are
absent from the public OpenAPI spec at this revision, so they use
raw HTTP. PUT responds 200 with an empty body, so the update path
uses `raw_request` rather than `raw_put` (which expects JSON).
BREAKING: `pup cases comment` → `pup cases comments create`,
`pup cases delete-comment` → `pup cases comments delete`. Both
shipped in v0.62.0 (yesterday); replacing rather than aliasing
because the tool is alpha and consistency with the rest of the
CLI surface wins over preserving a one-day-old surface.
Test coverage adds 7 cases tests: timeline happy path, comments
list filtering on cell type, comments get found / not-found /
non-COMMENT cell with shared id, and comments create/update/delete.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| } | ||
|
|
||
| // --------------------------------------------------------------------------- | ||
| // Timeline (uses raw HTTP — the DD API client doesn't expose this endpoint |
Collaborator
There was a problem hiding this comment.
Should we add it to the spec internally?
Contributor
Author
There was a problem hiding this comment.
Isn't that usually up to the team that owns the API? I'll flag it with them (they were the ones that told me it existed in the first place, as well as PUT on a comment)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
pup cases timeline <case-id>for the full case activity feed (comments, attribute updates, status transitions, etc.) and reorganizes the comment operations into a noun-subgroup that aligns with the existingprojectsprecedent.New surface:
Why
The previous flat
pup cases comment/pup cases delete-comment(shipped in v0.62.0) was inconsistent with the rest of pup: every other domain uses noun-subgroups for nested resources (pup cases projects {list,get,...},pup incidents attachments {list,...},pup synthetics tests {list,...}). The flat shape also made it impossible to grow naturally — there was no clean home forlist,get, orupdate. Folding everything undercomments {action}gets a uniform surface and unlocks read/edit operations that previously couldn't be expressed.timelinelives at the top level rather than under a subgroup because it has a single verb. If the API later grows additional timeline operations (e.g. posting custom cells), this can be refactored without breaking anything since timeline-cell ops aren't user-facing today.Implementation notes
listandgetderive fromGET /api/v2/cases/{id}/timelinesby filtering for cells whereattributes.type == "COMMENT". The endpoint is not in the public OpenAPI spec at this revision, so the calls useclient::raw_getrather than the typeddatadog-api-clientSDK. TheTimelineResponsemodel exists in the SDK (comment_casereturns it) but noget_timelineoperation is generated.updatecallsPUT /api/v2/cases/{id}/comment/{cell_id}— also undocumented; team confirmed it exists. PUT responds 200 with empty body on success, so the update path usesclient::raw_requestrather thanraw_put(which expects parseable JSON). Function prints a success message in the style ofcomments delete.createanddeletecontinue to use the typed SDK (comment_case/delete_case_comment).Breaking changes
pup cases comment→pup cases comments createpup cases delete-comment→pup cases comments deleteThese shipped in #504 / v0.62.0 (yesterday). Replacing rather than aliasing because the tool is alpha and uniformity with the rest of the CLI surface wins over preserving a one-day-old surface.
Test plan
cargo fmt --checkcleancargo clippy -- -D warningscleancargo test --bin pup -- --test-threads=1— 1149 passedsrc/commands/cases.rs:test_cases_timeline(happy path)test_cases_comments_list_filters_to_comment_cells(mixed-cell timeline → only COMMENT cells returned, plus direct assertion on the filter helper)test_cases_comments_get_foundtest_cases_comments_get_not_found(missing id → error mentions "not found")test_cases_comments_get_skips_non_comment_cell_with_same_id(defensive: non-COMMENT cell sharing an id is not returned)test_cases_comments_create/test_cases_comments_update/test_cases_comments_deleteagents/case-management.md(removed obsolete "no list-comments endpoint" caveat, added timeline section, refreshed best practices) andagents/incident-response.md(two example commands updated to the new surface)Pre-existing test flake
cargo test(default parallel execution) intermittently fails three tests unrelated to this PR:commands::monitors::tests::test_monitors_list_emptycommands::monitors::tests::test_monitors_list_with_resultscommands::tags::tests::test_tags_deleteAll three are in files this PR does not touch. They race on
PUP_MOCK_SERVERenv-var cleanup — the existinglock_env()helper serializes the function bodies butcleanup_env()runs outside the guard scope, so a concurrent test can read a stale env var pointing athttp://unused.localand fail DNS resolution. The three failing tests all pass in isolation and under--test-threads=1. Worth filing as a follow-up — fix is to makecleanup_env()part of the guard's Drop, or use a per-test mock-server env shadow rather than a process-wide one.🤖 Generated with Claude Code