Skip to content

Commit bee8b86

Browse files
Ruben Vittgmessner
Ruben Vitt
authored andcommitted
feat: update group with groupApi (#242)
* Update group with groupApi * Add group with groupApi
1 parent 190740a commit bee8b86

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/main/java/org/gitlab4j/api/GroupApi.java

+35
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,19 @@ public Group addGroup(String name, String path) throws GitLabApiException {
342342
return (response.readEntity(Group.class));
343343
}
344344

345+
public Group addGroup(Group group) throws GitLabApiException {
346+
Form formData = new GitLabApiForm()
347+
.withParam("name", group.getName())
348+
.withParam("path", group.getPath())
349+
.withParam("description", group.getDescription())
350+
.withParam("visibility", group.getDescription())
351+
.withParam("lfs_enabled", group.getLfsEnabled())
352+
.withParam("request_access_enabled", group.getRequestAccessEnabled())
353+
.withParam("parent_id", isApiVersion(ApiVersion.V3) ? null : group.getParentId());
354+
Response response = post(Response.Status.CREATED, formData, "groups");
355+
return (response.readEntity(Group.class));
356+
}
357+
345358
/**
346359
* Creates a new project group. Available only for users who can create groups.
347360
*
@@ -372,6 +385,28 @@ public Group addGroup(String name, String path, String description, Visibility v
372385
return (response.readEntity(Group.class));
373386
}
374387

388+
/**
389+
* Updates a project group. Available only for users who can create groups.
390+
*
391+
* PUT /groups
392+
*
393+
* @param group to update
394+
* @return updated group instance
395+
* @throws GitLabApiException at any exception
396+
*/
397+
public Group updateGroup(Group group) throws GitLabApiException {
398+
Form formData = new GitLabApiForm()
399+
.withParam("name", group.getName())
400+
.withParam("path", group.getPath())
401+
.withParam("description", group.getDescription())
402+
.withParam("visibility", group.getVisibility())
403+
.withParam("lfs_enabled", group.getLfsEnabled())
404+
.withParam("request_access_enabled", group.getRequestAccessEnabled())
405+
.withParam("parent_id", isApiVersion(ApiVersion.V3) ? null : group.getParentId());
406+
Response response = put(Response.Status.OK, formData.asMap(), "groups", group.getId());
407+
return (response.readEntity(Group.class));
408+
}
409+
375410
/**
376411
* Updates a project group. Available only for users who can create groups.
377412
*

0 commit comments

Comments
 (0)