diff --git a/gitlab4j-api/src/main/java/org/gitlab4j/api/MergeRequestApi.java b/gitlab4j-api/src/main/java/org/gitlab4j/api/MergeRequestApi.java index 13fead670..6c2ff6626 100644 --- a/gitlab4j-api/src/main/java/org/gitlab4j/api/MergeRequestApi.java +++ b/gitlab4j-api/src/main/java/org/gitlab4j/api/MergeRequestApi.java @@ -155,6 +155,52 @@ public List getMergeRequests(Object projectIdOrPath) throws GitLab return (getMergeRequests(projectIdOrPath, getDefaultPerPage()).all()); } + /** + * Get all merge requests for the specified project. + * + *
GitLab Endpoint: GET /projects/:id/merge_requests
+ * + * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance + * @param filter a MergeRequestFilter instance with the filter settings + * @return all merge requests for the specified project matching the filter + * @throws GitLabApiException if any exception occurs + */ + public List getMergeRequests(Object projectIdOrPath, MergeRequestFilter filter) + throws GitLabApiException { + return (getMergeRequests(projectIdOrPath, filter, getDefaultPerPage()).all()); + } + + /** + * Get all merge requests for the specified project. + * + *
GitLab Endpoint: GET /projects/:id/merge_requests
+ * + * @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance + * @param filter a MergeRequestFilter instance with the filter settings + * @param itemsPerPage the number of MergeRequest instances that will be fetched per page + * @return all merge requests for the specified project matching the filter + * @throws GitLabApiException if any exception occurs + */ + public Pager getMergeRequests(Object projectIdOrPath, MergeRequestFilter filter, int itemsPerPage) + throws GitLabApiException { + + if (filter != null && filter.getProjectId() != null) { + throw new RuntimeException( + "projectId cannot be specified in filter, use projectIdOrPath parameter instead"); + } + + MultivaluedMap queryParams = + (filter != null ? new GitLabApiForm(filter.getQueryParams()).asMap() : null); + return (new Pager( + this, + MergeRequest.class, + itemsPerPage, + queryParams, + "projects", + getProjectIdOrPath(projectIdOrPath), + "merge_requests")); + } + /** * Get all merge requests for the specified project. *