55
66import javax .ws .rs .core .Form ;
77import javax .ws .rs .core .GenericType ;
8+ import javax .ws .rs .core .MultivaluedMap ;
89import javax .ws .rs .core .Response ;
910
1011import org .gitlab4j .api .GitLabApi .ApiVersion ;
1112import org .gitlab4j .api .models .Commit ;
1213import org .gitlab4j .api .models .MergeRequest ;
14+ import org .gitlab4j .api .models .MergeRequestFilter ;
1315import org .gitlab4j .api .models .Participant ;
1416
1517/**
@@ -21,6 +23,52 @@ public MergeRequestApi(GitLabApi gitLabApi) {
2123 super (gitLabApi );
2224 }
2325
26+ /**
27+ * Get all merge requests matching the filter.
28+ *
29+ * GET /merge_requests
30+ *
31+ * @param filter a MergeRequestFilter instance with the filter settings
32+ * @return all merge requests for the specified project matching the filter
33+ * @throws GitLabApiException if any exception occurs
34+ */
35+ public List <MergeRequest > getMergeRequests (MergeRequestFilter filter ) throws GitLabApiException {
36+ return (getMergeRequests (filter , 1 , getDefaultPerPage ()));
37+ }
38+
39+ /**
40+ * Get all merge requests matching the filter.
41+ *
42+ * GET /merge_requests
43+ *
44+ * @param filter a MergeRequestFilter instance with the filter settings
45+ * @param page the page to get
46+ * @param perPage the number of MergeRequest instances per page
47+ * @return all merge requests for the specified project matching the filter
48+ * @throws GitLabApiException if any exception occurs
49+ */
50+ public List <MergeRequest > getMergeRequests (MergeRequestFilter filter , int page , int perPage ) throws GitLabApiException {
51+ MultivaluedMap <String , String > queryParams = (filter != null ?
52+ filter .getQueryParams (page , perPage ).asMap () : getPageQueryParams (page , perPage ));
53+ Response response = get (Response .Status .OK , queryParams , "merge_requests" );
54+ return (response .readEntity (new GenericType <List <MergeRequest >>() {}));
55+ }
56+
57+ /**
58+ * Get all merge requests matching the filter.
59+ *
60+ * GET /merge_requests
61+ *
62+ * @param filter a MergeRequestFilter instance with the filter settings
63+ * @param itemsPerPage the number of MergeRequest instances that will be fetched per page
64+ * @return all merge requests for the specified project matching the filter
65+ * @throws GitLabApiException if any exception occurs
66+ */
67+ public Pager <MergeRequest > getMergeRequests (MergeRequestFilter filter , int itemsPerPage ) throws GitLabApiException {
68+ MultivaluedMap <String , String > queryParams = (filter != null ? filter .getQueryParams ().asMap () : null );
69+ return (new Pager <MergeRequest >(this , MergeRequest .class , itemsPerPage , queryParams , "merge_requests" ));
70+ }
71+
2472 /**
2573 * Get all merge requests for the specified project.
2674 *
0 commit comments