Skip to content

Commit 32754ff

Browse files
committed
Cleanup based on review
1 parent 64aae75 commit 32754ff

File tree

4 files changed

+26
-20
lines changed

4 files changed

+26
-20
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ public enum Permission {
386386
* @throws IOException
387387
* the io exception
388388
* @deprecated https://developer.github.com/v3/teams/#create-team deprecates permission field use
389-
* {@link #createTeam(String, Collection)}
389+
* {@link #createTeam(String)}
390390
*/
391391
@Deprecated
392392
public GHTeam createTeam(String name, Permission p, Collection<GHRepository> repositories) throws IOException {
@@ -412,7 +412,7 @@ public GHTeam createTeam(String name, Permission p, Collection<GHRepository> rep
412412
* @throws IOException
413413
* the io exception
414414
* @deprecated https://developer.github.com/v3/teams/#create-team deprecates permission field use
415-
* {@link #createTeam(String, GHRepository...)}
415+
* {@link #createTeam(String)}
416416
*/
417417
@Deprecated
418418
public GHTeam createTeam(String name, Permission p, GHRepository... repositories) throws IOException {
@@ -429,7 +429,9 @@ public GHTeam createTeam(String name, Permission p, GHRepository... repositories
429429
* @return the gh team
430430
* @throws IOException
431431
* the io exception
432+
* @deprecated Use {@link #createTeam(String)} that uses a builder pattern to let you control every aspect.
432433
*/
434+
@Deprecated
433435
public GHTeam createTeam(String name, Collection<GHRepository> repositories) throws IOException {
434436
Requester post = root.createRequest().method("POST").with("name", name);
435437
List<String> repo_names = new ArrayList<String>();
@@ -450,7 +452,9 @@ public GHTeam createTeam(String name, Collection<GHRepository> repositories) thr
450452
* @return the gh team
451453
* @throws IOException
452454
* the io exception
455+
* @deprecated Use {@link #createTeam(String)} that uses a builder pattern to let you control every aspect.
453456
*/
457+
@Deprecated
454458
public GHTeam createTeam(String name, GHRepository... repositories) throws IOException {
455459
return createTeam(name, Arrays.asList(repositories));
456460
}
@@ -459,15 +463,15 @@ public GHTeam createTeam(String name, GHRepository... repositories) throws IOExc
459463
* Starts a builder that creates a new team.
460464
*
461465
* <p>
462-
* You use the returned builder to set various properties, then call {@link GHCreateTeamBuilder#create()} to finally
466+
* You use the returned builder to set various properties, then call {@link GHTeamBuilder#create()} to finally
463467
* create a team.
464468
*
465469
* @param name
466470
* the name
467471
* @return the gh create repository builder
468472
*/
469-
public GHCreateTeamBuilder createTeam(String name) {
470-
return new GHCreateTeamBuilder(root, "/orgs/" + login + "/teams", name);
473+
public GHTeamBuilder createTeam(String name) {
474+
return new GHTeamBuilder(root, login, name);
471475
}
472476

473477
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ public void setDescription(String description) throws IOException {
126126
}
127127

128128
/**
129-
* Sets privacy.
129+
* Updates the team's privacy setting.
130130
*
131131
* @param privacy
132132
* the privacy
133133
* @throws IOException
134134
* the io exception
135135
*/
136-
public void setPrivacy(Privacy privacy) throws IOException {
136+
public void updatePrivacy(Privacy privacy) throws IOException {
137137
root.createRequest().method("PATCH").with("privacy", privacy).withUrlPath(api("")).send();
138138
}
139139

src/main/java/org/kohsuke/github/GHCreateTeamBuilder.java renamed to src/main/java/org/kohsuke/github/GHTeamBuilder.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@
55

66
/**
77
* Creates a team.
8+
*
9+
* https://developer.github.com/v3/teams/#parameters
810
*/
9-
public class GHCreateTeamBuilder {
11+
public class GHTeamBuilder {
1012

1113
private final GitHub root;
1214
protected final Requester builder;
13-
private final String apiUrlTail;
15+
private final String orgName;
1416

15-
public GHCreateTeamBuilder(GitHub root, String apiUrlTail, String name) {
17+
public GHTeamBuilder(GitHub root, String orgName, String name) {
1618
this.root = root;
17-
this.apiUrlTail = apiUrlTail;
19+
this.orgName = orgName;
1820
this.builder = root.createRequest();
1921
this.builder.with("name", name);
2022
}
@@ -26,7 +28,7 @@ public GHCreateTeamBuilder(GitHub root, String apiUrlTail, String name) {
2628
* description of team
2729
* @return a builder to continue with building
2830
*/
29-
public GHCreateTeamBuilder description(String description) {
31+
public GHTeamBuilder description(String description) {
3032
this.builder.with("description", description);
3133
return this;
3234
}
@@ -38,7 +40,7 @@ public GHCreateTeamBuilder description(String description) {
3840
* maintainers of team
3941
* @return a builder to continue with building
4042
*/
41-
public GHCreateTeamBuilder maintainers(List<String> maintainers) {
43+
public GHTeamBuilder maintainers(List<String> maintainers) {
4244
this.builder.with("maintainers", maintainers);
4345
return this;
4446
}
@@ -50,7 +52,7 @@ public GHCreateTeamBuilder maintainers(List<String> maintainers) {
5052
* repoNames to add team to
5153
* @return a builder to continue with building
5254
*/
53-
public GHCreateTeamBuilder repoNames(List<String> repoNames) {
55+
public GHTeamBuilder repoNames(List<String> repoNames) {
5456
this.builder.with("repo_names", repoNames);
5557
return this;
5658
}
@@ -62,7 +64,7 @@ public GHCreateTeamBuilder repoNames(List<String> repoNames) {
6264
* privacy of team
6365
* @return a builder to continue with building
6466
*/
65-
public GHCreateTeamBuilder privacy(GHTeam.Privacy privacy) {
67+
public GHTeamBuilder privacy(GHTeam.Privacy privacy) {
6668
this.builder.with("privacy", privacy);
6769
return this;
6870
}
@@ -74,7 +76,7 @@ public GHCreateTeamBuilder privacy(GHTeam.Privacy privacy) {
7476
* parentTeamId of team
7577
* @return a builder to continue with building
7678
*/
77-
public GHCreateTeamBuilder parentTeamId(int parentTeamId) {
79+
public GHTeamBuilder parentTeamId(int parentTeamId) {
7880
this.builder.with("parent_team_id", parentTeamId);
7981
return this;
8082
}
@@ -87,6 +89,6 @@ public GHCreateTeamBuilder parentTeamId(int parentTeamId) {
8789
* if team cannot be created
8890
*/
8991
public GHTeam create() throws IOException {
90-
return builder.method("POST").withUrlPath(apiUrlTail).fetch(GHTeam.class).wrapUp(root);
92+
return builder.method("POST").withUrlPath("/orgs/" + orgName + "/teams").fetch(GHTeam.class).wrapUp(root);
9193
}
9294
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ public void testSetDescription() throws IOException {
3232
}
3333

3434
@Test
35-
public void testSetPrivacy() throws IOException {
35+
public void testUpdatePrivacy() throws IOException {
3636
String teamSlug = "dummy-team";
3737
Privacy privacy = Privacy.CLOSED;
3838

3939
// Set the privacy.
4040
GHTeam team = gitHub.getOrganization(GITHUB_API_TEST_ORG).getTeamBySlug(teamSlug);
41-
team.setPrivacy(privacy);
41+
team.updatePrivacy(privacy);
4242

4343
// Check that it was set correctly.
4444
team = gitHub.getOrganization(GITHUB_API_TEST_ORG).getTeamBySlug(teamSlug);
@@ -47,7 +47,7 @@ public void testSetPrivacy() throws IOException {
4747
privacy = Privacy.SECRET;
4848

4949
// Set the privacy.
50-
team.setPrivacy(privacy);
50+
team.updatePrivacy(privacy);
5151

5252
// Check that it was set correctly.
5353
team = gitHub.getOrganization(GITHUB_API_TEST_ORG).getTeamBySlug(teamSlug);

0 commit comments

Comments
 (0)