-
Notifications
You must be signed in to change notification settings - Fork 715
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 support for all create team parameters #683
Changes from 3 commits
69d2160
64aae75
32754ff
4cc90b4
0f32783
963478e
7e600c4
e008021
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 |
---|---|---|
|
@@ -12,12 +12,22 @@ | |
* @author Kohsuke Kawaguchi | ||
*/ | ||
public class GHTeam implements Refreshable { | ||
private String name, permission, slug, description; | ||
private String name; | ||
private String permission; | ||
private String slug; | ||
private String description; | ||
private Privacy privacy; | ||
|
||
private int id; | ||
private GHOrganization organization; // populated by GET /user/teams where Teams+Orgs are returned together | ||
|
||
protected /* final */ GitHub root; | ||
|
||
public enum Privacy { | ||
SECRET, // only visible to organization owners and members of this team. | ||
CLOSED // visible to all members of this organization. | ||
} | ||
|
||
/** | ||
* Member's role in a team | ||
*/ | ||
|
@@ -94,6 +104,15 @@ public String getDescription() { | |
return description; | ||
} | ||
|
||
/** | ||
* Gets the privacy state. | ||
* | ||
* @return the privacy state. | ||
*/ | ||
public Privacy getPrivacy() { | ||
return privacy; | ||
} | ||
|
||
/** | ||
* Sets description. | ||
* | ||
|
@@ -106,6 +125,18 @@ public void setDescription(String description) throws IOException { | |
root.createRequest().method("PATCH").with("description", description).withUrlPath(api("")).send(); | ||
} | ||
|
||
/** | ||
* Updates the team's privacy setting. | ||
* | ||
* @param privacy | ||
* the privacy | ||
* @throws IOException | ||
* the io exception | ||
*/ | ||
public void updatePrivacy(Privacy privacy) throws IOException { | ||
root.createRequest().method("PATCH").with("privacy", privacy).withUrlPath(api("")).send(); | ||
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. 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. agree, changed to update. 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. Glad you agree. But leave this for now. I don't want to do this unevenly (some update some set). 😄 |
||
} | ||
|
||
/** | ||
* Gets id. | ||
* | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,94 @@ | ||||||
package org.kohsuke.github; | ||||||
|
||||||
import java.io.IOException; | ||||||
import java.util.List; | ||||||
|
||||||
/** | ||||||
* Creates a team. | ||||||
* | ||||||
* https://developer.github.com/v3/teams/#parameters | ||||||
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.
Suggested change
|
||||||
*/ | ||||||
public class GHTeamBuilder { | ||||||
|
||||||
private final GitHub root; | ||||||
protected final Requester builder; | ||||||
private final String orgName; | ||||||
|
||||||
public GHTeamBuilder(GitHub root, String orgName, String name) { | ||||||
this.root = root; | ||||||
this.orgName = orgName; | ||||||
this.builder = root.createRequest(); | ||||||
this.builder.with("name", name); | ||||||
} | ||||||
|
||||||
/** | ||||||
* Description for this team. | ||||||
* | ||||||
* @param description | ||||||
* description of team | ||||||
* @return a builder to continue with building | ||||||
*/ | ||||||
public GHTeamBuilder description(String description) { | ||||||
this.builder.with("description", description); | ||||||
return this; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Maintainers for this team. | ||||||
* | ||||||
* @param maintainers | ||||||
* maintainers of team | ||||||
* @return a builder to continue with building | ||||||
*/ | ||||||
public GHTeamBuilder maintainers(List<String> maintainers) { | ||||||
timja marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
this.builder.with("maintainers", maintainers); | ||||||
return this; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Repo names to add this team to. | ||||||
* | ||||||
* @param repoNames | ||||||
* repoNames to add team to | ||||||
* @return a builder to continue with building | ||||||
*/ | ||||||
public GHTeamBuilder repoNames(List<String> repoNames) { | ||||||
timja marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
this.builder.with("repo_names", repoNames); | ||||||
return this; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Description for this team | ||||||
* | ||||||
* @param privacy | ||||||
* privacy of team | ||||||
* @return a builder to continue with building | ||||||
*/ | ||||||
public GHTeamBuilder privacy(GHTeam.Privacy privacy) { | ||||||
this.builder.with("privacy", privacy); | ||||||
return this; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Parent team id for this team | ||||||
* | ||||||
* @param parentTeamId | ||||||
* parentTeamId of team | ||||||
* @return a builder to continue with building | ||||||
*/ | ||||||
public GHTeamBuilder parentTeamId(int parentTeamId) { | ||||||
this.builder.with("parent_team_id", parentTeamId); | ||||||
return this; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Creates a team with all the parameters. | ||||||
* | ||||||
* @return the gh team | ||||||
* @throws IOException | ||||||
* if team cannot be created | ||||||
*/ | ||||||
public GHTeam create() throws IOException { | ||||||
return builder.method("POST").withUrlPath("/orgs/" + orgName + "/teams").fetch(GHTeam.class).wrapUp(root); | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"login": "github-api-test-org", | ||
"id": 7544739, | ||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", | ||
"url": "https://api.github.com/orgs/github-api-test-org", | ||
"repos_url": "https://api.github.com/orgs/github-api-test-org/repos", | ||
"events_url": "https://api.github.com/orgs/github-api-test-org/events", | ||
"hooks_url": "https://api.github.com/orgs/github-api-test-org/hooks", | ||
"issues_url": "https://api.github.com/orgs/github-api-test-org/issues", | ||
"members_url": "https://api.github.com/orgs/github-api-test-org/members{/member}", | ||
"public_members_url": "https://api.github.com/orgs/github-api-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": 10, | ||
"public_gists": 0, | ||
"followers": 0, | ||
"following": 0, | ||
"html_url": "https://github.com/github-api-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": 132, | ||
"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": 7, | ||
"seats": 0 | ||
} | ||
} |
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.