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 UserApi extends AbstractApi {
 
 	UserApi (GitLabApi gitLabApi) {
 		super(gitLabApi);
 	}


Get a list of users. GET /users

Returns:
Throws:
GitLabApiException
 
 	public List<UsergetProjects () throws GitLabApiException {		
 		ClientResponse response = get(..null"users");
 		return (response.getEntity(new GenericType<List<User>>() {}));
 	}


Get a single user. GET /users/:id

Parameters:
userId
Returns:
Throws:
GitLabApiException
 
 	public User getUser (int userIdthrows GitLabApiException {		
 		ClientResponse response = get(..null"users"userId);
 		return (response.getEntity(User.class));
 	}


Creates a new user. Note only administrators can create new users. POST /users email (required) - Email password (required) - Password username (required) - Username name (required) - Name skype (optional) - Skype ID linkedin (optional) - Linkedin twitter (optional) - Twitter account website_url (optional) - Website url projects_limit (optional) - Number of projects user can create extern_uid (optional) - External UID provider (optional) - External provider name bio (optional) - User's bio admin (optional) - User is admin - true or false (default) can_create_group (optional) - User can create groups - true or false

Parameters:
user
Returns:
Throws:
GitLabApiException
 
 	public User createUser (User userString passwordInteger projectsLimitthrows GitLabApiException {
 		
 		Form formData = new Form();
 		addFormParam(formData"email"user.getEmail(), true);
 		addFormParam(formData"password"passwordtrue);
 		addFormParam(formData"username"user.getUsername(), true);
 		addFormParam(formData"name"user.getName(), true);
 		addFormParam(formData"skype"user.getSkype(), false);
 		addFormParam(formData"linkedin"user.getLinkedin(), false);
 		addFormParam(formData"twitter"user.getTwitter(), false);
 		addFormParam(formData"website_url"user.getWebsiteUrl(), false);
 		addFormParam(formData"projects_limit"projectsLimitfalse);
 		addFormParam(formData"extern_uid"user.getExternUid(), false);
 		addFormParam(formData"provider"user.getProvider(), false);
 		addFormParam(formData"bio"user.getBio(), false);
 		addFormParam(formData"admin"user.getIsAdmin(), false);
 		addFormParam(formData"can_create_group"user.getCanCreateGroup(), false);		
 	
 		ClientResponse response = post(..formData"users");
 		return (response.getEntity(User.class));
 	}


Modifies an existing user. Only administrators can change attributes of a user. PUT /users/:id email (required) - Email password (required) - Password username (required) - Username name (required) - Name skype (optional) - Skype ID linkedin (optional) - Linkedin twitter (optional) - Twitter account website_url (optional) - Website url projects_limit (optional) - Number of projects user can create extern_uid (optional) - External UID provider (optional) - External provider name bio (optional) - User's bio admin (optional) - User is admin - true or false (default) can_create_group (optional) - User can create groups - true or false

Parameters:
user
Returns:
Throws:
GitLabApiException
	public User modifyUser (User userString passwordInteger projectsLimitthrows GitLabApiException {
		Form formData = new Form();
		addFormParam(formData"email"user.getEmail(), false);
		addFormParam(formData"password"passwordfalse);
		addFormParam(formData"username"user.getUsername(), false);
		addFormParam(formData"name"user.getName(), false);
		addFormParam(formData"skype"user.getSkype(), false);
		addFormParam(formData"linkedin"user.getLinkedin(), false);
		addFormParam(formData"twitter"user.getTwitter(), false);
		addFormParam(formData"website_url"user.getWebsiteUrl(), false);
		addFormParam(formData"projects_limit"projectsLimitfalse);
		addFormParam(formData"extern_uid"user.getExternUid(), false);
		addFormParam(formData"provider"user.getProvider(), false);
		addFormParam(formData"bio"user.getBio(), false);
		addFormParam(formData"admin"user.getIsAdmin(), false);
		addFormParam(formData"can_create_group"user.getCanCreateGroup(), false);		
		ClientResponse response = put(..formData"users"user.getId());
		return (response.getEntity(User.class));
	}	


Deletes a user. Available only for administrators. DELETE /users/:id

Parameters:
userId
Throws:
GitLabApiException
	public void deleteUser (Integer userIdthrows GitLabApiException {
		if (userId == null) {
			throw new RuntimeException("userId cannot be null");
		}
		delete(..null"users"userId);	
	}


Deletes a user. Available only for administrators. DELETE /users/:id

Parameters:
user
Throws:
GitLabApiException
	public void deleteUser (User user)  throws GitLabApiException {
	}
New to GrepCode? Check out our FAQ X