8000 allow fetching groups w/o projects by novalis · Pull Request #359 · timols/java-gitlab-api · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
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
37 changes: 35 additions & 2 deletions src/main/java/org/gitlab/api/GitlabAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class GitlabAPI {

private static final String DEFAULT_API_NAMESPACE = "/api/v4";
private static final String PARAM_SUDO = "sudo";
private static final String PARAM_WITH_PROJECTS = "with_projects";
private static final String PARAM_MAX_ITEMS_PER_PAGE = new Pagination().withPerPage(Pagination.MAX_ITEMS_PER_PAGE).toString();

private final String hostUrl;
Expand Down Expand Up @@ -464,17 +465,49 @@ public GitlabGroup getGroup(Integer groupId) throws IOException {
return getGroup(groupId.toString());
}

public GitlabGroup getGroupWithoutProjects(Integer groupId) throws IOException {
return getGroupWithoutProjects(groupId.toString());
}

/**
* Get a group by path
* Get a group by path. Don't include the projects.
*
* @param path Path of the group
* @return {@link GitlabGroup} object
*
* @throws IOException on gitlab api call error
*/
public GitlabGroup getGroupWithoutProjects(String path) throws IOException {
return getGroup(path, false);
}

/**
* Get a group by path, including its projects.
*
* @param path Path of the group
* @return {@link GitlabGroup} object
*
* @throws IOException on gitlab api call error
*/
public GitlabGroup getGroup(String path) throws IOException {
return getGroup(path, true);
}

/**
* Get a group by path
*
* @param path Path of the group
* @param withProjects If true, include the projects
* @return {@link GitlabGroup} object
*
* @throws IOException on gitlab api call error
*/
public GitlabGroup getGroup(String path, boolean withProjects) throws IOException {
String tailUrl = GitlabGroup.URL + "/" + URLEncoder.encode(path, "UTF-8");
return retrieve().to(tailUrl, GitlabGroup.class);
Query query = new Query()
.append(PARAM_WITH_PROJECTS, "" + withProjects);

return retrieve().to(tailUrl + query.toString(), GitlabGroup.class);
}

public List<GitlabGroup> getGroups() throws IOException {
Expand Down
0