Commit 894d7cfe authored by Tim Olshansky's avatar Tim Olshansky

Merge pull request #63 from openwide-java/deploy-key-support

Add support for project deploy keys
parents aec664c9 b5393d37
...@@ -138,7 +138,7 @@ public class GitlabAPI { ...@@ -138,7 +138,7 @@ public class GitlabAPI {
Query query = new Query() Query query = new Query()
.append("email", email) .append("email", email)
.appendIf("skip_confirmation", skip_confirmation) .appendIf("confirm", !skip_confirmation)
.appendIf("password", password) .appendIf("password", password)
.appendIf("username", username) .appendIf("username", username)
.appendIf("name", fullName) .appendIf("name", fullName)
...@@ -186,12 +186,10 @@ public class GitlabAPI { ...@@ -186,12 +186,10 @@ public class GitlabAPI {
String fullName, String skypeId, String linkedIn, String fullName, String skypeId, String linkedIn,
String twitter, String website_url, Integer projects_limit, String twitter, String website_url, Integer projects_limit,
String extern_uid, String extern_provider_name, String extern_uid, String extern_provider_name,
String bio, Boolean isAdmin, Boolean can_create_group, String bio, Boolean isAdmin, Boolean can_create_group) throws IOException {
Boolean skip_confirmation) throws IOException {
Query query = new Query() Query query = new Query()
.append("email", email) .append("email", email)
.appendIf("skip_confirmation", skip_confirmation)
.appendIf("password", password) .appendIf("password", password)
.appendIf("username", username) .appendIf("username", username)
.appendIf("name", fullName) .appendIf("name", fullName)
...@@ -951,6 +949,49 @@ public class GitlabAPI { ...@@ -951,6 +949,49 @@ public class GitlabAPI {
dispatch().to(tailUrl, Void.class); dispatch().to(tailUrl, Void.class);
} }
/**
* Create a new deploy key for the project
*
* @param targetProjectId The id of the Gitlab project
* @param title The title of the ssh key
* @param key The public key
* @return The new GitlabSSHKey
* @throws IOException on gitlab api call error
*/
public GitlabSSHKey createDeployKey(Integer targetProjectId, String title, String key) throws IOException {
Query query = new Query()
.append("title", title)
.append("key", key);
String tailUrl = GitlabProject.URL + "/" + targetProjectId + GitlabSSHKey.KEYS_URL + query.toString();
return dispatch().to(tailUrl, GitlabSSHKey.class);
}
/**
* Delete a deploy key for a project
*
* @param targetProjectId The id of the Gitlab project
* @param targetKeyId The id of the Gitlab ssh key
* @throws IOException on gitlab api call error
*/
public void deleteDeployKey(Integer targetProjectId, Integer targetKeyId) throws IOException {
String tailUrl = GitlabProject.URL + "/" + targetProjectId + GitlabSSHKey.KEYS_URL + "/" + targetKeyId;
retrieve().method("DELETE").to(tailUrl, Void.class);
}
/**
* Gets all deploy keys for a project
*
* @param targetProjectId The id of the Gitlab project
* @return The list of project deploy keys
* @throws IOException on gitlab api call error
*/
public List<GitlabSSHKey> getDeployKeys(Integer targetProjectId) throws IOException {
String tailUrl = GitlabProject.URL + "/" + targetProjectId + GitlabSSHKey.KEYS_URL;
return Arrays.asList(retrieve().to(tailUrl, GitlabSSHKey[].class));
}
public GitlabSession getCurrentSession() throws IOException { public GitlabSession getCurrentSession() throws IOException {
String tailUrl = "/user"; String tailUrl = "/user";
return retrieve().to(tailUrl, GitlabSession.class); return retrieve().to(tailUrl, GitlabSession.class);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment