Commit ef44af32 authored by Andrea Funtò's avatar Andrea Funtò Committed by Sander van Harmelen

Enhanced group creation and added update group support (#173)

* added VisibilityLevel, LSF and Request Access to Group creation API

* Updated Groups API to support group update and LFS/RequestAccess enablement
parent aadd98df
......@@ -18,6 +18,7 @@ package gitlab
import (
"fmt"
"net/url"
"time"
)
......@@ -39,6 +40,9 @@ type Group struct {
Name string `json:"name"`
Path string `json:"path"`
Description string `json:"description"`
VisibilityLevel VisibilityLevelValue `json:"visibility_level"`
LFSEnabled bool `json:"lfs_enabled"`
RequestAccessEnabled bool `json:"request_access_enabled"`
Projects []*Project `json:"projects"`
Statistics *StorageStatistics `json:"statistics"`
}
......@@ -105,7 +109,9 @@ type CreateGroupOptions struct {
Name *string `url:"name,omitempty" json:"name,omitempty"`
Path *string `url:"path,omitempty" json:"path,omitempty"`
Description *string `url:"description,omitempty" json:"description,omitempty"`
VisibilityLevel *VisibilityLevelValue `url:"visibility_level" json:"visibility_level,omitempty"`
VisibilityLevel *VisibilityLevelValue `url:"visibility_level,omitempty" json:"visibility_level,omitempty"`
LFSEnabled *bool `url:"lfs_enabled,omitempty" json:"lfs_enabled,omitempty"`
RequestAccessEnabled *bool `url:"request_access_enabled,omitempty" json:"request_access_enabled,omitempty"`
}
// CreateGroup creates a new project group. Available only for users who can
......@@ -128,6 +134,39 @@ func (s *GroupsService) CreateGroup(opt *CreateGroupOptions, options ...OptionFu
return g, resp, err
}
// UpdateGroupOptions represents the set of available options to update a Group;
// as of today these are exactly the same available when creating a new Group.
//
// GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/groups.md#update-group
type UpdateGroupOptions CreateGroupOptions
// UpdateGroup updates an existing group; only available to group owners and
// administrators.
//
// GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/groups.md#update-group
func (s *GroupsService) UpdateGroup(gid interface{}, opt *UpdateGroupOptions, options ...OptionFunc) (*Group, *Response, error) {
group, err := parseID(gid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("groups/%s", url.QueryEscape(group))
req, err := s.client.NewRequest("PUT", u, opt, options)
if err != nil {
return nil, nil, err
}
g := new(Group)
resp, err := s.client.Do(req, g)
if err != nil {
return nil, resp, err
}
return g, resp, err
}
// TransferGroup transfers a project to the Group namespace. Available only
// for admin.
//
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment