Documentation
¶
Overview ¶
Package apicall is the raw request behind `pgedge starfleet api` and `pgedge controlplane api`: one HTTP call to a path under the module's API base, over the module's own authenticated client, with the module's own status-to-exit mapping and the CLI's output formats.
It is an escape hatch for the endpoint no verb covers yet, and keeps the CLI's contract on the raw call, as gh api and az rest do.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Methods = []string{"GET", "POST", "PUT", "PATCH", "DELETE"}
Methods is the closed vocabulary; anything else is a usage error.
Functions ¶
func Build ¶
Build validates req against d and returns the http.Request, before anything is sent, so every refusal is exit 2 with no round trip.
Types ¶
type Deps ¶
type Deps struct {
Client *http.Client
BaseURL string
Edit func(context.Context, *http.Request) error
Check func(status int, body string) error
UsageErr func(msg string) error
// Transport wraps a failure to reach the server the way the
// module's own verbs do (controlplane adds its reachability hint);
// nil keeps the plain error.
Transport func(err error) error
}
Deps is what a module hands over: its client, base URL, request editor (nil for a client whose transport already authenticates), and its status-to-exit mapping.
type Request ¶
type Request struct {
Method string
Path string
Query []string // key=value, repeatable
Headers []string // Name: value, repeatable
Body []byte
// Include prints the status line and response headers on stderr.
Include bool
}
Request is one call. Path is relative to the base URL and must start with "/"; the host always comes from the parsed base, so a path can at most move within the API the credential was issued for.