Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2015-03-10 01:37:49 +0000
committerGerrit Code Review @ Eclipse.org2015-03-10 01:37:49 +0000
commit76dc8a6ef060de819a3e3c99d535fdca2a8785d9 (patch)
tree24d7721107a00b06b7441477ee0da329e269d877 /org.eclipse.egit.github.core
parent0857b455f61a38cd8ec96de9eef6c82c04f8a9a1 (diff)
parenta4b06eb46a951c821ba69fdec48ec4c5196cb718 (diff)
downloadegit-github-76dc8a6ef060de819a3e3c99d535fdca2a8785d9.tar.gz
egit-github-76dc8a6ef060de819a3e3c99d535fdca2a8785d9.tar.xz
egit-github-76dc8a6ef060de819a3e3c99d535fdca2a8785d9.zip
Merge "Implemented the GitHub Team Membership API"
Diffstat (limited to 'org.eclipse.egit.github.core')
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/TeamMembership.java61
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java2
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/TeamService.java49
3 files changed, 111 insertions, 1 deletions
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/TeamMembership.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/TeamMembership.java
new file mode 100644
index 00000000..cbc3ad8b
--- /dev/null
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/TeamMembership.java
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * Copyright (c) 2014, 2015 Arizona Board of Regents
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Michael Mathews (Arizona Board of Regents) - (Bug: 447419)
+ * Team Membership API implementation
+ *****************************************************************************/
+package org.eclipse.egit.github.core;
+
+import java.io.Serializable;
+
+/**
+ * Team Membership model class.
+ */
+public class TeamMembership implements Serializable {
+
+ private static final long serialVersionUID = -8207728181588115431L;
+
+ /**
+ * The possible states of a Team Membership
+ */
+ public static enum TeamMembershipState {
+ ACTIVE, PENDING;
+ }
+
+ private TeamMembershipState state;
+
+ private String url;
+
+ /**
+ * @return state
+ */
+ public TeamMembershipState getState() {
+ return state;
+ }
+
+ /**
+ * @param state
+ */
+ public void setState(TeamMembershipState state) {
+ this.state = state;
+ }
+
+ /**
+ * @return url
+ */
+ public String getUrl() {
+ return url;
+ }
+
+ /**
+ * @param url
+ */
+ public void setUrl(String url) {
+ this.url = url;
+ }
+}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java
index 83dc0206..eb0518b9 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/client/IGitHubConstants.java
@@ -137,6 +137,8 @@ public interface IGitHubConstants {
/** */
String SEGMENT_ORGANIZATIONS = "/organizations"; //$NON-NLS-1$
/** */
+ String SEGMENT_MEMBERSHIPS = "/memberships"; //$NON-NLS-1$
+ /** */
String SEGMENT_ORGS = "/orgs"; //$NON-NLS-1$
/** */
String SEGMENT_PUBLIC = "/public"; //$NON-NLS-1$
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 f015af19..7b439e58 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 GitHub Inc.
+ * Copyright (c) 2011, 2014 GitHub Inc. and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,10 +7,13 @@
*
* Contributors:
* Kevin Sawicki (GitHub Inc.) - initial API and implementation
+ * Michael Mathews (Arizona Board of Regents) - (Bug: 447419)
+ * Team Membership API implementation
*****************************************************************************/
package org.eclipse.egit.github.core.service;
import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_MEMBERS;
+import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_MEMBERSHIPS;
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;
@@ -25,6 +28,7 @@ import java.util.Map;
import org.eclipse.egit.github.core.IRepositoryIdProvider;
import org.eclipse.egit.github.core.Repository;
import org.eclipse.egit.github.core.Team;
+import org.eclipse.egit.github.core.TeamMembership;
import org.eclipse.egit.github.core.User;
import org.eclipse.egit.github.core.client.GitHubClient;
import org.eclipse.egit.github.core.client.GitHubRequest;
@@ -242,6 +246,49 @@ public class TeamService extends GitHubService {
client.delete(uri.toString());
}
+ public TeamMembership getMembership(int id, String user) throws IOException {
+ if (user == null)
+ throw new IllegalArgumentException("User cannot be null"); //$NON-NLS-1$
+ if (user.length() == 0)
+ throw new IllegalArgumentException("User cannot be empty"); //$NON-NLS-1$
+
+ StringBuilder uri = new StringBuilder(SEGMENT_TEAMS);
+ uri.append('/').append(id);
+ uri.append(SEGMENT_MEMBERSHIPS);
+ uri.append('/').append(user);
+
+ GitHubRequest request = createRequest();
+ request.setUri(uri);
+ request.setType(TeamMembership.class);
+ return (TeamMembership) client.get(request).getBody();
+ }
+
+ public TeamMembership addMembership(int id, String user) throws IOException {
+ if (user == null)
+ throw new IllegalArgumentException("User cannot be null"); //$NON-NLS-1$
+ if (user.length() == 0)
+ throw new IllegalArgumentException("User cannot be empty"); //$NON-NLS-1$
+
+ StringBuilder uri = new StringBuilder(SEGMENT_TEAMS);
+ uri.append('/').append(id);
+ uri.append(SEGMENT_MEMBERSHIPS);
+ uri.append('/').append(user);
+ return client.put(uri.toString(), null, TeamMembership.class);
+ }
+
+ public void removeMembership(int id, String user) throws IOException {
+ if (user == null)
+ throw new IllegalArgumentException("User cannot be null"); //$NON-NLS-1$
+ if (user.length() == 0)
+ throw new IllegalArgumentException("User cannot be empty"); //$NON-NLS-1$
+
+ StringBuilder uri = new StringBuilder(SEGMENT_TEAMS);
+ uri.append('/').append(id);
+ uri.append(SEGMENT_MEMBERSHIPS);
+ uri.append('/').append(user);
+ client.delete(uri.toString());
+ }
+
/**
* Get all repositories for given team
*

Back to the top