diff --git a/internal/services/gateway/action/project.go b/internal/services/gateway/action/project.go index f470d71..5c035e8 100644 --- a/internal/services/gateway/action/project.go +++ b/internal/services/gateway/action/project.go @@ -180,8 +180,10 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateProjectReq } type UpdateProjectRequest struct { - Name string - Visibility cstypes.Visibility + Name *string + ParentRef *string + + Visibility *cstypes.Visibility } func (h *ActionHandler) UpdateProject(ctx context.Context, projectRef string, req *UpdateProjectRequest) (*csapitypes.Project, error) { @@ -198,8 +200,15 @@ func (h *ActionHandler) UpdateProject(ctx context.Context, projectRef string, re return nil, util.NewErrForbidden(errors.Errorf("user not authorized")) } - p.Name = req.Name - p.Visibility = req.Visibility + if req.Name != nil { + p.Name = *req.Name + } + if req.ParentRef != nil { + p.Parent.ID = *req.ParentRef + } + if req.Visibility != nil { + p.Visibility = *req.Visibility + } h.log.Infof("updating project") rp, resp, err := h.configstoreClient.UpdateProject(ctx, p.ID, p.Project) diff --git a/internal/services/gateway/api/project.go b/internal/services/gateway/api/project.go index 4c03c87..f68eef9 100644 --- a/internal/services/gateway/api/project.go +++ b/internal/services/gateway/api/project.go @@ -94,9 +94,16 @@ func (h *UpdateProjectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) return } + var visibility *cstypes.Visibility + if req.Visibility != nil { + v := cstypes.Visibility(*req.Visibility) + visibility = &v + } + areq := &action.UpdateProjectRequest{ Name: req.Name, - Visibility: cstypes.Visibility(req.Visibility), + ParentRef: req.ParentRef, + Visibility: visibility, } project, err := h.ah.UpdateProject(ctx, projectRef, areq) if httpError(w, err) { diff --git a/services/gateway/api/types/project.go b/services/gateway/api/types/project.go index 66e2486..0dcdc8a 100644 --- a/services/gateway/api/types/project.go +++ b/services/gateway/api/types/project.go @@ -24,8 +24,9 @@ type CreateProjectRequest struct { } type UpdateProjectRequest 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 ProjectResponse struct {