Skip to content

COBS-1891: Add Insights dashboard support - #1201

Merged
DO-rrao merged 4 commits into
digitalocean:mainfrom
adityasingh-beep:adityasingh/COBS-1891-add-Insights-dashboard-support-to-godo
Nov 4, 2026
Merged

DO-rrao merged 4 commits into
digitalocean:mainfrom
adityasingh-beep:adityasingh/COBS-1891-add-Insights-dashboard-support-to-godo

Conversation

@adityasingh-beep

@adityasingh-beep adityasingh-beep commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Jira: https://do-internal.atlassian.net/browse/COBS-1891 · OpenAPI: digitalocean/openapi#1298

Adds dashboard support to InsightsService: ListDashboards, GetDashboard, CreateDashboard, UpdateDashboard, DeleteDashboard, and GetDashboardSchema, following the existing ListResources / GetResource pattern.

Worth knowing

  • The API carries the dashboard definition as a JSON document encoded into a string. Rather than make every caller do that encoding (and risk double-encoding), Spec is a json.RawMessage holding the document itself, and godo converts to and from the string on the wire. An empty, invalid, or non-object spec is rejected client-side before any request goes out.
  • List uses pagination.* query params and returns a pagination object instead of links/meta, so this has its own DashboardListOptions rather than reusing *ListOptions. Without a Sort, results are newest first; with one, direction defaults to ascending.
  • Every success is 200, including create and delete. Unset fields like description are omitted.
  • The service stores spec in a JSON column, so reads come back with normalized key order and whitespace. godo doesn't reformat in either direction.

Testing

Unit tests cover every method plus the client-side spec validation, path escaping, and a JSON round trip. gofmt, go vet, go test ./... are clean.

I also extended examples/insights/smoke and ran it against staging (s2r1): schema and list on every run, and with INSIGHTS_SMOKE_WRITE=1 the full create → get → sorted list → duplicate (409) → update → delete → get (404) cycle. All green, and it cleans up after itself.

Not here

Dashboard error bodies are grpc-gateway shaped ("error" is a string), which ErrorResponse doesn't decode cleanly yet. Status codes and errors.As work fine; the fix is in the shared godo.go and will be a separate PR. CHANGELOG goes in the release PR per CONTRIBUTING.

Add dashboard CRUD and schema methods to InsightsService for the public
Insights dashboard endpoints served by insightssvc:

  ListDashboards     GET    /v2/insights/dashboards
  GetDashboard       GET    /v2/insights/dashboards/{uuid}
  CreateDashboard    POST   /v2/insights/dashboards
  UpdateDashboard    PUT    /v2/insights/dashboards/{uuid}
  DeleteDashboard    DELETE /v2/insights/dashboards/{uuid}
  GetDashboardSchema GET    /v2/insights/dashboards/schema

The API transports the dashboard spec as a JSON document serialized to
a string. Dashboard.Spec and DashboardRequest.Spec are json.RawMessage
so callers work with the document directly; MarshalJSON/UnmarshalJSON
convert to and from the wire string. DashboardRequest rejects an empty,
invalid, or already string-encoded spec before any request is sent.

Wire details follow the live grpc-gateway behaviour: every success is
200 (delete returns an empty object), zero-value fields are omitted,
list pagination uses pagination.* query parameters and returns a
pagination object rather than links/meta.

POST /v2/insights/dashboards/generate is intentionally not exposed; it
is not routed publicly.

Co-authored-by: Cursor <cursoragent@cursor.com>
@adityasingh-beep
adityasingh-beep marked this pull request as draft November 1, 2026 14:57
@adityasingh-beep
adityasingh-beep marked this pull request as ready for review November 2, 2026 06:59

@dmamidala-glitch dmamidala-glitch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tiny change

Comment thread insights.go Resolved
adityasingh-beep and others added 2 commits November 2, 2026 13:47
SortDirection is only applied when Sort is set, where it defaults to
ascending. Without a Sort the API orders by created_at descending and
ignores SortDirection. Also note that an unknown SortDirection is a 400.

Co-authored-by: Cursor <cursoragent@cursor.com>
Exercise GetDashboardSchema and ListDashboards on every run, and under
INSIGHTS_SMOKE_WRITE=1 create, get, list sorted by name, duplicate (409),
update, delete, and get after delete (404) a dashboard. The write gate for
dashboards no longer requires INSIGHTS_EMAIL, which only the channel and
alert rule writes need.

Specs are compared semantically: the API stores them in a JSON column and
returns them with normalized key order and whitespace.

Co-authored-by: Cursor <cursoragent@cursor.com>
@DO-rrao
DO-rrao merged commit 525e40d into digitalocean:main Nov 4, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

⌂ 换网址