-
Notifications
You must be signed in to change notification settings - Fork 959
Add endpoint to lists invited groups of a project #2000
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1139,6 +1139,35 @@ func (s *ProjectsService) DeleteProject(pid interface{}, options ...RequestOptio | |||||||||
return s.client.Do(req, nil) | ||||||||||
} | ||||||||||
|
||||||||||
// ListProjectInvidedGroupOptions represents the available ListProjectsInvitedGroups() options. | ||||||||||
// | ||||||||||
// GitLab API docs: https://docs.gitlab.com/ee/api/projects.html#list-a-projects-invited-groups | ||||||||||
type ListProjectInvidedGroupOptions struct { | ||||||||||
ListOptions | ||||||||||
Search *string `url:"search,omitempty" json:"search,omitempty"` | ||||||||||
SharedMinAccessLevel *AccessLevelValue `url:"shared_min_access_level,omitempty" json:"shared_min_access_level,omitempty"` | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the docs this should be |
||||||||||
Relation []string `url:"relation,omitempty" json:"relation,omitempty"` | ||||||||||
WithCustomAttributes bool `url:"with_custom_attributes,omitempty" json:"with_custom_attributes,omitempty"` | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These need to be pointers and it seems this code is not formatted properly:
Suggested change
|
||||||||||
} | ||||||||||
|
||||||||||
// ListProjectsInvitedGroups lists invited groups of a project | ||||||||||
// | ||||||||||
// GitLab API docs: https://docs.gitlab.com/ee/api/projects.html#list-a-projects-invited-groups | ||||||||||
func (s *ProjectsService) ListProjectsInvitedGroups(pid interface{}, opt *ListProjectInvidedGroupOptions, options ...RequestOptionFunc) (*Response, error) { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function should also return a |
||||||||||
project, err := parseID(pid) | ||||||||||
if err != nil { | ||||||||||
return nil, err | ||||||||||
} | ||||||||||
u := fmt.Sprintf("projects/%s/invited_groups", PathEscape(project)) | ||||||||||
|
||||||||||
req, err := s.client.NewRequest(http.MethodGet, u, opt, options) | ||||||||||
if err != nil { | ||||||||||
return nil, err | ||||||||||
} | ||||||||||
|
||||||||||
return s.client.Do(req, nil) | ||||||||||
} | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following the ordering in the docs, this method should be placed between |
||||||||||
|
||||||||||
// ShareWithGroupOptions represents options to share project with groups | ||||||||||
// | ||||||||||
// GitLab API docs: https://docs.gitlab.com/ee/api/projects.html#share-project-with-group | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -647,6 +647,21 @@ func TestListProjectForks(t *testing.T) { | |
} | ||
} | ||
|
||
func TestListProjectsInvitedGroups(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A test like this doesn't actually test anything, so probably best to remove it. |
||
mux, client := setup(t) | ||
|
||
mux.HandleFunc("/api/v4/projects/1/invited_groups", func(w http.ResponseWriter, r *http.Request) { | ||
testMethod(t, r, http.MethodGet) | ||
}) | ||
|
||
opt := &ListProjectInvidedGroupOptions{} | ||
|
||
_, err := client.Projects.ListProjectsInvitedGroups(1, opt) | ||
if err != nil { | ||
t.Errorf("Projects.ListProjectsInvitedGroups returned error: %v", err) | ||
} | ||
} | ||
|
||
func TestShareProjectWithGroup(t *testing.T) { | ||
mux, client := setup(t) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please try to keep comments below 80 chars: