66import org .gitlab4j .api .utils .JacksonJson ;
77
88import java .io .Serializable ;
9+ import java .util .ArrayList ;
910import java .util .List ;
1011
1112/**
@@ -24,6 +25,7 @@ public class GroupFilter implements Serializable {
2425 private Boolean owned ;
2526 private AccessLevel accessLevel ;
2627 private Boolean topLevelOnly ;
28+ private List <CustomAttribute > customAttributesFilter = new ArrayList <>();
2729
2830 /**
2931 * Do not include the provided groups IDs.
@@ -103,6 +105,18 @@ public GroupFilter withCustomAttributes(Boolean withCustomAttributes) {
103105 return (this );
104106 }
105107
108+ /**
109+ * Results must have custom attribute (admins only). Can be chained to combine multiple attribute checks.
110+ *
111+ * @param key the assets returned must have the specified custom attribute key
112+ * @param value the assets returned must have the specified value for the custom attribute key
113+ * @return the reference to this GroupFilter instance
114+ */
115+ public GroupFilter withCustomAttributeFilter (String key , String value ) {
116+ this .customAttributesFilter .add (new CustomAttribute ().withKey (key ).withValue (value ));
117+ return (this );
118+ }
119+
106120 /**
107121 * Limit by groups explicitly owned by the current user
108122 *
@@ -142,18 +156,20 @@ public GroupFilter withTopLevelOnly(Boolean topLevelOnly) {
142156 * @return a GitLabApiForm instance holding the query parameters for this GroupFilter instance
143157 */
144158 public GitLabApiForm getQueryParams () {
145- return (new GitLabApiForm ()
146- .withParam ("skip_groups" , skipGroups )
147- .withParam ("all_available" , allAvailable )
148- .withParam ("search" , search )
149- .withParam ("order_by" , orderBy )
150- .withParam ("sort" , sort )
151- .withParam ("statistics" , statistics )
152- .withParam ("with_custom_attributes" , withCustomAttributes )
153- .withParam ("owned" , owned )
154- .withParam ("min_access_level" , accessLevel )
155- .withParam ("top_level_only" , topLevelOnly )
156- );
159+ GitLabApiForm form = new GitLabApiForm ().withParam ("skip_groups" , skipGroups )
160+ .withParam ("all_available" , allAvailable )
161+ .withParam ("search" , search )
162+ .withParam ("order_by" , orderBy )
163+ .withParam ("sort" , sort )
164+ .withParam ("statistics" , statistics )
165+ .withParam ("with_custom_attributes" , withCustomAttributes )
166+ .withParam ("owned" , owned )
167+ .withParam ("min_access_level" , accessLevel )
168+ .withParam ("top_level_only" , topLevelOnly );
169+ for (CustomAttribute customAttribute : customAttributesFilter ) {
170+ form .withParam (String .format ("custom_attributes[%s]" , customAttribute .getKey ()), customAttribute .getValue ());
171+ }
172+ return form ;
157173 }
158174
159175 @ Override
0 commit comments