configstore

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: 28 Imported by: 0

Documentation

Overview

Package configstore provides a persistent configuration store for Bifrost.

Index

Constants

View Source
const (
	DefaultLockTTL         = 30 * time.Second
	DefaultRetryInterval   = 100 * time.Millisecond
	DefaultMaxRetries      = 100
	DefaultCleanupInterval = 5 * time.Minute
)

Default lock configuration values

Variables

View Source
var (
	ErrLockNotAcquired = errors.New("failed to acquire lock")
	ErrLockNotHeld     = errors.New("lock not held by this holder")
	ErrLockExpired     = errors.New("lock has expired")
	ErrEmptyLockKey    = errors.New("empty lock key")
)

Lock errors

View Source
var ErrAlreadyExists = errors.New("already exists")
View Source
var ErrNotFound = errors.New("not found")

Functions

func GenerateBudgetHash

func GenerateBudgetHash(b tables.TableBudget) (string, error)

GenerateBudgetHash generates a SHA256 hash for a budget. This is used to detect changes to budgets between config.json and database. Skips: LastReset, CurrentUsage, CreatedAt, UpdatedAt (dynamic fields)

func GenerateCustomerHash

func GenerateCustomerHash(c tables.TableCustomer) (string, error)

GenerateCustomerHash generates a SHA256 hash for a customer. This is used to detect changes to customers between config.json and database. Skips: CreatedAt, UpdatedAt, and relationship objects (dynamic fields)

func GenerateKeyHash

func GenerateKeyHash(key schemas.Key) (string, error)

GenerateKeyHash generates a SHA256 hash for an individual key. This is used to detect changes to keys between config.json and database. Skips: ID (dynamic UUID), timestamps

func GenerateMCPClientHash

func GenerateMCPClientHash(m tables.TableMCPClient) (string, error)

GenerateMCPClientHash generates a SHA256 hash for an MCP client. This is used to detect changes to MCP clients between config.json and database. Skips: ID (autoIncrement), CreatedAt, UpdatedAt (dynamic fields)

func GeneratePluginHash

func GeneratePluginHash(p tables.TablePlugin) (string, error)

GeneratePluginHash generates a SHA256 hash for a plugin. This is used to detect changes to plugins between config.json and database. Skips: ID (autoIncrement), CreatedAt, UpdatedAt, IsCustom (dynamic fields)

func GenerateRateLimitHash

func GenerateRateLimitHash(rl tables.TableRateLimit) (string, error)

GenerateRateLimitHash generates a SHA256 hash for a rate limit. This is used to detect changes to rate limits between config.json and database. Skips: CurrentUsage, LastReset, CreatedAt, UpdatedAt (dynamic fields)

func GenerateRoutingRuleHash

func GenerateRoutingRuleHash(r tables.TableRoutingRule) (string, error)

Skips: CreatedAt, UpdatedAt (dynamic fields)

func GenerateTeamHash

func GenerateTeamHash(t tables.TableTeam) (string, error)

GenerateTeamHash generates a SHA256 hash for a team. This is used to detect changes to teams between config.json and database. Skips: CreatedAt, UpdatedAt, and relationship objects (dynamic fields)

func GenerateVirtualKeyHash

func GenerateVirtualKeyHash(vk tables.TableVirtualKey) (string, error)

GenerateVirtualKeyHash generates a SHA256 hash for a virtual key. This is used to detect changes to virtual keys between config.json and database. Skips: ID (primary key), CreatedAt, UpdatedAt, and relationship objects (Team, Customer, Budget, RateLimit)

Types

type AuthConfig

type AuthConfig struct {
	AdminUserName          *schemas.EnvVar `json:"admin_username"`
	AdminPassword          *schemas.EnvVar `json:"admin_password"`
	IsEnabled              bool            `json:"is_enabled"`
	DisableAuthOnInference bool            `json:"disable_auth_on_inference"`
}

AuthConfig represents configured auth config for Bifrost dashboard

type ClientConfig

type ClientConfig struct {
	DropExcessRequests              bool                             `json:"drop_excess_requests"`    // Drop excess requests if the provider queue is full
	InitialPoolSize                 int                              `json:"initial_pool_size"`       // The initial pool size for the bifrost client
	PrometheusLabels                []string                         `json:"prometheus_labels"`       // The labels to be used for prometheus metrics
	EnableLogging                   *bool                            `json:"enable_logging"`          // Enable logging of requests and responses
	DisableContentLogging           bool                             `json:"disable_content_logging"` // Disable logging of content
	DisableDBPingsInHealth          bool                             `json:"disable_db_pings_in_health"`
	LogRetentionDays                int                              `json:"log_retention_days" validate:"min=1"`  // Number of days to retain logs (minimum 1 day)
	EnforceAuthOnInference          bool                             `json:"enforce_auth_on_inference"`            // Require auth (VK, API key, or user token) on inference endpoints
	EnforceGovernanceHeader         bool                             `json:"enforce_governance_header,omitempty"`  // Deprecated: use EnforceAuthOnInference
	EnforceSCIMAuth                 bool                             `json:"enforce_scim_auth,omitempty"`          // Deprecated: use EnforceAuthOnInference
	AllowDirectKeys                 bool                             `json:"allow_direct_keys"`                    // Allow direct keys to be used for requests
	AllowedOrigins                  []string                         `json:"allowed_origins,omitempty"`            // Additional allowed origins for CORS and WebSocket (localhost is always allowed)
	AllowedHeaders                  []string                         `json:"allowed_headers,omitempty"`            // Additional allowed headers for CORS and WebSocket
	MaxRequestBodySizeMB            int                              `json:"max_request_body_size_mb"`             // The maximum request body size in MB
	EnableLiteLLMFallbacks          bool                             `json:"enable_litellm_fallbacks"`             // Enable litellm-specific fallbacks for text completion for Groq
	MCPAgentDepth                   int                              `json:"mcp_agent_depth"`                      // The maximum depth for MCP agent mode tool execution
	MCPToolExecutionTimeout         int                              `json:"mcp_tool_execution_timeout"`           // The timeout for individual tool execution in seconds
	MCPCodeModeBindingLevel         string                           `json:"mcp_code_mode_binding_level"`          // Code mode binding level: "server" or "tool"
	MCPToolSyncInterval             int                              `json:"mcp_tool_sync_interval"`               // Global tool sync interval in minutes (default: 10, 0 = disabled)
	HeaderFilterConfig              *tables.GlobalHeaderFilterConfig `json:"header_filter_config,omitempty"`       // Global header filtering configuration for x-bf-eh-* headers
	AsyncJobResultTTL               int                              `json:"async_job_result_ttl"`                 // Default TTL for async job results in seconds (default: 3600 = 1 hour)
	RequiredHeaders                 []string                         `json:"required_headers,omitempty"`           // Headers that must be present on every request (case-insensitive)
	LoggingHeaders                  []string                         `json:"logging_headers,omitempty"`            // Headers to capture in log metadata
	WhitelistedRoutes               []string                         `json:"whitelisted_routes,omitempty"`         // Routes that bypass auth middleware
	HideDeletedVirtualKeysInFilters bool                             `json:"hide_deleted_virtual_keys_in_filters"` // Hide deleted virtual keys from logs/MCP filter data
	ConfigHash                      string                           `json:"-"`                                    // Config hash for reconciliation (not serialized)
}

ClientConfig represents the core configuration for Bifrost HTTP transport and the Bifrost Client. It includes settings for excess request handling, Prometheus metrics, and initial pool size.

func (*ClientConfig) GenerateClientConfigHash

func (c *ClientConfig) GenerateClientConfigHash() (string, error)

GenerateClientConfigHash generates a SHA256 hash of the client configuration. This is used to detect changes between config.json and database config.

type Config

type Config struct {
	Enabled bool            `json:"enabled"`
	Type    ConfigStoreType `json:"type"`
	Config  any             `json:"config"`
}

Config represents the configuration for the config store.

func (*Config) UnmarshalJSON

func (c *Config) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the config from JSON.

type ConfigMap

type ConfigMap map[schemas.ModelProvider]ProviderConfig

ConfigMap maps provider names to their configurations.

type ConfigStore

type ConfigStore interface {
	// Health check
	Ping(ctx context.Context) error

	// Encryption
	EncryptPlaintextRows(ctx context.Context) error

	// Client config CRUD
	UpdateClientConfig(ctx context.Context, config *ClientConfig) error
	GetClientConfig(ctx context.Context) (*ClientConfig, error)

	// Framework config CRUD
	UpdateFrameworkConfig(ctx context.Context, config *tables.TableFrameworkConfig) error
	GetFrameworkConfig(ctx context.Context) (*tables.TableFrameworkConfig, error)

	// Provider config CRUD
	UpdateProvidersConfig(ctx context.Context, providers map[schemas.ModelProvider]ProviderConfig, tx ...*gorm.DB) error
	AddProvider(ctx context.Context, provider schemas.ModelProvider, config ProviderConfig, tx ...*gorm.DB) error
	UpdateProvider(ctx context.Context, provider schemas.ModelProvider, config ProviderConfig, tx ...*gorm.DB) error
	DeleteProvider(ctx context.Context, provider schemas.ModelProvider, tx ...*gorm.DB) error
	GetProvidersConfig(ctx context.Context) (map[schemas.ModelProvider]ProviderConfig, error)
	GetProviderConfig(ctx context.Context, provider schemas.ModelProvider) (*ProviderConfig, error)
	GetProviders(ctx context.Context) ([]tables.TableProvider, error)
	GetProvider(ctx context.Context, provider schemas.ModelProvider) (*tables.TableProvider, error)
	UpdateStatus(ctx context.Context, provider schemas.ModelProvider, keyID string, status, errorMsg string) error

	// MCP config CRUD
	GetMCPConfig(ctx context.Context) (*schemas.MCPConfig, error)
	GetMCPClientByID(ctx context.Context, id string) (*tables.TableMCPClient, error)
	GetMCPClientByName(ctx context.Context, name string) (*tables.TableMCPClient, error)
	GetMCPClientsPaginated(ctx context.Context, params MCPClientsQueryParams) ([]tables.TableMCPClient, int64, error)
	CreateMCPClientConfig(ctx context.Context, clientConfig *schemas.MCPClientConfig) error
	UpdateMCPClientConfig(ctx context.Context, id string, clientConfig *tables.TableMCPClient) error
	DeleteMCPClientConfig(ctx context.Context, id string) error

	// Vector store config CRUD
	UpdateVectorStoreConfig(ctx context.Context, config *vectorstore.Config) error
	GetVectorStoreConfig(ctx context.Context) (*vectorstore.Config, error)

	// Logs store config CRUD
	UpdateLogsStoreConfig(ctx context.Context, config *logstore.Config) error
	GetLogsStoreConfig(ctx context.Context) (*logstore.Config, error)

	// Config CRUD
	GetConfig(ctx context.Context, key string) (*tables.TableGovernanceConfig, error)
	UpdateConfig(ctx context.Context, config *tables.TableGovernanceConfig, tx ...*gorm.DB) error

	// Plugins CRUD
	GetPlugins(ctx context.Context) ([]*tables.TablePlugin, error)
	GetPlugin(ctx context.Context, name string) (*tables.TablePlugin, error)
	CreatePlugin(ctx context.Context, plugin *tables.TablePlugin, tx ...*gorm.DB) error
	UpsertPlugin(ctx context.Context, plugin *tables.TablePlugin, tx ...*gorm.DB) error
	UpdatePlugin(ctx context.Context, plugin *tables.TablePlugin, tx ...*gorm.DB) error
	DeletePlugin(ctx context.Context, name string, tx ...*gorm.DB) error

	// Governance config CRUD
	GetVirtualKeys(ctx context.Context) ([]tables.TableVirtualKey, error)
	GetVirtualKeysPaginated(ctx context.Context, params VirtualKeyQueryParams) ([]tables.TableVirtualKey, int64, error)
	GetRedactedVirtualKeys(ctx context.Context, ids []string) ([]tables.TableVirtualKey, error) // leave ids empty to get all
	GetVirtualKey(ctx context.Context, id string) (*tables.TableVirtualKey, error)
	GetVirtualKeyByValue(ctx context.Context, value string) (*tables.TableVirtualKey, error)
	CreateVirtualKey(ctx context.Context, virtualKey *tables.TableVirtualKey, tx ...*gorm.DB) error
	UpdateVirtualKey(ctx context.Context, virtualKey *tables.TableVirtualKey, tx ...*gorm.DB) error
	DeleteVirtualKey(ctx context.Context, id string) error

	// Virtual key provider config CRUD
	GetVirtualKeyProviderConfigs(ctx context.Context, virtualKeyID string) ([]tables.TableVirtualKeyProviderConfig, error)
	CreateVirtualKeyProviderConfig(ctx context.Context, virtualKeyProviderConfig *tables.TableVirtualKeyProviderConfig, tx ...*gorm.DB) error
	UpdateVirtualKeyProviderConfig(ctx context.Context, virtualKeyProviderConfig *tables.TableVirtualKeyProviderConfig, tx ...*gorm.DB) error
	DeleteVirtualKeyProviderConfig(ctx context.Context, id uint, tx ...*gorm.DB) error

	// Virtual key MCP config CRUD
	GetVirtualKeyMCPConfigs(ctx context.Context, virtualKeyID string) ([]tables.TableVirtualKeyMCPConfig, error)
	CreateVirtualKeyMCPConfig(ctx context.Context, virtualKeyMCPConfig *tables.TableVirtualKeyMCPConfig, tx ...*gorm.DB) error
	UpdateVirtualKeyMCPConfig(ctx context.Context, virtualKeyMCPConfig *tables.TableVirtualKeyMCPConfig, tx ...*gorm.DB) error
	DeleteVirtualKeyMCPConfig(ctx context.Context, id uint, tx ...*gorm.DB) error

	// Team CRUD
	GetTeams(ctx context.Context, customerID string) ([]tables.TableTeam, error)
	GetTeamsPaginated(ctx context.Context, params TeamsQueryParams) ([]tables.TableTeam, int64, error)
	GetTeam(ctx context.Context, id string) (*tables.TableTeam, error)
	CreateTeam(ctx context.Context, team *tables.TableTeam, tx ...*gorm.DB) error
	UpdateTeam(ctx context.Context, team *tables.TableTeam, tx ...*gorm.DB) error
	DeleteTeam(ctx context.Context, id string) error

	// Customer CRUD
	GetCustomers(ctx context.Context) ([]tables.TableCustomer, error)
	GetCustomersPaginated(ctx context.Context, params CustomersQueryParams) ([]tables.TableCustomer, int64, error)
	GetCustomer(ctx context.Context, id string) (*tables.TableCustomer, error)
	CreateCustomer(ctx context.Context, customer *tables.TableCustomer, tx ...*gorm.DB) error
	UpdateCustomer(ctx context.Context, customer *tables.TableCustomer, tx ...*gorm.DB) error
	DeleteCustomer(ctx context.Context, id string) error

	// Rate limit CRUD
	GetRateLimits(ctx context.Context) ([]tables.TableRateLimit, error)
	GetRateLimit(ctx context.Context, id string, tx ...*gorm.DB) (*tables.TableRateLimit, error)
	CreateRateLimit(ctx context.Context, rateLimit *tables.TableRateLimit, tx ...*gorm.DB) error
	UpdateRateLimit(ctx context.Context, rateLimit *tables.TableRateLimit, tx ...*gorm.DB) error
	UpdateRateLimits(ctx context.Context, rateLimits []*tables.TableRateLimit, tx ...*gorm.DB) error
	DeleteRateLimit(ctx context.Context, id string, tx ...*gorm.DB) error

	// Budget CRUD
	GetBudgets(ctx context.Context) ([]tables.TableBudget, error)
	GetBudget(ctx context.Context, id string, tx ...*gorm.DB) (*tables.TableBudget, error)
	CreateBudget(ctx context.Context, budget *tables.TableBudget, tx ...*gorm.DB) error
	UpdateBudget(ctx context.Context, budget *tables.TableBudget, tx ...*gorm.DB) error
	UpdateBudgets(ctx context.Context, budgets []*tables.TableBudget, tx ...*gorm.DB) error
	DeleteBudget(ctx context.Context, id string, tx ...*gorm.DB) error
	UpdateBudgetUsage(ctx context.Context, id string, currentUsage float64) error
	UpdateRateLimitUsage(ctx context.Context, id string, tokenCurrentUsage int64, requestCurrentUsage int64) error

	// Routing Rules CRUD
	GetRoutingRules(ctx context.Context) ([]tables.TableRoutingRule, error)
	GetRoutingRulesByScope(ctx context.Context, scope string, scopeID string) ([]tables.TableRoutingRule, error)
	GetRoutingRule(ctx context.Context, id string) (*tables.TableRoutingRule, error)
	GetRedactedRoutingRules(ctx context.Context, ids []string) ([]tables.TableRoutingRule, error) // leave ids empty to get all
	GetRoutingRulesPaginated(ctx context.Context, params RoutingRulesQueryParams) ([]tables.TableRoutingRule, int64, error)
	CreateRoutingRule(ctx context.Context, rule *tables.TableRoutingRule, tx ...*gorm.DB) error
	UpdateRoutingRule(ctx context.Context, rule *tables.TableRoutingRule, tx ...*gorm.DB) error
	DeleteRoutingRule(ctx context.Context, id string, tx ...*gorm.DB) error

	// Model config CRUD
	GetModelConfigs(ctx context.Context) ([]tables.TableModelConfig, error)
	GetModelConfigsPaginated(ctx context.Context, params ModelConfigsQueryParams) ([]tables.TableModelConfig, int64, error)
	GetModelConfig(ctx context.Context, modelName string, provider *string) (*tables.TableModelConfig, error)
	GetModelConfigByID(ctx context.Context, id string) (*tables.TableModelConfig, error)
	CreateModelConfig(ctx context.Context, modelConfig *tables.TableModelConfig, tx ...*gorm.DB) error
	UpdateModelConfig(ctx context.Context, modelConfig *tables.TableModelConfig, tx ...*gorm.DB) error
	UpdateModelConfigs(ctx context.Context, modelConfigs []*tables.TableModelConfig, tx ...*gorm.DB) error
	DeleteModelConfig(ctx context.Context, id string) error

	// Governance config CRUD
	GetGovernanceConfig(ctx context.Context) (*GovernanceConfig, error)

	// Auth config CRUD
	GetAuthConfig(ctx context.Context) (*AuthConfig, error)
	UpdateAuthConfig(ctx context.Context, config *AuthConfig) error

	// Proxy config CRUD
	GetProxyConfig(ctx context.Context) (*tables.GlobalProxyConfig, error)
	UpdateProxyConfig(ctx context.Context, config *tables.GlobalProxyConfig) error

	// Restart required config CRUD
	GetRestartRequiredConfig(ctx context.Context) (*tables.RestartRequiredConfig, error)
	SetRestartRequiredConfig(ctx context.Context, config *tables.RestartRequiredConfig) error
	ClearRestartRequiredConfig(ctx context.Context) error

	// Session CRUD
	GetSession(ctx context.Context, token string) (*tables.SessionsTable, error)
	CreateSession(ctx context.Context, session *tables.SessionsTable) error
	DeleteSession(ctx context.Context, token string) error
	FlushSessions(ctx context.Context) error

	// Model pricing CRUD
	GetModelPrices(ctx context.Context) ([]tables.TableModelPricing, error)
	UpsertModelPrices(ctx context.Context, pricing *tables.TableModelPricing, tx ...*gorm.DB) error
	DeleteModelPrices(ctx context.Context, tx ...*gorm.DB) error

	// Model parameters
	GetModelParameters(ctx context.Context, model string) (*tables.TableModelParameters, error)
	UpsertModelParameters(ctx context.Context, params *tables.TableModelParameters, tx ...*gorm.DB) error

	// Key management
	GetKeysByIDs(ctx context.Context, ids []string) ([]tables.TableKey, error)
	GetKeysByProvider(ctx context.Context, provider string) ([]tables.TableKey, error)
	GetAllRedactedKeys(ctx context.Context, ids []string) ([]schemas.Key, error) // leave ids empty to get all

	// Generic transaction manager
	ExecuteTransaction(ctx context.Context, fn func(tx *gorm.DB) error) error

	// TryAcquireLock attempts to insert a lock row. Returns true if the lock was acquired.
	// If the lock already exists and is not expired, returns false.
	TryAcquireLock(ctx context.Context, lock *tables.TableDistributedLock) (bool, error)

	// GetLock retrieves a lock by its key. Returns nil if the lock doesn't exist.
	GetLock(ctx context.Context, lockKey string) (*tables.TableDistributedLock, error)

	// UpdateLockExpiry updates the expiration time for an existing lock.
	// Only succeeds if the holder ID matches the current lock holder.
	UpdateLockExpiry(ctx context.Context, lockKey, holderID string, expiresAt time.Time) error

	// ReleaseLock deletes a lock if the holder ID matches.
	// Returns true if the lock was released, false if it wasn't held by the given holder.
	ReleaseLock(ctx context.Context, lockKey, holderID string) (bool, error)

	// CleanupExpiredLockByKey atomically deletes a specific lock only if it has expired.
	// Returns true if an expired lock was deleted, false if the lock doesn't exist or hasn't expired.
	CleanupExpiredLockByKey(ctx context.Context, lockKey string) (bool, error)

	// CleanupExpiredLocks removes all locks that have expired.
	// Returns the number of locks cleaned up.
	CleanupExpiredLocks(ctx context.Context) (int64, error)

	// OAuth config CRUD
	GetOauthConfigByID(ctx context.Context, id string) (*tables.TableOauthConfig, error)
	GetOauthConfigByState(ctx context.Context, state string) (*tables.TableOauthConfig, error)
	GetOauthConfigByTokenID(ctx context.Context, tokenID string) (*tables.TableOauthConfig, error)
	CreateOauthConfig(ctx context.Context, config *tables.TableOauthConfig) error
	UpdateOauthConfig(ctx context.Context, config *tables.TableOauthConfig) error

	// OAuth token CRUD
	GetOauthTokenByID(ctx context.Context, id string) (*tables.TableOauthToken, error)
	GetExpiringOauthTokens(ctx context.Context, before time.Time) ([]*tables.TableOauthToken, error)
	CreateOauthToken(ctx context.Context, token *tables.TableOauthToken) error
	UpdateOauthToken(ctx context.Context, token *tables.TableOauthToken) error
	DeleteOauthToken(ctx context.Context, id string) error

	// Not found retry wrapper
	RetryOnNotFound(ctx context.Context, fn func(ctx context.Context) (any, error), maxRetries int, retryDelay time.Duration) (any, error)

	// Prompt Repository - Folders
	GetFolders(ctx context.Context) ([]tables.TableFolder, error)
	GetFolderByID(ctx context.Context, id string) (*tables.TableFolder, error)
	CreateFolder(ctx context.Context, folder *tables.TableFolder) error
	UpdateFolder(ctx context.Context, folder *tables.TableFolder) error
	DeleteFolder(ctx context.Context, id string) error

	// Prompt Repository - Prompts
	GetPrompts(ctx context.Context, folderID *string) ([]tables.TablePrompt, error)
	GetPromptByID(ctx context.Context, id string) (*tables.TablePrompt, error)
	CreatePrompt(ctx context.Context, prompt *tables.TablePrompt) error
	UpdatePrompt(ctx context.Context, prompt *tables.TablePrompt) error
	DeletePrompt(ctx context.Context, id string) error

	// Prompt Repository - Versions
	GetPromptVersions(ctx context.Context, promptID string) ([]tables.TablePromptVersion, error)
	GetPromptVersionByID(ctx context.Context, id uint) (*tables.TablePromptVersion, error)
	GetLatestPromptVersion(ctx context.Context, promptID string) (*tables.TablePromptVersion, error)
	CreatePromptVersion(ctx context.Context, version *tables.TablePromptVersion) error
	DeletePromptVersion(ctx context.Context, id uint) error

	// Prompt Repository - Sessions
	GetPromptSessions(ctx context.Context, promptID string) ([]tables.TablePromptSession, error)
	GetPromptSessionByID(ctx context.Context, id uint) (*tables.TablePromptSession, error)
	CreatePromptSession(ctx context.Context, session *tables.TablePromptSession) error
	UpdatePromptSession(ctx context.Context, session *tables.TablePromptSession) error
	RenamePromptSession(ctx context.Context, id uint, name string) error
	DeletePromptSession(ctx context.Context, id uint) error

	// DB returns the underlying database connection.
	DB() *gorm.DB

	// Migration manager
	RunMigration(ctx context.Context, migration *migrator.Migration) error

	// Cleanup
	Close(ctx context.Context) error
}

ConfigStore is the interface for the config store.

func NewConfigStore

func NewConfigStore(ctx context.Context, config *Config, logger schemas.Logger) (ConfigStore, error)

NewConfigStore creates a new config store based on the configuration

type ConfigStoreType

type ConfigStoreType string

ConfigStoreType represents the type of config store.

const (
	ConfigStoreTypeSQLite   ConfigStoreType = "sqlite"
	ConfigStoreTypePostgres ConfigStoreType = "postgres"
)

ConfigStoreTypeSQLite is the type of config store for SQLite.

type CustomersQueryParams

type CustomersQueryParams struct {
	Limit  int
	Offset int
	Search string
}

CustomersQueryParams holds pagination, filtering, and search parameters for customer queries.

type DistributedLock

type DistributedLock struct {
	// contains filtered or unexported fields
}

DistributedLock represents a distributed lock that can be acquired and released across multiple processes or instances.

func (*DistributedLock) Extend

func (l *DistributedLock) Extend(ctx context.Context) error

Extend extends the lock's TTL. This is useful for long-running operations that need to hold the lock longer than the initial TTL. Returns an error if the lock is not held by this holder or has expired. Only clears l.acquired when ErrLockNotHeld is returned; transient errors leave l.acquired untouched so Unlock() can still attempt a proper release.

func (*DistributedLock) HolderID

func (l *DistributedLock) HolderID() string

HolderID returns the unique identifier for this lock holder.

func (*DistributedLock) IsHeld

func (l *DistributedLock) IsHeld(ctx context.Context) (bool, error)

IsHeld checks if the lock is currently held by this holder. Note: This checks the local state and the database state. Returns (false, error) on transient database errors without clearing l.acquired, allowing Unlock() to still attempt a proper release.

func (*DistributedLock) Key

func (l *DistributedLock) Key() string

Key returns the lock key.

func (*DistributedLock) Lock

func (l *DistributedLock) Lock(ctx context.Context) error

Lock acquires the lock, blocking until it's available or the context is cancelled. It will make up to (maxRetries + 1) attempts, sleeping retryInterval between failed attempts.

func (*DistributedLock) LockWithRetry

func (l *DistributedLock) LockWithRetry(ctx context.Context, maxRetries int) error

LockWithRetry acquires the lock, blocking until it's available or the context is cancelled. It will retry up to maxRetries times with retryInterval between attempts.

func (*DistributedLock) TryLock

func (l *DistributedLock) TryLock(ctx context.Context) (bool, error)

TryLock attempts to acquire the lock without blocking. Returns true if the lock was acquired, false if it's held by another process.

func (*DistributedLock) Unlock

func (l *DistributedLock) Unlock(ctx context.Context) error

Unlock releases the lock if it's held by this holder. Returns an error if the lock is not held by this holder.

type DistributedLockManager

type DistributedLockManager struct {
	// contains filtered or unexported fields
}

DistributedLockManager creates and manages distributed locks. It provides a factory for creating locks with consistent configuration.

func NewDistributedLockManager

func NewDistributedLockManager(store LockStore, logger schemas.Logger, opts ...DistributedLockManagerOption) *DistributedLockManager

NewDistributedLockManager creates a new lock manager with the given store and options.

func (*DistributedLockManager) CleanupExpiredLocks

func (m *DistributedLockManager) CleanupExpiredLocks(ctx context.Context) (int64, error)

CleanupExpiredLocks removes all expired locks from the store. This can be called periodically to clean up stale locks.

func (*DistributedLockManager) NewLock

func (m *DistributedLockManager) NewLock(lockKey string) (*DistributedLock, error)

NewLock creates a new DistributedLock for the given key. The lock is not acquired until Lock() or TryLock() is called. Returns an error if the lock key is empty.

func (*DistributedLockManager) NewLockWithTTL

func (m *DistributedLockManager) NewLockWithTTL(lockKey string, ttl time.Duration) (*DistributedLock, error)

NewLockWithTTL creates a new DistributedLock with a custom TTL. Returns an error if the lock key is empty.

type DistributedLockManagerOption

type DistributedLockManagerOption func(*DistributedLockManager)

DistributedLockManagerOption is a function that configures a DistributedLockManager.

func WithDefaultTTL

func WithDefaultTTL(ttl time.Duration) DistributedLockManagerOption

WithDefaultTTL sets the default TTL for locks created by this manager.

func WithMaxRetries

func WithMaxRetries(maxRetries int) DistributedLockManagerOption

WithMaxRetries sets the maximum number of retries for lock acquisition.

func WithRetryInterval

func WithRetryInterval(interval time.Duration) DistributedLockManagerOption

WithRetryInterval sets the interval between lock acquisition retries.

type EnvKeyInfo

type EnvKeyInfo struct {
	EnvVar     string                // The environment variable name (without env. prefix)
	Provider   schemas.ModelProvider // The provider this key belongs to (empty for core/mcp configs)
	KeyType    EnvKeyType            // Type of key (e.g., "api_key", "azure_config", "vertex_config", "bedrock_config", "connection_string", "mcp_header")
	ConfigPath string                // Path in config where this env var is used
	KeyID      string                // The key ID this env var belongs to (empty for non-key configs like bedrock_config, connection_string)
}

EnvKeyInfo stores information about a key sourced from environment

type EnvKeyType

type EnvKeyType string
const (
	EnvKeyTypeAPIKey        EnvKeyType = "api_key"
	EnvKeyTypeAzureConfig   EnvKeyType = "azure_config"
	EnvKeyTypeVertexConfig  EnvKeyType = "vertex_config"
	EnvKeyTypeBedrockConfig EnvKeyType = "bedrock_config"
	EnvKeyTypeConnection    EnvKeyType = "connection_string"
	EnvKeyTypeMCPHeader     EnvKeyType = "mcp_header"
)

type ErrUnresolvedKeys

type ErrUnresolvedKeys struct {
	Identifiers []string
}

ErrUnresolvedKeys is returned when one or more keys could not be resolved

func (*ErrUnresolvedKeys) Error

func (e *ErrUnresolvedKeys) Error() string

type GovernanceConfig

type GovernanceConfig struct {
	VirtualKeys  []tables.TableVirtualKey  `json:"virtual_keys"`
	Teams        []tables.TableTeam        `json:"teams"`
	Customers    []tables.TableCustomer    `json:"customers"`
	Budgets      []tables.TableBudget      `json:"budgets"`
	RateLimits   []tables.TableRateLimit   `json:"rate_limits"`
	ModelConfigs []tables.TableModelConfig `json:"model_configs"`
	Providers    []tables.TableProvider    `json:"providers"`
	RoutingRules []tables.TableRoutingRule `json:"routing_rules"`
	AuthConfig   *AuthConfig               `json:"auth_config,omitempty"`
}

type LockStore

type LockStore interface {
	// TryAcquireLock attempts to insert a lock row. Returns true if the lock was acquired.
	// If the lock already exists and is not expired, returns false.
	TryAcquireLock(ctx context.Context, lock *tables.TableDistributedLock) (bool, error)

	// GetLock retrieves a lock by its key. Returns nil if the lock doesn't exist.
	GetLock(ctx context.Context, lockKey string) (*tables.TableDistributedLock, error)

	// UpdateLockExpiry updates the expiration time for an existing lock.
	// Only succeeds if the holder ID matches the current lock holder.
	UpdateLockExpiry(ctx context.Context, lockKey, holderID string, expiresAt time.Time) error

	// ReleaseLock deletes a lock if the holder ID matches.
	// Returns true if the lock was released, false if it wasn't held by the given holder.
	ReleaseLock(ctx context.Context, lockKey, holderID string) (bool, error)

	// CleanupExpiredLocks removes all locks that have expired.
	// Returns the number of locks cleaned up.
	CleanupExpiredLocks(ctx context.Context) (int64, error)

	// CleanupExpiredLockByKey atomically deletes a lock only if it has expired.
	// Returns true if an expired lock was deleted, false if the lock doesn't exist or hasn't expired.
	CleanupExpiredLockByKey(ctx context.Context, lockKey string) (bool, error)
}

LockStore defines the storage operations required for distributed locking. This interface abstracts the database operations, making the lock implementation testable and decoupled from the specific database implementation.

type MCPClientsQueryParams

type MCPClientsQueryParams struct {
	Limit  int
	Offset int
	Search string
}

MCPClientsQueryParams holds pagination, filtering, and search parameters for MCP client queries.

type ModelConfigsQueryParams

type ModelConfigsQueryParams struct {
	Limit  int
	Offset int
	Search string
}

ModelConfigsQueryParams holds pagination, filtering, and search parameters for model configs queries.

type PostgresConfig

type PostgresConfig struct {
	Host         *schemas.EnvVar `json:"host"`
	Port         *schemas.EnvVar `json:"port"`
	User         *schemas.EnvVar `json:"user"`
	Password     *schemas.EnvVar `json:"password"`
	DBName       *schemas.EnvVar `json:"db_name"`
	SSLMode      *schemas.EnvVar `json:"ssl_mode"`
	MaxIdleConns int             `json:"max_idle_conns"`
	MaxOpenConns int             `json:"max_open_conns"`
}

PostgresConfig represents the configuration for a Postgres database.

type ProviderConfig

type ProviderConfig struct {
	Keys                     []schemas.Key                     `json:"keys"`                                  // API keys for the provider with UUIDs
	NetworkConfig            *schemas.NetworkConfig            `json:"network_config,omitempty"`              // Network-related settings
	ConcurrencyAndBufferSize *schemas.ConcurrencyAndBufferSize `json:"concurrency_and_buffer_size,omitempty"` // Concurrency settings
	ProxyConfig              *schemas.ProxyConfig              `json:"proxy_config,omitempty"`                // Proxy configuration
	SendBackRawRequest       bool                              `json:"send_back_raw_request"`                 // Include raw request in BifrostResponse
	SendBackRawResponse      bool                              `json:"send_back_raw_response"`                // Include raw response in BifrostResponse
	StoreRawRequestResponse  bool                              `json:"store_raw_request_response"`            // Capture raw request/response for internal logging only; strip from API responses returned to clients
	CustomProviderConfig     *schemas.CustomProviderConfig     `json:"custom_provider_config,omitempty"`      // Custom provider configuration
	OpenAIConfig             *schemas.OpenAIConfig             `json:"openai_config,omitempty"`               // OpenAI-specific configuration
	PricingOverrides         []schemas.ProviderPricingOverride `json:"pricing_overrides,omitempty"`           // Provider-level pricing overrides
	ConfigHash               string                            `json:"config_hash,omitempty"`                 // Hash of config.json version, used for change detection
	Status                   string                            `json:"status,omitempty"`                      // Model discovery status for keyless providers
	Description              string                            `json:"description,omitempty"`                 // Model discovery error message for keyless providers
}

ProviderConfig represents the configuration for a specific AI model provider. It includes API keys, network settings, and concurrency settings.

func (*ProviderConfig) GenerateConfigHash

func (p *ProviderConfig) GenerateConfigHash(providerName string) (string, error)

GenerateConfigHash generates a SHA256 hash of the provider configuration. This is used to detect changes between config.json and database config. Keys are excluded as they are hashed separately.

func (*ProviderConfig) Redacted

func (p *ProviderConfig) Redacted() *ProviderConfig

Redacted returns a redacted copy of the provider configuration.

type RDBConfigStore

type RDBConfigStore struct {
	// contains filtered or unexported fields
}

RDBConfigStore represents a configuration store that uses a relational database.

func (*RDBConfigStore) AddProvider

func (s *RDBConfigStore) AddProvider(ctx context.Context, provider schemas.ModelProvider, config ProviderConfig, tx ...*gorm.DB) error

AddProvider creates a new provider configuration in the database.

func (*RDBConfigStore) CleanupExpiredLockByKey

func (s *RDBConfigStore) CleanupExpiredLockByKey(ctx context.Context, lockKey string) (bool, error)

CleanupExpiredLockByKey atomically deletes a specific lock only if it has expired. Returns true if an expired lock was deleted, false if the lock doesn't exist or hasn't expired.

func (*RDBConfigStore) CleanupExpiredLocks

func (s *RDBConfigStore) CleanupExpiredLocks(ctx context.Context) (int64, error)

CleanupExpiredLocks removes all locks that have expired. Returns the number of locks cleaned up.

func (*RDBConfigStore) ClearRestartRequiredConfig

func (s *RDBConfigStore) ClearRestartRequiredConfig(ctx context.Context) error

ClearRestartRequiredConfig clears the restart required configuration in the database.

func (*RDBConfigStore) Close

func (s *RDBConfigStore) Close(ctx context.Context) error

Close closes the SQLite config store.

func (*RDBConfigStore) CreateBudget

func (s *RDBConfigStore) CreateBudget(ctx context.Context, budget *tables.TableBudget, tx ...*gorm.DB) error

CreateBudget creates a new budget in the database.

func (*RDBConfigStore) CreateCustomer

func (s *RDBConfigStore) CreateCustomer(ctx context.Context, customer *tables.TableCustomer, tx ...*gorm.DB) error

CreateCustomer creates a new customer in the database.

func (*RDBConfigStore) CreateFolder

func (s *RDBConfigStore) CreateFolder(ctx context.Context, folder *tables.TableFolder) error

CreateFolder creates a new folder

func (*RDBConfigStore) CreateMCPClientConfig

func (s *RDBConfigStore) CreateMCPClientConfig(ctx context.Context, clientConfig *schemas.MCPClientConfig) error

CreateMCPClientConfig creates a new MCP client configuration in the database.

func (*RDBConfigStore) CreateModelConfig

func (s *RDBConfigStore) CreateModelConfig(ctx context.Context, modelConfig *tables.TableModelConfig, tx ...*gorm.DB) error

CreateModelConfig creates a new model config in the database.

func (*RDBConfigStore) CreateOauthConfig

func (s *RDBConfigStore) CreateOauthConfig(ctx context.Context, config *tables.TableOauthConfig) error

CreateOauthConfig creates a new OAuth config

func (*RDBConfigStore) CreateOauthToken

func (s *RDBConfigStore) CreateOauthToken(ctx context.Context, token *tables.TableOauthToken) error

CreateOauthToken creates a new OAuth token

func (*RDBConfigStore) CreatePlugin

func (s *RDBConfigStore) CreatePlugin(ctx context.Context, plugin *tables.TablePlugin, tx ...*gorm.DB) error

CreatePlugin creates a new plugin in the database.

func (*RDBConfigStore) CreatePrompt

func (s *RDBConfigStore) CreatePrompt(ctx context.Context, prompt *tables.TablePrompt) error

CreatePrompt creates a new prompt

func (*RDBConfigStore) CreatePromptSession

func (s *RDBConfigStore) CreatePromptSession(ctx context.Context, session *tables.TablePromptSession) error

CreatePromptSession creates a new session

func (*RDBConfigStore) CreatePromptVersion

func (s *RDBConfigStore) CreatePromptVersion(ctx context.Context, version *tables.TablePromptVersion) error

CreatePromptVersion creates a new version and marks it as latest. Retries on unique constraint conflict (concurrent version_number allocation).

func (*RDBConfigStore) CreateRateLimit

func (s *RDBConfigStore) CreateRateLimit(ctx context.Context, rateLimit *tables.TableRateLimit, tx ...*gorm.DB) error

CreateRateLimit creates a new rate limit in the database.

func (*RDBConfigStore) CreateRoutingRule

func (s *RDBConfigStore) CreateRoutingRule(ctx context.Context, rule *tables.TableRoutingRule, tx ...*gorm.DB) error

CreateRoutingRule creates a new routing rule in the database.

func (*RDBConfigStore) CreateSession

func (s *RDBConfigStore) CreateSession(ctx context.Context, session *tables.SessionsTable) error

CreateSession creates a new session in the database.

func (*RDBConfigStore) CreateTeam

func (s *RDBConfigStore) CreateTeam(ctx context.Context, team *tables.TableTeam, tx ...*gorm.DB) error

CreateTeam creates a new team in the database.

func (*RDBConfigStore) CreateVirtualKey

func (s *RDBConfigStore) CreateVirtualKey(ctx context.Context, virtualKey *tables.TableVirtualKey, tx ...*gorm.DB) error

func (*RDBConfigStore) CreateVirtualKeyMCPConfig

func (s *RDBConfigStore) CreateVirtualKeyMCPConfig(ctx context.Context, virtualKeyMCPConfig *tables.TableVirtualKeyMCPConfig, tx ...*gorm.DB) error

CreateVirtualKeyMCPConfig creates a new virtual key MCP config in the database.

func (*RDBConfigStore) CreateVirtualKeyProviderConfig

func (s *RDBConfigStore) CreateVirtualKeyProviderConfig(ctx context.Context, virtualKeyProviderConfig *tables.TableVirtualKeyProviderConfig, tx ...*gorm.DB) error

CreateVirtualKeyProviderConfig creates a new virtual key provider config in the database.

func (*RDBConfigStore) DB

func (s *RDBConfigStore) DB() *gorm.DB

DB returns the underlying database connection.

func (*RDBConfigStore) DeleteBudget

func (s *RDBConfigStore) DeleteBudget(ctx context.Context, id string, tx ...*gorm.DB) error

DeleteBudget deletes a budget from the database.

func (*RDBConfigStore) DeleteCustomer

func (s *RDBConfigStore) DeleteCustomer(ctx context.Context, id string) error

DeleteCustomer deletes a customer from the database.

func (*RDBConfigStore) DeleteFolder

func (s *RDBConfigStore) DeleteFolder(ctx context.Context, id string) error

DeleteFolder deletes a folder and all its child prompts (with their versions, sessions, and messages). PostgreSQL uses native ON DELETE CASCADE; SQLite requires manual cascade because it cannot alter foreign key constraints after table creation.

func (*RDBConfigStore) DeleteMCPClientConfig

func (s *RDBConfigStore) DeleteMCPClientConfig(ctx context.Context, id string) error

DeleteMCPClientConfig deletes an MCP client configuration from the database.

func (*RDBConfigStore) DeleteModelConfig

func (s *RDBConfigStore) DeleteModelConfig(ctx context.Context, id string) error

DeleteModelConfig deletes a model config from the database.

func (*RDBConfigStore) DeleteModelPrices

func (s *RDBConfigStore) DeleteModelPrices(ctx context.Context, tx ...*gorm.DB) error

DeleteModelPrices deletes all model pricing records from the database.

func (*RDBConfigStore) DeleteOauthToken

func (s *RDBConfigStore) DeleteOauthToken(ctx context.Context, id string) error

DeleteOauthToken deletes an OAuth token by its ID

func (*RDBConfigStore) DeletePlugin

func (s *RDBConfigStore) DeletePlugin(ctx context.Context, name string, tx ...*gorm.DB) error

func (*RDBConfigStore) DeletePrompt

func (s *RDBConfigStore) DeletePrompt(ctx context.Context, id string) error

DeletePrompt deletes a prompt and all its child versions, sessions, and messages. PostgreSQL uses native ON DELETE CASCADE; SQLite requires manual cascade because it cannot alter foreign key constraints after table creation.

func (*RDBConfigStore) DeletePromptSession

func (s *RDBConfigStore) DeletePromptSession(ctx context.Context, id uint) error

DeletePromptSession deletes a session and its messages. PostgreSQL uses native ON DELETE CASCADE for messages; SQLite requires manual cascade.

func (*RDBConfigStore) DeletePromptVersion

func (s *RDBConfigStore) DeletePromptVersion(ctx context.Context, id uint) error

DeletePromptVersion deletes a version and promotes the previous version to latest if needed. PostgreSQL uses native ON DELETE CASCADE for messages; SQLite requires manual cascade.

func (*RDBConfigStore) DeleteProvider

func (s *RDBConfigStore) DeleteProvider(ctx context.Context, provider schemas.ModelProvider, tx ...*gorm.DB) error

DeleteProvider deletes a single provider and all its associated keys from the database.

func (*RDBConfigStore) DeleteRateLimit

func (s *RDBConfigStore) DeleteRateLimit(ctx context.Context, id string, tx ...*gorm.DB) error

DeleteRateLimit deletes a rate limit from the database.

func (*RDBConfigStore) DeleteRoutingRule

func (s *RDBConfigStore) DeleteRoutingRule(ctx context.Context, id string, tx ...*gorm.DB) error

DeleteRoutingRule deletes a routing rule and its targets from the database.

func (*RDBConfigStore) DeleteSession

func (s *RDBConfigStore) DeleteSession(ctx context.Context, token string) error

DeleteSession deletes a session from the database.

func (*RDBConfigStore) DeleteTeam

func (s *RDBConfigStore) DeleteTeam(ctx context.Context, id string) error

DeleteTeam deletes a team from the database.

func (*RDBConfigStore) DeleteVirtualKey

func (s *RDBConfigStore) DeleteVirtualKey(ctx context.Context, id string) error

DeleteVirtualKey deletes a virtual key from the database.

func (*RDBConfigStore) DeleteVirtualKeyMCPConfig

func (s *RDBConfigStore) DeleteVirtualKeyMCPConfig(ctx context.Context, id uint, tx ...*gorm.DB) error

DeleteVirtualKeyMCPConfig deletes a virtual key provider config from the database.

func (*RDBConfigStore) DeleteVirtualKeyProviderConfig

func (s *RDBConfigStore) DeleteVirtualKeyProviderConfig(ctx context.Context, id uint, tx ...*gorm.DB) error

DeleteVirtualKeyProviderConfig deletes a virtual key provider config from the database.

func (*RDBConfigStore) EncryptPlaintextRows

func (s *RDBConfigStore) EncryptPlaintextRows(ctx context.Context) error

EncryptPlaintextRows encrypts all rows with encryption_status='plain_text' across all sensitive tables. Called during startup when encryption is enabled. Each table's GORM BeforeSave hook handles the actual encryption.

func (*RDBConfigStore) ExecuteTransaction

func (s *RDBConfigStore) ExecuteTransaction(ctx context.Context, fn func(tx *gorm.DB) error) error

ExecuteTransaction executes a transaction.

func (*RDBConfigStore) FlushSessions

func (s *RDBConfigStore) FlushSessions(ctx context.Context) error

FlushSessions flushes all sessions from the database.

func (*RDBConfigStore) GetAllProviderModelNames

func (s *RDBConfigStore) GetAllProviderModelNames(ctx context.Context) (map[schemas.ModelProvider][]string, error)

GetAllProviderModelNames retrieves the persisted provider model inventories.

func (*RDBConfigStore) GetAllRedactedKeys

func (s *RDBConfigStore) GetAllRedactedKeys(ctx context.Context, ids []string) ([]schemas.Key, error)

GetAllRedactedKeys retrieves all redacted keys from the database.

func (*RDBConfigStore) GetAuthConfig

func (s *RDBConfigStore) GetAuthConfig(ctx context.Context) (*AuthConfig, error)

GetAuthConfig retrieves the auth configuration from the database.

func (*RDBConfigStore) GetBudget

func (s *RDBConfigStore) GetBudget(ctx context.Context, id string, tx ...*gorm.DB) (*tables.TableBudget, error)

GetBudget retrieves a specific budget from the database.

func (*RDBConfigStore) GetBudgets

func (s *RDBConfigStore) GetBudgets(ctx context.Context) ([]tables.TableBudget, error)

GetBudgets retrieves all budgets from the database.

func (*RDBConfigStore) GetClientConfig

func (s *RDBConfigStore) GetClientConfig(ctx context.Context) (*ClientConfig, error)

GetClientConfig retrieves the client configuration from the database.

func (*RDBConfigStore) GetConfig

GetConfig retrieves a specific config from the database.

func (*RDBConfigStore) GetCustomer

func (s *RDBConfigStore) GetCustomer(ctx context.Context, id string) (*tables.TableCustomer, error)

GetCustomer retrieves a specific customer from the database.

func (*RDBConfigStore) GetCustomers

func (s *RDBConfigStore) GetCustomers(ctx context.Context) ([]tables.TableCustomer, error)

GetCustomers retrieves all customers from the database.

func (*RDBConfigStore) GetCustomersPaginated

func (s *RDBConfigStore) GetCustomersPaginated(ctx context.Context, params CustomersQueryParams) ([]tables.TableCustomer, int64, error)

GetCustomersPaginated retrieves customers with pagination and optional search filtering.

func (*RDBConfigStore) GetExpiringOauthTokens

func (s *RDBConfigStore) GetExpiringOauthTokens(ctx context.Context, before time.Time) ([]*tables.TableOauthToken, error)

GetExpiringOauthTokens retrieves tokens that are expiring before the given time

func (*RDBConfigStore) GetFolderByID

func (s *RDBConfigStore) GetFolderByID(ctx context.Context, id string) (*tables.TableFolder, error)

GetFolderByID gets a folder by ID

func (*RDBConfigStore) GetFolders

func (s *RDBConfigStore) GetFolders(ctx context.Context) ([]tables.TableFolder, error)

GetFolders gets all folders

func (*RDBConfigStore) GetFrameworkConfig

func (s *RDBConfigStore) GetFrameworkConfig(ctx context.Context) (*tables.TableFrameworkConfig, error)

GetFrameworkConfig retrieves the framework configuration from the database.

func (*RDBConfigStore) GetGovernanceConfig

func (s *RDBConfigStore) GetGovernanceConfig(ctx context.Context) (*GovernanceConfig, error)

GetGovernanceConfig retrieves the governance configuration from the database.

func (*RDBConfigStore) GetKeysByIDs

func (s *RDBConfigStore) GetKeysByIDs(ctx context.Context, ids []string) ([]tables.TableKey, error)

GetKeysByIDs retrieves multiple keys by their IDs

func (*RDBConfigStore) GetKeysByProvider

func (s *RDBConfigStore) GetKeysByProvider(ctx context.Context, provider string) ([]tables.TableKey, error)

GetKeysByProvider retrieves all keys for a specific provider

func (*RDBConfigStore) GetLatestPromptVersion

func (s *RDBConfigStore) GetLatestPromptVersion(ctx context.Context, promptID string) (*tables.TablePromptVersion, error)

GetLatestPromptVersion gets the latest version for a prompt

func (*RDBConfigStore) GetLock

func (s *RDBConfigStore) GetLock(ctx context.Context, lockKey string) (*tables.TableDistributedLock, error)

GetLock retrieves a lock by its key. Returns nil if the lock doesn't exist.

func (*RDBConfigStore) GetLogsStoreConfig

func (s *RDBConfigStore) GetLogsStoreConfig(ctx context.Context) (*logstore.Config, error)

GetLogsStoreConfig retrieves the logs store configuration from the database.

func (*RDBConfigStore) GetMCPClientByID

func (s *RDBConfigStore) GetMCPClientByID(ctx context.Context, id string) (*tables.TableMCPClient, error)

GetMCPClientByID retrieves an MCP client by ID from the database.

func (*RDBConfigStore) GetMCPClientByName

func (s *RDBConfigStore) GetMCPClientByName(ctx context.Context, name string) (*tables.TableMCPClient, error)

GetMCPClientByName retrieves an MCP client by name from the database.

func (*RDBConfigStore) GetMCPClientsPaginated

func (s *RDBConfigStore) GetMCPClientsPaginated(ctx context.Context, params MCPClientsQueryParams) ([]tables.TableMCPClient, int64, error)

GetMCPClientsPaginated retrieves MCP clients with pagination and optional search.

func (*RDBConfigStore) GetMCPConfig

func (s *RDBConfigStore) GetMCPConfig(ctx context.Context) (*schemas.MCPConfig, error)

GetMCPConfig retrieves the MCP configuration from the database.

func (*RDBConfigStore) GetModelConfig

func (s *RDBConfigStore) GetModelConfig(ctx context.Context, modelName string, provider *string) (*tables.TableModelConfig, error)

GetModelConfig retrieves a specific model config from the database by model name and optional provider.

func (*RDBConfigStore) GetModelConfigByID

func (s *RDBConfigStore) GetModelConfigByID(ctx context.Context, id string) (*tables.TableModelConfig, error)

GetModelConfigByID retrieves a specific model config from the database by ID.

func (*RDBConfigStore) GetModelConfigs

func (s *RDBConfigStore) GetModelConfigs(ctx context.Context) ([]tables.TableModelConfig, error)

GetModelConfigs retrieves all model configs from the database.

func (*RDBConfigStore) GetModelConfigsPaginated

func (s *RDBConfigStore) GetModelConfigsPaginated(ctx context.Context, params ModelConfigsQueryParams) ([]tables.TableModelConfig, int64, error)

func (*RDBConfigStore) GetModelParameters

func (s *RDBConfigStore) GetModelParameters(ctx context.Context, model string) (*tables.TableModelParameters, error)

GetModelParameters retrieves model parameters for a specific model from the database.

func (*RDBConfigStore) GetModelPrices

func (s *RDBConfigStore) GetModelPrices(ctx context.Context) ([]tables.TableModelPricing, error)

GetModelPrices retrieves all model pricing records from the database.

func (*RDBConfigStore) GetOauthConfigByID

func (s *RDBConfigStore) GetOauthConfigByID(ctx context.Context, id string) (*tables.TableOauthConfig, error)

GetOauthConfigByID retrieves an OAuth config by its ID

func (*RDBConfigStore) GetOauthConfigByState

func (s *RDBConfigStore) GetOauthConfigByState(ctx context.Context, state string) (*tables.TableOauthConfig, error)

GetOauthConfigByState retrieves an OAuth config by its state token State is unique per OAuth flow (used for CSRF protection on callback)

func (*RDBConfigStore) GetOauthConfigByTokenID

func (s *RDBConfigStore) GetOauthConfigByTokenID(ctx context.Context, tokenID string) (*tables.TableOauthConfig, error)

GetOauthConfigByTokenID retrieves an OAuth config that references a specific token

func (*RDBConfigStore) GetOauthTokenByID

func (s *RDBConfigStore) GetOauthTokenByID(ctx context.Context, id string) (*tables.TableOauthToken, error)

GetOauthTokenByID retrieves an OAuth token by its ID

func (*RDBConfigStore) GetPlugin

func (s *RDBConfigStore) GetPlugin(ctx context.Context, name string) (*tables.TablePlugin, error)

func (*RDBConfigStore) GetPlugins

func (s *RDBConfigStore) GetPlugins(ctx context.Context) ([]*tables.TablePlugin, error)

func (*RDBConfigStore) GetPromptByID

func (s *RDBConfigStore) GetPromptByID(ctx context.Context, id string) (*tables.TablePrompt, error)

GetPromptByID gets a prompt by ID with latest version

func (*RDBConfigStore) GetPromptSessionByID

func (s *RDBConfigStore) GetPromptSessionByID(ctx context.Context, id uint) (*tables.TablePromptSession, error)

GetPromptSessionByID gets a session by ID

func (*RDBConfigStore) GetPromptSessions

func (s *RDBConfigStore) GetPromptSessions(ctx context.Context, promptID string) ([]tables.TablePromptSession, error)

GetPromptSessions gets all sessions for a prompt

func (*RDBConfigStore) GetPromptVersionByID

func (s *RDBConfigStore) GetPromptVersionByID(ctx context.Context, id uint) (*tables.TablePromptVersion, error)

GetPromptVersionByID gets a version by ID

func (*RDBConfigStore) GetPromptVersions

func (s *RDBConfigStore) GetPromptVersions(ctx context.Context, promptID string) ([]tables.TablePromptVersion, error)

GetPromptVersions gets all versions for a prompt

func (*RDBConfigStore) GetPrompts

func (s *RDBConfigStore) GetPrompts(ctx context.Context, folderID *string) ([]tables.TablePrompt, error)

GetPrompts gets all prompts, optionally filtered by folder ID

func (*RDBConfigStore) GetProvider

func (s *RDBConfigStore) GetProvider(ctx context.Context, provider schemas.ModelProvider) (*tables.TableProvider, error)

GetProvider retrieves a provider by name from the database with governance relationships.

func (*RDBConfigStore) GetProviderByName

func (s *RDBConfigStore) GetProviderByName(ctx context.Context, name string) (*tables.TableProvider, error)

GetProviderByName retrieves a provider by name from the database with governance relationships.

func (*RDBConfigStore) GetProviderConfig

func (s *RDBConfigStore) GetProviderConfig(ctx context.Context, provider schemas.ModelProvider) (*ProviderConfig, error)

GetProviderConfig retrieves the provider configuration from the database.

func (*RDBConfigStore) GetProviders

func (s *RDBConfigStore) GetProviders(ctx context.Context) ([]tables.TableProvider, error)

GetProviders retrieves all providers from the database with their governance relationships.

func (*RDBConfigStore) GetProvidersConfig

func (s *RDBConfigStore) GetProvidersConfig(ctx context.Context) (map[schemas.ModelProvider]ProviderConfig, error)

GetProvidersConfig retrieves the provider configuration from the database.

func (*RDBConfigStore) GetProxyConfig

func (s *RDBConfigStore) GetProxyConfig(ctx context.Context) (*tables.GlobalProxyConfig, error)

GetProxyConfig retrieves the proxy configuration from the database.

func (*RDBConfigStore) GetRateLimit

func (s *RDBConfigStore) GetRateLimit(ctx context.Context, id string, tx ...*gorm.DB) (*tables.TableRateLimit, error)

GetRateLimit retrieves a specific rate limit from the database.

func (*RDBConfigStore) GetRateLimits

func (s *RDBConfigStore) GetRateLimits(ctx context.Context) ([]tables.TableRateLimit, error)

GetRateLimits retrieves all rate limits from the database.

func (*RDBConfigStore) GetRedactedRoutingRules

func (s *RDBConfigStore) GetRedactedRoutingRules(ctx context.Context, ids []string) ([]tables.TableRoutingRule, error)

GetRedactedRoutingRules retrieves redacted routing rules from the database.

func (*RDBConfigStore) GetRedactedVirtualKeys

func (s *RDBConfigStore) GetRedactedVirtualKeys(ctx context.Context, ids []string) ([]tables.TableVirtualKey, error)

func (*RDBConfigStore) GetRestartRequiredConfig

func (s *RDBConfigStore) GetRestartRequiredConfig(ctx context.Context) (*tables.RestartRequiredConfig, error)

GetRestartRequiredConfig retrieves the restart required configuration from the database.

func (*RDBConfigStore) GetRoutingRule

func (s *RDBConfigStore) GetRoutingRule(ctx context.Context, id string) (*tables.TableRoutingRule, error)

GetRoutingRule retrieves a specific routing rule by ID.

func (*RDBConfigStore) GetRoutingRules

func (s *RDBConfigStore) GetRoutingRules(ctx context.Context) ([]tables.TableRoutingRule, error)

GetRoutingRules retrieves all routing rules from the database.

func (*RDBConfigStore) GetRoutingRulesByScope

func (s *RDBConfigStore) GetRoutingRulesByScope(ctx context.Context, scope string, scopeID string) ([]tables.TableRoutingRule, error)

GetRoutingRulesByScope retrieves routing rules by scope and scope ID, ordered by priority ASC.

func (*RDBConfigStore) GetRoutingRulesPaginated

func (s *RDBConfigStore) GetRoutingRulesPaginated(ctx context.Context, params RoutingRulesQueryParams) ([]tables.TableRoutingRule, int64, error)

GetRoutingRulesPaginated retrieves routing rules with pagination and optional search filtering.

func (*RDBConfigStore) GetSession

func (s *RDBConfigStore) GetSession(ctx context.Context, token string) (*tables.SessionsTable, error)

GetSession retrieves a session from the database.

func (*RDBConfigStore) GetTeam

func (s *RDBConfigStore) GetTeam(ctx context.Context, id string) (*tables.TableTeam, error)

GetTeam retrieves a specific team from the database.

func (*RDBConfigStore) GetTeams

func (s *RDBConfigStore) GetTeams(ctx context.Context, customerID string) ([]tables.TableTeam, error)

GetTeams retrieves all teams from the database.

func (*RDBConfigStore) GetTeamsPaginated

func (s *RDBConfigStore) GetTeamsPaginated(ctx context.Context, params TeamsQueryParams) ([]tables.TableTeam, int64, error)

GetTeamsPaginated retrieves teams with pagination, filtering, and search support.

func (*RDBConfigStore) GetVectorStoreConfig

func (s *RDBConfigStore) GetVectorStoreConfig(ctx context.Context) (*vectorstore.Config, error)

GetVectorStoreConfig retrieves the vector store configuration from the database.

func (*RDBConfigStore) GetVirtualKey

func (s *RDBConfigStore) GetVirtualKey(ctx context.Context, id string) (*tables.TableVirtualKey, error)

GetVirtualKey retrieves a virtual key from the database.

func (*RDBConfigStore) GetVirtualKeyByValue

func (s *RDBConfigStore) GetVirtualKeyByValue(ctx context.Context, value string) (*tables.TableVirtualKey, error)

GetVirtualKeyByValue retrieves a virtual key by its value using hash-based lookup.

func (*RDBConfigStore) GetVirtualKeyMCPConfigs

func (s *RDBConfigStore) GetVirtualKeyMCPConfigs(ctx context.Context, virtualKeyID string) ([]tables.TableVirtualKeyMCPConfig, error)

GetVirtualKeyMCPConfigs retrieves all virtual key MCP configs from the database.

func (*RDBConfigStore) GetVirtualKeyProviderConfigs

func (s *RDBConfigStore) GetVirtualKeyProviderConfigs(ctx context.Context, virtualKeyID string) ([]tables.TableVirtualKeyProviderConfig, error)

GetVirtualKeyProviderConfigs retrieves all virtual key provider configs from the database.

func (*RDBConfigStore) GetVirtualKeys

func (s *RDBConfigStore) GetVirtualKeys(ctx context.Context) ([]tables.TableVirtualKey, error)

GetVirtualKeys retrieves all virtual keys from the database.

func (*RDBConfigStore) GetVirtualKeysPaginated

func (s *RDBConfigStore) GetVirtualKeysPaginated(ctx context.Context, params VirtualKeyQueryParams) ([]tables.TableVirtualKey, int64, error)

GetVirtualKeysPaginated retrieves virtual keys with pagination, filtering, and search support.

func (*RDBConfigStore) Ping

func (s *RDBConfigStore) Ping(ctx context.Context) error

Ping checks if the database is reachable.

func (*RDBConfigStore) ReleaseLock

func (s *RDBConfigStore) ReleaseLock(ctx context.Context, lockKey, holderID string) (bool, error)

ReleaseLock deletes a lock if the holder ID matches. Returns true if the lock was released, false if it wasn't held by the given holder.

func (*RDBConfigStore) RenamePromptSession

func (s *RDBConfigStore) RenamePromptSession(ctx context.Context, id uint, name string) error

RenamePromptSession updates only the name of a session

func (*RDBConfigStore) ReplaceProviderModelNames

func (s *RDBConfigStore) ReplaceProviderModelNames(ctx context.Context, provider schemas.ModelProvider, models []string, tx ...*gorm.DB) error

ReplaceProviderModelNames replaces the persisted model inventory for a provider atomically.

func (*RDBConfigStore) RetryOnNotFound

func (s *RDBConfigStore) RetryOnNotFound(ctx context.Context, fn func(ctx context.Context) (any, error), maxRetries int, retryDelay time.Duration) (any, error)

RetryOnNotFound retries a function up to 3 times with 1-second delays if it returns ErrNotFound

func (*RDBConfigStore) RunMigration

func (s *RDBConfigStore) RunMigration(ctx context.Context, migration *migrator.Migration) error

RunMigration runs a migration.

func (*RDBConfigStore) SetRestartRequiredConfig

func (s *RDBConfigStore) SetRestartRequiredConfig(ctx context.Context, config *tables.RestartRequiredConfig) error

SetRestartRequiredConfig sets the restart required configuration in the database.

func (*RDBConfigStore) TryAcquireLock

func (s *RDBConfigStore) TryAcquireLock(ctx context.Context, lock *tables.TableDistributedLock) (bool, error)

TryAcquireLock attempts to insert a lock row. Returns true if the lock was acquired. Uses INSERT ... ON CONFLICT DO NOTHING for atomic lock acquisition.

func (*RDBConfigStore) UpdateAuthConfig

func (s *RDBConfigStore) UpdateAuthConfig(ctx context.Context, config *AuthConfig) error

UpdateAuthConfig updates the auth configuration in the database.

func (*RDBConfigStore) UpdateBudget

func (s *RDBConfigStore) UpdateBudget(ctx context.Context, budget *tables.TableBudget, tx ...*gorm.DB) error

UpdateBudget updates a budget in the database.

func (*RDBConfigStore) UpdateBudgetUsage

func (s *RDBConfigStore) UpdateBudgetUsage(ctx context.Context, id string, currentUsage float64) error

UpdateBudgetUsage updates only the current_usage field of a budget. Uses SkipHooks to avoid triggering BeforeSave validation since we're only updating usage.

func (*RDBConfigStore) UpdateBudgets

func (s *RDBConfigStore) UpdateBudgets(ctx context.Context, budgets []*tables.TableBudget, tx ...*gorm.DB) error

UpdateBudgets updates multiple budgets in the database.

func (*RDBConfigStore) UpdateClientConfig

func (s *RDBConfigStore) UpdateClientConfig(ctx context.Context, config *ClientConfig) error

UpdateClientConfig updates the client configuration in the database.

func (*RDBConfigStore) UpdateConfig

func (s *RDBConfigStore) UpdateConfig(ctx context.Context, config *tables.TableGovernanceConfig, tx ...*gorm.DB) error

UpdateConfig updates a specific config in the database.

func (*RDBConfigStore) UpdateCustomer

func (s *RDBConfigStore) UpdateCustomer(ctx context.Context, customer *tables.TableCustomer, tx ...*gorm.DB) error

UpdateCustomer updates an existing customer in the database.

func (*RDBConfigStore) UpdateFolder

func (s *RDBConfigStore) UpdateFolder(ctx context.Context, folder *tables.TableFolder) error

UpdateFolder updates a folder

func (*RDBConfigStore) UpdateFrameworkConfig

func (s *RDBConfigStore) UpdateFrameworkConfig(ctx context.Context, config *tables.TableFrameworkConfig) error

UpdateFrameworkConfig updates the framework configuration in the database.

func (*RDBConfigStore) UpdateLockExpiry

func (s *RDBConfigStore) UpdateLockExpiry(ctx context.Context, lockKey, holderID string, expiresAt time.Time) error

UpdateLockExpiry updates the expiration time for an existing lock. Only succeeds if the holder ID matches the current lock holder.

func (*RDBConfigStore) UpdateLogsStoreConfig

func (s *RDBConfigStore) UpdateLogsStoreConfig(ctx context.Context, config *logstore.Config) error

UpdateLogsStoreConfig updates the logs store configuration in the database.

func (*RDBConfigStore) UpdateMCPClientConfig

func (s *RDBConfigStore) UpdateMCPClientConfig(ctx context.Context, id string, clientConfig *tables.TableMCPClient) error

UpdateMCPClientConfig updates an existing MCP client configuration in the database.

func (*RDBConfigStore) UpdateModelConfig

func (s *RDBConfigStore) UpdateModelConfig(ctx context.Context, modelConfig *tables.TableModelConfig, tx ...*gorm.DB) error

UpdateModelConfig updates a model config in the database.

func (*RDBConfigStore) UpdateModelConfigs

func (s *RDBConfigStore) UpdateModelConfigs(ctx context.Context, modelConfigs []*tables.TableModelConfig, tx ...*gorm.DB) error

UpdateModelConfigs updates multiple model configs in the database.

func (*RDBConfigStore) UpdateOauthConfig

func (s *RDBConfigStore) UpdateOauthConfig(ctx context.Context, config *tables.TableOauthConfig) error

UpdateOauthConfig updates an existing OAuth config

func (*RDBConfigStore) UpdateOauthToken

func (s *RDBConfigStore) UpdateOauthToken(ctx context.Context, token *tables.TableOauthToken) error

UpdateOauthToken updates an existing OAuth token

func (*RDBConfigStore) UpdatePlugin

func (s *RDBConfigStore) UpdatePlugin(ctx context.Context, plugin *tables.TablePlugin, tx ...*gorm.DB) error

UpdatePlugin updates an existing plugin in the database.

func (*RDBConfigStore) UpdatePrompt

func (s *RDBConfigStore) UpdatePrompt(ctx context.Context, prompt *tables.TablePrompt) error

UpdatePrompt updates a prompt

func (*RDBConfigStore) UpdatePromptSession

func (s *RDBConfigStore) UpdatePromptSession(ctx context.Context, session *tables.TablePromptSession) error

UpdatePromptSession updates a session and its messages

func (*RDBConfigStore) UpdateProvider

func (s *RDBConfigStore) UpdateProvider(ctx context.Context, provider schemas.ModelProvider, config ProviderConfig, tx ...*gorm.DB) error

UpdateProvider updates a single provider configuration in the database without deleting/recreating.

func (*RDBConfigStore) UpdateProvidersConfig

func (s *RDBConfigStore) UpdateProvidersConfig(ctx context.Context, providers map[schemas.ModelProvider]ProviderConfig, tx ...*gorm.DB) error

UpdateProvidersConfig updates the client configuration in the database.

func (*RDBConfigStore) UpdateProxyConfig

func (s *RDBConfigStore) UpdateProxyConfig(ctx context.Context, config *tables.GlobalProxyConfig) error

UpdateProxyConfig updates the proxy configuration in the database.

func (*RDBConfigStore) UpdateRateLimit

func (s *RDBConfigStore) UpdateRateLimit(ctx context.Context, rateLimit *tables.TableRateLimit, tx ...*gorm.DB) error

UpdateRateLimit updates a rate limit in the database.

func (*RDBConfigStore) UpdateRateLimitUsage

func (s *RDBConfigStore) UpdateRateLimitUsage(ctx context.Context, id string, tokenCurrentUsage int64, requestCurrentUsage int64) error

UpdateRateLimitUsage updates only the usage fields of a rate limit. Uses SkipHooks to avoid triggering BeforeSave validation since we're only updating usage.

func (*RDBConfigStore) UpdateRateLimits

func (s *RDBConfigStore) UpdateRateLimits(ctx context.Context, rateLimits []*tables.TableRateLimit, tx ...*gorm.DB) error

UpdateRateLimits updates multiple rate limits in the database.

func (*RDBConfigStore) UpdateRoutingRule

func (s *RDBConfigStore) UpdateRoutingRule(ctx context.Context, rule *tables.TableRoutingRule, tx ...*gorm.DB) error

UpdateRoutingRule updates an existing routing rule in the database. It enforces the same unique-priority-per-scope invariant as CreateRoutingRule.

func (*RDBConfigStore) UpdateStatus

func (s *RDBConfigStore) UpdateStatus(ctx context.Context, provider schemas.ModelProvider, keyID string, status, description string) error

UpdateStatus updates the status for either a key or provider. - If keyID is non-empty: updates the key's status (for keyed providers) - If keyID is empty and provider is non-empty: updates the provider's status (for keyless providers)

func (*RDBConfigStore) UpdateTeam

func (s *RDBConfigStore) UpdateTeam(ctx context.Context, team *tables.TableTeam, tx ...*gorm.DB) error

UpdateTeam updates an existing team in the database.

func (*RDBConfigStore) UpdateVectorStoreConfig

func (s *RDBConfigStore) UpdateVectorStoreConfig(ctx context.Context, config *vectorstore.Config) error

UpdateVectorStoreConfig updates the vector store configuration in the database.

func (*RDBConfigStore) UpdateVirtualKey

func (s *RDBConfigStore) UpdateVirtualKey(ctx context.Context, virtualKey *tables.TableVirtualKey, tx ...*gorm.DB) error

func (*RDBConfigStore) UpdateVirtualKeyMCPConfig

func (s *RDBConfigStore) UpdateVirtualKeyMCPConfig(ctx context.Context, virtualKeyMCPConfig *tables.TableVirtualKeyMCPConfig, tx ...*gorm.DB) error

UpdateVirtualKeyMCPConfig updates a virtual key provider config in the database.

func (*RDBConfigStore) UpdateVirtualKeyProviderConfig

func (s *RDBConfigStore) UpdateVirtualKeyProviderConfig(ctx context.Context, virtualKeyProviderConfig *tables.TableVirtualKeyProviderConfig, tx ...*gorm.DB) error

UpdateVirtualKeyProviderConfig updates a virtual key provider config in the database.

func (*RDBConfigStore) UpsertModelParameters

func (s *RDBConfigStore) UpsertModelParameters(ctx context.Context, params *tables.TableModelParameters, tx ...*gorm.DB) error

UpsertModelParameters creates or updates model parameters for a specific model.

func (*RDBConfigStore) UpsertModelPrices

func (s *RDBConfigStore) UpsertModelPrices(ctx context.Context, pricing *tables.TableModelPricing, tx ...*gorm.DB) error

UpsertModelPrices creates or updates a model pricing record in the database. Uses a find-then-create-or-update pattern so it works regardless of dialect (SQLite vs PostgreSQL) and constraint naming.

func (*RDBConfigStore) UpsertPlugin

func (s *RDBConfigStore) UpsertPlugin(ctx context.Context, plugin *tables.TablePlugin, tx ...*gorm.DB) error

UpsertPlugin creates a new plugin in the database if it doesn't exist, otherwise updates it.

type RoutingRulesQueryParams

type RoutingRulesQueryParams struct {
	Limit  int
	Offset int
	Search string
}

RoutingRulesQueryParams holds pagination, filtering, and search parameters for routing rules queries.

type SQLiteConfig

type SQLiteConfig struct {
	Path string `json:"path"`
}

SQLiteConfig represents the configuration for a SQLite database.

type TeamsQueryParams

type TeamsQueryParams struct {
	Limit      int
	Offset     int
	Search     string
	CustomerID string
}

TeamsQueryParams holds pagination, filtering, and search parameters for team queries.

type VirtualKeyHashInput

type VirtualKeyHashInput struct {
	Name        string
	Description string
	IsActive    bool
	TeamID      *string
	CustomerID  *string
	BudgetID    *string
	RateLimitID *string
	// ProviderConfigs and MCPConfigs are hashed separately as they contain nested data
	ProviderConfigs []VirtualKeyProviderConfigHashInput
	MCPConfigs      []VirtualKeyMCPConfigHashInput
}

VirtualKeyHashInput represents the fields used for virtual key hash generation. This struct is used to create a consistent hash from TableVirtualKey, excluding dynamic fields like ID, timestamps, and relationship objects.

type VirtualKeyMCPConfigHashInput

type VirtualKeyMCPConfigHashInput struct {
	MCPClientID    uint
	ToolsToExecute []string
}

VirtualKeyMCPConfigHashInput represents MCP config fields for hashing

type VirtualKeyProviderConfigHashInput

type VirtualKeyProviderConfigHashInput struct {
	Provider      string
	Weight        float64
	AllowedModels []string
	BudgetID      *string
	RateLimitID   *string
	KeyIDs        []string // Only key IDs, not full key objects
}

VirtualKeyProviderConfigHashInput represents provider config fields for hashing

type VirtualKeyQueryParams

type VirtualKeyQueryParams struct {
	Limit      int
	Offset     int
	Search     string
	CustomerID string
	TeamID     string
	SortBy     string // name, budget_spent, created_at, status (default: created_at)
	Order      string // asc, desc (default: asc)
	Export     bool   // When true, skip default pagination limits (caller controls limit)
}

VirtualKeyQueryParams holds pagination, filtering, and search parameters for virtual key queries.

Directories

Path Synopsis
Package tables contains the database tables for the configstore.
Package tables contains the database tables for the configstore.

Jump to

Keyboard shortcuts

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