[API] expose repo.GetReviewers() & repo.GetAssignees() (#16168)

* API: expose repo.GetReviewers() & repo.GetAssignees()

* Add tests

* fix unrelated swagger query type
This commit is contained in:
6543 2021-06-17 16:02:34 +02:00 committed by GitHub
parent 0db1048c3a
commit b3fbd37e99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 170 additions and 11 deletions

View file

@ -221,3 +221,63 @@ func DeleteCollaborator(ctx *context.APIContext) {
}
ctx.Status(http.StatusNoContent)
}
// GetReviewers return all users that can be requested to review in this repo
func GetReviewers(ctx *context.APIContext) {
// swagger:operation GET /repos/{owner}/{repo}/reviewers repository repoGetReviewers
// ---
// summary: Return all users that can be requested to review in this repo
// produces:
// - application/json
// parameters:
// - name: owner
// in: path
// description: owner of the repo
// type: string
// required: true
// - name: repo
// in: path
// description: name of the repo
// type: string
// required: true
// responses:
// "200":
// "$ref": "#/responses/UserList"
reviewers, err := ctx.Repo.Repository.GetReviewers(ctx.User.ID, 0)
if err != nil {
ctx.Error(http.StatusInternalServerError, "ListCollaborators", err)
return
}
ctx.JSON(http.StatusOK, convert.ToUsers(ctx.User, reviewers))
}
// GetAssignees return all users that have write access and can be assigned to issues
func GetAssignees(ctx *context.APIContext) {
// swagger:operation GET /repos/{owner}/{repo}/assignees repository repoGetAssignees
// ---
// summary: Return all users that have write access and can be assigned to issues
// produces:
// - application/json
// parameters:
// - name: owner
// in: path
// description: owner of the repo
// type: string
// required: true
// - name: repo
// in: path
// description: name of the repo
// type: string
// required: true
// responses:
// "200":
// "$ref": "#/responses/UserList"
assignees, err := ctx.Repo.Repository.GetAssignees()
if err != nil {
ctx.Error(http.StatusInternalServerError, "ListCollaborators", err)
return
}
ctx.JSON(http.StatusOK, convert.ToUsers(ctx.User, assignees))
}