Skip to content

Commit 1dd6e1e

Browse files
committed
Added getClosesIssues() methods (#264).
1 parent 769168d commit 1dd6e1e

File tree

1 file changed

+57
-7
lines changed

1 file changed

+57
-7
lines changed

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

+57-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
package org.gitlab4j.api;
22

3-
import org.gitlab4j.api.GitLabApi.ApiVersion;
4-
import org.gitlab4j.api.models.Commit;
5-
import org.gitlab4j.api.models.MergeRequest;
6-
import org.gitlab4j.api.models.MergeRequestFilter;
7-
import org.gitlab4j.api.models.Participant;
3+
import java.util.List;
4+
import java.util.Optional;
85

96
import javax.ws.rs.core.Form;
107
import javax.ws.rs.core.GenericType;
118
import javax.ws.rs.core.MultivaluedMap;
129
import javax.ws.rs.core.Response;
13-
import java.util.List;
14-
import java.util.Optional;
10+
11+
import org.gitlab4j.api.GitLabApi.ApiVersion;
12+
import org.gitlab4j.api.models.Commit;
13+
import org.gitlab4j.api.models.Issue;
14+
import org.gitlab4j.api.models.MergeRequest;
15+
import org.gitlab4j.api.models.MergeRequestFilter;
16+
import org.gitlab4j.api.models.Participant;
1517

1618
/**
1719
* This class implements the client side API for the GitLab merge request calls.
@@ -785,4 +787,52 @@ public List<Participant> getParticipants(Integer projectId, Integer mergeRequest
785787
public Pager<Participant> getParticipants(Integer projectId, Integer mergeRequestIid, int itemsPerPage) throws GitLabApiException {
786788
return new Pager<Participant>(this, Participant.class, itemsPerPage, null, "projects", projectId, "merge_requests", mergeRequestIid, "participants");
787789
}
790+
791+
/**
792+
* Get list containing all the issues that would be closed by merging the provided merge requestt.
793+
*
794+
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/closes_issues</code></pre>
795+
*
796+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
797+
* @param mergeRequestIid the IID of the merge request to get the closes issues for
798+
* @return a List containing all the issues that would be closed by merging the provided merge request
799+
* @throws GitLabApiException if any exception occurs
800+
*/
801+
public List<Issue> getClosesIssues(Object projectIdOrPath, Integer mergeRequestIid) throws GitLabApiException {
802+
return (getClosesIssues(projectIdOrPath, mergeRequestIid, 1, getDefaultPerPage()));
803+
}
804+
805+
/**
806+
* Get list containing all the issues that would be closed by merging the provided merge request.
807+
*
808+
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/closes_issues</code></pre>
809+
*
810+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
811+
* @param mergeRequestIid the IID of the merge request to get the closes issues for
812+
* @param page the page to get
813+
* @param perPage the number of issues per page
814+
* @return a List containing all the issues that would be closed by merging the provided merge request
815+
* @throws GitLabApiException if any exception occurs
816+
*/
817+
public List<Issue> getClosesIssues(Object projectIdOrPath, Integer mergeRequestIid, int page, int perPage) throws GitLabApiException {
818+
Response response = get(Response.Status.OK, getPageQueryParams(page, perPage),
819+
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "closes_issues");
820+
return (response.readEntity(new GenericType<List<Issue>>() { }));
821+
}
822+
823+
/**
824+
* Get a Pager containing all the issues that would be closed by merging the provided merge request.
825+
*
826+
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/closes_issues</code></pre>
827+
*
828+
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
829+
* @param mergeRequestIid the IID of the merge request to get the closes issues for
830+
* @param itemsPerPage the number of Issue instances that will be fetched per page
831+
* @return a Pager containing all the issues that would be closed by merging the provided merge request
832+
* @throws GitLabApiException if any exception occurs
833+
*/
834+
public Pager<Issue> getClosesIssues(Object projectIdOrPath, Integer mergeRequestIid, int itemsPerPage) throws GitLabApiException {
835+
return new Pager<Issue>(this, Issue.class, itemsPerPage, null,
836+
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "closes_issues");
837+
}
788838
}

0 commit comments

Comments
 (0)