Skip to content

Add pagination support for project badges #1270

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

Merged
merged 1 commit into from
Aug 20, 2025
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
38 changes: 38 additions & 0 deletions gitlab4j-api/src/main/java/org/gitlab4j/api/ProjectApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -3972,6 +3972,44 @@ public List<Badge> getBadges(Object projectIdOrPath, String bagdeName) throws Gi
return (response.readEntity(new GenericType<List<Badge>>() {}));
}

/**
* Gets a pager of a project’s badges and its group badges.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/badges</code></pre>
*
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
* @param itemsPerPage the number of Badge instances that will be fetched per page
* @return a pager of Badge instances for the specified project
* @throws GitLabApiException if any exception occurs
*/
public Pager<Badge> getBadges(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException {
return getBadges(projectIdOrPath, null, itemsPerPage);
}

/**
* Gets a pager of a project’s badges and its group badges, case-sensitively filtered on bagdeName if non-null.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/badges?name=:name</code></pre>
*
* @param projectIdOrPath the project in the form of a Long(ID), String(path), or Project instance
* @param bagdeName The name to filter on (case-sensitive), ignored if null.
* @param itemsPerPage the number of Badge instances that will be fetched per page
* @return a pager of the GitLab item, case insensitively filtered on name.
* @throws GitLabApiException If any problem is encountered
*/
public Pager<Badge> getBadges(Object projectIdOrPath, String bagdeName, int itemsPerPage)
throws GitLabApiException {
Form queryParam = new GitLabApiForm().withParam("name", bagdeName);
return new Pager<Badge>(
this,
Badge.class,
itemsPerPage,
queryParam.asMap(),
"projects",
getProjectIdOrPath(projectIdOrPath),
"badges");
}

/**
* Gets a badge of a project.
*
Expand Down
Loading