Add `astro api` command by jeremybeard · Pull Request #2006 · astronomer/astro-cli
Introduce the `astro api` top-level command with two subcommands: astro api airflow — make requests to the Airflow REST API (local or deployed), with automatic version detection (2.x, 3.0.x, 3.0.3+) and OpenAPI spec resolution. astro api cloud — make requests to the Astro Cloud platform API using the current context's bearer token. Both subcommands support: - Endpoint discovery via `ls` and `describe` (parsed from OpenAPI specs) - Calling endpoints by operation ID or raw path - Pagination (per-page streaming or --slurp into a single array) - Response caching with TTL and automatic stale-entry cleanup - jq filters and Go-template output formatting - Colored JSON output - --curl flag to emit equivalent curl commands - Magic field syntax for request bodies (@file, :=json, =string) - Custom headers and path-parameter overrides Supporting packages: - pkg/openapi: OpenAPI spec fetching, caching, endpoint indexing, Airflow version-range mapping, and schema introspection. Includes unit tests for request handling, output formatting, field parsing, OpenAPI version mapping, endpoint indexing, and caching.