Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.messners.gitlab.api;
  
  
  import java.util.List;

This class implements the client side API for the GitLab groups calls.

Author(s):
Greg Messner <greg@messners.com>
 
 public class GroupApi extends AbstractApi {
 
 	GroupApi (GitLabApi gitLabApi) {
 		super(gitLabApi);
 	}


Get a list of groups. (As user: my groups, as admin: all groups) GET /groups

Returns:
the list of groups viewable by the authenticated user
Throws:
GitLabApiException
 
 	public List<GroupgetGroups () throws GitLabApiException {	
 		Response response = get(..null"groups");
 		return (response.readEntity(new GenericType<List<Group>>() {}));
 	}


Get all details of a group. GET /groups/:id

Parameters:
groupId
Returns:
the Group instance for the specified group ID
Throws:
GitLabApiException
 
 	public Group getGroup (int groupIdthrows GitLabApiException {		
 		Response response = get(..null"groups"groupId);
 		return (response.readEntity(Group.class));
 	}


Creates a new project group. Available only for admin. POST /groups

Parameters:
name
path
 
 	public void addGroup (String nameString paththrows GitLabApiException {
 		
 		Form formData = new Form();
 		formData.param("name"name);
 		formData.param("path"path);
 		post(..formData"groups");
 	}


Removes group with all projects inside. DELETE /groups/:id

Parameters:
groupId
Throws:
GitLabApiException
 
 	public void deleteGroup (Integer groupIdthrows GitLabApiException {
 		
 		if (groupId == null) {
 			throw new RuntimeException("groupId cannot be null");
 		}
 		
 		delete(..null"groups"groupId);
 	}


Removes group with all projects inside. DELETE /groups/:id

Parameters:
group
Throws:
GitLabApiException
 
 	public void deleteGroup (Group group)  throws GitLabApiException {
 		 deleteGroup(group.getId());
 	}


Get a list of group members viewable by the authenticated user. GET /groups/:id/members

Returns:
a list of group members viewable by the authenticated user
Throws:
GitLabApiException
	public List<MembergetMembers (int groupIdthrows GitLabApiException {		
		Response response = get(..null"groups"groupId"members");
		return (response.readEntity(new GenericType<List<Member>>() {}));
	}

Adds a user to the list of group members. POST /groups/:id/members

Parameters:
groupId
userId
accessLevel
Returns:
a Member instance for the added user
Throws:
GitLabApiException
	public Member addMember (Integer groupIdInteger userIdInteger accessLevelthrows GitLabApiException {
		Form formData = new Form();
		formData.param("user_id"userId.toString());
		formData.param("access_level"accessLevel.toString());
		Response response = post(..formData"groups"groupId"members");
		return (response.readEntity(Member.class));
	}


Removes member from the group team. DELETE /groups/:id/members/:user_id

Parameters:
projectId
userId
Throws:
GitLabApiException
	public void removeMember (Integer projectIdInteger userIdthrows GitLabApiException {		
		delete(..null"groups"projectId"members"userId);
	}
New to GrepCode? Check out our FAQ X