diff --git a/internal/services/gateway/action/projectgroup.go b/internal/services/gateway/action/projectgroup.go index f424ae9..350b9f6 100644 --- a/internal/services/gateway/action/projectgroup.go +++ b/internal/services/gateway/action/projectgroup.go @@ -105,8 +105,10 @@ func (h *ActionHandler) CreateProjectGroup(ctx context.Context, req *CreateProje } type UpdateProjectGroupRequest struct { - Name string - Visibility cstypes.Visibility + Name *string + ParentRef *string + + Visibility *cstypes.Visibility } func (h *ActionHandler) UpdateProjectGroup(ctx context.Context, projectGroupRef string, req *UpdateProjectGroupRequest) (*csapitypes.ProjectGroup, error) { @@ -123,8 +125,15 @@ func (h *ActionHandler) UpdateProjectGroup(ctx context.Context, projectGroupRef return nil, util.NewErrForbidden(errors.Errorf("user not authorized")) } - pg.Name = req.Name - pg.Visibility = req.Visibility + if req.Name != nil { + pg.Name = *req.Name + } + if req.ParentRef != nil { + pg.Parent.ID = *req.ParentRef + } + if req.Visibility != nil { + pg.Visibility = *req.Visibility + } h.log.Infof("updating project group") rp, resp, err := h.configstoreClient.UpdateProjectGroup(ctx, pg.ID, pg.ProjectGroup) diff --git a/internal/services/gateway/api/projectgroup.go b/internal/services/gateway/api/projectgroup.go index 0b01c10..4110283 100644 --- a/internal/services/gateway/api/projectgroup.go +++ b/internal/services/gateway/api/projectgroup.go @@ -100,9 +100,16 @@ func (h *UpdateProjectGroupHandler) ServeHTTP(w http.ResponseWriter, r *http.Req return } + var visibility *cstypes.Visibility + if req.Visibility != nil { + v := cstypes.Visibility(*req.Visibility) + visibility = &v + } + areq := &action.UpdateProjectGroupRequest{ Name: req.Name, - Visibility: cstypes.Visibility(req.Visibility), + ParentRef: req.ParentRef, + Visibility: visibility, } projectGroup, err := h.ah.UpdateProjectGroup(ctx, projectGroupRef, areq) if httpError(w, err) { diff --git a/services/gateway/api/types/projectgroup.go b/services/gateway/api/types/projectgroup.go index dbfd303..f6152f2 100644 --- a/services/gateway/api/types/projectgroup.go +++ b/services/gateway/api/types/projectgroup.go @@ -21,8 +21,9 @@ type CreateProjectGroupRequest struct { } type UpdateProjectGroupRequest struct { - Name string `json:"name,omitempty"` - Visibility Visibility `json:"visibility,omitempty"` + Name *string `json:"name,omitempty"` + ParentRef *string `json:"parent_ref,omitempty"` + Visibility *Visibility `json:"visibility,omitempty"` } type ProjectGroupResponse struct {