Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getDescendantGroups() methods to GroupApi #907

Merged
merged 2 commits into from
Mar 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add getDescendantGroups() methods to GroupApi
jmini committed Feb 8, 2023
commit ad6f85f7290dafd47f1da6e92f77fc74d1773cc4
44 changes: 44 additions & 0 deletions src/main/java/org/gitlab4j/api/GroupApi.java
Original file line number Diff line number Diff line change
@@ -350,6 +350,50 @@ public Stream<Group> getSubGroupsStream(Object groupIdOrPath, List<Integer> skip
return (getSubGroups(groupIdOrPath, skipGroups, allAvailable, search, orderBy, sortOrder, statistics, owned, getDefaultPerPage()).stream());
}

/**
* Get a list of visible descendant groups of a given group for the authenticated user using the provided filter.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/descendant_groups</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
* @param filter the GroupFilter to match against
* @return a List&lt;Group&gt; of the matching groups
* @throws GitLabApiException if any exception occurs
*/
public List<Group> getDescendantGroups(Object groupIdOrPath, GroupFilter filter) throws GitLabApiException {
return (getDescendantGroups(groupIdOrPath, filter, getDefaultPerPage()).all());
}

/**
* Get a Pager of visible descendant groups of a given group for the authenticated user using the provided filter.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/descendant_groups</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
* @param filter the GroupFilter to match against
* @param itemsPerPage the number of Group instances that will be fetched per page
* @return a Pager containing matching Group instances
* @throws GitLabApiException if any exception occurs
*/
public Pager<Group> getDescendantGroups(Object groupIdOrPath, GroupFilter filter, int itemsPerPage) throws GitLabApiException {
GitLabApiForm formData = filter.getQueryParams();
return (new Pager<Group>(this, Group.class, itemsPerPage, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "descendant_groups"));
}

/**
* Get a Stream of visible descendant groups of a given group for the authenticated user using the provided filter.
*
* <pre><code>GitLab Endpoint: GET /groups/:id/descendant_groups</code></pre>
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path, required
* @param filter the GroupFilter to match against
* @return a Stream&lt;Group&gt; of the matching groups
* @throws GitLabApiException if any exception occurs
*/
public Stream<Group> getDescendantGroupsStream(Object groupIdOrPath, GroupFilter filter) throws GitLabApiException {
return (getDescendantGroups(groupIdOrPath, filter, getDefaultPerPage()).stream());
}

/**
* Get a list of projects belonging to the specified group ID and filter.
*