|
| 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 generateCreateSpec = cli.Command{ |
| 17 | + Name: "create_spec", |
| 18 | + Usage: "Perform create_spec operation", |
| 19 | + Flags: []cli.Flag{ |
| 20 | + &jsonflag.JSONStringFlag{ |
| 21 | + Name: "project", |
| 22 | + Config: jsonflag.JSONConfig{ |
| 23 | + Kind: jsonflag.Body, |
| 24 | + Path: "project", |
| 25 | + }, |
| 26 | + }, |
| 27 | + &jsonflag.JSONStringFlag{ |
| 28 | + Name: "source.revision", |
| 29 | + Config: jsonflag.JSONConfig{ |
| 30 | + Kind: jsonflag.Body, |
| 31 | + Path: "source.revision", |
| 32 | + }, |
| 33 | + }, |
| 34 | + &jsonflag.JSONStringFlag{ |
| 35 | + Name: "source.type", |
| 36 | + Config: jsonflag.JSONConfig{ |
| 37 | + Kind: jsonflag.Body, |
| 38 | + Path: "source.type", |
| 39 | + }, |
| 40 | + }, |
| 41 | + &jsonflag.JSONStringFlag{ |
| 42 | + Name: "source.openapi_spec", |
| 43 | + Config: jsonflag.JSONConfig{ |
| 44 | + Kind: jsonflag.Body, |
| 45 | + Path: "source.openapi_spec", |
| 46 | + }, |
| 47 | + }, |
| 48 | + &jsonflag.JSONStringFlag{ |
| 49 | + Name: "source.stainless_config", |
| 50 | + Config: jsonflag.JSONConfig{ |
| 51 | + Kind: jsonflag.Body, |
| 52 | + Path: "source.stainless_config", |
| 53 | + }, |
| 54 | + }, |
| 55 | + }, |
| 56 | + Action: handleGenerateCreateSpec, |
| 57 | + HideHelpCommand: true, |
| 58 | +} |
| 59 | + |
| 60 | +func handleGenerateCreateSpec(ctx context.Context, cmd *cli.Command) error { |
| 61 | + cc := getAPICommandContext(cmd) |
| 62 | + params := stainlessv0.GenerateNewSpecParams{} |
| 63 | + res, err := cc.client.Generate.NewSpec( |
| 64 | + context.TODO(), |
| 65 | + params, |
| 66 | + option.WithMiddleware(cc.AsMiddleware()), |
| 67 | + ) |
| 68 | + if err != nil { |
| 69 | + return err |
| 70 | + } |
| 71 | + |
| 72 | + fmt.Printf("%s\n", ColorizeJSON(res.RawJSON(), os.Stdout)) |
| 73 | + return nil |
| 74 | +} |
0 commit comments