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,Phase 3a Task 4)。
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 Router(svc *service.Service, iss *auth.Issuer, users auth.UserStatusProvider, ...) http.Handler
- type ChangePasswordResponse
- type ChiServerOptions
- type DeletedResponse
- type Error
- type ErrorResponse
- 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 MiddlewareFunc
- type PostUserAuthChangePasswordJSONRequestBody
- type PostUserAuthForgotPasswordJSONRequestBody
- type PostUserAuthLoginJSONRequestBody
- type PostUserAuthRegisterCodeJSONRequestBody
- type PostUserAuthRegisterJSONRequestBody
- type PostUserAuthResetPasswordJSONRequestBody
- type PostUserKeysJSONRequestBody
- type PostUserRedemptionsJSONRequestBody
- type PutUserKeysIdJSONRequestBody
- 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) GetUserAuthMe(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) GetUserRedemptions(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUserStats(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) PostUserRedemptions(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PutUserKeysId(w http.ResponseWriter, r *http.Request)
- type StatTTFTSummary
- type StatTTFTSummarySource
- type StatTrendPoint
- type TempBalanceRow
- type TempBalancesResponse
- type TooManyValuesForParamError
- type UnescapedCookieParamError
- type Unimplemented
- func (_ Unimplemented) DeleteUserKeysId(w http.ResponseWriter, r *http.Request, id int64)
- func (_ Unimplemented) GetUserAuthMe(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) GetUserRedemptions(w http.ResponseWriter, r *http.Request, params GetUserRedemptionsParams)
- func (_ Unimplemented) GetUserStats(w http.ResponseWriter, r *http.Request, params GetUserStatsParams)
- 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) PostUserRedemptions(w http.ResponseWriter, r *http.Request)
- func (_ Unimplemented) PutUserKeysId(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) GetUserAuthMe(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) GetUserRedemptions(w http.ResponseWriter, r *http.Request, params GetUserRedemptionsParams)
- func (h *UserAPI) GetUserStats(w http.ResponseWriter, r *http.Request, params GetUserStatsParams)
- 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) PostUserRedemptions(w http.ResponseWriter, r *http.Request)
- func (h *UserAPI) PutUserKeysId(w http.ResponseWriter, r *http.Request, id int64)
- 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, users auth.UserStatusProvider, rules *rule.RuleEngine) http.Handler
Router 组装 /api/user 组路由(挂载于 /api/user/*): 公开路径(/api/user/auth/register、/api/user/auth/login)跳过 JWT;其余路径 RequireJWT(验证 + 内存快照用户状态校验)。生成路由的 spec 路径自带 /api/user 前缀,故无独立 BaseURL,HandlerWithOptions 直接使用 spec 路径。 rules 为规则引擎(/api/user/err_logs 行级脱敏用;main 装配注入——非 New, 测试构造零回归;nil = 不脱敏)。
Types ¶
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 {
Error string `json:"error"`
}
ErrorResponse defines model for ErrorResponse.
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" json:"from"`
To time.Time `form:"to" json:"to"`
Granularity *GetUserStatsParamsGranularity `form:"granularity,omitempty" json:"granularity,omitempty"`
Model *string `form:"model,omitempty" json:"model,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" json:"from"`
To time.Time `form:"to" json:"to"`
Model *string `form:"model,omitempty" json:"model,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"`
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 分组级协议转换方向(只补差,W5 网关 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"`
ID *int64 `json:"ID,omitempty"`
MaxConcurrency *int `json:"MaxConcurrency,omitempty"`
Name *string `json:"Name,omitempty"`
// Quota 累计 token 上限;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 累计 token 上限;0 = 不限
Quota *int64 `json:"quota,omitempty"`
}
KeyCreate defines model for KeyCreate.
type KeyListResponse ¶
KeyListResponse defines model for KeyListResponse.
type KeyUpdate ¶
type KeyUpdate struct {
MaxConcurrency *int `json:"max_concurrency,omitempty"`
Name *string `json:"name,omitempty"`
Quota *int64 `json:"quota,omitempty"`
Status *KeyStatus `json:"status,omitempty"`
}
KeyUpdate defines model for KeyUpdate.
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 PostUserRedemptionsJSONRequestBody ¶
type PostUserRedemptionsJSONRequestBody = RedeemRequest
PostUserRedemptionsJSONRequestBody defines body for PostUserRedemptions for application/json ContentType.
type PutUserKeysIdJSONRequestBody ¶
type PutUserKeysIdJSONRequestBody = KeyUpdate
PutUserKeysIdJSONRequestBody defines body for PutUserKeysId 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)
// 我的错误明细(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)
// 我的兑换记录(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)
// 我的 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) GetUserAuthMe ¶
func (siw *ServerInterfaceWrapper) GetUserAuthMe(w http.ResponseWriter, r *http.Request)
GetUserAuthMe 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) 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) 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) PostUserRedemptions ¶
func (siw *ServerInterfaceWrapper) PostUserRedemptions(w http.ResponseWriter, r *http.Request)
PostUserRedemptions operation middleware
func (*ServerInterfaceWrapper) PutUserKeysId ¶
func (siw *ServerInterfaceWrapper) PutUserKeysId(w http.ResponseWriter, r *http.Request)
PutUserKeysId 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 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) GetUserAuthMe ¶
func (_ Unimplemented) GetUserAuthMe(w http.ResponseWriter, r *http.Request)
当前用户信息(JWT) (GET /api/user/auth/me)
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) 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) 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) PostUserRedemptions ¶
func (_ Unimplemented) PostUserRedemptions(w http.ResponseWriter, r *http.Request)
兑换码(400 invalid code:不存在/失效/过期/用尽,统一不泄露细节;409 already redeemed 重复兑换) (POST /api/user/redemptions)
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})
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) GetUserAuthMe ¶
func (h *UserAPI) GetUserAuthMe(w http.ResponseWriter, r *http.Request)
GetUserAuthMe 当前用户信息(JWT 已由 Router 中间件验证,ServerInterface)。
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 透传仅本人行内生效)。
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) 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)。
func (*UserAPI) GetUserStatsTTFT ¶
func (h *UserAPI) GetUserStatsTTFT(w http.ResponseWriter, r *http.Request, params GetUserStatsTTFTParams)
GetUserStatsTTFT 我的 TTFT 聚合(强制 user_id = 当前用户)。
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 侧同构。
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 反枚举)。
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) PostUserRedemptions ¶
func (h *UserAPI) PostUserRedemptions(w http.ResponseWriter, r *http.Request)
PostUserRedemptions 兑换码(ServerInterface):400 invalid code(不存在/失效/ 过期/用尽,统一不泄露细节,决策 7)、409 already redeemed(重复兑换)。
func (*UserAPI) PutUserKeysId ¶
PutUserKeysId 更新 key(name/status/max_concurrency/quota;仅本人, 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 ( UserStatusActive UserStatus = "active" UserStatusDisabled 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——用户无上游账号拓扑概念)