{"modulePath":"github.com/usebraid/braid","version":"v0.5.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package api\n\nPackage api serves the /api/v1 endpoints used by the web app.\n\n## Functions\n\n```go\nfunc SourceLink(base, version, commit string) string\n```\nSourceLink returns the URL of the source of the given build below base.\n\n## Types\n\n```go\ntype About struct {\n\tVersion   string `json:\"version\"`\n\tCommit    string `json:\"commit\"`\n\tSourceURL string `json:\"source_url\"` // link to exactly this version\n}\n```\nAbout describes the running build.\n\n```go\ntype AdminStats struct {\n\tUsers           []AdminUserStats `json:\"users\"`\n\tTotals          AdminTotals      `json:\"totals\"`\n\tRebuildingUsers int              `json:\"rebuilding_users\"`\n}\n```\nAdminStats is the response of GET /api/v1/admin/stats.\n\n```go\ntype AdminTotals struct {\n\tUsers       int64   `json:\"users\"`\n\tDevices     int64   `json:\"devices\"`\n\tSessions    int64   `json:\"sessions\"`\n\tStoredBytes int64   `json:\"stored_bytes\"`\n\tCostUSD     float64 `json:\"cost_usd\"`\n\tTokens      int64   `json:\"tokens\"`\n}\n```\nAdminTotals sums AdminUserStats.\n\n```go\ntype AdminUser struct {\n\tID          string     `json:\"id\"`\n\tEmail       string     `json:\"email\"`\n\tName        string     `json:\"name\"`\n\tIsAdmin     bool       `json:\"is_admin\"`\n\tDisabledAt  *time.Time `json:\"disabled_at\"`\n\tLastLoginAt *time.Time `json:\"last_login_at\"`\n\tLastSyncAt  *time.Time `json:\"last_sync_at\"`\n\tDevices     int        `json:\"devices\"`\n\tStoredBytes int64      `json:\"stored_bytes\"`\n}\n```\nAdminUser is a user as seen by an admin.\n\n```go\ntype AdminUserStats struct {\n\tAdminUser\n\tSessions       int64      `json:\"sessions\"`\n\tCostUSD        float64    `json:\"cost_usd\"`\n\tTokens         int64      `json:\"tokens\"`\n\tLastActivityAt *time.Time `json:\"last_activity_at\"`\n\tDeriveErrors   int64      `json:\"derive_errors\"`\n\tRebuilding     bool       `json:\"rebuilding\"`\n}\n```\nAdminUserStats is AdminUser plus the aggregates of the user's derived data (numbers only).\n\n```go\ntype AuditEntry struct {\n\tID            int64           `json:\"id\"`\n\tAt            time.Time       `json:\"at\"`\n\tAction        string          `json:\"action\"`\n\tActorUserID   *string         `json:\"actor_user_id\"`\n\tSubjectUserID *string         `json:\"subject_user_id\"`\n\tDeviceID      *string         `json:\"device_id\"`\n\tIP            *string         `json:\"ip\"`\n\tUserAgent     *string         `json:\"user_agent\"`\n\tDetail        json.RawMessage `json:\"detail\"`\n}\n```\nAuditEntry is one audit log row.\n\n```go\ntype AuditPage struct {\n\tEntries []AuditEntry `json:\"entries\"`\n\tNext    *int64       `json:\"next\"`\n}\n```\nAuditPage is one page of audit entries; Next is the cursor for the following page.\n\n```go\ntype AvatarFetch func(ctx context.Context, rawURL string) (body []byte, contentType string, err error)\n```\nAvatarFetch loads the image behind a stored picture URL: the body and its media type.\n\n```go\nfunc IssuerAvatarFetch(issuer string, rt http.RoundTripper) AvatarFetch\n```\nIssuerAvatarFetch 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.\n\n```go\ntype Device struct {\n\tID            string     `json:\"id\"`\n\tName          string     `json:\"name\"`\n\tHostname      string     `json:\"hostname\"`\n\tOS            string     `json:\"os\"`\n\tArch          string     `json:\"arch\"`\n\tOSUser        string     `json:\"os_user\"`\n\tDaemonVersion string     `json:\"daemon_version\"`\n\tCreatedAt     time.Time  `json:\"created_at\"`\n\tLastSeenAt    *time.Time `json:\"last_seen_at\"`\n\tLastSyncAt    *time.Time `json:\"last_sync_at\"`\n\tRevokedAt     *time.Time `json:\"revoked_at\"`\n\tStale         bool       `json:\"stale\"`\n}\n```\nDevice is one registered device.\n\n```go\ntype Handler struct {\n\t// contains filtered or unexported fields\n}\n```\nHandler serves /api/v1.\n\n```go\nfunc New(cfg config.Config, d *db.DB) *Handler\n```\nNew returns a Handler.\n\n```go\nfunc (h *Handler) Register(mux *http.ServeMux, auth *webauth.Auth)\n```\nRegister mounts the routes behind auth.\n\n```go\nfunc (h *Handler) WithAvatarFetch(f AvatarFetch) *Handler\n```\nWithAvatarFetch replaces how picture URLs are fetched (tests use a stub).\n\n```go\ntype Me struct {\n\tID      string `json:\"id\"`\n\tEmail   string `json:\"email\"`\n\tName    string `json:\"name\"`\n\tIsAdmin bool   `json:\"is_admin\"`\n\t// TimeZone is the effective zone (\"UTC\" when unset); TimeZoneSet is false until the user sets it.\n\tTimeZone    string `json:\"time_zone\"`\n\tTimeZoneSet bool   `json:\"time_zone_set\"`\n}\n```\nMe is the current user.\n\n","path":"github.com/usebraid/braid/internal/server/api","name":"api","synopsis":"Package api serves the /api/v1 endpoints used by the web app.","isRedistributable":true}
