diff --git a/src/main/java/org/gitlab4j/api/GroupApi.java b/src/main/java/org/gitlab4j/api/GroupApi.java index b4aef7c03..256c27e77 100644 --- a/src/main/java/org/gitlab4j/api/GroupApi.java +++ b/src/main/java/org/gitlab4j/api/GroupApi.java @@ -342,6 +342,19 @@ public Group addGroup(String name, String path) throws GitLabApiException { return (response.readEntity(Group.class)); } + public Group addGroup(Group group) throws GitLabApiException { + Form formData = new GitLabApiForm() + .withParam("name", group.getName()) + .withParam("path", group.getPath()) + .withParam("description", group.getDescription()) + .withParam("visibility", group.getDescription()) + .withParam("lfs_enabled", group.getLfsEnabled()) + .withParam("request_access_enabled", group.getRequestAccessEnabled()) + .withParam("parent_id", isApiVersion(ApiVersion.V3) ? null : group.getParentId()); + Response response = post(Response.Status.CREATED, formData, "groups"); + return (response.readEntity(Group.class)); + } + /** * Creates a new project group. Available only for users who can create groups. * @@ -372,6 +385,28 @@ public Group addGroup(String name, String path, String description, Visibility v return (response.readEntity(Group.class)); } + /** + * Updates a project group. Available only for users who can create groups. + * + * PUT /groups + * + * @param group to update + * @return updated group instance + * @throws GitLabApiException at any exception + */ + public Group updateGroup(Group group) throws GitLabApiException { + Form formData = new GitLabApiForm() + .withParam("name", group.getName()) + .withParam("path", group.getPath()) + .withParam("description", group.getDescription()) + .withParam("visibility", group.getVisibility()) + .withParam("lfs_enabled", group.getLfsEnabled()) + .withParam("request_access_enabled", group.getRequestAccessEnabled()) + .withParam("parent_id", isApiVersion(ApiVersion.V3) ? null : group.getParentId()); + Response response = put(Response.Status.OK, formData.asMap(), "groups", group.getId()); + return (response.readEntity(Group.class)); + } + /** * Updates a project group. Available only for users who can create groups. *