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

astronomer / astro-cli / 7ad3521d-16b3-40c1-8bae-3435cbf5c859

14 Feb 2026 02:21AM UTC coverage: 35.009% (+1.9%) from 33.15%
7ad3521d-16b3-40c1-8bae-3435cbf5c859

Pull #2006

circleci

jeremybeard
Use kin-openapi for OpenAPI library
Pull Request #2006: Add `astro api` command

2029 of 2451 new or added lines in 13 files covered. (82.78%)

3 existing lines in 1 file now uncovered.

22893 of 65392 relevant lines covered (35.01%)

8.43 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

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

×
NEW
34
Use "astro api [command] --help" for more information about a command.`,
×
NEW
35
                PersistentPreRun: func(cmd *cobra.Command, args []string) {
×
NEW
36
                        // Cobra does not inherit SilenceUsage to subcommands, so propagate
×
NEW
37
                        // it here. The cmd parameter is the actual subcommand being executed,
×
NEW
38
                        // not the parent where PersistentPreRun is defined.
×
NEW
39
                        //
×
NEW
40
                        // Note: we do NOT propagate SilenceErrors. The parent api command
×
NEW
41
                        // sets SilenceErrors to avoid double-printing HTTP error bodies
×
NEW
42
                        // (SilentError), but subcommands need cobra to print non-silent
×
NEW
43
                        // errors like connection failures.
×
NEW
44
                        cmd.SilenceUsage = true
×
NEW
45

×
NEW
46
                        if noColor {
×
NEW
47
                                color.NoColor = true
×
NEW
48
                        }
×
49
                },
NEW
50
                Run: func(cmd *cobra.Command, args []string) {
×
NEW
51
                        _ = cmd.Help()
×
NEW
52
                },
×
53
        }
54

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

×
NEW
57
        cmd.AddCommand(NewAirflowCmd(out))
×
NEW
58
        cmd.AddCommand(NewCloudCmd(out))
×
NEW
59

×
NEW
60
        return cmd
×
61
}
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