Skip to content

Commit 64aae75

Browse files
committed
Allow updating privacy status
1 parent 69d2160 commit 64aae75

16 files changed

+738
-1
lines changed

src/main/java/org/kohsuke/github/GHTeam.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public String getDescription() {
106106

107107
/**
108108
* Gets the privacy state.
109-
*
109+
*
110110
* @return the privacy state.
111111
*/
112112
public Privacy getPrivacy() {
@@ -125,6 +125,18 @@ public void setDescription(String description) throws IOException {
125125
root.createRequest().method("PATCH").with("description", description).withUrlPath(api("")).send();
126126
}
127127

128+
/**
129+
* Sets privacy.
130+
*
131+
* @param privacy
132+
* the privacy
133+
* @throws IOException
134+
* the io exception
135+
*/
136+
public void setPrivacy(Privacy privacy) throws IOException {
137+
root.createRequest().method("PATCH").with("privacy", privacy).withUrlPath(api("")).send();
138+
}
139+
128140
/**
129141
* Gets id.
130142
*

src/test/java/org/kohsuke/github/GHTeamTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.kohsuke.github;
22

33
import org.junit.Test;
4+
import org.kohsuke.github.GHTeam.Privacy;
45

56
import java.io.IOException;
67

@@ -30,4 +31,27 @@ public void testSetDescription() throws IOException {
3031
assertEquals(description, team.getDescription());
3132
}
3233

34+
@Test
35+
public void testSetPrivacy() throws IOException {
36+
String teamSlug = "dummy-team";
37+
Privacy privacy = Privacy.CLOSED;
38+
39+
// Set the privacy.
40+
GHTeam team = gitHub.getOrganization(GITHUB_API_TEST_ORG).getTeamBySlug(teamSlug);
41+
team.setPrivacy(privacy);
42+
43+
// Check that it was set correctly.
44+
team = gitHub.getOrganization(GITHUB_API_TEST_ORG).getTeamBySlug(teamSlug);
45+
assertEquals(privacy, team.getPrivacy());
46+
47+
privacy = Privacy.SECRET;
48+
49+
// Set the privacy.
50+
team.setPrivacy(privacy);
51+
52+
// Check that it was set correctly.
53+
team = gitHub.getOrganization(GITHUB_API_TEST_ORG).getTeamBySlug(teamSlug);
54+
assertEquals(privacy, team.getPrivacy());
55+
}
56+
3357
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"login": "github-api-test-org",
3+
"id": 7544739,
4+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=",
5+
"url": "https://api.github.com/orgs/github-api-test-org",
6+
"repos_url": "https://api.github.com/orgs/github-api-test-org/repos",
7+
"events_url": "https://api.github.com/orgs/github-api-test-org/events",
8+
"hooks_url": "https://api.github.com/orgs/github-api-test-org/hooks",
9+
"issues_url": "https://api.github.com/orgs/github-api-test-org/issues",
10+
"members_url": "https://api.github.com/orgs/github-api-test-org/members{/member}",
11+
"public_members_url": "https://api.github.com/orgs/github-api-test-org/public_members{/member}",
12+
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4",
13+
"description": null,
14+
"is_verified": false,
15+
"has_organization_projects": true,
16+
"has_repository_projects": true,
17+
"public_repos": 9,
18+
"public_gists": 0,
19+
"followers": 0,
20+
"following": 0,
21+
"html_url": "https://github.com/github-api-test-org",
22+
"created_at": "2014-05-10T19:39:11Z",
23+
"updated_at": "2015-04-20T00:42:30Z",
24+
"type": "Organization",
25+
"total_private_repos": 0,
26+
"owned_private_repos": 0,
27+
"private_gists": 0,
28+
"disk_usage": 132,
29+
"collaborators": 0,
30+
"billing_email": "[email protected]",
31+
"default_repository_permission": "none",
32+
"members_can_create_repositories": false,
33+
"two_factor_requirement_enabled": false,
34+
"plan": {
35+
"name": "free",
36+
"space": 976562499,
37+
"private_repos": 0,
38+
"filled_seats": 3,
39+
"seats": 0
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[
2+
{
3+
"name": "Core Developers",
4+
"id": 3617900,
5+
"node_id": "MDQ6VGVhbTM2MTc5MDA=",
6+
"slug": "core-developers",
7+
"description": "",
8+
"privacy": "closed",
9+
"url": "https://api.github.com/organizations/49127317/team/3617900",
10+
"html_url": "https://github.com/orgs/github-api-test-org/teams/core-developers",
11+
"members_url": "https://api.github.com/organizations/49127317/team/3617900/members{/member}",
12+
"repositories_url": "https://api.github.com/organizations/49127317/team/3617900/repos",
13+
"permission": "pull",
14+
"parent": null
15+
},
16+
{
17+
"name": "dummy-team",
18+
"id": 3618279,
19+
"node_id": "MDQ6VGVhbTM2MTgyNzk=",
20+
"slug": "dummy-team",
21+
"description": "",
22+
"privacy": "secret",
23+
"url": "https://api.github.com/organizations/49127317/team/3618279",
24+
"html_url": "https://github.com/orgs/github-api-test-org/teams/dummy-team",
25+
"members_url": "https://api.github.com/organizations/49127317/team/3618279/members{/member}",
26+
"repositories_url": "https://api.github.com/organizations/49127317/team/3618279/repos",
27+
"permission": "pull",
28+
"parent": null
29+
},
30+
{
31+
"name": "slack-plugin Developers",
32+
"id": 3618268,
33+
"node_id": "MDQ6VGVhbTM2MTgyNjg=",
34+
"slug": "slack-plugin-developers",
35+
"description": null,
36+
"privacy": "closed",
37+
"url": "https://api.github.com/organizations/49127317/team/3618268",
38+
"html_url": "https://github.com/orgs/github-api-test-org/teams/slack-plugin-developers",
39+
"members_url": "https://api.github.com/organizations/49127317/team/3618268/members{/member}",
40+
"repositories_url": "https://api.github.com/organizations/49127317/team/3618268/repos",
41+
"permission": "pull",
42+
"parent": null
43+
},
44+
{
45+
"name": "bitwiseman-team",
46+
"id": 3617890,
47+
"node_id": "MDQ6VGVhbTM2MTc4OTA=",
48+
"slug": "bitwiseman-team",
49+
"description": "",
50+
"privacy": "secret",
51+
"url": "https://api.github.com/organizations/49127317/team/3617890",
52+
"html_url": "https://github.com/orgs/github-api-test-org/teams/bitwiseman-team",
53+
"members_url": "https://api.github.com/organizations/49127317/team/3617890/members{/member}",
54+
"repositories_url": "https://api.github.com/organizations/49127317/team/3617890/repos",
55+
"permission": "pull",
56+
"parent": null
57+
}
58+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[
2+
{
3+
"name": "Core Developers",
4+
"id": 3617900,
5+
"node_id": "MDQ6VGVhbTM2MTc5MDA=",
6+
"slug": "core-developers",
7+
"description": "",
8+
"privacy": "closed",
9+
"url": "https://api.github.com/organizations/49127317/team/3617900",
10+
"html_url": "https://github.com/orgs/github-api-test-org/teams/core-developers",
11+
"members_url": "https://api.github.com/organizations/49127317/team/3617900/members{/member}",
12+
"repositories_url": "https://api.github.com/organizations/49127317/team/3617900/repos",
13+
"permission": "pull",
14+
"parent": null
15+
},
16+
{
17+
"name": "dummy-team",
18+
"id": 3618279,
19+
"node_id": "MDQ6VGVhbTM2MTgyNzk=",
20+
"slug": "dummy-team",
21+
"description": "",
22+
"privacy": "closed",
23+
"url": "https://api.github.com/organizations/49127317/team/3618279",
24+
"html_url": "https://github.com/orgs/github-api-test-org/teams/dummy-team",
25+
"members_url": "https://api.github.com/organizations/49127317/team/3618279/members{/member}",
26+
"repositories_url": "https://api.github.com/organizations/49127317/team/3618279/repos",
27+
"permission": "pull",
28+
"parent": null
29+
},
30+
{
31+
"name": "slack-plugin Developers",
32+
"id": 3618268,
33+
"node_id": "MDQ6VGVhbTM2MTgyNjg=",
34+
"slug": "slack-plugin-developers",
35+
"description": null,
36+
"privacy": "closed",
37+
"url": "https://api.github.com/organizations/49127317/team/3618268",
38+
"html_url": "https://github.com/orgs/github-api-test-org/teams/slack-plugin-developers",
39+
"members_url": "https://api.github.com/organizations/49127317/team/3618268/members{/member}",
40+
"repositories_url": "https://api.github.com/organizations/49127317/team/3618268/repos",
41+
"permission": "pull",
42+
"parent": null
43+
},
44+
{
45+
"name": "bitwiseman-team",
46+
"id": 3617890,
47+
"node_id": "MDQ6VGVhbTM2MTc4OTA=",
48+
"slug": "bitwiseman-team",
49+
"description": "",
50+
"privacy": "secret",
51+
"url": "https://api.github.com/organizations/49127317/team/3617890",
52+
"html_url": "https://github.com/orgs/github-api-test-org/teams/bitwiseman-team",
53+
"members_url": "https://api.github.com/organizations/49127317/team/3617890/members{/member}",
54+
"repositories_url": "https://api.github.com/organizations/49127317/team/3617890/repos",
55+
"permission": "pull",
56+
"parent": null
57+
}
58+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[
2+
{
3+
"name": "Core Developers",
4+
"id": 3617900,
5+
"node_id": "MDQ6VGVhbTM2MTc5MDA=",
6+
"slug": "core-developers",
7+
"description": "",
8+
"privacy": "closed",
9+
"url": "https://api.github.com/organizations/49127317/team/3617900",
10+
"html_url": "https://github.com/orgs/github-api-test-org/teams/core-developers",
11+
"members_url": "https://api.github.com/organizations/49127317/team/3617900/members{/member}",
12+
"repositories_url": "https://api.github.com/organizations/49127317/team/3617900/repos",
13+
"permission": "pull",
14+
"parent": null
15+
},
16+
{
17+
"name": "dummy-team",
18+
"id": 3618279,
19+
"node_id": "MDQ6VGVhbTM2MTgyNzk=",
20+
"slug": "dummy-team",
21+
"description": "",
22+
"privacy": "secret",
23+
"url": "https://api.github.com/organizations/49127317/team/3618279",
24+
"html_url": "https://github.com/orgs/github-api-test-org/teams/dummy-team",
25+
"members_url": "https://api.github.com/organizations/49127317/team/3618279/members{/member}",
26+
"repositories_url": "https://api.github.com/organizations/49127317/team/3618279/repos",
27+
"permission": "pull",
28+
"parent": null
29+
},
30+
{
31+
"name": "slack-plugin Developers",
32+
"id": 3618268,
33+
"node_id": "MDQ6VGVhbTM2MTgyNjg=",
34+
"slug": "slack-plugin-developers",
35+
"description": null,
36+
"privacy": "closed",
37+
"url": "https://api.github.com/organizations/49127317/team/3618268",
38+
"html_url": "https://github.com/orgs/github-api-test-org/teams/slack-plugin-developers",
39+
"members_url": "https://api.github.com/organizations/49127317/team/3618268/members{/member}",
40+
"repositories_url": "https://api.github.com/organizations/49127317/team/3618268/repos",
41+
"permission": "pull",
42+
"parent": null
43+
},
44+
{
45+
"name": "bitwiseman-team",
46+
"id": 3617890,
47+
"node_id": "MDQ6VGVhbTM2MTc4OTA=",
48+
"slug": "bitwiseman-team",
49+
"description": "",
50+
"privacy": "secret",
51+
"url": "https://api.github.com/organizations/49127317/team/3617890",
52+
"html_url": "https://github.com/orgs/github-api-test-org/teams/bitwiseman-team",
53+
"members_url": "https://api.github.com/organizations/49127317/team/3617890/members{/member}",
54+
"repositories_url": "https://api.github.com/organizations/49127317/team/3617890/repos",
55+
"permission": "pull",
56+
"parent": null
57+
}
58+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "dummy-team",
3+
"id": 3618279,
4+
"node_id": "MDQ6VGVhbTM2MTgyNzk=",
5+
"slug": "dummy-team",
6+
"description": "",
7+
"privacy": "closed",
8+
"url": "https://api.github.com/organizations/49127317/team/3618279",
9+
"html_url": "https://github.com/orgs/github-api-test-org/teams/dummy-team",
10+
"members_url": "https://api.github.com/organizations/49127317/team/3618279/members{/member}",
11+
"repositories_url": "https://api.github.com/organizations/49127317/team/3618279/repos",
12+
"permission": "pull",
13+
"parent": null,
14+
"created_at": "2020-01-26T10:31:35Z",
15+
"updated_at": "2020-01-26T10:43:13Z",
16+
"members_count": 1,
17+
"repos_count": 0,
18+
"organization": {
19+
"login": "github-api-test-org",
20+
"id": 49127317,
21+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjQ5MTI3MzE3",
22+
"url": "https://api.github.com/orgs/github-api-test-org",
23+
"repos_url": "https://api.github.com/orgs/github-api-test-org/repos",
24+
"events_url": "https://api.github.com/orgs/github-api-test-org/events",
25+
"hooks_url": "https://api.github.com/orgs/github-api-test-org/hooks",
26+
"issues_url": "https://api.github.com/orgs/github-api-test-org/issues",
27+
"members_url": "https://api.github.com/orgs/github-api-test-org/members{/member}",
28+
"public_members_url": "https://api.github.com/orgs/github-api-test-org/public_members{/member}",
29+
"avatar_url": "https://avatars3.githubusercontent.com/u/49127317?v=4",
30+
"description": null,
31+
"is_verified": false,
32+
"has_organization_projects": true,
33+
"has_repository_projects": true,
34+
"public_repos": 5,
35+
"public_gists": 0,
36+
"followers": 0,
37+
"following": 0,
38+
"html_url": "https://github.com/github-api-test-org",
39+
"created_at": "2019-03-31T17:42:10Z",
40+
"updated_at": "2019-10-07T20:06:18Z",
41+
"type": "Organization"
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "dummy-team",
3+
"id": 3618279,
4+
"node_id": "MDQ6VGVhbTM2MTgyNzk=",
5+
"slug": "dummy-team",
6+
"description": "",
7+
"privacy": "secret",
8+
"url": "https://api.github.com/organizations/49127317/team/3618279",
9+
"html_url": "https://github.com/orgs/github-api-test-org/teams/dummy-team",
10+
"members_url": "https://api.github.com/organizations/49127317/team/3618279/members{/member}",
11+
"repositories_url": "https://api.github.com/organizations/49127317/team/3618279/repos",
12+
"permission": "pull",
13+
"parent": null,
14+
"created_at": "2020-01-26T10:31:35Z",
15+
"updated_at": "2020-01-26T10:43:14Z",
16+
"members_count": 1,
17+
"repos_count": 0,
18+
"organization": {
19+
"login": "github-api-test-org",
20+
"id": 49127317,
21+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjQ5MTI3MzE3",
22+
"url": "https://api.github.com/orgs/github-api-test-org",
23+
"repos_url": "https://api.github.com/orgs/github-api-test-org/repos",
24+
"events_url": "https://api.github.com/orgs/github-api-test-org/events",
25+
"hooks_url": "https://api.github.com/orgs/github-api-test-org/hooks",
26+
"issues_url": "https://api.github.com/orgs/github-api-test-org/issues",
27+
"members_url": "https://api.github.com/orgs/github-api-test-org/members{/member}",
28+
"public_members_url": "https://api.github.com/orgs/github-api-test-org/public_members{/member}",
29+
"avatar_url": "https://avatars3.githubusercontent.com/u/49127317?v=4",
30+
"description": null,
31+
"is_verified": false,
32+
"has_organization_projects": true,
33+
"has_repository_projects": true,
34+
"public_repos": 5,
35+
"public_gists": 0,
36+
"followers": 0,
37+
"following": 0,
38+
"html_url": "https://github.com/github-api-test-org",
39+
"created_at": "2019-03-31T17:42:10Z",
40+
"updated_at": "2019-10-07T20:06:18Z",
41+
"type": "Organization"
42+
}
43+
}

0 commit comments

Comments
 (0)