tables

package
v1.2.39 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package tables contains the database tables for the configstore.

Package tables provides tables for the configstore

Package tables provides tables for the configstore

Package tables provides tables for the configstore

Package tables provides tables for the configstore

Index

Constants

View Source
const (
	ConfigAdminUsernameKey          = "admin_username"
	ConfigAdminPasswordKey          = "admin_password"
	ConfigIsAuthEnabledKey          = "is_auth_enabled"
	ConfigDisableAuthOnInferenceKey = "disable_auth_on_inference"
	ConfigProxyKey                  = "proxy_config"
	ConfigRestartRequiredKey        = "restart_required"
	ConfigHeaderFilterKey           = "header_filter_config"
)
View Source
const (
	// EncryptionStatusPlainText indicates the row's sensitive fields are stored as plaintext.
	EncryptionStatusPlainText = "plain_text"
	// EncryptionStatusEncrypted indicates the row's sensitive fields have been encrypted.
	EncryptionStatusEncrypted = "encrypted"
)

Variables

This section is empty.

Functions

func GetCalendarPeriodStart

func GetCalendarPeriodStart(duration string, t time.Time) time.Time

GetCalendarPeriodStart returns the start of the current calendar period for the given duration and time. For calendar-scale durations (daily, weekly, monthly, yearly) it snaps to clean boundaries in UTC:

  • "Nd" → midnight UTC on the current day
  • "Nw" → midnight UTC on the most recent Monday
  • "NM" → midnight UTC on the 1st of the current month
  • "NY" → midnight UTC on Jan 1 of the current year

For all other durations (e.g. "1h", "30m") the original time t is returned unchanged, since sub-day periods don't have a natural calendar boundary.

func IsCalendarAlignableDuration

func IsCalendarAlignableDuration(duration string) bool

IsCalendarAlignableDuration reports whether the given duration string supports calendar-aligned resets. Only day ("d"), week ("w"), month ("M"), and year ("Y") suffixes have natural calendar boundaries. Sub-day durations like "1h", "30m" are not alignable.

func ParseDuration

func ParseDuration(duration string) (time.Duration, error)

ParseDuration function to parse duration strings

Types

type GlobalHeaderFilterConfig

type GlobalHeaderFilterConfig struct {
	Allowlist []string `json:"allowlist,omitempty"` // If non-empty, only these headers are allowed
	Denylist  []string `json:"denylist,omitempty"`  // Headers to always block
}

GlobalHeaderFilterConfig represents global header filtering configuration for headers forwarded to LLM providers via the x-bf-eh-* prefix. Filter logic: - If allowlist is non-empty, only headers in the allowlist are forwarded - If denylist is non-empty, headers in the denylist are dropped - If both are non-empty, allowlist takes precedence first, then denylist filters the result

type GlobalProxyConfig

type GlobalProxyConfig struct {
	Enabled       bool                    `json:"enabled"`
	Type          network.GlobalProxyType `json:"type"`                      // "http", "socks5", "tcp"
	URL           string                  `json:"url"`                       // Proxy URL (e.g., http://proxy.example.com:8080)
	Username      string                  `json:"username,omitempty"`        // Optional authentication username
	Password      string                  `json:"password,omitempty"`        // Optional authentication password
	NoProxy       string                  `json:"no_proxy,omitempty"`        // Comma-separated list of hosts to bypass proxy
	Timeout       int                     `json:"timeout,omitempty"`         // Connection timeout in seconds
	SkipTLSVerify bool                    `json:"skip_tls_verify,omitempty"` // Skip TLS certificate verification
	// Entity enablement flags
	EnableForSCIM      bool `json:"enable_for_scim"`      // Enable proxy for SCIM requests (enterprise only)
	EnableForInference bool `json:"enable_for_inference"` // Enable proxy for inference requests
	EnableForAPI       bool `json:"enable_for_api"`       // Enable proxy for API requests
}

GlobalProxyConfig represents the global proxy configuration

type ModelParams

type ModelParams map[string]interface{}

ModelParams represents model configuration parameters as a flexible map so that any provider-specific params (response_format, seed, logprobs, etc.) are preserved.

type PromptMessage

type PromptMessage = json.RawMessage

PromptMessage is a raw JSON message stored in the database. The frontend handles serialization/deserialization of the message format. The backend treats it as opaque JSON to remain format-agnostic and backward-compatible.

type RestartRequiredConfig

type RestartRequiredConfig struct {
	Required bool   `json:"required"`
	Reason   string `json:"reason,omitempty"`
}

RestartRequiredConfig represents the restart required configuration This is set when a config change requires a server restart to take effect

type SessionsTable

type SessionsTable struct {
	ID               int       `gorm:"primaryKey;autoIncrement" json:"id"`
	Token            string    `gorm:"type:text;not null;uniqueIndex" json:"token"`
	ExpiresAt        time.Time `gorm:"index;not null" json:"expires_at,omitempty"`
	CreatedAt        time.Time `gorm:"index;not null" json:"created_at"`
	UpdatedAt        time.Time `gorm:"index;not null" json:"updated_at"`
	EncryptionStatus string    `gorm:"type:varchar(20);default:'plain_text'" json:"-"`
	TokenHash        string    `gorm:"type:varchar(64);index:idx_session_token_hash,unique" json:"-"`
}

SessionsTable represents a session in the database

func (*SessionsTable) AfterFind

func (s *SessionsTable) AfterFind(tx *gorm.DB) error

AfterFind hook to decrypt the session token

func (*SessionsTable) BeforeSave

func (s *SessionsTable) BeforeSave(tx *gorm.DB) error

BeforeSave hook to hash and encrypt the session token

func (SessionsTable) TableName

func (SessionsTable) TableName() string

TableName sets the table name for each model

type TableBudget

type TableBudget struct {
	ID            string    `gorm:"primaryKey;type:varchar(255)" json:"id"`
	MaxLimit      float64   `gorm:"not null" json:"max_limit"`                       // Maximum budget in dollars
	ResetDuration string    `gorm:"type:varchar(50);not null" json:"reset_duration"` // e.g., "30s", "5m", "1h", "1d", "1w", "1M", "1Y"
	LastReset     time.Time `gorm:"index" json:"last_reset"`                         // Last time budget was reset
	CurrentUsage  float64   `gorm:"default:0" json:"current_usage"`                  // Current usage in dollars

	// CalendarAligned snaps LastReset to the start of the current calendar period (day, week, month, year)
	// instead of the exact creation/update time, so budgets reset at clean calendar boundaries.
	CalendarAligned bool `gorm:"default:false" json:"calendar_aligned"`

	// Config hash is used to detect the changes synced from config.json file
	// Every time we sync the config.json file, we will update the config hash
	ConfigHash string `gorm:"type:varchar(255);null" json:"config_hash"`

	CreatedAt time.Time `gorm:"index;not null" json:"created_at"`
	UpdatedAt time.Time `gorm:"index;not null" json:"updated_at"`
}

TableBudget defines spending limits with configurable reset periods

func (*TableBudget) BeforeSave

func (b *TableBudget) BeforeSave(tx *gorm.DB) error

BeforeSave hook for Budget to validate reset duration format and max limit

func (TableBudget) TableName

func (TableBudget) TableName() string

TableName sets the table name for each model

type TableClientConfig

type TableClientConfig struct {
	ID                              uint   `gorm:"primaryKey;autoIncrement" json:"id"`
	DropExcessRequests              bool   `gorm:"default:false" json:"drop_excess_requests"`
	PrometheusLabelsJSON            string `gorm:"type:text" json:"-"` // JSON serialized []string
	AllowedOriginsJSON              string `gorm:"type:text" json:"-"` // JSON serialized []string
	AllowedHeadersJSON              string `gorm:"type:text" json:"-"` // JSON serialized []string
	HeaderFilterConfigJSON          string `gorm:"type:text" json:"-"` // JSON serialized GlobalHeaderFilterConfig
	InitialPoolSize                 int    `gorm:"default:300" json:"initial_pool_size"`
	EnableLogging                   *bool  `gorm:"default:true" json:"enable_logging"`
	DisableContentLogging           bool   `gorm:"default:false" json:"disable_content_logging"` // DisableContentLogging controls whether sensitive content (inputs, outputs, embeddings, etc.) is logged
	DisableDBPingsInHealth          bool   `gorm:"default:false" json:"disable_db_pings_in_health"`
	LogRetentionDays                int    `gorm:"default:365" json:"log_retention_days" validate:"min=1"` // Number of days to retain logs (minimum 1 day)
	EnforceAuthOnInference          bool   `gorm:"default:false" json:"enforce_auth_on_inference"`
	EnforceGovernanceHeader         bool   `gorm:"" json:"enforce_governance_header"`
	EnforceSCIMAuth                 bool   `gorm:"default:false" json:"enforce_scim_auth"`
	AllowDirectKeys                 bool   `gorm:"" json:"allow_direct_keys"`
	MaxRequestBodySizeMB            int    `gorm:"default:100" json:"max_request_body_size_mb"`
	MCPAgentDepth                   int    `gorm:"default:10" json:"mcp_agent_depth"`
	MCPToolExecutionTimeout         int    `gorm:"default:30" json:"mcp_tool_execution_timeout"`              // Timeout for individual tool execution in seconds (default: 30)
	MCPCodeModeBindingLevel         string `gorm:"default:server" json:"mcp_code_mode_binding_level"`         // How tools are exposed in VFS: "server" or "tool"
	MCPToolSyncInterval             int    `gorm:"default:10" json:"mcp_tool_sync_interval"`                  // Global tool sync interval in minutes (default: 10, 0 = disabled)
	AsyncJobResultTTL               int    `gorm:"default:3600" json:"async_job_result_ttl"`                  // Default TTL for async job results in seconds (default: 3600 = 1 hour)
	RequiredHeadersJSON             string `gorm:"type:text" json:"-"`                                        // JSON serialized []string
	LoggingHeadersJSON              string `gorm:"type:text" json:"-"`                                        // JSON serialized []string
	HideDeletedVirtualKeysInFilters bool   `gorm:"default:false" json:"hide_deleted_virtual_keys_in_filters"` // Hide deleted virtual keys in logs filter dropdowns
	WhitelistedRoutesJSON           string `gorm:"type:text" json:"-"`                                        // JSON serialized []string

	// LiteLLM fallback flag
	EnableLiteLLMFallbacks bool `gorm:"column:enable_litellm_fallbacks;default:false" json:"enable_litellm_fallbacks"`

	// Config hash is used to detect the changes synced from config.json file
	// Every time we sync the config.json file, we will update the config hash
	ConfigHash string `gorm:"type:varchar(255);null" json:"config_hash"`

	CreatedAt time.Time `gorm:"index;not null" json:"created_at"`
	UpdatedAt time.Time `gorm:"index;not null" json:"updated_at"`

	// Virtual fields for runtime use (not stored in DB)
	PrometheusLabels   []string                  `gorm:"-" json:"prometheus_labels"`
	AllowedOrigins     []string                  `gorm:"-" json:"allowed_origins,omitempty"`
	AllowedHeaders     []string                  `gorm:"-" json:"allowed_headers,omitempty"`
	RequiredHeaders    []string                  `gorm:"-" json:"required_headers,omitempty"`
	LoggingHeaders     []string                  `gorm:"-" json:"logging_headers,omitempty"`
	WhitelistedRoutes  []string                  `gorm:"-" json:"whitelisted_routes,omitempty"`
	HeaderFilterConfig *GlobalHeaderFilterConfig `gorm:"-" json:"header_filter_config,omitempty"`
}

TableClientConfig represents global client configuration in the database

func (*TableClientConfig) AfterFind

func (cc *TableClientConfig) AfterFind(tx *gorm.DB) error

AfterFind hooks for deserialization

func (*TableClientConfig) BeforeSave

func (cc *TableClientConfig) BeforeSave(tx *gorm.DB) error

func (TableClientConfig) TableName

func (TableClientConfig) TableName() string

TableName sets the table name for each model

type TableConfigHash

type TableConfigHash struct {
	ID        uint      `gorm:"primaryKey;autoIncrement" json:"id"`
	Hash      string    `gorm:"type:varchar(255);uniqueIndex;not null" json:"hash"`
	CreatedAt time.Time `gorm:"index;not null" json:"created_at"`
	UpdatedAt time.Time `gorm:"index;not null" json:"updated_at"`
}

TableConfigHash represents the configuration hash in the database

func (TableConfigHash) TableName

func (TableConfigHash) TableName() string

TableName sets the table name for each model

type TableCustomer

type TableCustomer struct {
	ID          string  `gorm:"primaryKey;type:varchar(255)" json:"id"`
	Name        string  `gorm:"type:varchar(255);not null" json:"name"`
	BudgetID    *string `gorm:"type:varchar(255);index" json:"budget_id,omitempty"`
	RateLimitID *string `gorm:"type:varchar(255);index" json:"rate_limit_id,omitempty"`

	// Relationships
	Budget      *TableBudget      `gorm:"foreignKey:BudgetID" json:"budget,omitempty"`
	RateLimit   *TableRateLimit   `gorm:"foreignKey:RateLimitID" json:"rate_limit,omitempty"`
	Teams       []TableTeam       `gorm:"foreignKey:CustomerID" json:"teams"`
	VirtualKeys []TableVirtualKey `gorm:"foreignKey:CustomerID" json:"virtual_keys"`

	// Config hash is used to detect the changes synced from config.json file
	// Every time we sync the config.json file, we will update the config hash
	ConfigHash string `gorm:"type:varchar(255);null" json:"config_hash"`

	CreatedAt time.Time `gorm:"index;not null" json:"created_at"`
	UpdatedAt time.Time `gorm:"index;not null" json:"updated_at"`
}

TableCustomer represents a customer entity with budget and rate limit

func (TableCustomer) TableName

func (TableCustomer) TableName() string

TableName sets the table name for each model

type TableDistributedLock

type TableDistributedLock struct {
	LockKey   string    `gorm:"primaryKey;column:lock_key;size:255" json:"lock_key"`
	HolderID  string    `gorm:"column:holder_id;size:255;not null" json:"holder_id"`
	ExpiresAt time.Time `gorm:"column:expires_at;not null;index" json:"expires_at"`
	CreatedAt time.Time `gorm:"column:created_at;autoCreateTime" json:"created_at"`
}

TableDistributedLock represents a distributed lock entry in the database. This table is used to implement distributed locking across multiple instances.

func (TableDistributedLock) TableName

func (TableDistributedLock) TableName() string

TableName returns the table name for the distributed lock table.

type TableEnvKey

type TableEnvKey struct {
	ID         uint      `gorm:"primaryKey;autoIncrement" json:"id"`
	EnvVar     string    `gorm:"type:varchar(255);index;not null" json:"env_var"`
	Provider   string    `gorm:"type:varchar(50);index" json:"provider"`        // Empty for MCP/client configs
	KeyType    string    `gorm:"type:varchar(50);not null" json:"key_type"`     // "api_key", "azure_config", "vertex_config", "bedrock_config", "connection_string"
	ConfigPath string    `gorm:"type:varchar(500);not null" json:"config_path"` // Descriptive path of where this env var is used
	KeyID      string    `gorm:"type:varchar(255);index" json:"key_id"`         // Key UUID (empty for non-key configs)
	CreatedAt  time.Time `gorm:"index;not null" json:"created_at"`
}

TableEnvKey represents environment variable tracking in the database

func (TableEnvKey) TableName

func (TableEnvKey) TableName() string

TableName sets the table name for each model

type TableFolder

type TableFolder struct {
	ID          string    `gorm:"type:varchar(36);primaryKey" json:"id"`
	Name        string    `gorm:"type:varchar(255);not null" json:"name"`
	Description *string   `gorm:"type:text" json:"description,omitempty"`
	CreatedAt   time.Time `gorm:"not null" json:"created_at"`
	UpdatedAt   time.Time `gorm:"not null" json:"updated_at"`
	ConfigHash  string    `gorm:"type:varchar(64)" json:"-"`

	// Virtual fields (not stored in DB)
	PromptsCount int `gorm:"-" json:"prompts_count,omitempty"`
}

TableFolder represents a generic folder that can contain prompts

func (TableFolder) TableName

func (TableFolder) TableName() string

TableName for TableFolder

type TableFrameworkConfig

type TableFrameworkConfig struct {
	ID                                 uint    `gorm:"primaryKey;autoIncrement" json:"id"`
	PricingURL                         *string `gorm:"type:text" json:"pricing_url"`
	PricingSyncInterval                *int64  `gorm:"" json:"pricing_sync_interval"`
	ProviderModelHealthPersistDebounce *int64  `gorm:"column:provider_model_health_persist_debounce_ms" json:"provider_model_health_persist_debounce_ms"`
}

TableFrameworkConfig represents the framework configurations We will keep on adding different columns here as we add new features to the framework

func (TableFrameworkConfig) TableName

func (TableFrameworkConfig) TableName() string

TableName sets the table name for each model

type TableGovernanceConfig

type TableGovernanceConfig struct {
	Key   string `gorm:"primaryKey;type:varchar(255)" json:"key"`
	Value string `gorm:"type:text" json:"value"`
}

TableGovernanceConfig represents generic configuration key-value pairs

func (TableGovernanceConfig) TableName

func (TableGovernanceConfig) TableName() string

TableName sets the table name for each model

type TableKey

type TableKey struct {
	ID                    uint           `gorm:"primaryKey;autoIncrement" json:"id"`
	Name                  string         `gorm:"type:varchar(255);uniqueIndex:idx_key_name;not null" json:"name"`
	ProviderID            uint           `gorm:"index;not null" json:"provider_id"`
	Provider              string         `gorm:"index;type:varchar(50)" json:"provider"`                          // ModelProvider as string
	KeyID                 string         `gorm:"type:varchar(255);uniqueIndex:idx_key_id;not null" json:"key_id"` // UUID from schemas.Key
	Value                 schemas.EnvVar `gorm:"type:text;not null" json:"value"`
	ModelsJSON            string         `gorm:"type:text" json:"-"` // JSON serialized []string
	BlacklistedModelsJSON string         `gorm:"type:text" json:"-"` // JSON serialized []string
	Weight                *float64       `json:"weight"`
	Enabled               *bool          `gorm:"default:true" json:"enabled,omitempty"`
	CreatedAt             time.Time      `gorm:"index;not null" json:"created_at"`
	UpdatedAt             time.Time      `gorm:"index;not null" json:"updated_at"`

	// Config hash is used to detect changes synced from config.json file
	ConfigHash string `gorm:"type:varchar(255);null" json:"config_hash"`

	// Azure config fields (embedded instead of separate table for simplicity)
	AzureEndpoint        *schemas.EnvVar `gorm:"type:text" json:"azure_endpoint,omitempty"`
	AzureAPIVersion      *schemas.EnvVar `gorm:"type:text" json:"azure_api_version,omitempty"`
	AzureDeploymentsJSON *string         `gorm:"type:text" json:"-"` // JSON serialized map[string]string
	AzureClientID        *schemas.EnvVar `gorm:"type:text" json:"azure_client_id,omitempty"`
	AzureClientSecret    *schemas.EnvVar `gorm:"type:text" json:"azure_client_secret,omitempty"`
	AzureTenantID        *schemas.EnvVar `gorm:"type:text" json:"azure_tenant_id,omitempty"`
	AzureScopesJSON      *string         `gorm:"column:azure_scopes;type:text" json:"-"` // JSON serialized []string

	// Vertex config fields (embedded)
	VertexProjectID       *schemas.EnvVar `gorm:"type:text" json:"vertex_project_id,omitempty"`
	VertexProjectNumber   *schemas.EnvVar `gorm:"type:text" json:"vertex_project_number,omitempty"`
	VertexRegion          *schemas.EnvVar `gorm:"type:text" json:"vertex_region,omitempty"`
	VertexAuthCredentials *schemas.EnvVar `gorm:"type:text" json:"vertex_auth_credentials,omitempty"`
	VertexDeploymentsJSON *string         `gorm:"type:text" json:"-"` // JSON serialized map[string]string

	// Bedrock config fields (embedded)
	BedrockAccessKey         *schemas.EnvVar `gorm:"type:text" json:"bedrock_access_key,omitempty"`
	BedrockSecretKey         *schemas.EnvVar `gorm:"type:text" json:"bedrock_secret_key,omitempty"`
	BedrockSessionToken      *schemas.EnvVar `gorm:"type:text" json:"bedrock_session_token,omitempty"`
	BedrockRegion            *schemas.EnvVar `gorm:"type:text" json:"bedrock_region,omitempty"`
	BedrockARN               *schemas.EnvVar `gorm:"type:text" json:"bedrock_arn,omitempty"`
	BedrockRoleARN           *schemas.EnvVar `gorm:"type:text" json:"bedrock_role_arn,omitempty"`
	BedrockExternalID        *schemas.EnvVar `gorm:"type:text" json:"bedrock_external_id,omitempty"`
	BedrockRoleSessionName   *schemas.EnvVar `gorm:"type:text" json:"bedrock_role_session_name,omitempty"`
	BedrockDeploymentsJSON   *string         `gorm:"type:text" json:"-"` // JSON serialized map[string]string
	BedrockBatchS3ConfigJSON *string         `gorm:"type:text" json:"-"` // JSON serialized schemas.BatchS3Config

	// Replicate config fields (embedded)
	ReplicateDeploymentsJSON *string `gorm:"type:text" json:"-"` // JSON serialized map[string]string

	// VLLM config fields (embedded)
	VLLMUrl       *schemas.EnvVar `gorm:"type:text" json:"vllm_url,omitempty"`
	VLLMModelName *string         `gorm:"type:varchar(255)" json:"vllm_model_name,omitempty"`

	// Batch API configuration
	UseForBatchAPI *bool `gorm:"default:false" json:"use_for_batch_api,omitempty"` // Whether this key can be used for batch API operations

	Status      string `gorm:"type:varchar(50);default:'unknown'" json:"status"`
	Description string `gorm:"type:text" json:"description,omitempty"`

	EncryptionStatus string `gorm:"type:varchar(20);default:'plain_text'" json:"-"`

	// Virtual fields for runtime use (not stored in DB)
	Models             []string                    `gorm:"-" json:"models"`
	BlacklistedModels  []string                    `gorm:"-" json:"blacklisted_models"`
	AzureKeyConfig     *schemas.AzureKeyConfig     `gorm:"-" json:"azure_key_config,omitempty"`
	VertexKeyConfig    *schemas.VertexKeyConfig    `gorm:"-" json:"vertex_key_config,omitempty"`
	BedrockKeyConfig   *schemas.BedrockKeyConfig   `gorm:"-" json:"bedrock_key_config,omitempty"`
	ReplicateKeyConfig *schemas.ReplicateKeyConfig `gorm:"-" json:"replicate_key_config,omitempty"`
	VLLMKeyConfig      *schemas.VLLMKeyConfig      `gorm:"-" json:"vllm_key_config,omitempty"`
}

TableKey represents an API key configuration in the database

func (*TableKey) AfterFind

func (k *TableKey) AfterFind(tx *gorm.DB) error

AfterFind is a GORM hook that decrypts sensitive fields and reconstructs runtime config structs after reading from the database. Decryption runs first so that value copies into AzureKeyConfig, VertexKeyConfig, etc. receive plaintext data.

func (*TableKey) BeforeSave

func (k *TableKey) BeforeSave(tx *gorm.DB) error

BeforeSave is a GORM hook that serializes runtime config structs into JSON columns and encrypts sensitive fields (API key value, Azure endpoint/client ID/secret/tenant ID/API version, Vertex project ID/project number/region/credentials, Bedrock keys/region/ARN/deployments/ batch S3 config) before writing to the database. Encryption runs last to ensure it operates on the final serialized values.

func (TableKey) TableName

func (TableKey) TableName() string

TableName sets the table name for each model

type TableLogStoreConfig

type TableLogStoreConfig struct {
	ID        uint      `gorm:"primaryKey;autoIncrement" json:"id"`
	Enabled   bool      `json:"enabled"`
	Type      string    `gorm:"type:varchar(50);not null" json:"type"` // "sqlite"
	Config    *string   `gorm:"type:text" json:"config"`               // JSON serialized logstore.Config
	CreatedAt time.Time `gorm:"index;not null" json:"created_at"`
	UpdatedAt time.Time `gorm:"index;not null" json:"updated_at"`
}

TableLogStoreConfig represents the configuration for the log store in the database

func (TableLogStoreConfig) TableName

func (TableLogStoreConfig) TableName() string

TableName sets the table name for each model

type TableMCPClient

type TableMCPClient struct {
	ID                     uint            `gorm:"primaryKey;autoIncrement" json:"id"` // ID is used as the internal primary key and is also accessed by public methods, so it must be present.
	ClientID               string          `gorm:"type:varchar(255);uniqueIndex;not null" json:"client_id"`
	Name                   string          `gorm:"type:varchar(255);uniqueIndex;not null" json:"name"`
	IsCodeModeClient       bool            `gorm:"default:false" json:"is_code_mode_client"`         // Whether the client is a code mode client
	ConnectionType         string          `gorm:"type:varchar(20);not null" json:"connection_type"` // schemas.MCPConnectionType
	ConnectionString       *schemas.EnvVar `gorm:"type:text" json:"connection_string,omitempty"`
	StdioConfigJSON        *string         `gorm:"type:text" json:"-"`                              // JSON serialized schemas.MCPStdioConfig
	ToolsToExecuteJSON     string          `gorm:"type:text" json:"-"`                              // JSON serialized []string
	ToolsToAutoExecuteJSON string          `gorm:"type:text" json:"-"`                              // JSON serialized []string
	HeadersJSON            string          `gorm:"type:text" json:"-"`                              // JSON serialized map[string]string
	IsPingAvailable        *bool           `gorm:"default:true" json:"is_ping_available,omitempty"` // Whether the MCP server supports ping for health checks
	ToolPricingJSON        string          `gorm:"type:text" json:"-"`                              // JSON serialized map[string]float64
	ToolSyncInterval       int             `gorm:"default:0" json:"tool_sync_interval"`             // Per-client tool sync interval in minutes (0 = use global, -1 = disabled)

	// OAuth authentication fields
	AuthType      string            `gorm:"type:varchar(20);default:'headers'" json:"auth_type"`                         // "none", "headers", "oauth"
	OauthConfigID *string           `gorm:"type:varchar(255);index;constraint:OnDelete:CASCADE" json:"oauth_config_id"`  // Foreign key to oauth_configs.ID with CASCADE delete
	OauthConfig   *TableOauthConfig `gorm:"foreignKey:OauthConfigID;references:ID;constraint:OnDelete:CASCADE" json:"-"` // Gorm relationship

	// Config hash is used to detect the changes synced from config.json file
	// Every time we sync the config.json file, we will update the config hash
	ConfigHash string `gorm:"type:varchar(255);null" json:"config_hash"`

	EncryptionStatus string `gorm:"type:varchar(20);default:'plain_text'" json:"-"`

	CreatedAt time.Time `gorm:"index;not null" json:"created_at"`
	UpdatedAt time.Time `gorm:"index;not null" json:"updated_at"`

	// Virtual fields for runtime use (not stored in DB)
	StdioConfig        *schemas.MCPStdioConfig   `gorm:"-" json:"stdio_config,omitempty"`
	ToolsToExecute     []string                  `gorm:"-" json:"tools_to_execute"`
	ToolsToAutoExecute []string                  `gorm:"-" json:"tools_to_auto_execute"`
	Headers            map[string]schemas.EnvVar `gorm:"-" json:"headers"`
	ToolPricing        map[string]float64        `gorm:"-" json:"tool_pricing"`
}

TableMCPClient represents an MCP client configuration in the database

func (*TableMCPClient) AfterFind

func (c *TableMCPClient) AfterFind(tx *gorm.DB) error

AfterFind is a GORM hook that decrypts the connection string and headers (if encrypted) and deserializes JSON columns back into runtime structs after reading from the database.

func (*TableMCPClient) BeforeSave

func (c *TableMCPClient) BeforeSave(tx *gorm.DB) error

BeforeSave is a GORM hook that serializes runtime fields (stdio config, tools, headers, pricing) into JSON columns and encrypts the connection string and headers before writing to the database. Environment-variable-backed connection strings are not encrypted.

func (TableMCPClient) TableName

func (TableMCPClient) TableName() string

TableName sets the table name for each model

type TableModel

type TableModel struct {
	ID         string    `gorm:"primaryKey" json:"id"`
	ProviderID uint      `gorm:"index;not null;uniqueIndex:idx_provider_name" json:"provider_id"`
	Name       string    `gorm:"uniqueIndex:idx_provider_name" json:"name"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
}

TableModel represents a model configuration in the database

func (TableModel) TableName

func (TableModel) TableName() string

TableName sets the table name for each model

type TableModelConfig

type TableModelConfig struct {
	ID          string  `gorm:"primaryKey;type:varchar(255)" json:"id"`
	ModelName   string  `gorm:"type:varchar(255);not null;uniqueIndex:idx_model_provider" json:"model_name"`
	Provider    *string `gorm:"type:varchar(50);uniqueIndex:idx_model_provider" json:"provider,omitempty"` // Optional provider, nullable
	BudgetID    *string `gorm:"type:varchar(255);index:idx_model_config_budget" json:"budget_id,omitempty"`
	RateLimitID *string `gorm:"type:varchar(255);index:idx_model_config_rate_limit" json:"rate_limit_id,omitempty"`

	// Relationships
	Budget    *TableBudget    `gorm:"foreignKey:BudgetID;onDelete:CASCADE" json:"budget,omitempty"`
	RateLimit *TableRateLimit `gorm:"foreignKey:RateLimitID;onDelete:CASCADE" json:"rate_limit,omitempty"`

	// Config hash is used to detect the changes synced from config.json file
	// Every time we sync the config.json file, we will update the config hash
	ConfigHash string `gorm:"type:varchar(255);null" json:"config_hash"`

	CreatedAt time.Time `gorm:"index;not null" json:"created_at"`
	UpdatedAt time.Time `gorm:"index;not null" json:"updated_at"`
}

TableModelConfig represents a model configuration with rate limiting and budgeting

func (*TableModelConfig) BeforeSave

func (mc *TableModelConfig) BeforeSave(tx *gorm.DB) error

BeforeSave hook for ModelConfig to validate required fields

func (TableModelConfig) TableName

func (TableModelConfig) TableName() string

TableName sets the table name for each model

type TableModelParameters

type TableModelParameters struct {
	ID    uint   `gorm:"primaryKey;autoIncrement" json:"id"`
	Model string `gorm:"type:varchar(255);not null;uniqueIndex:idx_model_params_model" json:"model"`
	Data  string `gorm:"type:text;not null" json:"data"` // Raw JSON blob
}

TableModelParameters stores model parameters and capabilities data synced from the external datasheet API. Each row holds one model's full parameter/capability JSON blob.

func (TableModelParameters) TableName

func (TableModelParameters) TableName() string

TableName sets the table name

type TableModelPricing

type TableModelPricing struct {
	ID              uint                  `gorm:"primaryKey;autoIncrement" json:"id"`
	Model           string                `gorm:"type:varchar(255);not null;uniqueIndex:idx_model_provider_mode" json:"model"`
	BaseModel       string                `gorm:"type:varchar(255);default:null" json:"base_model,omitempty"`
	Provider        string                `gorm:"type:varchar(50);not null;uniqueIndex:idx_model_provider_mode" json:"provider"`
	Mode            string                `gorm:"type:varchar(50);not null;uniqueIndex:idx_model_provider_mode" json:"mode"`
	ContextLength   *int                  `gorm:"default:null" json:"context_length,omitempty"`
	MaxInputTokens  *int                  `gorm:"default:null" json:"max_input_tokens,omitempty"`
	MaxOutputTokens *int                  `gorm:"default:null" json:"max_output_tokens,omitempty"`
	Architecture    *schemas.Architecture `gorm:"type:text;serializer:json;default:null" json:"architecture,omitempty"`

	// Costs - Text
	InputCostPerToken          float64  `gorm:"not null" json:"input_cost_per_token"`
	OutputCostPerToken         float64  `gorm:"not null" json:"output_cost_per_token"`
	InputCostPerTokenBatches   *float64 `gorm:"default:null;column:input_cost_per_token_batches" json:"input_cost_per_token_batches,omitempty"`
	OutputCostPerTokenBatches  *float64 `gorm:"default:null;column:output_cost_per_token_batches" json:"output_cost_per_token_batches,omitempty"`
	InputCostPerTokenPriority  *float64 `gorm:"default:null;column:input_cost_per_token_priority" json:"input_cost_per_token_priority,omitempty"`
	OutputCostPerTokenPriority *float64 `gorm:"default:null;column:output_cost_per_token_priority" json:"output_cost_per_token_priority,omitempty"`
	InputCostPerTokenFlex      *float64 `gorm:"default:null;column:input_cost_per_token_flex" json:"input_cost_per_token_flex,omitempty"`
	OutputCostPerTokenFlex     *float64 `gorm:"default:null;column:output_cost_per_token_flex" json:"output_cost_per_token_flex,omitempty"`
	InputCostPerCharacter      *float64 `gorm:"default:null;column:input_cost_per_character" json:"input_cost_per_character,omitempty"`
	// Costs - 128k Tier
	InputCostPerTokenAbove128kTokens          *float64 `gorm:"default:null;column:input_cost_per_token_above_128k_tokens" json:"input_cost_per_token_above_128k_tokens,omitempty"`
	InputCostPerImageAbove128kTokens          *float64 `gorm:"default:null;column:input_cost_per_image_above_128k_tokens" json:"input_cost_per_image_above_128k_tokens,omitempty"`
	InputCostPerVideoPerSecondAbove128kTokens *float64 `` /* 143-byte string literal not displayed */
	InputCostPerAudioPerSecondAbove128kTokens *float64 `` /* 143-byte string literal not displayed */
	OutputCostPerTokenAbove128kTokens         *float64 `gorm:"default:null;column:output_cost_per_token_above_128k_tokens" json:"output_cost_per_token_above_128k_tokens,omitempty"`
	// Costs - 200k Tier
	InputCostPerTokenAbove200kTokens          *float64 `gorm:"default:null;column:input_cost_per_token_above_200k_tokens" json:"input_cost_per_token_above_200k_tokens,omitempty"`
	InputCostPerTokenAbove200kTokensPriority  *float64 `` /* 139-byte string literal not displayed */
	OutputCostPerTokenAbove200kTokens         *float64 `gorm:"default:null;column:output_cost_per_token_above_200k_tokens" json:"output_cost_per_token_above_200k_tokens,omitempty"`
	OutputCostPerTokenAbove200kTokensPriority *float64 `` /* 141-byte string literal not displayed */
	// Costs - 272k Tier
	InputCostPerTokenAbove272kTokens          *float64 `gorm:"default:null;column:input_cost_per_token_above_272k_tokens" json:"input_cost_per_token_above_272k_tokens,omitempty"`
	InputCostPerTokenAbove272kTokensPriority  *float64 `` /* 139-byte string literal not displayed */
	OutputCostPerTokenAbove272kTokens         *float64 `gorm:"default:null;column:output_cost_per_token_above_272k_tokens" json:"output_cost_per_token_above_272k_tokens,omitempty"`
	OutputCostPerTokenAbove272kTokensPriority *float64 `` /* 141-byte string literal not displayed */

	// Costs - Cache
	CacheCreationInputTokenCost                        *float64 `gorm:"default:null;column:cache_creation_input_token_cost" json:"cache_creation_input_token_cost,omitempty"`
	CacheReadInputTokenCost                            *float64 `gorm:"default:null;column:cache_read_input_token_cost" json:"cache_read_input_token_cost,omitempty"`
	CacheCreationInputTokenCostAbove200kTokens         *float64 `` /* 143-byte string literal not displayed */
	CacheReadInputTokenCostAbove200kTokens             *float64 `` /* 135-byte string literal not displayed */
	CacheReadInputTokenCostAbove200kTokensPriority     *float64 `` /* 153-byte string literal not displayed */
	CacheCreationInputTokenCostAbove1hr                *float64 `` /* 127-byte string literal not displayed */
	CacheCreationInputTokenCostAbove1hrAbove200kTokens *float64 `` /* 163-byte string literal not displayed */
	CacheCreationInputAudioTokenCost                   *float64 `gorm:"default:null;column:cache_creation_input_audio_token_cost" json:"cache_creation_input_audio_token_cost,omitempty"`
	CacheReadInputTokenCostPriority                    *float64 `gorm:"default:null;column:cache_read_input_token_cost_priority" json:"cache_read_input_token_cost_priority,omitempty"`
	CacheReadInputTokenCostFlex                        *float64 `gorm:"default:null;column:cache_read_input_token_cost_flex" json:"cache_read_input_token_cost_flex,omitempty"`
	CacheReadInputImageTokenCost                       *float64 `gorm:"default:null;column:cache_read_input_image_token_cost" json:"cache_read_input_image_token_cost,omitempty"`
	CacheReadInputTokenCostAbove272kTokens             *float64 `` /* 135-byte string literal not displayed */
	CacheReadInputTokenCostAbove272kTokensPriority     *float64 `` /* 153-byte string literal not displayed */

	// Costs - Image
	InputCostPerImage                             *float64 `gorm:"default:null;column:input_cost_per_image" json:"input_cost_per_image,omitempty"`
	InputCostPerPixel                             *float64 `gorm:"default:null;column:input_cost_per_pixel" json:"input_cost_per_pixel,omitempty"`
	OutputCostPerImage                            *float64 `gorm:"default:null;column:output_cost_per_image" json:"output_cost_per_image,omitempty"`
	OutputCostPerPixel                            *float64 `gorm:"default:null;column:output_cost_per_pixel" json:"output_cost_per_pixel,omitempty"`
	OutputCostPerImagePremiumImage                *float64 `gorm:"default:null;column:output_cost_per_image_premium_image" json:"output_cost_per_image_premium_image,omitempty"`
	OutputCostPerImageAbove512x512Pixels          *float64 `` /* 137-byte string literal not displayed */
	OutputCostPerImageAbove512x512PixelsPremium   *float64 `` /* 159-byte string literal not displayed */
	OutputCostPerImageAbove1024x1024Pixels        *float64 `` /* 141-byte string literal not displayed */
	OutputCostPerImageAbove1024x1024PixelsPremium *float64 `` /* 163-byte string literal not displayed */
	OutputCostPerImageAbove2048x2048Pixels        *float64 `` /* 141-byte string literal not displayed */
	OutputCostPerImageAbove4096x4096Pixels        *float64 `` /* 141-byte string literal not displayed */
	OutputCostPerImageLowQuality                  *float64 `gorm:"default:null;column:output_cost_per_image_low_quality" json:"output_cost_per_image_low_quality,omitempty"`
	OutputCostPerImageMediumQuality               *float64 `gorm:"default:null;column:output_cost_per_image_medium_quality" json:"output_cost_per_image_medium_quality,omitempty"`
	OutputCostPerImageHighQuality                 *float64 `gorm:"default:null;column:output_cost_per_image_high_quality" json:"output_cost_per_image_high_quality,omitempty"`
	OutputCostPerImageAutoQuality                 *float64 `gorm:"default:null;column:output_cost_per_image_auto_quality" json:"output_cost_per_image_auto_quality,omitempty"`
	InputCostPerImageToken                        *float64 `gorm:"default:null;column:input_cost_per_image_token" json:"input_cost_per_image_token,omitempty"`
	OutputCostPerImageToken                       *float64 `gorm:"default:null;column:output_cost_per_image_token" json:"output_cost_per_image_token,omitempty"`

	// Costs - Audio/Video
	InputCostPerAudioToken      *float64 `gorm:"default:null;column:input_cost_per_audio_token" json:"input_cost_per_audio_token,omitempty"`
	InputCostPerAudioPerSecond  *float64 `gorm:"default:null;column:input_cost_per_audio_per_second" json:"input_cost_per_audio_per_second,omitempty"`
	InputCostPerSecond          *float64 `gorm:"default:null;column:input_cost_per_second" json:"input_cost_per_second,omitempty"` // Only for transcription models
	InputCostPerVideoPerSecond  *float64 `gorm:"default:null;column:input_cost_per_video_per_second" json:"input_cost_per_video_per_second,omitempty"`
	OutputCostPerAudioToken     *float64 `gorm:"default:null;column:output_cost_per_audio_token" json:"output_cost_per_audio_token,omitempty"`
	OutputCostPerVideoPerSecond *float64 `gorm:"default:null;column:output_cost_per_video_per_second" json:"output_cost_per_video_per_second,omitempty"`
	OutputCostPerSecond         *float64 `gorm:"default:null;column:output_cost_per_second" json:"output_cost_per_second,omitempty"` // For both speech and video models

	// Costs - Other
	SearchContextCostPerQuery     *float64 `gorm:"default:null;column:search_context_cost_per_query" json:"search_context_cost_per_query,omitempty"`
	CodeInterpreterCostPerSession *float64 `gorm:"default:null;column:code_interpreter_cost_per_session" json:"code_interpreter_cost_per_session,omitempty"`
}

TableModelPricing represents pricing information for AI models

func (TableModelPricing) TableName

func (TableModelPricing) TableName() string

TableName sets the table name for each model

type TableOauthConfig

type TableOauthConfig struct {
	ID                  string    `gorm:"type:varchar(255);primaryKey" json:"id"`          // UUID
	ClientID            string    `gorm:"type:varchar(512)" json:"client_id"`              // OAuth provider's client ID (optional for public clients)
	ClientSecret        string    `gorm:"type:text" json:"-"`                              // Encrypted OAuth client secret (optional for public clients)
	AuthorizeURL        string    `gorm:"type:text" json:"authorize_url"`                  // Provider's authorization endpoint (optional, can be discovered)
	TokenURL            string    `gorm:"type:text" json:"token_url"`                      // Provider's token endpoint (optional, can be discovered)
	RegistrationURL     *string   `gorm:"type:text" json:"registration_url,omitempty"`     // Provider's dynamic registration endpoint (optional, can be discovered)
	RedirectURI         string    `gorm:"type:text;not null" json:"redirect_uri"`          // Callback URL
	Scopes              string    `gorm:"type:text" json:"scopes"`                         // JSON array of scopes (optional, can be discovered)
	State               string    `gorm:"type:varchar(255);uniqueIndex;not null" json:"-"` // CSRF state token
	CodeVerifier        string    `gorm:"type:text" json:"-"`                              // PKCE code verifier (generated, kept secret)
	CodeChallenge       string    `gorm:"type:varchar(255)" json:"code_challenge"`         // PKCE code challenge (sent to provider)
	Status              string    `gorm:"type:varchar(50);not null;index" json:"status"`   // "pending", "authorized", "failed", "expired", "revoked"
	TokenID             *string   `gorm:"type:varchar(255);index" json:"token_id"`         // Foreign key to oauth_tokens.ID (set after callback)
	ServerURL           string    `gorm:"type:text" json:"server_url"`                     // MCP server URL for OAuth discovery
	UseDiscovery        bool      `gorm:"default:false" json:"use_discovery"`              // Flag to enable OAuth discovery
	MCPClientConfigJSON *string   `gorm:"type:text" json:"-"`                              // JSON serialized MCPClientConfig for multi-instance support (pending MCP client waiting for OAuth completion)
	EncryptionStatus    string    `gorm:"type:varchar(20);default:'plain_text'" json:"-"`
	CreatedAt           time.Time `gorm:"index;not null" json:"created_at"`
	UpdatedAt           time.Time `gorm:"index;not null" json:"updated_at"`
	ExpiresAt           time.Time `gorm:"index;not null" json:"expires_at"` // State expiry (15 min)
}

TableOauthConfig represents an OAuth configuration in the database This stores the OAuth client configuration and flow state

func (*TableOauthConfig) AfterFind

func (c *TableOauthConfig) AfterFind(tx *gorm.DB) error

AfterFind hook to decrypt sensitive fields

func (*TableOauthConfig) BeforeSave

func (c *TableOauthConfig) BeforeSave(tx *gorm.DB) error

BeforeSave hook

func (TableOauthConfig) TableName

func (TableOauthConfig) TableName() string

TableName sets the table name

type TableOauthToken

type TableOauthToken struct {
	ID               string     `gorm:"type:varchar(255);primaryKey" json:"id"`      // UUID
	AccessToken      string     `gorm:"type:text;not null" json:"-"`                 // Encrypted access token
	RefreshToken     string     `gorm:"type:text" json:"-"`                          // Encrypted refresh token (optional)
	TokenType        string     `gorm:"type:varchar(50);not null" json:"token_type"` // "Bearer"
	ExpiresAt        time.Time  `gorm:"index;not null" json:"expires_at"`            // Token expiration
	Scopes           string     `gorm:"type:text" json:"scopes"`                     // JSON array of granted scopes
	LastRefreshedAt  *time.Time `gorm:"index" json:"last_refreshed_at,omitempty"`    // Track when token was last refreshed
	EncryptionStatus string     `gorm:"type:varchar(20);default:'plain_text'" json:"-"`
	CreatedAt        time.Time  `gorm:"index;not null" json:"created_at"`
	UpdatedAt        time.Time  `gorm:"index;not null" json:"updated_at"`
}

TableOauthToken represents an OAuth token in the database This stores the actual access and refresh tokens

func (*TableOauthToken) AfterFind

func (t *TableOauthToken) AfterFind(tx *gorm.DB) error

AfterFind hook to decrypt sensitive fields

func (*TableOauthToken) BeforeSave

func (t *TableOauthToken) BeforeSave(tx *gorm.DB) error

BeforeSave hook

func (TableOauthToken) TableName

func (TableOauthToken) TableName() string

TableName sets the table name

type TablePlugin

type TablePlugin struct {
	ID         uint      `gorm:"primaryKey;autoIncrement" json:"id"`
	Name       string    `gorm:"type:varchar(255);uniqueIndex;not null" json:"name"`
	Enabled    bool      `json:"enabled"`
	Path       *string   `json:"path,omitempty"`
	ConfigJSON string    `gorm:"type:text" json:"-"` // JSON serialized plugin.Config
	CreatedAt  time.Time `gorm:"index;not null" json:"created_at"`
	Version    int16     `gorm:"not null;default:1" json:"version"`
	UpdatedAt  time.Time `gorm:"index;not null" json:"updated_at"`
	IsCustom   bool      `gorm:"not null;default:false" json:"isCustom"`

	Placement *schemas.PluginPlacement `gorm:"column:placement;type:varchar(20);null" json:"placement,omitempty"`
	Order     *int                     `gorm:"column:exec_order;type:int;null" json:"order,omitempty"`

	// Config hash is used to detect the changes synced from config.json file
	// Every time we sync the config.json file, we will update the config hash
	ConfigHash string `gorm:"type:varchar(255);null" json:"config_hash"`

	EncryptionStatus string `gorm:"type:varchar(20);default:'plain_text'" json:"-"`

	// Virtual fields for runtime use (not stored in DB)
	Config any `gorm:"-" json:"config,omitempty"`
}

func (*TablePlugin) AfterFind

func (p *TablePlugin) AfterFind(tx *gorm.DB) error

AfterFind is a GORM hook that decrypts the plugin config JSON (if encrypted) and deserializes it back into the runtime Config field after reading from the database.

func (*TablePlugin) BeforeSave

func (p *TablePlugin) BeforeSave(tx *gorm.DB) error

BeforeSave is a GORM hook that serializes the plugin Config into a JSON column and encrypts it before writing to the database. Empty configs ("{}") are not encrypted.

func (TablePlugin) TableName

func (TablePlugin) TableName() string

TableName sets the table name for each model

type TablePrompt

type TablePrompt struct {
	ID         string       `gorm:"type:varchar(36);primaryKey" json:"id"`
	Name       string       `gorm:"type:varchar(255);not null" json:"name"`
	FolderID   *string      `gorm:"type:varchar(36);index" json:"folder_id,omitempty"`
	Folder     *TableFolder `gorm:"foreignKey:FolderID;constraint:OnDelete:CASCADE" json:"folder,omitempty"`
	CreatedAt  time.Time    `gorm:"not null" json:"created_at"`
	UpdatedAt  time.Time    `gorm:"not null" json:"updated_at"`
	ConfigHash string       `gorm:"type:varchar(64)" json:"-"`

	// Relationships
	Versions []TablePromptVersion `gorm:"foreignKey:PromptID;constraint:OnDelete:CASCADE" json:"versions,omitempty"`
	Sessions []TablePromptSession `gorm:"foreignKey:PromptID;constraint:OnDelete:CASCADE" json:"sessions,omitempty"`

	// Virtual fields (not stored in DB)
	LatestVersion *TablePromptVersion `gorm:"-" json:"latest_version,omitempty"`
}

TablePrompt represents a prompt entity that can have multiple versions and sessions

func (TablePrompt) TableName

func (TablePrompt) TableName() string

TableName for TablePrompt

type TablePromptSession

type TablePromptSession struct {
	ID              uint                `gorm:"primaryKey;autoIncrement" json:"id"`
	PromptID        string              `gorm:"type:varchar(36);not null;index" json:"prompt_id"`
	Prompt          *TablePrompt        `gorm:"foreignKey:PromptID" json:"prompt,omitempty"`
	VersionID       *uint               `gorm:"index" json:"version_id,omitempty"` // Optional - session may or may not be based on a version
	Version         *TablePromptVersion `gorm:"foreignKey:VersionID;constraint:OnDelete:SET NULL" json:"version,omitempty"`
	Name            string              `gorm:"type:varchar(255)" json:"name"`
	ModelParamsJSON *string             `gorm:"type:text;column:model_params_json" json:"-"`
	ModelParams     ModelParams         `gorm:"-" json:"model_params"`
	Provider        string              `gorm:"type:varchar(100)" json:"provider"`
	Model           string              `gorm:"type:varchar(100)" json:"model"`
	CreatedAt       time.Time           `gorm:"not null" json:"created_at"`
	UpdatedAt       time.Time           `gorm:"not null" json:"updated_at"`

	// Relationships
	Messages []TablePromptSessionMessage `gorm:"foreignKey:SessionID;constraint:OnDelete:CASCADE" json:"messages,omitempty"`
}

TablePromptSession represents a mutable working draft/session for a prompt Sessions belong to a prompt and can optionally be based on a specific version

func (*TablePromptSession) AfterFind

func (s *TablePromptSession) AfterFind(tx *gorm.DB) error

AfterFind GORM hook to deserialize JSON fields

func (*TablePromptSession) BeforeSave

func (s *TablePromptSession) BeforeSave(tx *gorm.DB) error

BeforeSave GORM hook to serialize JSON fields

func (TablePromptSession) TableName

func (TablePromptSession) TableName() string

TableName for TablePromptSession

type TablePromptSessionMessage

type TablePromptSessionMessage struct {
	ID          uint                `gorm:"primaryKey;autoIncrement" json:"id"`
	PromptID    string              `gorm:"type:varchar(36);not null;index" json:"prompt_id"`
	SessionID   uint                `gorm:"not null;index;uniqueIndex:idx_session_order" json:"session_id"`
	Session     *TablePromptSession `gorm:"foreignKey:SessionID" json:"-"`
	OrderIndex  int                 `gorm:"not null;uniqueIndex:idx_session_order" json:"order_index"`
	MessageJSON string              `gorm:"type:text;not null;column:message_json" json:"-"`
	Message     PromptMessage       `gorm:"-" json:"message"`
}

TablePromptSessionMessage represents a message in a mutable prompt session

func (*TablePromptSessionMessage) AfterFind

func (m *TablePromptSessionMessage) AfterFind(tx *gorm.DB) error

AfterFind GORM hook to deserialize JSON fields

func (*TablePromptSessionMessage) BeforeSave

func (m *TablePromptSessionMessage) BeforeSave(tx *gorm.DB) error

BeforeSave GORM hook to serialize JSON fields

func (TablePromptSessionMessage) TableName

func (TablePromptSessionMessage) TableName() string

TableName for TablePromptSessionMessage

type TablePromptVersion

type TablePromptVersion struct {
	ID              uint         `gorm:"primaryKey;autoIncrement" json:"id"`
	PromptID        string       `gorm:"type:varchar(36);not null;index;uniqueIndex:idx_prompt_version" json:"prompt_id"`
	Prompt          *TablePrompt `gorm:"foreignKey:PromptID" json:"prompt,omitempty"`
	VersionNumber   int          `gorm:"not null;uniqueIndex:idx_prompt_version" json:"version_number"`
	CommitMessage   string       `gorm:"type:text" json:"commit_message"`
	ModelParamsJSON *string      `gorm:"type:text;column:model_params_json" json:"-"`
	ModelParams     ModelParams  `gorm:"-" json:"model_params"`
	Provider        string       `gorm:"type:varchar(100)" json:"provider"`
	Model           string       `gorm:"type:varchar(100)" json:"model"`
	IsLatest        bool         `gorm:"not null;default:false" json:"is_latest"`
	CreatedAt       time.Time    `gorm:"not null" json:"created_at"`

	// Relationships
	Messages []TablePromptVersionMessage `gorm:"foreignKey:VersionID;constraint:OnDelete:CASCADE" json:"messages,omitempty"`
}

TablePromptVersion represents an immutable version of a prompt Once created, a version cannot be modified - to make changes, create a new version

func (*TablePromptVersion) AfterFind

func (v *TablePromptVersion) AfterFind(tx *gorm.DB) error

AfterFind GORM hook to deserialize JSON fields

func (*TablePromptVersion) BeforeSave

func (v *TablePromptVersion) BeforeSave(tx *gorm.DB) error

BeforeSave GORM hook to serialize JSON fields

func (TablePromptVersion) TableName

func (TablePromptVersion) TableName() string

TableName for TablePromptVersion

type TablePromptVersionMessage

type TablePromptVersionMessage struct {
	ID          uint                `gorm:"primaryKey;autoIncrement" json:"id"`
	PromptID    string              `gorm:"type:varchar(36);not null;index" json:"prompt_id"`
	VersionID   uint                `gorm:"not null;index;uniqueIndex:idx_version_order" json:"version_id"`
	Version     *TablePromptVersion `gorm:"foreignKey:VersionID" json:"-"`
	OrderIndex  int                 `gorm:"not null;uniqueIndex:idx_version_order" json:"order_index"`
	MessageJSON string              `gorm:"type:text;not null;column:message_json" json:"-"`
	Message     PromptMessage       `gorm:"-" json:"message"`
}

TablePromptVersionMessage represents a message in an immutable prompt version

func (*TablePromptVersionMessage) AfterFind

func (m *TablePromptVersionMessage) AfterFind(tx *gorm.DB) error

AfterFind GORM hook to deserialize JSON fields

func (*TablePromptVersionMessage) BeforeSave

func (m *TablePromptVersionMessage) BeforeSave(tx *gorm.DB) error

BeforeSave GORM hook to serialize JSON fields

func (TablePromptVersionMessage) TableName

func (TablePromptVersionMessage) TableName() string

TableName for TablePromptVersionMessage

type TableProvider

type TableProvider struct {
	ID                       uint      `gorm:"primaryKey;autoIncrement" json:"id"`
	Name                     string    `gorm:"type:varchar(50);uniqueIndex;not null" json:"name"` // ModelProvider as string
	NetworkConfigJSON        string    `gorm:"type:text" json:"-"`                                // JSON serialized schemas.NetworkConfig
	ConcurrencyBufferJSON    string    `gorm:"type:text" json:"-"`                                // JSON serialized schemas.ConcurrencyAndBufferSize
	ProxyConfigJSON          string    `gorm:"type:text" json:"-"`                                // JSON serialized schemas.ProxyConfig
	CustomProviderConfigJSON string    `gorm:"type:text" json:"-"`                                // JSON serialized schemas.CustomProviderConfig
	OpenAIConfigJSON         string    `gorm:"type:text" json:"-"`                                // JSON serialized schemas.OpenAIConfig
	PricingOverridesJSON     string    `gorm:"type:text" json:"-"`                                // JSON serialized []schemas.ProviderPricingOverride
	SendBackRawRequest       bool      `json:"send_back_raw_request"`
	SendBackRawResponse      bool      `json:"send_back_raw_response"`
	StoreRawRequestResponse  bool      `json:"store_raw_request_response"`
	CreatedAt                time.Time `gorm:"index;not null" json:"created_at"`
	UpdatedAt                time.Time `gorm:"index;not null" json:"updated_at"`

	// Relationships
	Keys []TableKey `gorm:"foreignKey:ProviderID;constraint:OnDelete:CASCADE" json:"keys"`

	// Virtual fields for runtime use (not stored in DB)
	NetworkConfig            *schemas.NetworkConfig            `gorm:"-" json:"network_config,omitempty"`
	ConcurrencyAndBufferSize *schemas.ConcurrencyAndBufferSize `gorm:"-" json:"concurrency_and_buffer_size,omitempty"`
	ProxyConfig              *schemas.ProxyConfig              `gorm:"-" json:"proxy_config,omitempty"`

	// Custom provider fields
	CustomProviderConfig *schemas.CustomProviderConfig     `gorm:"-" json:"custom_provider_config,omitempty"`
	OpenAIConfig         *schemas.OpenAIConfig             `gorm:"-" json:"openai_config,omitempty"`
	PricingOverrides     []schemas.ProviderPricingOverride `gorm:"-" json:"pricing_overrides,omitempty"`

	// Foreign keys
	Models []TableModel `gorm:"foreignKey:ProviderID;constraint:OnDelete:CASCADE" json:"models"`

	// Governance fields - Budget and Rate Limit for provider-level governance
	BudgetID    *string `gorm:"type:varchar(255);index:idx_provider_budget" json:"budget_id,omitempty"`
	RateLimitID *string `gorm:"type:varchar(255);index:idx_provider_rate_limit" json:"rate_limit_id,omitempty"`

	// Governance relationships
	Budget    *TableBudget    `gorm:"foreignKey:BudgetID;onDelete:CASCADE" json:"budget,omitempty"`
	RateLimit *TableRateLimit `gorm:"foreignKey:RateLimitID;onDelete:CASCADE" json:"rate_limit,omitempty"`

	// Config hash is used to detect the changes synced from config.json file
	// Every time we sync the config.json file, we will update the config hash
	ConfigHash string `gorm:"type:varchar(255);null" json:"config_hash"`

	// Model discovery status tracking for keyless providers
	Status      string `gorm:"type:varchar(50);default:'unknown'" json:"status"`
	Description string `gorm:"type:text" json:"description,omitempty"`

	EncryptionStatus string `gorm:"type:varchar(20);default:'plain_text'" json:"-"`
}

TableProvider represents a provider configuration in the database NOTE: Any changes to the provider configuration should be reflected in the GenerateConfigHash function That helps us detect changes between config file and database config

func (*TableProvider) AfterFind

func (p *TableProvider) AfterFind(tx *gorm.DB) error

AfterFind is a GORM hook that decrypts the proxy configuration (if encrypted) and deserializes JSON columns back into runtime config structs after reading from the database.

func (*TableProvider) BeforeSave

func (p *TableProvider) BeforeSave(tx *gorm.DB) error

BeforeSave is a GORM hook that serializes runtime config structs into JSON columns, validates governance fields, and encrypts the proxy configuration before writing to the database.

func (TableProvider) TableName

func (TableProvider) TableName() string

TableName represents a provider configuration in the database

type TableRateLimit

type TableRateLimit struct {
	ID string `gorm:"primaryKey;type:varchar(255)" json:"id"`

	// Token limits with flexible duration
	TokenMaxLimit      *int64    `gorm:"default:null" json:"token_max_limit,omitempty"`          // Maximum tokens allowed
	TokenResetDuration *string   `gorm:"type:varchar(50)" json:"token_reset_duration,omitempty"` // e.g., "30s", "5m", "1h", "1d", "1w", "1M", "1Y"
	TokenCurrentUsage  int64     `gorm:"default:0" json:"token_current_usage"`                   // Current token usage
	TokenLastReset     time.Time `gorm:"index" json:"token_last_reset"`                          // Last time token counter was reset

	// Request limits with flexible duration
	RequestMaxLimit      *int64    `gorm:"default:null" json:"request_max_limit,omitempty"`          // Maximum requests allowed
	RequestResetDuration *string   `gorm:"type:varchar(50)" json:"request_reset_duration,omitempty"` // e.g., "30s", "5m", "1h", "1d", "1w", "1M", "1Y"
	RequestCurrentUsage  int64     `gorm:"default:0" json:"request_current_usage"`                   // Current request usage
	RequestLastReset     time.Time `gorm:"index" json:"request_last_reset"`                          // Last time request counter was reset

	// Config hash is used to detect the changes synced from config.json file
	// Every time we sync the config.json file, we will update the config hash
	ConfigHash string `gorm:"type:varchar(255);null" json:"config_hash"`

	CreatedAt time.Time `gorm:"index;not null" json:"created_at"`
	UpdatedAt time.Time `gorm:"index;not null" json:"updated_at"`
}

TableRateLimit defines rate limiting rules for virtual keys using flexible max+reset approach

func (*TableRateLimit) BeforeSave

func (rl *TableRateLimit) BeforeSave(tx *gorm.DB) error

BeforeSave hook for RateLimit to validate reset duration formats

func (TableRateLimit) TableName

func (TableRateLimit) TableName() string

TableName sets the table name for each model

type TableRoutingRule

type TableRoutingRule struct {
	ID            string `gorm:"primaryKey;type:varchar(255)" json:"id"`
	ConfigHash    string `gorm:"type:varchar(255)" json:"config_hash"` // Hash of config.json version, used for change detection
	Name          string `gorm:"type:varchar(255);not null;uniqueIndex:idx_routing_rule_scope_name" json:"name"`
	Description   string `gorm:"type:text" json:"description"`
	Enabled       bool   `gorm:"not null;default:true" json:"enabled"`
	CelExpression string `gorm:"type:text;not null" json:"cel_expression"`

	// Routing Targets (output) — 1:many relationship; weights must sum to 1
	Targets []TableRoutingTarget `gorm:"foreignKey:RuleID;constraint:OnDelete:CASCADE" json:"targets,omitempty"`

	Fallbacks       *string  `gorm:"type:text" json:"-"`           // JSON array of fallback chains
	ParsedFallbacks []string `gorm:"-" json:"fallbacks,omitempty"` // Parsed fallbacks from JSON

	Query       *string        `gorm:"type:text" json:"-"`
	ParsedQuery map[string]any `gorm:"-" json:"query,omitempty"`

	// Scope: where this rule applies
	Scope   string  `gorm:"type:varchar(50);not null;uniqueIndex:idx_routing_rule_scope_name" json:"scope"` // "global" | "team" | "customer" | "virtual_key"
	ScopeID *string `gorm:"type:varchar(255);uniqueIndex:idx_routing_rule_scope_name" json:"scope_id"`      // nil for global, otherwise entity ID

	// Execution
	Priority int `gorm:"type:int;not null;default:0;index" json:"priority"` // Lower = evaluated first within scope

	// Timestamps
	CreatedAt time.Time `gorm:"index;not null" json:"created_at"`
	UpdatedAt time.Time `gorm:"index;not null" json:"updated_at"`
}

TableRoutingRule represents a routing rule in the database

func (*TableRoutingRule) AfterFind

func (r *TableRoutingRule) AfterFind(tx *gorm.DB) error

AfterFind hook for TableRoutingRule to deserialize JSON fields

func (*TableRoutingRule) BeforeSave

func (r *TableRoutingRule) BeforeSave(tx *gorm.DB) error

BeforeSave hook for TableRoutingRule to serialize JSON fields

func (TableRoutingRule) TableName

func (TableRoutingRule) TableName() string

TableName for TableRoutingRule

type TableRoutingTarget

type TableRoutingTarget struct {
	RuleID   string  `gorm:"type:varchar(255);not null;index;uniqueIndex:idx_routing_target_config" json:"-"`
	Provider *string `gorm:"type:varchar(255);uniqueIndex:idx_routing_target_config" json:"provider,omitempty"` // nil = use incoming provider
	Model    *string `gorm:"type:varchar(255);uniqueIndex:idx_routing_target_config" json:"model,omitempty"`    // nil = use incoming model
	KeyID    *string `gorm:"type:varchar(255);uniqueIndex:idx_routing_target_config" json:"key_id,omitempty"`   // nil = no key pin
	Weight   float64 `gorm:"not null;default:1" json:"weight"`                                                  // must sum to 1 across all targets in a rule
}

TableRoutingTarget represents a weighted routing target for probabilistic routing. Multiple targets can be associated with a single routing rule; weights determine the probability of each target being selected and must sum to 1 across all targets in a rule. The composite (RuleID, Provider, Model, KeyID) is unique to prevent duplicate target configs.

func (TableRoutingTarget) TableName

func (TableRoutingTarget) TableName() string

TableName for TableRoutingTarget

type TableTeam

type TableTeam struct {
	ID          string  `gorm:"primaryKey;type:varchar(255)" json:"id"`
	Name        string  `gorm:"type:varchar(255);not null" json:"name"`
	CustomerID  *string `gorm:"type:varchar(255);index" json:"customer_id,omitempty"` // A team can belong to a customer
	BudgetID    *string `gorm:"type:varchar(255);index" json:"budget_id,omitempty"`
	RateLimitID *string `gorm:"type:varchar(255);index" json:"rate_limit_id,omitempty"`

	// Relationships
	Customer    *TableCustomer    `gorm:"foreignKey:CustomerID" json:"customer,omitempty"`
	Budget      *TableBudget      `gorm:"foreignKey:BudgetID" json:"budget,omitempty"`
	RateLimit   *TableRateLimit   `gorm:"foreignKey:RateLimitID" json:"rate_limit,omitempty"`
	VirtualKeys []TableVirtualKey `gorm:"foreignKey:TeamID" json:"virtual_keys"`

	Profile       *string                `gorm:"type:text" json:"-"`
	ParsedProfile map[string]interface{} `gorm:"-" json:"profile"`

	Config       *string                `gorm:"type:text" json:"-"`
	ParsedConfig map[string]interface{} `gorm:"-" json:"config"`

	Claims       *string                `gorm:"type:text" json:"-"`
	ParsedClaims map[string]interface{} `gorm:"-" json:"claims"`

	// Config hash is used to detect the changes synced from config.json file
	// Every time we sync the config.json file, we will update the config hash
	ConfigHash string `gorm:"type:varchar(255);null" json:"config_hash"`

	CreatedAt time.Time `gorm:"index;not null" json:"created_at"`
	UpdatedAt time.Time `gorm:"index;not null" json:"updated_at"`
}

TableTeam represents a team entity with budget, rate limit and customer association

func (*TableTeam) AfterFind

func (t *TableTeam) AfterFind(tx *gorm.DB) error

AfterFind hook for TableTeam to deserialize JSON fields

func (*TableTeam) BeforeSave

func (t *TableTeam) BeforeSave(tx *gorm.DB) error

BeforeSave hook for TableTeam to serialize JSON fields

func (TableTeam) TableName

func (TableTeam) TableName() string

TableName sets the table name for each model

type TableVectorStoreConfig

type TableVectorStoreConfig struct {
	ID               uint      `gorm:"primaryKey;autoIncrement" json:"id"`
	Enabled          bool      `json:"enabled"`                               // Enable vector store
	Type             string    `gorm:"type:varchar(50);not null" json:"type"` // "weaviate, redis, qdrant."
	TTLSeconds       int       `gorm:"default:300" json:"ttl_seconds"`        // TTL in seconds (default: 5 minutes)
	CacheByModel     bool      `gorm:"" json:"cache_by_model"`                // Include model in cache key
	CacheByProvider  bool      `gorm:"" json:"cache_by_provider"`             // Include provider in cache key
	Config           *string   `gorm:"type:text" json:"config"`               // JSON serialized schemas.RedisVectorStoreConfig
	EncryptionStatus string    `gorm:"type:varchar(20);default:'plain_text'" json:"-"`
	CreatedAt        time.Time `gorm:"index;not null" json:"created_at"`
	UpdatedAt        time.Time `gorm:"index;not null" json:"updated_at"`
}

TableVectorStoreConfig represents Cache plugin configuration in the database

func (*TableVectorStoreConfig) AfterFind

func (vs *TableVectorStoreConfig) AfterFind(tx *gorm.DB) error

AfterFind hook to decrypt sensitive config

func (*TableVectorStoreConfig) BeforeSave

func (vs *TableVectorStoreConfig) BeforeSave(tx *gorm.DB) error

BeforeSave hook to encrypt sensitive config

func (TableVectorStoreConfig) TableName

func (TableVectorStoreConfig) TableName() string

TableName sets the table name for each model

type TableVirtualKey

type TableVirtualKey struct {
	ID              string                          `gorm:"primaryKey;type:varchar(255)" json:"id"`
	Name            string                          `gorm:"uniqueIndex:idx_virtual_key_name;type:varchar(255);not null" json:"name"`
	Description     string                          `gorm:"type:text" json:"description,omitempty"`
	Value           string                          `gorm:"uniqueIndex:idx_virtual_key_value;type:text;not null" json:"value"` // The virtual key value
	IsActive        bool                            `gorm:"default:true" json:"is_active"`
	ProviderConfigs []TableVirtualKeyProviderConfig `gorm:"foreignKey:VirtualKeyID;constraint:OnDelete:CASCADE" json:"provider_configs"` // Empty means all providers allowed
	MCPConfigs      []TableVirtualKeyMCPConfig      `gorm:"foreignKey:VirtualKeyID;constraint:OnDelete:CASCADE" json:"mcp_configs"`

	// Foreign key relationships (mutually exclusive: either TeamID or CustomerID, not both)
	TeamID      *string `gorm:"type:varchar(255);index" json:"team_id,omitempty"`
	CustomerID  *string `gorm:"type:varchar(255);index" json:"customer_id,omitempty"`
	BudgetID    *string `gorm:"type:varchar(255);index" json:"budget_id,omitempty"`
	RateLimitID *string `gorm:"type:varchar(255);index" json:"rate_limit_id,omitempty"`

	// Relationships
	Team      *TableTeam      `gorm:"foreignKey:TeamID" json:"team,omitempty"`
	Customer  *TableCustomer  `gorm:"foreignKey:CustomerID" json:"customer,omitempty"`
	Budget    *TableBudget    `gorm:"foreignKey:BudgetID;onDelete:CASCADE" json:"budget,omitempty"`
	RateLimit *TableRateLimit `gorm:"foreignKey:RateLimitID;onDelete:CASCADE" json:"rate_limit,omitempty"`

	// Config hash is used to detect the changes synced from config.json file
	// Every time we sync the config.json file, we will update the config hash
	ConfigHash string `gorm:"type:varchar(255);null" json:"config_hash"`

	EncryptionStatus string `gorm:"type:varchar(20);default:'plain_text'" json:"-"`
	ValueHash        string `gorm:"type:varchar(64);index:idx_virtual_key_value_hash,unique" json:"-"`

	CreatedAt time.Time `gorm:"index;not null" json:"created_at"`
	UpdatedAt time.Time `gorm:"index;not null" json:"updated_at"`
}

TableVirtualKey represents a virtual key with budget, rate limits, and team/customer association

func (*TableVirtualKey) AfterFind

func (vk *TableVirtualKey) AfterFind(tx *gorm.DB) error

AfterFind is a GORM hook that decrypts the virtual key value after reading from the database.

func (*TableVirtualKey) BeforeSave

func (vk *TableVirtualKey) BeforeSave(tx *gorm.DB) error

BeforeSave is a GORM hook that enforces mutual exclusion (team vs customer), computes a SHA-256 hash of the plaintext value for indexed lookups, and encrypts the virtual key value before writing to the database.

func (TableVirtualKey) TableName

func (TableVirtualKey) TableName() string

TableName sets the table name for each model

type TableVirtualKeyMCPConfig

type TableVirtualKeyMCPConfig struct {
	ID             uint           `gorm:"primaryKey;autoIncrement" json:"id"`
	VirtualKeyID   string         `gorm:"type:varchar(255);not null;uniqueIndex:idx_vk_mcpclient" json:"virtual_key_id"`
	MCPClientID    uint           `gorm:"not null;uniqueIndex:idx_vk_mcpclient" json:"mcp_client_id"`
	MCPClient      TableMCPClient `gorm:"foreignKey:MCPClientID" json:"mcp_client"`
	ToolsToExecute []string       `gorm:"type:text;serializer:json" json:"tools_to_execute"`

	// MCPClientName is used during config file parsing to resolve the MCP client by name.
	// This field is not persisted to the database - it's only used to capture
	// "mcp_client_name" from config.json and then resolve it to MCPClientID.
	MCPClientName string `gorm:"-" json:"-"`
}

func (TableVirtualKeyMCPConfig) TableName

func (TableVirtualKeyMCPConfig) TableName() string

TableName sets the table name for each model

func (*TableVirtualKeyMCPConfig) UnmarshalJSON

func (mc *TableVirtualKeyMCPConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON custom unmarshaller to handle both "mcp_client_id" (database format) and "mcp_client_name" (config file format) for MCP client references.

type TableVirtualKeyProviderConfig

type TableVirtualKeyProviderConfig struct {
	ID            uint     `gorm:"primaryKey;autoIncrement" json:"id"`
	VirtualKeyID  string   `gorm:"type:varchar(255);not null" json:"virtual_key_id"`
	Provider      string   `gorm:"type:varchar(50);not null" json:"provider"`
	Weight        *float64 `json:"weight"`
	AllowedModels []string `gorm:"type:text;serializer:json" json:"allowed_models"` // Empty means all models allowed
	BudgetID      *string  `gorm:"type:varchar(255);index" json:"budget_id,omitempty"`
	RateLimitID   *string  `gorm:"type:varchar(255);index" json:"rate_limit_id,omitempty"`

	// Relationships
	Budget    *TableBudget    `gorm:"foreignKey:BudgetID;onDelete:CASCADE" json:"budget,omitempty"`
	RateLimit *TableRateLimit `gorm:"foreignKey:RateLimitID;onDelete:CASCADE" json:"rate_limit,omitempty"`
	Keys      []TableKey      `gorm:"many2many:governance_virtual_key_provider_config_keys;constraint:OnDelete:CASCADE" json:"keys"` // Empty means all keys allowed for this provider
}

TableVirtualKeyProviderConfig represents a provider configuration for a virtual key

func (*TableVirtualKeyProviderConfig) AfterFind

func (pc *TableVirtualKeyProviderConfig) AfterFind(tx *gorm.DB) error

AfterFind hook for TableVirtualKeyProviderConfig to clear sensitive data from associated keys

func (TableVirtualKeyProviderConfig) MarshalJSON

func (pc TableVirtualKeyProviderConfig) MarshalJSON() ([]byte, error)

MarshalJSON custom marshaller to ensure AllowedModels is always an array (never null)

func (TableVirtualKeyProviderConfig) TableName

TableName sets the table name for each model

func (*TableVirtualKeyProviderConfig) UnmarshalJSON

func (pc *TableVirtualKeyProviderConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON custom unmarshaller to handle both "keys" ([]TableKey) and "allowed_keys" ([]string) formats

type TableVirtualKeyProviderConfigKey

type TableVirtualKeyProviderConfigKey struct {
	TableVirtualKeyProviderConfigID uint `gorm:"primaryKey;uniqueIndex:idx_vk_provider_config_key"`
	TableKeyID                      uint `gorm:"primaryKey;uniqueIndex:idx_vk_provider_config_key"`
}

TableVirtualKeyProviderConfigKey is the join table for the many2many relationship between TableVirtualKeyProviderConfig and TableKey

func (TableVirtualKeyProviderConfigKey) TableName

TableName sets the table name for the join table

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL