Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSingaram Subramanian2018-02-25 17:26:43 -0500
committerThomas Wolf2018-05-30 08:44:45 -0400
commit74b4db841f41835ab96521d2bd93dee318b94000 (patch)
tree7b722fa4a4d77045d4819254b812428220ea915a /org.eclipse.egit.github.core
parent6fc1a5eacd8dbaf89e4b6e2e9b28d7da30c09e9d (diff)
downloadegit-github-74b4db841f41835ab96521d2bd93dee318b94000.tar.gz
egit-github-74b4db841f41835ab96521d2bd93dee318b94000.tar.xz
egit-github-74b4db841f41835ab96521d2bd93dee318b94000.zip
Get user's teams across GitHub organizations
User may belong to different teams in different GitHub organizations. This change is to retrieve all those teams across organizations using GitHub APIs. Bug: 529850 Change-Id: I703c3385e26ffcd4e34aa1aa1515f6e53fbdf008 Signed-off-by: Singaram Subramanian <to.ramsubramanian@gmail.com>
Diffstat (limited to 'org.eclipse.egit.github.core')
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Organization.java99
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Team.java20
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/TeamService.java24
3 files changed, 139 insertions, 4 deletions
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Organization.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Organization.java
new file mode 100644
index 00000000..4d7fb245
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Organization.java
@@ -0,0 +1,99 @@
+/******************************************************************************
+ * Copyright (c) 2018 Singaram Subramanian <to.ramsubramanian@gmail.com>
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Singaram Subramanian (Capital One) - (Bug: 529850)
+ * User teams across GitHub organizations implementation
+ *****************************************************************************/
+package org.eclipse.egit.github.core;
+
+import java.io.Serializable;
+
+/**
+ * Organization model class.
+ *
+ * Contains information about the GitHub organization that a particular
+ * GitHub Team is associated with.
+ *
+ * @see Team
+ */
+public class Organization implements Serializable {
+
+ /** serialVersionUID */
+ private static final long serialVersionUID = -747906610305335107L;
+
+ private int id;
+
+ private String login;
+
+ private String description;
+
+ private String url;
+
+ /**
+ * @return the id
+ */
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public Organization setId(int id) {
+ this.id = id;
+ return this;
+ }
+
+ /**
+ * @return the login
+ */
+ public String getLogin() {
+ return login;
+ }
+
+ /**
+ * @param login the login to set
+ */
+ public Organization setLogin(String login) {
+ this.login = login;
+ return this;
+ }
+
+ /**
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description the description to set
+ */
+ public Organization setDescription(String description) {
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * @return the url
+ */
+ public String getUrl() {
+ return url;
+ }
+
+ /**
+ * @param url the url to set
+ */
+ public Organization setUrl(String url) {
+ this.url = url;
+ return this;
+ }
+
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Team.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Team.java
index f6436b31..1dbbf1f4 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Team.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Team.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2011 GitHub Inc.
+ * Copyright (c) 2011, 2018 GitHub Inc. and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -9,6 +9,8 @@
*
* Contributors:
* Kevin Sawicki (GitHub Inc.) - initial API and implementation
+ * Singaram Subramanian (Capital One) - (Bug: 529850)
+ * User teams across GitHub organizations implementation
*****************************************************************************/
package org.eclipse.egit.github.core;
@@ -34,6 +36,8 @@ public class Team implements Serializable {
private String url;
+ private Organization organization;
+
/**
* @return id
*/
@@ -130,4 +134,18 @@ public class Team implements Serializable {
return this;
}
+ /**
+ * @return the organization
+ */
+ public Organization getOrganization() {
+ return organization;
+ }
+
+ /**
+ * @param organization the organization to set
+ */
+ public void setOrganization(Organization organization) {
+ this.organization = organization;
+ }
+
}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/TeamService.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/TeamService.java
index e2a59a48..847403f9 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/TeamService.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/TeamService.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2011, 2014 GitHub Inc. and others
+ * Copyright (c) 2011, 2018 GitHub Inc. and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -11,6 +11,8 @@
* Kevin Sawicki (GitHub Inc.) - initial API and implementation
* Michael Mathews (Arizona Board of Regents) - (Bug: 447419)
* Team Membership API implementation
+ * Singaram Subramanian (Capital One) - (Bug: 529850)
+ * User teams across GitHub organizations implementation
*****************************************************************************/
package org.eclipse.egit.github.core.service;
@@ -19,8 +21,7 @@ import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_MEMBE
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_ORGS;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_REPOS;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_TEAMS;
-
-import com.google.gson.reflect.TypeToken;
+import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_USER;
import java.io.IOException;
import java.util.HashMap;
@@ -36,6 +37,8 @@ import org.eclipse.egit.github.core.client.GitHubClient;
import org.eclipse.egit.github.core.client.GitHubRequest;
import org.eclipse.egit.github.core.client.PagedRequest;
+import com.google.gson.reflect.TypeToken;
+
/**
* Service class for working with organization teams
*
@@ -380,4 +383,19 @@ public class TeamService extends GitHubService {
}.getType());
return getAll(request);
}
+
+ /**
+ * Get teams of the current user across all of the GitHub organizations
+ *
+ * @return list of teams
+ * @throws IOException
+ */
+ public List<Team> getTeams() throws IOException {
+ StringBuilder uri = new StringBuilder(SEGMENT_USER).append(SEGMENT_TEAMS);
+ PagedRequest<Team> request = createPagedRequest();
+ request.setUri(uri);
+ request.setType(new TypeToken<List<Team>>(){}.getType());
+ return getAll(request);
+ }
+
}

Back to the top