Skip to content

Commit

Permalink
Support returning Pager for getMergeRequest inside MilestonesApi (#1103)
Browse files Browse the repository at this point in the history
Fixes issue #1102
  • Loading branch information
brochard authored Apr 12, 2024
1 parent 6c06521 commit c3a0341
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions src/main/java/org/gitlab4j/api/MilestonesApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,37 @@ public Stream<Issue> getIssuesStream(Object projectIdOrPath, Long milestoneId) t
* @throws GitLabApiException if any exception occurs
*/
public List<MergeRequest> getMergeRequest(Object projectIdOrPath, Long milestoneId) throws GitLabApiException {
Response response = get(Response.Status.OK, getDefaultPerPageParam(),
"projects", getProjectIdOrPath(projectIdOrPath), "milestones", milestoneId, "merge_requests");
return (response.readEntity(new GenericType<List<MergeRequest>>() {}));
return (getMergeRequest(projectIdOrPath, milestoneId, getDefaultPerPage()).all());
}


/**
* Get a Pager of merge requests associated with the specified milestone.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/milestones/:milestone_id/merge_requests</code></pre>
*
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
* @param milestoneId the milestone ID to get the merge requests for
* @return a Pager of merge requests associated with the specified milestone
* @throws GitLabApiException if any exception occurs
*/
public Pager<MergeRequest> getMergeRequest(Object projectIdOrPath, Long milestoneId, int itemsPerPage) throws GitLabApiException {
return (new Pager<MergeRequest>(this, MergeRequest.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "milestones", milestoneId, "merge_requests"));
}

/**
* Get a Stream of merge requests associated with the specified milestone.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/milestones/:milestone_id/merge_requests</code></pre>
*
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
* @param milestoneId the milestone ID to get the merge requests for
* @return a Stream of merge requests associated with the specified milestone
* @throws GitLabApiException if any exception occurs
*/
public Stream<MergeRequest> getMergeRequestStream(Object projectIdOrPath, Long milestoneId) throws GitLabApiException {
return (getMergeRequest(projectIdOrPath, milestoneId, getDefaultPerPage()).stream());
}

/**
* Create a milestone.
*
Expand Down

0 comments on commit c3a0341

Please sign in to comment.