Skip to content

Commit 9338e5c

Browse files
sb0210gmessner
authored andcommitted
Added getClosedByMergeRequests() methods. (#264) (#265)
1 parent 0e99bac commit 9338e5c

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.gitlab4j.api.models.Duration;
3535
import org.gitlab4j.api.models.Issue;
3636
import org.gitlab4j.api.models.IssueFilter;
37+
import org.gitlab4j.api.models.MergeRequest;
3738
import org.gitlab4j.api.models.TimeStats;
3839
import org.gitlab4j.api.utils.DurationUtils;
3940

@@ -621,4 +622,52 @@ public Optional<TimeStats> getOptionalTimeTrackingStats(Integer projectId, Integ
621622
return (GitLabApi.createOptionalFromException(glae));
622623
}
623624
}
625+
626+
/**
627+
* Get list containing all the merge requests that will close issue when merged.
628+
*
629+
* GET /projects/:id/issues/:issue_iid/closed_by
630+
*
631+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
632+
* @param issueIid the internal ID of a project's issue
633+
* @return a List containing all the merge requests what will close the issue when merged.
634+
* @throws GitLabApiException if any exception occurs
635+
*/
636+
public List<MergeRequest> getClosedByMergeRequests(Object projectIdOrPath, Integer issueIid) throws GitLabApiException {
637+
return (getClosedByMergeRequests(projectIdOrPath, issueIid, 1, getDefaultPerPage()));
638+
}
639+
640+
/**
641+
* Get list containing all the merge requests that will close issue when merged.
642+
*
643+
* GET /projects/:id/issues/:issue_iid/closed_by
644+
*
645+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
646+
* @param issueIid the internal ID of a project's issue
647+
* @param page the page to get
648+
* @param perPage the number of issues per page
649+
* @return a List containing all the merge requests what will close the issue when merged.
650+
* @throws GitLabApiException if any exception occurs
651+
*/
652+
public List<MergeRequest> getClosedByMergeRequests(Object projectIdOrPath, Integer issueIid, int page, int perPage) throws GitLabApiException {
653+
Response response = get(Response.Status.OK, getPageQueryParams(page, perPage),
654+
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "closed_by");
655+
return (response.readEntity(new GenericType<List<MergeRequest>>() { }));
656+
}
657+
658+
/**
659+
* Get a Pager containing all the merge requests that will close issue when merged.
660+
*
661+
* GET /projects/:id/issues/:issue_iid/closed_by
662+
*
663+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
664+
* @param issueIid the internal ID of a project's issue
665+
* @param itemsPerPage the number of Issue instances that will be fetched per page
666+
* @return a Pager containing all the issues that would be closed by merging the provided merge request
667+
* @throws GitLabApiException if any exception occurs
668+
*/
669+
public Pager<MergeRequest> getClosedByMergeRequests(Object projectIdOrPath, Integer issueIid, int itemsPerPage) throws GitLabApiException {
670+
return new Pager<MergeRequest>(this, MergeRequest.class, itemsPerPage, null,
671+
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "closed_by");
672+
}
624673
}

0 commit comments

Comments
 (0)