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:
Harrison (Harry) Cramer
2023-08-16 21:42:53 -04:00
committed by GitHub
parent 6274746d4b
commit 844e093294
10 changed files with 368 additions and 44 deletions

43
cmd/members.go Normal file
View 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
}