Documentation ¶
Index ¶
- Variables
- func NewError(responseStatusCode int, responseBody io.Reader) error
- func NewMockedClient() (*Client, *Mock)
- func UseProxy(proxy *Proxy) error
- type Client
- func (cli *Client) Do(request *http.Request) (*http.Response, error)
- func (cli *Client) Get(ctx context.Context, path string, dst any) error
- func (cli *Client) Make(request *http.Request, dst any) error
- func (cli *Client) NewRequest(ctx context.Context, method, path string, src any) (*http.Request, error)
- func (cli *Client) Post(ctx context.Context, path string, src, dst any) error
- func (cli *Client) Put(ctx context.Context, path string, src, dst any) error
- func (cli *Client) WithTLSConfig(config *tls.Config) *Client
- type ConnectionError
- type Error
- type Mock
- type MockResponse
- type Proxy
Constants ¶
This section is empty.
Variables ¶
var UserAgent = "qbee-agent/" + app.Version
UserAgent is the user agent string used for all API calls. This is used to identify active versions of the agent.
Functions ¶
func NewMockedClient ¶
NewMockedClient returns a new API client with mocked transport.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a device hub API client.
func (*Client) NewRequest ¶
func (cli *Client) NewRequest(ctx context.Context, method, path string, src any) (*http.Request, error)
NewRequest returns a new HTTP request for provided method, path and src.
type ConnectionError ¶
type ConnectionError struct {
// contains filtered or unexported fields
}
ConnectionError is used to explicitly indicate API connectivity issue. This is used to track failed API connection attempts.
func NewConnectionError ¶
func NewConnectionError(err error) ConnectionError
NewConnectionError returns a new connection error with the given underlying error.
func (ConnectionError) Error ¶
func (err ConnectionError) Error() string
Error returns a string representation of the error.
func (ConnectionError) Unwrap ¶
func (err ConnectionError) Unwrap() error
Unwrap returns the underlying error.
type Mock ¶
type Mock struct {
// contains filtered or unexported fields
}
Mock is a mock RoundTripper implementation.
func (*Mock) Add ¶
func (m *Mock) Add(statusCode int, body string, args ...any) *MockResponse
Add adds a new mock response with the given status code and body. Response body can contain format specifiers.
func (*Mock) AddResponse ¶
func (m *Mock) AddResponse(response *http.Response) *MockResponse
AddResponse adds a new mock response.
type MockResponse ¶
type MockResponse struct {
// contains filtered or unexported fields
}
MockResponse represents a mock response with the request that was used to get it.
func (*MockResponse) Called ¶
func (resp *MockResponse) Called() bool
Called returns true if the response was used.
func (*MockResponse) Request ¶
func (resp *MockResponse) Request() *http.Request
Request returns the request that was used to get this response.