Add/Remove Reviewers and Assignees (#38)
Adds APIs for the ability to add or remove reviewers and assignees to a merge request. The eligible reviewers and assignees are pulled from the current members of a project.
This commit is contained in:
committed by
GitHub
parent
6274746d4b
commit
844e093294
43
cmd/members.go
Normal file
43
cmd/members.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/xanzy/go-gitlab"
|
||||
)
|
||||
|
||||
type ProjectMembersResponse struct {
|
||||
SuccessResponse
|
||||
ProjectMembers []*gitlab.ProjectMember
|
||||
}
|
||||
|
||||
func ProjectMembersHandler(w http.ResponseWriter, r *http.Request) {
|
||||
c := r.Context().Value("client").(Client)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
projectMemberOptions := gitlab.ListProjectMembersOptions{
|
||||
ListOptions: gitlab.ListOptions{
|
||||
PerPage: 100,
|
||||
},
|
||||
}
|
||||
|
||||
projectMembers, res, err := c.git.ProjectMembers.ListAllProjectMembers(c.projectId, &projectMemberOptions)
|
||||
if err != nil {
|
||||
c.handleError(w, err, "Could not fetch project users", res.StatusCode)
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
response := ProjectMembersResponse{
|
||||
SuccessResponse: SuccessResponse{
|
||||
Status: http.StatusOK,
|
||||
Message: "Project users fetched successfully",
|
||||
},
|
||||
ProjectMembers: projectMembers,
|
||||
}
|
||||
|
||||
json.NewEncoder(w).Encode(response)
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user