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.
@@ -103,6 +105,18 @@ public GroupFilter withCustomAttributes(Boolean withCustomAttributes) {
103
105
return (this );
104
106
}
105
107
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
+
106
120
/**
107
121
* Limit by groups explicitly owned by the current user
108
122
*
@@ -142,18 +156,20 @@ public GroupFilter withTopLevelOnly(Boolean topLevelOnly) {
142
156
* @return a GitLabApiForm instance holding the query parameters for this GroupFilter instance
143
157
*/
144
158
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 ;
157
173
}
158
174
159
175
@ Override
0 commit comments