Commit 6bc36c98 authored by caguilar187's avatar caguilar187

readding some methods that use the slug version of the project id

readding the json properties

fixing up code style to match master

trying to fix up whitespace issues to match original changes

white space fixes for gitlab branch and project hook

clean up gitlab api file

fixing compile issues with gitlab api

fixing compile issues with gitlab api
parent c70ceb94
...@@ -390,6 +390,12 @@ public class GitlabAPI { ...@@ -390,6 +390,12 @@ public class GitlabAPI {
return dispatch().with("body", body).to(tailUrl, GitlabNote.class); return dispatch().with("body", body).to(tailUrl, GitlabNote.class);
} }
public List<GitlabBranch> getBranches(String projectId) throws IOException {
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabBranch.URL;
GitlabBranch[] branches = retrieve().to(tailUrl, GitlabBranch[].class);
return Arrays.asList(branches);
}
public List<GitlabBranch> getBranches(GitlabProject project) throws IOException { public List<GitlabBranch> getBranches(GitlabProject project) throws IOException {
String tailUrl = GitlabProject.URL + "/" + project.getId() + GitlabBranch.URL; String tailUrl = GitlabProject.URL + "/" + project.getId() + GitlabBranch.URL;
GitlabBranch[] branches = retrieve().to(tailUrl, GitlabBranch[].class); GitlabBranch[] branches = retrieve().to(tailUrl, GitlabBranch[].class);
...@@ -412,6 +418,12 @@ public class GitlabAPI { ...@@ -412,6 +418,12 @@ public class GitlabAPI {
retrieve().method("PUT").to(tailUrl, Void.class); retrieve().method("PUT").to(tailUrl, Void.class);
} }
public List<GitlabProjectHook> getProjectHooks(String projectId) throws IOException {
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabProjectHook.URL;
GitlabProjectHook[] hooks = retrieve().to(tailUrl, GitlabProjectHook[].class);
return Arrays.asList(hooks);
}
public List<GitlabProjectHook> getProjectHooks(GitlabProject project) throws IOException { public List<GitlabProjectHook> getProjectHooks(GitlabProject project) throws IOException {
String tailUrl = GitlabProject.URL + "/" + project.getId() + GitlabProjectHook.URL; String tailUrl = GitlabProject.URL + "/" + project.getId() + GitlabProjectHook.URL;
GitlabProjectHook[] hooks = retrieve().to(tailUrl, GitlabProjectHook[].class); GitlabProjectHook[] hooks = retrieve().to(tailUrl, GitlabProjectHook[].class);
...@@ -432,6 +444,17 @@ public class GitlabAPI { ...@@ -432,6 +444,17 @@ public class GitlabAPI {
return dispatch().to(tailUrl, GitlabProjectHook.class); return dispatch().to(tailUrl, GitlabProjectHook.class);
} }
public GitlabProjectHook addProjectHook(String projectId, String url, boolean pushEvents, boolean issuesEvents, boolean mergeRequestEvents) throws IOException {
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabProjectHook.URL;
return dispatch()
.with("url", url)
.with("push_events", pushEvents ? "true" : "false")
.with("issues_events", issuesEvents ? "true" : "false")
.with("merge_requests_events", mergeRequestEvents ? "true" : "false")
.to(tailUrl, GitlabProjectHook.class);
}
public GitlabProjectHook editProjectHook(GitlabProject project, String hookId, String url) throws IOException { public GitlabProjectHook editProjectHook(GitlabProject project, String hookId, String url) throws IOException {
Query query = new Query() Query query = new Query()
.append("url", url); .append("url", url);
...@@ -440,6 +463,11 @@ public class GitlabAPI { ...@@ -440,6 +463,11 @@ public class GitlabAPI {
return retrieve().method("PUT").to(tailUrl, GitlabProjectHook.class); return retrieve().method("PUT").to(tailUrl, GitlabProjectHook.class);
} }
public void deleteProjectHook(GitlabProjectHook hook) throws IOException {
String tailUrl = GitlabProject.URL + "/" + hook.getProjectId() + GitlabProjectHook.URL + "/" + hook.getId();
retrieve().method("DELETE").to(tailUrl, Void.class);
}
public void deleteProjectHook(GitlabProject project, String hookId) throws IOException { public void deleteProjectHook(GitlabProject project, String hookId) throws IOException {
String tailUrl = GitlabProject.URL + "/" + project.getId() + GitlabProjectHook.URL + "/" + hookId; String tailUrl = GitlabProject.URL + "/" + project.getId() + GitlabProjectHook.URL + "/" + hookId;
retrieve().method("DELETE").to(tailUrl, Void.class); retrieve().method("DELETE").to(tailUrl, Void.class);
...@@ -503,17 +531,17 @@ public class GitlabAPI { ...@@ -503,17 +531,17 @@ public class GitlabAPI {
} }
public GitlabNote createNote(String projectId, Integer issueId, String message) throws IOException { public GitlabNote createNote(String projectId, Integer issueId, String message) throws IOException {
String tailUrl = GitlabProject.URL + "/" + sanitizeProjectId(projectId) + GitlabIssue.URL String tailUrl = GitlabProject.URL + "/" + projectId + GitlabIssue.URL
+ "/" + issueId + GitlabNote.URL; + "/" + issueId + GitlabNote.URL;
return dispatch().with("body", message).to(tailUrl, GitlabNote.class); return dispatch().with("body", message).to(tailUrl, GitlabNote.class);
} }
public GitlabNote createNote(GitlabIssue issue, String message) throws IOException { public GitlabNote createNote(GitlabIssue issue, String message) throws IOException {
return createNote(issue.getProjectId(), issue.getId(), message); return createNote(String.valueOf(issue.getProjectId()), issue.getId(), message);
} }
public List<GitlabMilestone> getMilestones(GitlabProject project) throws IOException { public List<GitlabMilestone> getMilestones(GitlabProject project) throws IOException {
return getMilestones(project.getId()); return getMilestones(String.valueOf(project.getId()));
} }
public List<GitlabMilestone> getMilestones(String projectId) throws IOException { public List<GitlabMilestone> getMilestones(String projectId) throws IOException {
...@@ -522,7 +550,7 @@ public class GitlabAPI { ...@@ -522,7 +550,7 @@ public class GitlabAPI {
} }
public List<GitlabProjectMember> getProjectMembers(GitlabProject project) throws IOException { public List<GitlabProjectMember> getProjectMembers(GitlabProject project) throws IOException {
return getProjectMembers(project.getId()); return getProjectMembers(String.valueOf(project.getId()));
} }
public List<GitlabProjectMember> getProjectMembers(String projectId) throws IOException { public List<GitlabProjectMember> getProjectMembers(String projectId) throws IOException {
......
package org.gitlab.api.models; package org.gitlab.api.models;
import org.gitlab.api.models.GitlabBranchCommit;
import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.annotate.JsonProperty;
public class GitlabBranch { public class GitlabBranch {
public static String URL = "/repository/branches/"; public final static String URL = "/repository/branches/";
@JsonProperty("name")
private String _name; private String _name;
@JsonProperty("commit")
private GitlabBranchCommit _commit; private GitlabBranchCommit _commit;
@JsonProperty("protected")
private boolean _protected; private boolean _protected;
public String getName() { public String getName() {
...@@ -16,7 +19,7 @@ public class GitlabBranch { ...@@ -16,7 +19,7 @@ public class GitlabBranch {
} }
public void setName(String name) { public void setName(String name) {
_name = name; this._name = name;
} }
public GitlabBranchCommit getCommit() { public GitlabBranchCommit getCommit() {
...@@ -24,14 +27,14 @@ public class GitlabBranch { ...@@ -24,14 +27,14 @@ public class GitlabBranch {
} }
public void setCommit(GitlabBranchCommit commit) { public void setCommit(GitlabBranchCommit commit) {
_commit = commit; this._commit = commit;
} }
public boolean getProtected() { public boolean isProtected() {
return _protected; return _protected;
} }
public void setProtected(boolean isProtected) { public void setProtected(boolean isProtected) {
_protected = isProtected; this._protected = isProtected;
} }
} }
\ No newline at end of file
package org.gitlab.api.models; package org.gitlab.api.models;
import java.util.Date; import java.util.Date;
import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.annotate.JsonProperty;
public class GitlabProjectHook { public class GitlabProjectHook {
public static final String URL = "/hooks"; public final static String URL = "/hooks";
private Integer _id; private String _id;
private String _url; private String _url;
@JsonProperty("project_id")
private Integer _projectId; private Integer _projectId;
@JsonProperty("push_events") @JsonProperty("push_events")
...@@ -25,11 +25,12 @@ public class GitlabProjectHook { ...@@ -25,11 +25,12 @@ public class GitlabProjectHook {
@JsonProperty("created_at") @JsonProperty("created_at")
private Date _createdAt; private Date _createdAt;
public Integer getId() {
public String getId() {
return _id; return _id;
} }
public void setId(Integer id) { public void setId(String id) {
_id = id; _id = id;
} }
...@@ -38,7 +39,7 @@ public class GitlabProjectHook { ...@@ -38,7 +39,7 @@ public class GitlabProjectHook {
} }
public void setUrl(String url) { public void setUrl(String url) {
_url = url; this._url = url;
} }
public Integer getProjectId() { public Integer getProjectId() {
...@@ -57,14 +58,6 @@ public class GitlabProjectHook { ...@@ -57,14 +58,6 @@ public class GitlabProjectHook {
_pushEvents = pushEvents; _pushEvents = pushEvents;
} }
public Date getCreatedAt() {
return _createdAt;
}
public void setCreatedAt(Date createdAt) {
_createdAt = createdAt;
}
public boolean getIssueEvents() { public boolean getIssueEvents() {
return _issueEvents; return _issueEvents;
} }
...@@ -80,4 +73,12 @@ public class GitlabProjectHook { ...@@ -80,4 +73,12 @@ public class GitlabProjectHook {
public void setMergeRequestsEvents(boolean mergeRequestsEvents) { public void setMergeRequestsEvents(boolean mergeRequestsEvents) {
_mergeRequestsEvents = mergeRequestsEvents; _mergeRequestsEvents = mergeRequestsEvents;
} }
public Date getCreatedAt() {
return _createdAt;
}
public void setCreatedAt(Date createdAt) {
_createdAt = createdAt;
}
} }
\ No newline at end of file
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