diff --git a/pom.xml b/pom.xml
index 9f5452a9e5..739a0e4f4b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
org.kohsuke
github-api
jar
- 1.0
+ 1.1
GitHub API for Java
http://kohsuke.org/github-api/
GitHub API for Java
diff --git a/src/main/java/org/kohsuke/github/GHUser.java b/src/main/java/org/kohsuke/github/GHUser.java
index 2a5b73f1ff..b439ca4ee8 100644
--- a/src/main/java/org/kohsuke/github/GHUser.java
+++ b/src/main/java/org/kohsuke/github/GHUser.java
@@ -27,6 +27,7 @@
import java.net.URL;
import java.util.Collections;
import java.util.Map;
+import java.util.Set;
import java.util.TreeMap;
import static org.kohsuke.github.GitHub.MAPPER;
@@ -143,6 +144,34 @@ public GHRepository getRepository(String name) throws IOException {
return getRepositories().get(name);
}
+ /**
+ * Follow this user.
+ */
+ public void follow() throws IOException {
+ new Poster(root).withCredential().to(root.getApiURL("/user/follow/"+login));
+ }
+
+ /**
+ * Unfollow this user.
+ */
+ public void unfollow() throws IOException {
+ new Poster(root).withCredential().to(root.getApiURL("/user/unfollow/"+login));
+ }
+
+ /**
+ * Lists the users that this user is following
+ */
+ public Set getFollows() throws IOException {
+ return root.retrieve("/user/show/"+login+"/following",JsonUsers.class).toSet(root);
+ }
+
+ /**
+ * Lists the users who are following this user.
+ */
+ public Set getFollowers() throws IOException {
+ return root.retrieve("/user/show/"+login+"/followers",JsonUsers.class).toSet(root);
+ }
+
@Override
public String toString() {
return "User:"+login;
diff --git a/src/main/java/org/kohsuke/github/JsonUsers.java b/src/main/java/org/kohsuke/github/JsonUsers.java
new file mode 100644
index 0000000000..257f6001f0
--- /dev/null
+++ b/src/main/java/org/kohsuke/github/JsonUsers.java
@@ -0,0 +1,43 @@
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2010, Kohsuke Kawaguchi
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+package org.kohsuke.github;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Kohsuke Kawaguchi
+ */
+class JsonUsers {
+ public List users;
+
+ public Set toSet(GitHub root) throws IOException {
+ Set r = new HashSet();
+ for (String u : users)
+ r.add(root.getUser(u));
+ return r;
+ }
+}