Documentation ¶
Index ¶
- Constants
- func CACerts() *x509.CertPool
- func LazyCreateNewTransport(c *Client) *http.Transport
- func NewTransport() *http.Transport
- func ParseGoalResponse(data []byte) (*goal.Goal, error)
- func ParseHeartbeatResponses(data []byte) ([]heartbeat.Result, error)
- func ParseSummariesResponse(data []byte) ([]summary.Summary, error)
- type BasicAuth
- type Client
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) Goal(id string) (*goal.Goal, error)
- func (c *Client) SendDiagnostics(plugin string, diagnostics ...diagnostic.Diagnostic) error
- func (c *Client) SendHeartbeats(heartbeats []heartbeat.Heartbeat) ([]heartbeat.Result, error)
- func (c *Client) Summaries(startDate, endDate time.Time) ([]summary.Summary, error)
- type Err
- type ErrAuth
- type ErrRequest
- type Option
- func WithAuth(auth BasicAuth) (Option, error)
- func WithDisableSSLVerify() Option
- func WithHostname(hostname string) Option
- func WithNTLM(creds string) (Option, error)
- func WithNTLMRequestRetry(creds string) (Option, error)
- func WithProxy(proxyURL string) (Option, error)
- func WithSSLCertFile(filepath string) (Option, error)
- func WithSSLCertPool(caCertPool *x509.CertPool) (Option, error)
- func WithTimeout(timeout time.Duration) Option
- func WithUserAgent(plugin string) Option
- func WithUserAgentUnknownPlugin() Option
Constants ¶
const BaseURL = "https://api.wakatime.com/api/v1"
BaseURL is the base url of the wakatime api.
Variables ¶
This section is empty.
Functions ¶
func CACerts ¶ added in v1.7.4
CACerts returns a root cert pool with the system's cacerts and LetsEncrypt's root certs.
func LazyCreateNewTransport ¶ added in v1.18.1
LazyCreateNewTransport uses the client's Transport if exists, or creates a new one.
func NewTransport ¶ added in v1.7.4
NewTransport initializes a new http.Transport.
func ParseGoalResponse ¶
ParseGoalResponse parses the wakatime api response into goal.Goal.
func ParseHeartbeatResponses ¶
ParseHeartbeatResponses parses the aggregated responses returned by the heartbeat bulk endpoint.
Types ¶
type BasicAuth ¶
BasicAuth contains authentication data.
func (BasicAuth) HeaderValue ¶
HeaderValue returns the value for Authorization header.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client communicates with the wakatime api.
func (*Client) Do ¶
Do executes c.doFunc(), which in turn allows wrapping c.client.Do() and manipulating the request behavior of the api client.
func (*Client) Goal ¶
Goal fetches goal for the given goal id.
ErrRequest is returned upon request failure with no received response from api. ErrAuth is returned upon receiving a 401 Unauthorized api response. Err is returned on any other api response related error.
func (*Client) SendDiagnostics ¶ added in v1.18.1
func (c *Client) SendDiagnostics(plugin string, diagnostics ...diagnostic.Diagnostic) error
SendDiagnostics sends diagnostics to the WakaTime api.
func (*Client) SendHeartbeats ¶ added in v1.18.1
SendHeartbeats sends a bulk of heartbeats to the wakatime api and returns the result. The API does not guarantuee the setting of the Heartbeat property of the result. On certain errors, like 429/too many heartbeats, this is omitted and not set.
ErrRequest is returned upon request failure with no received response from api. ErrAuth is returned upon receiving a 401 Unauthorized api response. Err is returned on any other api response related error.
type ErrRequest ¶
type ErrRequest string
ErrRequest represents a request failure, where no response was received from the api.
func (ErrRequest) Error ¶
func (e ErrRequest) Error() string
Error method to implement error interface.
type Option ¶
type Option func(*Client)
Option is a functional option for Client.
func WithDisableSSLVerify ¶
func WithDisableSSLVerify() Option
WithDisableSSLVerify disables verification of insecure certificates.
func WithHostname ¶
WithHostname sets the X-Machine-Name header to the passed in hostname.
func WithNTLMRequestRetry ¶
WithNTLMRequestRetry will, upon request failure, retry with ntlm authentication.
func WithSSLCertFile ¶
WithSSLCertFile overrides the default CA certs file to trust specified cert file.
func WithSSLCertPool ¶
WithSSLCertPool overrides the default CA cert pool to trust specified cert pool.
func WithTimeout ¶
WithTimeout configures a timeout for all requests.
func WithUserAgent ¶
WithUserAgent sets the User-Agent header on all requests, including the passed in value for plugin.
func WithUserAgentUnknownPlugin ¶
func WithUserAgentUnknownPlugin() Option
WithUserAgentUnknownPlugin sets the User-Agent header on all requests, including default value for plugin.