Documentation
¶
Overview ¶
Package api serves the JSON API under /api/v1. Handlers call the same services as the HTML handlers and only translate between JSON and models.
Index ¶
- Constants
- Variables
- func Allowed(w http.ResponseWriter, r *http.Request, need model.Rights) bool
- func CSRFToken(w http.ResponseWriter, r *http.Request)
- func CodeForStatus(status int) string
- func Decode(w http.ResponseWriter, r *http.Request, value any) bool
- func Error(w http.ResponseWriter, status int, code, message string)
- func FieldMessage(err error) string
- func JSON(w http.ResponseWriter, status int, value any)
- func NoContent(w http.ResponseWriter)
- func OpenAPI(w http.ResponseWriter, _ *http.Request)
- func ServiceError(w http.ResponseWriter, err error)
- func StreamDeadline(bearer model.Bearer, now time.Time) time.Time
- func ValidationError(w http.ResponseWriter, fields map[string]string)
- type Access
- type AccountHandler
- func (h *AccountHandler) ChangeEmail(w http.ResponseWriter, r *http.Request)
- func (h *AccountHandler) DeleteAccount(w http.ResponseWriter, r *http.Request)
- func (h *AccountHandler) DeleteAvatar(w http.ResponseWriter, r *http.Request)
- func (h *AccountHandler) SetEmailAlerts(w http.ResponseWriter, r *http.Request)
- func (h *AccountHandler) UpdateName(w http.ResponseWriter, r *http.Request)
- func (h *AccountHandler) UploadAvatar(w http.ResponseWriter, r *http.Request)
- type ActivityPage
- type AdminActivityEvent
- type AdminHandler
- type AdminMetrics
- type AdminNetwork
- type AdminOverview
- type AdminUser
- type AdminUserPage
- type AlertDestination
- type AlertDestinationList
- type AlertDestinationRequest
- type AlertsHandler
- type App
- type AppBackups
- type AppBucketRequest
- type AppDetail
- type AppList
- type AppMetrics
- type AppMetricsNow
- type AppPoint
- type AppUpdateRequest
- type AppsHandler
- func (h *AppsHandler) AddBucket(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) AppMetrics(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Backups(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Buckets(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) ComposeFile(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Create(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) CreateDeploy(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Databases(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Delete(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) DeleteBucket(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) DeletePassword(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) DeleteRegistry(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) DeleteRepo(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) DeleteRow(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) DeployEvents(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Domains(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Download(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) EditBucket(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Events(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Exec(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Get(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) GetBucket(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) GetDeploy(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) GetEnv(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) GetGitHub(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) GetGitHubBranches(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) GetGitHubRepos(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) GetInstant(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) GetIntegrations(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) InsertRow(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) List(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Logs(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Query(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Redeploy(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Registries(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) RemoveHook(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Rename(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) ReplaceEnv(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Restart(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Restore(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Rollback(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) RotateHook(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Rows(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) ServerMetrics(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) SetAppBucket(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) SetBackupSchedule(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) SetBucketKey(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) SetDomains(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) SetInstant(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) SetIntegrations(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) SetPassword(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) SetPinned(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) SetRegistry(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) SetRepo(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) SetSecurity(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) SetUptime(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Start(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) StartRestore(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Stop(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Tables(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) UpdateEnv(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) UpdateRow(w http.ResponseWriter, r *http.Request)
- func (h *AppsHandler) Uptime(w http.ResponseWriter, r *http.Request)
- type AuthHandler
- type AuthorizationServerMetadata
- type BackupSchedule
- type Billing
- type BillingHandler
- type Bucket
- type BucketKeyRequest
- type BucketList
- type BucketRequest
- type CIToken
- type CITokenList
- type CITokensHandler
- type CatalogDeploy
- type CatalogEntry
- type CatalogHandler
- type CatalogInstallRequest
- type CatalogList
- type CatalogVersion
- type Change
- type ClientRegistration
- type ComposeFile
- type Connection
- type ConnectionList
- type ConnectionsHandler
- type CreatedAlertDestination
- type CreatedApp
- type CreatedCIToken
- type CreatedServer
- type DaemonUpdates
- type DatabaseBackup
- type DatabaseBackups
- type Databases
- type Deploy
- type DeployHook
- type DeployMark
- type DeviceHandler
- type DeviceLogin
- type DomainCheck
- type DomainChecks
- type Download
- type DownloadRequest
- type EmailAlerts
- type Env
- type EnvVar
- type ErrorBody
- type ErrorDetail
- type ExecRequest
- type GitHub
- type GitHubBranches
- type GitHubInstallation
- type GitHubRepo
- type GitHubRepos
- type Handlers
- type InsertRequest
- type Instant
- type Integrations
- type IntegrationsRequest
- type InvitationPreview
- type Logs
- type Membership
- type MetaHandler
- type Middleware
- type Moment
- type NewPassword
- type OAuthError
- type OAuthHandler
- type Outage
- type Passkey
- type PasskeyList
- type PasskeyNameRequest
- type PasskeysHandler
- type PendingInvitation
- type Plan
- type PlanPrice
- type ProtectedResourceMetadata
- type QueryRequest
- type RegisteredClient
- type Registry
- type RegistryList
- type RemovedServer
- type ReplacedEnv
- type RepoRequest
- type Restore
- type RestoreRequest
- type RightsRequest
- type Route
- type RowRequest
- type Seats
- type SecretOn
- type SecretServers
- type SecurityRequest
- type Server
- type ServerAppMetrics
- type ServerList
- type ServerMetrics
- type ServerMetricsNow
- type ServerPoint
- type ServersHandler
- func (h *ServersHandler) Create(w http.ResponseWriter, r *http.Request)
- func (h *ServersHandler) Delete(w http.ResponseWriter, r *http.Request)
- func (h *ServersHandler) Events(w http.ResponseWriter, r *http.Request)
- func (h *ServersHandler) List(w http.ResponseWriter, r *http.Request)
- func (h *ServersHandler) NewInstall(w http.ResponseWriter, r *http.Request)
- func (h *ServersHandler) Rename(w http.ResponseWriter, r *http.Request)
- func (h *ServersHandler) Update(w http.ResponseWriter, r *http.Request)
- type Session
- type SessionList
- type SessionsHandler
- type StatusCounts
- type StatusHandler
- type StatusIssue
- type StatusResponse
- type StatusUpdate
- type Subscription
- type TableRows
- type TokenHandler
- type TokenResponse
- type URLResponse
- type Uptime
- type UptimeDomain
- type UptimeRequest
- type User
- type UserResponse
- type VersionHandler
- type VersionInfo
- type Workspace
- type WorkspaceDetail
- type WorkspaceEvent
- type WorkspaceHandler
- func (h *WorkspaceHandler) Activity(w http.ResponseWriter, r *http.Request)
- func (h *WorkspaceHandler) ChangeRole(w http.ResponseWriter, r *http.Request)
- func (h *WorkspaceHandler) Create(w http.ResponseWriter, r *http.Request)
- func (h *WorkspaceHandler) Delete(w http.ResponseWriter, r *http.Request)
- func (h *WorkspaceHandler) Invite(w http.ResponseWriter, r *http.Request)
- func (h *WorkspaceHandler) Leave(w http.ResponseWriter, r *http.Request)
- func (h *WorkspaceHandler) List(w http.ResponseWriter, r *http.Request)
- func (h *WorkspaceHandler) RemoveMember(w http.ResponseWriter, r *http.Request)
- func (h *WorkspaceHandler) ResendInvitation(w http.ResponseWriter, r *http.Request)
- func (h *WorkspaceHandler) RevokeInvitation(w http.ResponseWriter, r *http.Request)
- func (h *WorkspaceHandler) Show(w http.ResponseWriter, r *http.Request)
- func (h *WorkspaceHandler) UpdateName(w http.ResponseWriter, r *http.Request)
- type WorkspaceInvitationHandler
- type WorkspaceMember
- type WorkspacePermissions
- type Wrap
Constants ¶
const ( MaxQueryLimit = 1000 QueryLimitMessage = "Choose between 1 and 1000 rows." )
MaxQueryLimit is the most rows a read returns; QueryLimitMessage explains a limit outside 1 to MaxQueryLimit.
const ( // DeviceGrantType is the grant of RFC 8628: a poll with the device code. DeviceGrantType = "urn:ietf:params:oauth:grant-type:device_code" // RefreshGrantType exchanges a refresh token for new tokens. RefreshGrantType = "refresh_token" // CodeGrantType trades the code of an AI agent's approval, with its // PKCE verifier. CodeGrantType = "authorization_code" )
const ( // DefaultActivityLimit is the page size of workspace activity. DefaultActivityLimit = 50 // MaxActivityLimit is the largest page of workspace activity. MaxActivityLimit = 200 // ActivityLimitMessage explains an invalid activity limit. ActivityLimitMessage = "Limit must be a number between 1 and 200." )
const AdminInviteMessage = "A connection or CI token invites only members. Invite an admin in the web: Settings, Team."
AdminInviteMessage is the answer when a connection or CI token invites an admin.
const MaxAvatarBytes = 10 << 20
MaxAvatarBytes caps an avatar upload request.
const MaxBodyBytes = 1 << 20
MaxBodyBytes caps every JSON request body.
const NoToken model.Rights = 0
NoToken is the right of a route that connections and CI tokens may not call: account security, deletions of the account and workspace, roles, billing, admin, and the steps of signing in. A signed-in browser, or for signing in nobody, calls it.
const ProtectedResourcePath = "/.well-known/oauth-protected-resource" + service.MCPPath
ProtectedResourcePath is where /mcp's metadata is: the well-known path with the resource's path after it (RFC 9728, section 3.1).
const TrialEndedMessage = "Your trial has ended. Subscribe under Billing to make changes. Your apps keep running, and you can still stop and start them."
TrialEndedMessage answers a change to a workspace whose trial has ended.
const ValidationMessage = "Check the highlighted fields and try again."
ValidationMessage is the message of every validation_failed error.
Variables ¶
var ( // ErrInvalidCursor is returned for an activity cursor that does not // decode or points to an event that no longer exists. ErrInvalidCursor = errors.New("invalid activity cursor") )
var OpenAPIDocument []byte
OpenAPIDocument is the OpenAPI 3.1 description of this API. It is rendered for the modules of this project and kept in sync with Routes by openapi_test.go.
Functions ¶
func Allowed ¶
Allowed answers 403 missing_right and reports false when the connection or CI token of the request lacks a right of need. Sessions are allowed. Routes name their right in Routes; a handler asks only when the body decides, like SQL that writes.
func CSRFToken ¶
func CSRFToken(w http.ResponseWriter, r *http.Request)
CSRFToken returns the CSRF token of the request for a browser frontend that signs in with the session cookie. CSRFProtection sets the csrf_token cookie on this GET when it is missing; the cookie stays HttpOnly, so the frontend sends this value as the X-CSRF-Token header instead.
func CodeForStatus ¶
CodeForStatus returns the default code for a status, used by middleware errors that have no more specific code.
func Decode ¶
Decode reads one JSON object from the request body into value. A request whose Content-Type is not application/json gets a 415 unsupported_media_type envelope, so a cross-site page cannot send a JSON body without a CORS preflight. Unknown fields, trailing data, and bodies over MaxBodyBytes are rejected with a 400 invalid_body envelope. On failure Decode writes the envelope and returns false.
func Error ¶
func Error(w http.ResponseWriter, status int, code, message string)
Error writes the error envelope with a code and a message.
func FieldMessage ¶
FieldMessage turns a validation error into a sentence for the fields map.
func JSON ¶
func JSON(w http.ResponseWriter, status int, value any)
JSON writes value as a JSON response with the given status.
func ServiceError ¶
func ServiceError(w http.ResponseWriter, err error)
ServiceError maps a service or repository error to its status and code. Unknown errors are logged and answered with 500 internal.
func StreamDeadline ¶
StreamDeadline is when the stream of a connection or CI token ends: when its access token does, and at the latest an hour from now.
func ValidationError ¶
func ValidationError(w http.ResponseWriter, fields map[string]string)
ValidationError writes a 422 validation_failed envelope with one message per invalid field.
Types ¶
type Access ¶
type Access struct {
PlanID string `json:"plan_id"`
State access.State `json:"state"`
TrialEndsAt *time.Time `json:"trial_ends_at"`
AccessEndsAt *time.Time `json:"access_ends_at"`
}
Access is the resolved product access of a subscription: the plan, the state, and the trial or grace end.
type AccountHandler ¶
type AccountHandler struct {
// contains filtered or unexported fields
}
AccountHandler serves profile, email, avatar and account deletion.
func NewAccountHandler ¶
func NewAccountHandler(authService *service.AuthService, userService *service.UserService, fileService *service.FileService) *AccountHandler
func (*AccountHandler) ChangeEmail ¶
func (h *AccountHandler) ChangeEmail(w http.ResponseWriter, r *http.Request)
ChangeEmail sends a verification link to the new address. The address changes once the link is verified.
func (*AccountHandler) DeleteAccount ¶
func (h *AccountHandler) DeleteAccount(w http.ResponseWriter, r *http.Request)
DeleteAccount deletes the account after the caller confirms its email address. Every session of the account ends with it.
func (*AccountHandler) DeleteAvatar ¶
func (h *AccountHandler) DeleteAvatar(w http.ResponseWriter, r *http.Request)
DeleteAvatar removes the avatar.
func (*AccountHandler) SetEmailAlerts ¶
func (h *AccountHandler) SetEmailAlerts(w http.ResponseWriter, r *http.Request)
SetEmailAlerts turns the email alerts of the signed-in user on or off.
func (*AccountHandler) UpdateName ¶
func (h *AccountHandler) UpdateName(w http.ResponseWriter, r *http.Request)
UpdateName changes the display name and returns the user.
func (*AccountHandler) UploadAvatar ¶
func (h *AccountHandler) UploadAvatar(w http.ResponseWriter, r *http.Request)
UploadAvatar replaces the avatar with the multipart field "file".
type ActivityPage ¶
type ActivityPage struct {
Items []WorkspaceEvent `json:"items"`
NextCursor *string `json:"next_cursor"`
}
ActivityPage is one page of workspace activity. NextCursor continues after the last event and is null on the last page.
func NewActivityPage ¶
func NewActivityPage(workspaces *service.WorkspaceService, member *model.WorkspaceMember, filter model.ActivityFilter, cursor string, limit int) (ActivityPage, error)
NewActivityPage loads up to limit events of the member's workspace that match the filter, newest first, after the event cursor points to. An empty cursor starts with the newest event. Members who may not view the activity get service.ErrActivityPermission. A cursor that does not decode or no longer exists returns ErrInvalidCursor.
type AdminActivityEvent ¶
type AdminActivityEvent struct {
ID string `json:"id"`
ActorUserID *string `json:"actor_user_id"`
ActorEmail string `json:"actor_email"`
WorkspaceID *string `json:"workspace_id"`
Action string `json:"action"`
TargetType string `json:"target_type"`
TargetID string `json:"target_id"`
Metadata string `json:"metadata"`
CreatedAt time.Time `json:"created_at"`
}
AdminActivityEvent is one entry of the admin activity.
type AdminHandler ¶
type AdminHandler struct {
// contains filtered or unexported fields
}
AdminHandler serves the admin overview data and session revocation. Impersonation stays in the HTML admin.
func NewAdminHandler ¶
func NewAdminHandler(admin *service.AdminService) *AdminHandler
func (*AdminHandler) OldDomain ¶
func (h *AdminHandler) OldDomain(w http.ResponseWriter, r *http.Request)
OldDomain returns what still arrives on the old domains of the hub over the last days.
func (*AdminHandler) RevokeUserSessions ¶
func (h *AdminHandler) RevokeUserSessions(w http.ResponseWriter, r *http.Request)
RevokeUserSessions signs a user out everywhere.
func (*AdminHandler) Users ¶
func (h *AdminHandler) Users(w http.ResponseWriter, r *http.Request)
Users returns the admin overview: metrics, one page of users filtered by the query parameter, and the latest activity events.
type AdminMetrics ¶
type AdminMetrics struct {
Users int `json:"users"`
VerifiedUsers int `json:"verified_users"`
Workspaces int `json:"workspaces"`
PaidWorkspaces int `json:"paid_workspaces"`
ActiveSessions int `json:"active_sessions"`
}
AdminMetrics are the counters of the admin overview.
type AdminNetwork ¶
type AdminNetwork struct {
Deploys int `json:"deploys"`
Apps int `json:"apps"`
Servers int `json:"servers"`
HostedWorkspaces int `json:"hosted_workspaces"`
SelfHosted int `json:"self_hosted"`
}
AdminNetwork is everything moin runs: hosted and self-hosted.
type AdminOverview ¶
type AdminOverview struct {
Metrics AdminMetrics `json:"metrics"`
Users AdminUserPage `json:"users"`
Events []AdminActivityEvent `json:"events"`
// Network is only on the hosted hub.
Network *AdminNetwork `json:"network,omitempty"`
}
AdminOverview is the JSON shape of model.AdminOverview.
func NewAdminOverview ¶
func NewAdminOverview(overview *model.AdminOverview) AdminOverview
NewAdminOverview converts the admin overview into its JSON shape.
type AdminUser ¶
type AdminUser struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
EmailVerifiedAt *time.Time `json:"email_verified_at"`
GitHubLogin string `json:"github_login"`
CreatedAt time.Time `json:"created_at"`
WorkspaceCount int `json:"workspace_count"`
ActiveSessionCount int `json:"active_session_count"`
IsAdmin bool `json:"is_admin"`
}
AdminUser is one row of the admin user list.
type AdminUserPage ¶
type AdminUserPage struct {
Items []AdminUser `json:"items"`
Query string `json:"query"`
Page int `json:"page"`
TotalPages int `json:"total_pages"`
TotalUsers int `json:"total_users"`
}
AdminUserPage is one page of the admin user list.
type AlertDestination ¶
type AlertDestination struct {
ID string `json:"id"`
Name string `json:"name"`
Kind string `json:"kind"`
Hint string `json:"hint"`
ChatID string `json:"chat_id"`
Events []string `json:"events"`
// Failing says sends to it fail since failing_since, with last_error.
Failing bool `json:"failing"`
FailingSince *time.Time `json:"failing_since"`
LastError string `json:"last_error"`
LastSentAt *time.Time `json:"last_sent_at"`
CreatedAt time.Time `json:"created_at"`
}
AlertDestination is a destination without its URL, token or signing secret: hint shows its host and last characters.
func NewAlertDestination ¶
func NewAlertDestination(destination model.AlertDestination) AlertDestination
NewAlertDestination is the JSON shape of a destination.
type AlertDestinationList ¶
type AlertDestinationList struct {
Items []AlertDestination `json:"items"`
}
AlertDestinationList is the answer of GET /api/v1/alert-destinations.
func NewAlertDestinationList ¶
func NewAlertDestinationList(destinations []model.AlertDestination) AlertDestinationList
NewAlertDestinationList is the JSON shape of the destinations.
type AlertDestinationRequest ¶
type AlertDestinationRequest struct {
Kind string `json:"kind"`
Name string `json:"name"`
URL string `json:"url"`
BotToken string `json:"bot_token"`
ChatID string `json:"chat_id"`
Events []string `json:"events"`
}
AlertDestinationRequest is the body of POST /api/v1/alert-destinations.
type AlertsHandler ¶
type AlertsHandler struct {
// contains filtered or unexported fields
}
AlertsHandler serves the alert destinations of a workspace.
func NewAlertsHandler ¶
func NewAlertsHandler(alerts *service.AlertService) *AlertsHandler
func (*AlertsHandler) Create ¶
func (h *AlertsHandler) Create(w http.ResponseWriter, r *http.Request)
Create adds an alert destination.
func (*AlertsHandler) Delete ¶
func (h *AlertsHandler) Delete(w http.ResponseWriter, r *http.Request)
Delete removes an alert destination.
func (*AlertsHandler) List ¶
func (h *AlertsHandler) List(w http.ResponseWriter, r *http.Request)
List returns the alert destinations of the workspace.
func (*AlertsHandler) Test ¶
func (h *AlertsHandler) Test(w http.ResponseWriter, r *http.Request)
Test sends a test alert to a destination.
type App ¶
type App struct {
ID string `json:"id"`
Name string `json:"name"`
ServerID string `json:"server_id"`
ServerName string `json:"server_name"`
LatestNumber int `json:"latest_number"`
LatestStatus string `json:"latest_status"`
LiveNumber int `json:"live_number"`
Domains []string `json:"domains"`
Canonical string `json:"canonical"`
// Password says the app's password is on: its domains and its
// instant address ask for it. The password itself is never here.
Password bool `json:"password"`
// ServiceDomains are the domains of the app's other services.
ServiceDomains map[string][]string `json:"service_domains"`
// Instant is the app's instant address, "" when it has none;
// InstantProvider its provider or off.
Instant string `json:"instant"`
InstantProvider string `json:"instant_provider"`
// Stopped is set when the app was stopped; a deploy, restart or start
// runs it again.
Stopped bool `json:"stopped"`
// ChangesWaiting counts the changes saved since the live deploy
// started (env vars, domains, password, instant address, bucket); a
// restart applies them. Only GET /apps/{app} fills it.
ChangesWaiting int `json:"changes_waiting"`
// Repo and Branch are the GitHub repo the app follows, if any.
Repo string `json:"repo"`
Branch string `json:"branch"`
AutoDeploy bool `json:"auto_deploy"`
// Pinned keeps the app above the others that run fine, in every list.
Pinned bool `json:"pinned"`
// Bucket is the bucket the app backs up to; empty uses the
// workspace's default bucket.
Bucket string `json:"bucket"`
// Hook says the app has a deploy hook URL; the URL itself is shown
// only once, when it is made.
Hook bool `json:"hook"`
// DeployFrom is where new versions come from, one at a time: ci (the
// deploy hook, with the compose file from the linked repo when there
// is one) or github (the linked repo); empty while neither is set up.
// Making a hook or turning deploy on push on switches it.
DeployFrom string `json:"deploy_from"`
// HookImage is the image the deploy hook deploys new tags of: the one
// running now, without its tag. Empty while the app runs from its
// repo; the hook then deploys nothing until an image is deployed by
// hand.
HookImage string `json:"hook_image"`
// Catalog is the slug of the catalog entry the app was installed
// from; empty for an app of your own.
Catalog string `json:"catalog"`
CreatedAt time.Time `json:"created_at"`
}
App is the public JSON shape of an app.
type AppBackups ¶
type AppBackups struct {
Bucket string `json:"bucket"`
BackupSchedule
Databases []DatabaseBackups `json:"databases"`
}
AppBackups is the answer of GET /api/v1/apps/{app}/backups: the bucket the copies go to, the user's own, the schedule and each database.
func NewAppBackups ¶
func NewAppBackups(apps *service.AppService, app *model.App, databases []service.DatabaseBackups) AppBackups
NewAppBackups is the JSON shape of an app's backups.
type AppBucketRequest ¶
type AppBucketRequest struct {
Bucket string `json:"bucket"`
}
AppBucketRequest is the body of PUT /api/v1/apps/{app}/bucket. An empty bucket follows the workspace's default bucket.
type AppList ¶
type AppList struct {
Items []App `json:"items"`
}
AppList is the answer of GET /api/v1/apps and every event of GET /api/v1/apps/events.
type AppMetrics ¶
type AppMetrics struct {
App string `json:"app"`
Server string `json:"server"`
ServerOnline bool `json:"server_online"`
Range string `json:"range"`
StepSeconds int `json:"step_seconds"`
Now *AppMetricsNow `json:"now"`
Points []AppPoint `json:"points"`
Deploys []DeployMark `json:"deploys"`
}
AppMetrics is the answer of GET /api/v1/apps/{app}/metrics: the app now, its points over the range and the deploys that went live in it.
func NewAppMetrics ¶
func NewAppMetrics(app *model.App, metrics service.AppMetrics) AppMetrics
NewAppMetrics is the JSON shape of an app's metrics.
type AppMetricsNow ¶
type AppMetricsNow struct {
At time.Time `json:"at"`
CPU float64 `json:"cpu"`
MemoryUsed uint64 `json:"memory_used"`
MemoryLimit uint64 `json:"memory_limit"`
NetRx float64 `json:"net_rx"`
NetTx float64 `json:"net_tx"`
Containers int `json:"containers"`
}
AppMetricsNow is the newest sample of an app's running containers added up. CPU is the app's share of the whole server in percent; a memory limit of 0 means none.
type AppPoint ¶
type AppPoint struct {
At time.Time `json:"at"`
CPU float64 `json:"cpu"`
Memory uint64 `json:"memory"`
NetRx float64 `json:"net_rx"`
NetTx float64 `json:"net_tx"`
}
AppPoint is an app at one point of a chart.
type AppUpdateRequest ¶
type AppUpdateRequest struct {
Version string `json:"version"`
}
AppUpdateRequest updates a catalog app; an empty version is the newest.
type AppsHandler ¶
type AppsHandler struct {
// contains filtered or unexported fields
}
AppsHandler serves apps, their deploys, logs and env. The web UI, the CLI and the TUI all use it.
func NewAppsHandler ¶
func NewAppsHandler(apps *service.AppService) *AppsHandler
func (*AppsHandler) AddBucket ¶
func (h *AppsHandler) AddBucket(w http.ResponseWriter, r *http.Request)
AddBucket checks and stores a new bucket.
func (*AppsHandler) AppMetrics ¶
func (h *AppsHandler) AppMetrics(w http.ResponseWriter, r *http.Request)
AppMetrics returns the metrics of an app over ?range=1h, 24h, 7d or 30d.
func (*AppsHandler) Backups ¶
func (h *AppsHandler) Backups(w http.ResponseWriter, r *http.Request)
Backups lists the backups of an app's databases with their moments.
func (*AppsHandler) Buckets ¶
func (h *AppsHandler) Buckets(w http.ResponseWriter, r *http.Request)
Buckets lists the workspace's buckets, the default first.
func (*AppsHandler) ComposeFile ¶
func (h *AppsHandler) ComposeFile(w http.ResponseWriter, r *http.Request)
ComposeFile answers the compose file of the app's live deploy.
func (*AppsHandler) Create ¶
func (h *AppsHandler) Create(w http.ResponseWriter, r *http.Request)
Create adds an app on a server.
func (*AppsHandler) CreateDeploy ¶
func (h *AppsHandler) CreateDeploy(w http.ResponseWriter, r *http.Request)
CreateDeploy starts a deploy: {"image": "..."} deploys an image built elsewhere, with the compose file of "ref" in the linked repo, its branch by default; {"ref": "..."} alone a branch, tag or commit of the linked repo, built on the server.
func (*AppsHandler) Databases ¶
func (h *AppsHandler) Databases(w http.ResponseWriter, r *http.Request)
Databases lists the databases of the app's live deploy: SQLite files and Postgres services.
func (*AppsHandler) Delete ¶
func (h *AppsHandler) Delete(w http.ResponseWriter, r *http.Request)
Delete stops the app on its server and removes it. Its data stays there. ?confirm= is its name, typed out.
func (*AppsHandler) DeleteBucket ¶
func (h *AppsHandler) DeleteBucket(w http.ResponseWriter, r *http.Request)
DeleteBucket removes a bucket nothing uses; ?confirm= is its name.
func (*AppsHandler) DeletePassword ¶
func (h *AppsHandler) DeletePassword(w http.ResponseWriter, r *http.Request)
DeletePassword turns the app's password off: no domain asks for one.
func (*AppsHandler) DeleteRegistry ¶
func (h *AppsHandler) DeleteRegistry(w http.ResponseWriter, r *http.Request)
DeleteRegistry removes the login for one registry host.
func (*AppsHandler) DeleteRepo ¶
func (h *AppsHandler) DeleteRepo(w http.ResponseWriter, r *http.Request)
DeleteRepo stops the app from following its repo.
func (*AppsHandler) DeleteRow ¶
func (h *AppsHandler) DeleteRow(w http.ResponseWriter, r *http.Request)
DeleteRow deletes one row.
func (*AppsHandler) DeployEvents ¶
func (h *AppsHandler) DeployEvents(w http.ResponseWriter, r *http.Request)
DeployEvents streams a deploy: a line event per log line, then one done event with the deploy. A finished deploy streams its whole log at once.
func (*AppsHandler) Domains ¶
func (h *AppsHandler) Domains(w http.ResponseWriter, r *http.Request)
Domains checks the DNS of every domain of the app.
func (*AppsHandler) Download ¶
func (h *AppsHandler) Download(w http.ResponseWriter, r *http.Request)
Download signs a link to a copy of a database in the app's bucket.
func (*AppsHandler) EditBucket ¶
func (h *AppsHandler) EditBucket(w http.ResponseWriter, r *http.Request)
EditBucket changes a bucket.
func (*AppsHandler) Events ¶
func (h *AppsHandler) Events(w http.ResponseWriter, r *http.Request)
Events streams the app list: once on connect and again after every change.
func (*AppsHandler) Exec ¶
func (h *AppsHandler) Exec(w http.ResponseWriter, r *http.Request)
Exec runs a command in a container of the app and answers with server- sent events: "output" with each piece the command writes, then "done" with how it ended, or "error". A request refused before it runs answers with the usual error envelope instead.
func (*AppsHandler) Get ¶
func (h *AppsHandler) Get(w http.ResponseWriter, r *http.Request)
Get returns an app with its newest deploys.
func (*AppsHandler) GetBucket ¶
func (h *AppsHandler) GetBucket(w http.ResponseWriter, r *http.Request)
GetBucket returns one bucket.
func (*AppsHandler) GetDeploy ¶
func (h *AppsHandler) GetDeploy(w http.ResponseWriter, r *http.Request)
GetDeploy returns one deploy with its log.
func (*AppsHandler) GetEnv ¶
func (h *AppsHandler) GetEnv(w http.ResponseWriter, r *http.Request)
GetEnv lists the env vars by key, without their values.
func (*AppsHandler) GetGitHub ¶
func (h *AppsHandler) GetGitHub(w http.ResponseWriter, r *http.Request)
GetGitHub returns the installations and the links that connect GitHub.
func (*AppsHandler) GetGitHubBranches ¶
func (h *AppsHandler) GetGitHubBranches(w http.ResponseWriter, r *http.Request)
GetGitHubBranches lists the branches of a repo, the default branch first.
func (*AppsHandler) GetGitHubRepos ¶
func (h *AppsHandler) GetGitHubRepos(w http.ResponseWriter, r *http.Request)
GetGitHubRepos lists the repos moin may read.
func (*AppsHandler) GetInstant ¶
func (h *AppsHandler) GetInstant(w http.ResponseWriter, r *http.Request)
GetInstant answers the app's instant address, without the password.
func (*AppsHandler) GetIntegrations ¶
func (h *AppsHandler) GetIntegrations(w http.ResponseWriter, r *http.Request)
GetIntegrations says which keys are stored.
func (*AppsHandler) InsertRow ¶
func (h *AppsHandler) InsertRow(w http.ResponseWriter, r *http.Request)
InsertRow adds one row.
func (*AppsHandler) List ¶
func (h *AppsHandler) List(w http.ResponseWriter, r *http.Request)
List returns the apps in the order every client shows: what needs you, what deploys, pinned apps, then the rest by name.
func (*AppsHandler) Logs ¶
func (h *AppsHandler) Logs(w http.ResponseWriter, r *http.Request)
Logs returns the last lines of the app's containers from its server.
func (*AppsHandler) Query ¶
func (h *AppsHandler) Query(w http.ResponseWriter, r *http.Request)
Query runs SQL. A read cannot change anything; write runs it in one transaction.
func (*AppsHandler) Redeploy ¶
func (h *AppsHandler) Redeploy(w http.ResponseWriter, r *http.Request)
Redeploy builds the newest source again with the env as it is now.
func (*AppsHandler) Registries ¶
func (h *AppsHandler) Registries(w http.ResponseWriter, r *http.Request)
Registries lists the registry logins daemons use to pull private images.
func (*AppsHandler) RemoveHook ¶
func (h *AppsHandler) RemoveHook(w http.ResponseWriter, r *http.Request)
RemoveHook turns the app's deploy hook off; its URL stops working.
func (*AppsHandler) Rename ¶
func (h *AppsHandler) Rename(w http.ResponseWriter, r *http.Request)
Rename gives an app a new name and answers it. Links name the app by its name, so they follow it; its data, backups and instant address stay, and the next restart names its containers after it.
func (*AppsHandler) ReplaceEnv ¶
func (h *AppsHandler) ReplaceEnv(w http.ResponseWriter, r *http.Request)
ReplaceEnv makes the sent env vars the app's, all at once: keys not sent are removed. The next deploy gets them.
func (*AppsHandler) Restart ¶
func (h *AppsHandler) Restart(w http.ResponseWriter, r *http.Request)
Restart starts the live deploy again with the env and domains as they are now.
func (*AppsHandler) Restore ¶
func (h *AppsHandler) Restore(w http.ResponseWriter, r *http.Request)
Restore says how a restore stands.
func (*AppsHandler) Rollback ¶
func (h *AppsHandler) Rollback(w http.ResponseWriter, r *http.Request)
Rollback starts an earlier successful release again.
func (*AppsHandler) RotateHook ¶
func (h *AppsHandler) RotateHook(w http.ResponseWriter, r *http.Request)
RotateHook gives the app a new deploy hook URL; the old one stops working.
func (*AppsHandler) Rows ¶
func (h *AppsHandler) Rows(w http.ResponseWriter, r *http.Request)
Rows returns one page of a table, newest first. Rows are app data, as strong as secrets, so a connection or CI token needs env.
func (*AppsHandler) ServerMetrics ¶
func (h *AppsHandler) ServerMetrics(w http.ResponseWriter, r *http.Request)
ServerMetrics returns the metrics of a server over ?range=1h, 24h, 7d or 30d.
func (*AppsHandler) SetAppBucket ¶
func (h *AppsHandler) SetAppBucket(w http.ResponseWriter, r *http.Request)
SetAppBucket moves an app's new backups to a bucket.
func (*AppsHandler) SetBackupSchedule ¶
func (h *AppsHandler) SetBackupSchedule(w http.ResponseWriter, r *http.Request)
SetBackupSchedule sets how often an app is copied and how long each copy stays.
func (*AppsHandler) SetBucketKey ¶
func (h *AppsHandler) SetBucketKey(w http.ResponseWriter, r *http.Request)
SetBucketKey hands the secret key of a bucket to one more server, which checks the bucket with it and keeps it.
func (*AppsHandler) SetDomains ¶
func (h *AppsHandler) SetDomains(w http.ResponseWriter, r *http.Request)
SetDomains replaces the domains and applies them to the live deploy.
func (*AppsHandler) SetInstant ¶
func (h *AppsHandler) SetInstant(w http.ResponseWriter, r *http.Request)
SetInstant picks the provider of the app's instant address, or off.
func (*AppsHandler) SetIntegrations ¶
func (h *AppsHandler) SetIntegrations(w http.ResponseWriter, r *http.Request)
SetIntegrations stores the Cloudflare API token and hands the Tailscale key to a server.
func (*AppsHandler) SetPassword ¶
func (h *AppsHandler) SetPassword(w http.ResponseWriter, r *http.Request)
SetPassword turns the app's password on for its domains and its instant address. Without a password moin makes one and answers it, the one time it shows it.
func (*AppsHandler) SetPinned ¶
func (h *AppsHandler) SetPinned(w http.ResponseWriter, r *http.Request)
SetPinned pins or unpins an app: {"pinned": true}.
func (*AppsHandler) SetRegistry ¶
func (h *AppsHandler) SetRegistry(w http.ResponseWriter, r *http.Request)
SetRegistry hands the login for one registry host to a server, which keeps it; the hub keeps the host and the username.
func (*AppsHandler) SetRepo ¶
func (h *AppsHandler) SetRepo(w http.ResponseWriter, r *http.Request)
SetRepo makes the app follow a repo and branch.
func (*AppsHandler) SetSecurity ¶
func (h *AppsHandler) SetSecurity(w http.ResponseWriter, r *http.Request)
SetSecurity sets how a server is reached and locked down, and answers the server with what its daemon set up.
func (*AppsHandler) SetUptime ¶
func (h *AppsHandler) SetUptime(w http.ResponseWriter, r *http.Request)
SetUptime changes the path of a domain's visit or pauses it.
func (*AppsHandler) Start ¶
func (h *AppsHandler) Start(w http.ResponseWriter, r *http.Request)
Start runs a stopped app again.
func (*AppsHandler) StartRestore ¶
func (h *AppsHandler) StartRestore(w http.ResponseWriter, r *http.Request)
StartRestore checks the moment and has the daemon put the database back to it, on its own: 202 with the restore to follow.
func (*AppsHandler) Stop ¶
func (h *AppsHandler) Stop(w http.ResponseWriter, r *http.Request)
Stop stops the app's containers. Its data stays.
func (*AppsHandler) Tables ¶
func (h *AppsHandler) Tables(w http.ResponseWriter, r *http.Request)
Tables lists the tables of a database with columns and row counts.
func (*AppsHandler) UpdateEnv ¶
func (h *AppsHandler) UpdateEnv(w http.ResponseWriter, r *http.Request)
UpdateEnv sets and removes env vars. The next deploy gets them.
func (*AppsHandler) UpdateRow ¶
func (h *AppsHandler) UpdateRow(w http.ResponseWriter, r *http.Request)
UpdateRow sets one column of one row.
func (*AppsHandler) Uptime ¶
func (h *AppsHandler) Uptime(w http.ResponseWriter, r *http.Request)
Uptime returns the uptime of every domain of an app.
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
AuthHandler serves sign-in, onboarding, logout and the account summary.
func NewAuthHandler ¶
func NewAuthHandler(authService *service.AuthService, userService *service.UserService, workspaceService *service.WorkspaceService) *AuthHandler
func (*AuthHandler) Account ¶
func (h *AuthHandler) Account(w http.ResponseWriter, r *http.Request)
Account returns the signed-in user, whether onboarding is still open, the workspaces the user belongs to, and whether the session belongs to an operator. Subscriptions belong to workspaces and are read through the workspace billing endpoint.
func (*AuthHandler) CompleteOnboarding ¶
func (h *AuthHandler) CompleteOnboarding(w http.ResponseWriter, r *http.Request)
CompleteOnboarding sets the name of a new account and creates its first workspace when the user has none yet, named workspace_name or "<name>'s Workspace" without one. An available invitation for the account's email address skips the default workspace, like the pending invitation of the web sign-in, because the account joins that workspace next.
func (*AuthHandler) Logout ¶
func (h *AuthHandler) Logout(w http.ResponseWriter, r *http.Request)
Logout ends the cookie session and clears its cookie.
func (*AuthHandler) VerifyEmailChange ¶
func (h *AuthHandler) VerifyEmailChange(w http.ResponseWriter, r *http.Request)
VerifyEmailChange consumes an email change token, moves the pending address to the account and returns the user. Like the link on the web, it ends every session of the user but the caller's own, when the caller is signed in as that user.
type AuthorizationServerMetadata ¶
type AuthorizationServerMetadata struct {
Issuer string `json:"issuer"`
AuthorizationEndpoint string `json:"authorization_endpoint"`
TokenEndpoint string `json:"token_endpoint"`
RegistrationEndpoint string `json:"registration_endpoint"`
RevocationEndpoint string `json:"revocation_endpoint"`
ResponseTypesSupported []string `json:"response_types_supported"`
GrantTypesSupported []string `json:"grant_types_supported"`
CodeChallengeMethodsSupported []string `json:"code_challenge_methods_supported"`
TokenEndpointAuthMethodsSupported []string `json:"token_endpoint_auth_methods_supported"`
RevocationEndpointAuthMethodsSupported []string `json:"revocation_endpoint_auth_methods_supported"`
AuthorizationResponseISSParameterSupported bool `json:"authorization_response_iss_parameter_supported"`
ServiceDocumentation string `json:"service_documentation"`
}
AuthorizationServerMetadata describes the hub as an authorization server (RFC 8414). Only public clients with PKCE S256: no client has a secret.
type BackupSchedule ¶
type BackupSchedule struct {
EveryMinutes int `json:"every_minutes"`
KeepDays int `json:"keep_days"`
}
BackupSchedule is how an app is backed up: a copy every every_minutes (15, 60 or 1440), each kept keep_days (1, 3, 7 or 30). PUT /api/v1/apps/{app}/backups takes it.
func NewBackupSchedule ¶
func NewBackupSchedule(app *model.App) BackupSchedule
NewBackupSchedule is the JSON shape of an app's schedule.
type Billing ¶
type Billing struct {
Subscription *Subscription `json:"subscription"`
Access *Access `json:"access"`
Plans []Plan `json:"plans"`
}
Billing is the answer of the billing endpoints: the subscription, its resolved access, and the plans a checkout can start.
func NewBilling ¶
func NewBilling(subscription *model.Subscription) Billing
NewBilling builds the billing answer for a subscription, which may be nil.
func NewWorkspaceBilling ¶
func NewWorkspaceBilling(member *model.WorkspaceMember, subscription *model.Subscription) (Billing, error)
NewWorkspaceBilling returns the billing summary of a workspace for a member who may manage billing, and service.ErrBillingPermission for everyone else.
type BillingHandler ¶
type BillingHandler struct {
// contains filtered or unexported fields
}
BillingHandler serves the subscription of a workspace, checkout, and the provider billing management. Only members who may manage billing reach them, like the web billing page.
func NewBillingHandler ¶
func NewBillingHandler(paymentService payment.Provider, workspaceService *service.WorkspaceService) *BillingHandler
func (*BillingHandler) Billing ¶
func (h *BillingHandler) Billing(w http.ResponseWriter, r *http.Request)
Billing returns the workspace subscription, its access, and the purchasable plans.
func (*BillingHandler) BillingManagement ¶
func (h *BillingHandler) BillingManagement(w http.ResponseWriter, r *http.Request)
BillingManagement returns the URL of the provider billing management for the workspace. A workspace without a provider customer gets 409 no_billing_account.
func (*BillingHandler) CreateCheckout ¶
func (h *BillingHandler) CreateCheckout(w http.ResponseWriter, r *http.Request)
CreateCheckout starts a provider checkout for the workspace and returns its URL.
type Bucket ¶
type Bucket struct {
ID string `json:"id"`
Name string `json:"name"`
Default bool `json:"default"`
Endpoint string `json:"endpoint"`
Region string `json:"region"`
Bucket string `json:"bucket"`
Path string `json:"path"`
Folder string `json:"folder"`
AccessKey string `json:"access_key"`
Apps []string `json:"apps"`
OlderBackups []string `json:"older_backups"`
CreatedAt time.Time `json:"created_at"`
SecretServers
}
Bucket is one bucket of the workspace, without its secret key, which only the servers keep: Servers are the ones that keep it, MissingOn the others. Folder is where this workspace's files go in it: path, then the workspace ID. Apps back up there now; OlderBackups are the apps that moved away and keep their older backups there.
type BucketKeyRequest ¶
BucketKeyRequest is the body of PUT /api/v1/buckets/{name}/key: the secret key for one more server.
type BucketList ¶
type BucketList struct {
Items []Bucket `json:"items"`
}
BucketList is the answer of GET /api/v1/buckets.
type BucketRequest ¶
type BucketRequest struct {
Server string `json:"server"`
Name string `json:"name"`
Endpoint string `json:"endpoint"`
Region string `json:"region"`
Bucket string `json:"bucket"`
Path string `json:"path"`
AccessKey string `json:"access_key"`
SecretKey string `json:"secret_key"`
Default bool `json:"default"`
}
BucketRequest is the body of POST /api/v1/buckets and PUT /api/v1/buckets/{name}. Server is the server that checks the bucket and keeps its secret key, empty for the workspace's only one. On a change an empty secret_key keeps the key the server has and an empty name keeps the name; default true makes it the workspace's default bucket.
type CIToken ¶
type CIToken struct {
ID string `json:"id"`
Name string `json:"name"`
// Prefix is the start of the token after "pat_", for telling tokens
// apart.
Prefix string `json:"prefix"`
Rights []string `json:"rights"`
// App is the one app the token reaches, null for every app.
App *string `json:"app"`
// CreatedBy is the name of the person who made it.
CreatedBy string `json:"created_by"`
WorkspaceID string `json:"workspace_id"`
LastUsedAt *time.Time `json:"last_used_at"`
ExpiresAt *time.Time `json:"expires_at"`
Expired bool `json:"expired"`
CreatedAt time.Time `json:"created_at"`
}
CIToken is the public JSON shape of a CI token. It never carries the token or its hash.
type CITokenList ¶
type CITokenList struct {
Items []CIToken `json:"items"`
}
CITokenList is the answer of GET /api/v1/ci-tokens.
type CITokensHandler ¶
type CITokensHandler struct {
// contains filtered or unexported fields
}
CITokensHandler lists, makes, edits and removes the CI tokens of a workspace. Making one and changing its rights need a signed-in browser.
func NewCITokensHandler ¶
func NewCITokensHandler(tokens *service.CITokenService, passkeys *service.PasskeyService) *CITokensHandler
func (*CITokensHandler) Create ¶
func (h *CITokensHandler) Create(w http.ResponseWriter, r *http.Request)
Create makes a CI token in the workspace and answers it once. It needs the person to have confirmed in the last five minutes, as an approval does.
func (*CITokensHandler) List ¶
func (h *CITokensHandler) List(w http.ResponseWriter, r *http.Request)
List returns the CI tokens of the workspace you see: yours, and as its owner every one.
func (*CITokensHandler) Remove ¶
func (h *CITokensHandler) Remove(w http.ResponseWriter, r *http.Request)
Remove deletes a CI token: yours, or as the owner any. Requests with it stop at once. A connection or CI token removes another person's only with the servers right: its own with read.
func (*CITokensHandler) SetRights ¶
func (h *CITokensHandler) SetRights(w http.ResponseWriter, r *http.Request)
SetRights changes what a CI token may do: {"rights": ["deploy"]}.
type CatalogDeploy ¶
type CatalogDeploy struct {
App App `json:"app"`
Deploy Deploy `json:"deploy"`
Login map[string]string `json:"login,omitempty"`
Password string `json:"password,omitempty"`
}
CatalogDeploy is the answer of an install or an update: the app and its new deploy, which streams like every deploy. Login, only on an install, holds the secrets the first sign-in needs, such as ADMIN_PASSWORD, and Password the app's password, user moin, which every address of it asks for: the one time they are shown.
type CatalogEntry ¶
type CatalogEntry struct {
Slug string `json:"slug"`
Name string `json:"name"`
Pitch string `json:"pitch"`
Category string `json:"category"`
Website string `json:"website"`
Source string `json:"source"`
License string `json:"license"`
Image string `json:"image"`
// Database is postgres or sqlite, which moin backs up, or mysql,
// mongodb or clickhouse, which it does not yet.
Database string `json:"database"`
// DatabaseNote says so for a database moin does not back up; empty
// otherwise.
DatabaseNote string `json:"database_note"`
// Login says how to sign in the first time.
Login string `json:"login"`
// NeedsDomain says the install needs a domain: moin sets APP_URL from it.
NeedsDomain bool `json:"needs_domain"`
// Secrets are the env vars moin generates on install.
Secrets []string `json:"secrets"`
Latest *CatalogVersion `json:"latest"`
Versions []CatalogVersion `json:"versions,omitempty"`
}
CatalogEntry is the public JSON shape of a catalog app. Versions is only set on the single answer; Latest is null before its registry answered.
func NewCatalogEntry ¶
NewCatalogEntry is entry with its newest release; withVersions adds them all.
type CatalogHandler ¶
type CatalogHandler struct {
// contains filtered or unexported fields
}
CatalogHandler lists the catalog, installs its apps and updates them.
func NewCatalogHandler ¶
func NewCatalogHandler(catalog *service.CatalogService) *CatalogHandler
func (*CatalogHandler) Get ¶
func (h *CatalogHandler) Get(w http.ResponseWriter, r *http.Request)
Get returns a catalog app with every release, newest first.
func (*CatalogHandler) Install ¶
func (h *CatalogHandler) Install(w http.ResponseWriter, r *http.Request)
Install creates the app from the catalog and deploys it.
func (*CatalogHandler) List ¶
func (h *CatalogHandler) List(w http.ResponseWriter, _ *http.Request)
List returns every app of the catalog with its newest release.
func (*CatalogHandler) Update ¶
func (h *CatalogHandler) Update(w http.ResponseWriter, r *http.Request)
Update sets a catalog app to a version and deploys it.
type CatalogInstallRequest ¶
type CatalogInstallRequest struct {
Server string `json:"server"`
Version string `json:"version"`
Name string `json:"name"`
Domain string `json:"domain"`
}
CatalogInstallRequest installs a catalog app. Version, name and domain are optional: the newest release, the slug, no domain.
type CatalogList ¶
type CatalogList struct {
Items []CatalogEntry `json:"items"`
}
CatalogList is the answer of GET /api/v1/catalog.
type CatalogVersion ¶
CatalogVersion is a release of a catalog app.
type Change ¶
Change is the answer to a change of the domains: the app as it is now. The app takes it with its next restart, start or deploy. Unchanged is set when the app had it so already.
type ClientRegistration ¶
type ClientRegistration struct {
ClientName string `json:"client_name"`
RedirectURIs []string `json:"redirect_uris"`
}
ClientRegistration is what an MCP client sends to register (RFC 7591, section 2). Only the name and the redirect URIs are kept; the rest is what every client gets here anyway.
type ComposeFile ¶
ComposeFile is the compose file of an app's live deploy, YAML: everything moin runs for the app, without a secret value.
type Connection ¶
type Connection struct {
ID string `json:"id"`
// ClientName is what the client called itself, such as "moin CLI on
// laptop-1".
ClientName string `json:"client_name"`
// RedirectHost is where an AI agent sends the person back, like
// claude.ai; empty for `moin login`.
RedirectHost string `json:"redirect_host"`
WorkspaceID string `json:"workspace_id"`
Rights []string `json:"rights"`
Current bool `json:"current"`
LastUsedAt *time.Time `json:"last_used_at"`
CreatedAt time.Time `json:"created_at"`
}
Connection is the public JSON shape of a connection. It never carries a token.
func NewConnection ¶
func NewConnection(connection model.Connection, current *model.Bearer) Connection
NewConnection converts a connection into its public JSON shape. current marks the connection of the request.
type ConnectionList ¶
type ConnectionList struct {
Items []Connection `json:"items"`
}
ConnectionList is the answer of GET /api/v1/account/connections.
type ConnectionsHandler ¶
type ConnectionsHandler struct {
// contains filtered or unexported fields
}
ConnectionsHandler lists, edits and removes the connections of the signed-in person. A connection lists and removes; only a signed-in browser changes rights, so no client gives itself more.
func NewConnectionsHandler ¶
func NewConnectionsHandler(connections *service.ConnectionService, passkeys *service.PasskeyService) *ConnectionsHandler
func (*ConnectionsHandler) List ¶
func (h *ConnectionsHandler) List(w http.ResponseWriter, r *http.Request)
List returns the live connections, newest first. A connection sees those of its own workspace.
func (*ConnectionsHandler) Remove ¶
func (h *ConnectionsHandler) Remove(w http.ResponseWriter, r *http.Request)
Remove ends a connection and every token of it, at once. A connection removes those of its own workspace.
func (*ConnectionsHandler) SetRights ¶
func (h *ConnectionsHandler) SetRights(w http.ResponseWriter, r *http.Request)
SetRights changes what a connection may do: {"rights": ["deploy"]}. It counts from the connection's next request. Adding a right needs the person to have confirmed in the last five minutes, as an approval does.
type CreatedAlertDestination ¶
type CreatedAlertDestination struct {
AlertDestination
SigningSecret string `json:"signing_secret,omitempty"`
}
CreatedAlertDestination is the answer of POST /api/v1/alert-destinations: a webhook comes with its signing secret, this once.
type CreatedApp ¶
CreatedApp is the answer of POST /api/v1/apps: the app and its password, user moin, which its domains and its instant address ask for: shown this once.
type CreatedCIToken ¶
CreatedCIToken is the answer of POST /api/v1/ci-tokens. Token is the raw token, shown this one time only.
type CreatedServer ¶
type CreatedServer struct {
Server Server `json:"server"`
InstallToken string `json:"install_token"`
InstallCommand string `json:"install_command"`
ExpiresAt time.Time `json:"expires_at"`
}
CreatedServer is the answer of POST /api/v1/servers. The install token works once, within an hour.
type DaemonUpdates ¶
type DaemonUpdates struct {
// Auto updates every daemon older than the hub by itself.
Auto bool `json:"auto"`
}
DaemonUpdates is the answer of GET and PUT /api/v1/daemon-updates.
type DatabaseBackup ¶
type DatabaseBackup struct {
Database string `json:"database"`
Kind string `json:"kind,omitempty"`
CopiedAt *time.Time `json:"copied_at,omitempty"`
CheckedAt *time.Time `json:"checked_at,omitempty"`
CheckError string `json:"check_error,omitempty"`
Copies []protocol.Copy `json:"copies"`
Undos []protocol.Copy `json:"undos"`
Error string `json:"error,omitempty"`
}
DatabaseBackup is how one database is backed up, as the daemon reports it: protocol.DatabaseBackup under the API's own names.
type DatabaseBackups ¶
type DatabaseBackups struct {
DatabaseBackup
Problem string `json:"problem,omitempty"`
Moments []Moment `json:"moments"`
}
DatabaseBackups is the backup of one database: what the daemon reports, problem as one short sentence when it does not work, and the moments a restore can go back to, the copies and the undos, newest first.
type Deploy ¶
type Deploy struct {
Number int `json:"number"`
Status string `json:"status"`
FromNumber int `json:"from_number"`
Image string `json:"image"`
// Ref and Commit name the GitHub commit the deploy came from.
Ref string `json:"ref,omitempty"`
Commit string `json:"commit,omitempty"`
CommitMessage string `json:"commit_message,omitempty"`
Error string `json:"error"`
Detected *protocol.Detected `json:"detected"`
CreatedAt time.Time `json:"created_at"`
FinishedAt *time.Time `json:"finished_at"`
Log []string `json:"log,omitempty"`
// OnServer says whether the server still keeps the release, so it can
// be rolled back to. Only in the deploys of an app's detail.
OnServer *bool `json:"on_server,omitempty"`
}
Deploy is the public JSON shape of a deploy. Log is only set on the single-deploy answer.
type DeployHook ¶
type DeployHook struct {
URL string `json:"url"`
}
DeployHook is the answer of POST /api/v1/apps/{app}/hook. The URL is shown once.
type DeployMark ¶
DeployMark is a deploy that went live, to mark on the charts.
type DeviceHandler ¶
type DeviceHandler struct {
// contains filtered or unexported fields
}
DeviceHandler starts `moin login` in the browser, the device authorization grant of RFC 8628. It is public; the CLI then polls the token endpoint with the device code (TokenHandler).
func NewDeviceHandler ¶
func NewDeviceHandler(logins *service.DeviceLoginService, appURL string) *DeviceHandler
func (*DeviceHandler) Start ¶
func (h *DeviceHandler) Start(w http.ResponseWriter, r *http.Request)
Start begins a login and answers the codes and where to confirm it.
type DeviceLogin ¶
type DeviceLogin struct {
DeviceCode string `json:"device_code"`
UserCode string `json:"user_code"`
VerificationURI string `json:"verification_uri"`
VerificationURIComplete string `json:"verification_uri_complete"`
ExpiresIn int `json:"expires_in"`
Interval int `json:"interval"`
}
DeviceLogin is the answer of POST /api/v1/auth/device, with the names of RFC 8628, section 3.2.
type DomainCheck ¶
type DomainCheck struct {
Domain string `json:"domain"`
Canonical bool `json:"canonical"`
Address string `json:"address"`
// IPv4 and IPv6 are the server's addresses, empty when unknown.
IPv4 string `json:"ipv4"`
IPv6 string `json:"ipv6"`
// Advice is the DNS record to set, such as "A record to 203.0.113.7".
Advice string `json:"advice"`
Found []string `json:"found"`
Points bool `json:"points"`
// Service is the service of compose.yml the domain reaches, empty for
// the main one.
Service string `json:"service,omitempty"`
}
DomainCheck says whether a domain points at the app's server.
type DomainChecks ¶
type DomainChecks struct {
Items []DomainCheck `json:"items"`
}
DomainChecks is the answer of GET /api/v1/apps/{app}/domains.
func NewDomainChecks ¶
func NewDomainChecks(checks []service.DomainCheck) DomainChecks
type Download ¶
type Download struct {
App string `json:"app"`
Database string `json:"database"`
Copy string `json:"copy"`
Label string `json:"label"`
At time.Time `json:"at"`
Size int64 `json:"size"`
Link string `json:"link"`
}
Download is a copy of a database in the app's own bucket; link is a signed link to it there, valid 15 minutes.
func NewDownload ¶
NewDownload is the JSON shape of a download.
type DownloadRequest ¶
DownloadRequest is the body of POST /api/v1/apps/{app}/backups/download: the database when the app has several, and a moment from the list, the newest copy without one.
type EmailAlerts ¶
type EmailAlerts struct {
On bool `json:"on"`
}
EmailAlerts is the body and the answer of PUT /api/v1/account/email-alerts.
type Env ¶
type Env struct {
Items []EnvVar `json:"items"`
}
Env is the answer of GET /api/v1/apps/{app}/env: the keys and when they changed. Values are write-only: no answer ever holds one.
type ErrorBody ¶
type ErrorBody struct {
Error ErrorDetail `json:"error"`
}
ErrorBody is the envelope of every non-2xx JSON response.
type ErrorDetail ¶
type ErrorDetail struct {
Code string `json:"code"`
Message string `json:"message"`
Fields map[string]string `json:"fields,omitempty"`
Right string `json:"right,omitempty"`
}
ErrorDetail carries a stable lowercase snake case code, a message for humans, per-field messages for validation errors, and for missing_right the right that is missing.
func ErrorFor ¶
func ErrorFor(err error) (int, ErrorDetail, bool)
ErrorFor returns the status and error detail the API answers for a service or repository error. Other transports, like the MCP server, use it to report the same codes. known is false for errors without a mapping; they get 500 internal and the caller should log them.
func MissingRight ¶
func MissingRight(bearer model.Bearer, missing model.Rights) ErrorDetail
MissingRight is the error of a connection or CI token without a right: "This connection may not deploy and restart. Change it in Settings, Connections."
type ExecRequest ¶
type ExecRequest struct {
Service string `json:"service"`
Command []string `json:"command"`
Line string `json:"line"`
Timeout int `json:"timeout"`
}
ExecRequest is the body of POST /api/v1/apps/{app}/exec: the command as a list of words, or as one line split the way a shell quotes words, never read by a shell; the service, the app's main one when empty; and the timeout in seconds.
type GitHub ¶
type GitHub struct {
Enabled bool `json:"enabled"`
// ConnectURL connects GitHub: it connects the app where the user
// already installed it, or installs it.
ConnectURL string `json:"connect_url,omitempty"`
// InstallURL installs the app on another account or organization.
InstallURL string `json:"install_url,omitempty"`
Installations []GitHubInstallation `json:"installations"`
}
GitHub is the answer of GET /api/v1/github: where the moin GitHub App is installed and the links that connect it.
type GitHubBranches ¶
type GitHubBranches struct {
Items []string `json:"items"`
}
GitHubBranches is the answer of GET /api/v1/github/repos/{owner}/{repo}/branches.
type GitHubInstallation ¶
type GitHubInstallation struct {
ID int64 `json:"id"`
Account string `json:"account"`
// SettingsURL is where the account chooses the repos moin may read.
SettingsURL string `json:"settings_url"`
}
GitHubInstallation is the app on one account or organization.
type GitHubRepo ¶
type GitHubRepo struct {
FullName string `json:"full_name"`
DefaultBranch string `json:"default_branch"`
Private bool `json:"private"`
Account string `json:"account"`
}
GitHubRepo is a repo moin may read.
type GitHubRepos ¶
type GitHubRepos struct {
Items []GitHubRepo `json:"items"`
}
GitHubRepos is the answer of GET /api/v1/github/repos.
type Handlers ¶
type Handlers struct {
Meta *MetaHandler
Auth *AuthHandler
Account *AccountHandler
Sessions *SessionsHandler
Passkeys *PasskeysHandler
Connections *ConnectionsHandler
CITokens *CITokensHandler
Token *TokenHandler
Billing *BillingHandler
Admin *AdminHandler
Workspaces *WorkspaceHandler
Invitations *WorkspaceInvitationHandler
Servers *ServersHandler
Apps *AppsHandler
Version *VersionHandler
Alerts *AlertsHandler
Catalog *CatalogHandler
Status *StatusHandler
Device *DeviceHandler
OAuth *OAuthHandler
}
Handlers are the API handlers the routes call.
type InsertRequest ¶
type InsertRequest struct {
Database string `json:"database"`
Table string `json:"table"`
Values map[string]string `json:"values"`
}
InsertRequest is the body of POST /api/v1/apps/{app}/databases/rows. Columns missing from values get their default.
type Instant ¶
type Instant struct {
URL string `json:"url"`
Provider string `json:"provider"`
Reason string `json:"reason,omitempty"`
}
Instant is the instant address of an app: its URL, or why it has none. The app's password guards it like the app's domains.
func NewInstant ¶
type Integrations ¶
type Integrations struct {
Cloudflare bool `json:"cloudflare"`
CloudflareAccount string `json:"cloudflare_account"`
Tailscale SecretServers `json:"tailscale"`
}
Integrations is the answer of GET /api/v1/integrations: which keys there are, never the keys. The hub keeps the Cloudflare API token; the Tailscale key only the servers keep.
func NewIntegrations ¶
func NewIntegrations(integrations service.Integrations) Integrations
NewIntegrations is the JSON shape of the workspace's keys.
type IntegrationsRequest ¶
type IntegrationsRequest struct {
CloudflareToken *string `json:"cloudflare_token"`
TailscaleKey *string `json:"tailscale_key"`
Server string `json:"server"`
}
IntegrationsRequest is the body of PUT /api/v1/integrations. A missing key stays, an empty one is removed. Server is the server that keeps the Tailscale key, empty for the workspace's only one.
type InvitationPreview ¶
type InvitationPreview struct {
WorkspaceName string `json:"workspace_name"`
InviterName string `json:"inviter_name"`
Role string `json:"role"`
ExpiresAt time.Time `json:"expires_at"`
}
InvitationPreview is what the holder of an invitation token may see before accepting it.
type Logs ¶
type Logs struct {
Lines []string `json:"lines"`
}
Logs is the answer of GET /api/v1/apps/{app}/logs.
type Membership ¶
Membership is a workspace the user belongs to and the user's role in it.
func NewMemberships ¶
func NewMemberships(memberships []model.WorkspaceMembership) []Membership
NewMemberships converts workspace memberships into their public JSON shape.
type MetaHandler ¶
type MetaHandler struct {
// contains filtered or unexported fields
}
MetaHandler answers public facts about the project for a frontend.
func NewMetaHandler ¶
func NewMetaHandler(supportEmail string) *MetaHandler
func (*MetaHandler) Meta ¶
func (h *MetaHandler) Meta(w http.ResponseWriter, _ *http.Request)
Meta returns the project name, the support address and the version.
type Middleware ¶
type Middleware struct {
// RequireAuth answers 401 without a session.
RequireAuth Wrap
// RequireOnboarded also answers 403 onboarding_required without a name.
RequireOnboarded Wrap
// RateLimitEmailChanges limits email change requests per user and
// recipient.
RateLimitEmailChanges Wrap
// RequireAdmin answers 403 forbidden for users who are not admins.
RequireAdmin Wrap
// Workspace requires onboarding and scopes the route to the workspace
// in its path.
Workspace Wrap
// RateLimitInvitations limits workspace invitation emails.
RateLimitInvitations Wrap
// InWorkspace requires onboarding and scopes a moin route to the
// workspace of the connection or CI token, or for a session to the workspace its
// Moin-Workspace header names.
InWorkspace Wrap
// RateLimitDevice limits the logins `moin login` starts per client IP.
RateLimitDevice Wrap
// RateLimitDevicePoll limits the polls of `moin login` and the
// refreshes of the token endpoint per client IP.
RateLimitDevicePoll Wrap
// RateLimitRegister limits the MCP clients that register themselves per
// client IP.
RateLimitRegister Wrap
// AppID finds the ID of an app in a workspace by its name or ID, for
// CI tokens that may reach one app only.
AppID func(workspaceID, app string) (string, error)
}
Middleware are the route middleware from internal/middleware. They are passed in because internal/middleware imports this package.
type Moment ¶
type Moment struct {
ID string `json:"id"`
Label string `json:"label"`
At time.Time `json:"at"`
Kind string `json:"kind"`
}
Moment is one moment to go back to. POST /api/v1/apps/{app}/restores takes its id or label as moment.
type NewPassword ¶
NewPassword is the answer of PUT /api/v1/apps/{app}/password: the change, and the password when moin made it, the one time moin shows it.
type OAuthError ¶
type OAuthError struct {
Error string `json:"error"`
Description string `json:"error_description"`
}
OAuthError is a failed answer of the token and revocation endpoints (RFC 6749, section 5.2).
type OAuthHandler ¶
type OAuthHandler struct {
// contains filtered or unexported fields
}
OAuthHandler tells MCP clients how to sign in and registers them. The two documents under /.well-known follow RFC 9728 and RFC 8414, registration RFC 7591: an MCP client finds all of it from the 401 of /mcp, with nothing to set up by hand.
func NewOAuthHandler ¶
func NewOAuthHandler(oauth *service.OAuthService) *OAuthHandler
func (*OAuthHandler) AuthorizationServer ¶
func (h *OAuthHandler) AuthorizationServer(w http.ResponseWriter, r *http.Request)
AuthorizationServer answers the metadata of the hub as an authorization server.
func (*OAuthHandler) ProtectedResource ¶
func (h *OAuthHandler) ProtectedResource(w http.ResponseWriter, r *http.Request)
ProtectedResource answers the metadata of /mcp. middleware.CORS lets any page read it, as the other public OAuth endpoints.
func (*OAuthHandler) Register ¶
func (h *OAuthHandler) Register(w http.ResponseWriter, r *http.Request)
Register stores an MCP client that registers itself. Every client is a public client with PKCE: one that asks for a secret gets none, as RFC 7591 lets the hub decide.
type Outage ¶
type Outage struct {
StartedAt time.Time `json:"started_at"`
EndedAt *time.Time `json:"ended_at"`
Reason string `json:"reason"`
}
Outage is a time a domain was down; ended_at is null while it lasts.
type Passkey ¶
type Passkey struct {
ID string `json:"id"`
Name string `json:"name"`
CreatedAt time.Time `json:"created_at"`
LastUsedAt *time.Time `json:"last_used_at"`
}
Passkey is the public JSON shape of a passkey. It never carries the credential.
type PasskeyList ¶
type PasskeyList struct {
Items []Passkey `json:"items"`
}
PasskeyList is the answer of GET /api/v1/account/passkeys.
type PasskeyNameRequest ¶
type PasskeyNameRequest struct {
Name string `json:"name"`
}
PasskeyNameRequest is the body of PATCH /api/v1/account/passkeys/{id}.
type PasskeysHandler ¶
type PasskeysHandler struct {
// contains filtered or unexported fields
}
PasskeysHandler lists, renames and removes the passkeys of the signed-in user. Adding one is a ceremony in the browser: only the web adds passkeys.
func NewPasskeysHandler ¶
func NewPasskeysHandler(passkeys *service.PasskeyService) *PasskeysHandler
func (*PasskeysHandler) List ¶
func (h *PasskeysHandler) List(w http.ResponseWriter, r *http.Request)
List returns every passkey of the user, oldest first.
func (*PasskeysHandler) Remove ¶
func (h *PasskeysHandler) Remove(w http.ResponseWriter, r *http.Request)
Remove deletes one passkey, unless it is the user's last way in.
func (*PasskeysHandler) Rename ¶
func (h *PasskeysHandler) Rename(w http.ResponseWriter, r *http.Request)
Rename names one passkey of the user.
type PendingInvitation ¶
type PendingInvitation struct {
ID string `json:"id"`
Email string `json:"email"`
Role string `json:"role"`
ExpiresAt time.Time `json:"expires_at"`
CreatedAt time.Time `json:"created_at"`
}
PendingInvitation is an open invitation of a workspace.
type Plan ¶
type Plan struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Benefits []string `json:"benefits"`
Current bool `json:"current"`
Prices []PlanPrice `json:"prices"`
}
Plan is a purchasable plan of the product catalog with its prices.
type PlanPrice ¶
type PlanPrice struct {
Interval string `json:"interval"`
Amount int `json:"amount"`
DisplayPrice string `json:"display_price"`
}
PlanPrice is the price of a plan for one billing interval. Amount is in the smallest currency unit, DisplayPrice is formatted like the web page.
type ProtectedResourceMetadata ¶
type ProtectedResourceMetadata struct {
Resource string `json:"resource"`
AuthorizationServers []string `json:"authorization_servers"`
BearerMethodsSupported []string `json:"bearer_methods_supported"`
ResourceName string `json:"resource_name"`
ResourceDocumentation string `json:"resource_documentation"`
}
ProtectedResourceMetadata describes /mcp as a protected resource (RFC 9728): what it is and which authorization server hands out its tokens.
type QueryRequest ¶
type QueryRequest struct {
Database string `json:"database"`
SQL string `json:"sql"`
Params []any `json:"params"`
Write bool `json:"write"`
Limit int `json:"limit"`
}
QueryRequest is the body of POST /api/v1/apps/{app}/databases/query.
type RegisteredClient ¶
type RegisteredClient struct {
ClientID string `json:"client_id"`
ClientIDIssuedAt int64 `json:"client_id_issued_at"`
ClientName string `json:"client_name"`
RedirectURIs []string `json:"redirect_uris"`
GrantTypes []string `json:"grant_types"`
ResponseTypes []string `json:"response_types"`
TokenEndpointAuthMethod string `json:"token_endpoint_auth_method"`
}
RegisteredClient is the answer of a registration (RFC 7591, section 3.2.1): the client_id, and what the hub keeps of the request.
type Registry ¶
type Registry struct {
Host string `json:"host"`
Username string `json:"username"`
CreatedAt time.Time `json:"created_at"`
SecretServers
}
Registry is a registry login without its password, which only the servers keep: Servers are the ones that keep it, MissingOn the others.
func NewRegistry ¶
func NewRegistry(login service.RegistryLogin) Registry
NewRegistry is the JSON shape of a registry login.
type RegistryList ¶
type RegistryList struct {
Items []Registry `json:"items"`
}
RegistryList is the answer of GET /api/v1/registries.
type RemovedServer ¶
type RemovedServer struct {
UninstallCommand string `json:"uninstall_command"`
// Apps went with the server: it was offline, so it could not remove
// them. They stay on the machine if it comes back.
Apps []string `json:"apps"`
}
RemovedServer is the answer of DELETE /api/v1/servers/{id}: the command that removes the daemon from the server too.
type ReplacedEnv ¶
ReplacedEnv is the env vars after a replace and what changed, by key.
type RepoRequest ¶
type RepoRequest struct {
Repo string `json:"repo"`
Branch string `json:"branch"`
AutoDeploy *bool `json:"auto_deploy"`
}
RepoRequest is the body of PUT /api/v1/apps/{app}/repo. Without auto_deploy, deploy on push is on, unless the app has a deploy hook.
type Restore ¶
type Restore struct {
ID string `json:"id"`
App string `json:"app"`
Database string `json:"database"`
To string `json:"to"`
State string `json:"state"`
Error string `json:"error,omitempty"`
StartedAt time.Time `json:"started_at"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
}
Restore is a restore the daemon runs: running, then done or failed with error. To is the moment it goes back to, as people read it.
func NewRestore ¶
NewRestore is the JSON shape of a restore.
type RestoreRequest ¶
type RestoreRequest struct {
Database string `json:"database"`
Moment string `json:"moment"`
At *time.Time `json:"at"`
Confirm string `json:"confirm"`
}
RestoreRequest is the body of POST /api/v1/apps/{app}/restores: a moment from the list, by id or label, or a time. Database names the database when the app has several. Confirm is the app's name, typed out by the user.
type RightsRequest ¶
type RightsRequest struct {
Rights []string `json:"rights"`
}
RightsRequest changes the rights of a connection or CI token. Read is always in.
type Route ¶
type Route struct {
Pattern string
Handler http.HandlerFunc
// Right is what a connection or CI token needs, one right or two that
// must both be on. NoToken, the zero value, keeps them out.
Right model.Rights
}
Route is one endpoint of the JSON API: a ServeMux pattern, its handler with every middleware applied, and the right a connection or CI token needs there. This table is the one place that says it: the gate checks it, and a test checks the docs' table of rights against it.
func Routes ¶
func Routes(h Handlers, m Middleware) []Route
Routes lists every endpoint under /api/v1. The router registers exactly these routes, and openapi_test.go checks them against openapi.yaml. Every handler is wrapped by the gate of its route: a connection or CI token without the route's right gets 403 missing_right, and NoToken routes answer 403 to them.
type RowRequest ¶
type RowRequest struct {
Database string `json:"database"`
Table string `json:"table"`
RowID int64 `json:"rowid"`
// Key names the row by its primary key, column by column: for Postgres
// and tables without a rowid. It wins over RowID.
Key map[string]string `json:"key,omitempty"`
Column string `json:"column"`
Value *string `json:"value"`
}
RowRequest names one row: PATCH sets Column to Value (null for NULL), DELETE removes it.
type Seats ¶
Seats compares the member count with the plan limit. Limit is null when the plan has no member limit.
type SecretServers ¶
type SecretServers struct {
Servers []SecretOn `json:"servers"`
MissingOn []string `json:"missing_on"`
}
SecretServers says which servers keep a secret and which do not.
func NewSecretServers ¶
func NewSecretServers(where service.SecretServers) SecretServers
NewSecretServers is the JSON shape of where a secret is.
type SecurityRequest ¶
type SecurityRequest struct {
Tunnel bool `json:"tunnel"`
SSH string `json:"ssh"`
Firewall bool `json:"firewall"`
}
SecurityRequest is the body of PUT /api/v1/servers/{id}/security.
type Server ¶
type Server struct {
ID string `json:"id"`
Name string `json:"name"`
Online bool `json:"online"`
Hostname string `json:"hostname"`
OS string `json:"os"`
Arch string `json:"arch"`
DaemonVersion string `json:"daemon_version"`
LastSeenAt *time.Time `json:"last_seen_at"`
// Tunnel carries app traffic through a Cloudflare Tunnel, with no open
// port. SSH is who SSH answers: tailscale, everyone or off. Firewall
// drops every other inbound connection. They are what is set; Security
// is what the daemon last saw on the server.
Tunnel bool `json:"tunnel"`
SSH string `json:"ssh"`
Firewall bool `json:"firewall"`
Security *protocol.ServerConfigResult `json:"security"`
// Rules are what the owner of the server allows moin to do there, from
// /etc/moin/rules on the server. Null for a server without the file, an
// empty object for one whose rules limit nothing.
Rules *protocol.Rules `json:"rules"`
CreatedAt time.Time `json:"created_at"`
}
Server is the public JSON shape of a server. It never carries a token.
type ServerAppMetrics ¶
type ServerAppMetrics struct {
App string `json:"app"`
Now *AppMetricsNow `json:"now"`
}
ServerAppMetrics is an app on the server and its newest sample, null without one.
type ServerList ¶
type ServerList struct {
Items []Server `json:"items"`
}
ServerList is the answer of GET /api/v1/servers and every event of GET /api/v1/servers/events.
type ServerMetrics ¶
type ServerMetrics struct {
Server string `json:"server"`
Online bool `json:"online"`
// Range is 1h, 24h, 7d or 30d; StepSeconds is how far apart the points
// are: 15 for the samples of the last hour, else the step they average.
Range string `json:"range"`
StepSeconds int `json:"step_seconds"`
Now *ServerMetricsNow `json:"now"`
Points []ServerPoint `json:"points"`
Apps []ServerAppMetrics `json:"apps"`
}
ServerMetrics is the answer of GET /api/v1/servers/{id}/metrics: the server now, its points over the range, and its apps now, the one with the most memory first.
func NewServerMetrics ¶
func NewServerMetrics(server *model.Server, metrics service.ServerMetrics) ServerMetrics
NewServerMetrics is the JSON shape of a server's metrics.
type ServerMetricsNow ¶
type ServerMetricsNow struct {
At time.Time `json:"at"`
CPU float64 `json:"cpu"`
Cores int `json:"cores"`
MemoryUsed uint64 `json:"memory_used"`
MemoryTotal uint64 `json:"memory_total"`
DiskUsed uint64 `json:"disk_used"`
DiskTotal uint64 `json:"disk_total"`
NetRx float64 `json:"net_rx"`
NetTx float64 `json:"net_tx"`
Load float64 `json:"load"`
}
ServerMetricsNow is the newest sample of a server, at most two minutes old. CPU is the busy share of all cores in percent, memory and disk in bytes, the network in bytes per second.
type ServerPoint ¶
type ServerPoint struct {
At time.Time `json:"at"`
CPU float64 `json:"cpu"`
Memory uint64 `json:"memory"`
Disk uint64 `json:"disk"`
NetRx float64 `json:"net_rx"`
NetTx float64 `json:"net_tx"`
Load float64 `json:"load"`
}
ServerPoint is a server at one point of a chart.
type ServersHandler ¶
type ServersHandler struct {
// contains filtered or unexported fields
}
ServersHandler lists, adds and removes the servers of the signed-in user. The web UI, the CLI and the TUI all use it.
func NewServersHandler ¶
func NewServersHandler(servers *service.ServerService) *ServersHandler
func (*ServersHandler) Create ¶
func (h *ServersHandler) Create(w http.ResponseWriter, r *http.Request)
Create adds a server and answers 201 with its install command.
func (*ServersHandler) Delete ¶
func (h *ServersHandler) Delete(w http.ResponseWriter, r *http.Request)
Delete removes a server by ID or name and disconnects its daemon; ?confirm= is its name, typed out.
func (*ServersHandler) Events ¶
func (h *ServersHandler) Events(w http.ResponseWriter, r *http.Request)
Events streams the server list as server-sent events: once on connect and again after every change.
func (*ServersHandler) List ¶
func (h *ServersHandler) List(w http.ResponseWriter, r *http.Request)
List returns the servers by name.
func (*ServersHandler) NewInstall ¶
func (h *ServersHandler) NewInstall(w http.ResponseWriter, r *http.Request)
NewInstall answers 201 with a new install command for the server. The old one stops working.
func (*ServersHandler) Rename ¶
func (h *ServersHandler) Rename(w http.ResponseWriter, r *http.Request)
Rename gives a server a new name and answers it.
func (*ServersHandler) Update ¶
func (h *ServersHandler) Update(w http.ResponseWriter, r *http.Request)
Update has the server's daemon swap its binary for the hub's and answers the server once the new daemon is back.
type Session ¶
type Session struct {
ID string `json:"id"`
DisplayName string `json:"display_name"`
Current bool `json:"current"`
LastSeenAt time.Time `json:"last_seen_at"`
CreatedAt time.Time `json:"created_at"`
}
Session is the public JSON shape of a session. It never carries the token hash or the raw user agent.
type SessionList ¶
type SessionList struct {
Items []Session `json:"items"`
}
SessionList is the answer of GET /api/v1/account/sessions.
type SessionsHandler ¶
type SessionsHandler struct {
// contains filtered or unexported fields
}
SessionsHandler lists and revokes the sessions of the signed-in user.
func NewSessionsHandler ¶
func NewSessionsHandler(authService *service.AuthService) *SessionsHandler
func (*SessionsHandler) List ¶
func (h *SessionsHandler) List(w http.ResponseWriter, r *http.Request)
List returns every active session and marks the current one.
func (*SessionsHandler) Revoke ¶
func (h *SessionsHandler) Revoke(w http.ResponseWriter, r *http.Request)
Revoke signs out one session. Revoking the current session also clears the cookie of a cookie request.
func (*SessionsHandler) RevokeOthers ¶
func (h *SessionsHandler) RevokeOthers(w http.ResponseWriter, r *http.Request)
RevokeOthers signs out every session except the current one.
type StatusCounts ¶
type StatusCounts struct {
Apps int `json:"apps"`
AppsLive int `json:"apps_live"`
Servers int `json:"servers"`
ServersOnline int `json:"servers_online"`
Databases int `json:"databases"`
BackupsChecked int `json:"backups_checked"`
}
StatusCounts is what runs well.
type StatusHandler ¶
type StatusHandler struct {
// contains filtered or unexported fields
}
StatusHandler answers whether everything is OK in a workspace.
func NewStatusHandler ¶
func NewStatusHandler(status *service.StatusService) *StatusHandler
func (*StatusHandler) Get ¶
func (h *StatusHandler) Get(w http.ResponseWriter, r *http.Request)
Get answers whether everything is OK.
type StatusIssue ¶
type StatusIssue struct {
Kind string `json:"kind"`
Target string `json:"target"`
Detail string `json:"detail"`
Path string `json:"path"`
Since *time.Time `json:"since"`
}
StatusIssue is one thing that needs you; Path is under the workspace in the web app.
type StatusResponse ¶
type StatusResponse struct {
OK bool `json:"ok"`
Issues []StatusIssue `json:"issues"`
Updates []StatusUpdate `json:"updates"`
Counts StatusCounts `json:"counts"`
}
StatusResponse is the workspace at a glance: ok is false when an issue needs you; updates never make it false.
func NewStatus ¶
func NewStatus(status service.WorkspaceStatus) StatusResponse
NewStatus is the JSON shape of a workspace status.
type StatusUpdate ¶
type StatusUpdate struct {
App string `json:"app"`
Name string `json:"name"`
Version string `json:"version"`
Latest string `json:"latest"`
}
StatusUpdate is a catalog app with a newer release.
type Subscription ¶
type Subscription struct {
ID string `json:"id"`
PlanID string `json:"plan_id"`
Status string `json:"status"`
Provider string `json:"provider"`
CurrentPeriodEnd *time.Time `json:"current_period_end"`
Amount *int `json:"amount"`
Currency string `json:"currency"`
Interval *string `json:"interval"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Subscription is the public JSON shape of a subscription. Provider identifiers and checkout bookkeeping stay on the server.
func NewSubscription ¶
func NewSubscription(subscription *model.Subscription) *Subscription
NewSubscription converts a subscription model into its public JSON shape.
type TableRows ¶
type TableRows struct {
Database string `json:"database"`
Table protocol.DBTable `json:"table"`
Columns []string `json:"columns"`
Rows [][]any `json:"rows"`
Offset int `json:"offset"`
Limit int `json:"limit"`
Truncated bool `json:"truncated"`
}
TableRows is the answer of GET /api/v1/apps/{app}/databases/rows. When the table has a rowid, it is the first column.
type TokenHandler ¶
type TokenHandler struct {
// contains filtered or unexported fields
}
TokenHandler is the OAuth token endpoint and the revocation endpoint of the hub. They follow RFC 6749, RFC 8628 and RFC 7009 word for word, so any OAuth client works: the requests are forms, and the errors are {"error", "error_description"}, not the API's envelope.
func NewTokenHandler ¶
func NewTokenHandler(logins *service.DeviceLoginService, connections *service.ConnectionService, oauth *service.OAuthService) *TokenHandler
func (*TokenHandler) Revoke ¶
func (h *TokenHandler) Revoke(w http.ResponseWriter, r *http.Request)
Revoke ends the connection of an access or refresh token (RFC 7009). It answers 200 for a token it does not know too: there is nothing left to end.
func (*TokenHandler) Token ¶
func (h *TokenHandler) Token(w http.ResponseWriter, r *http.Request)
Token answers a poll of the device flow, the code of an AI agent or a refresh.
type TokenResponse ¶
type TokenResponse struct {
AccessToken string `json:"access_token"`
TokenType string `json:"token_type"`
ExpiresIn int `json:"expires_in"`
RefreshToken string `json:"refresh_token"`
Scope string `json:"scope"`
ConnectionID string `json:"connection_id"`
}
TokenResponse is a successful answer of POST /api/v1/auth/token (RFC 6749, section 5.1). Scope names the connection's rights, and ConnectionID the connection, so a client can tell it apart.
type URLResponse ¶
type URLResponse struct {
URL string `json:"url"`
}
URLResponse carries a provider-hosted URL the client opens next.
type Uptime ¶
type Uptime struct {
App string `json:"app"`
// State is up, down, pending, paused, stopped or no_domains.
State string `json:"state"`
Server string `json:"server"`
ServerOnline bool `json:"server_online"`
Domains []UptimeDomain `json:"domains"`
}
Uptime is the answer of GET /api/v1/apps/{app}/uptime: the state of the app as a whole, its server, and each domain.
type UptimeDomain ¶
type UptimeDomain struct {
Domain string `json:"domain"`
// Path is where the visit goes; custom_path says it was set, not /.
Path string `json:"path"`
CustomPath bool `json:"custom_path"`
Paused bool `json:"paused"`
// State is up, down, pending or paused, since when it began.
State string `json:"state"`
Since *time.Time `json:"since"`
VisitedAt *time.Time `json:"visited_at"`
StatusCode int `json:"status_code"`
ResponseMS int `json:"response_ms"`
Error string `json:"error"`
CertExpiresAt *time.Time `json:"cert_expires_at"`
// Uptime in percent; null without a visit in that time.
Uptime24h *float64 `json:"uptime_24h"`
Uptime7d *float64 `json:"uptime_7d"`
Uptime30d *float64 `json:"uptime_30d"`
AverageMS int `json:"average_ms"`
Outages []Outage `json:"outages"`
}
UptimeDomain is the uptime of one domain.
func NewUptimeDomain ¶
func NewUptimeDomain(domain service.UptimeDomain) UptimeDomain
NewUptimeDomain is the JSON shape of a domain's uptime.
type UptimeRequest ¶
UptimeRequest is the body of PUT /api/v1/apps/{app}/uptime/{domain}. A missing field keeps its setting; an empty path goes back to the health path or /.
type User ¶
type User struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
// GitHubLogin is the GitHub account the user signs in with, like
// octocat, or "" before one is connected.
GitHubLogin string `json:"github_login"`
// EmailAlerts mails the user when a site or a server goes down or
// comes back, or a deploy fails, in the workspaces they own or run as
// admin.
EmailAlerts bool `json:"email_alerts"`
CreatedAt time.Time `json:"created_at"`
}
User is the public JSON shape of an account. It never carries a key or any token.
type UserResponse ¶
type UserResponse struct {
User User `json:"user"`
}
UserResponse wraps a user for endpoints that answer {"user": ...}.
type VersionHandler ¶
type VersionHandler struct {
// contains filtered or unexported fields
}
VersionHandler answers the version of the hub, the newest release, and the workspace's automatic daemon updates.
func NewVersionHandler ¶
func NewVersionHandler(updates *service.UpdateService, servers *service.ServerService) *VersionHandler
func (*VersionHandler) DaemonUpdates ¶
func (h *VersionHandler) DaemonUpdates(w http.ResponseWriter, r *http.Request)
DaemonUpdates answers whether the daemons update by themselves.
func (*VersionHandler) SetDaemonUpdates ¶
func (h *VersionHandler) SetDaemonUpdates(w http.ResponseWriter, r *http.Request)
SetDaemonUpdates turns automatic daemon updates on or off.
func (*VersionHandler) Show ¶
func (h *VersionHandler) Show(w http.ResponseWriter, r *http.Request)
Show answers the version and the newest release.
type VersionInfo ¶
type VersionInfo struct {
// Version is the hub's version, the one daemons update to.
Version string `json:"version"`
// SelfHosted is false on the hosted hub, which updates with
// every release; the fields below stay empty there.
SelfHosted bool `json:"self_hosted"`
Latest string `json:"latest"`
UpdateAvailable bool `json:"update_available"`
PublishedAt *time.Time `json:"published_at"`
NotesURL string `json:"notes_url"`
Summary string `json:"summary"`
Notes string `json:"notes"`
// ReadFirst goes above the notes before every update, while one is out.
ReadFirst string `json:"read_first,omitempty"`
CheckedAt *time.Time `json:"checked_at"`
// HubBackup is how the backup of the hub's own database stands, for
// the admins of the hub only; null for everyone else.
HubBackup *model.HubBackup `json:"hub_backup"`
}
VersionInfo is the answer of GET /api/v1/version.
func NewVersion ¶
func NewVersion(info model.VersionInfo) VersionInfo
NewVersion is the JSON shape of the version info.
type Workspace ¶
Workspace is the public JSON shape of a workspace. Its ID is the UUID without dashes, as links carry it; the API takes either.
func NewWorkspace ¶
NewWorkspace converts a workspace model into its public JSON shape.
type WorkspaceDetail ¶
type WorkspaceDetail struct {
Workspace Workspace `json:"workspace"`
Role string `json:"role"`
Permissions WorkspacePermissions `json:"permissions"`
Members []WorkspaceMember `json:"members"`
Invitations []PendingInvitation `json:"invitations"`
Seats Seats `json:"seats"`
}
WorkspaceDetail is a workspace with the role and permissions of the current member, its members, pending invitations and seats.
func NewWorkspaceDetail ¶
func NewWorkspaceDetail(workspaces *service.WorkspaceService, workspace *model.Workspace, member *model.WorkspaceMember, subscription *model.Subscription) (WorkspaceDetail, error)
NewWorkspaceDetail loads the members of a workspace, and its pending invitations for members who may manage them, and builds the detail the member sees. Seats.Limit comes from the plan of subscription.
type WorkspaceEvent ¶
type WorkspaceEvent struct {
ID string `json:"id"`
ActorUserID *string `json:"actor_user_id"`
// ActorName is the member's name; ActorEmail is for admins and owners
// only, left out for members.
ActorName string `json:"actor_name"`
ActorEmail string `json:"actor_email,omitempty"`
Action string `json:"action"`
TargetType string `json:"target_type"`
TargetID string `json:"target_id"`
Metadata string `json:"metadata"`
// Actor and Summary read as a sentence: "Ada Lovelace deployed blog
// v12". Via is web, cli, tui, api, mcp, hook, github or system;
// Token is the connection or CI token it came with, by name.
Actor string `json:"actor"`
Summary string `json:"summary"`
Via string `json:"via"`
Token string `json:"token"`
// App and Server are what the change touched, by name.
App string `json:"app"`
Server string `json:"server"`
// IP and UserAgent are of the member's request, for admins only.
IP string `json:"ip,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
// CreatedAt is in UTC with full precision.
CreatedAt time.Time `json:"created_at"`
}
WorkspaceEvent is one entry of the workspace activity.
type WorkspaceHandler ¶
type WorkspaceHandler struct {
// contains filtered or unexported fields
}
WorkspaceHandler serves workspaces, their members and invitations, and workspace activity. Every rule and permission check lives in WorkspaceService, like for the HTML handler.
func NewWorkspaceHandler ¶
func NewWorkspaceHandler(workspaces *service.WorkspaceService) *WorkspaceHandler
func (*WorkspaceHandler) Activity ¶
func (h *WorkspaceHandler) Activity(w http.ResponseWriter, r *http.Request)
Activity returns workspace activity, newest first, in pages of limit events (default 50, at most 200). next_cursor continues after the last event and is null on the last page.
func (*WorkspaceHandler) ChangeRole ¶
func (h *WorkspaceHandler) ChangeRole(w http.ResponseWriter, r *http.Request)
ChangeRole changes the role of a member and returns the member.
func (*WorkspaceHandler) Create ¶
func (h *WorkspaceHandler) Create(w http.ResponseWriter, r *http.Request)
Create creates a workspace owned by the user.
func (*WorkspaceHandler) Delete ¶
func (h *WorkspaceHandler) Delete(w http.ResponseWriter, r *http.Request)
Delete deletes the workspace; ?confirm= is its name, typed out.
func (*WorkspaceHandler) Invite ¶
func (h *WorkspaceHandler) Invite(w http.ResponseWriter, r *http.Request)
Invite sends an invitation. It answers 202 because the invitation is delivered by email; GET on the workspace lists it.
func (*WorkspaceHandler) Leave ¶
func (h *WorkspaceHandler) Leave(w http.ResponseWriter, r *http.Request)
Leave removes the user from the workspace.
func (*WorkspaceHandler) List ¶
func (h *WorkspaceHandler) List(w http.ResponseWriter, r *http.Request)
List returns the workspaces of the user with the user's role.
func (*WorkspaceHandler) RemoveMember ¶
func (h *WorkspaceHandler) RemoveMember(w http.ResponseWriter, r *http.Request)
RemoveMember removes a member from the workspace.
func (*WorkspaceHandler) ResendInvitation ¶
func (h *WorkspaceHandler) ResendInvitation(w http.ResponseWriter, r *http.Request)
ResendInvitation sends a pending invitation again.
func (*WorkspaceHandler) RevokeInvitation ¶
func (h *WorkspaceHandler) RevokeInvitation(w http.ResponseWriter, r *http.Request)
RevokeInvitation revokes a pending invitation.
func (*WorkspaceHandler) Show ¶
func (h *WorkspaceHandler) Show(w http.ResponseWriter, r *http.Request)
Show returns the workspace page data: the workspace, the role and permissions of the member, members, pending invitations for members who may manage them, and seats.
func (*WorkspaceHandler) UpdateName ¶
func (h *WorkspaceHandler) UpdateName(w http.ResponseWriter, r *http.Request)
UpdateName renames the workspace. Its slug follows the name, and so do the links inside moin.
type WorkspaceInvitationHandler ¶
type WorkspaceInvitationHandler struct {
// contains filtered or unexported fields
}
WorkspaceInvitationHandler shows and accepts workspace invitations by the token from the invitation email.
func NewWorkspaceInvitationHandler ¶
func NewWorkspaceInvitationHandler(workspaces *service.WorkspaceService) *WorkspaceInvitationHandler
func (*WorkspaceInvitationHandler) Accept ¶
func (h *WorkspaceInvitationHandler) Accept(w http.ResponseWriter, r *http.Request)
Accept adds the signed-in user to the workspace of the invitation and returns the membership.
func (*WorkspaceInvitationHandler) Show ¶
func (h *WorkspaceInvitationHandler) Show(w http.ResponseWriter, r *http.Request)
Show returns the workspace name, the inviter, the role and the expiry of an open invitation. It needs no session.
type WorkspaceMember ¶
type WorkspaceMember struct {
ID string `json:"id"`
UserID string `json:"user_id"`
Name string `json:"name"`
Email string `json:"email,omitempty"`
Role string `json:"role"`
CreatedAt time.Time `json:"created_at"`
}
WorkspaceMember is a member of a workspace. Email is empty for viewers who may not manage members.
func NewWorkspaceMember ¶
func NewWorkspaceMember(member *model.WorkspaceMember) WorkspaceMember
NewWorkspaceMember converts a member model into its public JSON shape.
type WorkspacePermissions ¶
type WorkspacePermissions struct {
ManageWorkspace bool `json:"manage_workspace"`
ManageMembers bool `json:"manage_members"`
ManageOwners bool `json:"manage_owners"`
ManageBilling bool `json:"manage_billing"`
DeleteWorkspace bool `json:"delete_workspace"`
ViewActivity bool `json:"view_activity"`
}
WorkspacePermissions lists what the current member may do.
type Wrap ¶
type Wrap func(http.HandlerFunc) http.HandlerFunc
Wrap adds one middleware to a route handler.
Source Files
¶
- account.go
- account_avatar.go
- account_deletion.go
- account_dependencies.go
- admin.go
- alerts.go
- apps.go
- auth.go
- auth_handler.go
- avatar.go
- backups.go
- billing.go
- buckets.go
- catalog.go
- ci_tokens.go
- connections.go
- csrf.go
- data.go
- decode.go
- device.go
- exec.go
- github.go
- meta.go
- metrics.go
- oauth.go
- openapi.go
- passkeys.go
- plan.go
- respond.go
- rights.go
- routes.go
- security.go
- servers.go
- sessions.go
- status.go
- streams.go
- subscription.go
- token.go
- token_binding.go
- uptime.go
- user.go
- version.go
- workspace.go
- workspace_invitation.go
- workspace_types.go