Skip to content

Commit f951568

Browse files
authored
Add pagination support for project badges (#1270)
1 parent 493f3a1 commit f951568

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
@@ -3976,6 +3976,44 @@ public List<Badge> getBadges(Object projectIdOrPath, String bagdeName) throws Gi
39763976
return (response.readEntity(new GenericType<List<Badge>>() {}));
39773977
}
39783978

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

0 commit comments

Comments
 (0)