Documentation
¶
Overview ¶
Package client calls Edgescale's products from a backend: billing and OTP with the project's platform key, and auth's server API with a server app's secret or the key.
c, err := client.New("k3x9m2q7pa", client.WithKey(os.Getenv("EDGESCALE_KEY")))
plans, err := client.Decode[[]billing.Plan](c.Billing.ListPlans(ctx, nil))
Each product is a package generated from its public spec, in spec/.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Answer ¶
type Answer[T any] struct { Result T Messages []Message // notices that aren't failures, such as auth's 3000 for a header it didn't store Page *PageInfo // a list's result_info, or nil }
Answer is a whole envelope, for when its notices or a list's paging matter.
type Client ¶
type Client struct {
Billing billing.ClientInterface // takes the key
OTP otp.ClientInterface // takes the key
Auth auth.ClientInterface // takes the server secret, or the key when there's no secret
}
Client is one project's products, each the generated client of its spec.
type Error ¶
type Error struct {
Status int
Errors []Message
RetryAfter time.Duration // from a 429 or a 503 that says when to try again
}
Error is a failed call: its status, and the envelope's errors. A failure from in front of the API, such as a proxy's that isn't an envelope, has none.
type Message ¶
Message is one of an answer's errors or notices. Code is what to branch on, never Message.
type Option ¶
type Option func(*options)
Option is one of New's settings.
func WithHTTPClient ¶
WithHTTPClient sends every call through hc, http.DefaultClient unless set; nil keeps the default. Its timeouts and retries are the caller's.
func WithKey ¶
WithKey is the project's platform key, eds_ak_…, or eds_ak_test_… for a product's test mode.
func WithServerSecret ¶
WithServerSecret is a server app's secret, eds_as_…, from the project's Auth tab.
type PageInfo ¶
type PageInfo struct {
Page int `json:"page"`
PerPage int `json:"per_page"`
Count int `json:"count"` // the length of the result
TotalCount int `json:"total_count"`
TotalPages int `json:"total_pages"`
}
PageInfo is a list's paging. Its last page is the one where Page reaches TotalPages.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package auth provides primitives to interact with the openapi HTTP API.
|
Package auth provides primitives to interact with the openapi HTTP API. |
|
Package billing provides primitives to interact with the openapi HTTP API.
|
Package billing provides primitives to interact with the openapi HTTP API. |
|
Package otp provides primitives to interact with the openapi HTTP API.
|
Package otp provides primitives to interact with the openapi HTTP API. |