From c3a034148e8182f936db3ff689d9d86e216ecca6 Mon Sep 17 00:00:00 2001 From: brochard <31168075+brochard@users.noreply.github.com> Date: Fri, 12 Apr 2024 17:48:05 +0200 Subject: [PATCH] Support returning Pager for getMergeRequest inside MilestonesApi (#1103) Fixes issue #1102 --- .../java/org/gitlab4j/api/MilestonesApi.java | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gitlab4j/api/MilestonesApi.java b/src/main/java/org/gitlab4j/api/MilestonesApi.java index 8204f204c..df81a0d0a 100644 --- a/src/main/java/org/gitlab4j/api/MilestonesApi.java +++ b/src/main/java/org/gitlab4j/api/MilestonesApi.java @@ -496,11 +496,37 @@ public Stream getIssuesStream(Object projectIdOrPath, Long milestoneId) t * @throws GitLabApiException if any exception occurs */ public List 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>() {})); + return (getMergeRequest(projectIdOrPath, milestoneId, getDefaultPerPage()).all()); } - + + /** + * Get a Pager of merge requests associated with the specified milestone. + * + *
GitLab Endpoint: GET /projects/:id/milestones/:milestone_id/merge_requests
+ * + * @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 getMergeRequest(Object projectIdOrPath, Long milestoneId, int itemsPerPage) throws GitLabApiException { + return (new Pager(this, MergeRequest.class, itemsPerPage, null, "projects", getProjectIdOrPath(projectIdOrPath), "milestones", milestoneId, "merge_requests")); + } + + /** + * Get a Stream of merge requests associated with the specified milestone. + * + *
GitLab Endpoint: GET /projects/:id/milestones/:milestone_id/merge_requests
+ * + * @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 getMergeRequestStream(Object projectIdOrPath, Long milestoneId) throws GitLabApiException { + return (getMergeRequest(projectIdOrPath, milestoneId, getDefaultPerPage()).stream()); + } + /** * Create a milestone. *