Documentation
¶
Overview ¶
Package user provides primitives to interact with the openapi HTTP API.
Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 DO NOT EDIT.
Package user 实现 /user 面 HTTP 处理(OpenAPI tag: user 的独立 ServerInterface):认证(register/login 公开;me 及业务端点 JWT 保护)+ 业务端点(groups/keys/logs/stats)。
Index ¶
- func Handler(si ServerInterface) http.Handler
- func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler
- func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler
- func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler
- func Mount(api *UserAPI, iss *auth.Issuer, p auth.SnapshotProvider) http.Handler
- func Router(svc *service.Service, iss *auth.Issuer, p auth.SnapshotProvider, ...) http.Handler
- type BalanceWarningThresholdResponse
- type BalanceWarningThresholdUpdate
- type ChangePasswordResponse
- type ChiServerOptions
- type DeletedResponse
- type Error
- type ErrorResponse
- type ErrorResponseReason
- type ErrorResponseStorage
- type ErrorType
- type ForgotPasswordRequest
- type GetUserErrLogsParams
- type GetUserKeysParams
- type GetUserKeysParamsOrder
- type GetUserRedemptionsParams
- type GetUserRedemptionsParamsOrder
- type GetUserStatsParams
- type GetUserStatsParamsGranularity
- type GetUserStatsTTFTParams
- type GetUserUsageLogsParams
- type Group
- type GroupProtocolConvert
- type GroupVisibility
- type InvalidParamFormatError
- type Key
- type KeyCreate
- type KeyListResponse
- type KeyStatus
- type KeyUpdate
- type ManagementKey
- type ManagementKeyCreate
- type ManagementKeyListResponse
- type ManagementKeyStatus
- type ManagementKeyUpdate
- type MiddlewareFunc
- type PostUserAuthChangePasswordJSONRequestBody
- type PostUserAuthForgotPasswordJSONRequestBody
- type PostUserAuthLoginJSONRequestBody
- type PostUserAuthRegisterCodeJSONRequestBody
- type PostUserAuthRegisterJSONRequestBody
- type PostUserAuthResetPasswordJSONRequestBody
- type PostUserKeysJSONRequestBody
- type PostUserManagementKeysJSONRequestBody
- type PostUserRedemptionsJSONRequestBody
- type PutUserBalanceWarningThresholdJSONRequestBody
- type PutUserKeysIdJSONRequestBody
- type PutUserManagementKeysIdJSONRequestBody
- type RedeemRequest
- type RedeemResponse
- type RedemptionRecord
- type RedemptionRecordListResponse
- type RedemptionType
- type RegisterCodeRequest
- type RequestFormat
- type RequiredHeaderError
- type RequiredParamError
- type ResetPasswordRequest
- type SentResponse
- type ServerInterface
- type ServerInterfaceWrapper
- func (siw *ServerInterfaceWrapper) DeleteUserKeysId(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) DeleteUserManagementKeysId(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUserAuthMe(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUserBalanceWarningThreshold(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUserErrLogs(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUserGroups(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUserKeys(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUserKeysId(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUserManagementKeys(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUserRedemptions(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUserStats(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUserStatsCapabilities(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUserStatsTTFT(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUserTempBalances(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUserUsageLogs(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PostUserAuthChangePassword(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PostUserAuthForgotPassword(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PostUserAuthLogin(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PostUserAuthRegister(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PostUserAuthRegisterCode(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PostUserAuthResetPassword(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PostUserKeys(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PostUserKeysIdRotate(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PostUserManagementKeys(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PostUserRedemptions(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PutUserBalanceWarningThreshold(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PutUserKeysId(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PutUserManagementKeysId(w http.ResponseWriter, r *http.Request)
- type StatTTFTSummary
- type StatTTFTSummarySource
- type StatTrendPoint
- type StatsCapabilities
- type StatsKindCapability
- type StatsKindCapabilityStorages
- type StatsTimezone
- type StatsWindow
- type TempBalanceRow
- type TempBalancesResponse
- type TooManyValuesForParamError
- type UnescapedCookieParamError
- type Unimplemented
- func (_ Unimplemented) DeleteUserKeysId(w http.ResponseWriter, r *http.Request, id int64)
- func (_ Unimplemented) DeleteUserManagementKeysId(w http.ResponseWriter, r *http.Request, id int64)
- func (_ Unimplemented) GetUserAuthMe(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) GetUserBalanceWarningThreshold(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) GetUserErrLogs(w http.ResponseWriter, r *http.Request, params GetUserErrLogsParams)
- func (_ Unimplemented) GetUserGroups(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) GetUserKeys(w http.ResponseWriter, r *http.Request, params GetUserKeysParams)
- func (_ Unimplemented) GetUserKeysId(w http.ResponseWriter, r *http.Request, id int64)
- func (_ Unimplemented) GetUserManagementKeys(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) GetUserRedemptions(w http.ResponseWriter, r *http.Request, params GetUserRedemptionsParams)
- func (_ Unimplemented) GetUserStats(w http.ResponseWriter, r *http.Request, params GetUserStatsParams)
- func (_ Unimplemented) GetUserStatsCapabilities(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) GetUserStatsTTFT(w http.ResponseWriter, r *http.Request, params GetUserStatsTTFTParams)
- func (_ Unimplemented) GetUserTempBalances(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) GetUserUsageLogs(w http.ResponseWriter, r *http.Request, params GetUserUsageLogsParams)
- func (_ Unimplemented) PostUserAuthChangePassword(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) PostUserAuthForgotPassword(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) PostUserAuthLogin(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) PostUserAuthRegister(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) PostUserAuthRegisterCode(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) PostUserAuthResetPassword(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) PostUserKeys(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) PostUserKeysIdRotate(w http.ResponseWriter, r *http.Request, id int64)
- func (_ Unimplemented) PostUserManagementKeys(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) PostUserRedemptions(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) PutUserBalanceWarningThreshold(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) PutUserKeysId(w http.ResponseWriter, r *http.Request, id int64)
- func (_ Unimplemented) PutUserManagementKeysId(w http.ResponseWriter, r *http.Request, id int64)
- type UnmarshalingParamError
- type User
- type UserAPI
- func (h *UserAPI) DeleteUserKeysId(w http.ResponseWriter, r *http.Request, id int64)
- func (h *UserAPI) DeleteUserManagementKeysId(w http.ResponseWriter, r *http.Request, id int64)
- func (h *UserAPI) GetUserAuthMe(w http.ResponseWriter, r *http.Request)
- func (h *UserAPI) GetUserBalanceWarningThreshold(w http.ResponseWriter, r *http.Request)
- func (h *UserAPI) GetUserErrLogs(w http.ResponseWriter, r *http.Request, params GetUserErrLogsParams)
- func (h *UserAPI) GetUserGroups(w http.ResponseWriter, r *http.Request)
- func (h *UserAPI) GetUserKeys(w http.ResponseWriter, r *http.Request, params GetUserKeysParams)
- func (h *UserAPI) GetUserKeysId(w http.ResponseWriter, r *http.Request, id int64)
- func (h *UserAPI) GetUserManagementKeys(w http.ResponseWriter, r *http.Request)
- func (h *UserAPI) GetUserRedemptions(w http.ResponseWriter, r *http.Request, params GetUserRedemptionsParams)
- func (h *UserAPI) GetUserStats(w http.ResponseWriter, r *http.Request, params GetUserStatsParams)
- func (h *UserAPI) GetUserStatsCapabilities(w http.ResponseWriter, r *http.Request)
- func (h *UserAPI) GetUserStatsTTFT(w http.ResponseWriter, r *http.Request, params GetUserStatsTTFTParams)
- func (h *UserAPI) GetUserTempBalances(w http.ResponseWriter, r *http.Request)
- func (h *UserAPI) GetUserUsageLogs(w http.ResponseWriter, r *http.Request, params GetUserUsageLogsParams)
- func (h *UserAPI) PostUserAuthChangePassword(w http.ResponseWriter, r *http.Request)
- func (h *UserAPI) PostUserAuthForgotPassword(w http.ResponseWriter, r *http.Request)
- func (h *UserAPI) PostUserAuthLogin(w http.ResponseWriter, r *http.Request)
- func (h *UserAPI) PostUserAuthRegister(w http.ResponseWriter, r *http.Request)
- func (h *UserAPI) PostUserAuthRegisterCode(w http.ResponseWriter, r *http.Request)
- func (h *UserAPI) PostUserAuthResetPassword(w http.ResponseWriter, r *http.Request)
- func (h *UserAPI) PostUserKeys(w http.ResponseWriter, r *http.Request)
- func (h *UserAPI) PostUserKeysIdRotate(w http.ResponseWriter, r *http.Request, id int64)
- func (h *UserAPI) PostUserManagementKeys(w http.ResponseWriter, r *http.Request)
- func (h *UserAPI) PostUserRedemptions(w http.ResponseWriter, r *http.Request)
- func (h *UserAPI) PutUserBalanceWarningThreshold(w http.ResponseWriter, r *http.Request)
- func (h *UserAPI) PutUserKeysId(w http.ResponseWriter, r *http.Request, id int64)
- func (h *UserAPI) PutUserManagementKeysId(w http.ResponseWriter, r *http.Request, id int64)
- func (h *UserAPI) SetClock(now func() time.Time)
- type UserAuthChangePassword
- type UserAuthLogin
- type UserAuthRegister
- type UserAuthResponse
- type UserErrLog
- type UserErrLogsResponse
- type UserLogsResponse
- type UserRole
- type UserStatus
- type UserUsageLog
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
func Handler(si ServerInterface) http.Handler
Handler creates http.Handler with routing matching OpenAPI spec.
func HandlerFromMux ¶
func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler
HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.
func HandlerWithOptions ¶
func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler
HandlerWithOptions creates http.Handler with additional options
func Router ¶
func Router(svc *service.Service, iss *auth.Issuer, p auth.SnapshotProvider, rules *rule.RuleEngine, log *logx.Logger) http.Handler
Router 组装 /api/user 组路由(挂载于 /api/user/*): 公开路径(/api/user/auth/register、/api/user/auth/login)跳过鉴权;其余路径 RequireIdentity(JWT 或管理 key mk- 统一身份鉴权 + 内存快照用户状态校验)。 生成路由的 spec 路径自带 /api/user 前缀,故无独立 BaseURL, HandlerWithOptions 直接使用 spec 路径。 rules 为规则引擎(/api/user/err_logs 行级脱敏用;main 装配注入——非 New, 测试构造零回归;nil = 不脱敏)。log 为面日志(/forgot-password 反枚举路径的 发送失败可观测出口;nil = 静默)。p 为单一鉴权快照面(users + mgmt 合并; proxy.Auth 实现;支持 mk- 凭证以 owner 身份访问 /api/user 面)。
Types ¶
type BalanceWarningThresholdResponse ¶
type BalanceWarningThresholdResponse struct {
// BalanceWarningThreshold 阈值 USD;0 = 关闭
BalanceWarningThreshold float64 `json:"balance_warning_threshold"`
}
BalanceWarningThresholdResponse defines model for BalanceWarningThresholdResponse.
type BalanceWarningThresholdUpdate ¶
type BalanceWarningThresholdUpdate struct {
// BalanceWarningThreshold 阈值 USD;0 = 关闭;内部毫分存储(1 USD = 100,000 毫分)
BalanceWarningThreshold float64 `json:"balance_warning_threshold"`
}
BalanceWarningThresholdUpdate defines model for BalanceWarningThresholdUpdate.
type ChangePasswordResponse ¶
type ChangePasswordResponse struct {
Updated bool `json:"updated"`
}
ChangePasswordResponse defines model for ChangePasswordResponse.
type ChiServerOptions ¶
type ChiServerOptions struct {
BaseURL string
BaseRouter chi.Router
Middlewares []MiddlewareFunc
ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}
type DeletedResponse ¶
type DeletedResponse struct {
Deleted bool `json:"deleted"`
}
DeletedResponse defines model for DeletedResponse.
type ErrorResponse ¶
type ErrorResponse struct {
// EffectiveFrom 判定后的生效窗口下界(`window_invalid`/`window_ambiguous` 不携带)
EffectiveFrom *time.Time `json:"effective_from,omitempty"`
// EffectiveTo 判定后的生效窗口上界(`window_invalid`/`window_ambiguous` 不携带)
EffectiveTo *time.Time `json:"effective_to,omitempty"`
Error string `json:"error"`
// LimitSeconds 成本上限秒数(`window_too_long` 携带;0 = 无上限)
LimitSeconds *int64 `json:"limit_seconds,omitempty"`
// Reason 统计窗口被拒的机读原因(仅统计端点可能携带)。取值词表取自规划层原因与
// 拒绝原因的**全量映射表**(唯一来源),本版实际会发出的有五个:
// raw_horizon/cube_horizon = 起点早于所要读表的保留截止;
// window_too_long = 请求跨度超过该形状的成本上限;window_invalid =
// 必填/倒序/`window` 时长串不可解析等参数本身非法;window_ambiguous =
// `from`/`to`/`window` 三者的"恰择一"未被满足(两态都给、只给一端、
// 或两态都不给)。offset/dst/span_below_grid 是"该窗口无法用卷积表精确
// 表达、已降级到原始行"的派生原因(只用于降级告警日志,不作为拒绝原因
// 发出)。
Reason *ErrorResponseReason `json:"reason,omitempty"`
// RetentionDays 覆盖判定所依据的最保守保留天数(`*_horizon` 携带)
RetentionDays *int `json:"retention_days,omitempty"`
// Storage 判定所依据的实际存储(`window_invalid`/`window_ambiguous` 不携带)
Storage *ErrorResponseStorage `json:"storage,omitempty"`
}
ErrorResponse defines model for ErrorResponse.
type ErrorResponseReason ¶
type ErrorResponseReason string
ErrorResponseReason 统计窗口被拒的机读原因(仅统计端点可能携带)。取值词表取自规划层原因与 拒绝原因的**全量映射表**(唯一来源),本版实际会发出的有五个: raw_horizon/cube_horizon = 起点早于所要读表的保留截止; window_too_long = 请求跨度超过该形状的成本上限;window_invalid = 必填/倒序/`window` 时长串不可解析等参数本身非法;window_ambiguous = `from`/`to`/`window` 三者的"恰择一"未被满足(两态都给、只给一端、 或两态都不给)。offset/dst/span_below_grid 是"该窗口无法用卷积表精确 表达、已降级到原始行"的派生原因(只用于降级告警日志,不作为拒绝原因 发出)。
const ( CubeHorizon ErrorResponseReason = "cube_horizon" Dst ErrorResponseReason = "dst" Offset ErrorResponseReason = "offset" RawHorizon ErrorResponseReason = "raw_horizon" SpanBelowGrid ErrorResponseReason = "span_below_grid" WindowAmbiguous ErrorResponseReason = "window_ambiguous" WindowInvalid ErrorResponseReason = "window_invalid" WindowTooLong ErrorResponseReason = "window_too_long" )
Defines values for ErrorResponseReason.
type ErrorResponseStorage ¶
type ErrorResponseStorage string
ErrorResponseStorage 判定所依据的实际存储(`window_invalid`/`window_ambiguous` 不携带)
const ( ErrorResponseStorageCube ErrorResponseStorage = "cube" ErrorResponseStorageRaw ErrorResponseStorage = "raw" )
Defines values for ErrorResponseStorage.
type ForgotPasswordRequest ¶
type ForgotPasswordRequest struct {
Email string `json:"email"`
}
ForgotPasswordRequest defines model for ForgotPasswordRequest.
type GetUserErrLogsParams ¶
type GetUserErrLogsParams struct {
Limit *int `form:"limit,omitempty" json:"limit,omitempty"`
Cursor *int64 `form:"cursor,omitempty" json:"cursor,omitempty"`
GroupId *int64 `form:"group_id,omitempty" json:"group_id,omitempty"`
KeyId *int64 `form:"key_id,omitempty" json:"key_id,omitempty"`
Model *string `form:"model,omitempty" json:"model,omitempty"`
Format *RequestFormat `form:"format,omitempty" json:"format,omitempty"`
StatusCode *int `form:"status_code,omitempty" json:"status_code,omitempty"`
ErrorType *string `form:"error_type,omitempty" json:"error_type,omitempty"`
From time.Time `form:"from" json:"from"`
To time.Time `form:"to" json:"to"`
}
GetUserErrLogsParams defines parameters for GetUserErrLogs.
type GetUserKeysParams ¶
type GetUserKeysParams struct {
Limit *int `form:"limit,omitempty" json:"limit,omitempty"`
Offset *int `form:"offset,omitempty" json:"offset,omitempty"`
Name *string `form:"name,omitempty" json:"name,omitempty"`
Sort *string `form:"sort,omitempty" json:"sort,omitempty"`
Order *GetUserKeysParamsOrder `form:"order,omitempty" json:"order,omitempty"`
}
GetUserKeysParams defines parameters for GetUserKeys.
type GetUserKeysParamsOrder ¶
type GetUserKeysParamsOrder string
GetUserKeysParamsOrder defines parameters for GetUserKeys.
const ( GetUserKeysParamsOrderAsc GetUserKeysParamsOrder = "asc" GetUserKeysParamsOrderDesc GetUserKeysParamsOrder = "desc" )
Defines values for GetUserKeysParamsOrder.
type GetUserRedemptionsParams ¶
type GetUserRedemptionsParams struct {
Page *int `form:"page,omitempty" json:"page,omitempty"`
PageSize *int `form:"page_size,omitempty" json:"page_size,omitempty"`
Sort *string `form:"sort,omitempty" json:"sort,omitempty"`
Order *GetUserRedemptionsParamsOrder `form:"order,omitempty" json:"order,omitempty"`
}
GetUserRedemptionsParams defines parameters for GetUserRedemptions.
type GetUserRedemptionsParamsOrder ¶
type GetUserRedemptionsParamsOrder string
GetUserRedemptionsParamsOrder defines parameters for GetUserRedemptions.
const ( GetUserRedemptionsParamsOrderAsc GetUserRedemptionsParamsOrder = "asc" GetUserRedemptionsParamsOrderDesc GetUserRedemptionsParamsOrder = "desc" )
Defines values for GetUserRedemptionsParamsOrder.
type GetUserStatsParams ¶
type GetUserStatsParams struct {
From *time.Time `form:"from,omitempty" json:"from,omitempty"`
To *time.Time `form:"to,omitempty" json:"to,omitempty"`
// Window 相对窗口(时长串,Go `time.ParseDuration` 形态,如 `24h`/`168h`/`2160h`)。
// 给出它时**必须**省略 `from`/`to`(同时给出 → 400 `reason=window_ambiguous`)。
// 服务端自持时钟:`to` = 当前时刻向上取整到 UTC 整点、`from` = `to` − `window`
// ⇒ 两端恒整点,命中卷积表的精确分支(零对齐位移、零桶丢失),这就是 UI 预设
// 走这条形态的理由。
//
// **只收时长,不收日历天**:`d` 不是 `time.ParseDuration` 的单位,`7d` → 400
// (`reason=window_invalid`)。理由:`24h` 与"一个日历天"在 DST 切换日不相等,
// 而本 API 的唯一对齐基准是固定 1h 网格;另立 `AddDate` 日历语义会引入第二套
// 窗口长度语义。预设即网格整倍数:24h / 168h / 720h / 2160h。
Window *StatsWindow `form:"window,omitempty" json:"window,omitempty"`
Granularity *GetUserStatsParamsGranularity `form:"granularity,omitempty" json:"granularity,omitempty"`
Model *string `form:"model,omitempty" json:"model,omitempty"`
// Timezone IANA 时区名(如 Asia/Shanghai / America/New_York;控制台取浏览器时区)。
// 仅影响**分组读**:时间桶按该时区的本地小时/日界聚合。显式 from/to 恒为
// 绝对时刻直透,不受时区改写;排行/TTFT 等无分组数值端点接受并校验该参数
// 但不改变数值。空/缺省 = UTC(兼容旧客户端);未知名 → 400。overview 的
// 「今日」日界仍按该时区本地零点计算(窗口是 days,不是 from/to)。
//
// 窗口上限**不是一个固定天数**:界不齐时服务端把两端向后取整到整点以换取
// 卷积表快路径(生效窗口用 X-Stats-Effective-From/To 回显),能否用卷积表
// 取决于**时区偏移是否恒整点且窗内无 DST 跳变**;DST 或 :30/:45 偏移时区的
// 分组读只能扫原始明细行。成本上限是保留期无关的纯常量(分组原始行固定
// 8 天、卷积表 90 天),覆盖上限另有 per-table 保留期闸门(起点早于保留
// 截止 → 400)。两者的**真实数值见 GET /api/admin/stats/capabilities**。
Timezone *StatsTimezone `form:"timezone,omitempty" json:"timezone,omitempty"`
}
GetUserStatsParams defines parameters for GetUserStats.
type GetUserStatsParamsGranularity ¶
type GetUserStatsParamsGranularity string
GetUserStatsParamsGranularity defines parameters for GetUserStats.
const ( Day GetUserStatsParamsGranularity = "day" Hour GetUserStatsParamsGranularity = "hour" )
Defines values for GetUserStatsParamsGranularity.
type GetUserStatsTTFTParams ¶
type GetUserStatsTTFTParams struct {
From *time.Time `form:"from,omitempty" json:"from,omitempty"`
To *time.Time `form:"to,omitempty" json:"to,omitempty"`
// Window 相对窗口(时长串,Go `time.ParseDuration` 形态,如 `24h`/`168h`/`2160h`)。
// 给出它时**必须**省略 `from`/`to`(同时给出 → 400 `reason=window_ambiguous`)。
// 服务端自持时钟:`to` = 当前时刻向上取整到 UTC 整点、`from` = `to` − `window`
// ⇒ 两端恒整点,命中卷积表的精确分支(零对齐位移、零桶丢失),这就是 UI 预设
// 走这条形态的理由。
//
// **只收时长,不收日历天**:`d` 不是 `time.ParseDuration` 的单位,`7d` → 400
// (`reason=window_invalid`)。理由:`24h` 与"一个日历天"在 DST 切换日不相等,
// 而本 API 的唯一对齐基准是固定 1h 网格;另立 `AddDate` 日历语义会引入第二套
// 窗口长度语义。预设即网格整倍数:24h / 168h / 720h / 2160h。
Window *StatsWindow `form:"window,omitempty" json:"window,omitempty"`
Model *string `form:"model,omitempty" json:"model,omitempty"`
// Timezone IANA 时区名(如 Asia/Shanghai / America/New_York;控制台取浏览器时区)。
// 仅影响**分组读**:时间桶按该时区的本地小时/日界聚合。显式 from/to 恒为
// 绝对时刻直透,不受时区改写;排行/TTFT 等无分组数值端点接受并校验该参数
// 但不改变数值。空/缺省 = UTC(兼容旧客户端);未知名 → 400。overview 的
// 「今日」日界仍按该时区本地零点计算(窗口是 days,不是 from/to)。
//
// 窗口上限**不是一个固定天数**:界不齐时服务端把两端向后取整到整点以换取
// 卷积表快路径(生效窗口用 X-Stats-Effective-From/To 回显),能否用卷积表
// 取决于**时区偏移是否恒整点且窗内无 DST 跳变**;DST 或 :30/:45 偏移时区的
// 分组读只能扫原始明细行。成本上限是保留期无关的纯常量(分组原始行固定
// 8 天、卷积表 90 天),覆盖上限另有 per-table 保留期闸门(起点早于保留
// 截止 → 400)。两者的**真实数值见 GET /api/admin/stats/capabilities**。
Timezone *StatsTimezone `form:"timezone,omitempty" json:"timezone,omitempty"`
}
GetUserStatsTTFTParams defines parameters for GetUserStatsTTFT.
type GetUserUsageLogsParams ¶
type GetUserUsageLogsParams struct {
Limit *int `form:"limit,omitempty" json:"limit,omitempty"`
Cursor *int64 `form:"cursor,omitempty" json:"cursor,omitempty"`
GroupId *int64 `form:"group_id,omitempty" json:"group_id,omitempty"`
KeyId *int64 `form:"key_id,omitempty" json:"key_id,omitempty"`
Model *string `form:"model,omitempty" json:"model,omitempty"`
Format *RequestFormat `form:"format,omitempty" json:"format,omitempty"`
ErrorType *string `form:"error_type,omitempty" json:"error_type,omitempty"`
From time.Time `form:"from" json:"from"`
To time.Time `form:"to" json:"to"`
}
GetUserUsageLogsParams defines parameters for GetUserUsageLogs.
type Group ¶
type Group struct {
CreatedAt *time.Time `json:"CreatedAt,omitempty"`
// DeletedAt 软删除时间戳;null = 存活(列表/消费路径过滤已删;GET 单个可查已删项)
DeletedAt *time.Time `json:"DeletedAt"`
// Description 分组描述(空串 = 无描述)
Description *string `json:"Description,omitempty"`
ID *int64 `json:"ID,omitempty"`
Name *string `json:"Name,omitempty"`
// PriceMultiplier 价格倍率(正常值,1 = ×1,0 = 免费,上限 10 = ×10;API 边界与万分数换算——存储 15000 ↔ 显示 1.5)
PriceMultiplier *float64 `json:"PriceMultiplier,omitempty"`
// ProtocolConvert 协议转换方向集合(空数组 = off = 不转换;多方向按客户端格式命中)
ProtocolConvert *[]GroupProtocolConvert `json:"ProtocolConvert,omitempty"`
UpdatedAt *time.Time `json:"UpdatedAt,omitempty"`
Visibility *GroupVisibility `json:"Visibility,omitempty"`
}
Group defines model for Group.
type GroupProtocolConvert ¶
type GroupProtocolConvert string
GroupProtocolConvert 分组级协议转换方向(只补差,网关 internal/protoconv 消费):chat_to_resp = 客户端 chat → 模板 resp;mess_to_resp = anthropic messages → resp;resp_to_mess = resp → anthropic messages;chat_to_mess = chat → anthropic messages。off 不在枚举内——不转换 = 空数组(见 protocol_convert 字段说明)
const ( ChatToMess GroupProtocolConvert = "chat_to_mess" ChatToResp GroupProtocolConvert = "chat_to_resp" MessToResp GroupProtocolConvert = "mess_to_resp" RespToMess GroupProtocolConvert = "resp_to_mess" )
Defines values for GroupProtocolConvert.
type GroupVisibility ¶
type GroupVisibility string
GroupVisibility defines model for GroupVisibility.
const ( Private GroupVisibility = "private" Public GroupVisibility = "public" )
Defines values for GroupVisibility.
type InvalidParamFormatError ¶
func (*InvalidParamFormatError) Error ¶
func (e *InvalidParamFormatError) Error() string
func (*InvalidParamFormatError) Unwrap ¶
func (e *InvalidParamFormatError) Unwrap() error
type Key ¶
type Key struct {
CreatedAt *time.Time `json:"CreatedAt,omitempty"`
// DeletedAt 软删除时间戳;null = 存活(列表/鉴权过滤已删;GET 单个可查已删项)
DeletedAt *time.Time `json:"DeletedAt"`
GroupID *int64 `json:"GroupID,omitempty"`
// GroupName 归属分组名(只读投影;组非存活/未加载 → 空串,前端回退 `#<GroupID>`)
GroupName *string `json:"GroupName,omitempty"`
ID *int64 `json:"ID,omitempty"`
MaxConcurrency *int `json:"MaxConcurrency,omitempty"`
Name *string `json:"Name,omitempty"`
// Quota 累计最终计费金额上限(毫分,1 USD = 100,000 毫分);0 = 不限
Quota *int64 `json:"Quota,omitempty"`
// QuotaUsed 已消耗计费金额(毫分;后扣;无额度 key 恒 0)
QuotaUsed *int64 `json:"QuotaUsed,omitempty"`
Status *KeyStatus `json:"Status,omitempty"`
UpdatedAt *time.Time `json:"UpdatedAt,omitempty"`
UserID *int64 `json:"UserID,omitempty"`
// Key key 明文(长期可查看/复制;DB 泄露即暴露——自托管权衡,用户裁决)
Key *string `json:"key,omitempty"`
}
Key defines model for Key.
type KeyCreate ¶
type KeyCreate struct {
GroupId int64 `json:"group_id"`
// MaxConcurrency 单 key 在途上限;0 = 不限
MaxConcurrency *int `json:"max_concurrency,omitempty"`
Name string `json:"name"`
// Quota 累计最终计费金额上限(毫分,1 USD = 100,000 毫分);0 = 不限
Quota *int64 `json:"quota,omitempty"`
}
KeyCreate defines model for KeyCreate.
type KeyListResponse ¶
KeyListResponse defines model for KeyListResponse.
type KeyUpdate ¶
type KeyUpdate struct {
// GroupId 切换归属分组(可选;缺省 = 不改组。可选性同创建——public 或已授予 private;缺失/软删 → 404,未授予 → 400,<=0 → 400)
GroupId *int64 `json:"group_id,omitempty"`
MaxConcurrency *int `json:"max_concurrency,omitempty"`
Name *string `json:"name,omitempty"`
// Quota 累计最终计费金额上限(毫分,1 USD = 100,000 毫分);0 = 不限
Quota *int64 `json:"quota,omitempty"`
Status *KeyStatus `json:"status,omitempty"`
}
KeyUpdate defines model for KeyUpdate.
type ManagementKey ¶
type ManagementKey struct {
CreatedAt *time.Time `json:"created_at,omitempty"`
Id *int64 `json:"id,omitempty"`
// KeyRaw 管理 key 明文(前缀 mk-;长期可查看/复制——自托管权衡)
KeyRaw *string `json:"key_raw,omitempty"`
// Name 备注/标识(非唯一)
Name *string `json:"name,omitempty"`
Status *ManagementKeyStatus `json:"status,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
// UserId owner 用户 id
UserId *int64 `json:"user_id,omitempty"`
}
ManagementKey defines model for ManagementKey.
type ManagementKeyCreate ¶
type ManagementKeyCreate struct {
// Name 备注/标识(非唯一,非空)
Name string `json:"name"`
}
ManagementKeyCreate defines model for ManagementKeyCreate.
type ManagementKeyListResponse ¶
type ManagementKeyListResponse struct {
Rows []ManagementKey `json:"rows"`
}
ManagementKeyListResponse defines model for ManagementKeyListResponse.
type ManagementKeyStatus ¶
type ManagementKeyStatus string
ManagementKeyStatus defines model for ManagementKeyStatus.
const ( ManagementKeyStatusActive ManagementKeyStatus = "active" ManagementKeyStatusDisabled ManagementKeyStatus = "disabled" )
Defines values for ManagementKeyStatus.
type ManagementKeyUpdate ¶
type ManagementKeyUpdate struct {
Name *string `json:"name,omitempty"`
Status *ManagementKeyStatus `json:"status,omitempty"`
}
ManagementKeyUpdate defines model for ManagementKeyUpdate.
type PostUserAuthChangePasswordJSONRequestBody ¶
type PostUserAuthChangePasswordJSONRequestBody = UserAuthChangePassword
PostUserAuthChangePasswordJSONRequestBody defines body for PostUserAuthChangePassword for application/json ContentType.
type PostUserAuthForgotPasswordJSONRequestBody ¶
type PostUserAuthForgotPasswordJSONRequestBody = ForgotPasswordRequest
PostUserAuthForgotPasswordJSONRequestBody defines body for PostUserAuthForgotPassword for application/json ContentType.
type PostUserAuthLoginJSONRequestBody ¶
type PostUserAuthLoginJSONRequestBody = UserAuthLogin
PostUserAuthLoginJSONRequestBody defines body for PostUserAuthLogin for application/json ContentType.
type PostUserAuthRegisterCodeJSONRequestBody ¶
type PostUserAuthRegisterCodeJSONRequestBody = RegisterCodeRequest
PostUserAuthRegisterCodeJSONRequestBody defines body for PostUserAuthRegisterCode for application/json ContentType.
type PostUserAuthRegisterJSONRequestBody ¶
type PostUserAuthRegisterJSONRequestBody = UserAuthRegister
PostUserAuthRegisterJSONRequestBody defines body for PostUserAuthRegister for application/json ContentType.
type PostUserAuthResetPasswordJSONRequestBody ¶
type PostUserAuthResetPasswordJSONRequestBody = ResetPasswordRequest
PostUserAuthResetPasswordJSONRequestBody defines body for PostUserAuthResetPassword for application/json ContentType.
type PostUserKeysJSONRequestBody ¶
type PostUserKeysJSONRequestBody = KeyCreate
PostUserKeysJSONRequestBody defines body for PostUserKeys for application/json ContentType.
type PostUserManagementKeysJSONRequestBody ¶
type PostUserManagementKeysJSONRequestBody = ManagementKeyCreate
PostUserManagementKeysJSONRequestBody defines body for PostUserManagementKeys for application/json ContentType.
type PostUserRedemptionsJSONRequestBody ¶
type PostUserRedemptionsJSONRequestBody = RedeemRequest
PostUserRedemptionsJSONRequestBody defines body for PostUserRedemptions for application/json ContentType.
type PutUserBalanceWarningThresholdJSONRequestBody ¶
type PutUserBalanceWarningThresholdJSONRequestBody = BalanceWarningThresholdUpdate
PutUserBalanceWarningThresholdJSONRequestBody defines body for PutUserBalanceWarningThreshold for application/json ContentType.
type PutUserKeysIdJSONRequestBody ¶
type PutUserKeysIdJSONRequestBody = KeyUpdate
PutUserKeysIdJSONRequestBody defines body for PutUserKeysId for application/json ContentType.
type PutUserManagementKeysIdJSONRequestBody ¶
type PutUserManagementKeysIdJSONRequestBody = ManagementKeyUpdate
PutUserManagementKeysIdJSONRequestBody defines body for PutUserManagementKeysId for application/json ContentType.
type RedeemRequest ¶
type RedeemRequest struct {
Code string `json:"code"`
}
RedeemRequest defines model for RedeemRequest.
type RedeemResponse ¶
type RedeemResponse struct {
Applied struct {
ResourceExpiresAt *time.Time `json:"resource_expires_at"`
Type RedemptionType `json:"type"`
// Value 兑换时的值快照(同面值单位语义)
Value float64 `json:"value"`
} `json:"applied"`
}
RedeemResponse defines model for RedeemResponse.
type RedemptionRecord ¶
type RedemptionRecord struct {
Code string `json:"Code"`
CodeID int64 `json:"CodeID"`
CodeType RedemptionType `json:"CodeType"`
CreatedAt time.Time `json:"CreatedAt"`
ID int64 `json:"ID"`
Remark *string `json:"Remark"`
ResourceExpiresAt *time.Time `json:"ResourceExpiresAt"`
// Value 兑换时的值快照(同面值单位语义)
Value float64 `json:"Value"`
}
RedemptionRecord defines model for RedemptionRecord.
type RedemptionRecordListResponse ¶
type RedemptionRecordListResponse struct {
Rows []RedemptionRecord `json:"rows"`
Total int64 `json:"total"`
}
RedemptionRecordListResponse defines model for RedemptionRecordListResponse.
type RedemptionType ¶
type RedemptionType string
RedemptionType defines model for RedemptionType.
const ( Balance RedemptionType = "balance" Concurrency RedemptionType = "concurrency" TempBalance RedemptionType = "temp_balance" )
Defines values for RedemptionType.
type RegisterCodeRequest ¶
type RegisterCodeRequest struct {
Email string `json:"email"`
}
RegisterCodeRequest defines model for RegisterCodeRequest.
type RequestFormat ¶
type RequestFormat string
RequestFormat defines model for RequestFormat.
const ( Anthropic RequestFormat = "anthropic" OpenaiChat RequestFormat = "openai-chat" OpenaiImages RequestFormat = "openai-images" OpenaiResponses RequestFormat = "openai-responses" OpenaiResponsesWs RequestFormat = "openai-responses-ws" OpenaiSearch RequestFormat = "openai-search" )
Defines values for RequestFormat.
type RequiredHeaderError ¶
func (*RequiredHeaderError) Error ¶
func (e *RequiredHeaderError) Error() string
func (*RequiredHeaderError) Unwrap ¶
func (e *RequiredHeaderError) Unwrap() error
type RequiredParamError ¶
type RequiredParamError struct {
ParamName string
}
func (*RequiredParamError) Error ¶
func (e *RequiredParamError) Error() string
type ResetPasswordRequest ¶
type ResetPasswordRequest struct {
Code string `json:"code"`
Email string `json:"email"`
NewPassword string `json:"new_password"`
}
ResetPasswordRequest defines model for ResetPasswordRequest.
type SentResponse ¶
type SentResponse struct {
Sent bool `json:"sent"`
}
SentResponse defines model for SentResponse.
type ServerInterface ¶
type ServerInterface interface {
// 修改密码(旧密码校验复用登录语义——失败 401 同登录文案防枚举;新密码非空且 ≤72 字节,非法 400;不撤销既有 JWT,新密码下次登录生效)
// (POST /api/user/auth/change-password)
PostUserAuthChangePassword(w http.ResponseWriter, r *http.Request)
// 忘记密码发码(恒 200 {sent:true},反枚举——无论账号是否存在或邮件是否启用)
// (POST /api/user/auth/forgot-password)
PostUserAuthForgotPassword(w http.ResponseWriter, r *http.Request)
// 登录(bcrypt 校验 → JWT)
// (POST /api/user/auth/login)
PostUserAuthLogin(w http.ResponseWriter, r *http.Request)
// 当前用户信息(JWT)
// (GET /api/user/auth/me)
GetUserAuthMe(w http.ResponseWriter, r *http.Request)
// 注册(signup_enabled 开关检查;注册即登录返回 JWT)
// (POST /api/user/auth/register)
PostUserAuthRegister(w http.ResponseWriter, r *http.Request)
// 发送注册验证码(signup_enabled gate 403;已注册静默抑制仍 200;限频 429)
// (POST /api/user/auth/register-code)
PostUserAuthRegisterCode(w http.ResponseWriter, r *http.Request)
// 重置密码(验证码校验→更新密码;不撤销既有 JWT)
// (POST /api/user/auth/reset-password)
PostUserAuthResetPassword(w http.ResponseWriter, r *http.Request)
// 获取余额预警阈值(当前用户;0 = 关闭)
// (GET /api/user/balance-warning-threshold)
GetUserBalanceWarningThreshold(w http.ResponseWriter, r *http.Request)
// 设置余额预警阈值(USD;0 = 关闭;负值/非有限/正值舍入为0 拒绝)
// (PUT /api/user/balance-warning-threshold)
PutUserBalanceWarningThreshold(w http.ResponseWriter, r *http.Request)
// 我的错误明细(err_logs 完整错误面:拒绝 + 异常双轨;强制 user_id = 当前用户,防越权)
// (GET /api/user/err_logs)
GetUserErrLogs(w http.ResponseWriter, r *http.Request, params GetUserErrLogsParams)
// 可选组列表(public 全部 + 已授予 private;只读,key 创建时选组)
// (GET /api/user/groups)
GetUserGroups(w http.ResponseWriter, r *http.Request)
// 我的 key 列表(分页/排序;key 明文长期可查看/复制)
// (GET /api/user/keys)
GetUserKeys(w http.ResponseWriter, r *http.Request, params GetUserKeysParams)
// 创建 key(组可选性校验:public 或已授予 private;明文长期回显)
// (POST /api/user/keys)
PostUserKeys(w http.ResponseWriter, r *http.Request)
// 删除 key(仅本人;Auth 快照增量移除——立即失效)
// (DELETE /api/user/keys/{id})
DeleteUserKeysId(w http.ResponseWriter, r *http.Request, id int64)
// key 详情(仅本人;他人 key → 404)
// (GET /api/user/keys/{id})
GetUserKeysId(w http.ResponseWriter, r *http.Request, id int64)
// 更新 key(name/status/max_concurrency/quota;仅本人)
// (PUT /api/user/keys/{id})
PutUserKeysId(w http.ResponseWriter, r *http.Request, id int64)
// 轮换 key(仅本人;新明文生效,旧 key 立即失效)
// (POST /api/user/keys/{id}/rotate)
PostUserKeysIdRotate(w http.ResponseWriter, r *http.Request, id int64)
// 我的管理 key 列表(软删过滤;含明文 mk-,与客户端 key 一致)
// (GET /api/user/management-keys)
GetUserManagementKeys(w http.ResponseWriter, r *http.Request)
// 创建管理 key(以自身身份鉴权管理面;返回明文 mk-)
// (POST /api/user/management-keys)
PostUserManagementKeys(w http.ResponseWriter, r *http.Request)
// 删除管理 key(仅本人;软删 + 本实例快照即时移除)
// (DELETE /api/user/management-keys/{id})
DeleteUserManagementKeysId(w http.ResponseWriter, r *http.Request, id int64)
// 更新管理 key(name/status;仅本人;disabled 即时 401 可再启用)
// (PUT /api/user/management-keys/{id})
PutUserManagementKeysId(w http.ResponseWriter, r *http.Request, id int64)
// 我的兑换记录(use 快照 + 码的 type/remark 联查;强制 user_id = 当前用户,防越权)
// (GET /api/user/redemptions)
GetUserRedemptions(w http.ResponseWriter, r *http.Request, params GetUserRedemptionsParams)
// 兑换码(400 invalid code:不存在/失效/过期/用尽,统一不泄露细节;409 already redeemed 重复兑换)
// (POST /api/user/redemptions)
PostUserRedemptions(w http.ResponseWriter, r *http.Request)
// 我的用量统计(强制 user_id = 当前用户)
// (GET /api/user/stats)
GetUserStats(w http.ResponseWriter, r *http.Request, params GetUserStatsParams)
// 统计能力(本部署能查多久——与 /api/admin/stats/capabilities 同一投影)
// (GET /api/user/stats/capabilities)
GetUserStatsCapabilities(w http.ResponseWriter, r *http.Request)
// 我的 TTFT 聚合(强制 user_id = 当前用户)
// (GET /api/user/stats/ttft)
GetUserStatsTTFT(w http.ResponseWriter, r *http.Request, params GetUserStatsTTFTParams)
// 我的临时额度(仅有效额度:未过期且正余额,用尽/过期隐藏;expires_at 升序 FEFO 同序、永久最后;强制 user_id = 当前用户,无 user_id 参数防越权)
// (GET /api/user/temp-balances)
GetUserTempBalances(w http.ResponseWriter, r *http.Request)
// 我的用量明细(usage_logs 纯计费明细;强制 user_id = 当前用户,防越权;error_type 值域 none/abort)
// (GET /api/user/usage_logs)
GetUserUsageLogs(w http.ResponseWriter, r *http.Request, params GetUserUsageLogsParams)
}
ServerInterface represents all server handlers.
type ServerInterfaceWrapper ¶
type ServerInterfaceWrapper struct {
Handler ServerInterface
HandlerMiddlewares []MiddlewareFunc
ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}
ServerInterfaceWrapper converts contexts to parameters.
func (*ServerInterfaceWrapper) DeleteUserKeysId ¶
func (siw *ServerInterfaceWrapper) DeleteUserKeysId(w http.ResponseWriter, r *http.Request)
DeleteUserKeysId operation middleware
func (*ServerInterfaceWrapper) DeleteUserManagementKeysId ¶
func (siw *ServerInterfaceWrapper) DeleteUserManagementKeysId(w http.ResponseWriter, r *http.Request)
DeleteUserManagementKeysId operation middleware
func (*ServerInterfaceWrapper) GetUserAuthMe ¶
func (siw *ServerInterfaceWrapper) GetUserAuthMe(w http.ResponseWriter, r *http.Request)
GetUserAuthMe operation middleware
func (*ServerInterfaceWrapper) GetUserBalanceWarningThreshold ¶
func (siw *ServerInterfaceWrapper) GetUserBalanceWarningThreshold(w http.ResponseWriter, r *http.Request)
GetUserBalanceWarningThreshold operation middleware
func (*ServerInterfaceWrapper) GetUserErrLogs ¶
func (siw *ServerInterfaceWrapper) GetUserErrLogs(w http.ResponseWriter, r *http.Request)
GetUserErrLogs operation middleware
func (*ServerInterfaceWrapper) GetUserGroups ¶
func (siw *ServerInterfaceWrapper) GetUserGroups(w http.ResponseWriter, r *http.Request)
GetUserGroups operation middleware
func (*ServerInterfaceWrapper) GetUserKeys ¶
func (siw *ServerInterfaceWrapper) GetUserKeys(w http.ResponseWriter, r *http.Request)
GetUserKeys operation middleware
func (*ServerInterfaceWrapper) GetUserKeysId ¶
func (siw *ServerInterfaceWrapper) GetUserKeysId(w http.ResponseWriter, r *http.Request)
GetUserKeysId operation middleware
func (*ServerInterfaceWrapper) GetUserManagementKeys ¶
func (siw *ServerInterfaceWrapper) GetUserManagementKeys(w http.ResponseWriter, r *http.Request)
GetUserManagementKeys operation middleware
func (*ServerInterfaceWrapper) GetUserRedemptions ¶
func (siw *ServerInterfaceWrapper) GetUserRedemptions(w http.ResponseWriter, r *http.Request)
GetUserRedemptions operation middleware
func (*ServerInterfaceWrapper) GetUserStats ¶
func (siw *ServerInterfaceWrapper) GetUserStats(w http.ResponseWriter, r *http.Request)
GetUserStats operation middleware
func (*ServerInterfaceWrapper) GetUserStatsCapabilities ¶
func (siw *ServerInterfaceWrapper) GetUserStatsCapabilities(w http.ResponseWriter, r *http.Request)
GetUserStatsCapabilities operation middleware
func (*ServerInterfaceWrapper) GetUserStatsTTFT ¶
func (siw *ServerInterfaceWrapper) GetUserStatsTTFT(w http.ResponseWriter, r *http.Request)
GetUserStatsTTFT operation middleware
func (*ServerInterfaceWrapper) GetUserTempBalances ¶
func (siw *ServerInterfaceWrapper) GetUserTempBalances(w http.ResponseWriter, r *http.Request)
GetUserTempBalances operation middleware
func (*ServerInterfaceWrapper) GetUserUsageLogs ¶
func (siw *ServerInterfaceWrapper) GetUserUsageLogs(w http.ResponseWriter, r *http.Request)
GetUserUsageLogs operation middleware
func (*ServerInterfaceWrapper) PostUserAuthChangePassword ¶
func (siw *ServerInterfaceWrapper) PostUserAuthChangePassword(w http.ResponseWriter, r *http.Request)
PostUserAuthChangePassword operation middleware
func (*ServerInterfaceWrapper) PostUserAuthForgotPassword ¶
func (siw *ServerInterfaceWrapper) PostUserAuthForgotPassword(w http.ResponseWriter, r *http.Request)
PostUserAuthForgotPassword operation middleware
func (*ServerInterfaceWrapper) PostUserAuthLogin ¶
func (siw *ServerInterfaceWrapper) PostUserAuthLogin(w http.ResponseWriter, r *http.Request)
PostUserAuthLogin operation middleware
func (*ServerInterfaceWrapper) PostUserAuthRegister ¶
func (siw *ServerInterfaceWrapper) PostUserAuthRegister(w http.ResponseWriter, r *http.Request)
PostUserAuthRegister operation middleware
func (*ServerInterfaceWrapper) PostUserAuthRegisterCode ¶
func (siw *ServerInterfaceWrapper) PostUserAuthRegisterCode(w http.ResponseWriter, r *http.Request)
PostUserAuthRegisterCode operation middleware
func (*ServerInterfaceWrapper) PostUserAuthResetPassword ¶
func (siw *ServerInterfaceWrapper) PostUserAuthResetPassword(w http.ResponseWriter, r *http.Request)
PostUserAuthResetPassword operation middleware
func (*ServerInterfaceWrapper) PostUserKeys ¶
func (siw *ServerInterfaceWrapper) PostUserKeys(w http.ResponseWriter, r *http.Request)
PostUserKeys operation middleware
func (*ServerInterfaceWrapper) PostUserKeysIdRotate ¶
func (siw *ServerInterfaceWrapper) PostUserKeysIdRotate(w http.ResponseWriter, r *http.Request)
PostUserKeysIdRotate operation middleware
func (*ServerInterfaceWrapper) PostUserManagementKeys ¶
func (siw *ServerInterfaceWrapper) PostUserManagementKeys(w http.ResponseWriter, r *http.Request)
PostUserManagementKeys operation middleware
func (*ServerInterfaceWrapper) PostUserRedemptions ¶
func (siw *ServerInterfaceWrapper) PostUserRedemptions(w http.ResponseWriter, r *http.Request)
PostUserRedemptions operation middleware
func (*ServerInterfaceWrapper) PutUserBalanceWarningThreshold ¶
func (siw *ServerInterfaceWrapper) PutUserBalanceWarningThreshold(w http.ResponseWriter, r *http.Request)
PutUserBalanceWarningThreshold operation middleware
func (*ServerInterfaceWrapper) PutUserKeysId ¶
func (siw *ServerInterfaceWrapper) PutUserKeysId(w http.ResponseWriter, r *http.Request)
PutUserKeysId operation middleware
func (*ServerInterfaceWrapper) PutUserManagementKeysId ¶
func (siw *ServerInterfaceWrapper) PutUserManagementKeysId(w http.ResponseWriter, r *http.Request)
PutUserManagementKeysId operation middleware
type StatTTFTSummary ¶
type StatTTFTSummary struct {
AvgMS float64 `json:"AvgMS"`
Count int64 `json:"Count"`
MaxMS int64 `json:"MaxMS"`
P50MS int64 `json:"P50MS"`
P95MS int64 `json:"P95MS"`
P99MS int64 `json:"P99MS"`
Source StatTTFTSummarySource `json:"Source"`
}
StatTTFTSummary defines model for StatTTFTSummary.
type StatTTFTSummarySource ¶
type StatTTFTSummarySource string
StatTTFTSummarySource defines model for StatTTFTSummary.Source.
const ( Exact StatTTFTSummarySource = "exact" Sketch StatTTFTSummarySource = "sketch" )
Defines values for StatTTFTSummarySource.
type StatTrendPoint ¶
type StatTrendPoint struct {
BucketTime *time.Time `json:"BucketTime,omitempty"`
CacheCreationTokens *int64 `json:"CacheCreationTokens,omitempty"`
CacheReadTokens *int64 `json:"CacheReadTokens,omitempty"`
CallCount *int64 `json:"CallCount,omitempty"`
// Cost 成本 USD(毫分 /1e5)
Cost *float64 `json:"Cost,omitempty"`
ErrorCount *int64 `json:"ErrorCount,omitempty"`
InputTokens *int64 `json:"InputTokens,omitempty"`
OutputTokens *int64 `json:"OutputTokens,omitempty"`
// RawCost 原始成本 USD(毫分 /1e5)
RawCost *float64 `json:"RawCost,omitempty"`
RequestCount *int64 `json:"RequestCount,omitempty"`
// TTFTAvgMS TTFT 平均毫秒(TTFTTotalMS/TTFTCount,无样本 0)
TTFTAvgMS *float64 `json:"TTFTAvgMS,omitempty"`
// TTFTMaxMS TTFT 最大毫秒
TTFTMaxMS *int64 `json:"TTFTMaxMS,omitempty"`
TotalTokens *int64 `json:"TotalTokens,omitempty"`
}
StatTrendPoint defines model for StatTrendPoint.
type StatsCapabilities ¶
type StatsCapabilities struct {
// BucketGridSeconds 卷积表桶网格单位(秒;恒 3600 = 1 小时)
BucketGridSeconds int `json:"bucket_grid_seconds"`
// Kinds 键 = 读形状标识(trend/entity_trend/summary/days/top/ttft_sketch/ttft_exact/usage_agg/usage_list/errlog_list)
Kinds map[string]StatsKindCapability `json:"kinds"`
}
StatsCapabilities defines model for StatsCapabilities.
type StatsKindCapability ¶
type StatsKindCapability struct {
// CostCapSeconds 每候选存储的最大跨度秒数(保留期无关的纯常量;0 = 无上限)
CostCapSeconds map[string]int64 `json:"cost_cap_seconds"`
// CoverageDays 每候选存储实际读表的保留天数(读多表取最保守者;0 = 该表未启用分区保留,覆盖守卫关闭)
CoverageDays map[string]int `json:"coverage_days"`
// Grouping 读形状的分组模式:`zoned` = 按请求时区分组(桶界随时区变);`none` =
// 数值与请求时区无关。刻意不写 enum:enum 会为一个取值是 `none` 的字段
// 生成名为 `None` 的常量,与既有 `ErrorType` 枚举的 `None` 撞名,触发
// oapi-codegen 把该枚举九个常量全部改名(无关生成的额外改动)。
Grouping string `json:"grouping"`
// Storages 候选存储(按偏好序)
Storages []StatsKindCapabilityStorages `json:"storages"`
}
StatsKindCapability defines model for StatsKindCapability.
type StatsKindCapabilityStorages ¶
type StatsKindCapabilityStorages string
StatsKindCapabilityStorages defines model for StatsKindCapability.Storages.
const ( StatsKindCapabilityStoragesCube StatsKindCapabilityStorages = "cube" StatsKindCapabilityStoragesRaw StatsKindCapabilityStorages = "raw" )
Defines values for StatsKindCapabilityStorages.
type TempBalanceRow ¶
type TempBalanceRow struct {
// AmountUsd 金额 USD(毫分 /1e5;1 USD = 100,000 毫分)
AmountUsd float64 `json:"amount_usd"`
// ExpiresAt 到期时间;null = 永久额度
ExpiresAt *time.Time `json:"expires_at"`
Id int64 `json:"id"`
// Note 固定系统备注(signup bonus / redemption code),无敏感信息
Note *string `json:"note"`
}
TempBalanceRow defines model for TempBalanceRow.
type TempBalancesResponse ¶
type TempBalancesResponse struct {
Rows []TempBalanceRow `json:"rows"`
// TotalUsd 有效额度合计 USD(毫分 Σ /1e5;0 = 无有效额度)
TotalUsd float64 `json:"total_usd"`
}
TempBalancesResponse defines model for TempBalancesResponse.
type TooManyValuesForParamError ¶
func (*TooManyValuesForParamError) Error ¶
func (e *TooManyValuesForParamError) Error() string
type UnescapedCookieParamError ¶
func (*UnescapedCookieParamError) Error ¶
func (e *UnescapedCookieParamError) Error() string
func (*UnescapedCookieParamError) Unwrap ¶
func (e *UnescapedCookieParamError) Unwrap() error
type Unimplemented ¶
type Unimplemented struct{}
func (Unimplemented) DeleteUserKeysId ¶
func (_ Unimplemented) DeleteUserKeysId(w http.ResponseWriter, r *http.Request, id int64)
删除 key(仅本人;Auth 快照增量移除——立即失效) (DELETE /api/user/keys/{id})
func (Unimplemented) DeleteUserManagementKeysId ¶
func (_ Unimplemented) DeleteUserManagementKeysId(w http.ResponseWriter, r *http.Request, id int64)
删除管理 key(仅本人;软删 + 本实例快照即时移除) (DELETE /api/user/management-keys/{id})
func (Unimplemented) GetUserAuthMe ¶
func (_ Unimplemented) GetUserAuthMe(w http.ResponseWriter, r *http.Request)
当前用户信息(JWT) (GET /api/user/auth/me)
func (Unimplemented) GetUserBalanceWarningThreshold ¶
func (_ Unimplemented) GetUserBalanceWarningThreshold(w http.ResponseWriter, r *http.Request)
获取余额预警阈值(当前用户;0 = 关闭) (GET /api/user/balance-warning-threshold)
func (Unimplemented) GetUserErrLogs ¶
func (_ Unimplemented) GetUserErrLogs(w http.ResponseWriter, r *http.Request, params GetUserErrLogsParams)
我的错误明细(err_logs 完整错误面:拒绝 + 异常双轨;强制 user_id = 当前用户,防越权) (GET /api/user/err_logs)
func (Unimplemented) GetUserGroups ¶
func (_ Unimplemented) GetUserGroups(w http.ResponseWriter, r *http.Request)
可选组列表(public 全部 + 已授予 private;只读,key 创建时选组) (GET /api/user/groups)
func (Unimplemented) GetUserKeys ¶
func (_ Unimplemented) GetUserKeys(w http.ResponseWriter, r *http.Request, params GetUserKeysParams)
我的 key 列表(分页/排序;key 明文长期可查看/复制) (GET /api/user/keys)
func (Unimplemented) GetUserKeysId ¶
func (_ Unimplemented) GetUserKeysId(w http.ResponseWriter, r *http.Request, id int64)
key 详情(仅本人;他人 key → 404) (GET /api/user/keys/{id})
func (Unimplemented) GetUserManagementKeys ¶
func (_ Unimplemented) GetUserManagementKeys(w http.ResponseWriter, r *http.Request)
我的管理 key 列表(软删过滤;含明文 mk-,与客户端 key 一致) (GET /api/user/management-keys)
func (Unimplemented) GetUserRedemptions ¶
func (_ Unimplemented) GetUserRedemptions(w http.ResponseWriter, r *http.Request, params GetUserRedemptionsParams)
我的兑换记录(use 快照 + 码的 type/remark 联查;强制 user_id = 当前用户,防越权) (GET /api/user/redemptions)
func (Unimplemented) GetUserStats ¶
func (_ Unimplemented) GetUserStats(w http.ResponseWriter, r *http.Request, params GetUserStatsParams)
我的用量统计(强制 user_id = 当前用户) (GET /api/user/stats)
func (Unimplemented) GetUserStatsCapabilities ¶
func (_ Unimplemented) GetUserStatsCapabilities(w http.ResponseWriter, r *http.Request)
统计能力(本部署能查多久——与 /api/admin/stats/capabilities 同一投影) (GET /api/user/stats/capabilities)
func (Unimplemented) GetUserStatsTTFT ¶
func (_ Unimplemented) GetUserStatsTTFT(w http.ResponseWriter, r *http.Request, params GetUserStatsTTFTParams)
我的 TTFT 聚合(强制 user_id = 当前用户) (GET /api/user/stats/ttft)
func (Unimplemented) GetUserTempBalances ¶
func (_ Unimplemented) GetUserTempBalances(w http.ResponseWriter, r *http.Request)
我的临时额度(仅有效额度:未过期且正余额,用尽/过期隐藏;expires_at 升序 FEFO 同序、永久最后;强制 user_id = 当前用户,无 user_id 参数防越权) (GET /api/user/temp-balances)
func (Unimplemented) GetUserUsageLogs ¶
func (_ Unimplemented) GetUserUsageLogs(w http.ResponseWriter, r *http.Request, params GetUserUsageLogsParams)
我的用量明细(usage_logs 纯计费明细;强制 user_id = 当前用户,防越权;error_type 值域 none/abort) (GET /api/user/usage_logs)
func (Unimplemented) PostUserAuthChangePassword ¶
func (_ Unimplemented) PostUserAuthChangePassword(w http.ResponseWriter, r *http.Request)
修改密码(旧密码校验复用登录语义——失败 401 同登录文案防枚举;新密码非空且 ≤72 字节,非法 400;不撤销既有 JWT,新密码下次登录生效) (POST /api/user/auth/change-password)
func (Unimplemented) PostUserAuthForgotPassword ¶
func (_ Unimplemented) PostUserAuthForgotPassword(w http.ResponseWriter, r *http.Request)
忘记密码发码(恒 200 {sent:true},反枚举——无论账号是否存在或邮件是否启用) (POST /api/user/auth/forgot-password)
func (Unimplemented) PostUserAuthLogin ¶
func (_ Unimplemented) PostUserAuthLogin(w http.ResponseWriter, r *http.Request)
登录(bcrypt 校验 → JWT) (POST /api/user/auth/login)
func (Unimplemented) PostUserAuthRegister ¶
func (_ Unimplemented) PostUserAuthRegister(w http.ResponseWriter, r *http.Request)
注册(signup_enabled 开关检查;注册即登录返回 JWT) (POST /api/user/auth/register)
func (Unimplemented) PostUserAuthRegisterCode ¶
func (_ Unimplemented) PostUserAuthRegisterCode(w http.ResponseWriter, r *http.Request)
发送注册验证码(signup_enabled gate 403;已注册静默抑制仍 200;限频 429) (POST /api/user/auth/register-code)
func (Unimplemented) PostUserAuthResetPassword ¶
func (_ Unimplemented) PostUserAuthResetPassword(w http.ResponseWriter, r *http.Request)
重置密码(验证码校验→更新密码;不撤销既有 JWT) (POST /api/user/auth/reset-password)
func (Unimplemented) PostUserKeys ¶
func (_ Unimplemented) PostUserKeys(w http.ResponseWriter, r *http.Request)
创建 key(组可选性校验:public 或已授予 private;明文长期回显) (POST /api/user/keys)
func (Unimplemented) PostUserKeysIdRotate ¶
func (_ Unimplemented) PostUserKeysIdRotate(w http.ResponseWriter, r *http.Request, id int64)
轮换 key(仅本人;新明文生效,旧 key 立即失效) (POST /api/user/keys/{id}/rotate)
func (Unimplemented) PostUserManagementKeys ¶
func (_ Unimplemented) PostUserManagementKeys(w http.ResponseWriter, r *http.Request)
创建管理 key(以自身身份鉴权管理面;返回明文 mk-) (POST /api/user/management-keys)
func (Unimplemented) PostUserRedemptions ¶
func (_ Unimplemented) PostUserRedemptions(w http.ResponseWriter, r *http.Request)
兑换码(400 invalid code:不存在/失效/过期/用尽,统一不泄露细节;409 already redeemed 重复兑换) (POST /api/user/redemptions)
func (Unimplemented) PutUserBalanceWarningThreshold ¶
func (_ Unimplemented) PutUserBalanceWarningThreshold(w http.ResponseWriter, r *http.Request)
设置余额预警阈值(USD;0 = 关闭;负值/非有限/正值舍入为0 拒绝) (PUT /api/user/balance-warning-threshold)
func (Unimplemented) PutUserKeysId ¶
func (_ Unimplemented) PutUserKeysId(w http.ResponseWriter, r *http.Request, id int64)
更新 key(name/status/max_concurrency/quota;仅本人) (PUT /api/user/keys/{id})
func (Unimplemented) PutUserManagementKeysId ¶
func (_ Unimplemented) PutUserManagementKeysId(w http.ResponseWriter, r *http.Request, id int64)
更新管理 key(name/status;仅本人;disabled 即时 401 可再启用) (PUT /api/user/management-keys/{id})
type UnmarshalingParamError ¶
func (*UnmarshalingParamError) Error ¶
func (e *UnmarshalingParamError) Error() string
func (*UnmarshalingParamError) Unwrap ¶
func (e *UnmarshalingParamError) Unwrap() error
type User ¶
type User struct {
// Balance 余额 USD(浮点;内部存储毫分——1 USD = 100,000 毫分,API 边界换算)
Balance *float64 `json:"Balance,omitempty"`
CreatedAt *time.Time `json:"CreatedAt,omitempty"`
Email *string `json:"Email,omitempty"`
ID *int64 `json:"ID,omitempty"`
MaxConcurrency *int `json:"MaxConcurrency,omitempty"`
Role *UserRole `json:"Role,omitempty"`
Status *UserStatus `json:"Status,omitempty"`
UpdatedAt *time.Time `json:"UpdatedAt,omitempty"`
}
User defines model for User.
type UserAPI ¶
type UserAPI struct {
// contains filtered or unexported fields
}
UserAPI 实现生成的 ServerInterface(user 面唯一实现)。
func (*UserAPI) DeleteUserKeysId ¶
DeleteUserKeysId 删除 key(仅本人;Auth 快照增量移除——立即失效, ServerInterface)。
func (*UserAPI) DeleteUserManagementKeysId ¶
DeleteUserManagementKeysId 删除管理 key(仅本人;软删 + 本实例快照即时移除, ServerInterface)。
func (*UserAPI) GetUserAuthMe ¶
func (h *UserAPI) GetUserAuthMe(w http.ResponseWriter, r *http.Request)
GetUserAuthMe 当前用户信息(JWT 已由 Router 中间件验证,ServerInterface)。
func (*UserAPI) GetUserBalanceWarningThreshold ¶
func (h *UserAPI) GetUserBalanceWarningThreshold(w http.ResponseWriter, r *http.Request)
func (*UserAPI) GetUserErrLogs ¶
func (h *UserAPI) GetUserErrLogs(w http.ResponseWriter, r *http.Request, params GetUserErrLogsParams)
GetUserErrLogs 我的错误明细(/api/user/err_logs:完整错误面——本地拒绝 + 半异常 双轨;强制 user_id = 当前用户,防越权)。keyset 游标分页与 /api/user/usage_logs 同语义(cursor 透传仅本人行内生效;limit 归一/探测走 httpface.LogLimit + ClipLogPage,C2 消重)。
func (*UserAPI) GetUserGroups ¶
func (h *UserAPI) GetUserGroups(w http.ResponseWriter, r *http.Request)
GetUserGroups 可选组列表(public 全部 + 已授予 private;只读——组管理是 平台面职责,key 创建时在此选组,ServerInterface)。
func (*UserAPI) GetUserKeys ¶
func (h *UserAPI) GetUserKeys(w http.ResponseWriter, r *http.Request, params GetUserKeysParams)
GetUserKeys 我的 key 列表(分页/排序;明文长期回显,ServerInterface)。
func (*UserAPI) GetUserKeysId ¶
GetUserKeysId key 详情(仅本人;他人 key → 404,ServerInterface)。
func (*UserAPI) GetUserManagementKeys ¶
func (h *UserAPI) GetUserManagementKeys(w http.ResponseWriter, r *http.Request)
GetUserManagementKeys 我的管理 key 列表(软删过滤;含明文,ServerInterface)。
func (*UserAPI) GetUserRedemptions ¶
func (h *UserAPI) GetUserRedemptions(w http.ResponseWriter, r *http.Request, params GetUserRedemptionsParams)
GetUserRedemptions 我的兑换记录(use 快照 + 码的 type/remark 联查;强制 user_id = 当前用户,ServerInterface)。
func (*UserAPI) GetUserStats ¶
func (h *UserAPI) GetUserStats(w http.ResponseWriter, r *http.Request, params GetUserStatsParams)
GetUserStats 我的用量统计(强制 user_id = 当前用户;granularity 缺省 day; timezone = 浏览器时区,缺省 UTC——分组路由见 repository)。
func (*UserAPI) GetUserStatsCapabilities ¶
func (h *UserAPI) GetUserStatsCapabilities(w http.ResponseWriter, r *http.Request)
GetUserStatsCapabilities 用户台的统计能力(与 /api/admin/stats/capabilities 同一份服务端投影——service.StatsCapabilities 是唯一来源,本层只做形状映射, 零字面量)。存在的理由:用户台的选择器裁剪与 TTFT 窗口上限同样需要按部署 取值,而 /api/admin/* 只接受 platform_admin 凭据(普通用户拿不到)。
func (*UserAPI) GetUserStatsTTFT ¶
func (h *UserAPI) GetUserStatsTTFT(w http.ResponseWriter, r *http.Request, params GetUserStatsTTFTParams)
GetUserStatsTTFT 我的 TTFT 聚合(强制 user_id = 当前用户)。数值与 时区无关;`timezone` 仅接受并校验(非法 400),不进查询。窗口形态解码/ 时钟同 GetUserStats。
func (*UserAPI) GetUserTempBalances ¶
func (h *UserAPI) GetUserTempBalances(w http.ResponseWriter, r *http.Request)
GetUserTempBalances 我的临时额度(强制 user_id = 当前用户,无 user_id 参数 ——对齐 /api/user/stats 模式防越权,ServerInterface)。
func (*UserAPI) GetUserUsageLogs ¶
func (h *UserAPI) GetUserUsageLogs(w http.ResponseWriter, r *http.Request, params GetUserUsageLogsParams)
GetUserUsageLogs 我的用量明细(/api/user/usage_logs;强制 user_id = 当前用户—— 越权过滤在 service/repo 层,请求侧不可指定他人,ServerInterface)。 keyset 游标分页:cursor 透传仅作本人行内 id 下界(跨页注入他人 id 仍被 user_id 过滤钳制),next_cursor 组装与 admin 侧同构(limit 归一/探测走 httpface.LogLimit + ClipLogPage,C2 消重)。
func (*UserAPI) PostUserAuthChangePassword ¶
func (h *UserAPI) PostUserAuthChangePassword(w http.ResponseWriter, r *http.Request)
PostUserAuthChangePassword 修改密码:旧密码校验复用登录语义(失败 401 同 登录文案防枚举)+ 新密码非空/≤72 字节(非法 400)→ bcrypt 重哈希落库。 **改密即撤销既有 JWT**(token_version 原子递增 + 快照比对——本响应返回后 当前会话同样失效,需重新登录,spec 2026-08-25-jwt-password-revocation, ServerInterface)。
func (*UserAPI) PostUserAuthForgotPassword ¶
func (h *UserAPI) PostUserAuthForgotPassword(w http.ResponseWriter, r *http.Request)
PostUserAuthForgotPassword 忘记密码发码(恒 200 反枚举)。发送失败不再静默 吞:记 Warn 后仍返回 200(反枚举语义不变——响应码/体不泄露邮箱是否存在)。
func (*UserAPI) PostUserAuthLogin ¶
func (h *UserAPI) PostUserAuthLogin(w http.ResponseWriter, r *http.Request)
PostUserAuthLogin 登录:bcrypt 校验 → JWT(ServerInterface)。
func (*UserAPI) PostUserAuthRegister ¶
func (h *UserAPI) PostUserAuthRegister(w http.ResponseWriter, r *http.Request)
PostUserAuthRegister 注册(signup_enabled 开关检查在 service;注册即登录: 直接签发 JWT 返回,ServerInterface)。code 可选:verif=on 时必填(缺→400 sentinel),verif=off 时忽略。
func (*UserAPI) PostUserAuthRegisterCode ¶
func (h *UserAPI) PostUserAuthRegisterCode(w http.ResponseWriter, r *http.Request)
PostUserAuthRegisterCode 发送注册验证码(public)。
func (*UserAPI) PostUserAuthResetPassword ¶
func (h *UserAPI) PostUserAuthResetPassword(w http.ResponseWriter, r *http.Request)
PostUserAuthResetPassword 重置密码(验证码校验→更新密码;改密即撤销—— 该用户全部既有 JWT 401,spec 2026-08-25-jwt-password-revocation)。
func (*UserAPI) PostUserKeys ¶
func (h *UserAPI) PostUserKeys(w http.ResponseWriter, r *http.Request)
PostUserKeys 创建 key(组可选性校验:public 或已授予 private;明文长期回显, ServerInterface)。
func (*UserAPI) PostUserKeysIdRotate ¶
PostUserKeysIdRotate 轮换 key(仅本人;新明文生效,旧 key 立即失效, ServerInterface)。
func (*UserAPI) PostUserManagementKeys ¶
func (h *UserAPI) PostUserManagementKeys(w http.ResponseWriter, r *http.Request)
PostUserManagementKeys 创建管理 key(以自身身份鉴权管理面;返回明文 mk-, ServerInterface)。
func (*UserAPI) PostUserRedemptions ¶
func (h *UserAPI) PostUserRedemptions(w http.ResponseWriter, r *http.Request)
PostUserRedemptions 兑换码(ServerInterface):400 invalid code(不存在/失效/ 过期/用尽,统一不泄露细节,决策 7)、409 already redeemed(重复兑换)。
func (*UserAPI) PutUserBalanceWarningThreshold ¶
func (h *UserAPI) PutUserBalanceWarningThreshold(w http.ResponseWriter, r *http.Request)
func (*UserAPI) PutUserKeysId ¶
PutUserKeysId 更新 key(name/status/max_concurrency/quota;仅本人, ServerInterface)。
func (*UserAPI) PutUserManagementKeysId ¶
PutUserManagementKeysId 更新管理 key(name/status;仅本人;disabled 即时 401 可再启用,ServerInterface)。
type UserAuthChangePassword ¶
type UserAuthChangePassword struct {
// NewPassword 非空且 ≤72 字节(bcrypt 截断限制),非法 400
NewPassword string `json:"new_password"`
OldPassword string `json:"old_password"`
}
UserAuthChangePassword defines model for UserAuthChangePassword.
type UserAuthLogin ¶
UserAuthLogin defines model for UserAuthLogin.
type UserAuthRegister ¶
type UserAuthRegister struct {
// Code 可选:邮箱验证码(mail.register_verification 开启时必填,否则 400 email verification required)
Code *string `json:"code,omitempty"`
Email string `json:"email"`
Password string `json:"password"`
}
UserAuthRegister defines model for UserAuthRegister.
type UserAuthResponse ¶
UserAuthResponse defines model for UserAuthResponse.
type UserErrLog ¶
type UserErrLog struct {
// BillingTier 计费档位(service_tier 归一化:priority/flex/fast/auto);null = 未计费路径
BillingTier *string `json:"BillingTier"`
// ClientIP 客户端 IP(CF-Connecting-IP / True-Client-IP / X-Real-IP 按序识别;无则 RemoteAddr 剥端口);空 = 无
ClientIP *string `json:"ClientIP,omitempty"`
CreatedAt *time.Time `json:"CreatedAt,omitempty"`
// ErrorMessage 错误文本(拒绝文案/上游 body,域内截断 500 字符);null = 无错误文本
ErrorMessage *string `json:"ErrorMessage"`
ErrorType *ErrorType `json:"ErrorType,omitempty"`
Format *RequestFormat `json:"Format,omitempty"`
GroupID *int64 `json:"GroupID,omitempty"`
ID *int64 `json:"ID,omitempty"`
// KeyID 鉴权归属 key;0 = 无
KeyID *int64 `json:"KeyID,omitempty"`
LatencyMS *int64 `json:"LatencyMS,omitempty"`
Model *string `json:"Model,omitempty"`
RequestID *string `json:"RequestID,omitempty"`
// StatusCode 错误状态码(完整错误面;0 = 连接级)
StatusCode *int `json:"StatusCode,omitempty"`
// UserID 鉴权归属用户;0 = 无
UserID *int64 `json:"UserID,omitempty"`
}
UserErrLog 用户面错误明细(= ErrLog 删 AccountID/TemplateID——用户无上游账号拓扑概念)
type UserErrLogsResponse ¶
type UserErrLogsResponse struct {
// NextCursor 下一页游标(本页最后一条 id);null = 无更多行
NextCursor *int64 `json:"next_cursor"`
Rows []UserErrLog `json:"rows"`
}
UserErrLogsResponse defines model for UserErrLogsResponse.
type UserLogsResponse ¶
type UserLogsResponse struct {
// NextCursor 下一页游标(本页最后一条 id);null = 无更多行
NextCursor *int64 `json:"next_cursor"`
Rows []UserUsageLog `json:"rows"`
}
UserLogsResponse defines model for UserLogsResponse.
type UserStatus ¶
type UserStatus string
UserStatus defines model for UserStatus.
const ( Active UserStatus = "active" Disabled UserStatus = "disabled" )
Defines values for UserStatus.
type UserUsageLog ¶
type UserUsageLog struct {
// AboveHit 任一分量超 above 阈值命中分段
AboveHit *bool `json:"AboveHit,omitempty"`
// BillingTier 请求 service_tier 归一化值(priority/flex/fast/auto);空 = 未计费路径
BillingTier *string `json:"BillingTier,omitempty"`
CacheCreationTokens *int64 `json:"CacheCreationTokens,omitempty"`
CacheReadTokens *int64 `json:"CacheReadTokens,omitempty"`
// ClientIP 客户端 IP(CF-Connecting-IP / True-Client-IP / X-Real-IP 按序识别;无则 RemoteAddr 剥端口);空 = 无
ClientIP *string `json:"ClientIP,omitempty"`
// Cost 计费成本(毫分,1 USD = 100,000 毫分);错误请求(402/4xx)为 0
Cost *int64 `json:"Cost,omitempty"`
CreatedAt *time.Time `json:"CreatedAt,omitempty"`
ErrorType *ErrorType `json:"ErrorType,omitempty"`
Format *RequestFormat `json:"Format,omitempty"`
GroupID *int64 `json:"GroupID,omitempty"`
ID *int64 `json:"ID,omitempty"`
InputTokens *int64 `json:"InputTokens,omitempty"`
// KeyID 鉴权归属 key;0 = 无
KeyID *int64 `json:"KeyID,omitempty"`
LatencyMS *int64 `json:"LatencyMS,omitempty"`
MappedModel *string `json:"MappedModel"`
Model *string `json:"Model,omitempty"`
OutputTokens *int64 `json:"OutputTokens,omitempty"`
// Overdraft 本次扣费透支(余额不足扣为负余额)
Overdraft *bool `json:"Overdraft,omitempty"`
// PriceCacheCreationMillis 缓存写单价快照(每 M token 毫分);null = 该请求无缓存写或无缓存价
PriceCacheCreationMillis *int64 `json:"PriceCacheCreationMillis"`
// PriceCacheReadMillis 缓存读单价快照(每 M token 毫分);null = 该请求无缓存读或无缓存价
PriceCacheReadMillis *int64 `json:"PriceCacheReadMillis"`
// PriceInputMillis 输入单价快照(每 M token 毫分,1 USD = 100,000 毫分;pricing 同款单位);null = 未计费路径
PriceInputMillis *int64 `json:"PriceInputMillis"`
// PriceOutputMillis 输出单价快照(每 M token 毫分);null = 未计费路径
PriceOutputMillis *int64 `json:"PriceOutputMillis"`
// RawCost 原始成本(毫分,乘倍率前——免费组 cost=0 但 raw 有值,实际消耗口径);bill 未装配/无价防御路径恒 0
RawCost *int64 `json:"RawCost,omitempty"`
RequestID *string `json:"RequestID,omitempty"`
// TTFTMS 首 token 时间毫秒(流式首 chunk 采集);非流式/失败/无首 token 路径 = null
TTFTMS *int64 `json:"TTFTMS"`
TotalTokens *int64 `json:"TotalTokens,omitempty"`
// UserID 鉴权归属用户;0 = 无
UserID *int64 `json:"UserID,omitempty"`
}
UserUsageLog 用户面用量明细(= UsageLog 删 AccountID/TemplateID——用户无上游账号拓扑概念)