Skip to content

Commit d8a7ea9

Browse files
authored
Add getDescendantGroups() methods to GroupApi (#907)
* Add getDescendantGroups() methods to GroupApi * Update javadoc
1 parent 336a8c8 commit d8a7ea9

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

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

+44
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,50 @@ public Stream<Group> getSubGroupsStream(Object groupIdOrPath, List<Integer> skip
350350
return (getSubGroups(groupIdOrPath, skipGroups, allAvailable, search, orderBy, sortOrder, statistics, owned, getDefaultPerPage()).stream());
351351
}
352352

353+
/**
354+
* Get a list of visible descendant groups of a given group for the authenticated user using the provided filter.
355+
*
356+
* <pre><code>GitLab Endpoint: GET /groups/:id/descendant_groups</code></pre>
357+
*
358+
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
359+
* @param filter the GroupFilter to match against
360+
* @return a List&lt;Group&gt; of the matching groups
361+
* @throws GitLabApiException if any exception occurs
362+
*/
363+
public List<Group> getDescendantGroups(Object groupIdOrPath, GroupFilter filter) throws GitLabApiException {
364+
return (getDescendantGroups(groupIdOrPath, filter, getDefaultPerPage()).all());
365+
}
366+
367+
/**
368+
* Get a Pager of visible descendant groups of a given group for the authenticated user using the provided filter.
369+
*
370+
* <pre><code>GitLab Endpoint: GET /groups/:id/descendant_groups</code></pre>
371+
*
372+
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
373+
* @param filter the GroupFilter to match against
374+
* @param itemsPerPage the number of Group instances that will be fetched per page
375+
* @return a Pager containing matching Group instances
376+
* @throws GitLabApiException if any exception occurs
377+
*/
378+
public Pager<Group> getDescendantGroups(Object groupIdOrPath, GroupFilter filter, int itemsPerPage) throws GitLabApiException {
379+
GitLabApiForm formData = filter.getQueryParams();
380+
return (new Pager<Group>(this, Group.class, itemsPerPage, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "descendant_groups"));
381+
}
382+
383+
/**
384+
* Get a Stream of visible descendant groups of a given group for the authenticated user using the provided filter.
385+
*
386+
* <pre><code>GitLab Endpoint: GET /groups/:id/descendant_groups</code></pre>
387+
*
388+
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
389+
* @param filter the GroupFilter to match against
390+
* @return a Stream&lt;Group&gt; of the matching groups
391+
* @throws GitLabApiException if any exception occurs
392+
*/
393+
public Stream<Group> getDescendantGroupsStream(Object groupIdOrPath, GroupFilter filter) throws GitLabApiException {
394+
return (getDescendantGroups(groupIdOrPath, filter, getDefaultPerPage()).stream());
395+
}
396+
353397
/**
354398
* Get a list of projects belonging to the specified group ID and filter.
355399
*

src/main/java/org/gitlab4j/api/models/GroupFilter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import org.gitlab4j.api.GitLabApiForm;
88

99
/**
10-
* This class is used to filter Projects when getting lists of projects for a specified group.
10+
* This class is used to filter Groups when getting lists of groups.
1111
*/
1212
public class GroupFilter {
1313

0 commit comments

Comments
 (0)