Commit ad3ec370 authored by Tim Olshansky's avatar Tim Olshansky

Merge pull request #73 from bozaro/system-hooks

Add system hook API support
parents 920840ef e3d741e3
......@@ -1065,6 +1065,48 @@ public class GitlabAPI {
return retrieve().to(tailUrl, GitlabSession.class);
}
/**
* Get list of system hooks
*
* @return The system hooks list
* @throws IOException on gitlab api call error
*/
public List<GitlabSystemHook> getSystemHooks() throws IOException {
String tailUrl = GitlabSystemHook.URL;
return Arrays.asList(retrieve().to(tailUrl, GitlabSystemHook[].class));
}
/**
* Add new system hook hook
*
* @param url System hook url
* @throws IOException on gitlab api call error
*/
public GitlabSystemHook addSystemHook(String url) throws IOException {
String tailUrl = GitlabSystemHook.URL;
return dispatch().with("url", url).to(tailUrl, GitlabSystemHook.class);
}
/**
* Test system hook
*
* @throws IOException on gitlab api call error
*/
public void testSystemHook(Integer hookId) throws IOException {
String tailUrl = GitlabSystemHook.URL + "/" + hookId;
retrieve().to(tailUrl, Void.class);
}
/**
* Delete system hook
*
* @throws IOException on gitlab api call error
*/
public GitlabSystemHook deleteSystemHook(Integer hookId) throws IOException {
String tailUrl = GitlabSystemHook.URL + "/" + hookId;
return retrieve().method("DELETE").to(tailUrl, GitlabSystemHook.class);
}
private String sanitizeProjectId(Serializable projectId) {
if (!(projectId instanceof String) && !(projectId instanceof Integer)) {
throw new IllegalArgumentException();
......
package org.gitlab.api.models;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Date;
public class GitlabSystemHook {
public final static String URL = "/hooks";
private Integer id;
private String url;
@JsonProperty("created_at")
private Date createdAt;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
}
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