From ba416b12940938cb305f9c4f875e5d5a6f062c1b Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sat, 6 Apr 2013 19:06:44 -0700 Subject: [PATCH 1/7] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8c0582e1c9..076bea0f0c 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ github-api - 1.38 + 1.39-SNAPSHOT GitHub API for Java http://github-api.kohsuke.org/ GitHub API for Java From e8a2a69649c16ee39b3b977cfa7a277b0249675a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Br=C3=A1zdil?= Date: Sat, 13 Apr 2013 17:09:03 +0200 Subject: [PATCH 2/7] Implement GHEventPayload.IssueComment --- .../org/kohsuke/github/GHEventPayload.java | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/kohsuke/github/GHEventPayload.java b/src/main/java/org/kohsuke/github/GHEventPayload.java index efb3d0d3fe..bd858b5a40 100644 --- a/src/main/java/org/kohsuke/github/GHEventPayload.java +++ b/src/main/java/org/kohsuke/github/GHEventPayload.java @@ -21,7 +21,7 @@ public abstract class GHEventPayload { public static class PullRequest extends GHEventPayload { private String action; private int number; - GHPullRequest pull_request; + private GHPullRequest pull_request; public String getAction() { return action; @@ -42,5 +42,47 @@ void wrapUp(GitHub root) { pull_request.wrapUp(root); } } + + public static class IssueComment extends GHEventPayload { + private String action; + private GHIssueComment comment; + private GHIssue issue; + private GHRepository repository; + + public String getAction() { + return action; + } + + public GHIssueComment getComment() { + return comment; + } + + public void setComment(GHIssueComment comment) { + this.comment = comment; + } + + public GHIssue getIssue() { + return issue; + } + public void setIssue(GHIssue issue) { + this.issue = issue; + } + + public GHRepository getRepository() { + return repository; + } + + public void setRepository(GHRepository repository) { + this.repository = repository; + } + + @Override + void wrapUp(GitHub root) { + super.wrapUp(root); + repository.wrap(root); + issue.wrap(repository); + comment.wrapUp(issue); + } + } } From e9564f101b51bb87cca5b08fe0ebfbee41a30f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Br=C3=A1zdil?= Date: Sun, 14 Apr 2013 05:48:29 +0200 Subject: [PATCH 3/7] implement retrieving of access token --- .../org/kohsuke/github/GHAuthorization.java | 90 +++++++++++++++++++ src/main/java/org/kohsuke/github/GitHub.java | 12 +++ 2 files changed, 102 insertions(+) create mode 100644 src/main/java/org/kohsuke/github/GHAuthorization.java diff --git a/src/main/java/org/kohsuke/github/GHAuthorization.java b/src/main/java/org/kohsuke/github/GHAuthorization.java new file mode 100644 index 0000000000..711be454c6 --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHAuthorization.java @@ -0,0 +1,90 @@ +package org.kohsuke.github; + +import java.net.URL; +import java.util.Date; +import java.util.List; + +/** + * + * @author janinko + */ +public class GHAuthorization { + public static final String USER = "user"; + public static final String USER_EMAIL = "user:email"; + public static final String USER_FOLLOW = "user:follow"; + public static final String PUBLIC_REPO = "public_repo"; + public static final String REPO = "repo"; + public static final String REPO_STATUS = "repo:status"; + public static final String DELETE_REPO = "delete_repo"; + public static final String NOTIFICATIONS = "notifications"; + public static final String GIST = "gist"; + + private GitHub root; + private int id; + private String url; + private List scopes; + private String token; + private App app; + private String note; + private String note_url; + private String updated_at; + private String created_at; + + public GitHub getRoot() { + return root; + } + + public int getId() { + return id; + } + + public List getScopes() { + return scopes; + } + + public String getToken(){ + return token; + } + + public URL getAppUrl(){ + return GitHub.parseURL(app.url); + } + + public String getAppName() { + return app.name; + } + + public URL getApiURL(){ + return GitHub.parseURL(url); + } + + public String getNote() { + return note; + } + + public URL getNoteUrl(){ + return GitHub.parseURL(note_url); + } + + public Date getCreatedAt() { + return GitHub.parseDate(created_at); + } + + public Date getUpdatedAt() { + return GitHub.parseDate(updated_at); + } + + /*package*/ GHAuthorization wrap(GitHub root) { + this.root = root; + return this; + } + + + + + + private static class App{ + private String url; + private String name; + } +} diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index 177f197819..889a5e93e4 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -39,11 +39,14 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Arrays; +import java.util.Collection; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; import java.util.TimeZone; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.*; @@ -303,6 +306,15 @@ public GHRepository createRepository(String name, String description, String hom return requester.method("POST").to("/user/repos", GHRepository.class).wrap(this); } + public GHAuthorization createToken(Collection scope, String note, String noteUrl) throws IOException{ + Requester requester = new Requester(this) + .with("scopes",scope) + .with("note",note) + .with("note_url",noteUrl); + + return requester.method("POST").to("/authorizations", GHAuthorization.class).wrap(this); + } + /** * Ensures that the credential is valid. */ From df857d3a84e0c07efc7d4dbca59ec37a716004f5 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 16 Apr 2013 12:14:06 -0700 Subject: [PATCH 4/7] doc improvement --- .../java/org/kohsuke/github/GHAuthorization.java | 4 ++++ src/main/java/org/kohsuke/github/GitHub.java | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHAuthorization.java b/src/main/java/org/kohsuke/github/GHAuthorization.java index 711be454c6..dae2c74115 100644 --- a/src/main/java/org/kohsuke/github/GHAuthorization.java +++ b/src/main/java/org/kohsuke/github/GHAuthorization.java @@ -1,12 +1,16 @@ package org.kohsuke.github; import java.net.URL; +import java.util.Collection; import java.util.Date; import java.util.List; /** + * Generated OAuth token * * @author janinko + * @see GitHub#createToken(Collection, String, String) + * @see http://developer.github.com/v3/oauth/#create-a-new-authorization */ public class GHAuthorization { public static final String USER = "user"; diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index 889a5e93e4..6c7999492b 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -306,11 +306,18 @@ public GHRepository createRepository(String name, String description, String hom return requester.method("POST").to("/user/repos", GHRepository.class).wrap(this); } + /** + * Creates a new authorization. + * + * The token created can be then used for {@link GitHub#connectUsingOAuth(String)} in the future. + * + * @see http://developer.github.com/v3/oauth/#create-a-new-authorization + */ public GHAuthorization createToken(Collection scope, String note, String noteUrl) throws IOException{ Requester requester = new Requester(this) - .with("scopes",scope) - .with("note",note) - .with("note_url",noteUrl); + .with("scopes", scope) + .with("note", note) + .with("note_url", noteUrl); return requester.method("POST").to("/authorizations", GHAuthorization.class).wrap(this); } From c21d61a70d219a956cb4901fc8158b6d6586f122 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 16 Apr 2013 12:17:30 -0700 Subject: [PATCH 5/7] TAB -> WS --- .../org/kohsuke/github/GHEventPayload.java | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHEventPayload.java b/src/main/java/org/kohsuke/github/GHEventPayload.java index bd858b5a40..edfcc24885 100644 --- a/src/main/java/org/kohsuke/github/GHEventPayload.java +++ b/src/main/java/org/kohsuke/github/GHEventPayload.java @@ -42,47 +42,47 @@ void wrapUp(GitHub root) { pull_request.wrapUp(root); } } - + public static class IssueComment extends GHEventPayload { private String action; private GHIssueComment comment; - private GHIssue issue; - private GHRepository repository; + private GHIssue issue; + private GHRepository repository; public String getAction() { return action; } - public GHIssueComment getComment() { - return comment; - } + public GHIssueComment getComment() { + return comment; + } - public void setComment(GHIssueComment comment) { - this.comment = comment; - } + public void setComment(GHIssueComment comment) { + this.comment = comment; + } - public GHIssue getIssue() { - return issue; - } + public GHIssue getIssue() { + return issue; + } - public void setIssue(GHIssue issue) { - this.issue = issue; - } + public void setIssue(GHIssue issue) { + this.issue = issue; + } - public GHRepository getRepository() { - return repository; - } + public GHRepository getRepository() { + return repository; + } - public void setRepository(GHRepository repository) { - this.repository = repository; - } + public void setRepository(GHRepository repository) { + this.repository = repository; + } @Override void wrapUp(GitHub root) { super.wrapUp(root); - repository.wrap(root); + repository.wrap(root); issue.wrap(repository); - comment.wrapUp(issue); + comment.wrapUp(issue); } } } From ba6c6a17aeb777f289162506a074f0e987c58c94 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 16 Apr 2013 12:18:50 -0700 Subject: [PATCH 6/7] doc improvement --- src/main/java/org/kohsuke/github/GHEventPayload.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/kohsuke/github/GHEventPayload.java b/src/main/java/org/kohsuke/github/GHEventPayload.java index edfcc24885..5d666f5090 100644 --- a/src/main/java/org/kohsuke/github/GHEventPayload.java +++ b/src/main/java/org/kohsuke/github/GHEventPayload.java @@ -18,6 +18,11 @@ public abstract class GHEventPayload { this.root = root; } + /** + * A pull request status has changed. + * + * @see http://developer.github.com/v3/activity/events/types/#pullrequestevent + */ public static class PullRequest extends GHEventPayload { private String action; private int number; @@ -43,6 +48,11 @@ void wrapUp(GitHub root) { } } + /** + * A comment was added to an issue + * + * @see http://developer.github.com/v3/activity/events/types/#issuecommentevent + */ public static class IssueComment extends GHEventPayload { private String action; private GHIssueComment comment; From f7e5292b8c5f2ce6d827a2c3687cf94ccfbb7069 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 16 Apr 2013 12:22:20 -0700 Subject: [PATCH 7/7] [maven-release-plugin] prepare release github-api-1.39 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 076bea0f0c..2acbbfdafa 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ github-api - 1.39-SNAPSHOT + 1.39 GitHub API for Java http://github-api.kohsuke.org/ GitHub API for Java