MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / NewCmdAPI

Function NewCmdAPI

pkg/cmd/api/api.go:20–40  ·  view source on GitHub ↗
(f factory.Factory)

Source from the content-addressed store, hash-verified

18)
19
20func NewCmdAPI(f factory.Factory) *cobra.Command {
21 cmd := &cobra.Command{
22 Use: "api <url>",
23 Short: "Execute a raw API GET request",
24 Long: "Execute an authenticated GET request against the Octopus Server API and print the JSON response.",
25 Example: heredoc.Docf(`
26 %[1]s api /api
27 %[1]s api /api/spaces
28 %[1]s api /api/Spaces-1/projects
29 `, constants.ExecutableName),
30 Args: cobra.ExactArgs(1),
31 RunE: func(cmd *cobra.Command, args []string) error {
32 return apiRun(cmd, f, args[0])
33 },
34 Annotations: map[string]string{
35 annotations.IsCore: "true",
36 },
37 }
38
39 return cmd
40}
41
42func apiRun(cmd *cobra.Command, f factory.Factory, path string) error {
43 if err := validateAPIPath(path); err != nil {

Callers

nothing calls this directly

Calls 1

apiRunFunction · 0.85

Tested by

no test coverage detected