6
6
import org .gitlab4j .api .utils .JacksonJson ;
7
7
8
8
import java .io .Serializable ;
9
+ import java .util .ArrayList ;
9
10
import java .util .List ;
10
11
11
12
/**
@@ -24,6 +25,7 @@ public class GroupFilter implements Serializable {
24
25
private Boolean owned ;
25
26
private AccessLevel accessLevel ;
26
27
private Boolean topLevelOnly ;
28
+ private List <CustomAttribute > customAttributesFilter = new ArrayList <>();
27
29
28
30
/**
29
31
* Do not include the provided groups IDs.
@@ -111,6 +113,18 @@ public GroupFilter withCustomAttributes(Boolean withCustomAttributes) {
111
113
return (this );
112
114
}
113
115
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
+
114
128
/**
115
129
* Limit by groups explicitly owned by the current user
116
130
*
@@ -150,18 +164,20 @@ public GroupFilter withTopLevelOnly(Boolean topLevelOnly) {
150
164
* @return a GitLabApiForm instance holding the query parameters for this GroupFilter instance
151
165
*/
152
166
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 ;
165
181
}
166
182
167
183
@ Override
0 commit comments