Files
gitlab.nvim/cmd/members.go
Harrison (Harry) Cramer 844e093294 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.
2023-08-16 21:42:53 -04:00

44 lines
942 B
Go

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
}