Documentation ¶
Index ¶
- Constants
- Variables
- func AddTypeConsumers(rtime *client.Runtime) *client.Runtime
- func NewTransport(rt http.RoundTripper, cfg TransportConfig) http.RoundTripper
- func UnwrapError(err error) error
- type API
- type AuthWriter
- type CloudClientRuntime
- type Config
- type DebugTransport
- type ErrCatchTransport
- type TransportConfig
- type VerboseSettings
Constants ¶
const ( // RegionPrefix is used when a Region is passed as part of the API config. RegionPrefix = "/api/v1/regions/%s" // RegionlessPrefix is used when no region is specified, assumed target is // most likely an ECE installation or a non federated one. RegionlessPrefix = "/api/v1" )
const Version = "2.4.3"
Version contains the ECE API version compatibility for the current auto-generated client and models. This needs to be updated every time a new "api/apidocs.json" file added and the client and models are re-generated. Even though the Bugfix version is specified, the general support statement is on the minor version, i.e: 2.4.2 means that all the 2.4 branch is supported, expecting some potentially unfixed bugs when ECE version is the same feature version bug higher bugfix version.
Variables ¶
var ( // DefaultTimeout is used when TransportConfig.Transport is not specified. DefaultTimeout = 30 * time.Second )
var DefaultTransport = new(ErrCatchTransport)
DefaultTransport can be used by clients which rely on the api.UnwrapError Can obtain the underlying http.Response is returned with a StatusCode not defined within the swagger spec from which the models have been generated. Meaning this is a small hack which allows http.Response.Body to be accessed. See error.go in the same package for details on how UnwrapError works. Note that using this variable directly won't allow any of the http.Transport setttings to be overridden. To customize the transport further, please use NewTransport()
Functions ¶
func AddTypeConsumers ¶
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. If rt is *http.Transport then it will be wrapped with *ErrCatchTransport. See more information on the GoDoc help for that type.
func UnwrapError ¶
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 NewDebugMock ¶
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.
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 CloudClientRuntime ¶
type CloudClientRuntime struct {
// contains filtered or unexported fields
}
CloudClientRuntime wraps runtimeclient.Runtime to allow operations to use a transport depending on the operation which is being performed.
func NewCloudClientRuntime ¶
func NewCloudClientRuntime(c Config) (*CloudClientRuntime, error)
NewCloudClientRuntime creates a CloudClientRuntime from the config. Using the configured region (if any) to instantiate two different client.Runtime. If there's no region specified in the config then both are regionless.
func (*CloudClientRuntime) Submit ¶
func (r *CloudClientRuntime) Submit(op *runtime.ClientOperation) (interface{}, error)
Submit calls either the regionRuntime or the regionless runtime depending on which operation is being performed. Any API call to /deployments will use a regionless runtime while all others will use a region (if specified).
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 // Timeout for all of the API calls performed through the API structure. Timeout time.Duration }
Config contains the API config
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
type ErrCatchTransport ¶
type ErrCatchTransport struct {
// contains filtered or unexported fields
}
ErrCatchTransport is an http.RoundTripper that which allows the http.Response to be accessed in certain types of wrapped errors returned by autogenerated code. See error.go in the same package for details on how UnwrapError works.
func NewErrCatchTransport ¶
func NewErrCatchTransport(rt http.RoundTripper) *ErrCatchTransport
NewErrCatchTransport initialises an ErrCatchTransport. See GoDoc for more help on this type.
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 // Timeout for the Transport net.Dialer. Timeout time.Duration }
TransportConfig is meant to be used so an http.RoundTripper is constructed with the appropriate settings.
type VerboseSettings ¶
VerboseSettings define the behaviour of verbosity.
func (VerboseSettings) Validate ¶
func (settings VerboseSettings) Validate() error
Validate ensures the settings are usable.
Source Files ¶
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. |