mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -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"`
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user