Documentation
¶
Index ¶
- func BuildOAuthTokenSource(cfg *config.Config) oauth2.TokenSource
- func CheckResponse(resp *http.Response, body []byte) error
- func MaybePersistRefreshedOAuthToken(cfg *config.Config, tok *oauth2.Token, mu *sync.Mutex)
- func NewAuthRequestEditor(cfg *config.Config) func(context.Context, *http.Request) error
- func NewAuthedHTTPClient(cfg *config.Config, maxRetries int, timeout time.Duration) *http.Client
- type APIError
- type Client
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildOAuthTokenSource ¶ added in v0.10.0
func BuildOAuthTokenSource(cfg *config.Config) oauth2.TokenSource
BuildOAuthTokenSource creates an oauth2.TokenSource from the given config. If refresh credentials are available, the source auto-refreshes expired tokens.
func CheckResponse ¶
CheckResponse returns nil for 2xx responses or an *APIError describing the failure for non-2xx responses.
func MaybePersistRefreshedOAuthToken ¶ added in v0.10.0
MaybePersistRefreshedOAuthToken writes a refreshed token back to the config file if the access token, refresh token, or expiry has changed.
func NewAuthRequestEditor ¶ added in v0.13.0
NewAuthRequestEditor returns a request editor that applies Oodle authentication: an OAuth Bearer token when one is configured (refreshing and persisting it as needed), falling back to the API key.
Exported so hand-rolled clients for endpoints the generated OpenAPI client does not cover (e.g. the Grafana migration endpoints) authenticate exactly like every other command, rather than hardcoding X-API-Key and silently failing for OAuth-only users.
func NewAuthedHTTPClient ¶ added in v0.13.0
NewAuthedHTTPClient returns an http.Client that authenticates and retries the same way the generated API client does. `timeout` overrides the default request timeout, which matters for uploads far larger than a normal API call.
Types ¶
type APIError ¶
type APIError struct {
StatusCode int
Code string
Message string
Cause string
Remedy string
TraceID string
}
APIError is the structured representation of a non-2xx Oodle API response.
type Client ¶
type Client struct {
// Inner is exported so command files can call generated methods directly.
Inner *client.ClientWithResponses
Config *config.Config
// contains filtered or unexported fields
}
Client wraps the generated OpenAPI client and adds Oodle-specific behaviour: API-key injection, retries on transient failures, and friendly error formatting.