diff --git a/src/main/java/org/gitlab4j/api/GroupApi.java b/src/main/java/org/gitlab4j/api/GroupApi.java index 85737ee144f52a3df1a52857e1d4ecec22bc2785..1a37205e219064e8ed968f5755893a2c3e607918 100644 --- a/src/main/java/org/gitlab4j/api/GroupApi.java +++ b/src/main/java/org/gitlab4j/api/GroupApi.java @@ -1,12 +1,13 @@ package org.gitlab4j.api; -import javax.ws.rs.core.Form; -import javax.ws.rs.core.GenericType; -import javax.ws.rs.core.Response; - import org.gitlab4j.api.models.Group; import org.gitlab4j.api.models.Member; +import org.gitlab4j.api.models.Project; +import org.gitlab4j.api.models.Visibility; +import javax.ws.rs.core.Form; +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.Response; import java.util.List; /** @@ -32,6 +33,21 @@ public class GroupApi extends AbstractApi { })); } + /** + * Get a list of projects belonging to the specified group ID. + * + * GET /groups/:id/projects + * + * @param groupId the group ID to list the projects for + * @return a list of projects belonging to the specified group ID + * @throws GitLabApiException if any exception occurs + */ + public List getProjects(int groupId) throws GitLabApiException { + Response response = get(Response.Status.OK, null, "groups", groupId, "projects"); + return (response.readEntity(new GenericType>() { + })); + } + /** * Get all details of a group. * @@ -47,7 +63,7 @@ public class GroupApi extends AbstractApi { } /** - * Creates a new project group. Available only for admin. + * Creates a new project group. Available only for users who can create groups. * * POST /groups * @@ -63,6 +79,79 @@ public class GroupApi extends AbstractApi { post(Response.Status.CREATED, formData, "groups"); } + /** + * Creates a new project group. Available only for users who can create groups. + * + * POST /groups + * + * @param name the name of the group to add + * @param path the path for the group + * @param description (optional) - The group's description + * @param membershipLock (optional, boolean) - Prevent adding new members to project membership within this group + * @param shareWithGroupLock (optional, boolean) - Prevent sharing a project with another group within this group + * @param visibility (optional) - The group's visibility. Can be private, internal, or public. + * @param lfsEnabled (optional) - Enable/disable Large File Storage (LFS) for the projects in this group + * @param requestAccessEnabled (optional) - Allow users to request member access. + * @param parentId (optional) - The parent group id for creating nested group. + * @param sharedRunnersMinutesLimit (optional) - (admin-only) Pipeline minutes quota for this group + * @throws GitLabApiException if any exception occurs + */ + public void addGroup(String name, String path, String description, Boolean membershipLock, + Boolean shareWithGroupLock, Visibility visibility, Boolean lfsEnabled, Boolean requestAccessEnabled, + Integer parentId, Integer sharedRunnersMinutesLimit) throws GitLabApiException { + + Form formData = new GitLabApiForm() + .withParam("name", name) + .withParam("path", path) + .withParam("description", description) + .withParam("membership_lock", membershipLock) + .withParam("share_with_group_lock", shareWithGroupLock) + .withParam("visibility", visibility) + .withParam("lfs_enabled", lfsEnabled) + .withParam("request_access_enabled", requestAccessEnabled) + .withParam("parent_id", parentId) + .withParam("shared_runners_minutes_limit", sharedRunnersMinutesLimit); + post(Response.Status.CREATED, formData, "groups"); + } + + /** + * Creates a new project group. Available only for users who can create groups. + * + * PUT /groups + * + * @param groupId the ID of the group to update + * @param name the name of the group to add + * @param path the path for the group + * @param description (optional) - The group's description + * @param membershipLock (optional, boolean) - Prevent adding new members to project membership within this group + * @param shareWithGroupLock (optional, boolean) - Prevent sharing a project with another group within this group + * @param visibility (optional) - The group's visibility. Can be private, internal, or public. + * @param lfsEnabled (optional) - Enable/disable Large File Storage (LFS) for the projects in this group + * @param requestAccessEnabled (optional) - Allow users to request member access. + * @param parentId (optional) - The parent group id for creating nested group. + * @param sharedRunnersMinutesLimit (optional) - (admin-only) Pipeline minutes quota for this group + * @throws GitLabApiException if any exception occurs + */ + public Group updateGroup(Integer groupId, String name, String path, String description, Boolean membershipLock, + Boolean shareWithGroupLock, Visibility visibility, Boolean lfsEnabled, Boolean requestAccessEnabled, + Integer parentId, Integer sharedRunnersMinutesLimit) throws GitLabApiException { + + Form formData = new GitLabApiForm() + .withParam("name", name) + .withParam("path", path) + .withParam("description", description) + .withParam("membership_lock", membershipLock) + .withParam("share_with_group_lock", shareWithGroupLock) + .withParam("visibility", visibility) + .withParam("lfs_enabled", lfsEnabled) + .withParam("request_access_enabled", requestAccessEnabled) + .withParam("parent_id", parentId) + .withParam("shared_runners_minutes_limit", sharedRunnersMinutesLimit); + + Response response = put(Response.Status.OK, formData.asMap(), "groups", groupId); + return (response.readEntity(Group.class)); + } + /** * Removes group with all projects inside. * @@ -139,4 +228,4 @@ public class GroupApi extends AbstractApi { public void removeMember(Integer projectId, Integer userId) throws GitLabApiException { delete(Response.Status.OK, null, "groups", projectId, "members", userId); } -} +} \ No newline at end of file diff --git a/src/main/java/org/gitlab4j/api/models/Group.java b/src/main/java/org/gitlab4j/api/models/Group.java index 97b083db7d1d74992115f34fbee8d9b560ee0c36..9140db328a84d508486e4ba469cea189f1bbd3cf 100644 --- a/src/main/java/org/gitlab4j/api/models/Group.java +++ b/src/main/java/org/gitlab4j/api/models/Group.java @@ -13,9 +13,18 @@ public class Group { private Integer id; private String name; - private Integer ownerId; private String path; + private String description; + private Visibility visibility; + private String avatarUrl; + private String webUrl; + private Boolean requestAccessEnabled; + private String fullName; + private String fullPath; + private Integer parentId; + private Integer sharedRunnersMinutesLimit; private List projects; + private List sharedProjects; public Integer getId() { return this.id; @@ -33,14 +42,6 @@ public class Group { this.name = name; } - public Integer getOwnerId() { - return this.ownerId; - } - - public void setOwnerId(Integer ownerId) { - this.ownerId = ownerId; - } - public String getPath() { return this.path; } @@ -49,6 +50,78 @@ public class Group { this.path = path; } + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Visibility getVisibility() { + return visibility; + } + + public void setVisibility(Visibility visibility) { + this.visibility = visibility; + } + + public String getAvatarUrl() { + return avatarUrl; + } + + public void setAvatarUrl(String avatarUrl) { + this.avatarUrl = avatarUrl; + } + + public String getWebUrl() { + return webUrl; + } + + public void setWebUrl(String webUrl) { + this.webUrl = webUrl; + } + + public Boolean getRequestAccessEnabled() { + return requestAccessEnabled; + } + + public void setRequestAccessEnabled(Boolean requestAccessEnabled) { + this.requestAccessEnabled = requestAccessEnabled; + } + + public String getFullName() { + return fullName; + } + + public void setFullName(String fullName) { + this.fullName = fullName; + } + + public String getFullPath() { + return fullPath; + } + + public void setFullPath(String fullPath) { + this.fullPath = fullPath; + } + + public Integer getParentId() { + return parentId; + } + + public void setParentId(Integer parentId) { + this.parentId = parentId; + } + + public Integer getSharedRunnersMinutesLimit() { + return sharedRunnersMinutesLimit; + } + + public void setSharedRunnersMinutesLimit(Integer sharedRunnersMinutesLimit) { + this.sharedRunnersMinutesLimit = sharedRunnersMinutesLimit; + } + public List getProjects() { return (projects); } @@ -56,4 +129,12 @@ public class Group { public void setProjects(List projects) { this.projects = projects; } + + public List getSharedProjects() { + return (sharedProjects); + } + + public void setSharedProjects(List sharedProjects) { + this.sharedProjects = sharedProjects; + } } diff --git a/src/main/java/org/gitlab4j/api/models/Namespace.java b/src/main/java/org/gitlab4j/api/models/Namespace.java index 76fb1f54130a257aaba420ac7b25f896322b4583..bbf35a64e6111555db87a59916a9cac6c2d8d8df 100644 --- a/src/main/java/org/gitlab4j/api/models/Namespace.java +++ b/src/main/java/org/gitlab4j/api/models/Namespace.java @@ -10,29 +10,11 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlAccessorType(XmlAccessType.FIELD) public class Namespace { - private Date createdAt; - private String description; private Integer id; private String name; - private Integer ownerId; private String path; - private String updatedAt; - - public Date getCreatedAt() { - return this.createdAt; - } - - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } - - public String getDescription() { - return this.description; - } - - public void setDescription(String description) { - this.description = description; - } + private String kind; + private String fullPath; public Integer getId() { return this.id; @@ -50,14 +32,6 @@ public class Namespace { this.name = name; } - public Integer getOwnerId() { - return this.ownerId; - } - - public void setOwnerId(Integer ownerId) { - this.ownerId = ownerId; - } - public String getPath() { return this.path; } @@ -66,11 +40,19 @@ public class Namespace { this.path = path; } - public String getUpdatedAt() { - return this.updatedAt; + public String getKind() { + return kind; + } + + public void setKind(String kind) { + this.kind = kind; + } + + public String getFullPath() { + return fullPath; } - public void setUpdatedAt(String updatedAt) { - this.updatedAt = updatedAt; + public void setFullPath(String fullPath) { + this.fullPath = fullPath; } } diff --git a/src/test/resources/org/gitlab4j/api/group.json b/src/test/resources/org/gitlab4j/api/group.json index d04561235342a965edf0f9ee1a60b764f1ae8fae..32c44dd19ff24ea67045bc070793affba7bf194d 100644 --- a/src/test/resources/org/gitlab4j/api/group.json +++ b/src/test/resources/org/gitlab4j/api/group.json @@ -1,7 +1,135 @@ { - "id": 1, - "name": "Foobar Group", - "path": "foo-bar", - "owner_id": 18 + "id": 4, + "name": "Twitter", + "path": "twitter", + "description": "Aliquid qui quis dignissimos distinctio ut commodi voluptas est.", + "visibility": "public", + "web_url": "https://gitlab.example.com/groups/twitter", + "request_access_enabled": false, + "full_name": "Twitter", + "full_path": "twitter", + "parent_id": 1234, + "shared_runners_minutes_limit": 133, + "projects": [ + { + "id": 7, + "description": "Voluptas veniam qui et beatae voluptas doloremque explicabo facilis.", + "default_branch": "master", + "archived": false, + "visibility": "public", + "ssh_url_to_repo": "git@gitlab.example.com:twitter/typeahead-js.git", + "http_url_to_repo": "https://gitlab.example.com/twitter/typeahead-js.git", + "web_url": "https://gitlab.example.com/twitter/typeahead-js", + "name": "Typeahead.Js", + "name_with_namespace": "Twitter / Typeahead.Js", + "path": "typeahead-js", + "path_with_namespace": "twitter/typeahead-js", + "issues_enabled": true, + "merge_requests_enabled": true, + "wiki_enabled": true, + "jobs_enabled": true, + "snippets_enabled": false, + "container_registry_enabled": true, + "created_at": "2016-06-17T07:47:25.578Z", + "last_activity_at": "2016-06-17T07:47:25.881Z", + "shared_runners_enabled": true, + "creator_id": 1, + "namespace": { + "id": 4, + "name": "Twitter", + "path": "twitter", + "kind": "group" + }, + "star_count": 0, + "forks_count": 0, + "open_issues_count": 3, + "public_jobs": true, + "shared_with_groups": [], + "request_access_enabled": false + }, + { + "id": 6, + "description": "Aspernatur omnis repudiandae qui voluptatibus eaque.", + "default_branch": "master", + "archived": false, + "visibility": "internal", + "ssh_url_to_repo": "git@gitlab.example.com:twitter/flight.git", + "http_url_to_repo": "https://gitlab.example.com/twitter/flight.git", + "web_url": "https://gitlab.example.com/twitter/flight", + "name": "Flight", + "name_with_namespace": "Twitter / Flight", + "path": "flight", + "path_with_namespace": "twitter/flight", + "issues_enabled": true, + "merge_requests_enabled": true, + "wiki_enabled": true, + "jobs_enabled": true, + "snippets_enabled": false, + "container_registry_enabled": true, + "created_at": "2016-06-17T07:47:24.661Z", + "last_activity_at": "2016-06-17T07:47:24.838Z", + "shared_runners_enabled": true, + "creator_id": 1, + "namespace": { + "id": 4, + "name": "Twitter", + "path": "twitter", + "kind": "group" + }, + "star_count": 0, + "forks_count": 0, + "open_issues_count": 8, + "public_jobs": true, + "shared_with_groups": [], + "request_access_enabled": false + } + ], + "shared_projects": [ + { + "id": 8, + "description": "Velit eveniet provident fugiat saepe eligendi autem.", + "default_branch": "master", + "archived": false, + "visibility": "private", + "ssh_url_to_repo": "git@gitlab.example.com:h5bp/html5-boilerplate.git", + "http_url_to_repo": "https://gitlab.example.com/h5bp/html5-boilerplate.git", + "web_url": "https://gitlab.example.com/h5bp/html5-boilerplate", + "name": "Html5 Boilerplate", + "name_with_namespace": "H5bp / Html5 Boilerplate", + "path": "html5-boilerplate", + "path_with_namespace": "h5bp/html5-boilerplate", + "issues_enabled": true, + "merge_requests_enabled": true, + "wiki_enabled": true, + "jobs_enabled": true, + "snippets_enabled": false, + "container_registry_enabled": true, + "created_at": "2016-06-17T07:47:27.089Z", + "last_activity_at": "2016-06-17T07:47:27.310Z", + "shared_runners_enabled": true, + "creator_id": 1, + "namespace": { + "id": 5, + "name": "H5bp", + "path": "h5bp", + "kind": "group" + }, + "star_count": 0, + "forks_count": 0, + "open_issues_count": 4, + "public_jobs": true, + "shared_with_groups": [ + { + "group_id": 4, + "group_name": "Twitter", + "group_access_level": 30 + }, + { + "group_id": 3, + "group_name": "Gitlab Org", + "group_access_level": 10 + } + ] + } + ] } - diff --git a/src/test/resources/org/gitlab4j/api/project.json b/src/test/resources/org/gitlab4j/api/project.json index 9d79b566a21e55a31d1af433a91a07c60d164df0..f719e972e15505dc8a4f21324f14f5bbaf323072 100644 --- a/src/test/resources/org/gitlab4j/api/project.json +++ b/src/test/resources/org/gitlab4j/api/project.json @@ -30,13 +30,9 @@ "last_activity_at": "2013-09-30T13:46:02Z", "creator_id": 3, "namespace": { - "created_at": "2013-09-30T13:46:02Z", - "description": "", "id": 3, "name": "Diaspora", - "owner_id": 1, - "path": "diaspora", - "updated_at": "2013-09-30T13:46:02Z" + "path": "diaspora" }, "permissions": { "project_access": {