From 76c5506c2c05d49e8a287c5eb07df213f358b1b8 Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Wed, 8 Apr 2026 00:52:39 -0700 Subject: [PATCH 1/2] feat: add missing setter methods to GHTeam Add setName, setNotificationSetting, setPermission, and setParentTeamId methods following the existing setDescription and setPrivacy pattern. Each uses PATCH to the team API endpoint. Fixes #2218 --- src/main/java/org/kohsuke/github/GHTeam.java | 52 ++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/main/java/org/kohsuke/github/GHTeam.java b/src/main/java/org/kohsuke/github/GHTeam.java index 49be640321..a6a3160e4f 100644 --- a/src/main/java/org/kohsuke/github/GHTeam.java +++ b/src/main/java/org/kohsuke/github/GHTeam.java @@ -511,6 +511,58 @@ public void setPrivacy(Privacy privacy) throws IOException { root().createRequest().method("PATCH").with("privacy", privacy).withUrlPath(api("")).send(); } + /** + * Sets the team's name. + * + * @param name + * the new name + * @throws IOException + * the io exception + */ + public void setName(String name) throws IOException { + root().createRequest().method("PATCH").with("name", name).withUrlPath(api("")).send(); + } + + /** + * Sets the team's notification setting. + * + * @param notificationSetting + * the notification setting (e.g. "notifications_enabled" or "notifications_disabled") + * @throws IOException + * the io exception + */ + public void setNotificationSetting(String notificationSetting) throws IOException { + root().createRequest() + .method("PATCH") + .with("notification_setting", notificationSetting) + .withUrlPath(api("")) + .send(); + } + + /** + * Sets the team's permission. + * + * @param permission + * the permission (e.g. "pull", "push", or "admin") + * @throws IOException + * the io exception + */ + public void setPermission(String permission) throws IOException { + root().createRequest().method("PATCH").with("permission", permission).withUrlPath(api("")).send(); + } + + /** + * Sets the team's parent team by ID. + * + * @param parentTeamId + * the ID of the parent team, or {@code null} to remove the parent + * @throws IOException + * the io exception + */ + public void setParentTeamId(Long parentTeamId) throws IOException { + root().createRequest().method("PATCH").with("parent_team_id", parentTeamId).withUrlPath(api("")).send(); + } + private String api(String tail) { if (organization == null) { // Teams returned from pull requests to do not have an organization. Attempt to use url. From 8dadafe1444290da033818228ea30c4144713dcf Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Sat, 11 Apr 2026 11:37:19 -0400 Subject: [PATCH 2/2] refactor: use enum types for setPermission and setNotificationSetting Addresses review feedback from @rozza-sb on #2219: - setNotificationSetting now takes a new GHTeam.NotificationSetting enum (NOTIFICATIONS_ENABLED / NOTIFICATIONS_DISABLED) instead of a raw String. The enum overrides toString() to return the exact API values and is passed to .with("notification_setting", ...) as a String so transformEnum() doesn't rewrite the underscores. - setPermission now takes GHOrganization.Permission (ADMIN, MAINTAIN, PULL, PUSH, TRIAGE) so callers can only pass valid values. The enum names lowercase cleanly into the API values the Teams endpoint expects, and reuses the enum that already exists in this package instead of inventing a new team-scoped one. --- src/main/java/org/kohsuke/github/GHTeam.java | 32 +++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHTeam.java b/src/main/java/org/kohsuke/github/GHTeam.java index a6a3160e4f..26567485cd 100644 --- a/src/main/java/org/kohsuke/github/GHTeam.java +++ b/src/main/java/org/kohsuke/github/GHTeam.java @@ -34,6 +34,28 @@ public enum Privacy { UNKNOWN } + /** + * Notification setting for a team. Controls whether members receive notifications when the team is mentioned. + */ + public enum NotificationSetting { + + /** Notifications enabled: members receive notifications when the team is @mentioned. */ + NOTIFICATIONS_ENABLED("notifications_enabled"), + /** Notifications disabled: mentions of the team do not generate notifications. */ + NOTIFICATIONS_DISABLED("notifications_disabled"); + + private final String apiValue; + + NotificationSetting(String apiValue) { + this.apiValue = apiValue; + } + + @Override + public String toString() { + return apiValue; + } + } + /** * Member's role in a team. */ @@ -527,14 +549,14 @@ public void setName(String name) throws IOException { * Sets the team's notification setting. * * @param notificationSetting - * the notification setting (e.g. "notifications_enabled" or "notifications_disabled") + * the notification setting * @throws IOException * the io exception */ - public void setNotificationSetting(String notificationSetting) throws IOException { + public void setNotificationSetting(NotificationSetting notificationSetting) throws IOException { root().createRequest() .method("PATCH") - .with("notification_setting", notificationSetting) + .with("notification_setting", notificationSetting.toString()) .withUrlPath(api("")) .send(); } @@ -543,11 +565,11 @@ public void setNotificationSetting(String notificationSetting) throws IOExceptio * Sets the team's permission. * * @param permission - * the permission (e.g. "pull", "push", or "admin") + * the permission * @throws IOException * the io exception */ - public void setPermission(String permission) throws IOException { + public void setPermission(GHOrganization.Permission permission) throws IOException { root().createRequest().method("PATCH").with("permission", permission).withUrlPath(api("")).send(); }