Commit 8c85a4e0 authored by Tim Olshansky's avatar Tim Olshansky

Merge pull request #60 from openwide-java/add-new-api-stuff

Added various API calls:
parents d9f4c407 5cf40640
...@@ -211,6 +211,32 @@ public class GitlabAPI { ...@@ -211,6 +211,32 @@ public class GitlabAPI {
return retrieve().method("PUT").to(tailUrl, GitlabUser.class); return retrieve().method("PUT").to(tailUrl, GitlabUser.class);
} }
/**
* Block a user
*
* @param targetUserId The id of the Gitlab user
* @throws IOException on gitlab api call error
*/
public void blockUser(Integer targetUserId) throws IOException {
String tailUrl = GitlabUser.USERS_URL + "/" + targetUserId + GitlabUser.BLOCK_URL;
retrieve().method("PUT").to(tailUrl, Void.class);
}
/**
* Unblock a user
*
* @param targetUserId The id of the Gitlab user
* @throws IOException on gitlab api call error
*/
public void unblockUser(Integer targetUserId) throws IOException {
String tailUrl = GitlabUser.USERS_URL + "/" + targetUserId + GitlabUser.UNBLOCK_URL;
retrieve().method("PUT").to(tailUrl, Void.class);
}
/** /**
* Create a new ssh key for the user * Create a new ssh key for the user
* *
...@@ -522,6 +548,39 @@ public class GitlabAPI { ...@@ -522,6 +548,39 @@ public class GitlabAPI {
return dispatch().to(tailUrl, GitlabProject.class); return dispatch().to(tailUrl, GitlabProject.class);
} }
/**
* Updates a Project
*
* @param projectId The id of the project to update
* @param name The name of the project
* @param description A description for the project, null otherwise
* @param issuesEnabled Whether Issues should be enabled, otherwise null indicates to use GitLab default
* @param wallEnabled Whether The Wall should be enabled, otherwise null indicates to use GitLab default
* @param mergeRequestsEnabled Whether Merge Requests should be enabled, otherwise null indicates to use GitLab default
* @param wikiEnabled Whether a Wiki should be enabled, otherwise null indicates to use GitLab default
* @param snippetsEnabled Whether Snippets should be enabled, otherwise null indicates to use GitLab default
* @param publik Whether the project is public or private, if true same as setting visibilityLevel = 20, otherwise null indicates to use GitLab default
* @param visibilityLevel The visibility level of the project, otherwise null indicates to use GitLab default
* @return the Gitlab Project
* @throws IOException on gitlab api call error
*/
public GitlabProject updateProject(Integer projectId, String name, String description, Boolean issuesEnabled, Boolean wallEnabled, Boolean mergeRequestsEnabled, Boolean wikiEnabled, Boolean snippetsEnabled, Boolean publik, Integer visibilityLevel) throws IOException {
Query query = new Query()
.appendIf("name", name)
.appendIf("description", description)
.appendIf("issues_enabled", issuesEnabled)
.appendIf("wall_enabled", wallEnabled)
.appendIf("merge_requests_enabled", mergeRequestsEnabled)
.appendIf("wiki_enabled", wikiEnabled)
.appendIf("snippets_enabled", snippetsEnabled)
.appendIf("public", publik)
.appendIf("visibility_level", visibilityLevel);
String tailUrl = GitlabProject.URL + "/" + projectId + query.toString();
return retrieve().method("PUT").to(tailUrl, GitlabProject.class);
}
/** /**
* Delete a Project. * Delete a Project.
* *
...@@ -880,6 +939,18 @@ public class GitlabAPI { ...@@ -880,6 +939,18 @@ public class GitlabAPI {
return Arrays.asList(retrieve().to(tailUrl, GitlabProjectMember[].class)); return Arrays.asList(retrieve().to(tailUrl, GitlabProjectMember[].class));
} }
/**
* Transfer a project to the given namespace
*
* @param namespaceId Namespace ID
* @param projectId Project ID
* @throws IOException on gitlab api call error
*/
public void transfer(Integer namespaceId, Integer projectId) throws IOException {
String tailUrl = GitlabNamespace.URL + "/" + namespaceId + GitlabProject.URL + "/" + projectId;
dispatch().to(tailUrl, Void.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);
......
...@@ -8,6 +8,8 @@ public class GitlabUser { ...@@ -8,6 +8,8 @@ public class GitlabUser {
public static String URL = "/users"; public static String URL = "/users";
public static String USERS_URL = "/users"; public static String USERS_URL = "/users";
public static String USER_URL = "/user"; // for sudo based ops public static String USER_URL = "/user"; // for sudo based ops
public static String BLOCK_URL = "/block";
public static String UNBLOCK_URL = "/unblock";
private Integer _id; private Integer _id;
private String _username; private String _username;
......
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