Skip to content
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

Add outside_collaborators list #1561

Merged
merged 5 commits into from
Nov 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/main/java/org/kohsuke/github/GHOrganization.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,17 @@ public PagedIterable<GHUser> listPublicMembers() throws IOException {
return listMembers("public_members");
}

/**
* All the outside collaborators of this organization.
*
* @return the paged iterable
* @throws IOException
* the io exception
*/
public PagedIterable<GHUser> listOutsideCollaborators() throws IOException {
return listMembers("outside_collaborators");
Diegunix marked this conversation as resolved.
Show resolved Hide resolved
}

private PagedIterable<GHUser> listMembers(String suffix) throws IOException {
return listMembers(suffix, null, null);
}
Expand All @@ -332,6 +343,19 @@ public PagedIterable<GHUser> listMembersWithFilter(String filter) throws IOExcep
return listMembers("members", filter, null);
}

/**
* List outside collaborators with filter paged iterable.
*
* @param filter
* the filter
* @return the paged iterable
* @throws IOException
* the io exception
*/
public PagedIterable<GHUser> listOutsideCollaboratorsWithFilter(String filter) throws IOException {
return listMembers("outside_collaborators", filter, null);
}

/**
* List members with specified role paged iterable.
*
Expand Down
59 changes: 59 additions & 0 deletions src/test/java/org/kohsuke/github/GHOrganizationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,65 @@ public void testListMembersWithRole() throws IOException {
"timja"));
}

/**
* Test list outside collaborators.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testListOutsideCollaborators() throws IOException {
GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG);

List<GHUser> admins = org.listOutsideCollaborators().toList();

assertThat(admins, notNullValue());
// In case more are added in the future
assertThat(admins.size(), greaterThanOrEqualTo(12));
assertThat(admins.stream().map(GHUser::getLogin).collect(Collectors.toList()),
hasItems("alexanderrtaylor",
"asthinasthi",
"bitwiseman",
"farmdawgnation",
"halkeye",
"jberglund-BSFT",
"kohsuke",
"kohsuke2",
"martinvanzijl",
"PauloMigAlmeida",
"Sage-Pierce",
"timja"));
}
/**
* Test list outside collaborators with filter.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testListOutsideCollaboratorsWithFilter() throws IOException {
GHOrganization org = gitHub.getOrganization(GITHUB_API_TEST_ORG);

List<GHUser> admins = org.listOutsideCollaboratorsWithFilter("all").toList();

assertThat(admins, notNullValue());
// In case more are added in the future
assertThat(admins.size(), greaterThanOrEqualTo(12));
assertThat(admins.stream().map(GHUser::getLogin).collect(Collectors.toList()),
hasItems("alexanderrtaylor",
"asthinasthi",
"bitwiseman",
"farmdawgnation",
"halkeye",
"jberglund-BSFT",
"kohsuke",
"kohsuke2",
"martinvanzijl",
"PauloMigAlmeida",
"Sage-Pierce",
"timja"));
}

/**
* Test create team with repo access.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"login": "hub4j-test-org",
"id": 7544739,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
"url": "https://api.github.com/orgs/hub4j-test-org",
"repos_url": "https://api.github.com/orgs/hub4j-test-org/repos",
"events_url": "https://api.github.com/orgs/hub4j-test-org/events",
"hooks_url": "https://api.github.com/orgs/hub4j-test-org/hooks",
"issues_url": "https://api.github.com/orgs/hub4j-test-org/issues",
"members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}",
"public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}",
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
"description": null,
"is_verified": false,
"has_organization_projects": true,
"has_repository_projects": true,
"public_repos": 11,
"public_gists": 0,
"followers": 0,
"following": 0,
"html_url": "https://github.com/hub4j-test-org",
"created_at": "2014-05-10T19:39:11Z",
"updated_at": "2015-04-20T00:42:30Z",
"type": "Organization",
"total_private_repos": 0,
"owned_private_repos": 0,
"private_gists": 0,
"disk_usage": 147,
"collaborators": 0,
"billing_email": "kk@kohsuke.org",
"default_repository_permission": "none",
"members_can_create_repositories": false,
"two_factor_requirement_enabled": false,
"plan": {
"name": "free",
"space": 976562499,
"private_repos": 0,
"filled_seats": 12,
"seats": 0
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
[
{
"login": "alexanderrtaylor",
"id": 852179,
"node_id": "MDQ6VXNlcjg1MjE3OQ==",
"avatar_url": "https://avatars0.githubusercontent.com/u/852179?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/alexanderrtaylor",
"html_url": "https://github.com/alexanderrtaylor",
"followers_url": "https://api.github.com/users/alexanderrtaylor/followers",
"following_url": "https://api.github.com/users/alexanderrtaylor/following{/other_user}",
"gists_url": "https://api.github.com/users/alexanderrtaylor/gists{/gist_id}",
"starred_url": "https://api.github.com/users/alexanderrtaylor/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/alexanderrtaylor/subscriptions",
"organizations_url": "https://api.github.com/users/alexanderrtaylor/orgs",
"repos_url": "https://api.github.com/users/alexanderrtaylor/repos",
"events_url": "https://api.github.com/users/alexanderrtaylor/events{/privacy}",
"received_events_url": "https://api.github.com/users/alexanderrtaylor/received_events",
"type": "User",
"site_admin": false
},
{
"login": "asthinasthi",
"id": 4577101,
"node_id": "MDQ6VXNlcjQ1NzcxMDE=",
"avatar_url": "https://avatars1.githubusercontent.com/u/4577101?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/asthinasthi",
"html_url": "https://github.com/asthinasthi",
"followers_url": "https://api.github.com/users/asthinasthi/followers",
"following_url": "https://api.github.com/users/asthinasthi/following{/other_user}",
"gists_url": "https://api.github.com/users/asthinasthi/gists{/gist_id}",
"starred_url": "https://api.github.com/users/asthinasthi/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/asthinasthi/subscriptions",
"organizations_url": "https://api.github.com/users/asthinasthi/orgs",
"repos_url": "https://api.github.com/users/asthinasthi/repos",
"events_url": "https://api.github.com/users/asthinasthi/events{/privacy}",
"received_events_url": "https://api.github.com/users/asthinasthi/received_events",
"type": "User",
"site_admin": false
},
{
"login": "bitwiseman",
"id": 1958953,
"node_id": "MDQ6VXNlcjE5NTg5NTM=",
"avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/bitwiseman",
"html_url": "https://github.com/bitwiseman",
"followers_url": "https://api.github.com/users/bitwiseman/followers",
"following_url": "https://api.github.com/users/bitwiseman/following{/other_user}",
"gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}",
"starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions",
"organizations_url": "https://api.github.com/users/bitwiseman/orgs",
"repos_url": "https://api.github.com/users/bitwiseman/repos",
"events_url": "https://api.github.com/users/bitwiseman/events{/privacy}",
"received_events_url": "https://api.github.com/users/bitwiseman/received_events",
"type": "User",
"site_admin": false
},
{
"login": "farmdawgnation",
"id": 620189,
"node_id": "MDQ6VXNlcjYyMDE4OQ==",
"avatar_url": "https://avatars2.githubusercontent.com/u/620189?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/farmdawgnation",
"html_url": "https://github.com/farmdawgnation",
"followers_url": "https://api.github.com/users/farmdawgnation/followers",
"following_url": "https://api.github.com/users/farmdawgnation/following{/other_user}",
"gists_url": "https://api.github.com/users/farmdawgnation/gists{/gist_id}",
"starred_url": "https://api.github.com/users/farmdawgnation/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/farmdawgnation/subscriptions",
"organizations_url": "https://api.github.com/users/farmdawgnation/orgs",
"repos_url": "https://api.github.com/users/farmdawgnation/repos",
"events_url": "https://api.github.com/users/farmdawgnation/events{/privacy}",
"received_events_url": "https://api.github.com/users/farmdawgnation/received_events",
"type": "User",
"site_admin": false
},
{
"login": "halkeye",
"id": 110087,
"node_id": "MDQ6VXNlcjExMDA4Nw==",
"avatar_url": "https://avatars3.githubusercontent.com/u/110087?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/halkeye",
"html_url": "https://github.com/halkeye",
"followers_url": "https://api.github.com/users/halkeye/followers",
"following_url": "https://api.github.com/users/halkeye/following{/other_user}",
"gists_url": "https://api.github.com/users/halkeye/gists{/gist_id}",
"starred_url": "https://api.github.com/users/halkeye/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/halkeye/subscriptions",
"organizations_url": "https://api.github.com/users/halkeye/orgs",
"repos_url": "https://api.github.com/users/halkeye/repos",
"events_url": "https://api.github.com/users/halkeye/events{/privacy}",
"received_events_url": "https://api.github.com/users/halkeye/received_events",
"type": "User",
"site_admin": false
},
{
"login": "jberglund-BSFT",
"id": 19560713,
"node_id": "MDQ6VXNlcjE5NTYwNzEz",
"avatar_url": "https://avatars3.githubusercontent.com/u/19560713?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/jberglund-BSFT",
"html_url": "https://github.com/jberglund-BSFT",
"followers_url": "https://api.github.com/users/jberglund-BSFT/followers",
"following_url": "https://api.github.com/users/jberglund-BSFT/following{/other_user}",
"gists_url": "https://api.github.com/users/jberglund-BSFT/gists{/gist_id}",
"starred_url": "https://api.github.com/users/jberglund-BSFT/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/jberglund-BSFT/subscriptions",
"organizations_url": "https://api.github.com/users/jberglund-BSFT/orgs",
"repos_url": "https://api.github.com/users/jberglund-BSFT/repos",
"events_url": "https://api.github.com/users/jberglund-BSFT/events{/privacy}",
"received_events_url": "https://api.github.com/users/jberglund-BSFT/received_events",
"type": "User",
"site_admin": false
},
{
"login": "kohsuke",
"id": 50003,
"node_id": "MDQ6VXNlcjUwMDAz",
"avatar_url": "https://avatars1.githubusercontent.com/u/50003?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/kohsuke",
"html_url": "https://github.com/kohsuke",
"followers_url": "https://api.github.com/users/kohsuke/followers",
"following_url": "https://api.github.com/users/kohsuke/following{/other_user}",
"gists_url": "https://api.github.com/users/kohsuke/gists{/gist_id}",
"starred_url": "https://api.github.com/users/kohsuke/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/kohsuke/subscriptions",
"organizations_url": "https://api.github.com/users/kohsuke/orgs",
"repos_url": "https://api.github.com/users/kohsuke/repos",
"events_url": "https://api.github.com/users/kohsuke/events{/privacy}",
"received_events_url": "https://api.github.com/users/kohsuke/received_events",
"type": "User",
"site_admin": false
},
{
"login": "kohsuke2",
"id": 1329242,
"node_id": "MDQ6VXNlcjEzMjkyNDI=",
"avatar_url": "https://avatars2.githubusercontent.com/u/1329242?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/kohsuke2",
"html_url": "https://github.com/kohsuke2",
"followers_url": "https://api.github.com/users/kohsuke2/followers",
"following_url": "https://api.github.com/users/kohsuke2/following{/other_user}",
"gists_url": "https://api.github.com/users/kohsuke2/gists{/gist_id}",
"starred_url": "https://api.github.com/users/kohsuke2/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/kohsuke2/subscriptions",
"organizations_url": "https://api.github.com/users/kohsuke2/orgs",
"repos_url": "https://api.github.com/users/kohsuke2/repos",
"events_url": "https://api.github.com/users/kohsuke2/events{/privacy}",
"received_events_url": "https://api.github.com/users/kohsuke2/received_events",
"type": "User",
"site_admin": false
},
{
"login": "martinvanzijl",
"id": 24422213,
"node_id": "MDQ6VXNlcjI0NDIyMjEz",
"avatar_url": "https://avatars0.githubusercontent.com/u/24422213?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/martinvanzijl",
"html_url": "https://github.com/martinvanzijl",
"followers_url": "https://api.github.com/users/martinvanzijl/followers",
"following_url": "https://api.github.com/users/martinvanzijl/following{/other_user}",
"gists_url": "https://api.github.com/users/martinvanzijl/gists{/gist_id}",
"starred_url": "https://api.github.com/users/martinvanzijl/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/martinvanzijl/subscriptions",
"organizations_url": "https://api.github.com/users/martinvanzijl/orgs",
"repos_url": "https://api.github.com/users/martinvanzijl/repos",
"events_url": "https://api.github.com/users/martinvanzijl/events{/privacy}",
"received_events_url": "https://api.github.com/users/martinvanzijl/received_events",
"type": "User",
"site_admin": false
},
{
"login": "PauloMigAlmeida",
"id": 1011868,
"node_id": "MDQ6VXNlcjEwMTE4Njg=",
"avatar_url": "https://avatars1.githubusercontent.com/u/1011868?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/PauloMigAlmeida",
"html_url": "https://github.com/PauloMigAlmeida",
"followers_url": "https://api.github.com/users/PauloMigAlmeida/followers",
"following_url": "https://api.github.com/users/PauloMigAlmeida/following{/other_user}",
"gists_url": "https://api.github.com/users/PauloMigAlmeida/gists{/gist_id}",
"starred_url": "https://api.github.com/users/PauloMigAlmeida/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/PauloMigAlmeida/subscriptions",
"organizations_url": "https://api.github.com/users/PauloMigAlmeida/orgs",
"repos_url": "https://api.github.com/users/PauloMigAlmeida/repos",
"events_url": "https://api.github.com/users/PauloMigAlmeida/events{/privacy}",
"received_events_url": "https://api.github.com/users/PauloMigAlmeida/received_events",
"type": "User",
"site_admin": false
},
{
"login": "Sage-Pierce",
"id": 5396306,
"node_id": "MDQ6VXNlcjUzOTYzMDY=",
"avatar_url": "https://avatars3.githubusercontent.com/u/5396306?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/Sage-Pierce",
"html_url": "https://github.com/Sage-Pierce",
"followers_url": "https://api.github.com/users/Sage-Pierce/followers",
"following_url": "https://api.github.com/users/Sage-Pierce/following{/other_user}",
"gists_url": "https://api.github.com/users/Sage-Pierce/gists{/gist_id}",
"starred_url": "https://api.github.com/users/Sage-Pierce/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/Sage-Pierce/subscriptions",
"organizations_url": "https://api.github.com/users/Sage-Pierce/orgs",
"repos_url": "https://api.github.com/users/Sage-Pierce/repos",
"events_url": "https://api.github.com/users/Sage-Pierce/events{/privacy}",
"received_events_url": "https://api.github.com/users/Sage-Pierce/received_events",
"type": "User",
"site_admin": false
},
{
"login": "timja",
"id": 21194782,
"node_id": "MDQ6VXNlcjIxMTk0Nzgy",
"avatar_url": "https://avatars3.githubusercontent.com/u/21194782?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/timja",
"html_url": "https://github.com/timja",
"followers_url": "https://api.github.com/users/timja/followers",
"following_url": "https://api.github.com/users/timja/following{/other_user}",
"gists_url": "https://api.github.com/users/timja/gists{/gist_id}",
"starred_url": "https://api.github.com/users/timja/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/timja/subscriptions",
"organizations_url": "https://api.github.com/users/timja/orgs",
"repos_url": "https://api.github.com/users/timja/repos",
"events_url": "https://api.github.com/users/timja/events{/privacy}",
"received_events_url": "https://api.github.com/users/timja/received_events",
"type": "User",
"site_admin": false
}
]