mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
refactor(api): split Provider into ProviderGroup and APIKey models
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
This commit is contained in:
14
internal/dto/api_key.go
Normal file
14
internal/dto/api_key.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package dto
|
||||
|
||||
import "time"
|
||||
|
||||
// APIKeyDTO defines inbound payload for API key creation/update.
|
||||
type APIKeyDTO struct {
|
||||
GroupID uint `json:"group_id"`
|
||||
APIKey string `json:"api_key"`
|
||||
Weight int `json:"weight,omitempty"`
|
||||
Status string `json:"status"`
|
||||
AutoBan *bool `json:"auto_ban,omitempty"`
|
||||
BanReason string `json:"ban_reason,omitempty"`
|
||||
BanUntil time.Time `json:"ban_until,omitempty"`
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
package dto
|
||||
|
||||
// BindingDTO defines inbound payload for binding creation/update.
|
||||
// It maps "(namespace, public_model)" to a RouteGroup and an upstream selector.
|
||||
// It maps "(namespace, public_model)" to a ProviderGroup and an upstream selector.
|
||||
type BindingDTO struct {
|
||||
Namespace string `json:"namespace"`
|
||||
PublicModel string `json:"public_model"`
|
||||
RouteGroup string `json:"route_group"`
|
||||
GroupID uint `json:"group_id"`
|
||||
Weight int `json:"weight"`
|
||||
SelectorType string `json:"selector_type"`
|
||||
SelectorValue string `json:"selector_value"`
|
||||
Status string `json:"status"`
|
||||
|
||||
12
internal/dto/provider_group.go
Normal file
12
internal/dto/provider_group.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package dto
|
||||
|
||||
// ProviderGroupDTO defines inbound payload for provider group creation/update.
|
||||
type ProviderGroupDTO struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
BaseURL string `json:"base_url"`
|
||||
GoogleProject string `json:"google_project,omitempty"`
|
||||
GoogleLocation string `json:"google_location,omitempty"`
|
||||
Models []string `json:"models"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
Reference in New Issue
Block a user