Documentation
¶
Index ¶
- type AgentInfo
- type AgentRegistrationCode
- type DB
- func (db *DB) AddWorkspaceMember(workspaceID, userID, role string) error
- func (db *DB) AddWorkspaceVolume(id, workspaceID, pvcName, mountPath string) error
- func (db *DB) ConsumeAgentRegistrationCode(code string) (*AgentRegistrationCode, error)
- func (db *DB) CountSandboxesByWorkspace(workspaceID string) (int, error)
- func (db *DB) CountUsers() (int, error)
- func (db *DB) CountWorkspacesOwnedByUser(userID string) (int, error)
- func (db *DB) CreateAgentRegistrationCode(code, userID, workspaceID string, expiresAt time.Time) error
- func (db *DB) CreateLocalSandbox(...) error
- func (db *DB) CreateOIDCIdentity(provider, subject, userID string, email *string) error
- func (db *DB) CreateSandbox(...) error
- func (db *DB) CreateToken(token, userID string, expiresAt time.Time) error
- func (db *DB) CreateUser(id, username, email, passwordHash string) error
- func (db *DB) CreateUserWithEmail(id, username string, passwordHash *string, email string) error
- func (db *DB) CreateWorkspace(id, name string) error
- func (db *DB) DeleteExpiredTokens() error
- func (db *DB) DeleteSandbox(id string) error
- func (db *DB) DeleteUserQuota(userID string) error
- func (db *DB) DeleteWorkspace(id string) error
- func (db *DB) DeleteWorkspaceQuota(workspaceID string) error
- func (db *DB) GetAgentInfo(sandboxID string) (*AgentInfo, error)
- func (db *DB) GetAllWorkspaceNamespaces() ([]string, error)
- func (db *DB) GetOIDCIdentity(provider, subject string) (*OIDCIdentity, error)
- func (db *DB) GetPasswordHash(userID string) (*string, error)
- func (db *DB) GetSandbox(id string) (*Sandbox, error)
- func (db *DB) GetSandboxByProxyToken(proxyToken string) (*Sandbox, error)
- func (db *DB) GetSandboxByShortID(shortID string) (*Sandbox, error)
- func (db *DB) GetSandboxByTunnelToken(sandboxID, tunnelToken string) (*Sandbox, error)
- func (db *DB) GetSystemSetting(key string) (string, error)
- func (db *DB) GetUserByEmail(email string) (*User, error)
- func (db *DB) GetUserByID(id string) (*User, error)
- func (db *DB) GetUserByUsername(username string) (*User, error)
- func (db *DB) GetUserQuota(userID string) (*UserQuota, error)
- func (db *DB) GetWorkspace(id string) (*Workspace, error)
- func (db *DB) GetWorkspaceMember(workspaceID, userID string) (*WorkspaceMember, error)
- func (db *DB) GetWorkspaceMemberRole(workspaceID, userID string) (string, error)
- func (db *DB) GetWorkspaceQuota(workspaceID string) (*WorkspaceQuota, error)
- func (db *DB) IsWorkspaceMember(workspaceID, userID string) (bool, error)
- func (db *DB) ListAllActiveSandboxNames() ([]string, error)
- func (db *DB) ListAllSandboxes() ([]*Sandbox, error)
- func (db *DB) ListAllUsers() ([]*User, error)
- func (db *DB) ListAllWorkspaces() ([]*Workspace, error)
- func (db *DB) ListIdleSandboxes(defaultTimeoutSeconds int) ([]*Sandbox, error)
- func (db *DB) ListSandboxesByWorkspace(workspaceID string) ([]*Sandbox, error)
- func (db *DB) ListWorkspaceMembers(workspaceID string) ([]*WorkspaceMember, error)
- func (db *DB) ListWorkspaceVolumes(workspaceID string) ([]WorkspaceVolume, error)
- func (db *DB) ListWorkspacesByUser(userID string) ([]*Workspace, error)
- func (db *DB) ListWorkspacesWithoutNamespace() ([]*Workspace, error)
- func (db *DB) RemoveWorkspaceMember(workspaceID, userID string) error
- func (db *DB) SetPasswordHash(userID, hash string) error
- func (db *DB) SetSystemSetting(key, value string) error
- func (db *DB) SetUserQuota(userID string, maxWorkspaces *int) error
- func (db *DB) SetWorkspaceNamespace(id, namespace string) error
- func (db *DB) SetWorkspaceQuota(workspaceID string, maxSandboxes *int, maxSandboxCPU *int, ...) error
- func (db *DB) SumWorkspaceSandboxResources(workspaceID string) (cpuMillis int64, memBytes int64, err error)
- func (db *DB) UpdateOIDCIdentityEmail(provider, subject, email string) error
- func (db *DB) UpdateSandboxActivity(id string) error
- func (db *DB) UpdateSandboxHeartbeat(id string) error
- func (db *DB) UpdateSandboxName(id, name string) error
- func (db *DB) UpdateSandboxPodIP(id, podIP string) error
- func (db *DB) UpdateSandboxSandboxName(id, sandboxName string) error
- func (db *DB) UpdateSandboxStatus(id, status string) error
- func (db *DB) UpdateUserEmail(userID, email string) error
- func (db *DB) UpdateUserName(userID, name string) error
- func (db *DB) UpdateUserPicture(userID, picture string) error
- func (db *DB) UpdateUserRole(userID, role string) error
- func (db *DB) UpdateWorkspaceMemberRole(workspaceID, userID, role string) error
- func (db *DB) UpdateWorkspaceName(id, name string) error
- func (db *DB) UpsertAgentInfo(info *AgentInfo) error
- func (db *DB) ValidateToken(token string) (string, error)
- type OIDCIdentity
- type Sandbox
- type User
- type UserQuota
- type Workspace
- type WorkspaceMember
- type WorkspaceQuota
- type WorkspaceVolume
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentInfo ¶ added in v0.16.0
type AgentInfo struct {
SandboxID string `json:"sandbox_id"`
Hostname string `json:"hostname"`
OS string `json:"os"`
Platform string `json:"platform"`
PlatformVersion string `json:"platform_version"`
KernelArch string `json:"kernel_arch"`
CPUModelName string `json:"cpu_model_name"`
CPUCountLogical int `json:"cpu_count_logical"`
MemoryTotal int64 `json:"memory_total"`
DiskTotal int64 `json:"disk_total"`
DiskFree int64 `json:"disk_free"`
AgentVersion string `json:"agent_version"`
OpencodeVersion string `json:"opencode_version"`
HostInfo json.RawMessage `json:"host_info"`
CPUInfo json.RawMessage `json:"cpu_info"`
MemoryInfo json.RawMessage `json:"memory_info"`
DiskInfo json.RawMessage `json:"disk_info"`
UpdatedAt time.Time `json:"updated_at"`
}
AgentInfo holds system information reported by a local agent.
type AgentRegistrationCode ¶
type DB ¶
DB wraps a *sql.DB with migration support.
func (*DB) AddWorkspaceMember ¶
func (*DB) AddWorkspaceVolume ¶ added in v0.9.0
func (*DB) ConsumeAgentRegistrationCode ¶
func (db *DB) ConsumeAgentRegistrationCode(code string) (*AgentRegistrationCode, error)
ConsumeAgentRegistrationCode atomically validates and marks a code as used. Returns the code record if valid, nil if not found/expired/used.
func (*DB) CountSandboxesByWorkspace ¶ added in v0.7.0
func (*DB) CountUsers ¶ added in v0.6.1
func (*DB) CountWorkspacesOwnedByUser ¶ added in v0.7.0
func (*DB) CreateAgentRegistrationCode ¶
func (db *DB) CreateAgentRegistrationCode(code, userID, workspaceID string, expiresAt time.Time) error
CreateAgentRegistrationCode inserts a new one-time registration code.
func (*DB) CreateLocalSandbox ¶
func (db *DB) CreateLocalSandbox(id, workspaceID, name, sandboxType, opencodeToken, proxyToken, tunnelToken, shortID string) error
CreateLocalSandbox inserts a local agent sandbox with is_local=true.
func (*DB) CreateOIDCIdentity ¶
func (*DB) CreateSandbox ¶
func (*DB) CreateUser ¶
func (*DB) CreateUserWithEmail ¶
func (*DB) CreateWorkspace ¶
func (*DB) DeleteExpiredTokens ¶
func (*DB) DeleteSandbox ¶
func (*DB) DeleteUserQuota ¶ added in v0.7.0
func (*DB) DeleteWorkspace ¶
func (*DB) DeleteWorkspaceQuota ¶ added in v0.9.0
func (*DB) GetAgentInfo ¶ added in v0.16.0
GetAgentInfo returns agent info for a sandbox, or nil,nil if not found.
func (*DB) GetAllWorkspaceNamespaces ¶
func (*DB) GetOIDCIdentity ¶
func (db *DB) GetOIDCIdentity(provider, subject string) (*OIDCIdentity, error)
func (*DB) GetPasswordHash ¶ added in v0.9.0
GetPasswordHash returns the bcrypt hash for the given user, or nil if no credential exists.
func (*DB) GetSandboxByProxyToken ¶
func (*DB) GetSandboxByShortID ¶
func (*DB) GetSandboxByTunnelToken ¶
GetSandboxByTunnelToken finds a local sandbox by its tunnel token.
func (*DB) GetSystemSetting ¶ added in v0.7.0
func (*DB) GetUserQuota ¶ added in v0.7.0
func (*DB) GetWorkspaceMember ¶
func (db *DB) GetWorkspaceMember(workspaceID, userID string) (*WorkspaceMember, error)
func (*DB) GetWorkspaceMemberRole ¶
func (*DB) GetWorkspaceQuota ¶ added in v0.9.0
func (db *DB) GetWorkspaceQuota(workspaceID string) (*WorkspaceQuota, error)
func (*DB) IsWorkspaceMember ¶
func (*DB) ListAllActiveSandboxNames ¶
func (*DB) ListAllSandboxes ¶ added in v0.6.1
func (*DB) ListAllUsers ¶ added in v0.6.1
func (*DB) ListAllWorkspaces ¶ added in v0.6.1
func (*DB) ListIdleSandboxes ¶
func (*DB) ListSandboxesByWorkspace ¶
func (*DB) ListWorkspaceMembers ¶
func (db *DB) ListWorkspaceMembers(workspaceID string) ([]*WorkspaceMember, error)
func (*DB) ListWorkspaceVolumes ¶ added in v0.9.0
func (db *DB) ListWorkspaceVolumes(workspaceID string) ([]WorkspaceVolume, error)
func (*DB) ListWorkspacesByUser ¶
func (*DB) ListWorkspacesWithoutNamespace ¶
func (*DB) RemoveWorkspaceMember ¶
func (*DB) SetPasswordHash ¶ added in v0.9.0
SetPasswordHash upserts a password hash for the given user.
func (*DB) SetSystemSetting ¶ added in v0.7.0
func (*DB) SetUserQuota ¶ added in v0.7.0
func (*DB) SetWorkspaceNamespace ¶
func (*DB) SetWorkspaceQuota ¶ added in v0.9.0
func (*DB) SumWorkspaceSandboxResources ¶ added in v0.7.0
func (db *DB) SumWorkspaceSandboxResources(workspaceID string) (cpuMillis int64, memBytes int64, err error)
SumWorkspaceSandboxResources returns the total CPU (millicores) and memory (bytes) allocated by non-offline sandboxes in a workspace.
func (*DB) UpdateOIDCIdentityEmail ¶ added in v0.9.0
func (*DB) UpdateSandboxActivity ¶
func (*DB) UpdateSandboxHeartbeat ¶
UpdateSandboxHeartbeat updates the last_heartbeat_at timestamp.
func (*DB) UpdateSandboxName ¶ added in v0.16.0
func (*DB) UpdateSandboxPodIP ¶
func (*DB) UpdateSandboxSandboxName ¶
func (*DB) UpdateSandboxStatus ¶
func (*DB) UpdateUserEmail ¶
func (*DB) UpdateUserName ¶ added in v0.9.0
func (*DB) UpdateUserPicture ¶ added in v0.9.0
func (*DB) UpdateUserRole ¶ added in v0.6.1
func (*DB) UpdateWorkspaceMemberRole ¶
func (*DB) UpdateWorkspaceName ¶ added in v0.16.0
func (*DB) UpsertAgentInfo ¶ added in v0.16.0
UpsertAgentInfo inserts or updates agent info for a sandbox.
type OIDCIdentity ¶
type Sandbox ¶
type Sandbox struct {
ID string
WorkspaceID string
Name string
Type string
Status string
IsLocal bool
ShortID sql.NullString
SandboxName sql.NullString
PodIP sql.NullString
ProxyToken sql.NullString
OpencodeToken sql.NullString
OpenclawToken sql.NullString
TunnelToken sql.NullString
LastActivityAt sql.NullTime
CreatedAt time.Time
PausedAt sql.NullTime
LastHeartbeatAt sql.NullTime
CPU *int
Memory *int64
IdleTimeout *int
}