Documentation ¶
Overview ¶
Package api implements low-level primitives for interacting with the Exoscale API.
Index ¶
Constants ¶
const ( // EndpointURL represents the default API Endpoint URL. EndpointURL = "https://api.exoscale.com/" // Prefix represents the current API prefix. Prefix = "v2" )
Variables ¶
var ( // ErrNotFound represents an error indicating a non-existent resource. ErrNotFound = errors.New("resource not found") // ErrTooManyFound represents an error indicating multiple results found for a single resource. ErrTooManyFound = errors.New("multiple resources found") // ErrInvalidRequest represents an error indicating that the caller's request is invalid. ErrInvalidRequest = errors.New("invalid request") // ErrAPIError represents an error indicating an API-side issue. ErrAPIError = errors.New("API error") )
Functions ¶
func WithEndpoint ¶
func WithEndpoint(ctx context.Context, endpoint ReqEndpoint) context.Context
WithEndpoint returns an augmented context instance containing the Exoscale endpoint to send the request to.
Types ¶
type ErrorHandlerMiddleware ¶
type ErrorHandlerMiddleware struct {
// contains filtered or unexported fields
}
ErrorHandlerMiddleware is an Exoscale API HTTP client middleware that returns concrete Go errors according to API response errors.
type Middleware ¶
type Middleware interface { http.RoundTripper }
func NewAPIErrorHandlerMiddleware ¶
func NewAPIErrorHandlerMiddleware(next http.RoundTripper) Middleware
func NewTraceMiddleware ¶
func NewTraceMiddleware(next http.RoundTripper) Middleware
type ReqEndpoint ¶
type ReqEndpoint struct {
// contains filtered or unexported fields
}
ReqEndpoint represents an Exoscale API request endpoint.
func NewReqEndpoint ¶
func NewReqEndpoint(env, zone string) ReqEndpoint
NewReqEndpoint returns a new Exoscale API request endpoint from an environment and zone.
func (*ReqEndpoint) Env ¶
func (r *ReqEndpoint) Env() string
Env returns the Exoscale API endpoint environment.
func (*ReqEndpoint) Host ¶
func (r *ReqEndpoint) Host() string
Host returns the Exoscale API endpoint host FQDN.
func (*ReqEndpoint) Zone ¶
func (r *ReqEndpoint) Zone() string
Zone returns the Exoscale API endpoint zone.
type SecurityProviderExoscale ¶
type SecurityProviderExoscale struct { // ReqExpire represents the request expiration duration. ReqExpire time.Duration // contains filtered or unexported fields }
SecurityProviderExoscale represents an Exoscale public API security provider.
func NewSecurityProvider ¶
func NewSecurityProvider(apiKey, apiSecret string) (*SecurityProviderExoscale, error)
NewSecurityProvider returns a new Exoscale public API security provider to sign API requests using the specified API key/secret.
type TraceMiddleware ¶
type TraceMiddleware struct {
// contains filtered or unexported fields
}
TraceMiddleware is a client HTTP middleware that dumps HTTP requests and responses content.