@@ -183,14 +183,77 @@ public Group getGroup(String groupPath) throws GitLabApiException {
183183 *
184184 * @param name the name of the group to add
185185 * @param path the path for the group
186+ * @return the created Group instance
186187 * @throws GitLabApiException if any exception occurs
187188 */
188- public void addGroup (String name , String path ) throws GitLabApiException {
189+ public Group addGroup (String name , String path ) throws GitLabApiException {
189190
190191 Form formData = new Form ();
191192 formData .param ("name" , name );
192193 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 ));
194257 }
195258
196259 /**
@@ -208,9 +271,12 @@ public void addGroup(String name, String path) throws GitLabApiException {
208271 * @param requestAccessEnabled (optional) - Allow users to request member access.
209272 * @param parentId (optional) - The parent group id for creating nested group.
210273 * @param sharedRunnersMinutesLimit (optional) - (admin-only) Pipeline minutes quota for this group
274+ * @return the created Group instance
211275 * @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)}
212278 */
213- public void addGroup (String name , String path , String description , Boolean membershipLock ,
279+ public Group addGroup (String name , String path , String description , Boolean membershipLock ,
214280 Boolean shareWithGroupLock , Visibility visibility , Boolean lfsEnabled , Boolean requestAccessEnabled ,
215281 Integer parentId , Integer sharedRunnersMinutesLimit ) throws GitLabApiException {
216282
@@ -225,11 +291,12 @@ public void addGroup(String name, String path, String description, Boolean membe
225291 .withParam ("request_access_enabled" , requestAccessEnabled )
226292 .withParam ("parent_id" , parentId )
227293 .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 ));
229296 }
230297
231298 /**
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.
233300 *
234301 * PUT /groups
235302 *
@@ -241,11 +308,13 @@ public void addGroup(String name, String path, String description, Boolean membe
241308 * @param shareWithGroupLock (optional, boolean) - Prevent sharing a project with another group within this group
242309 * @param visibility (optional) - The group's visibility. Can be private, internal, or public.
243310 * @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
246313 * @param sharedRunnersMinutesLimit (optional) - (admin-only) Pipeline minutes quota for this group
247314 * @return the updated Group instance
248315 * @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)}
249318 */
250319 public Group updateGroup (Integer groupId , String name , String path , String description , Boolean membershipLock ,
251320 Boolean shareWithGroupLock , Visibility visibility , Boolean lfsEnabled , Boolean requestAccessEnabled ,
@@ -262,7 +331,6 @@ public Group updateGroup(Integer groupId, String name, String path, String descr
262331 .withParam ("request_access_enabled" , requestAccessEnabled )
263332 .withParam ("parent_id" , parentId )
264333 .withParam ("shared_runners_minutes_limit" , sharedRunnersMinutesLimit );
265-
266334 Response response = put (Response .Status .OK , formData .asMap (), "groups" , groupId );
267335 return (response .readEntity (Group .class ));
268336 }
0 commit comments