api

package
v1.0.0-bc3 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2019 License: Apache-2.0 Imports: 22 Imported by: 55

Documentation

Index

Constants

View Source
const (
	// RegionPrefix is used when a Region is passed as part of the API config.
	RegionPrefix = "/api/v1/regions"

	// RegionlessPrefix is used when no region is specified, assumed target is
	// most likely an ECE installation or a non federated one.
	RegionlessPrefix = "/api/v1"
)

Variables

This section is empty.

Functions

func AddTypeConsumers

func AddTypeConsumers(rtime *client.Runtime) *client.Runtime

AddTypeConsumers adds the missing consumers and producers to the client.Runtime. Even though a pointer is passed it is returned too.

func NewTransport

func NewTransport(rt http.RoundTripper, cfg TransportConfig) http.RoundTripper

NewTransport constructs a new http.RoundTripper from its config.

func UnwrapError

func UnwrapError(err error) error

UnwrapError unpacks an error message returned from autogenerated sdk.

Types

type API

type API struct {
	V1API      *client.Rest
	AuthWriter AuthWriter
}

API contains all of the API clients and authentication objects necessary for the EC API

func NewAPI

func NewAPI(c Config) (*API, error)

NewAPI initializes the API clients from an API config that it receives

func NewDebugMock

func NewDebugMock(o io.Writer, res ...mock.Response) *API

NewDebugMock creates a new api.API from a list of Responses. Defaults to a dummy APIKey for authentication, which is not checked. Additionally adds the DebugTransport so that the responses go to the configured io.Writer.

func NewMock

func NewMock(res ...mock.Response) *API

NewMock creates a new api.API from a list of Responses. Defaults to a dummy APIKey for authentication, which is not checked

type AuthWriter

type AuthWriter interface {
	runtime.ClientAuthInfoWriter
	AuthRequest(req *http.Request) *http.Request
}

AuthWriter wraps the runtime.ClientAuthInfoWriter interface adding a method to Auth generic http.Request.

type Config

type Config struct {
	Client     *http.Client
	AuthWriter AuthWriter
	Host       string
	Region     string

	// SkipTLSVerify will not perform any TLS/SSL verification.
	SkipTLSVerify bool

	// ErrorDevice is used to send errors to prevent cluttering the output.
	ErrorDevice io.Writer

	VerboseSettings
}

Config contains the API config

func (Config) Validate

func (c Config) Validate() error

Validate returns an error if the config is invalid

type DebugTransport

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

DebugTransport is an http.RoundTripper that keeps track of the in-flight request and implements hooks to report HTTP tracing events.

func NewDebugTransport

func NewDebugTransport(transport http.RoundTripper, o io.Writer) *DebugTransport

NewDebugTransport factory for DebugTransport

func (*DebugTransport) RoundTrip

func (t *DebugTransport) RoundTrip(rreq *http.Request) (*http.Response, error)

RoundTrip wraps http.DefaultTransport.RoundTrip to keep track of the current request.

type TransportConfig

type TransportConfig struct {
	// When SkipTLSVerify the TLS verification is completely skipped.
	SkipTLSVerify bool

	// ErrorDevice where any error or notices will be sent.
	ErrorDevice io.Writer

	// Can enable a debug RoundTripper which dumps the request and responses to
	// the configured device.
	VerboseSettings
}

TransportConfig is meant to be used so an http.RoundTripper is constructed with the appropriate settings.

type VerboseSettings

type VerboseSettings struct {
	Verbose bool
	Device  io.Writer
}

VerboseSettings define the behaviour of verbosity.

func (VerboseSettings) Validate

func (settings VerboseSettings) Validate() error

Validate ensures the settings are usable.

Directories

Path Synopsis
Package mock provides functions and types to help test and stub external calls that the API structures would otherwise perform causing external calls through the network.
Package mock provides functions and types to help test and stub external calls that the API structures would otherwise perform causing external calls through the network.

Jump to

Keyboard shortcuts

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