Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions gitlab4j-api/src/main/java/org/gitlab4j/api/MergeRequestApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,52 @@ public List<MergeRequest> getMergeRequests(Object projectIdOrPath) throws GitLab
return (getMergeRequests(projectIdOrPath, getDefaultPerPage()).all());
}

/**
* Get all merge requests for the specified project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests</code></pre>
*
* @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<MergeRequest> getMergeRequests(Object projectIdOrPath, MergeRequestFilter filter)
throws GitLabApiException {
return (getMergeRequests(projectIdOrPath, filter, getDefaultPerPage()).all());
}

/**
* Get all merge requests for the specified project.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests</code></pre>
*
* @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<MergeRequest> 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<String, String> queryParams =
(filter != null ? new GitLabApiForm(filter.getQueryParams()).asMap() : null);
return (new Pager<MergeRequest>(
this,
MergeRequest.class,
itemsPerPage,
queryParams,
"projects",
getProjectIdOrPath(projectIdOrPath),
"merge_requests"));
}

/**
* Get all merge requests for the specified project.
*
Expand Down
Loading