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.
@@ -111,6 +113,18 @@ public GroupFilter withCustomAttributes(Boolean withCustomAttributes) {
111113 return (this );
112114 }
113115
116+ /**
117+ * Results must have custom attribute (admins only). Can be chained to combine multiple attribute checks.
118+ *
119+ * @param key the assets returned must have the specified custom attribute key
120+ * @param value the assets returned must have the specified value for the custom attribute key
121+ * @return the reference to this GroupFilter instance
122+ */
123+ public GroupFilter withCustomAttributeFilter (String key , String value ) {
124+ this .customAttributesFilter .add (new CustomAttribute ().withKey (key ).withValue (value ));
125+ return (this );
126+ }
127+
114128 /**
115129 * Limit by groups explicitly owned by the current user
116130 *
@@ -150,18 +164,20 @@ public GroupFilter withTopLevelOnly(Boolean topLevelOnly) {
150164 * @return a GitLabApiForm instance holding the query parameters for this GroupFilter instance
151165 */
152166 public GitLabApiForm getQueryParams () {
153- return (new GitLabApiForm ()
154- .withParam ("skip_groups" , skipGroups )
155- .withParam ("all_available" , allAvailable )
156- .withParam ("search" , search )
157- .withParam ("order_by" , orderBy )
158- .withParam ("sort" , sort )
159- .withParam ("statistics" , statistics )
160- .withParam ("with_custom_attributes" , withCustomAttributes )
161- .withParam ("owned" , owned )
162- .withParam ("min_access_level" , accessLevel )
163- .withParam ("top_level_only" , topLevelOnly )
164- );
167+ GitLabApiForm form = new GitLabApiForm ().withParam ("skip_groups" , skipGroups )
168+ .withParam ("all_available" , allAvailable )
169+ .withParam ("search" , search )
170+ .withParam ("order_by" , orderBy )
171+ .withParam ("sort" , sort )
172+ .withParam ("statistics" , statistics )
173+ .withParam ("with_custom_attributes" , withCustomAttributes )
174+ .withParam ("owned" , owned )
175+ .withParam ("min_access_level" , accessLevel )
176+ .withParam ("top_level_only" , topLevelOnly );
177+ for (CustomAttribute customAttribute : customAttributesFilter ) {
178+ form .withParam (String .format ("custom_attributes[%s]" , customAttribute .getKey ()), customAttribute .getValue ());
179+ }
180+ return form ;
165181 }
166182
167183 @ Override
0 commit comments