mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add group AI spend endpoint (#27568)
## Description
Adds `GET /api/v2/groups/{group}/ai/spend`, returning the AI spend limit
and aggregate spend for a single group over the current budget period.
The period is derived from the deployment's configured budget period
rather than being caller-specified, matching the other AI spend
endpoints.
## Changes
- Add the `groupAISpend` handler and route, gated by the
`aigateway-cost-control` experiment and the `AIBridge` feature.
- Reuse the existing `GetOrganizationGroupsAISpend` query with a single
group ID, so no new query or authorization path is introduced.
- Add the `GroupAISpend` codersdk type and client method.
Closes
https://linear.app/codercom/issue/AIGOV-475/implement-apiv2groupsgroupaispend
> [!NOTE]
> Initially generated by Claude Opus 4.7, modified and reviewed by
@ssncferreira
This commit is contained in:
Generated
+63
@@ -3400,6 +3400,42 @@ const docTemplate = `{
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v2/groups/{group}/ai/spend": {
|
||||
"get": {
|
||||
"description": "Returns the AI spend limit and aggregate spend for the group.",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Enterprise"
|
||||
],
|
||||
"summary": "Get group AI spend",
|
||||
"operationId": "get-group-ai-spend",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"format": "uuid",
|
||||
"description": "Group ID",
|
||||
"name": "group",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/codersdk.GroupAISpend"
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"CoderSessionToken": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v2/groups/{group}/members": {
|
||||
"get": {
|
||||
"produces": [
|
||||
@@ -20642,6 +20678,33 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.GroupAISpend": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"current_spend_micros": {
|
||||
"description": "CurrentSpendMicros is the group's spend over the current budget\nperiod.",
|
||||
"type": "integer"
|
||||
},
|
||||
"group_id": {
|
||||
"type": "string",
|
||||
"format": "uuid"
|
||||
},
|
||||
"period_end": {
|
||||
"description": "PeriodEnd is the exclusive upper bound of the current budget\nperiod.",
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"period_start": {
|
||||
"description": "PeriodStart is the inclusive lower bound of the current budget\nperiod.",
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"spend_limit_micros": {
|
||||
"description": "SpendLimitMicros is the group's configured AI spend limit. Null when\nthe group has no configured budget.",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.GroupMemberAISpend": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
Generated
+59
@@ -2999,6 +2999,38 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v2/groups/{group}/ai/spend": {
|
||||
"get": {
|
||||
"description": "Returns the AI spend limit and aggregate spend for the group.",
|
||||
"produces": ["application/json"],
|
||||
"tags": ["Enterprise"],
|
||||
"summary": "Get group AI spend",
|
||||
"operationId": "get-group-ai-spend",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"format": "uuid",
|
||||
"description": "Group ID",
|
||||
"name": "group",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/codersdk.GroupAISpend"
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"CoderSessionToken": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v2/groups/{group}/members": {
|
||||
"get": {
|
||||
"produces": ["application/json"],
|
||||
@@ -18790,6 +18822,33 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.GroupAISpend": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"current_spend_micros": {
|
||||
"description": "CurrentSpendMicros is the group's spend over the current budget\nperiod.",
|
||||
"type": "integer"
|
||||
},
|
||||
"group_id": {
|
||||
"type": "string",
|
||||
"format": "uuid"
|
||||
},
|
||||
"period_end": {
|
||||
"description": "PeriodEnd is the exclusive upper bound of the current budget\nperiod.",
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"period_start": {
|
||||
"description": "PeriodStart is the inclusive lower bound of the current budget\nperiod.",
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"spend_limit_micros": {
|
||||
"description": "SpendLimitMicros is the group's configured AI spend limit. Null when\nthe group has no configured budget.",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.GroupMemberAISpend": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
Reference in New Issue
Block a user