Commit 514e9046 authored by Greg Messner's avatar Greg Messner
Browse files

Added additional Group API calls.

parent 64622559
package com.messners.gitlab.api;
import java.io.IOException;
import java.util.List;
import com.messners.gitlab.api.models.Group;
import com.messners.gitlab.api.models.Member;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.GenericType;
public class GroupApi extends AbstractApi {
GroupApi (GitLabApi gitLabApi) {
super(gitLabApi);
}
/**
* GET /groups
*
* @return
* @throws IOException
*/
public List<Group> getGroups () throws IOException {
ClientResponse response = get(null, "groups");
return (response.getEntity(new GenericType<List<Group>>() {}));
}
/**
* GET /groups/:id
*
* @param groupId
* @return
* @throws IOException
*/
public Group getGroup (int groupId) throws IOException {
ClientResponse response = get(null, "groups", groupId);
return (response.getEntity(Group.class));
}
/**
* DELETE /groups/:id
*
* @param groupId
* @return
* @throws IOException
*/
public boolean deleteGroup (Integer groupId) throws IOException {
if (groupId == null) {
throw new RuntimeException("groupId cannot be null");
}
ClientResponse response = delete(null, "groups", groupId);
return (response.getStatus() == ClientResponse.Status.OK.getStatusCode());
}
/**
*
* @param group
* @return
* @throws IOException
*/
public boolean deleteGroup (Group group) throws IOException {
return (deleteGroup(group.getId()));
}
/**
* GET /groups/:id/members
*
* @return
* @throws IOException
*/
public List<Member> getMembers (int groupId) throws IOException {
ClientResponse response = get(null, "groups", groupId, "members");
return (response.getEntity(new GenericType<List<Member>>() {}));
}
}
package com.messners.gitlab.api.models;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
......@@ -13,6 +15,7 @@ public class Group {
private String name;
private Integer ownerId;
private String path;
private List<Project> projects;
public Integer getId () {
return this.id;
......@@ -45,4 +48,12 @@ public class Group {
public void setPath (String path) {
this.path = path;
}
public List<Project> getProjects () {
return (projects);
}
public void setProjects (List<Project> projects) {
this.projects = projects;
}
}
......@@ -10,6 +10,12 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Member {
public static final int GUEST_LEVEL = 10;
public static final int REPORTER_LEVEL = 20;
public static final int DEVELOPER_LEVEL = 30;
public static final int MASTER_LEVEL = 40;
public static final int OWNER_LEVEL = 50;
private Integer accessLevel;
private Date createdAt;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment