Documentation ¶
Index ¶
- Constants
- func NewDefaultHTTPClient() *http.Client
- func NewDefaultHTTPTransport() http.RoundTripper
- type Client
- func (c *Client) Delete(ctx context.Context, path string) ([]byte, error)
- func (c *Client) Do(r *http.Request) ([]byte, error)
- func (c *Client) Get(ctx context.Context, path string) ([]byte, error)
- func (c *Client) Patch(ctx context.Context, path string, body []byte) ([]byte, error)
- func (c *Client) Post(ctx context.Context, path string, body []byte) ([]byte, error)
- func (c *Client) Put(ctx context.Context, path string, body []byte) ([]byte, error)
- type ConfigFn
- type Error
- type ErrorType
- type LogFn
Examples ¶
Constants ¶
const ( Version string = "8.14.0" APIVersion string = "1.3" APIBaseURL string = "https://api.upcloud.com" EnvDebugAPIBaseURL string = "UPCLOUD_DEBUG_API_BASE_URL" EnvDebugSkipCertificateVerify string = "UPCLOUD_DEBUG_SKIP_CERTIFICATE_VERIFY" )
const ( ErrorTypeError = iota ErrorTypeProblem )
Variables ¶
This section is empty.
Functions ¶
func NewDefaultHTTPClient ¶
NewDefaultHTTPClient returns new default http.Client.
func NewDefaultHTTPTransport ¶
func NewDefaultHTTPTransport() http.RoundTripper
NewDefaultHTTPTransport return new HTTP client transport round tripper.
Types ¶
type Client ¶
type Client struct { UserAgent string // contains filtered or unexported fields }
Client represents an API client
func New ¶
New creates and returns a new client configured with the specified user and password and optional config functions.
func (*Client) Delete ¶
Delete performs a DELETE request to the specified path and returns the response body.
func (*Client) Get ¶
Get performs a GET request to the specified path and returns the response body.
func (*Client) Patch ¶
Patch performs a PATCH request to the specified path and returns the response body.
type ConfigFn ¶
type ConfigFn func(o *config)
func WithBaseURL ¶
WithBaseURL modifies the client baseURL
func WithHTTPClient ¶
WithHTTPClient replaces the client's default httpClient with the specified one
Example ¶
httpClient := &http.Client{ // setup custom HTTP client } New(os.Getenv("UPCLOUD_USERNAME"), os.Getenv("UPCLOUD_PASSWORD"), WithHTTPClient(httpClient))
Output:
func WithInsecureSkipVerify ¶
func WithInsecureSkipVerify() ConfigFn
WithInsecureSkipVerify modifies the client's httpClient to skip verifying the server's certificate chain and host name. This should be used only for testing.
func WithLogger ¶ added in v8.10.0
WithLogger configures logging function that logs requests and responses