Documentation
¶
Overview ¶
Package admin provides the admin REST API and dashboard for GoModel.
Index ¶
- Constants
- type DashboardConfigResponse
- type Handler
- func (h *Handler) AuditConversation(c *echo.Context) error
- func (h *Handler) AuditLog(c *echo.Context) error
- func (h *Handler) AuditLogDetail(c *echo.Context) error
- func (h *Handler) AuditStats(c *echo.Context) error
- func (h *Handler) BudgetSettings(c *echo.Context) error
- func (h *Handler) CacheOverview(c *echo.Context) error
- func (h *Handler) CreateAuthKey(c *echo.Context) error
- func (h *Handler) CreateWorkflow(c *echo.Context) error
- func (h *Handler) DailyUsage(c *echo.Context) error
- func (h *Handler) DashboardConfig(c *echo.Context) error
- func (h *Handler) DeactivateAuthKey(c *echo.Context) error
- func (h *Handler) DeactivateWorkflow(c *echo.Context) error
- func (h *Handler) DeleteBudget(c *echo.Context) error
- func (h *Handler) DeleteFailoverRule(c *echo.Context) error
- func (h *Handler) DeleteGuardrail(c *echo.Context) error
- func (h *Handler) DeleteMCPServer(c *echo.Context) error
- func (h *Handler) DeleteModelPricingOverride(c *echo.Context) error
- func (h *Handler) DeleteProviderCredential(c *echo.Context) error
- func (h *Handler) DeleteRateLimit(c *echo.Context) error
- func (h *Handler) DeleteVirtualModel(c *echo.Context) error
- func (h *Handler) GenerateFailoverRules(c *echo.Context) error
- func (h *Handler) GetWorkflow(c *echo.Context) error
- func (h *Handler) ListAuthKeys(c *echo.Context) error
- func (h *Handler) ListBudgets(c *echo.Context) error
- func (h *Handler) ListCategories(c *echo.Context) error
- func (h *Handler) ListFailoverRules(c *echo.Context) error
- func (h *Handler) ListGuardrailTypes(c *echo.Context) error
- func (h *Handler) ListGuardrails(c *echo.Context) error
- func (h *Handler) ListMCPServers(c *echo.Context) error
- func (h *Handler) ListModelPricingOverrides(c *echo.Context) error
- func (h *Handler) ListModels(c *echo.Context) error
- func (h *Handler) ListProviderCredentials(c *echo.Context) error
- func (h *Handler) ListRateLimits(c *echo.Context) error
- func (h *Handler) ListVirtualModels(c *echo.Context) error
- func (h *Handler) ListWorkflowGuardrails(c *echo.Context) error
- func (h *Handler) ListWorkflows(c *echo.Context) error
- func (h *Handler) LiveLogs(c *echo.Context) error
- func (h *Handler) MCPServerCatalog(c *echo.Context) error
- func (h *Handler) ProviderCredentialTypes(c *echo.Context) error
- func (h *Handler) ProviderStatus(c *echo.Context) error
- func (h *Handler) RecalculateUsagePricing(c *echo.Context) error
- func (h *Handler) ReconnectMCPServer(c *echo.Context) error
- func (h *Handler) RefreshRuntime(c *echo.Context) error
- func (h *Handler) RegisterRoutes(g RouteRegistrar)
- func (h *Handler) ResetBudget(c *echo.Context) error
- func (h *Handler) ResetBudgets(c *echo.Context) error
- func (h *Handler) ResetFailoverRules(c *echo.Context) error
- func (h *Handler) ResetRateLimit(c *echo.Context) error
- func (h *Handler) ResetRateLimits(c *echo.Context) error
- func (h *Handler) TaggingSettings(c *echo.Context) error
- func (h *Handler) TokenThroughput(c *echo.Context) error
- func (h *Handler) UpdateAuthKeyLabels(c *echo.Context) error
- func (h *Handler) UpdateBudgetSettings(c *echo.Context) error
- func (h *Handler) UpdateTaggingSettings(c *echo.Context) error
- func (h *Handler) UpsertBudget(c *echo.Context) error
- func (h *Handler) UpsertFailoverRule(c *echo.Context) error
- func (h *Handler) UpsertGuardrail(c *echo.Context) error
- func (h *Handler) UpsertMCPServer(c *echo.Context) error
- func (h *Handler) UpsertModelPricingOverride(c *echo.Context) error
- func (h *Handler) UpsertProviderCredential(c *echo.Context) error
- func (h *Handler) UpsertRateLimit(c *echo.Context) error
- func (h *Handler) UpsertVirtualModel(c *echo.Context) error
- func (h *Handler) UsageByLabel(c *echo.Context) error
- func (h *Handler) UsageByModel(c *echo.Context) error
- func (h *Handler) UsageByUserPath(c *echo.Context) error
- func (h *Handler) UsageLog(c *echo.Context) error
- func (h *Handler) UsageSummary(c *echo.Context) error
- type MCPServerAdmin
- type Option
- func WithAuditReader(reader auditlog.Reader) Option
- func WithAuthKeys(service *authkeys.Service) Option
- func WithBudgets(service *budget.Service) Option
- func WithConfiguredProviders(configs []providers.SanitizedProviderConfig) Option
- func WithDashboardRuntimeConfig(values DashboardConfigResponse) Option
- func WithFailover(service *failover.Service) Option
- func WithGuardrailService(service *guardrails.Service) Option
- func WithLiveBroker(broker *live.Broker) Option
- func WithMCPServers(service MCPServerAdmin) Option
- func WithPricingOverrides(service *pricingoverrides.Service) Option
- func WithPricingResolver(resolver usage.PricingResolver) Option
- func WithProviderCredentials(service ProviderCredentialsAdmin) Option
- func WithRateLimits(service *ratelimit.Service) Option
- func WithRequestHealth(source RequestHealthSource) Option
- func WithRuntimeRefresher(refresher RuntimeRefresher) Option
- func WithTagging(service *tagging.Service) Option
- func WithUsagePricingRecalculator(recalculator usage.PricingRecalculator) Option
- func WithVirtualModels(service *virtualmodels.Service) Option
- func WithWorkflows(service *workflows.Service) Option
- type ProviderCredentialsAdmin
- type RequestHealthSource
- type RouteRegistrar
- type RuntimeRefreshReport
- type RuntimeRefreshStep
- type RuntimeRefresher
Constants ¶
const ( DashboardConfigDemoMode = "DEMO_MODE" DashboardConfigFailoverEnabled = "FAILOVER_ENABLED" DashboardConfigLoggingEnabled = "LOGGING_ENABLED" DashboardConfigLoggingRetentionDays = "LOGGING_RETENTION_DAYS" DashboardConfigUsageEnabled = "USAGE_ENABLED" DashboardConfigBudgetsEnabled = "BUDGETS_ENABLED" DashboardConfigRateLimitsEnabled = "RATE_LIMITS_ENABLED" DashboardConfigGuardrailsEnabled = "GUARDRAILS_ENABLED" DashboardConfigCacheEnabled = "CACHE_ENABLED" DashboardConfigRedisURL = "REDIS_URL" DashboardConfigSemanticCacheEnabled = "SEMANTIC_CACHE_ENABLED" DashboardConfigPricingRecalculation = "USAGE_PRICING_RECALCULATION_ENABLED" DashboardConfigLiveLogsEnabled = "DASHBOARD_LIVE_LOGS_ENABLED" )
const ( RuntimeRefreshStatusOK = "ok" RuntimeRefreshStatusPartial = "partial" RuntimeRefreshStatusFailed = "failed" RuntimeRefreshStatusSkipped = "skipped" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DashboardConfigResponse ¶
type DashboardConfigResponse struct {
DemoMode string `json:"DEMO_MODE,omitempty"`
FailoverEnabled string `json:"FAILOVER_ENABLED,omitempty"`
LoggingEnabled string `json:"LOGGING_ENABLED,omitempty"`
LoggingRetentionDays string `json:"LOGGING_RETENTION_DAYS,omitempty"`
UsageEnabled string `json:"USAGE_ENABLED,omitempty"`
BudgetsEnabled string `json:"BUDGETS_ENABLED,omitempty"`
RateLimitsEnabled string `json:"RATE_LIMITS_ENABLED,omitempty"`
GuardrailsEnabled string `json:"GUARDRAILS_ENABLED,omitempty"`
CacheEnabled string `json:"CACHE_ENABLED,omitempty"`
RedisURL string `json:"REDIS_URL,omitempty"`
SemanticCacheEnabled string `json:"SEMANTIC_CACHE_ENABLED,omitempty"`
PricingRecalculation string `json:"USAGE_PRICING_RECALCULATION_ENABLED,omitempty"`
LiveLogsEnabled string `json:"DASHBOARD_LIVE_LOGS_ENABLED,omitempty"`
}
DashboardConfigResponse is the allowlisted runtime config contract exposed to the dashboard UI.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves admin API endpoints.
func NewHandler ¶
func NewHandler(reader usage.UsageReader, registry *providers.ModelRegistry, options ...Option) *Handler
NewHandler creates a new admin API handler. usageReader may be nil if usage tracking is not available.
func (*Handler) AuditConversation ¶
AuditConversation handles GET /admin/audit/conversation
@Summary Get conversation thread around an audit log entry @Tags admin @Produce json @Security BearerAuth @Param log_id query string true "Anchor audit log entry ID" @Param limit query int false "Max entries in thread (default 40, max 200)" @Success 200 {object} auditlog.ConversationResult @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Router /admin/audit/conversation [get]
func (*Handler) AuditLog ¶
AuditLog handles GET /admin/audit/log
@Summary Get paginated audit log entries @Tags admin @Produce json @Security BearerAuth @Param days query int false "Number of days (default 30)" @Param start_date query string false "Start date (YYYY-MM-DD)" @Param end_date query string false "End date (YYYY-MM-DD)" @Param requested_model query string false "Filter by requested model selector" @Param provider query string false "Filter by provider name or provider type" @Param method query string false "Filter by HTTP method" @Param path query string false "Filter by request path" @Param user_path query string false "Filter by tracked user path subtree" @Param error_type query string false "Filter by error type" @Param status_code query int false "Filter by status code" @Param stream query bool false "Filter by stream mode (true/false)" @Param search query string false "Search across request_id/requested_model/provider/method/path/error_type/error_message" @Param limit query int false "Page size (default 25, max 100)" @Param offset query int false "Offset for pagination" @Success 200 {object} auditLogListResponse @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Router /admin/audit/log [get]
func (*Handler) AuditLogDetail ¶
AuditLogDetail handles GET /admin/audit/detail.
@Summary Get audit log entry detail @Description Returns one audit log entry enriched with usage summary when available. @Tags admin @Produce json @Security BearerAuth @Param log_id query string true "Audit log entry ID" @Success 200 {object} auditLogEntryResponse @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 404 {object} core.GatewayError @Failure 500 {object} core.GatewayError @Router /admin/audit/detail [get]
func (*Handler) AuditStats ¶
AuditStats handles GET /admin/audit/stats
@Summary Get time-bucketed request status and latency stats @Description Returns request counts grouped into 2xx/4xx/5xx status classes @Description per time bucket, an overall success-rate summary, and average @Description request duration per provider for the dashboard charts. @Description Ranges up to 3 days use hourly buckets, longer ranges daily. @Tags admin @Produce json @Security BearerAuth @Param days query int false "Number of days (default 30)" @Param start_date query string false "Start date (YYYY-MM-DD)" @Param end_date query string false "End date (YYYY-MM-DD)" @Success 200 {object} auditlog.RequestStats @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Router /admin/audit/stats [get]
func (*Handler) BudgetSettings ¶
BudgetSettings handles GET /admin/budgets/settings. @Summary Get budget reset settings @Tags admin @Produce json @Security BearerAuth @Success 200 {object} budget.Settings @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/budgets/settings [get]
func (*Handler) CacheOverview ¶
CacheOverview handles GET /admin/cache/overview
@Summary Get cached-only usage overview @Tags admin @Produce json @Security BearerAuth @Param days query int false "Number of days (default 30)" @Param start_date query string false "Start date (YYYY-MM-DD)" @Param end_date query string false "End date (YYYY-MM-DD)" @Param interval query string false "Grouping interval: daily, weekly, monthly, yearly (default daily)" @Param model query string false "Filter by exact model name" @Param provider query string false "Filter by provider name or provider type" @Param label query string false "Filter by request label (exact match)" @Param user_path query string false "Filter by tracked user path subtree" @Param cache_mode query string false "Cache mode filter: uncached, cached, all (cache overview always uses cached mode)" @Success 200 {object} usage.CacheOverview @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/cache/overview [get]
func (*Handler) CreateAuthKey ¶
CreateAuthKey handles POST /admin/auth-keys
func (*Handler) CreateWorkflow ¶
CreateWorkflow handles POST /admin/workflows
func (*Handler) DailyUsage ¶
DailyUsage handles GET /admin/usage/daily
@Summary Get usage breakdown by period @Tags admin @Produce json @Security BearerAuth @Param days query int false "Number of days (default 30)" @Param start_date query string false "Start date (YYYY-MM-DD)" @Param end_date query string false "End date (YYYY-MM-DD)" @Param interval query string false "Grouping interval: daily, weekly, monthly, yearly (default daily)" @Param model query string false "Filter by exact model name" @Param provider query string false "Filter by provider name or provider type" @Param label query string false "Filter by request label (exact match)" @Param user_path query string false "Filter by tracked user path subtree" @Param cache_mode query string false "Cache mode filter: uncached, cached, all (default uncached)" @Success 200 {array} usage.DailyUsage @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Router /admin/usage/daily [get]
func (*Handler) DashboardConfig ¶
DashboardConfig handles GET /admin/runtime/config
@Summary Get admin runtime configuration @Tags admin @Produce json @Security BearerAuth @Success 200 {object} DashboardConfigResponse @Failure 401 {object} core.GatewayError @Router /admin/runtime/config [get]
func (*Handler) DeactivateAuthKey ¶
DeactivateAuthKey handles POST /admin/auth-keys/:id/deactivate
func (*Handler) DeactivateWorkflow ¶
DeactivateWorkflow handles POST /admin/workflows/:id/deactivate
func (*Handler) DeleteBudget ¶
DeleteBudget handles DELETE /admin/budgets. @Summary Delete one budget @Tags admin @Accept json @Produce json @Security BearerAuth @Param budget body deleteBudgetRequest true "Budget key" @Success 200 {object} budgetListResponse @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/budgets [delete]
func (*Handler) DeleteFailoverRule ¶
DeleteFailoverRule handles DELETE /admin/failover.
@Summary Delete one failover mapping @Tags admin @Accept json @Produce json @Security BearerAuth @Param request body deleteFailoverRuleRequest true "Failover primary model to remove" @Success 204 "No Content" @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 404 {object} core.GatewayError @Failure 502 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/failover [delete]
func (*Handler) DeleteGuardrail ¶
DeleteGuardrail handles DELETE /admin/guardrails
func (*Handler) DeleteMCPServer ¶
DeleteMCPServer handles DELETE /admin/mcp-servers/:name.
@Summary Delete one admin-managed MCP server @Tags admin @Produce json @Security BearerAuth @Param name path string true "MCP server slug" @Success 204 "No Content" @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 404 {object} core.GatewayError @Failure 502 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/mcp-servers/{name} [delete]
func (*Handler) DeleteModelPricingOverride ¶
DeleteModelPricingOverride handles DELETE /admin/model-pricing-overrides.
@Summary Delete one model pricing override @Tags admin @Accept json @Produce json @Security BearerAuth @Param request body deleteModelPricingOverrideRequest true "Pricing selector to remove" @Success 204 "No Content" @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 404 {object} core.GatewayError @Failure 502 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/model-pricing-overrides [delete]
func (*Handler) DeleteProviderCredential ¶ added in v0.1.56
DeleteProviderCredential handles DELETE /admin/provider-credentials/:name.
@Summary Delete one admin-managed provider credential @Tags admin @Produce json @Security BearerAuth @Param name path string true "Provider name" @Success 204 "No Content" @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 404 {object} core.GatewayError @Failure 502 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/provider-credentials/{name} [delete]
func (*Handler) DeleteRateLimit ¶
DeleteRateLimit handles DELETE /admin/rate-limits. @Summary Delete one rate limit rule @Tags admin @Accept json @Produce json @Security BearerAuth @Param rule body deleteRateLimitRequest true "Rate limit key" @Success 200 {object} rateLimitListResponse @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/rate-limits [delete]
func (*Handler) DeleteVirtualModel ¶
DeleteVirtualModel handles DELETE /admin/virtual-models.
@Summary Delete one virtual model @Tags admin @Accept json @Produce json @Security BearerAuth @Param request body deleteVirtualModelRequest true "Virtual model source to remove" @Success 204 "No Content" @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 404 {object} core.GatewayError @Failure 502 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/virtual-models [delete]
func (*Handler) GenerateFailoverRules ¶
GenerateFailoverRules handles POST /admin/failover/generate.
@Summary Generate failover mapping suggestions @Tags admin @Accept json @Produce json @Security BearerAuth @Param request body generateFailoverRulesRequest false "Optional source model filter" @Success 200 {array} failover.View @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/failover/generate [post]
func (*Handler) GetWorkflow ¶
GetWorkflow handles GET /admin/workflows/:id
func (*Handler) ListBudgets ¶
ListBudgets handles GET /admin/budgets.
@Summary List budgets with current status @Tags admin @Produce json @Security BearerAuth @Success 200 {object} budgetListResponse @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/budgets [get]
func (*Handler) ListCategories ¶
ListCategories handles GET /admin/models/categories
@Summary List model categories with counts @Tags admin @Produce json @Security BearerAuth @Success 200 {array} providers.CategoryCount @Failure 401 {object} core.GatewayError @Router /admin/models/categories [get]
func (*Handler) ListFailoverRules ¶
ListFailoverRules handles GET /admin/failover.
@Summary List failover mappings @Tags admin @Produce json @Security BearerAuth @Success 200 {array} failover.View @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/failover [get]
func (*Handler) ListGuardrails ¶
ListGuardrails handles GET /admin/guardrails
func (*Handler) ListMCPServers ¶
ListMCPServers handles GET /admin/mcp-servers.
@Summary List MCP servers (config-declared and admin-managed) @Tags admin @Produce json @Security BearerAuth @Success 200 {array} mcpServerViewResponse @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/mcp-servers [get]
func (*Handler) ListModelPricingOverrides ¶
ListModelPricingOverrides handles GET /admin/model-pricing-overrides.
@Summary List model pricing overrides @Description Lists persisted USD pricing overrides. Selectors support global "/", provider-wide "provider/", model-wide "model", and exact "provider/model" scopes. @Tags admin @Produce json @Security BearerAuth @Success 200 {array} pricingoverrides.View @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/model-pricing-overrides [get]
func (*Handler) ListModels ¶
ListModels handles GET /admin/models Supports optional ?category= query param for filtering by model category.
@Summary List all registered models with provider info and access state @Tags admin @Produce json @Security BearerAuth @Param category query string false "Filter by model category" @Success 200 {array} modelInventoryResponse @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Router /admin/models [get]
func (*Handler) ListProviderCredentials ¶ added in v0.1.56
ListProviderCredentials handles GET /admin/provider-credentials.
@Summary List admin-managed model provider credentials @Tags admin @Produce json @Security BearerAuth @Success 200 {array} providerCredentialViewResponse @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/provider-credentials [get]
func (*Handler) ListRateLimits ¶
ListRateLimits handles GET /admin/rate-limits.
@Summary List rate limit rules with live counter status @Tags admin @Produce json @Security BearerAuth @Success 200 {object} rateLimitListResponse @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/rate-limits [get]
func (*Handler) ListVirtualModels ¶
ListVirtualModels handles GET /admin/virtual-models.
@Summary List virtual models (redirects and access policies) @Tags admin @Produce json @Security BearerAuth @Success 200 {array} virtualmodels.View @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/virtual-models [get]
func (*Handler) ListWorkflowGuardrails ¶
ListWorkflowGuardrails handles GET /admin/workflows/guardrails
func (*Handler) MCPServerCatalog ¶
MCPServerCatalog handles GET /admin/mcp-servers/:name/catalog.
@Summary Inspect one MCP server's current catalog @Description Lists the tools, prompts, resources, and resource templates the named server currently exposes through the gateway, after operator tool filters. Names are the upstream originals; the aggregated /mcp endpoint prefixes them with the server slug. @Tags admin @Produce json @Security BearerAuth @Param name path string true "MCP server slug" @Success 200 {object} mcpgateway.CatalogView @Failure 401 {object} core.GatewayError @Failure 404 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/mcp-servers/{name}/catalog [get]
func (*Handler) ProviderCredentialTypes ¶ added in v0.1.56
ProviderCredentialTypes handles GET /admin/provider-credentials/types.
@Summary List provider types the gateway can construct @Tags admin @Produce json @Security BearerAuth @Success 200 {array} string @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/provider-credentials/types [get]
func (*Handler) RecalculateUsagePricing ¶
RecalculateUsagePricing handles POST /admin/usage/recalculate-pricing.
@Summary Recalculate stored usage costs from current model pricing metadata @Tags admin @Accept json @Produce json @Security BearerAuth @Param request body recalculatePricingRequest true "Recalculation filters and confirmation" @Success 200 {object} usage.RecalculatePricingResult @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 500 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/usage/recalculate-pricing [post]
func (*Handler) ReconnectMCPServer ¶
ReconnectMCPServer handles POST /admin/mcp-servers/:name/reconnect. The action succeeds even when the upstream stays down: the refreshed view then carries the degraded status and last_error. Only an unknown name is a 404.
@Summary Force-redial one MCP server and return its fresh state @Tags admin @Produce json @Security BearerAuth @Param name path string true "MCP server slug" @Success 200 {object} mcpServerViewResponse @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 404 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/mcp-servers/{name}/reconnect [post]
func (*Handler) RefreshRuntime ¶
RefreshRuntime handles POST /admin/runtime/refresh
func (*Handler) RegisterRoutes ¶
func (h *Handler) RegisterRoutes(g RouteRegistrar)
RegisterRoutes mounts the admin REST API on the given route group. Callers typically pass an *echo.Group rooted at /admin.
func (*Handler) ResetBudget ¶
ResetBudget handles POST /admin/budgets/reset-one. @Summary Reset one budget period @Tags admin @Accept json @Produce json @Security BearerAuth @Param budget body resetBudgetRequest true "Budget key" @Success 200 {object} budgetListResponse @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/budgets/reset-one [post]
func (*Handler) ResetBudgets ¶
ResetBudgets handles POST /admin/budgets/reset. @Summary Reset all budget periods @Tags admin @Accept json @Produce json @Security BearerAuth @Param confirmation body resetBudgetsRequest true "Reset confirmation" @Success 200 {object} resetBudgetsResponse @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/budgets/reset [post]
func (*Handler) ResetFailoverRules ¶
ResetFailoverRules handles POST /admin/failover/reset.
@Summary Reset dashboard-managed failover mappings @Tags admin @Produce json @Security BearerAuth @Success 200 {array} failover.View @Failure 401 {object} core.GatewayError @Failure 502 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/failover/reset [post]
func (*Handler) ResetRateLimit ¶
ResetRateLimit handles POST /admin/rate-limits/reset-one. @Summary Reset the live counters of one rate limit rule @Tags admin @Accept json @Produce json @Security BearerAuth @Param rule body resetRateLimitRequest true "Rate limit key" @Success 200 {object} rateLimitListResponse @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/rate-limits/reset-one [post]
func (*Handler) ResetRateLimits ¶
ResetRateLimits handles POST /admin/rate-limits/reset. @Summary Reset the live counters of all rate limit rules @Tags admin @Accept json @Produce json @Security BearerAuth @Param confirmation body resetRateLimitsRequest true "Reset confirmation" @Success 200 {object} resetRateLimitsResponse @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/rate-limits/reset [post]
func (*Handler) TaggingSettings ¶
TaggingSettings handles GET /admin/tagging/settings. @Summary Get header tagging rules @Tags admin @Produce json @Security BearerAuth @Success 200 {object} taggingSettingsResponse @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/tagging/settings [get]
func (*Handler) TokenThroughput ¶
TokenThroughput handles GET /admin/usage/throughput.
@Summary Get the live token-throughput window @Description Returns a fixed, trailing window of token-volume buckets @Description (input / output / prompt-cached / locally-cached) at the @Description requested granularity, for the overview live chart. @Tags admin @Produce json @Security BearerAuth @Param granularity query string true "Bucket granularity: second, minute, hour, day" @Success 200 {object} usage.TokenThroughput @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Router /admin/usage/throughput [get]
func (*Handler) UpdateAuthKeyLabels ¶
UpdateAuthKeyLabels handles PUT /admin/auth-keys/:id/labels. The request labels replace the key's labels; an empty list clears them.
func (*Handler) UpdateBudgetSettings ¶
UpdateBudgetSettings handles PUT /admin/budgets/settings. @Summary Update budget reset settings @Tags admin @Accept json @Produce json @Security BearerAuth @Param settings body updateBudgetSettingsRequest true "Budget reset settings" @Success 200 {object} budget.Settings @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/budgets/settings [put]
func (*Handler) UpdateTaggingSettings ¶
UpdateTaggingSettings handles PUT /admin/tagging/settings. The request replaces the operator-managed rule set; config/env-declared rules are read-only and rejected. @Summary Replace operator header tagging rules @Tags admin @Accept json @Produce json @Security BearerAuth @Param settings body updateTaggingSettingsRequest true "Operator tagging rules" @Success 200 {object} taggingSettingsResponse @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/tagging/settings [put]
func (*Handler) UpsertBudget ¶
UpsertBudget handles PUT /admin/budgets. @Summary Create or update one budget @Tags admin @Accept json @Produce json @Security BearerAuth @Param budget body upsertBudgetRequest true "Budget key and amount" @Success 200 {object} budgetListResponse @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/budgets [put]
func (*Handler) UpsertFailoverRule ¶
UpsertFailoverRule handles PUT /admin/failover.
@Summary Create or update one failover mapping @Tags admin @Accept json @Produce json @Security BearerAuth @Param mapping body upsertFailoverRuleRequest true "Failover mapping" @Success 200 {object} failover.View @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 502 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/failover [put]
func (*Handler) UpsertGuardrail ¶
UpsertGuardrail handles PUT /admin/guardrails
func (*Handler) UpsertMCPServer ¶
UpsertMCPServer handles PUT /admin/mcp-servers.
@Summary Create or update one admin-managed MCP server @Tags admin @Accept json @Produce json @Security BearerAuth @Param mcp_server body upsertMCPServerRequest true "MCP server definition" @Success 200 {object} mcpServerViewResponse @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 502 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/mcp-servers [put]
func (*Handler) UpsertModelPricingOverride ¶
UpsertModelPricingOverride handles PUT /admin/model-pricing-overrides.
@Summary Create or update one model pricing override @Description Stores USD-only pricing for one selector. More precise selectors override broader selectors at runtime. @Tags admin @Accept json @Produce json @Security BearerAuth @Param override body upsertModelPricingOverrideRequest true "Pricing selector and override" @Success 200 {object} pricingoverrides.View @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 500 {object} core.GatewayError @Failure 502 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/model-pricing-overrides [put]
func (*Handler) UpsertProviderCredential ¶ added in v0.1.56
UpsertProviderCredential handles PUT /admin/provider-credentials.
@Summary Create or update one admin-managed provider credential @Description Registers (or re-registers) the provider into the running gateway immediately, without a restart. @Tags admin @Accept json @Produce json @Security BearerAuth @Param provider body upsertProviderCredentialRequest true "Provider credential definition" @Success 200 {object} providerCredentialViewResponse @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 502 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/provider-credentials [put]
func (*Handler) UpsertRateLimit ¶
UpsertRateLimit handles PUT /admin/rate-limits. @Summary Create or update one rate limit rule @Tags admin @Accept json @Produce json @Security BearerAuth @Param rule body upsertRateLimitRequest true "Rate limit key and limits" @Success 200 {object} rateLimitListResponse @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/rate-limits [put]
func (*Handler) UpsertVirtualModel ¶
UpsertVirtualModel handles PUT /admin/virtual-models. When old_source is set and differs from source, the row is renamed: stored under the new source and removed from the old one in a single validated operation.
@Summary Create, update, or rename one virtual model @Tags admin @Accept json @Produce json @Security BearerAuth @Param virtual_model body upsertVirtualModelRequest true "Virtual model definition" @Success 200 {object} virtualmodels.View @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Failure 502 {object} core.GatewayError @Failure 503 {object} core.GatewayError @Router /admin/virtual-models [put]
func (*Handler) UsageByLabel ¶
UsageByLabel handles GET /admin/usage/labels
@Summary Get usage breakdown by request label @Description Returns per-label token and cost aggregates. Requests carrying @Description several labels count once per label, so rows overlap and do @Description not sum to the period totals. Unlabelled requests are omitted. @Tags admin @Produce json @Security BearerAuth @Param days query int false "Number of days (default 30)" @Param start_date query string false "Start date (YYYY-MM-DD)" @Param end_date query string false "End date (YYYY-MM-DD)" @Param model query string false "Filter by exact model name" @Param provider query string false "Filter by provider name or provider type" @Param label query string false "Filter by request label (exact match)" @Param user_path query string false "Filter by tracked user path subtree" @Param cache_mode query string false "Cache mode filter: uncached, cached, all (default uncached)" @Success 200 {array} usage.LabelUsage @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Router /admin/usage/labels [get]
func (*Handler) UsageByModel ¶
UsageByModel handles GET /admin/usage/models
@Summary Get usage breakdown by model @Tags admin @Produce json @Security BearerAuth @Param days query int false "Number of days (default 30)" @Param start_date query string false "Start date (YYYY-MM-DD)" @Param end_date query string false "End date (YYYY-MM-DD)" @Param model query string false "Filter by exact model name" @Param provider query string false "Filter by provider name or provider type" @Param label query string false "Filter by request label (exact match)" @Param user_path query string false "Filter by tracked user path subtree" @Param cache_mode query string false "Cache mode filter: uncached, cached, all (default uncached)" @Success 200 {array} usage.ModelUsage @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Router /admin/usage/models [get]
func (*Handler) UsageByUserPath ¶
UsageByUserPath handles GET /admin/usage/user-paths
@Summary Get usage breakdown by user path @Tags admin @Produce json @Security BearerAuth @Param days query int false "Number of days (default 30)" @Param start_date query string false "Start date (YYYY-MM-DD)" @Param end_date query string false "End date (YYYY-MM-DD)" @Param model query string false "Filter by exact model name" @Param provider query string false "Filter by provider name or provider type" @Param label query string false "Filter by request label (exact match)" @Param user_path query string false "Filter by tracked user path subtree" @Param cache_mode query string false "Cache mode filter: uncached, cached, all (default uncached)" @Success 200 {array} usage.UserPathUsage @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Router /admin/usage/user-paths [get]
func (*Handler) UsageLog ¶
UsageLog handles GET /admin/usage/log
@Summary Get paginated usage log entries @Tags admin @Produce json @Security BearerAuth @Param days query int false "Number of days (default 30)" @Param start_date query string false "Start date (YYYY-MM-DD)" @Param end_date query string false "End date (YYYY-MM-DD)" @Param model query string false "Filter by exact model name" @Param provider query string false "Filter by provider name or provider type" @Param label query string false "Filter by request label (exact match)" @Param user_path query string false "Filter by tracked user path subtree" @Param cache_mode query string false "Cache mode filter: uncached, cached, all (default uncached)" @Param search query string false "Search across model, provider, request_id, provider_id" @Param limit query int false "Page size (default 50, max 200)" @Param offset query int false "Offset for pagination" @Success 200 {object} usage.UsageLogResult @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Router /admin/usage/log [get]
func (*Handler) UsageSummary ¶
UsageSummary handles GET /admin/usage/summary
@Summary Get usage summary @Tags admin @Produce json @Security BearerAuth @Param days query int false "Number of days (default 30)" @Param start_date query string false "Start date (YYYY-MM-DD)" @Param end_date query string false "End date (YYYY-MM-DD)" @Param model query string false "Filter by exact model name" @Param provider query string false "Filter by provider name or provider type" @Param label query string false "Filter by request label (exact match)" @Param user_path query string false "Filter by tracked user path subtree" @Param cache_mode query string false "Cache mode filter: uncached, cached, all (default uncached)" @Success 200 {object} usage.UsageSummary @Failure 400 {object} core.GatewayError @Failure 401 {object} core.GatewayError @Router /admin/usage/summary [get]
type MCPServerAdmin ¶
type MCPServerAdmin interface {
Views() []mcpgateway.ServerView
IsManaged(name string) bool
GetManaged(ctx context.Context, name string) (*mcpgateway.ManagedServer, error)
Upsert(ctx context.Context, server mcpgateway.ManagedServer) error
Delete(ctx context.Context, name string) error
Reconnect(ctx context.Context, name string) (mcpgateway.ServerView, error)
Catalog(name string) (mcpgateway.CatalogView, bool)
}
MCPServerAdmin is the narrow surface of *mcpgateway.Service the admin API needs, kept as an interface so handler tests can stub the gateway without dialing upstream servers.
type Option ¶
type Option func(*Handler)
Option configures the admin API handler.
func WithAuditReader ¶
WithAuditReader enables audit log read endpoints.
func WithAuthKeys ¶
WithAuthKeys enables managed auth key administration endpoints.
func WithBudgets ¶
WithBudgets enables budget administration endpoints.
func WithConfiguredProviders ¶
func WithConfiguredProviders(configs []providers.SanitizedProviderConfig) Option
WithConfiguredProviders enables the admin-safe provider inventory endpoint.
func WithDashboardRuntimeConfig ¶
func WithDashboardRuntimeConfig(values DashboardConfigResponse) Option
WithDashboardRuntimeConfig enables the allowlisted dashboard runtime config endpoint.
func WithFailover ¶
WithFailover enables failover rule administration endpoints.
func WithGuardrailService ¶
func WithGuardrailService(service *guardrails.Service) Option
WithGuardrailService enables full guardrail definition administration endpoints.
func WithLiveBroker ¶
WithLiveBroker enables realtime dashboard log previews.
func WithMCPServers ¶
func WithMCPServers(service MCPServerAdmin) Option
WithMCPServers enables MCP server administration endpoints. Callers must not wrap a nil *mcpgateway.Service (a typed nil would defeat the handlers' feature-unavailable check).
func WithPricingOverrides ¶
func WithPricingOverrides(service *pricingoverrides.Service) Option
WithPricingOverrides enables model pricing override administration endpoints.
func WithPricingResolver ¶
func WithPricingResolver(resolver usage.PricingResolver) Option
WithPricingResolver sets the resolver used for usage pricing recalculation.
func WithProviderCredentials ¶ added in v0.1.56
func WithProviderCredentials(service ProviderCredentialsAdmin) Option
WithProviderCredentials enables admin management of model provider credentials (the dashboard alternative to setting provider API keys as env vars). Callers must not wrap a nil *providers.CredentialsService (a typed nil would defeat the handlers' feature-unavailable check).
func WithRateLimits ¶
WithRateLimits enables rate limit administration endpoints.
func WithRequestHealth ¶
func WithRequestHealth(source RequestHealthSource) Option
WithRequestHealth folds recent request outcomes (per-model errors and the live circuit-breaker state) into the provider status endpoint.
func WithRuntimeRefresher ¶
func WithRuntimeRefresher(refresher RuntimeRefresher) Option
WithRuntimeRefresher enables manual runtime refresh from the admin API.
func WithTagging ¶
WithTagging wires the header tagging service for label rule management.
func WithUsagePricingRecalculator ¶
func WithUsagePricingRecalculator(recalculator usage.PricingRecalculator) Option
WithUsagePricingRecalculator enables persisted usage pricing recalculation.
func WithVirtualModels ¶
func WithVirtualModels(service *virtualmodels.Service) Option
WithVirtualModels enables unified virtual model administration endpoints.
func WithWorkflows ¶
WithWorkflows enables workflow administration endpoints.
type ProviderCredentialsAdmin ¶ added in v0.1.56
type ProviderCredentialsAdmin interface {
List(ctx context.Context) ([]providers.ManagedProviderCredential, error)
Get(ctx context.Context, name string) (*providers.ManagedProviderCredential, error)
Upsert(ctx context.Context, cred providers.ManagedProviderCredential) error
Delete(ctx context.Context, name string) error
IsManaged(name string) bool
RegisteredTypes() []string
}
ProviderCredentialsAdmin is the narrow surface of *providers.CredentialsService the admin API needs, kept as an interface so handler tests can stub it.
type RequestHealthSource ¶
type RequestHealthSource interface {
Snapshot() map[string]health.ProviderHealth
}
RequestHealthSource supplies windowed real-traffic health per provider, keyed by configured provider name.
type RouteRegistrar ¶
type RouteRegistrar interface {
GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) echo.RouteInfo
POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) echo.RouteInfo
PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) echo.RouteInfo
DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) echo.RouteInfo
}
RouteRegistrar is the subset of *echo.Group / *echo.Echo that RegisterRoutes uses. Decoupling from a concrete echo type keeps the admin package useful for callers that want to mount the API under a different path prefix or wrap the routes with extra middleware.
type RuntimeRefreshReport ¶
type RuntimeRefreshReport struct {
Status string `json:"status"`
StartedAt time.Time `json:"started_at"`
FinishedAt time.Time `json:"finished_at"`
DurationMS int64 `json:"duration_ms"`
ModelCount int `json:"model_count"`
ProviderCount int `json:"provider_count"`
Steps []RuntimeRefreshStep `json:"steps"`
}
RuntimeRefreshReport is returned by the manual runtime refresh endpoint.
type RuntimeRefreshStep ¶
type RuntimeRefreshStep struct {
Name string `json:"name"`
Status string `json:"status"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
DurationMS int64 `json:"duration_ms"`
}
RuntimeRefreshStep describes the result of one manual runtime refresh step.
type RuntimeRefresher ¶
type RuntimeRefresher interface {
RefreshRuntime(ctx context.Context) (RuntimeRefreshReport, error)
}
RuntimeRefresher refreshes application runtime snapshots on demand.
Source Files
¶
- errors.go
- handler.go
- handler_audit.go
- handler_authkeys.go
- handler_budgets.go
- handler_failover.go
- handler_guardrails.go
- handler_live.go
- handler_managed_resource.go
- handler_mcpservers.go
- handler_model_pricing_overrides.go
- handler_models.go
- handler_provider_credentials.go
- handler_providers.go
- handler_ratelimits.go
- handler_tagging.go
- handler_usage.go
- handler_virtualmodels.go
- handler_workflows.go
- routes.go