Skip to content

Commit c3a0341

Browse files
authored
Support returning Pager for getMergeRequest inside MilestonesApi (#1103)
Fixes issue #1102
1 parent 6c06521 commit c3a0341

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

src/main/java/org/gitlab4j/api/MilestonesApi.java

+30-4
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,37 @@ public Stream<Issue> getIssuesStream(Object projectIdOrPath, Long milestoneId) t
496496
* @throws GitLabApiException if any exception occurs
497497
*/
498498
public List<MergeRequest> getMergeRequest(Object projectIdOrPath, Long milestoneId) throws GitLabApiException {
499-
Response response = get(Response.Status.OK, getDefaultPerPageParam(),
500-
"projects", getProjectIdOrPath(projectIdOrPath), "milestones", milestoneId, "merge_requests");
501-
return (response.readEntity(new GenericType<List<MergeRequest>>() {}));
499+
return (getMergeRequest(projectIdOrPath, milestoneId, getDefaultPerPage()).all());
502500
}
503-
501+
502+
/**
503+
* Get a Pager of merge requests associated with the specified milestone.
504+
*
505+
* <pre><code>GitLab Endpoint: GET /projects/:id/milestones/:milestone_id/merge_requests</code></pre>
506+
*
507+
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
508+
* @param milestoneId the milestone ID to get the merge requests for
509+
* @return a Pager of merge requests associated with the specified milestone
510+
* @throws GitLabApiException if any exception occurs
511+
*/
512+
public Pager<MergeRequest> getMergeRequest(Object projectIdOrPath, Long milestoneId, int itemsPerPage) throws GitLabApiException {
513+
return (new Pager<MergeRequest>(this, MergeRequest.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "milestones", milestoneId, "merge_requests"));
514+
}
515+
516+
/**
517+
* Get a Stream of merge requests associated with the specified milestone.
518+
*
519+
* <pre><code>GitLab Endpoint: GET /projects/:id/milestones/:milestone_id/merge_requests</code></pre>
520+
*
521+
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
522+
* @param milestoneId the milestone ID to get the merge requests for
523+
* @return a Stream of merge requests associated with the specified milestone
524+
* @throws GitLabApiException if any exception occurs
525+
*/
526+
public Stream<MergeRequest> getMergeRequestStream(Object projectIdOrPath, Long milestoneId) throws GitLabApiException {
527+
return (getMergeRequest(projectIdOrPath, milestoneId, getDefaultPerPage()).stream());
528+
}
529+
504530
/**
505531
* Create a milestone.
506532
*

0 commit comments

Comments
 (0)