Merged
Conversation
Pull Request Test Coverage Report for Build 4cf0f249-3ceb-45e4-8eea-c8b56b786960Details
💛 - Coveralls |
astro api command for authenticated Airflow and Cloud API requestsastro api command
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.
7868dd1 to
dbb3d6a
Compare
There was a problem hiding this comment.
Pull request overview
Adds the new astro api command group for making authenticated requests to Astro Cloud and Airflow APIs, backed by OpenAPI spec discovery/caching and rich output formatting.
Changes:
- Introduces
astro api cloudandastro api airflowcommands withlsanddescribehelpers, request execution, pagination, caching, curl generation, and output formatting (jq/templates/color). - Adds
pkg/openapiutilities for fetching/caching OpenAPI specs, endpoint extraction/filtering, and Airflow version→spec-path mapping. - Updates dependencies and root command registration + README command list.
Reviewed changes
Copilot reviewed 27 out of 28 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/openapi/types.go | Adds minimal OpenAPI 3.0 struct types + Endpoint model for discovery/describe. |
| pkg/openapi/schema.go | Adds $ref resolution utilities for schema introspection in describe. |
| pkg/openapi/schema_test.go | Unit tests for schema resolver behavior. |
| pkg/openapi/endpoints.go | Implements endpoint extraction/sorting/filtering/path-param extraction. |
| pkg/openapi/endpoints_test.go | Unit tests for endpoint extraction/filtering/lookup. |
| pkg/openapi/cache.go | Implements spec fetch + on-disk caching with TTL, plus Airflow per-version cache config. |
| pkg/openapi/cache_test.go | Unit tests for cache read/write/fetch behavior and prefix stripping. |
| pkg/openapi/airflow_versions.go | Maps Airflow versions to OpenAPI spec paths + builds raw GitHub URLs. |
| pkg/openapi/airflow_versions_test.go | Unit tests for version-range mapping + URL building + normalization. |
| cmd/root.go | Registers the new api top-level command. |
| cmd/api/api.go | Adds astro api parent command + --no-color flag and subcommands. |
| cmd/api/cloud.go | Implements astro api cloud request flow + placeholder/path-param handling + subcommands. |
| cmd/api/cloud_test.go | Unit tests for cloud command utilities and spec operation-id resolution. |
| cmd/api/airflow.go | Implements astro api airflow including auth/token/version detection and subcommands. |
| cmd/api/airflow_test.go | Unit tests for Airflow auth/version detection/spec-cache init and command wiring. |
| cmd/api/list.go | Implements ls endpoint listing (table + verbose) for both APIs. |
| cmd/api/list_test.go | Unit tests for list rendering/grouping/filtering. |
| cmd/api/describe.go | Implements describe endpoint schema/params rendering using OpenAPI schemas/resolver. |
| cmd/api/describe_test.go | Unit tests for describe output and schema rendering edge cases. |
| cmd/api/fields.go | Implements magic/raw field parsing for request bodies with nested/array syntax. |
| cmd/api/fields_test.go | Unit tests for field parsing and magic conversions/file reads. |
| cmd/api/output.go | Implements jq filtering, Go templates, and colorized pretty JSON output. |
| cmd/api/output_test.go | Unit tests for jq/template/colorized JSON output behavior. |
| cmd/api/request.go | Implements HTTP execution, verbose I/O, pagination, curl generation, and response caching. |
| cmd/api/request_test.go | Extensive unit tests for request execution, pagination, caching, curl quoting, etc. |
| go.mod | Adds jq/json coloring deps and bumps several module versions. |
| README.md | Documents the new api command in the CLI command list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jlaneve
reviewed
Feb 13, 2026
| @@ -0,0 +1,120 @@ | |||
| // Package openapi provides utilities for working with OpenAPI specifications. | |||
Contributor
There was a problem hiding this comment.
chatted about this offline but it'd be good to see if we can find a package for this instead of maintaining it ourselves
Contributor
Author
There was a problem hiding this comment.
Switched it to kin-openapi, which was actually already a transitive dependency
jlaneve
approved these changes
Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add the
astro apitop-level command with two subcommands for making authenticated API requests to Astronomer services:astro api airflow— make requests to the Airflow REST API (local or deployed), with automatic version detection 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:
lsanddescribe(parsed from OpenAPI specs)--slurpinto a single array)jqfilters and Go-template output formatting--curlflag to emit equivalent curl commands@file,:=json,=string)Supporting packages:
pkg/openapi: OpenAPI spec fetching, caching, endpoint indexing, Airflow version-range mapping, and schema introspection.🧪 Functional Testing
astro dev start, thenastro api airflow lsto list available endpoints. Call an endpoint by operation ID, e.g.astro api airflow get_health.astro api airflow -d <deployment-id> lsto list endpoints on a deployed Airflow instance. Call an endpoint, e.g.astro api airflow -d <deployment-id> get_dags.astro api cloud lsto list Astro platform endpoints. Call an endpoint, e.g.astro api cloud list-deployments --path-param organizationId=<org-id>.astro api airflow describe get_dagsorastro api cloud describe list-deploymentsto see endpoint details including parameters and response schemas.--jq '.dags[]',--template '{{range .dags}}{{.dag_id}}{{end}}',--silent, and--slurpflags.--curlto any request to verify the generated curl command.📋 Checklist
make testbefore taking out of draftmake lintbefore taking out of draft