Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #1102 Support returning Pager for getMergeRequest inside MilestonesApi #1103

Merged
merged 2 commits into from
Apr 12, 2024
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
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
Loading