Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eb5f19c

Browse filesBrowse files
committed
feat: add GET /organizations/{org}/groups/ai/spend
1 parent a567f6a commit eb5f19c
Copy full SHA for eb5f19c

18 files changed

+1,169-19Lines changed: 1169 additions & 19 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎coderd/apidoc/docs.go‎

Copy file name to clipboardExpand all lines: coderd/apidoc/docs.go
+80Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎coderd/apidoc/swagger.json‎

Copy file name to clipboardExpand all lines: coderd/apidoc/swagger.json
+76Lines changed: 76 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎coderd/database/dbauthz/dbauthz.go‎

Copy file name to clipboardExpand all lines: coderd/database/dbauthz/dbauthz.go
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4171,6 +4171,10 @@ func (q *querier) GetOrganizationByName(ctx context.Context, name database.GetOr
41714171
return fetch(q.log, q.auth, q.db.GetOrganizationByName)(ctx, name)
41724172
}
41734173

4174+
func (q *querier) GetOrganizationGroupsAISpend(ctx context.Context, arg database.GetOrganizationGroupsAISpendParams) ([]database.GetOrganizationGroupsAISpendRow, error) {
4175+
return fetchWithPostFilter(q.auth, policy.ActionRead, q.db.GetOrganizationGroupsAISpend)(ctx, arg)
4176+
}
4177+
41744178
func (q *querier) GetOrganizationIDsByMemberIDs(ctx context.Context, ids []uuid.UUID) ([]database.GetOrganizationIDsByMemberIDsRow, error) {
41754179
// TODO: This should be rewritten to return a list of database.OrganizationMember for consistent RBAC objects.
41764180
// Currently this row returns a list of org ids per user, which is challenging to check against the RBAC system.
Collapse file

‎coderd/database/dbauthz/dbauthz_test.go‎

Copy file name to clipboardExpand all lines: coderd/database/dbauthz/dbauthz_test.go
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6894,6 +6894,22 @@ func (s *MethodTestSuite) TestAIBridge() {
68946894
check.Args(database.GetAIModelPriceByProviderModelParams{}).Asserts(rbac.ResourceAiModelPrice, policy.ActionRead)
68956895
}))
68966896

6897+
s.Run("GetOrganizationGroupsAISpend", s.Mocked(func(dbm *dbmock.MockStore, faker *gofakeit.Faker, check *expects) {
6898+
org := testutil.Fake(s.T(), faker, database.Organization{})
6899+
row1 := testutil.Fake(s.T(), faker, database.GetOrganizationGroupsAISpendRow{OrganizationID: org.ID})
6900+
row2 := testutil.Fake(s.T(), faker, database.GetOrganizationGroupsAISpendRow{OrganizationID: org.ID})
6901+
arg := database.GetOrganizationGroupsAISpendParams{
6902+
OrganizationID: org.ID,
6903+
GroupIds: []uuid.UUID{row1.GroupID, row2.GroupID},
6904+
PeriodStart: time.Now().UTC().Truncate(24 * time.Hour),
6905+
}
6906+
dbm.EXPECT().GetOrganizationGroupsAISpend(gomock.Any(), arg).
6907+
Return([]database.GetOrganizationGroupsAISpendRow{row1, row2}, nil).AnyTimes()
6908+
check.Args(arg).
6909+
Asserts(row1, policy.ActionRead, row2, policy.ActionRead).
6910+
Returns([]database.GetOrganizationGroupsAISpendRow{row1, row2})
6911+
}))
6912+
68976913
s.Run("GetGroupAIBudget", s.Mocked(func(dbm *dbmock.MockStore, faker *gofakeit.Faker, check *expects) {
68986914
g := testutil.Fake(s.T(), faker, database.Group{})
68996915
b := testutil.Fake(s.T(), faker, database.GroupAIBudget{GroupID: g.ID})
Collapse file

‎coderd/database/dbmetrics/querymetrics.go‎

Copy file name to clipboardExpand all lines: coderd/database/dbmetrics/querymetrics.go
+8Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎coderd/database/dbmock/dbmock.go‎

Copy file name to clipboardExpand all lines: coderd/database/dbmock/dbmock.go
+15Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎coderd/database/modelmethods.go‎

Copy file name to clipboardExpand all lines: coderd/database/modelmethods.go
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,16 @@ func (g GetGroupsRow) RBACObject() rbac.Object {
458458
return g.Group.RBACObject()
459459
}
460460

461+
func (g GetOrganizationGroupsAISpendRow) RBACObject() rbac.Object {
462+
return rbac.ResourceGroup.WithID(g.GroupID).
463+
InOrg(g.OrganizationID).
464+
WithGroupACL(map[string][]policy.Action{
465+
g.GroupID.String(): {
466+
policy.ActionRead,
467+
},
468+
})
469+
}
470+
461471
func (gm GroupMember) RBACObject() rbac.Object {
462472
return rbac.ResourceGroupMember.WithID(gm.UserID).InOrg(gm.OrganizationID).WithOwner(gm.UserID.String())
463473
}
Collapse file

‎coderd/database/querier.go‎

Copy file name to clipboardExpand all lines: coderd/database/querier.go
+6Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.