Documentation
¶
Index ¶
- type APIError
- type APIProblem
- type Client
- func (c *Client) CreateItem(ctx context.Context, idempotencyKey string, body CreateItemBody) (*Item, error)
- func (c *Client) DeleteItem(ctx context.Context, id int64, idempotencyKey string, ifMatch string) error
- func (c *Client) ExportItems(ctx context.Context) (io.ReadCloser, error)
- func (c *Client) GetItem(ctx context.Context, id int64) (*Item, GetItemResponseHeaders, error)
- func (c *Client) Healthz(ctx context.Context) (*Health, error)
- func (c *Client) ImportItems(ctx context.Context, body io.Reader) error
- func (c *Client) ListItems(ctx context.Context, cursor *string, limit *int64) (*ItemList, error)
- type CreateItemBody
- type GetItemResponseHeaders
- type Health
- type Item
- type ItemList
- type Problem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
StatusCode int
Status string
Method string
URL string
Body []byte
// Problem holds the decoded RFC 7807 payload when the response
// carried application/problem+json (or application/json) and the
// body parsed as a JSON object. nil otherwise; Body always keeps
// the raw bytes either way.
Problem *APIProblem
}
APIError is returned for non-2xx responses. It captures the HTTP status, the raw response body, and — for JSON error bodies — the decoded RFC 7807 problem details.
type APIProblem ¶ added in v0.1.0
type APIProblem struct {
Type string `json:"type,omitempty"`
Title string `json:"title,omitempty"`
Status int `json:"status,omitempty"`
Detail string `json:"detail,omitempty"`
Instance string `json:"instance,omitempty"`
// Extensions holds any non-standard members (e.g. a per-field
// "errors" array) keyed by member name.
Extensions map[string]json.RawMessage `json:"-"`
}
APIProblem is an RFC 7807 "problem details" object. Members beyond the five standard ones are preserved in Extensions as raw JSON.
func (*APIProblem) UnmarshalJSON ¶ added in v0.1.0
func (p *APIProblem) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes the standard RFC 7807 members and captures everything else in Extensions.
type Client ¶
type Client struct {
// BaseURL is prepended to every request path (no trailing slash).
BaseURL string
// HTTP is the underlying HTTP client. nil falls back to http.DefaultClient.
HTTP *http.Client
// DefaultHeaders are merged onto every request before per-call headers.
DefaultHeaders http.Header
}
Client is the typed HTTP client for the generated API.
func (*Client) CreateItem ¶
func (c *Client) CreateItem(ctx context.Context, idempotencyKey string, body CreateItemBody) (*Item, error)
Create an item
func (*Client) DeleteItem ¶
func (c *Client) DeleteItem(ctx context.Context, id int64, idempotencyKey string, ifMatch string) error
Delete an item
func (*Client) ExportItems ¶ added in v0.1.0
Export items as CSV
The returned io.ReadCloser streams the raw text/csv response body; the caller must close it.
func (*Client) ImportItems ¶ added in v0.1.0
Bulk-import items from a CSV upload
The request body is streamed as application/octet-stream; it is not buffered.
type CreateItemBody ¶
type CreateItemBody struct {
Name string `json:"name"`
}
type GetItemResponseHeaders ¶ added in v0.1.0
type GetItemResponseHeaders struct {
CacheControl string
// Entity tag for the returned item
Etag string
}
GetItemResponseHeaders carries the response headers declared on GetItem's success response. Headers absent from the response are left as zero values.