Documentation ¶
Index ¶
- Constants
- func WithBaseURL(baseURL string) configFn
- func WithHTTPClient(httpClient *http.Client) configFn
- func WithTimeout(timeout time.Duration) configFn
- 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 Error
- type ErrorType
Examples ¶
Constants ¶
View Source
const ( Version string = "5.4.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" )
View Source
const ( ErrorTypeError = iota ErrorTypeProblem )
Variables ¶
This section is empty.
Functions ¶
func WithBaseURL ¶
func WithBaseURL(baseURL string) configFn
func WithHTTPClient ¶
Example ¶
httpClient := &http.Client{ // setup custom HTTP client } New(os.Getenv("UPCLOUD_USERNAME"), os.Getenv("UPCLOUD_PASSWORD"), WithHTTPClient(httpClient))
Output:
func WithTimeout ¶
Example ¶
New(os.Getenv("UPCLOUD_USERNAME"), os.Getenv("UPCLOUD_PASSWORD"), WithTimeout(10*time.Second))
Output:
Types ¶
type Client ¶
type Client struct { UserAgent string // contains filtered or unexported fields }
Client represents an API client
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.
Click to show internal directories.
Click to hide internal directories.