55import java .util .List ;
66import java .util .Objects ;
77import java .util .Optional ;
8+ import java .util .stream .Collectors ;
89import java .util .stream .Stream ;
910
1011import javax .ws .rs .core .Form ;
@@ -1572,8 +1573,23 @@ public void denyAccessRequest(Object groupIdOrPath, Long userId) throws GitLabAp
15721573 * @throws GitLabApiException if any exception occurs
15731574 */
15741575 public List <Badge > getBadges (Object groupIdOrPath ) throws GitLabApiException {
1575- Response response = get (Response .Status .OK , null , "groups" , getGroupIdOrPath (groupIdOrPath ), "badges" );
1576- return (response .readEntity (new GenericType <List <Badge >>() {}));
1576+ return getBadges (groupIdOrPath , null );
1577+ }
1578+
1579+ /**
1580+ * Gets a list of a group’s badges, case-sensitively filtered on bagdeName if non-null.
1581+ *
1582+ * <pre><code>GitLab Endpoint: GET /groups/:id/badges?name=:name</code></pre>
1583+ *
1584+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
1585+ * @param badgeName The name to filter on (case-sensitive), ignored if null.
1586+ * @return All badges of the GitLab item, case insensitively filtered on name.
1587+ * @throws GitLabApiException If any problem is encountered
1588+ */
1589+ public List <Badge > getBadges (Object groupIdOrPath , String badgeName ) throws GitLabApiException {
1590+ Form queryParam = new GitLabApiForm ().withParam ("name" , badgeName );
1591+ Response response = get (Response .Status .OK , queryParam .asMap (), "groups" , getGroupIdOrPath (groupIdOrPath ), "badges" );
1592+ return (response .readEntity (new GenericType <List <Badge >>() {}));
15771593 }
15781594
15791595 /**
@@ -1620,11 +1636,28 @@ public Optional<Badge> getOptionalBadge(Object groupIdOrPath, Long badgeId) {
16201636 * @throws GitLabApiException if any exception occurs
16211637 */
16221638 public Badge addBadge (Object groupIdOrPath , String linkUrl , String imageUrl ) throws GitLabApiException {
1623- GitLabApiForm formData = new GitLabApiForm ()
1624- .withParam ("link_url" , linkUrl , true )
1625- .withParam ("image_url" , imageUrl , true );
1626- Response response = post (Response .Status .OK , formData , "groups" , getGroupIdOrPath (groupIdOrPath ), "badges" );
1627- return (response .readEntity (Badge .class ));
1639+ return addBadge (groupIdOrPath , null , linkUrl , imageUrl );
1640+ }
1641+
1642+ /**
1643+ * Add a badge to a group.
1644+ *
1645+ * <pre><code>GitLab Endpoint: POST /groups/:id/badges</code></pre>
1646+ *
1647+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
1648+ * @param name The name to give the badge (may be null)
1649+ * @param linkUrl the URL of the badge link
1650+ * @param imageUrl the URL of the image link
1651+ * @return A Badge instance for the added badge
1652+ * @throws GitLabApiException if any exception occurs
1653+ */
1654+ public Badge addBadge (Object groupIdOrPath , String name , String linkUrl , String imageUrl ) throws GitLabApiException {
1655+ GitLabApiForm formData = new GitLabApiForm ()
1656+ .withParam ("name" , name , false )
1657+ .withParam ("link_url" , linkUrl , true )
1658+ .withParam ("image_url" , imageUrl , true );
1659+ Response response = post (Response .Status .OK , formData , "groups" , getGroupIdOrPath (groupIdOrPath ), "badges" );
1660+ return (response .readEntity (Badge .class ));
16281661 }
16291662
16301663 /**
@@ -1640,11 +1673,29 @@ public Badge addBadge(Object groupIdOrPath, String linkUrl, String imageUrl) thr
16401673 * @throws GitLabApiException if any exception occurs
16411674 */
16421675 public Badge editBadge (Object groupIdOrPath , Long badgeId , String linkUrl , String imageUrl ) throws GitLabApiException {
1643- GitLabApiForm formData = new GitLabApiForm ()
1644- .withParam ("link_url" , linkUrl , false )
1645- .withParam ("image_url" , imageUrl , false );
1646- Response response = putWithFormData (Response .Status .OK , formData , "groups" , getGroupIdOrPath (groupIdOrPath ), "badges" , badgeId );
1647- return (response .readEntity (Badge .class ));
1676+ return (editBadge (groupIdOrPath , badgeId , null , linkUrl , imageUrl ));
1677+ }
1678+
1679+ /**
1680+ * Edit a badge of a group.
1681+ *
1682+ * <pre><code>GitLab Endpoint: PUT /groups/:id/badges</code></pre>
1683+ *
1684+ * @param groupIdOrPath the group ID, path of the group, or a Group instance holding the group ID or path
1685+ * @param badgeId the ID of the badge to edit
1686+ * @param name The name of the badge to edit (may be null)
1687+ * @param linkUrl the URL of the badge link
1688+ * @param imageUrl the URL of the image link
1689+ * @return a Badge instance for the edited badge
1690+ * @throws GitLabApiException if any exception occurs
1691+ */
1692+ public Badge editBadge (Object groupIdOrPath , Long badgeId , String name , String linkUrl , String imageUrl ) throws GitLabApiException {
1693+ GitLabApiForm formData = new GitLabApiForm ()
1694+ .withParam ("name" , name , false )
1695+ .withParam ("link_url" , linkUrl , false )
1696+ .withParam ("image_url" , imageUrl , false );
1697+ Response response = putWithFormData (Response .Status .OK , formData , "groups" , getGroupIdOrPath (groupIdOrPath ), "badges" , badgeId );
1698+ return (response .readEntity (Badge .class ));
16481699 }
16491700
16501701 /**
0 commit comments