Skip to content

Commit

Permalink
Add endpoint to lists invited groups of a project
Browse files Browse the repository at this point in the history
  • Loading branch information
habnux committed Aug 28, 2024
1 parent 6404ea3 commit 8a4f93b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
29 changes: 29 additions & 0 deletions projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Relation []string `url:"relation,omitempty" json:"relation,omitempty"`
WithCustomAttributes bool `url:"with_custom_attributes,omitempty" json:"with_custom_attributes,omitempty"`
}

// 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) {
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)
}

// ShareWithGroupOptions represents options to share project with groups
//
// GitLab API docs: https://docs.gitlab.com/ee/api/projects.html#share-project-with-group
Expand Down
15 changes: 15 additions & 0 deletions projects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,21 @@ func TestListProjectForks(t *testing.T) {
}
}

func TestListProjectsInvitedGroups(t *testing.T) {
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)

Expand Down

0 comments on commit 8a4f93b

Please sign in to comment.