Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.messners.gitlab.api;
  
  import java.util.List;
  
  import  com.sun.jersey.api.representation.Form;
 
 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:
Throws:
GitLabApiException
 
 	public List<GroupgetGroups () throws GitLabApiException {	
 		ClientResponse response = get(..null"groups");
 		return (response.getEntity(new GenericType<List<Group>>() {}));
 	}


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

Parameters:
groupId
Returns:
Throws:
GitLabApiException
 
 	public Group getGroup (int groupIdthrows GitLabApiException {		
 		ClientResponse response = get(..null"groups"groupId);
 		return (response.getEntity(Group.class));
 	}


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

Parameters:
groupId
Throws:
GitLabApiException
 
 	public void deleteGroup (Integer groupId)  throws 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:
Throws:
GitLabApiException
 
 	public List<MembergetMembers (int groupIdthrows GitLabApiException {		
 		ClientResponse response = get(..null"groups"groupId"members");
 		return (response.getEntity(new GenericType<List<Member>>() {}));
 	}

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

Parameters:
groupId
userId
accessLevel
Returns:
Throws:
GitLabApiException
	public Member addMember (Integer groupIdInteger userIdInteger accessLevelthrows GitLabApiException {
		Form formData = new Form();
		formData.add("user_id",  userId);		
		formData.add("access_level",  accessLevel);		
		ClientResponse response = post(..formData"groups"groupId"members");
		return (response.getEntity(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