1212import org .gitlab4j .api .models .ChildEpic ;
1313import org .gitlab4j .api .models .CreatedChildEpic ;
1414import org .gitlab4j .api .models .Epic ;
15+ import org .gitlab4j .api .models .EpicFilter ;
1516import org .gitlab4j .api .models .EpicIssue ;
1617import org .gitlab4j .api .models .EpicIssueLink ;
1718import org .gitlab4j .api .models .LinkType ;
@@ -54,7 +55,7 @@ public List<Epic> getEpics(Object groupIdOrPath) throws GitLabApiException {
5455 *
5556 * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
5657 * @param page the page to get
57- * @param perPage the number of issues per page
58+ * @param perPage the number of epics per page
5859 * @return a list of all epics of the requested group and its subgroups in the specified range
5960 * @throws GitLabApiException if any exception occurs
6061 */
@@ -69,7 +70,7 @@ public List<Epic> getEpics(Object groupIdOrPath, int page, int perPage) throws G
6970 * <pre><code>GitLab Endpoint: GET /groups/:id/epics</code></pre>
7071 *
7172 * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
72- * @param itemsPerPage the number of issues per page
73+ * @param itemsPerPage the number of epics per page
7374 * @return the Pager of all epics of the requested group and its subgroups
7475 * @throws GitLabApiException if any exception occurs
7576 */
@@ -123,20 +124,28 @@ public List<Epic> getEpics(Object groupIdOrPath, Long authorId, String labels, E
123124 * @param sortOrder return epics sorted in ASC or DESC order. Default is DESC
124125 * @param search search epics against their title and description
125126 * @param page the page to get
126- * @param perPage the number of issues per page
127+ * @param perPage the number of epics per page
127128 * @return a list of matching epics of the requested group and its subgroups in the specified range
128129 * @throws GitLabApiException if any exception occurs
129130 */
130131 public List <Epic > getEpics (Object groupIdOrPath , Long authorId , String labels ,
131132 EpicOrderBy orderBy , SortOrder sortOrder , String search , int page , int perPage ) throws GitLabApiException {
132- GitLabApiForm formData = new GitLabApiForm (page , perPage )
133- .withParam ("author_id" , authorId )
134- .withParam ("labels" , labels )
135- .withParam ("order_by" , orderBy )
136- .withParam ("sort" , sortOrder )
137- .withParam ("search" , search );
138- Response response = get (Response .Status .OK , formData .asMap (), "groups" , getGroupIdOrPath (groupIdOrPath ), "epics" );
139- return (response .readEntity (new GenericType <List <Epic >>() { }));
133+ EpicFilter filter = createEpicFilter (authorId , labels , orderBy , sortOrder , search );
134+ return getEpics (groupIdOrPath , filter );
135+ }
136+
137+ /**
138+ * Gets all epics of the requested group and its subgroups using the specified page and per page setting.
139+ *
140+ * <pre><code>GitLab Endpoint: GET /groups/:id/epics</code></pre>
141+ *
142+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
143+ * @param filter epic filter
144+ * @return a list of matching epics of the requested group and its subgroups in the specified range
145+ * @throws GitLabApiException if any exception occurs
146+ */
147+ public List <Epic > getEpics (Object groupIdOrPath , EpicFilter filter ) throws GitLabApiException {
148+ return getEpics (groupIdOrPath , getDefaultPerPage (), filter ).all ();
140149 }
141150
142151 /**
@@ -148,7 +157,7 @@ public List<Epic> getEpics(Object groupIdOrPath, Long authorId, String labels,
148157 * @param authorId returns epics created by the given user id
149158 * @param labels return epics matching a comma separated list of labels names.
150159 * Label names from the epic group or a parent group can be used
151- * @param itemsPerPage the number of issues per page
160+ * @param itemsPerPage the number of epics per page
152161 * @param orderBy return epics ordered by CREATED_AT or UPDATED_AT. Default is CREATED_AT
153162 * @param sortOrder return epics sorted in ASC or DESC order. Default is DESC
154163 * @param search search epics against their title and description
@@ -157,13 +166,32 @@ public List<Epic> getEpics(Object groupIdOrPath, Long authorId, String labels,
157166 */
158167 public Pager <Epic > getEpics (Object groupIdOrPath , Long authorId , String labels ,
159168 EpicOrderBy orderBy , SortOrder sortOrder , String search , int itemsPerPage ) throws GitLabApiException {
160- GitLabApiForm formData = new GitLabApiForm ()
161- .withParam ("author_id" , authorId )
162- .withParam ("labels" , labels )
163- .withParam ("order_by" , orderBy )
164- .withParam ("sort" , sortOrder )
165- .withParam ("search" , search );
166- return (new Pager <Epic >(this , Epic .class , itemsPerPage , formData .asMap (), "groups" , getGroupIdOrPath (groupIdOrPath ), "epics" ));
169+ EpicFilter filter = createEpicFilter (authorId , labels , orderBy , sortOrder , search );
170+ return getEpics (groupIdOrPath , itemsPerPage , filter );
171+ }
172+
173+ /**
174+ * Gets all epics of the requested group and its subgroups using the specified page and per page setting.
175+ *
176+ * <pre><code>GitLab Endpoint: GET /groups/:id/epics</code></pre>
177+ *
178+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
179+ * @param filter epic filter
180+ * @param itemsPerPage the number of epics per page
181+ * @return a list of matching epics of the requested group and its subgroups in the specified range
182+ * @throws GitLabApiException if any exception occurs
183+ */
184+ public Pager <Epic > getEpics (Object groupIdOrPath , int itemsPerPage , EpicFilter filter ) throws GitLabApiException {
185+ return (new Pager <Epic >(this , Epic .class , itemsPerPage , filter .getQueryParams ().asMap (), "groups" , getGroupIdOrPath (groupIdOrPath ), "epics" ));
186+ }
187+
188+ private EpicFilter createEpicFilter (Long authorId , String labels , EpicOrderBy orderBy , SortOrder sortOrder , String search ) {
189+ return new EpicFilter ()
190+ .withAuthorId (authorId )
191+ .withLabels (labels )
192+ .withOrderBy (orderBy )
193+ .withSortOrder (sortOrder )
194+ .withSearch (search );
167195 }
168196
169197 /**
@@ -369,7 +397,7 @@ public List<EpicIssue> getEpicIssues(Object groupIdOrPath, Long epicIid) throws
369397 * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
370398 * @param epicIid the IID of the epic to get issues for
371399 * @param page the page to get
372- * @param perPage the number of issues per page
400+ * @param perPage the number of epics per page
373401 * @return a list of all issues belonging to the specified epic in the specified range
374402 * @throws GitLabApiException if any exception occurs
375403 */
@@ -385,7 +413,7 @@ public List<EpicIssue> getEpicIssues(Object groupIdOrPath, Long epicIid, int pag
385413 *
386414 * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
387415 * @param epicIid the IID of the epic to get issues for
388- * @param itemsPerPage the number of issues per page
416+ * @param itemsPerPage the number of epics per page
389417 * @return the Pager of all issues belonging to the specified epic
390418 * @throws GitLabApiException if any exception occurs
391419 */
0 commit comments