@@ -183,14 +183,77 @@ public Group getGroup(String groupPath) throws GitLabApiException {
183
183
*
184
184
* @param name the name of the group to add
185
185
* @param path the path for the group
186
+ * @return the created Group instance
186
187
* @throws GitLabApiException if any exception occurs
187
188
*/
188
- public void addGroup (String name , String path ) throws GitLabApiException {
189
+ public Group addGroup (String name , String path ) throws GitLabApiException {
189
190
190
191
Form formData = new Form ();
191
192
formData .param ("name" , name );
192
193
formData .param ("path" , path );
193
- post (Response .Status .CREATED , formData , "groups" );
194
+ Response response = post (Response .Status .CREATED , formData , "groups" );
195
+ return (response .readEntity (Group .class ));
196
+ }
197
+
198
+ /**
199
+ * Creates a new project group. Available only for users who can create groups.
200
+ *
201
+ * POST /groups
202
+ *
203
+ * @param name the name of the group to add
204
+ * @param path the path for the group
205
+ * @param description (optional) - The group's description
206
+ * @param visibility (optional) - The group's visibility. Can be private, internal, or public.
207
+ * @param lfsEnabled (optional) - Enable/disable Large File Storage (LFS) for the projects in this group
208
+ * @param requestAccessEnabled (optional) - Allow users to request member access
209
+ * @param parentId (optional) - The parent group id for creating nested group
210
+ * @return the created Group instance
211
+ * @throws GitLabApiException if any exception occurs
212
+ */
213
+ public Group addGroup (String name , String path , String description , Visibility visibility ,
214
+ Boolean lfsEnabled , Boolean requestAccessEnabled , Integer parentId ) throws GitLabApiException {
215
+
216
+ Form formData = new GitLabApiForm ()
217
+ .withParam ("name" , name )
218
+ .withParam ("path" , path )
219
+ .withParam ("description" , description )
220
+ .withParam ("visibility" , visibility )
221
+ .withParam ("lfs_enabled" , lfsEnabled )
222
+ .withParam ("request_access_enabled" , requestAccessEnabled )
223
+ .withParam ("parent_id" , isApiVersion (ApiVersion .V3 ) ? null : parentId );
224
+ Response response = post (Response .Status .CREATED , formData , "groups" );
225
+ return (response .readEntity (Group .class ));
226
+ }
227
+
228
+ /**
229
+ * Updates a project group. Available only for users who can create groups.
230
+ *
231
+ * PUT /groups
232
+ *
233
+ * @param groupId the ID of the group to update
234
+ * @param name the name of the group to add
235
+ * @param path the path for the group
236
+ * @param description (optional) - The group's description
237
+ * @param visibility (optional) - The group's visibility. Can be private, internal, or public.
238
+ * @param lfsEnabled (optional) - Enable/disable Large File Storage (LFS) for the projects in this group
239
+ * @param requestAccessEnabled (optional) - Allow users to request member access
240
+ * @param parentId (optional) - The parent group id for creating nested group
241
+ * @return the updated Group instance
242
+ * @throws GitLabApiException if any exception occurs
243
+ */
244
+ public Group updateGroup (Integer groupId , String name , String path , String description , Visibility visibility ,
245
+ Boolean lfsEnabled , Boolean requestAccessEnabled , Integer parentId ) throws GitLabApiException {
246
+
247
+ Form formData = new GitLabApiForm ()
248
+ .withParam ("name" , name )
249
+ .withParam ("path" , path )
250
+ .withParam ("description" , description )
251
+ .withParam ("visibility" , visibility )
252
+ .withParam ("lfs_enabled" , lfsEnabled )
253
+ .withParam ("request_access_enabled" , requestAccessEnabled )
254
+ .withParam ("parent_id" , isApiVersion (ApiVersion .V3 ) ? null : parentId );
255
+ Response response = put (Response .Status .OK , formData .asMap (), "groups" , groupId );
256
+ return (response .readEntity (Group .class ));
194
257
}
195
258
196
259
/**
@@ -208,9 +271,12 @@ public void addGroup(String name, String path) throws GitLabApiException {
208
271
* @param requestAccessEnabled (optional) - Allow users to request member access.
209
272
* @param parentId (optional) - The parent group id for creating nested group.
210
273
* @param sharedRunnersMinutesLimit (optional) - (admin-only) Pipeline minutes quota for this group
274
+ * @return the created Group instance
211
275
* @throws GitLabApiException if any exception occurs
276
+ * @deprecated Will be removed in version 5.0, replaced by {@link #addGroup(String, String, String, Visibility,
277
+ * Boolean, Boolean, Integer)}
212
278
*/
213
- public void addGroup (String name , String path , String description , Boolean membershipLock ,
279
+ public Group addGroup (String name , String path , String description , Boolean membershipLock ,
214
280
Boolean shareWithGroupLock , Visibility visibility , Boolean lfsEnabled , Boolean requestAccessEnabled ,
215
281
Integer parentId , Integer sharedRunnersMinutesLimit ) throws GitLabApiException {
216
282
@@ -225,11 +291,12 @@ public void addGroup(String name, String path, String description, Boolean membe
225
291
.withParam ("request_access_enabled" , requestAccessEnabled )
226
292
.withParam ("parent_id" , parentId )
227
293
.withParam ("shared_runners_minutes_limit" , sharedRunnersMinutesLimit );
228
- post (Response .Status .CREATED , formData , "groups" );
294
+ Response response = post (Response .Status .CREATED , formData , "groups" );
295
+ return (response .readEntity (Group .class ));
229
296
}
230
297
231
298
/**
232
- * Creates a new project group. Available only for users who can create groups.
299
+ * Updates a project group. Available only for users who can create groups.
233
300
*
234
301
* PUT /groups
235
302
*
@@ -241,11 +308,13 @@ public void addGroup(String name, String path, String description, Boolean membe
241
308
* @param shareWithGroupLock (optional, boolean) - Prevent sharing a project with another group within this group
242
309
* @param visibility (optional) - The group's visibility. Can be private, internal, or public.
243
310
* @param lfsEnabled (optional) - Enable/disable Large File Storage (LFS) for the projects in this group
244
- * @param requestAccessEnabled (optional) - Allow users to request member access.
245
- * @param parentId (optional) - The parent group id for creating nested group.
311
+ * @param requestAccessEnabled (optional) - Allow users to request member access
312
+ * @param parentId (optional) - The parent group id for creating nested group
246
313
* @param sharedRunnersMinutesLimit (optional) - (admin-only) Pipeline minutes quota for this group
247
314
* @return the updated Group instance
248
315
* @throws GitLabApiException if any exception occurs
316
+ * @deprecated Will be removed in version 5.0, replaced by {@link #updateGroup(Integer, String, String, String,
317
+ * Visibility, Boolean, Boolean, Integer)}
249
318
*/
250
319
public Group updateGroup (Integer groupId , String name , String path , String description , Boolean membershipLock ,
251
320
Boolean shareWithGroupLock , Visibility visibility , Boolean lfsEnabled , Boolean requestAccessEnabled ,
@@ -262,7 +331,6 @@ public Group updateGroup(Integer groupId, String name, String path, String descr
262
331
.withParam ("request_access_enabled" , requestAccessEnabled )
263
332
.withParam ("parent_id" , parentId )
264
333
.withParam ("shared_runners_minutes_limit" , sharedRunnersMinutesLimit );
265
-
266
334
Response response = put (Response .Status .OK , formData .asMap (), "groups" , groupId );
267
335
return (response .readEntity (Group .class ));
268
336
}
0 commit comments