management

package
v6.10.9-aug.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 60 Imported by: 0

Documentation

Overview

Package management provides the management API handlers and middleware for configuring the server and managing auth files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteOAuthCallbackFileForPendingSession

func WriteOAuthCallbackFileForPendingSession(authDir, provider, state, code, errorMessage string) (string, error)

Types

type Handler

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

Handler aggregates config reference, persistence path and helpers.

func NewHandler

func NewHandler(cfg *config.Config, configFilePath string, manager *coreauth.Manager, opts ...Option) *Handler

NewHandler creates a new management handler instance.

func NewHandlerWithoutConfigFilePath

func NewHandlerWithoutConfigFilePath(cfg *config.Config, manager *coreauth.Manager, opts ...Option) *Handler

NewHandlerWithoutConfigFilePath creates a management handler without a config file path.

func (*Handler) APICall

func (h *Handler) APICall(c *gin.Context)

APICall makes a generic HTTP request on behalf of the management API caller. It is protected by the management middleware.

Endpoint:

POST /v0/management/api-call

Authentication:

Same as other management APIs (requires a management key and remote-management rules).
You can provide the key via:
- Authorization: Bearer <key>
- X-Management-Key: <key>

Request JSON:

  • auth_index / authIndex / AuthIndex (optional): The credential "auth_index" from GET /v0/management/auth-files (or other endpoints returning it). If omitted or not found, credential-specific proxy/token substitution is skipped.
  • method (required): HTTP method, e.g. GET, POST, PUT, PATCH, DELETE.
  • url (required): Absolute URL including scheme and host, e.g. "https://api.example.com/v1/ping".
  • header (optional): Request headers map. Supports magic variable "$TOKEN$" which is replaced using the selected credential: 1) metadata.access_token 2) attributes.api_key 3) metadata.token / metadata.id_token / metadata.cookie Example: {"Authorization":"Bearer $TOKEN$"}. Note: if you need to override the HTTP Host header, set header["Host"].
  • data (optional): Raw request body as string (useful for POST/PUT/PATCH).

Proxy selection (highest priority first):

  1. Selected credential proxy_url
  2. Global config proxy-url
  3. Direct connect (environment proxies are not used)

Response JSON (returned with HTTP 200 when the APICall itself succeeds):

  • status_code: Upstream HTTP status code.
  • header: Upstream response headers.
  • body: Upstream response body as string.

Example:

curl -sS -X POST "http://127.0.0.1:8317/v0/management/api-call" \
  -H "Authorization: Bearer <MANAGEMENT_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"auth_index":"<AUTH_INDEX>","method":"GET",
       "url":"https://api.example.com/v1/ping",
       "header":{"Authorization":"Bearer $TOKEN$"}}'

curl -sS -X POST "http://127.0.0.1:8317/v0/management/api-call" \
  -H "Authorization: Bearer 831227" \
  -H "Content-Type: application/json" \
  -d '{"auth_index":"<AUTH_INDEX>","method":"POST",
       "url":"https://api.example.com/v1/fetchAvailableModels",
       "header":{"Authorization":"Bearer $TOKEN$",
                  "Content-Type":"application/json",
                  "User-Agent":"cliproxyapi"},
       "data":"{}"}'

func (*Handler) DeleteAPIKeyAlias

func (h *Handler) DeleteAPIKeyAlias(c *gin.Context)

func (*Handler) DeleteAPIKeys

func (h *Handler) DeleteAPIKeys(c *gin.Context)

func (*Handler) DeleteAmpModelMappings

func (h *Handler) DeleteAmpModelMappings(c *gin.Context)

DeleteAmpModelMappings removes specified model mappings by "from" field.

func (*Handler) DeleteAmpUpstreamAPIKey

func (h *Handler) DeleteAmpUpstreamAPIKey(c *gin.Context)

DeleteAmpUpstreamAPIKey clears the ampcode upstream API key.

func (*Handler) DeleteAmpUpstreamAPIKeys

func (h *Handler) DeleteAmpUpstreamAPIKeys(c *gin.Context)

DeleteAmpUpstreamAPIKeys removes specified upstream API keys entries. Body must be JSON: {"value": ["<upstream-api-key>", ...]}. If "value" is an empty array, clears all entries. If JSON is invalid or "value" is missing/null, returns 400 and does not persist any change.

func (*Handler) DeleteAmpUpstreamURL

func (h *Handler) DeleteAmpUpstreamURL(c *gin.Context)

DeleteAmpUpstreamURL clears the ampcode upstream URL.

func (*Handler) DeleteAuthFile

func (h *Handler) DeleteAuthFile(c *gin.Context)

DeleteAuthFile deletes auth files: single by name, batch by body, or all.

func (*Handler) DeleteClaudeKey

func (h *Handler) DeleteClaudeKey(c *gin.Context)

func (*Handler) DeleteCodexKey

func (h *Handler) DeleteCodexKey(c *gin.Context)

func (*Handler) DeleteGeminiKey

func (h *Handler) DeleteGeminiKey(c *gin.Context)

func (*Handler) DeleteLogs

func (h *Handler) DeleteLogs(c *gin.Context)

DeleteLogs removes all rotated log files and truncates the active log.

func (*Handler) DeleteOAuthExcludedModels

func (h *Handler) DeleteOAuthExcludedModels(c *gin.Context)

func (*Handler) DeleteOAuthModelAlias

func (h *Handler) DeleteOAuthModelAlias(c *gin.Context)

func (*Handler) DeleteOpenAICompat

func (h *Handler) DeleteOpenAICompat(c *gin.Context)

func (*Handler) DeleteProxyURL

func (h *Handler) DeleteProxyURL(c *gin.Context)

func (*Handler) DeleteVertexCompatKey

func (h *Handler) DeleteVertexCompatKey(c *gin.Context)

func (*Handler) DownloadAuthFile

func (h *Handler) DownloadAuthFile(c *gin.Context)

DownloadAuthFile downloads a single auth file by name.

func (*Handler) DownloadRequestErrorLog

func (h *Handler) DownloadRequestErrorLog(c *gin.Context)

DownloadRequestErrorLog downloads a specific error request log file by name. When the "lines" query parameter is set, returns a JSON preview instead.

func (*Handler) ExportUsageStatistics

func (h *Handler) ExportUsageStatistics(c *gin.Context)

ExportUsageStatistics returns a usage snapshot for backup/migration. The response shape (version 1 + nested StatisticsSnapshot) is preserved so previously exported files stay re-importable across the SQLite swap.

Supports optional query parameters from / to / model / api_key / credential to scope the export to the user's current dashboard view. Without any parameters the full snapshot is returned (legacy behaviour).

func (*Handler) GetAPIKeyAliases

func (h *Handler) GetAPIKeyAliases(c *gin.Context)

func (*Handler) GetAPIKeyUsage

func (h *Handler) GetAPIKeyUsage(c *gin.Context)

func (*Handler) GetAPIKeys

func (h *Handler) GetAPIKeys(c *gin.Context)

func (*Handler) GetAmpCode

func (h *Handler) GetAmpCode(c *gin.Context)

GetAmpCode returns the complete ampcode configuration.

func (*Handler) GetAmpForceModelMappings

func (h *Handler) GetAmpForceModelMappings(c *gin.Context)

GetAmpForceModelMappings returns whether model mappings are forced.

func (*Handler) GetAmpModelMappings

func (h *Handler) GetAmpModelMappings(c *gin.Context)

GetAmpModelMappings returns the ampcode model mappings.

func (*Handler) GetAmpRestrictManagementToLocalhost

func (h *Handler) GetAmpRestrictManagementToLocalhost(c *gin.Context)

GetAmpRestrictManagementToLocalhost returns the localhost restriction setting.

func (*Handler) GetAmpUpstreamAPIKey

func (h *Handler) GetAmpUpstreamAPIKey(c *gin.Context)

GetAmpUpstreamAPIKey returns the ampcode upstream API key.

func (*Handler) GetAmpUpstreamAPIKeys

func (h *Handler) GetAmpUpstreamAPIKeys(c *gin.Context)

GetAmpUpstreamAPIKeys returns the ampcode upstream API keys mapping.

func (*Handler) GetAmpUpstreamURL

func (h *Handler) GetAmpUpstreamURL(c *gin.Context)

GetAmpUpstreamURL returns the ampcode upstream URL.

func (*Handler) GetAuthFileModels

func (h *Handler) GetAuthFileModels(c *gin.Context)

GetAuthFileModels returns the models supported by a specific auth file

func (*Handler) GetAuthStatus

func (h *Handler) GetAuthStatus(c *gin.Context)

func (*Handler) GetAutoRefreshInterval

func (h *Handler) GetAutoRefreshInterval(c *gin.Context)

GetAutoRefreshInterval returns the auto refresh interval.

func (*Handler) GetClaudeKeys

func (h *Handler) GetClaudeKeys(c *gin.Context)

func (*Handler) GetCodexKeys

func (h *Handler) GetCodexKeys(c *gin.Context)

func (*Handler) GetConfig

func (h *Handler) GetConfig(c *gin.Context)

func (*Handler) GetConfigYAML

func (h *Handler) GetConfigYAML(c *gin.Context)

GetConfigYAML returns the raw config.yaml file bytes without re-encoding. It preserves comments and original formatting/styles.

func (*Handler) GetDebug

func (h *Handler) GetDebug(c *gin.Context)

GetDebug returns the debug flag.

func (*Handler) GetErrorLogsMaxFiles

func (h *Handler) GetErrorLogsMaxFiles(c *gin.Context)

GetErrorLogsMaxFiles returns the error logs max files count.

func (*Handler) GetForceModelPrefix

func (h *Handler) GetForceModelPrefix(c *gin.Context)

GetForceModelPrefix returns the force model prefix flag.

func (*Handler) GetGeminiKeys

func (h *Handler) GetGeminiKeys(c *gin.Context)

func (*Handler) GetLatestVersion

func (h *Handler) GetLatestVersion(c *gin.Context)

GetLatestVersion returns the latest release version from GitHub without downloading assets.

func (*Handler) GetLogSize

func (h *Handler) GetLogSize(c *gin.Context)

GetLogSize returns the total disk usage of all log files in the log directory.

func (*Handler) GetLoggingToFile

func (h *Handler) GetLoggingToFile(c *gin.Context)

GetLoggingToFile returns the logging-to-file flag.

func (*Handler) GetLogs

func (h *Handler) GetLogs(c *gin.Context)

GetLogs returns log lines with optional incremental loading.

func (*Handler) GetLogsMaxTotalSizeMB

func (h *Handler) GetLogsMaxTotalSizeMB(c *gin.Context)

GetLogsMaxTotalSizeMB returns the logs max total size in MB.

func (*Handler) GetMaxRetryInterval

func (h *Handler) GetMaxRetryInterval(c *gin.Context)

GetMaxRetryInterval returns the max retry interval.

func (*Handler) GetModelPrices

func (h *Handler) GetModelPrices(c *gin.Context)

GetModelPrices returns the stored model pricing configuration.

func (*Handler) GetModelsCatalogMeta

func (h *Handler) GetModelsCatalogMeta(c *gin.Context)

GetModelsCatalogMeta returns the current state of the remote model catalog so the UI can show the source URL and refresh timing.

func (*Handler) GetOAuthExcludedModels

func (h *Handler) GetOAuthExcludedModels(c *gin.Context)

func (*Handler) GetOAuthModelAlias

func (h *Handler) GetOAuthModelAlias(c *gin.Context)

func (*Handler) GetOpenAICompat

func (h *Handler) GetOpenAICompat(c *gin.Context)

func (*Handler) GetProxyURL

func (h *Handler) GetProxyURL(c *gin.Context)

GetProxyURL returns the proxy URL.

func (*Handler) GetQuotaConfig

func (h *Handler) GetQuotaConfig(c *gin.Context)

GetQuotaConfig returns the current quota scheduler configuration.

func (*Handler) GetQuotaStatus

func (h *Handler) GetQuotaStatus(c *gin.Context)

GetQuotaStatus returns the cached quota status for all credentials.

func (*Handler) GetReleases

func (h *Handler) GetReleases(c *gin.Context)

GetReleases proxies the GitHub Releases API with a 15-minute per-repo cache. Query params: page (default 1), per_page (default 30, max 100), target ("cpa" | "panel", default "cpa").

func (*Handler) GetRequestErrorLogs

func (h *Handler) GetRequestErrorLogs(c *gin.Context)

GetRequestErrorLogs lists error request log files when RequestLog is disabled. It returns an empty list when RequestLog is enabled.

func (*Handler) GetRequestLog

func (h *Handler) GetRequestLog(c *gin.Context)

GetRequestLog returns the request log flag.

func (*Handler) GetRequestLogByID

func (h *Handler) GetRequestLogByID(c *gin.Context)

GetRequestLogByID finds and downloads a request log file by its request ID. The ID is matched against the suffix of log file names (format: *-{requestID}.log).

func (*Handler) GetRequestRetry

func (h *Handler) GetRequestRetry(c *gin.Context)

GetRequestRetry returns the request retry count.

func (*Handler) GetRoutingStrategy

func (h *Handler) GetRoutingStrategy(c *gin.Context)

GetRoutingStrategy returns the routing strategy.

func (*Handler) GetStaticModelDefinitions

func (h *Handler) GetStaticModelDefinitions(c *gin.Context)

GetStaticModelDefinitions returns static model metadata for a given channel. Channel is provided via path param (:channel) or query param (?channel=...).

func (*Handler) GetSwitchPreviewModel

func (h *Handler) GetSwitchPreviewModel(c *gin.Context)

func (*Handler) GetSwitchProject

func (h *Handler) GetSwitchProject(c *gin.Context)

func (*Handler) GetUpdateCompatibility

func (h *Handler) GetUpdateCompatibility(c *gin.Context)

GetUpdateCompatibility returns real backend upgrade compatibility signals.

func (*Handler) GetUpdateStatus

func (h *Handler) GetUpdateStatus(c *gin.Context)

GetUpdateStatus returns the current self-update progress.

func (*Handler) GetUsageDBSize

func (h *Handler) GetUsageDBSize(c *gin.Context)

GetUsageDBSize returns the on-disk size of the SQLite database (events.db + WAL + SHM). Used by the retention card to surface real disk usage.

func (*Handler) GetUsageEvents

func (h *Handler) GetUsageEvents(c *gin.Context)

GetUsageEvents returns paginated usage event details.

GET /v0/management/usage/events?from=...&to=...&page=1&page_size=50
    &model=...&source=...&search=...&sort=timestamp&order=desc

func (*Handler) GetUsageRetention

func (h *Handler) GetUsageRetention(c *gin.Context)

GetUsageRetention returns the current retention configuration.

func (*Handler) GetUsageStatistics

func (h *Handler) GetUsageStatistics(c *gin.Context)

GetUsageStatistics returns the in-memory request statistics snapshot. With SQLite storage, the snapshot is rebuilt from disk on every call.

func (*Handler) GetUsageStatisticsEnabled

func (h *Handler) GetUsageStatisticsEnabled(c *gin.Context)

GetUsageStatisticsEnabled returns the usage statistics enabled flag.

func (*Handler) GetUsageSummary

func (h *Handler) GetUsageSummary(c *gin.Context)

GetUsageSummary returns aggregated usage data for dashboard rendering.

GET /v0/management/usage/summary?from=...&to=...&granularity=hourly|daily

func (*Handler) GetVersion

func (h *Handler) GetVersion(c *gin.Context)

GetVersion returns the build metadata of the currently running server binary plus the minimum panel version required for compatibility. The management panel calls this on mount to decide whether to render a version mismatch banner.

func (*Handler) GetVertexCompatKeys

func (h *Handler) GetVertexCompatKeys(c *gin.Context)

func (*Handler) GetWebsocketAuth

func (h *Handler) GetWebsocketAuth(c *gin.Context)

GetWebsocketAuth returns the websocket auth flag.

func (*Handler) ImportUsageStatistics

func (h *Handler) ImportUsageStatistics(c *gin.Context)

ImportUsageStatistics merges a previously exported payload into the SQLite store. Auto-detects the format (v1 nested, v2 detail, today.json, raw FlatDetail array) so old export files remain importable.

func (*Handler) ImportVertexCredential

func (h *Handler) ImportVertexCredential(c *gin.Context)

ImportVertexCredential handles uploading a Vertex service account JSON and saving it as an auth record.

func (*Handler) InternalToken

func (h *Handler) InternalToken() string

InternalToken returns the token for authenticating internal localhost requests.

func (*Handler) ListAuthFiles

func (h *Handler) ListAuthFiles(c *gin.Context)

func (*Handler) Middleware

func (h *Handler) Middleware() gin.HandlerFunc

Middleware enforces access control for management endpoints. All requests (local and remote) require a valid management key. Additionally, remote access requires allow-remote-management=true.

func (*Handler) PatchAPIKeyAlias

func (h *Handler) PatchAPIKeyAlias(c *gin.Context)

func (*Handler) PatchAPIKeys

func (h *Handler) PatchAPIKeys(c *gin.Context)

func (*Handler) PatchAmpModelMappings

func (h *Handler) PatchAmpModelMappings(c *gin.Context)

PatchAmpModelMappings adds or updates model mappings.

func (*Handler) PatchAmpUpstreamAPIKeys

func (h *Handler) PatchAmpUpstreamAPIKeys(c *gin.Context)

PatchAmpUpstreamAPIKeys adds or updates upstream API keys entries. Matching is done by upstream-api-key value.

func (*Handler) PatchAuthFileFields

func (h *Handler) PatchAuthFileFields(c *gin.Context)

PatchAuthFileFields updates editable fields (prefix, proxy_url, priority) of an auth file.

func (*Handler) PatchAuthFileStatus

func (h *Handler) PatchAuthFileStatus(c *gin.Context)

PatchAuthFileStatus toggles the disabled state of an auth file

func (*Handler) PatchAuthFilesBulkDisable

func (h *Handler) PatchAuthFilesBulkDisable(c *gin.Context)

PatchAuthFilesBulkDisable disables every auth file named in the body.

func (*Handler) PatchAuthFilesBulkEnable

func (h *Handler) PatchAuthFilesBulkEnable(c *gin.Context)

PatchAuthFilesBulkEnable enables (sets disabled=false) every auth file named in the body. Paired with PatchAuthFilesBulkDisable to let the panel flip many credentials at once without N round-trips to PatchAuthFileStatus.

func (*Handler) PatchClaudeKey

func (h *Handler) PatchClaudeKey(c *gin.Context)

func (*Handler) PatchCodexKey

func (h *Handler) PatchCodexKey(c *gin.Context)

func (*Handler) PatchGeminiKey

func (h *Handler) PatchGeminiKey(c *gin.Context)

func (*Handler) PatchOAuthExcludedModels

func (h *Handler) PatchOAuthExcludedModels(c *gin.Context)

func (*Handler) PatchOAuthModelAlias

func (h *Handler) PatchOAuthModelAlias(c *gin.Context)

func (*Handler) PatchOpenAICompat

func (h *Handler) PatchOpenAICompat(c *gin.Context)

func (*Handler) PatchVertexCompatKey

func (h *Handler) PatchVertexCompatKey(c *gin.Context)

func (*Handler) PostModelsCatalogRefresh

func (h *Handler) PostModelsCatalogRefresh(c *gin.Context)

PostModelsCatalogRefresh triggers an immediate model catalog refresh.

func (*Handler) PostOAuthCallback

func (h *Handler) PostOAuthCallback(c *gin.Context)

func (*Handler) PostPanelUpdate

func (h *Handler) PostPanelUpdate(c *gin.Context)

PostPanelUpdate triggers a panel HTML asset refresh. An optional `version` field in the request body pins the update to a specific release tag; when empty the latest release is used.

func (*Handler) PostQuotaRefresh

func (h *Handler) PostQuotaRefresh(c *gin.Context)

PostQuotaRefresh triggers an immediate quota refresh asynchronously.

func (*Handler) PostUpdate

func (h *Handler) PostUpdate(c *gin.Context)

PostUpdate triggers a self-update to the specified version.

func (*Handler) PutAPIKeyAliases

func (h *Handler) PutAPIKeyAliases(c *gin.Context)

func (*Handler) PutAPIKeys

func (h *Handler) PutAPIKeys(c *gin.Context)

func (*Handler) PutAmpForceModelMappings

func (h *Handler) PutAmpForceModelMappings(c *gin.Context)

PutAmpForceModelMappings updates the force model mappings setting.

func (*Handler) PutAmpModelMappings

func (h *Handler) PutAmpModelMappings(c *gin.Context)

PutAmpModelMappings replaces all ampcode model mappings.

func (*Handler) PutAmpRestrictManagementToLocalhost

func (h *Handler) PutAmpRestrictManagementToLocalhost(c *gin.Context)

PutAmpRestrictManagementToLocalhost updates the localhost restriction setting.

func (*Handler) PutAmpUpstreamAPIKey

func (h *Handler) PutAmpUpstreamAPIKey(c *gin.Context)

PutAmpUpstreamAPIKey updates the ampcode upstream API key.

func (*Handler) PutAmpUpstreamAPIKeys

func (h *Handler) PutAmpUpstreamAPIKeys(c *gin.Context)

PutAmpUpstreamAPIKeys replaces all ampcode upstream API keys mappings.

func (*Handler) PutAmpUpstreamURL

func (h *Handler) PutAmpUpstreamURL(c *gin.Context)

PutAmpUpstreamURL updates the ampcode upstream URL.

func (*Handler) PutAutoRefreshInterval

func (h *Handler) PutAutoRefreshInterval(c *gin.Context)

func (*Handler) PutClaudeKeys

func (h *Handler) PutClaudeKeys(c *gin.Context)

func (*Handler) PutCodexKeys

func (h *Handler) PutCodexKeys(c *gin.Context)

func (*Handler) PutConfigYAML

func (h *Handler) PutConfigYAML(c *gin.Context)

func (*Handler) PutDebug

func (h *Handler) PutDebug(c *gin.Context)

func (*Handler) PutErrorLogsMaxFiles

func (h *Handler) PutErrorLogsMaxFiles(c *gin.Context)

func (*Handler) PutForceModelPrefix

func (h *Handler) PutForceModelPrefix(c *gin.Context)

func (*Handler) PutGeminiKeys

func (h *Handler) PutGeminiKeys(c *gin.Context)

func (*Handler) PutLoggingToFile

func (h *Handler) PutLoggingToFile(c *gin.Context)

func (*Handler) PutLogsMaxTotalSizeMB

func (h *Handler) PutLogsMaxTotalSizeMB(c *gin.Context)

func (*Handler) PutMaxRetryInterval

func (h *Handler) PutMaxRetryInterval(c *gin.Context)

func (*Handler) PutModelPrices

func (h *Handler) PutModelPrices(c *gin.Context)

PutModelPrices replaces the stored model pricing configuration.

func (*Handler) PutOAuthExcludedModels

func (h *Handler) PutOAuthExcludedModels(c *gin.Context)

func (*Handler) PutOAuthModelAlias

func (h *Handler) PutOAuthModelAlias(c *gin.Context)

func (*Handler) PutOpenAICompat

func (h *Handler) PutOpenAICompat(c *gin.Context)

func (*Handler) PutProxyURL

func (h *Handler) PutProxyURL(c *gin.Context)

func (*Handler) PutQuotaConfig

func (h *Handler) PutQuotaConfig(c *gin.Context)

PutQuotaConfig updates the quota scheduler configuration. Uses merge semantics: unspecified fields retain their current values.

func (*Handler) PutRequestLog

func (h *Handler) PutRequestLog(c *gin.Context)

func (*Handler) PutRequestRetry

func (h *Handler) PutRequestRetry(c *gin.Context)

func (*Handler) PutRoutingStrategy

func (h *Handler) PutRoutingStrategy(c *gin.Context)

func (*Handler) PutSwitchPreviewModel

func (h *Handler) PutSwitchPreviewModel(c *gin.Context)

func (*Handler) PutSwitchProject

func (h *Handler) PutSwitchProject(c *gin.Context)

func (*Handler) PutUsageRetention

func (h *Handler) PutUsageRetention(c *gin.Context)

PutUsageRetention updates the retention configuration.

func (*Handler) PutUsageStatisticsEnabled

func (h *Handler) PutUsageStatisticsEnabled(c *gin.Context)

func (*Handler) PutVertexCompatKeys

func (h *Handler) PutVertexCompatKeys(c *gin.Context)

func (*Handler) PutWebsocketAuth

func (h *Handler) PutWebsocketAuth(c *gin.Context)

func (*Handler) RecalculateCosts

func (h *Handler) RecalculateCosts(c *gin.Context)

RecalculateCosts recalculates all historical costs using the current price table.

POST /v0/management/usage/recalculate-costs

func (*Handler) RequestAnthropicToken

func (h *Handler) RequestAnthropicToken(c *gin.Context)

func (*Handler) RequestAntigravityToken

func (h *Handler) RequestAntigravityToken(c *gin.Context)

func (*Handler) RequestCodexToken

func (h *Handler) RequestCodexToken(c *gin.Context)

func (*Handler) RequestGeminiCLIToken

func (h *Handler) RequestGeminiCLIToken(c *gin.Context)

func (*Handler) RequestIFlowCookieToken

func (h *Handler) RequestIFlowCookieToken(c *gin.Context)

func (*Handler) RequestIFlowToken

func (h *Handler) RequestIFlowToken(c *gin.Context)

func (*Handler) RequestKimiToken

func (h *Handler) RequestKimiToken(c *gin.Context)

func (*Handler) RequestQwenToken

func (h *Handler) RequestQwenToken(c *gin.Context)

func (*Handler) SetAuthManager

func (h *Handler) SetAuthManager(manager *coreauth.Manager)

SetAuthManager updates the auth manager reference used by management endpoints.

func (*Handler) SetConfig

func (h *Handler) SetConfig(cfg *config.Config)

SetConfig updates the in-memory config reference when the server hot-reloads.

func (*Handler) SetLocalPassword

func (h *Handler) SetLocalPassword(password string)

SetLocalPassword configures the runtime-local password accepted for localhost requests.

func (*Handler) SetLogDirectory

func (h *Handler) SetLogDirectory(dir string)

SetLogDirectory updates the directory where main.log should be looked up.

func (*Handler) SetPostAuthHook

func (h *Handler) SetPostAuthHook(hook coreauth.PostAuthHook)

SetPostAuthHook registers a hook to be called after auth record creation but before persistence.

func (*Handler) SetQuotaScheduler

func (h *Handler) SetQuotaScheduler(s *quota.Scheduler)

SetQuotaScheduler sets the quota refresh scheduler after handler creation. Must be called before Server.Start() — not safe for concurrent use.

func (*Handler) SetUsagePersister

func (h *Handler) SetUsagePersister(p *usage.Persister)

SetUsagePersister sets the usage statistics persister reference.

func (*Handler) SetUsageStatistics

func (h *Handler) SetUsageStatistics(stats *usage.RequestStatistics)

SetUsageStatistics allows replacing the usage statistics reference.

func (*Handler) StartCPAAutoUpdater

func (h *Handler) StartCPAAutoUpdater(ctx context.Context)

func (*Handler) StopCPAAutoUpdater

func (h *Handler) StopCPAAutoUpdater()

func (*Handler) TrimPreviewUsageStatistics

func (h *Handler) TrimPreviewUsageStatistics(c *gin.Context)

TrimPreviewUsageStatistics returns a preview of what would be cleaned by Trim.

func (*Handler) TrimUsageStatistics

func (h *Handler) TrimUsageStatistics(c *gin.Context)

TrimUsageStatistics triggers an immediate cleanup of expired details.

func (*Handler) UploadAuthFile

func (h *Handler) UploadAuthFile(c *gin.Context)

UploadAuthFile uploads auth files via multipart or raw JSON with ?name= parameter.

func (*Handler) ValidateConfigYAML

func (h *Handler) ValidateConfigYAML(c *gin.Context)

type Option

type Option func(*Handler)

Option configures a Handler.

func WithEnvSecret

func WithEnvSecret(secret string) Option

WithEnvSecret overrides the management password (default: from MANAGEMENT_PASSWORD env).

func WithLogDir

func WithLogDir(dir string) Option

WithLogDir sets the log directory.

func WithQuotaScheduler

func WithQuotaScheduler(s *quota.Scheduler) Option

WithQuotaScheduler sets the quota refresh scheduler.

func WithTokenStore

func WithTokenStore(store coreauth.Store) Option

WithTokenStore overrides the token store.

func WithUsagePersister

func WithUsagePersister(p *usage.Persister) Option

WithUsagePersister sets the usage persister.

func WithUsageStats

func WithUsageStats(stats *usage.RequestStatistics) Option

WithUsageStats overrides the usage statistics source.

Jump to

Keyboard shortcuts

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