Documentation
¶
Overview ¶
Package api serves the /api/v1 endpoints used by the web app.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SourceLink ¶
SourceLink returns the URL of the source of the given build below base.
Types ¶
type About ¶
type About struct {
Version string `json:"version"`
Commit string `json:"commit"`
SourceURL string `json:"source_url"` // link to exactly this version
}
About describes the running build.
type AdminStats ¶
type AdminStats struct {
Users []AdminUserStats `json:"users"`
Totals AdminTotals `json:"totals"`
RebuildingUsers int `json:"rebuilding_users"`
}
AdminStats is the response of GET /api/v1/admin/stats.
type AdminTotals ¶
type AdminTotals struct {
Users int64 `json:"users"`
Devices int64 `json:"devices"`
Sessions int64 `json:"sessions"`
StoredBytes int64 `json:"stored_bytes"`
CostUSD float64 `json:"cost_usd"`
Tokens int64 `json:"tokens"`
}
AdminTotals sums AdminUserStats.
type AdminUser ¶
type AdminUser struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
IsAdmin bool `json:"is_admin"`
DisabledAt *time.Time `json:"disabled_at"`
LastLoginAt *time.Time `json:"last_login_at"`
LastSyncAt *time.Time `json:"last_sync_at"`
Devices int `json:"devices"`
StoredBytes int64 `json:"stored_bytes"`
}
AdminUser is a user as seen by an admin.
type AdminUserStats ¶
type AdminUserStats struct {
AdminUser
Sessions int64 `json:"sessions"`
CostUSD float64 `json:"cost_usd"`
Tokens int64 `json:"tokens"`
LastActivityAt *time.Time `json:"last_activity_at"`
DeriveErrors int64 `json:"derive_errors"`
Rebuilding bool `json:"rebuilding"`
}
AdminUserStats is AdminUser plus the aggregates of the user's derived data (numbers only).
type AuditEntry ¶
type AuditEntry struct {
ID int64 `json:"id"`
At time.Time `json:"at"`
Action string `json:"action"`
ActorUserID *string `json:"actor_user_id"`
SubjectUserID *string `json:"subject_user_id"`
DeviceID *string `json:"device_id"`
IP *string `json:"ip"`
UserAgent *string `json:"user_agent"`
Detail json.RawMessage `json:"detail"`
}
AuditEntry is one audit log row.
type AuditPage ¶
type AuditPage struct {
Entries []AuditEntry `json:"entries"`
Next *int64 `json:"next"`
}
AuditPage is one page of audit entries; Next is the cursor for the following page.
type AvatarFetch ¶
type AvatarFetch func(ctx context.Context, rawURL string) (body []byte, contentType string, err error)
AvatarFetch loads the image behind a stored picture URL: the body and its media type.
func IssuerAvatarFetch ¶
func IssuerAvatarFetch(issuer string, rt http.RoundTripper) AvatarFetch
IssuerAvatarFetch fetches only https URLs on the issuer's origin (no SSRF to anything else), follows no redirects, and accepts at most 512 KiB of PNG, JPEG, WebP or GIF within 5 s. Errors never carry the URL, which may hold tokens.
type Device ¶
type Device struct {
ID string `json:"id"`
Name string `json:"name"`
Hostname string `json:"hostname"`
OS string `json:"os"`
Arch string `json:"arch"`
OSUser string `json:"os_user"`
DaemonVersion string `json:"daemon_version"`
CreatedAt time.Time `json:"created_at"`
LastSeenAt *time.Time `json:"last_seen_at"`
LastSyncAt *time.Time `json:"last_sync_at"`
RevokedAt *time.Time `json:"revoked_at"`
Stale bool `json:"stale"`
}
Device is one registered device.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves /api/v1.
func (*Handler) WithAvatarFetch ¶
func (h *Handler) WithAvatarFetch(f AvatarFetch) *Handler
WithAvatarFetch replaces how picture URLs are fetched (tests use a stub).
type Me ¶
type Me struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
IsAdmin bool `json:"is_admin"`
// TimeZone is the effective zone ("UTC" when unset); TimeZoneSet is false until the user sets it.
TimeZone string `json:"time_zone"`
TimeZoneSet bool `json:"time_zone_set"`
}
Me is the current user.