feat(dashboards): granular widget editing + schema discovery + saved-widgets rename#584
Draft
platinummonkey wants to merge 5 commits into
Draft
feat(dashboards): granular widget editing + schema discovery + saved-widgets rename#584platinummonkey wants to merge 5 commits into
platinummonkey wants to merge 5 commits into
Conversation
…scovery
Adds `pup dashboards widgets <list|get|add|update|remove|types|schema>` for
editing individual widgets within a dashboard, replacing the need to
round-trip the entire dashboard JSON.
Widget editing uses a safe fetch → mutate → PUT flow (the Datadog Dashboard
API has no per-widget PATCH endpoint). The SDK losslessly round-trips
unknown fields via `additional_properties`, so untouched widgets are
preserved. Widget input is validated by detecting `WidgetDefinition::UnparsedObject`
— the only validation gate available without importing private SDK internals.
Widget schema discovery emits either a ready-to-edit skeleton JSON (for 8
high-traffic types: timeseries, query_value, query_table, toplist, note,
free_text, heatmap, slo) or a minimal `{"definition":{"type":"<type>"}}`
fallback for the other ~26 known types.
The existing `pup dashboards widgets` saved/reporting widgets (V2 API) are
promoted to a new top-level `pup widgets` command, freeing the natural
`dashboards widgets` path for embedded-widget editing.
Files changed:
- src/commands/dashboards.rs: helpers, 7 widget commands, static type
registry + templates, 22 new co-located tests
- src/main.rs: DashboardWidgetActions enum, Commands::Widgets top-level
variant, routing changes
- src/test_commands.rs: 13 new integration tests covering clap parsing,
mutual-exclusion, and read-only classification
Environment: Datadog workspace
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…dgets` Rename the Commands::Widgets variant to Commands::SavedWidgets with #[command(name = "saved-widgets")] so the top-level saved/reporting widgets command is invoked as `pup saved-widgets` instead of `pup widgets`. Also repositions the variant alphabetically (after Runbooks, before Scorecards). Updates routing arm and tests accordingly. Environment: Datadog workspace Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
`pup dashboards widgets types` now returns objects with `type` and
`description` fields sourced from the Datadog OpenAPI spec (v1).
`pup dashboards widgets schema <type>` now returns a wrapper object
with `type`, `description`, and `template` fields so callers see
what the widget does alongside the ready-to-edit JSON skeleton.
- WIDGET_TYPES changed from &[&str] to &[(&str, &str)] (type, description)
- widget_types() emits [{type, description}] objects instead of plain strings
- widget_schema() wraps the template in {type, description, template}
Environment: Datadog workspace
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
`pup dashboards widgets schema <type>` now outputs a `schema` field
alongside the existing `template`. The schema is a JSON Schema document
derived from the Datadog OpenAPI spec (v1/dashboard.yaml) covering all
34 widget types. Each type documents its required fields, optional
properties, types, enum values, and descriptions for every field
including nested objects (requests, style, view, layout, etc.).
Output shape: {type, description, schema: {type, required, properties:
{id, layout: {x,y,width,height}, definition: <type-specific schema>}},
template: <minimal ready-to-edit JSON>}
Environment: Datadog workspace
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Run cargo fmt to fix formatting in dashboards.rs and test_commands.rs. Environment: Datadog workspace Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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 dashboards widgets <list|get|add|update|remove|types|schema>for editing individual widgets within a dashboard without round-tripping the entire dashboard JSON. Also renames the unrelated top-level saved/reporting widgets command frompup widgetstopup saved-widgetsto free the naturaldashboards widgetspath, and enriches bothwidgets typesandwidgets schemawith descriptions and full JSON Schemas sourced from the Datadog OpenAPI spec.Changes
src/commands/dashboards.rs— 7 new widget commands (widget_list,widget_get,widget_add,widget_update,widget_remove,widget_types,widget_schema),widget_json_schema(full JSON Schema for all 34 widget types from OpenAPI spec),WIDGET_TYPESas&[(&str, &str)]tuples with descriptions,widget_template(ready-to-edit skeletons),read_widget_input,validate_widget,locate_widget_indexhelpers, 22 co-located unit testssrc/main.rs—DashboardWidgetActionsenum withList/Get/Add/Update/Remove/Types/Schemasubcommands;Commands::SavedWidgets(renamed fromCommands::Widgets, repositioned alphabetically afterRunbooks); routing wired to new dashboard widget functionssrc/test_commands.rs— 13 new clap-parsing integration tests covering alldashboards widgetssubcommands, mutual-exclusion of--widget-id/--index, read-only classification oflist/get/types/schema, and renamedsaved-widgetscommandKey design decisions
additional_propertiesso untouched widgets are preserved.WidgetDefinition::UnparsedObjectvalidation gate: A successfulserde_json::from_slice::<Widget>does not mean valid — the untagged enum silently falls through toUnparsedObjectfor unknown types.validate_widgetrejects these before any PUT.--widget-id(API-assigned integer id) or--index(0-based position). Exactly one required via clapconflicts_with+required_unless_present.pup saved-widgetsrename: Freespup dashboards widgetsfor embedded widgets. No backward-compat alias (the two concepts are unrelated).widget_json_schemacovers all 34 types with field types, enum values, required arrays, and descriptions fromspec/v1/dashboard.yaml.Testing
cargo testpasses (22 new dashboards unit tests + 13 new integration tests; 5 pre-existing failures in unrelated modules are unchanged)cargo clippy -- -D warningscleancargo fmt --checkclean🤖 Generated with Claude Code