Skip to content

Add ergonomic aliases for control-plane methods#7

Open
njbrake wants to merge 1 commit into
mainfrom
feat/control-plane-ergonomic-aliases
Open

Add ergonomic aliases for control-plane methods#7
njbrake wants to merge 1 commit into
mainfrom
feat/control-plane-ergonomic-aliases

Conversation

@njbrake

@njbrake njbrake commented Jun 8, 2026

Copy link
Copy Markdown
Member

Summary

  • The control-plane resources previously exposed only the OpenAPI-generator-derived method names (e.g. keys.create_key_v1_keys_post(...)), leaking generator naming into the public management surface. The migrated shell explicitly flagged friendlier aliases as a follow-up.
  • Each resource accessor (keys, users, budgets, pricing, usage) now returns a hand-written wrapper exposing ergonomic aliases that delegate to the generated methods:
    • keys: create, get, list, update, delete
    • users: create, get, list, update, delete, get_usage
    • budgets: create, get, list, update, delete
    • pricing: get, set, delete, get_history, list
    • usage: list
  • The generated core is untouched, so regeneration is unaffected. The raw generated methods stay reachable via a raw accessor on each resource (e.g. keys.raw.create_key_v1_keys_post(...)) as an escape hatch.
  • Aliases forward request options (_request_timeout, _headers, ...) through **kwargs.

Test plan

  • ruff check .
  • mypy src/
  • New unit test (tests/unit/test_control_plane_aliases.py): table-driven assertions that every alias forwards to the correct generated method with the right args, options pass through as kwargs, and raw exposes the generated API.
  • Integration tests rewritten to drive the ergonomic aliases, plus a new test proving the raw escape hatch works end to end.
  • Full suite: 116 passed, 2 skipped, including the 7 control-plane integration tests run against a live gateway built from the otari repo.

Fixes #107

🤖 Generated with Claude Code

The control-plane resources previously exposed only the
OpenAPI-generator-derived method names (for example
keys.create_key_v1_keys_post(...)), which leaked generator naming into the
public management surface. The migrated SDK shell explicitly flagged friendlier
aliases as a follow-up.

Wrap each generated control-plane API (keys, users, budgets, pricing, usage) in
a hand-written resource exposing ergonomic aliases (create, get, list, update,
delete, plus get_usage / set / get_history). Aliases delegate to the generated
methods and forward request options as kwargs. The generated core is untouched,
so regeneration is unaffected, and the raw generated methods stay reachable via
a `raw` accessor on each resource as an escape hatch.

Fixes #107

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@njbrake njbrake requested a review from tbille June 8, 2026 17:02
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