mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add shared_with_group: and shared_with_user: filters to /workspaces endpoint (#19875)
Adds shared_with_user and shared_with_group filters to the /workspaces endpoint. - `shared_with_user`: filters workspaces shared with a specific user. Accepts a user UUID or username. - `shared_with_group`: filters workspaces shared with a specific group. Accepts: - a group UUID, or - `<organization name>/<group name>`, or - `<group name>` (resolved in the default organization). Closes [coder/internal#1004](https://github.com/coder/internal/issues/1004)
This commit is contained in:
@@ -518,6 +518,10 @@ type WorkspaceFilter struct {
|
||||
Limit int `json:"limit,omitempty" typescript:"-"`
|
||||
// Shared is a whether the workspace is shared with any users or groups
|
||||
Shared *bool `json:"shared,omitempty" typescript:"-"`
|
||||
// SharedWithUser is the username or ID of the user that the workspace is shared with
|
||||
SharedWithUser string `json:"shared_with_user,omitempty" typescript:"-"`
|
||||
// SharedWithGroup is the group name, group ID, or <org name>/<group name> of the group that the workspace is shared with
|
||||
SharedWithGroup string `json:"shared_with_group,omitempty" typescript:"-"`
|
||||
// FilterQuery supports a raw filter query string
|
||||
FilterQuery string `json:"q,omitempty"`
|
||||
}
|
||||
@@ -544,6 +548,12 @@ func (f WorkspaceFilter) asRequestOption() RequestOption {
|
||||
if f.Shared != nil {
|
||||
params = append(params, fmt.Sprintf("shared:%v", *f.Shared))
|
||||
}
|
||||
if f.SharedWithUser != "" {
|
||||
params = append(params, fmt.Sprintf("shared_with_user:%q", f.SharedWithUser))
|
||||
}
|
||||
if f.SharedWithGroup != "" {
|
||||
params = append(params, fmt.Sprintf("shared_with_group:%q", f.SharedWithGroup))
|
||||
}
|
||||
if f.FilterQuery != "" {
|
||||
// If custom stuff is added, just add it on here.
|
||||
params = append(params, f.FilterQuery)
|
||||
|
||||
Reference in New Issue
Block a user