Skip to content

feat: organizations CRUD + users delete-account (100% coverage)#63

Merged
yorkable merged 4 commits into
mainfrom
feat-orgs-and-account
Apr 30, 2026
Merged

feat: organizations CRUD + users delete-account (100% coverage)#63
yorkable merged 4 commits into
mainfrom
feat-orgs-and-account

Conversation

@yorkable

Copy link
Copy Markdown
Contributor

Summary

Final PR (5 of 5) in the 100% OpenAPI coverage initiative. Closes the last 4 gaps and reaches 100% coverage of non-deprecated endpoints.

  • organizations get (rename of organizations list) → GET /api/v1/organizations/
    • The spec calls this Get Current Organization (singular). The old list name was misleading.
    • organizations list kept as a hidden cobra alias for back-compat — old scripts still work.
  • organizations create --file body.jsonPOST /api/v1/organizations/
  • organizations update --file body.jsonPUT /api/v1/organizations/
  • organizations delete --confirmDELETE /api/v1/organizations/
  • users delete-account --confirmDELETE /api/v1/users/delete_account

--confirm gate

The two destructive endpoints require a literal --confirm flag. Without it, the command errors out and never hits the network — verified by tests. This is a new pattern in the CLI; if accepted here it could be applied to other destructive verbs in a follow-up.

Coverage status (after merge)

  • Total spec operations: 163
  • Deprecated (skipped): 12 — language_groups (6), dashboards session_* (4), channels.twilio create/update (2)
  • Active operations: 151
  • CLI coverage after this PR: 151/151 = 100%

Independent of PRs #59, #60, #61, #62. Merge order doesn't matter.

Test plan

  • go test ./... passes (8 new tests, including --confirm gate assertions)
  • go build clean
  • --help renders for all new commands; delete shows --confirm requirement
  • organizations list (hidden) still works as alias of get
  • Live: smoke organizations get against any org (read-only, safe)
  • Do not run organizations delete or users delete-account against any real account — there is no recovery path

🤖 Generated with Claude Code

yorkable added a commit that referenced this pull request Apr 30, 2026
Codex review on PR #63 caught a real bug: the spec declares
POST/PUT /api/v1/organizations/ as multipart/form-data with required
fields (logo + display_name on create, display_name on update), but
the previous implementation sent JSON via apiClient.Post/Put. Real
requests would have failed validation against the live API.

Fix:
- Add Client.PostMultipartForm / PutMultipartForm helpers that mix
  text fields and an optional file (single field). Reuses the existing
  multipart machinery and 5-minute upload timeout.
- Rewrite organizations create/update with explicit flags matching
  the spec's Body_organizations_{create,update} schema:
  - create: --display-name, --logo (required); --description,
    --domains, --saml-provider-id (optional)
  - update: --display-name (required); --logo, --description,
    --domains, --saml-provider-id, --update-comments (optional)
- Drop the --file JSON-body pattern for these two endpoints; it can't
  represent the binary logo and would mislead users.
- Tests parse the multipart body server-side and assert form-field
  values + presence of the logo file part.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
yorkable added a commit that referenced this pull request Apr 30, 2026
"Keeping the old name works avoids breaking scripts" → "...avoids breaking
scripts that still invoke it."

Caught in self-review of PR #63.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
yorkable and others added 3 commits April 30, 2026 16:09
Closes the final 4/15 coverage gaps and reaches 100% of non-deprecated
spec endpoints:
- POST /api/v1/organizations/ (organizations_create)
- PUT  /api/v1/organizations/ (organizations_update)
- DELETE /api/v1/organizations/ (organizations_delete) — requires --confirm
- DELETE /api/v1/users/delete_account (users_delete_account) — requires --confirm

Naming fix: the spec calls GET /api/v1/organizations/ "Get Current
Organization" (singular). Earlier CLI versions exposed it as
`organizations list` which was misleading. Renamed to `organizations get`;
`organizations list` kept as a hidden alias so existing scripts keep working.

The two destructive endpoints gate behind a literal --confirm flag —
the first such gate in the CLI. Without --confirm, the command exits
with a non-zero status and never hits the network.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Codex review on PR #63 caught a real bug: the spec declares
POST/PUT /api/v1/organizations/ as multipart/form-data with required
fields (logo + display_name on create, display_name on update), but
the previous implementation sent JSON via apiClient.Post/Put. Real
requests would have failed validation against the live API.

Fix:
- Add Client.PostMultipartForm / PutMultipartForm helpers that mix
  text fields and an optional file (single field). Reuses the existing
  multipart machinery and 5-minute upload timeout.
- Rewrite organizations create/update with explicit flags matching
  the spec's Body_organizations_{create,update} schema:
  - create: --display-name, --logo (required); --description,
    --domains, --saml-provider-id (optional)
  - update: --display-name (required); --logo, --description,
    --domains, --saml-provider-id, --update-comments (optional)
- Drop the --file JSON-body pattern for these two endpoints; it can't
  represent the binary logo and would mislead users.
- Tests parse the multipart body server-side and assert form-field
  values + presence of the logo file part.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
"Keeping the old name works avoids breaking scripts" → "...avoids breaking
scripts that still invoke it."

Caught in self-review of PR #63.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@yorkable
yorkable force-pushed the feat-orgs-and-account branch from 5b48cc9 to 8e84478 Compare April 30, 2026 23:09
A user pointed out that exposing organizations delete is too dangerous to
ship even with a --confirm gate — one bad keystroke wipes every agent,
session, batch, and channel target for the org. The endpoint exists in
the spec but is intentionally absent from the CLI.

The web console retains delete for the small set of operators who need
it. CLI users should use that path; the safety floor is simpler with no
CLI surface at all.

This drops the cobra command, both gate tests, and the AGENTS.md row.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@yorkable
yorkable merged commit e3eb140 into main Apr 30, 2026
2 checks passed
@yorkable
yorkable deleted the feat-orgs-and-account branch April 30, 2026 23:34
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.

1 participant