chore: remove organization requirement from convertGroup() (#12195)

* feat: convertGroups() no longer requires organization info

Removing role information from some users in the api. This info is
excessive and not required. It is costly to always include
This commit is contained in:
Steven Masley
2024-02-21 15:58:11 -06:00
committed by GitHub
parent 3f65bd14cc
commit c3a7b13690
25 changed files with 350 additions and 278 deletions
+8 -8
View File
@@ -25,14 +25,14 @@ type CreateGroupRequest struct {
}
type Group struct {
ID uuid.UUID `json:"id" format:"uuid"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
OrganizationID uuid.UUID `json:"organization_id" format:"uuid"`
Members []User `json:"members"`
AvatarURL string `json:"avatar_url"`
QuotaAllowance int `json:"quota_allowance"`
Source GroupSource `json:"source"`
ID uuid.UUID `json:"id" format:"uuid"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
OrganizationID uuid.UUID `json:"organization_id" format:"uuid"`
Members []ReducedUser `json:"members"`
AvatarURL string `json:"avatar_url"`
QuotaAllowance int `json:"quota_allowance"`
Source GroupSource `json:"source"`
}
func (g Group) IsEveryone() bool {
+2 -2
View File
@@ -200,8 +200,8 @@ type UpdateTemplateACL struct {
// ACLAvailable is a list of users and groups that can be added to a template
// ACL.
type ACLAvailable struct {
Users []User `json:"users"`
Groups []Group `json:"groups"`
Users []ReducedUser `json:"users"`
Groups []Group `json:"groups"`
}
type UpdateTemplateMeta struct {
+17 -10
View File
@@ -42,21 +42,28 @@ type MinimalUser struct {
AvatarURL string `json:"avatar_url" format:"uri"`
}
// ReducedUser omits role and organization information. Roles are deduced from
// the user's site and organization roles. This requires fetching the user's
// organizational memberships. Fetching that is more expensive, and not usually
// required by the frontend.
type ReducedUser struct {
MinimalUser `table:"m,recursive_inline"`
Name string `json:"name"`
Email string `json:"email" validate:"required" table:"email" format:"email"`
CreatedAt time.Time `json:"created_at" validate:"required" table:"created at" format:"date-time"`
LastSeenAt time.Time `json:"last_seen_at" format:"date-time"`
Status UserStatus `json:"status" table:"status" enums:"active,suspended"`
LoginType LoginType `json:"login_type"`
ThemePreference string `json:"theme_preference"`
}
// User represents a user in Coder.
type User struct {
ID uuid.UUID `json:"id" validate:"required" table:"id" format:"uuid"`
Username string `json:"username" validate:"required" table:"username,default_sort"`
Name string `json:"name"`
Email string `json:"email" validate:"required" table:"email" format:"email"`
CreatedAt time.Time `json:"created_at" validate:"required" table:"created at" format:"date-time"`
LastSeenAt time.Time `json:"last_seen_at" format:"date-time"`
ReducedUser `table:"r,recursive_inline"`
Status UserStatus `json:"status" table:"status" enums:"active,suspended"`
OrganizationIDs []uuid.UUID `json:"organization_ids" format:"uuid"`
Roles []Role `json:"roles"`
AvatarURL string `json:"avatar_url" format:"uri"`
LoginType LoginType `json:"login_type"`
ThemePreference string `json:"theme_preference"`
}
type GetUsersResponse struct {
+3 -4
View File
@@ -56,7 +56,7 @@ type WorkspaceProxy struct {
// and ready to use.
Status WorkspaceProxyStatus `json:"status,omitempty" table:"proxy,recursive"`
CreatedAt time.Time `json:"created_at" format:"date-time" table:"created_at,default_sort"`
CreatedAt time.Time `json:"created_at" format:"date-time" table:"created_at"`
UpdatedAt time.Time `json:"updated_at" format:"date-time" table:"updated_at"`
Deleted bool `json:"deleted" table:"deleted"`
Version string `json:"version" table:"version"`
@@ -69,9 +69,8 @@ type CreateWorkspaceProxyRequest struct {
}
type UpdateWorkspaceProxyResponse struct {
Proxy WorkspaceProxy `json:"proxy" table:"proxy,recursive"`
// The recursive table sort is not working very well.
ProxyToken string `json:"proxy_token" table:"proxy token,default_sort"`
Proxy WorkspaceProxy `json:"proxy" table:"p,recursive_inline"`
ProxyToken string `json:"proxy_token" table:"proxy token"`
}
func (c *Client) CreateWorkspaceProxy(ctx context.Context, req CreateWorkspaceProxyRequest) (UpdateWorkspaceProxyResponse, error) {