Documentation ¶
Overview ¶
Package api provides commmon functionality for the OTF API
Index ¶
Constants ¶
const ( DefaultBasePath = "/otfapi" PingEndpoint = "ping" DefaultURL = "https://localhost:8080" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶ added in v0.1.15
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Do ¶ added in v0.1.15
Do sends an API request and returns the API response. The API response is JSONAPI decoded and the document's primary data is stored in the value pointed to by v, or returned as an error if an API error has occurred.
If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.
The provided ctx must be non-nil. If it is canceled or times out, ctx.Err() will be returned.
func (*Client) NewRequest ¶ added in v0.1.15
func (c *Client) NewRequest(method, path string, v interface{}) (*retryablehttp.Request, error)
NewRequest creates an API request with proper headers and serialization.
A relative URL path can be provided, in which case it is resolved relative to the baseURL of the Client. Relative URL paths should always be specified without a preceding slash. Adding a preceding slash allows for ignoring the configured baseURL for non-standard endpoints.
If v is supplied, the value will be JSONAPI encoded and included as the request body. If the method is GET, the value will be parsed and added as query parameters.
type Config ¶ added in v0.1.15
type Config struct { // The URL of the otf API. URL string // The base path on which the API is served. BasePath string // API token used to access the otf API. Token string // Headers that will be added to every request. Headers http.Header // Toggle retrying requests upon encountering transient errors. RetryRequests bool // RetryLogHook is invoked each time a request is retried. RetryLogHook retryablehttp.RequestLogHook // Override default http transport Transport http.RoundTripper }
Config provides configuration details to the API client.