|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +package cmd |
| 4 | + |
| 5 | +import ( |
| 6 | + "context" |
| 7 | + "fmt" |
| 8 | + "os" |
| 9 | + |
| 10 | + "github.com/stainless-api/stainless-api-cli/pkg/jsonflag" |
| 11 | + "github.com/stainless-api/stainless-api-go" |
| 12 | + "github.com/stainless-api/stainless-api-go/option" |
| 13 | + "github.com/urfave/cli/v3" |
| 14 | +) |
| 15 | + |
| 16 | +var buildsDiagnosticsList = cli.Command{ |
| 17 | + Name: "list", |
| 18 | + Usage: "Get diagnostics for a build", |
| 19 | + Flags: []cli.Flag{ |
| 20 | + &cli.StringFlag{ |
| 21 | + Name: "build-id", |
| 22 | + }, |
| 23 | + &jsonflag.JSONStringFlag{ |
| 24 | + Name: "cursor", |
| 25 | + Config: jsonflag.JSONConfig{ |
| 26 | + Kind: jsonflag.Query, |
| 27 | + Path: "cursor", |
| 28 | + }, |
| 29 | + }, |
| 30 | + &jsonflag.JSONFloatFlag{ |
| 31 | + Name: "limit", |
| 32 | + Config: jsonflag.JSONConfig{ |
| 33 | + Kind: jsonflag.Query, |
| 34 | + Path: "limit", |
| 35 | + }, |
| 36 | + }, |
| 37 | + &jsonflag.JSONStringFlag{ |
| 38 | + Name: "severity", |
| 39 | + Config: jsonflag.JSONConfig{ |
| 40 | + Kind: jsonflag.Query, |
| 41 | + Path: "severity", |
| 42 | + }, |
| 43 | + }, |
| 44 | + &jsonflag.JSONStringFlag{ |
| 45 | + Name: "targets", |
| 46 | + Config: jsonflag.JSONConfig{ |
| 47 | + Kind: jsonflag.Query, |
| 48 | + Path: "targets.#", |
| 49 | + }, |
| 50 | + }, |
| 51 | + &jsonflag.JSONStringFlag{ |
| 52 | + Name: "+target", |
| 53 | + Config: jsonflag.JSONConfig{ |
| 54 | + Kind: jsonflag.Query, |
| 55 | + Path: "targets.-1", |
| 56 | + }, |
| 57 | + }, |
| 58 | + }, |
| 59 | + Action: handleBuildsDiagnosticsList, |
| 60 | + HideHelpCommand: true, |
| 61 | +} |
| 62 | + |
| 63 | +func handleBuildsDiagnosticsList(ctx context.Context, cmd *cli.Command) error { |
| 64 | + cc := getAPICommandContext(cmd) |
| 65 | + params := stainlessv0.BuildDiagnosticListParams{} |
| 66 | + res, err := cc.client.Builds.Diagnostics.List( |
| 67 | + context.TODO(), |
| 68 | + cmd.Value("build-id").(string), |
| 69 | + params, |
| 70 | + option.WithMiddleware(cc.AsMiddleware()), |
| 71 | + ) |
| 72 | + if err != nil { |
| 73 | + return err |
| 74 | + } |
| 75 | + |
| 76 | + fmt.Printf("%s\n", ColorizeJSON(res.RawJSON(), os.Stdout)) |
| 77 | + return nil |
| 78 | +} |
0 commit comments