api

package
v0.0.0-...-883fa4f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package api implements low-level primitives for interacting with the Exoscale API.

Index

Constants

View Source
const (
	// EndpointURL represents the default API Endpoint URL.
	EndpointURL = "https://api.exoscale.com/"

	// Prefix represents the current API prefix.
	Prefix = "v2"
)

Variables

View Source
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.

func WithZone

func WithZone(ctx context.Context, zone string) context.Context

WithZone is a shorthand to WithEndpoint where only the endpoint zone has to be specified. If a request endpoint is already set in the specified context instance, the value currently set for the environment will be reused.

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.

func (*ErrorHandlerMiddleware) RoundTrip

func (m *ErrorHandlerMiddleware) RoundTrip(req *http.Request) (*http.Response, error)

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.

func (*SecurityProviderExoscale) Intercept

func (s *SecurityProviderExoscale) Intercept(_ context.Context, req *http.Request) error

Intercept is an HTTP middleware that intercepts and signs client requests before sending them to the API endpoint.

type TraceMiddleware

type TraceMiddleware struct {
	// contains filtered or unexported fields
}

TraceMiddleware is a client HTTP middleware that dumps HTTP requests and responses content.

func (*TraceMiddleware) RoundTrip

func (t *TraceMiddleware) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL