Skip to content
Draft
Show file tree
Hide file tree
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
57 changes: 57 additions & 0 deletions gitlab4j-api/src/main/java/org/gitlab4j/api/GroupApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,63 @@ public Stream<Group> getGroupsStream() throws GitLabApiException {
return (getGroups(getDefaultPerPage()).stream());
}

/**
* Get a list of active groups
*
* <pre><code>GitLab Endpoint: GET /groups?active=true</code></pre>
*
* @return a list of active Groups
* @throws GitLabApiException if any exception occurs
*/
public List<Group> getActiveGroups() throws GitLabApiException {
return (getActiveGroups(getDefaultPerPage()).all());
}

/**
* Get a list of active groups using the specified page and per page settings.
*
* <pre><code>GitLab Endpoint: GET /groups?active=true</code></pre>
*
* @param page the page to get
* @param perPage the number of groups per page
* @return the list of active Groups in the specified range
* @throws GitLabApiException if any exception occurs
*/
public List<Group> getActiveGroups(int page, int perPage) throws GitLabApiException {
Form formData = new GitLabApiForm()
.withParam("active", true)
.withParam(PAGE_PARAM, page)
.withParam(PER_PAGE_PARAM, perPage);
Response response = get(Response.Status.OK, formData.asMap(), "groups");
return (response.readEntity(new GenericType<List<Group>>() {}));
}

/**
* Get a Pager of active groups.
*
* <pre><code>GitLab Endpoint: GET /groups?active=true</code></pre>
*
* @param itemsPerPage the number of active Group instances that will be fetched per page
* @return a Pager of active Groups
* @throws GitLabApiException if any exception occurs
*/
public Pager<Group> getActiveGroups(int itemsPerPage) throws GitLabApiException {
Form formData = new GitLabApiForm().withParam("active", true);
return (new Pager<Group>(this, Group.class, itemsPerPage, formData.asMap(), "groups"));
}

/**
* Get a Stream of active groups
*
* <pre><code>GitLab Endpoint: GET /groups?active=true</code></pre>
*
* @return a Stream of active Groups
* @throws GitLabApiException if any exception occurs
*/
public Stream<Group> getActiveGroupsStream() throws GitLabApiException {
return (getActiveGroups(getDefaultPerPage()).stream());
}

/**
* Get all groups that match your string in their name or path.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void setJobArtifactsSize(Long jobArtifactsSize) {

private String path;
private String description;
private String archived;
private Visibility visibility;
private Boolean lfsEnabled;
private Boolean requestAccessEnabled;
Expand Down Expand Up @@ -91,6 +92,14 @@ public void setDescription(String description) {
this.description = description;
}

public String getArchived() {
return archived;
}

public void setArchived(String archived) {
this.archived = archived;
}

public Visibility getVisibility() {
return visibility;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class GroupFilter implements Serializable {
private String search;
private GroupOrderBy orderBy;
private SortOrder sort;
private Boolean archived;
private Boolean active;
private Boolean statistics;
private Boolean withCustomAttributes;
private Boolean owned;
Expand Down Expand Up @@ -83,6 +85,28 @@ public GroupFilter withSortOder(SortOrder sort) {
return (this);
}

/**
* Include group archived status.
*
* @param archived If true, returns only archived groups
* @return the reference to this GroupFilter instance
*/
public GroupFilter withArchived(Boolean archived) {
this.archived = archived;
return (this);
}

/**
* Include group active status.
*
* @param active If true, returns only groups that are not archived and not marked for deletion.
* @return the reference to this GroupFilter instance
*/
public GroupFilter withActive(Boolean active) {
this.active = active;
return (this);
}

/**
* Include group statistics (admins only).
*
Expand Down Expand Up @@ -162,6 +186,8 @@ public GitLabForm getQueryParams() {
.withParam("search", search)
.withParam("order_by", orderBy)
.withParam("sort", sort)
.withParam("archived", archived)
.withParam("active", active)
.withParam("statistics", statistics)
.withParam("with_custom_attributes", withCustomAttributes)
.withParam("owned", owned)
Expand Down
Loading