Documentation
¶
Overview ¶
Package deskclient is the WB daemon's HTTP client for Sneat Dev Desk (spec/features/desk-connect). Every failure is a typed desk.ErrorCode; the text of a Desk response is never kept.
Index ¶
- Constants
- Variables
- func CodeOf(err error) desk.ErrorCode
- type Client
- func (client *Client) Heartbeat(ctx context.Context, request desk.HeartbeatRequest) error
- func (client *Client) Publish(ctx context.Context, request desk.SnapshotRequest) (desk.SnapshotReceipt, error)
- func (client *Client) Revoke(ctx context.Context) error
- func (client *Client) Self(ctx context.Context) (desk.MachineSelf, error)
- func (client *Client) Start(ctx context.Context, request desk.ConnectStartRequest) (desk.ConnectStartResponse, error)
- func (client *Client) Token(ctx context.Context, deviceCode string) (desk.ConnectTokenResponse, error)
- type Error
- type Options
Constants ¶
const ( DefaultConnectTimeout = 10 * time.Second DefaultTotalTimeout = 30 * time.Second )
Default timeouts.
Variables ¶
var ErrCredential = errors.New("desk credential file must be one private token")
ErrCredential is returned when the credential file is missing, not private, or not one token.
var ErrInvalidURL = errors.New("desk url must be https, or http on a loopback host, with no path")
ErrInvalidURL is returned for a Desk address a credential may not be sent to.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to one Desk origin.
func (*Client) Publish ¶
func (client *Client) Publish(ctx context.Context, request desk.SnapshotRequest) (desk.SnapshotReceipt, error)
Publish sends a snapshot gzip-encoded, refusing locally one over the bounds (desk-connect#req:bounded-payload).
func (*Client) Revoke ¶
Revoke deletes this machine's credential at Desk. A 404 means Desk no longer has the machine, which is what revoking asks for.
func (*Client) Start ¶
func (client *Client) Start(ctx context.Context, request desk.ConnectStartRequest) (desk.ConnectStartResponse, error)
Start opens a device grant (unauthenticated).
type Error ¶
type Error struct {
Code desk.ErrorCode
// RetryAfter is Desk's Retry-After for rate_limited, zero when absent.
RetryAfter time.Duration
// MinimumSchemaVersion is the version Desk requires for schema_unsupported.
MinimumSchemaVersion int
}
Error is a typed Desk failure.
type Options ¶
type Options struct {
// CredentialFile holds the machine credential; empty for the unauthenticated
// connect routes only.
CredentialFile string
Connect time.Duration
Total time.Duration
// Transport replaces the default transport (tests).
Transport http.RoundTripper
}
Options configures a Client.