gateway: add parentRef field to project group update api
and make all the request fields optional
This commit is contained in:
parent
bd3852809c
commit
11da186913
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue