mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
refactor: make user AI budget and spend endpoints consistent (#27611)
## Description
Makes the user AI cost control endpoints consistent.
## Changes
- Replaces the flat `spend_limit_micros` and `limit_source` fields on
`GET /users/{user}/ai/spend` with a nested `effective_budget`, reusing
the type behind `group_budget`. The flat pair made it possible to encode
a limit without a source.
- Renames `AIGroupBudget` to `AIBudgetLimit`, since it also carries
`user_override` limits and is no longer group-specific. The type name is
not part of the wire format.
- Moves `/users/{user}/ai/budget` to `/users/{user}/ai/budget/override`.
The endpoint only ever managed the per-user override, which the type,
the handlers, and the operation IDs all already said; the path was the
only place that didn't.
> [!NOTE]
> Initially generated by Claude Opus 4.7, modified and reviewed by
@ssncferreira
This commit is contained in:
@@ -1490,7 +1490,7 @@ func GroupMemberAISpend(row database.GetGroupMembersAISpendRow) codersdk.GroupMe
|
||||
member.EffectiveGroupID = &row.EffectiveGroupID.UUID
|
||||
}
|
||||
if row.SpendLimitMicros.Valid {
|
||||
member.GroupBudget = &codersdk.AIGroupBudget{
|
||||
member.GroupBudget = &codersdk.AIBudgetLimit{
|
||||
SpendLimitMicros: row.SpendLimitMicros.Int64,
|
||||
LimitSource: codersdk.AIBudgetLimitSource(row.LimitSource.String),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user