Skip to content

Commit 83b4933

Browse files
committed
feat: Add pagination support for project badges (#1192)
1 parent d5bce14 commit 83b4933

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

gitlab4j-api/src/main/java/org/gitlab4j/api/ProjectApi.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3972,6 +3972,44 @@ public List<Badge> getBadges(Object projectIdOrPath, String bagdeName) throws Gi
39723972
return (response.readEntity(new GenericType<List<Badge>>() {}));
39733973
}
39743974

3975+
/**
3976+
* Gets a pager of a project’s badges and its group badges.
3977+
*
3978+
* <pre><code>GitLab Endpoint: GET /projects/:id/badges</code></pre>
3979+
*
3980+
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
3981+
* @param itemsPerPage the number of Badge instances that will be fetched per page
3982+
* @return a pager of Badge instances for the specified project
3983+
* @throws GitLabApiException if any exception occurs
3984+
*/
3985+
public Pager<Badge> getBadges(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException {
3986+
return getBadges(projectIdOrPath, null, itemsPerPage);
3987+
}
3988+
3989+
/**
3990+
* Gets a pager of a project’s badges and its group badges, case-sensitively filtered on bagdeName if non-null.
3991+
*
3992+
* <pre><code>GitLab Endpoint: GET /projects/:id/badges?name=:name</code></pre>
3993+
*
3994+
* @param projectIdOrPath the project in the form of a Long(ID), String(path), or Project instance
3995+
* @param bagdeName The name to filter on (case-sensitive), ignored if null.
3996+
* @param itemsPerPage the number of Badge instances that will be fetched per page
3997+
* @return a pager of the GitLab item, case insensitively filtered on name.
3998+
* @throws GitLabApiException If any problem is encountered
3999+
*/
4000+
public Pager<Badge> getBadges(Object projectIdOrPath, String bagdeName, int itemsPerPage)
4001+
throws GitLabApiException {
4002+
Form queryParam = new GitLabApiForm().withParam("name", bagdeName);
4003+
return new Pager<Badge>(
4004+
this,
4005+
Badge.class,
4006+
itemsPerPage,
4007+
queryParam.asMap(),
4008+
"projects",
4009+
getProjectIdOrPath(projectIdOrPath),
4010+
"badges");
4011+
}
4012+
39754013
/**
39764014
* Gets a badge of a project.
39774015
*

0 commit comments

Comments
 (0)