Skip to content

Commit bad2b9a

Browse files
authored
Merge pull request #39 from axiomhq/aisha/edge-auto-resolve
feat: use v2 dashboard apis
2 parents 51db1e6 + 2143631 commit bad2b9a

File tree

15 files changed

+50
-40
lines changed

15 files changed

+50
-40
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ org_id = "your-staging-org-id"
5050
```
5151

5252
**To get these values:**
53-
1. **org_id**: Settings → Organization → Copy the org ID (or from URL: `app.axiom.co/{org_id}/...`)
54-
2. **token**: Settings → Profile → Personal Access Tokens → Create token (use a Personal Access Token, not an API token, for full query access)
53+
- **`org_id`** - The organization ID. Get it from Settings → Organization.
54+
- **`token`** - Use an advanced API token with minimal privileges.
5555

5656
The deployment name (e.g., `prod`, `staging`) is passed to scripts: `scripts/axiom-query prod "..."`
5757

skills/building-dashboards/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ token = "xaat-your-api-token"
3434
org_id = "your-org-id"
3535
```
3636

37-
Get your org_id from Settings → Organization. For the token, use a **Personal Access Token** (Settings → Profile → Personal Access Tokens) for full query access.
37+
- **`org_id`** - The organization ID. Get it from Settings → Organization.
38+
- **`token`** - Use an advanced API token with minimal privileges.
3839

3940
**Tip:** Run `scripts/setup` from the `axiom-sre` skill for interactive configuration.
4041

skills/building-dashboards/scripts/axiom-api

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
# Reads credentials from ~/.axiom.toml (shared with axiom-sre)
77
#
88
# Examples:
9-
# axiom-api prod GET /internal/dashboards
10-
# axiom-api prod GET /internal/dashboards/abc123
11-
# axiom-api prod POST /internal/dashboards '{"name":"Test",...}'
12-
# axiom-api prod GET /v2/user
9+
# axiom-api prod GET /dashboards
10+
# axiom-api prod GET /dashboards/abc123
11+
# axiom-api prod POST /dashboards '{"name":"Test",...}'
12+
# axiom-api prod GET /user
1313

1414
set -euo pipefail
1515

@@ -59,8 +59,7 @@ if [[ -z "$URL" || -z "$TOKEN" || -z "$ORG_ID" ]]; then
5959
exit 1
6060
fi
6161

62-
# Dashboard API uses app.* instead of api.*
63-
API_URL="${URL/api./app.}/api"
62+
API_URL="${URL%/}/v2"
6463

6564
CURL_ARGS=(
6665
-s

skills/building-dashboards/scripts/dashboard-copy

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,26 @@ if [[ -z "$DEPLOYMENT" || -z "$ID" ]]; then
2121
fi
2222

2323
# Fetch original
24-
ORIGINAL=$("$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" GET "/internal/dashboards/$ID")
24+
ORIGINAL=$("$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" GET "/dashboards/uid/$ID")
2525

2626
# Get original name if new name not provided
2727
if [[ -z "$NEW_NAME" ]]; then
28-
ORIG_NAME=$(echo "$ORIGINAL" | jq -r '.name')
28+
ORIG_NAME=$(echo "$ORIGINAL" | jq -r '.dashboard.name')
2929
NEW_NAME="${ORIG_NAME} (copy)"
3030
fi
3131

32-
# Strip server fields and set new name
32+
# Strip server fields and set new name on the dashboard subobject
3333
BODY=$(echo "$ORIGINAL" | jq --arg name "$NEW_NAME" '
34-
del(.id, .version, .createdAt, .updatedAt, .createdBy, .updatedBy) |
34+
.dashboard |
35+
del(.id, .uid, .version, .createdAt, .updatedAt, .createdBy, .updatedBy) |
3536
.name = $name
36-
')
37+
' | jq '{dashboard: .}')
3738

38-
RESPONSE=$("$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" POST "/internal/dashboards" "$BODY")
39+
RESPONSE=$("$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" POST "/dashboards" "$BODY")
3940

40-
# Print new ID and name
41-
ID=$(echo "$RESPONSE" | jq -r '.id // empty')
42-
NAME=$(echo "$RESPONSE" | jq -r '.name // empty')
41+
# Print new UID and name
42+
ID=$(echo "$RESPONSE" | jq -r '.dashboard.uid // empty')
43+
NAME=$(echo "$RESPONSE" | jq -r '.dashboard.dashboard.name // empty')
4344

4445
if [[ -n "$ID" ]]; then
4546
echo -e "${ID}\t${NAME}"

skills/building-dashboards/scripts/dashboard-create

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@ fi
3636
# Read, strip server-managed fields, and normalize layout for react-grid-layout
3737
BODY=$(jq -L "$SCRIPT_DIR" '
3838
include "dashboard-normalize";
39-
del(.id, .version, .createdAt, .updatedAt, .createdBy, .updatedBy) |
39+
del(.id, .uid, .version, .createdAt, .updatedAt, .createdBy, .updatedBy) |
4040
normalize_dashboard_layout
4141
' "$JSON_FILE")
4242

43-
RESPONSE=$("$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" POST "/internal/dashboards" "$BODY")
43+
BODY=$(echo "$BODY" | jq '{dashboard: .}')
4444

45-
# Extract and print the new dashboard ID
46-
ID=$(echo "$RESPONSE" | jq -r '.id // empty')
45+
RESPONSE=$("$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" POST "/dashboards" "$BODY")
46+
47+
# Extract and print the new dashboard UID
48+
ID=$(echo "$RESPONSE" | jq -r '.dashboard.uid // empty')
4749
if [[ -n "$ID" ]]; then
4850
echo "$ID"
4951
else

skills/building-dashboards/scripts/dashboard-delete

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
2828
exit 0
2929
fi
3030

31-
"$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" DELETE "/internal/dashboards/$ID"
31+
"$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" DELETE "/dashboards/uid/$ID"
3232
echo "Deleted: $ID"

skills/building-dashboards/scripts/dashboard-get

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ if [[ -z "$DEPLOYMENT" || -z "$ID" ]]; then
1919
exit 1
2020
fi
2121

22-
"$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" GET "/internal/dashboards/$ID" | jq .
22+
"$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" GET "/dashboards/uid/$ID" | jq '.dashboard'

skills/building-dashboards/scripts/dashboard-list

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ if [[ -z "$DEPLOYMENT" ]]; then
1919
exit 1
2020
fi
2121

22-
RESPONSE=$("$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" GET "/internal/dashboards?limit=1000")
22+
RESPONSE=$("$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" GET "/dashboards?limit=1000")
2323

2424
if [[ "$FORMAT" == "--json" ]]; then
2525
echo "$RESPONSE" | jq .
2626
else
27-
echo "$RESPONSE" | jq -r '.[] | [.id, .name] | @tsv'
27+
echo "$RESPONSE" | jq -r '.[] | [.uid, .dashboard.name] | @tsv'
2828
fi

skills/building-dashboards/scripts/dashboard-update

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ if [[ -z "$VERSION" ]]; then
4949
exit 1
5050
fi
5151

52-
RESPONSE=$("$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" PUT "/internal/dashboards/$ID" "$BODY")
52+
# Wrap body in v2 envelope: {dashboard: {...}, version: N}
53+
# Version must be a numeric int64. jq loses precision on large integers,
54+
# so we inject it via string substitution.
55+
DASHBOARD=$(echo "$BODY" | jq 'del(.version)')
56+
BODY="{\"dashboard\":${DASHBOARD},\"version\":${VERSION}}"
57+
58+
RESPONSE=$("$SCRIPT_DIR/axiom-api" "$DEPLOYMENT" PUT "/dashboards/uid/$ID" "$BODY")
5359

5460
echo "$RESPONSE" | jq .

skills/building-dashboards/tests/test-script-output.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ METHOD="${2:-}"
6464
PATH_="${3:-}"
6565
6666
case "$METHOD:$PATH_" in
67-
"POST:/internal/dashboards")
68-
echo '{"id":"created-id"}'
67+
"POST:/dashboards")
68+
echo '{"status":"created","dashboard":{"uid":"created-uid","id":"created-id","version":1,"dashboard":{"name":"Test Dashboard"},"createdAt":"2026-02-01T10:00:00Z","updatedAt":"2026-02-01T10:00:00Z","createdBy":"alice@example.com","updatedBy":"alice@example.com"}}'
6969
;;
70-
"PUT:/internal/dashboards/dashboard-root-id")
71-
echo '{"id":"dashboard-root-id","updated":true}'
70+
"PUT:/dashboards/uid/dashboard-root-id")
71+
echo '{"status":"updated","dashboard":{"uid":"dashboard-root-id","id":"dashboard-root-id","version":2,"dashboard":{"name":"Test Dashboard","updated":true},"createdAt":"2026-02-01T10:00:00Z","updatedAt":"2026-02-02T11:00:00Z","createdBy":"alice@example.com","updatedBy":"bob@example.com"}}'
7272
;;
7373
*)
7474
echo "Unexpected call: $METHOD $PATH_" >&2
@@ -83,14 +83,14 @@ echo "Script Stdout Contract"
8383
echo "======================"
8484

8585
create_out=$("$TMPDIR/dashboard-create" prod "$TMPDIR/input.json")
86-
if [[ "$create_out" == "created-id" ]]; then
87-
ok "dashboard-create outputs only dashboard ID"
86+
if [[ "$create_out" == "created-uid" ]]; then
87+
ok "dashboard-create outputs only dashboard UID"
8888
else
89-
fail "dashboard-create outputs only dashboard ID" "got: $create_out"
89+
fail "dashboard-create outputs only dashboard UID" "got: $create_out"
9090
fi
9191

9292
update_out=$("$TMPDIR/dashboard-update" prod dashboard-root-id "$TMPDIR/input.json")
93-
if echo "$update_out" | jq -e '.id == "dashboard-root-id" and .updated == true' > /dev/null 2>&1; then
93+
if echo "$update_out" | jq -e '.dashboard.uid == "dashboard-root-id" and .dashboard.dashboard.updated == true' > /dev/null 2>&1; then
9494
ok "dashboard-update outputs valid JSON only"
9595
else
9696
fail "dashboard-update outputs valid JSON only" "got: $update_out"

0 commit comments

Comments
 (0)