Commit b78db144 authored by mdeknowis's avatar mdeknowis Committed by Greg Messner
Browse files

Add all parameters to get project of group api (#269)

* Add all parameters listed by
https://docs.gitlab.com/ee/api/groups.html#list-a-groups-projects
parent b7b2e3af
......@@ -13,6 +13,7 @@ import org.gitlab4j.api.models.AccessLevel;
import org.gitlab4j.api.models.Group;
import org.gitlab4j.api.models.Member;
import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.ProjectOfGroupFilter;
import org.gitlab4j.api.models.Visibility;
/**
......@@ -224,6 +225,21 @@ public class GroupApi extends AbstractApi {
return (new Pager<Group>(this, Group.class, itemsPerPage, formData.asMap(), "groups", groupId, "subgroups"));
}
/**
* Get a list of projects belonging to the specified group ID.
*
* GET /groups/:id/projects
*
* @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
* @param filter the ProjectOfGroupFilter instance holding the filter values for the query
* @throws GitLabApiException if any exception occurs
*/
public List<Project> getProjects(Object groupIdOrPath, ProjectOfGroupFilter filter) throws GitLabApiException {
GitLabApiForm formData = filter.getQueryParams();
Response response = get(Response.Status.OK, formData.asMap(), "groups", getGroupIdOrPath(groupIdOrPath), "projects");
return (response.readEntity(new GenericType<List<Project>>() {}));
}
/**
* Get a list of projects belonging to the specified group ID.
*
......
package org.gitlab4j.api.models;
import org.gitlab4j.api.Constants.ProjectOrderBy;
import org.gitlab4j.api.Constants.SortOrder;
import org.gitlab4j.api.Constants;
import org.gitlab4j.api.GitLabApiForm;
/**
* This class is used to filter Projects when getting lists of projects for a specified group.
*/
public class ProjectOfGroupFilter {
private Boolean archived;
private Visibility visibility;
private ProjectOrderBy orderBy;
private SortOrder sort;
private String search;
private Boolean simple;
private Boolean owned;
private Boolean starred;
private Boolean withCustomAttributes;
private Boolean withIssuesEnabled;
private Boolean withMergeRequestsEnabled;
/**
* Limit by archived status.
*
* @param archived if true will only return archived projects
* @return the reference to this ProjectFilter instance
*/
public ProjectOfGroupFilter withArchived(Boolean archived) {
this.archived = archived;
return (this);
}
/**
* Limit by visibility public, internal, or private.
*
* @param visibility the visibility to match
* @return the reference to this ProjectFilter instance
*/
public ProjectOfGroupFilter withVisibility(Visibility visibility) {
this.visibility = visibility;
return (this);
}
/**
* Return projects ordered by id, name, path, created_at, updated_at, or last_activity_at fields. Default is created_at.
*
* @param orderBy specifies what field to order by
* @return the reference to this ProjectFilter instance
*/
public ProjectOfGroupFilter withOrderBy(ProjectOrderBy orderBy) {
this.orderBy = orderBy;
return (this);
}
/**
* Return projects sorted in asc or desc order. Default is desc.
*
* @param sort sort direction, ASC or DESC
* @return the reference to this ProjectFilter instance
*/
public ProjectOfGroupFilter withSortOder(SortOrder sort) {
this.sort = sort;
return (this);
}
/**
* Return list of projects matching the search criteria.
*
* @param search the search criteria
* @return the reference to this ProjectFilter instance
*/
public ProjectOfGroupFilter withSearch(String search) {
this.search = search;
return (this);
}
/**
* Return only limited fields for each project. This is a no-op without
* authentication as then only simple fields are returned.
*
* @param simple if true, return only limited fields for each project
* @return the reference to this ProjectFilter instance
*/
public ProjectOfGroupFilter withSimple(Boolean simple) {
this.simple = simple;
return (this);
}
/**
* Limit by projects explicitly owned by the current user
*
* @param owned if true, limit to projects explicitly owned by the current user
* @return the reference to this ProjectFilter instance
*/
public ProjectOfGroupFilter withOwned(Boolean owned) {
this.owned = owned;
return (this);
}
/**
* Limit by projects starred by the current user.
*
* @param starred if true, limit by projects starred by the current user
* @return the reference to this ProjectFilter instance
*/
public ProjectOfGroupFilter withStarred(Boolean starred) {
this.starred = starred;
return (this);
}
/**
* Include custom attributes in response (admins only).
*
* @param withCustomAttributes if true, include custom attributes in the repsonse
* @return the reference to this ProjectFilter instance
*/
public ProjectOfGroupFilter withCustomAttributes(Boolean withCustomAttributes) {
this.withCustomAttributes = withCustomAttributes;
return (this);
}
/**
* Limit by enabled issues feature
*
* @param withIssuesEnabled if true, limit by enabled issues feature
* @return the reference to this ProjectFilter instance
*/
public ProjectOfGroupFilter withIssuesEnabled(Boolean withIssuesEnabled) {
this.withIssuesEnabled = withIssuesEnabled;
return (this);
}
/**
* Limit by enabled merge requests feature
*
* @param withMergeRequestsEnabled if true, imit by enabled merge requests feature
* @return the reference to this ProjectFilter instance
*/
public ProjectOfGroupFilter withMergeRequestsEnabled(Boolean withMergeRequestsEnabled) {
this.withMergeRequestsEnabled = withMergeRequestsEnabled;
return (this);
}
/**
* Get the query params specified by this filter.
*
* @return a GitLabApiForm instance holding the query parameters for this ProjectFilter instance
*/
public GitLabApiForm getQueryParams() {
return (new GitLabApiForm()
.withParam("archived", archived)
.withParam("visibility", visibility)
.withParam("order_by", orderBy)
.withParam("sort", sort)
.withParam("search", search)
.withParam("simple", simple)
.withParam("owned", owned)
.withParam("starred", starred)
.withParam("with_custom_attributes", withCustomAttributes)
.withParam("with_issues_enabled", withIssuesEnabled)
.withParam("with_merge_requests_enabled ", withMergeRequestsEnabled)
);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment