diff --git a/pom.xml b/pom.xml index ff3f7d820b..4d026c5a83 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ github-api - 1.44 + 1.45 GitHub API for Java http://github-api.kohsuke.org/ GitHub API for Java @@ -64,9 +64,9 @@ test - org.codehaus.jackson - jackson-mapper-asl - 1.9.9 + com.fasterxml.jackson.core + jackson-databind + 2.2.3 commons-io @@ -85,8 +85,13 @@ 1.1 test + + org.eclipse.jgit + org.eclipse.jgit + 3.1.0.201310021548-r + test + - repo.jenkins-ci.org diff --git a/src/main/java/org/kohsuke/github/GHAsset.java b/src/main/java/org/kohsuke/github/GHAsset.java new file mode 100644 index 0000000000..b26c72000e --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHAsset.java @@ -0,0 +1,108 @@ +package org.kohsuke.github; + +import java.io.IOException; +import java.util.Date; + +/** + * Asset in a release. + * + * @see GHRelease#getAssets() + */ +public class GHAsset { + GitHub root; + GHRepository owner; + private String url; + private String id; + private String name; + private String label; + private String state; + private String content_type; + private long size; + private long download_count; + private Date created_at; + private Date updated_at; + + public String getContentType() { + return content_type; + } + + public void setContentType(String contentType) throws IOException { + edit("content_type", contentType); + this.content_type = contentType; + } + + public Date getCreatedAt() { + return created_at; + } + + public long getDownloadCount() { + return download_count; + } + + public String getId() { + return id; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) throws IOException { + edit("label", label); + this.label = label; + } + + public String getName() { + return name; + } + + public GHRepository getOwner() { + return owner; + } + + public GitHub getRoot() { + return root; + } + + public long getSize() { + return size; + } + + public String getState() { + return state; + } + + public Date getUpdatedAt() { + return updated_at; + } + + public String getUrl() { + return url; + } + + private void edit(String key, Object value) throws IOException { + new Requester(root)._with(key, value).method("PATCH").to(getApiRoute()); + } + + public void delete() throws IOException { + new Requester(root).method("DELETE").to(getApiRoute()); + } + + + private String getApiRoute() { + return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/releases/assets/" + id; + } + + GHAsset wrap(GHRelease release) { + this.owner = release.getOwner(); + this.root = owner.root; + return this; + } + + public static GHAsset[] wrap(GHAsset[] assets, GHRelease release) { + for (GHAsset aTo : assets) { + aTo.wrap(release); + } + return assets; + } +} diff --git a/src/main/java/org/kohsuke/github/GHEventInfo.java b/src/main/java/org/kohsuke/github/GHEventInfo.java index fe9aada27f..b3dfba0238 100644 --- a/src/main/java/org/kohsuke/github/GHEventInfo.java +++ b/src/main/java/org/kohsuke/github/GHEventInfo.java @@ -1,10 +1,10 @@ package org.kohsuke.github; -import org.codehaus.jackson.node.ObjectNode; - import java.io.IOException; import java.util.Date; +import com.fasterxml.jackson.databind.node.ObjectNode; + /** * Represents an event. * diff --git a/src/main/java/org/kohsuke/github/GHIssue.java b/src/main/java/org/kohsuke/github/GHIssue.java index 636ebb7c51..dfd73dc785 100644 --- a/src/main/java/org/kohsuke/github/GHIssue.java +++ b/src/main/java/org/kohsuke/github/GHIssue.java @@ -49,7 +49,7 @@ public class GHIssue { protected String closed_at; protected int comments; protected String body; - protected List labels; + protected List