Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/main/java/org/gitlab/api/GitlabAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -531,4 +531,25 @@ public GitlabSession getCurrentSession() throws IOException {
String tailUrl = "/user";
return retrieve().to(tailUrl, GitlabSession.class);
}

/**
* There are several circumstances where bad input data WILL fail
* in an opaque way with the gitlab api. User password length < 8
* is one that got me repeatedly... 404 error. Existing user id
* or email will also throw 404. Method returns a GitlabUser.
* @param user
* @throws IOException
*/
public void createUser(GitlabUser user) throws IOException {
Query query = new Query()
.append("email", user.getEmail())
.append("name", user.getName())
.append("password", user.getPassword())
.append("username", user.getUsername());
//.append("can_create_group", Boolean.FALSE.toString());
if (user.isAdmin())
query.append("admin", Boolean.TRUE.toString());
String tailUrl = GitlabUser.URL + query.toString();
user = dispatch().to(tailUrl, GitlabUser.class);
}
}
11 changes: 11 additions & 0 deletions src/main/java/org/gitlab/api/models/GitlabUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class GitlabUser {
private String _twitter;
private String _provider;
private String _state;
private String _password;
private boolean _blocked;

@JsonProperty("created_at")
Expand Down Expand Up @@ -195,4 +196,14 @@ public boolean isCanCreateTeam() {
public void setCanCreateTeam(boolean canCreateTeam) {
_canCreateTeam = canCreateTeam;
}

public String getPassword() {
return _password;
}

public void setPassword(String password) {
_password = password;
}


}