mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
Restructure the provider management system by separating the monolithic Provider model into two distinct entities: - ProviderGroup: defines shared upstream configuration (type, base_url, google settings, models, status) - APIKey: represents individual credentials within a group (api_key, weight, status, auto_ban, ban settings) This change also updates: - Binding model to reference GroupID instead of RouteGroup string - All CRUD handlers for the new provider-group and api-key endpoints - Sync service to rebuild provider snapshots from joined tables - Model registry to aggregate capabilities across group/key pairs - Access handler to validate namespace existence and subset constraints - Migration importer to handle the new schema structure - All related tests to use the new model relationships BREAKING CHANGE: Provider API endpoints replaced with /provider-groups and /api-keys endpoints; Binding.RouteGroup replaced with Binding.GroupID
32 lines
1.2 KiB
Go
32 lines
1.2 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// ProviderGroup represents a shared upstream definition.
|
|
type ProviderGroup struct {
|
|
gorm.Model
|
|
Name string `gorm:"size:255;uniqueIndex;not null" json:"name"`
|
|
Type string `gorm:"size:50;not null" json:"type"` // openai, anthropic, gemini
|
|
BaseURL string `gorm:"size:512;not null" json:"base_url"`
|
|
GoogleProject string `gorm:"size:128" json:"google_project,omitempty"`
|
|
GoogleLocation string `gorm:"size:64" json:"google_location,omitempty"`
|
|
Models string `json:"models"` // comma-separated list of supported models
|
|
Status string `gorm:"size:50;default:'active'" json:"status"`
|
|
}
|
|
|
|
// APIKey represents a credential within a provider group.
|
|
type APIKey struct {
|
|
gorm.Model
|
|
GroupID uint `gorm:"not null;index" json:"group_id"`
|
|
APIKey string `gorm:"not null" json:"api_key"`
|
|
Weight int `gorm:"default:1" json:"weight"`
|
|
Status string `gorm:"size:50;default:'active'" json:"status"`
|
|
AutoBan bool `gorm:"default:true" json:"auto_ban"`
|
|
BanReason string `gorm:"size:255" json:"ban_reason"`
|
|
BanUntil *time.Time `json:"ban_until"`
|
|
}
|