mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: add /groups endpoint to filter by organization and/or member (#14260)
* chore: merge get groups sql queries into 1 * Add endpoint for fetching groups with filters * remove 2 ways to customizing a fake authorizer
This commit is contained in:
@@ -144,6 +144,19 @@ func (p *QueryParamParser) RequiredNotEmpty(queryParam ...string) *QueryParamPar
|
||||
return p
|
||||
}
|
||||
|
||||
// UUIDorName will parse a string as a UUID, if it fails, it uses the "fetchByName"
|
||||
// function to return a UUID based on the value as a string.
|
||||
// This is useful when fetching something like an organization by ID or by name.
|
||||
func (p *QueryParamParser) UUIDorName(vals url.Values, def uuid.UUID, queryParam string, fetchByName func(name string) (uuid.UUID, error)) uuid.UUID {
|
||||
return ParseCustom(p, vals, def, queryParam, func(v string) (uuid.UUID, error) {
|
||||
id, err := uuid.Parse(v)
|
||||
if err == nil {
|
||||
return id, nil
|
||||
}
|
||||
return fetchByName(v)
|
||||
})
|
||||
}
|
||||
|
||||
func (p *QueryParamParser) UUIDorMe(vals url.Values, def uuid.UUID, me uuid.UUID, queryParam string) uuid.UUID {
|
||||
return ParseCustom(p, vals, def, queryParam, func(v string) (uuid.UUID, error) {
|
||||
if v == "me" {
|
||||
|
||||
Reference in New Issue
Block a user