• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

astronomer / astro-cli / 5b1aac88-2fcd-4067-b077-48a1fbc5d97d

05 Feb 2026 09:04PM UTC coverage: 33.316% (+0.2%) from 33.15%
5b1aac88-2fcd-4067-b077-48a1fbc5d97d

Pull #2006

circleci

jeremybeard
Feedback
Pull Request #2006: Add `astro api` command for authenticated Airflow and Cloud API requests

900 of 2387 new or added lines in 13 files covered. (37.7%)

21765 of 65328 relevant lines covered (33.32%)

8.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/cmd/api/api.go
1
// Package api provides the 'astro api' command for making authenticated API requests.
2
package api
3

4
import (
5
        "io"
6
        "os"
7

8
        "github.com/fatih/color"
9
        "github.com/spf13/cobra"
10
)
11

12
// NewAPICmd creates the parent 'astro api' command.
NEW
13
func NewAPICmd() *cobra.Command {
×
NEW
14
        return NewAPICmdWithOutput(os.Stdout)
×
NEW
15
}
×
16

17
// NewAPICmdWithOutput creates the parent 'astro api' command with a custom output writer.
NEW
18
func NewAPICmdWithOutput(out io.Writer) *cobra.Command {
×
NEW
19
        var noColor bool
×
NEW
20

×
NEW
21
        cmd := &cobra.Command{
×
NEW
22
                Use:           "api",
×
NEW
23
                Short:         "Make authenticated API requests to Astronomer services",
×
NEW
24
                SilenceErrors: true, // API commands print error bodies themselves; don't let cobra double-print
×
NEW
25
                SilenceUsage:  true,
×
NEW
26
                Long: `Make authenticated HTTP requests to Astronomer APIs and print responses.
×
NEW
27

×
NEW
28
The 'astro api' command provides direct access to Astronomer's REST APIs,
×
NEW
29
similar to 'gh api' for GitHub or 'vercel api' for Vercel.
×
NEW
30

×
NEW
31
Available subcommands:
×
NEW
32
  airflow  Make requests to the Airflow REST API
×
NEW
33
  cloud    Make requests to the Astro Cloud API (api.astronomer.io)
×
NEW
34

×
NEW
35
Use "astro api [command] --help" for more information about a command.`,
×
NEW
36
                PersistentPreRun: func(cmd *cobra.Command, args []string) {
×
NEW
37
                        if noColor {
×
NEW
38
                                color.NoColor = true
×
NEW
39
                        }
×
40
                },
NEW
41
                Run: func(cmd *cobra.Command, args []string) {
×
NEW
42
                        _ = cmd.Help()
×
NEW
43
                },
×
44
        }
45

NEW
46
        cmd.PersistentFlags().BoolVar(&noColor, "no-color", false, "Disable colorized output")
×
NEW
47

×
NEW
48
        cmd.AddCommand(NewAirflowCmd(out))
×
NEW
49
        cmd.AddCommand(NewCloudCmd(out))
×
NEW
50

×
NEW
51
        return cmd
×
52
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc