feat: add filtering to org members (#23334)

Continuation of https://github.com/coder/coder/pull/23067

Add filtering to the paginated org member endpoint (pretty much the same
as what I did in the previous PR with group members, except there I also
had to add pagination since it was missing).
This commit is contained in:
Asher
2026-03-21 16:58:45 -08:00
committed by GitHub
parent 4b707515c0
commit 47daca6eea
14 changed files with 576 additions and 75 deletions
+5
View File
@@ -77,6 +77,11 @@ type OrganizationMemberWithUserData struct {
Name string `table:"name" json:"name,omitempty"`
AvatarURL string `json:"avatar_url,omitempty"`
Email string `json:"email"`
Status UserStatus `json:"status" enums:"active,suspended"`
LoginType LoginType `json:"login_type"`
LastSeenAt time.Time `table:"last seen at" json:"last_seen_at,omitempty" format:"date-time"`
UserCreatedAt time.Time `table:"user created at" json:"user_created_at" format:"date-time"`
UserUpdatedAt time.Time `table:"user updated at" json:"user_updated_at" format:"date-time"`
GlobalRoles []SlimRole `json:"global_roles"`
OrganizationMember `table:"m,recursive_inline"`
}
+19
View File
@@ -714,6 +714,25 @@ func (c *Client) OrganizationMembers(ctx context.Context, organizationID uuid.UU
return members, json.NewDecoder(res.Body).Decode(&members)
}
// OrganizationMembers lists filtered and paginated members in an organization
func (c *Client) OrganizationMembersPaginated(ctx context.Context, organizationID uuid.UUID, req UsersRequest) (PaginatedMembersResponse, error) {
res, err := c.Request(ctx, http.MethodGet,
fmt.Sprintf("/api/v2/organizations/%s/paginated-members", organizationID),
nil,
req.Pagination.asRequestOption(),
req.asRequestOption(),
)
if err != nil {
return PaginatedMembersResponse{}, err
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
return PaginatedMembersResponse{}, ReadBodyAsError(res)
}
var membersRes PaginatedMembersResponse
return membersRes, json.NewDecoder(res.Body).Decode(&membersRes)
}
// UpdateUserRoles grants the userID the specified roles.
// Include ALL roles the user has.
func (c *Client) UpdateUserRoles(ctx context.Context, user string, req UpdateRoles) (User, error) {