Documentation
¶
Overview ¶
Package api talks to the Bachs HTTP API.
Only the handful of calls the CLI needs. Errors carry the server's own message rather than a bare status code: a bad event name or a key missing webhooks:write is worth reading, and hiding it behind "400" wastes the user's time.
Index ¶
- Variables
- type Client
- func (c *Client) CloseSession(ctx context.Context, sessionID string) error
- func (c *Client) CreateEndpoint(ctx context.Context, req CreateEndpointRequest) (*CreateEndpointResponse, error)
- func (c *Client) CreateSession(ctx context.Context, req CreateSessionRequest) (*CreateSessionResponse, error)
- func (c *Client) DeleteEndpoint(ctx context.Context, endpointID string) error
- func (c *Client) ListEndpoints(ctx context.Context) ([]Endpoint, error)
- func (c *Client) ListEvents(ctx context.Context, limit, offset int) (*EventsResponse, error)
- func (c *Client) Replay(ctx context.Context, eventID string) (*ReplayResponse, error)
- func (c *Client) Trigger(ctx context.Context, eventType string) (*TriggerResponse, error)
- type CreateEndpointRequest
- type CreateEndpointResponse
- type CreateSessionRequest
- type CreateSessionResponse
- type Endpoint
- type Error
- type Event
- type EventsResponse
- type ReplayRequest
- type ReplayResponse
- type TriggerRequest
- type TriggerResponse
Constants ¶
This section is empty.
Variables ¶
var Version = "dev"
Version is the CLI version, overridden at build time via -ldflags. Set by main before any request is made, so the user agent is computed per call rather than frozen at init.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CloseSession ¶
CloseSession releases a session so fanout stops aiming at a socket nobody holds. Best-effort at shutdown — the server's reaper covers the case where this never runs, which is why a failure here is not worth surfacing.
func (*Client) CreateEndpoint ¶ added in v0.2.0
func (c *Client) CreateEndpoint( ctx context.Context, req CreateEndpointRequest, ) (*CreateEndpointResponse, error)
func (*Client) CreateSession ¶
func (c *Client) CreateSession( ctx context.Context, req CreateSessionRequest, ) (*CreateSessionResponse, error)
func (*Client) DeleteEndpoint ¶ added in v0.2.0
func (*Client) ListEndpoints ¶ added in v0.2.0
func (*Client) ListEvents ¶ added in v0.2.0
ListEvents returns a page of recent events, newest first.
The server takes only limit and offset, so any filtering by type or outcome happens in the caller. Pages are capped at 100 server-side.
type CreateEndpointRequest ¶ added in v0.2.0
type CreateEndpointResponse ¶ added in v0.2.0
CreateEndpointResponse carries the signing secret, which the API returns only on creation.
type CreateSessionRequest ¶
type CreateSessionResponse ¶
type CreateSessionResponse struct {
SessionID string `json:"session_id"`
Token string `json:"token"`
SigningSecret string `json:"signing_secret"`
WebSocketPath string `json:"websocket_path"`
Events []string `json:"events"`
// How often to cycle the connection. Server-dictated so deploys can
// drain sockets without stranding them.
ReconnectAfterSeconds int `json:"reconnect_after_seconds"`
}
type Event ¶ added in v0.2.0
type Event struct {
EventID string `json:"event_id"`
EventType string `json:"event_type"`
EntityType string `json:"entity_type"`
EntityID string `json:"entity_id"`
CreatedAt string `json:"created_at"`
Account string `json:"account"`
// Attempts is 0 when nothing was configured to receive the event. That
// distinction matters: it separates "nobody was listening" from "delivery
// was tried and failed", which otherwise look identical from outside.
Attempts int `json:"attempts"`
Success int `json:"success"`
Failed int `json:"failed"`
LastAttemptStatus *string `json:"last_attempt_status"`
LastAttemptHTTPStatus *int `json:"last_attempt_http_status"`
LastAttemptError *string `json:"last_attempt_error"`
LastAttemptAt *string `json:"last_attempt_at"`
}
Event is one webhook event and a summary of how its delivery went.
type EventsResponse ¶ added in v0.2.0
type ReplayRequest ¶
type ReplayRequest struct {
EventID string `json:"event_id,omitempty"`
}
type ReplayResponse ¶
type TriggerRequest ¶ added in v0.2.0
type TriggerRequest struct {
EventType string `json:"event_type"`
}