-
Notifications
You must be signed in to change notification settings - Fork 729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added getUserPublicOrganizations method #510
Changes from 3 commits
0848556
c78af01
ffdd54d
9c6f977
4c3e1af
eb36cb4
c763c02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,6 +172,7 @@ public static GitHub connect() throws IOException { | |
* @deprecated | ||
* Use {@link #connectToEnterpriseWithOAuth(String, String, String)} | ||
*/ | ||
@Deprecated | ||
public static GitHub connectToEnterprise(String apiUrl, String oauthAccessToken) throws IOException { | ||
return connectToEnterpriseWithOAuth(apiUrl,null,oauthAccessToken); | ||
} | ||
|
@@ -194,6 +195,7 @@ public static GitHub connectToEnterpriseWithOAuth(String apiUrl, String login, S | |
* @deprecated | ||
* Use with caution. Login with password is not a preferred method. | ||
*/ | ||
@Deprecated | ||
public static GitHub connectToEnterprise(String apiUrl, String login, String password) throws IOException { | ||
return new GitHubBuilder().withEndpoint(apiUrl).withPassword(login, password).build(); | ||
} | ||
|
@@ -207,6 +209,7 @@ public static GitHub connect(String login, String oauthAccessToken) throws IOExc | |
* Either OAuth token or password is sufficient, so there's no point in passing both. | ||
* Use {@link #connectUsingPassword(String, String)} or {@link #connectUsingOAuth(String)}. | ||
*/ | ||
@Deprecated | ||
public static GitHub connect(String login, String oauthAccessToken, String password) throws IOException { | ||
return new GitHubBuilder().withOAuthToken(oauthAccessToken, login).withPassword(login, password).build(); | ||
} | ||
|
@@ -380,7 +383,7 @@ public GHMyself getMyself() throws IOException { | |
requireCredential(); | ||
synchronized (this) { | ||
if (this.myself != null) return myself; | ||
|
||
GHMyself u = retrieve().to("/user", GHMyself.class); | ||
|
||
u.root = this; | ||
|
@@ -402,7 +405,7 @@ public GHUser getUser(String login) throws IOException { | |
return u; | ||
} | ||
|
||
|
||
/** | ||
* clears all cached data in order for external changes (modifications and del | ||
*/ | ||
|
@@ -493,6 +496,7 @@ public GHRepository getRepositoryById(String id) throws IOException { | |
@Preview @Deprecated | ||
public PagedIterable<GHLicense> listLicenses() throws IOException { | ||
return new PagedIterable<GHLicense>() { | ||
@Override | ||
public PagedIterator<GHLicense> _iterator(int pageSize) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
return new PagedIterator<GHLicense>(retrieve().withPreview(DRAX).asIterator("/licenses", GHLicense[].class, pageSize)) { | ||
@Override | ||
|
@@ -510,6 +514,7 @@ protected void wrapUp(GHLicense[] page) { | |
*/ | ||
public PagedIterable<GHUser> listUsers() throws IOException { | ||
return new PagedIterable<GHUser>() { | ||
@Override | ||
public PagedIterator<GHUser> _iterator(int pageSize) { | ||
return new PagedIterator<GHUser>(retrieve().asIterator("/users", GHUser[].class, pageSize)) { | ||
@Override | ||
|
@@ -562,6 +567,32 @@ public Map<String, GHOrganization> getMyOrganizations() throws IOException { | |
} | ||
return r; | ||
} | ||
|
||
/** | ||
* Alias for {@link #getUserPublicOrganizations(String)}. | ||
*/ | ||
public Map<String, GHOrganization> getUserPublicOrganizations(GHUser user) throws IOException { | ||
return getUserPublicOrganizations( user.getLogin() ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One method takes a |
||
} | ||
|
||
/** | ||
* This method returns a shallowly populated organizations. | ||
* | ||
* To retrieve full organization details, you need to call {@link #getOrganization(String)} | ||
* | ||
* @param user the user to retrieve public Organization membership information for | ||
* | ||
* @return the public Organization memberships for the user | ||
*/ | ||
public Map<String, GHOrganization> getUserPublicOrganizations(String login) throws IOException { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other method takes a plain old |
||
GHOrganization[] orgs = retrieve().to("/users/" + login + "/orgs", GHOrganization[].class); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. API Documentation: https://developer.github.com/v3/orgs/#list-user-organizations |
||
Map<String, GHOrganization> r = new HashMap<String, GHOrganization>(); | ||
for (GHOrganization o : orgs) { | ||
// don't put 'o' into orgs because they are shallow | ||
r.put(o.getLogin(),o.wrapUp(this)); | ||
} | ||
return r; | ||
} | ||
|
||
/** | ||
* Gets complete map of organizations/teams that current user belongs to. | ||
|
@@ -634,6 +665,7 @@ public <T extends GHEventPayload> T parseEventPayload(Reader r, Class<T> type) t | |
* @deprecated | ||
* Use {@link #createRepository(String)} that uses a builder pattern to let you control every aspect. | ||
*/ | ||
@Deprecated | ||
public GHRepository createRepository(String name, String description, String homepage, boolean isPublic) throws IOException { | ||
return createRepository(name).description(description).homepage(homepage).private_(!isPublic).create(); | ||
} | ||
|
@@ -869,6 +901,7 @@ public PagedIterable<GHRepository> listAllPublicRepositories() { | |
*/ | ||
public PagedIterable<GHRepository> listAllPublicRepositories(final String since) { | ||
return new PagedIterable<GHRepository>() { | ||
@Override | ||
public PagedIterator<GHRepository> _iterator(int pageSize) { | ||
return new PagedIterator<GHRepository>(retrieve().with("since",since).asIterator("/repositories", GHRepository[].class, pageSize)) { | ||
@Override | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
@Deprecated
annotation to match@deprecated
javadoc; this is best-practice but may start causing IDE or compile warnings for existing users of the methods.If the method is truly deprecated, this is fine.