243 lines
6.8 KiB
Go
243 lines
6.8 KiB
Go
package metastore
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
const AdminTagName = "admin"
|
|
|
|
type User struct {
|
|
ID string `json:"id"`
|
|
Username string `json:"username"`
|
|
Email string `json:"email,omitempty"`
|
|
PasswordHash string `json:"password_hash"`
|
|
TagIDs []string `json:"tag_ids"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
Disabled bool `json:"disabled"`
|
|
AdminNote string `json:"admin_note,omitempty"`
|
|
MaxFileSizeBytes *int64 `json:"max_file_size_bytes,omitempty"`
|
|
MaxBoxSizeBytes *int64 `json:"max_box_size_bytes,omitempty"`
|
|
MaxExpirySeconds *int64 `json:"max_expiry_seconds,omitempty"`
|
|
PermOverrides *UserPermOverrides `json:"perm_overrides,omitempty"`
|
|
}
|
|
|
|
type UserPermOverrides struct {
|
|
UploadAllowed *bool `json:"upload_allowed,omitempty"`
|
|
ManageOwnBoxes *bool `json:"manage_own_boxes,omitempty"`
|
|
ZipDownloadAllowed *bool `json:"zip_download_allowed,omitempty"`
|
|
OneTimeDownloadAllowed *bool `json:"one_time_download_allowed,omitempty"`
|
|
RenewableAllowed *bool `json:"renewable_allowed,omitempty"`
|
|
AllowPasswordProtected *bool `json:"allow_password_protected,omitempty"`
|
|
RenewOnAccess *bool `json:"renew_on_access,omitempty"`
|
|
RenewOnDownload *bool `json:"renew_on_download,omitempty"`
|
|
AllowOwnerBoxEditing *bool `json:"allow_owner_box_editing,omitempty"`
|
|
}
|
|
|
|
type Tag struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
Protected bool `json:"protected"`
|
|
Permissions TagPermissions `json:"permissions"`
|
|
}
|
|
|
|
type TagPermissions struct {
|
|
UploadAllowed bool `json:"upload_allowed"`
|
|
AllowedExpirySeconds []int64 `json:"allowed_expiry_seconds,omitempty"`
|
|
MaxFileSizeBytes *int64 `json:"max_file_size_bytes,omitempty"`
|
|
MaxBoxSizeBytes *int64 `json:"max_box_size_bytes,omitempty"`
|
|
OneTimeDownloadAllowed bool `json:"one_time_download_allowed"`
|
|
ZipDownloadAllowed bool `json:"zip_download_allowed"`
|
|
RenewableAllowed bool `json:"renewable_allowed"`
|
|
RenewOnAccessSeconds int64 `json:"renew_on_access_seconds,omitempty"`
|
|
RenewOnDownloadSeconds int64 `json:"renew_on_download_seconds,omitempty"`
|
|
AdminAccess bool `json:"admin_access"`
|
|
AdminUsersView bool `json:"admin_users_view"`
|
|
AdminUsersManage bool `json:"admin_users_manage"`
|
|
AdminSettingsManage bool `json:"admin_settings_manage"`
|
|
AdminBoxesView bool `json:"admin_boxes_view"`
|
|
}
|
|
|
|
type Session struct {
|
|
Token string `json:"token"`
|
|
CSRFToken string `json:"csrf_token"`
|
|
UserID string `json:"user_id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
ExpiresAt time.Time `json:"expires_at"`
|
|
}
|
|
|
|
type EffectivePermissions struct {
|
|
UploadAllowed bool
|
|
AllowedExpirySeconds []int64
|
|
MaxFileSizeBytes int64
|
|
MaxBoxSizeBytes int64
|
|
MaxExpirySeconds int64
|
|
OneTimeDownloadAllowed bool
|
|
ZipDownloadAllowed bool
|
|
RenewableAllowed bool
|
|
RenewOnAccessSeconds int64
|
|
RenewOnDownloadSeconds int64
|
|
AdminAccess bool
|
|
AdminUsersView bool
|
|
AdminUsersManage bool
|
|
AdminSettingsManage bool
|
|
AdminBoxesView bool
|
|
}
|
|
|
|
type BootstrapResult struct {
|
|
AdminTag Tag
|
|
AdminUser *User
|
|
AdminLoginEnabled bool
|
|
}
|
|
|
|
type Alert struct {
|
|
ID string `json:"id"`
|
|
Title string `json:"title"`
|
|
Description string `json:"description"`
|
|
Severity string `json:"severity"`
|
|
Status string `json:"status"`
|
|
Code string `json:"code"`
|
|
Trace string `json:"trace"`
|
|
Metadata json.RawMessage `json:"metadata,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
AcknowledgedAt *time.Time `json:"acknowledged_at,omitempty"`
|
|
ClosedAt *time.Time `json:"closed_at,omitempty"`
|
|
CreatedBy string `json:"created_by"`
|
|
}
|
|
|
|
type AlertInput struct {
|
|
Title string
|
|
Description string
|
|
Severity string
|
|
Code string
|
|
Trace string
|
|
Metadata json.RawMessage
|
|
CreatedBy string
|
|
}
|
|
|
|
type AlertFilters struct {
|
|
Query string
|
|
Severity string
|
|
Status string
|
|
Group string
|
|
Sort string
|
|
}
|
|
|
|
type BoxRecord struct {
|
|
ID string `json:"id"`
|
|
OwnerID string `json:"owner_id,omitempty"`
|
|
OwnerUsername string `json:"owner_username,omitempty"`
|
|
FileNames []string `json:"file_names,omitempty"`
|
|
FileCount int `json:"file_count"`
|
|
TotalSize int64 `json:"total_size"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
ExpiresAt time.Time `json:"expires_at"`
|
|
PasswordProtected bool `json:"password_protected"`
|
|
OneTimeDownload bool `json:"one_time_download"`
|
|
DisableZip bool `json:"disable_zip"`
|
|
RefreshCount int `json:"refresh_count"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type BoxFilters struct {
|
|
Query string
|
|
Owner string
|
|
Status string
|
|
Flag string
|
|
Sort string
|
|
}
|
|
|
|
type BoxPageRequest struct {
|
|
Page int
|
|
PageSize int
|
|
}
|
|
|
|
type BoxRecordPage struct {
|
|
Rows []BoxRecord
|
|
Page int
|
|
PageSize int
|
|
Total int
|
|
HasPrev bool
|
|
HasNext bool
|
|
PrevPage int
|
|
NextPage int
|
|
TotalPages int
|
|
}
|
|
|
|
type UserFilters struct {
|
|
Query string
|
|
Status string
|
|
Role string
|
|
Sort string
|
|
}
|
|
|
|
type UserPageRequest struct {
|
|
Page int
|
|
PageSize int
|
|
}
|
|
|
|
type UserRow struct {
|
|
ID string
|
|
Username string
|
|
Email string
|
|
Status string
|
|
Role string
|
|
TagIDs []string
|
|
Tags string
|
|
Plan string
|
|
PolicySummary string
|
|
BoxCount int
|
|
APIKeyCount int
|
|
CreatedAt string
|
|
LastSeen string
|
|
Disabled bool
|
|
IsCurrent bool
|
|
IsInvite bool
|
|
}
|
|
|
|
type UserPage struct {
|
|
Rows []UserRow
|
|
Page int
|
|
PageSize int
|
|
Total int
|
|
HasPrev bool
|
|
HasNext bool
|
|
PrevPage int
|
|
NextPage int
|
|
TotalPages int
|
|
Stats UserPageStats
|
|
}
|
|
|
|
type UserPageStats struct {
|
|
TotalUsers int
|
|
ActiveUsers int
|
|
PendingInvites int
|
|
DisabledUsers int
|
|
}
|
|
|
|
type CreateUserInput struct {
|
|
Username string
|
|
Email string
|
|
Password string
|
|
Mode string
|
|
Role string
|
|
Plan string
|
|
AdminNote string
|
|
SendSetup bool
|
|
ForceChange bool
|
|
}
|
|
|
|
type CreateUserResult struct {
|
|
User User
|
|
InviteToken string
|
|
InviteLink string
|
|
IsInvite bool
|
|
PasswordSet string
|
|
InviteNotSent bool
|
|
}
|