Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

new: GitLabApi.create(url, user, pass) #3

Merged
Merged
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
15 changes: 14 additions & 1 deletion src/main/java/com/messners/gitlab/api/GitLabApi.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,20 @@ public class GitLabApi {
private RepositoryApi repositoryApi;
private SessionApi sessoinApi;
private UserApi userApi;


/**
* Logs into GitLab using provided {@code username} and {@code password}, and creates a new
* {@code GitLabApi} instance using returned private token
* @param url GitLab URL
* @param username user name for which private token should be obtained
* @param password password for a given {@code username}
* @return new {@code GitLabApi} instance configured for a user-specific token
*/
static public GitLabApi create(String url, String username, String password) throws GitLabApiException {
String token = new SessionApi(new GitLabApi(url, null)).login(username, null, password).getPrivateToken();
return new GitLabApi(url, token);
}


/**
* Constructs a GitLabApi instance set up to interact with the GitLab server
Expand Down