Repository: google/go-github
Pull request #3111 (2024-03-25 13:14:33)

Add NotificationSetting to NewTeam
Fixes: #3107.


Patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index f95e4c3b..57a7165f 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -11982,6 +11982,14 @@ func (n *NewTeam) GetLDAPDN() string {
 	return *n.LDAPDN
 }
 
+// GetNotificationSetting returns the NotificationSetting field if it's non-nil, zero value otherwise.
+func (n *NewTeam) GetNotificationSetting() string {
+	if n == nil || n.NotificationSetting == nil {
+		return ""
+	}
+	return *n.NotificationSetting
+}
+
 // GetParentTeamID returns the ParentTeamID field if it's non-nil, zero value otherwise.
 func (n *NewTeam) GetParentTeamID() int64 {
 	if n == nil || n.ParentTeamID == nil {
diff --git a/github/teams.go b/github/teams.go
index fd22b792..0f6cc9d1 100644
--- a/github/teams.go
+++ b/github/teams.go
@@ -155,6 +155,9 @@ type NewTeam struct {
 	RepoNames    []string `json:"repo_names,omitempty"`
 	ParentTeamID *int64   `json:"parent_team_id,omitempty"`
 
+	// NotificationSetting can be one of: "notifications_enabled", "notifications_disabled".
+	NotificationSetting *string `json:"notification_setting,omitempty"`
+
 	// Deprecated: Permission is deprecated when creating or editing a team in an org
 	// using the new GitHub permission model. It no longer identifies the
 	// permission a team has on its repos, but only specifies the default


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index ca263064..bbf9fb84 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -13985,6 +13985,16 @@ func TestNewTeam_GetLDAPDN(tt *testing.T) {
 	n.GetLDAPDN()
 }
 
+func TestNewTeam_GetNotificationSetting(tt *testing.T) {
+	var zeroValue string
+	n := &NewTeam{NotificationSetting: &zeroValue}
+	n.GetNotificationSetting()
+	n = &NewTeam{}
+	n.GetNotificationSetting()
+	n = nil
+	n.GetNotificationSetting()
+}
+
 func TestNewTeam_GetParentTeamID(tt *testing.T) {
 	var zeroValue int64
 	n := &NewTeam{ParentTeamID: &zeroValue}
diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go
index 576db8ff..8633d837 100644
--- a/github/github-stringify_test.go
+++ b/github/github-stringify_test.go
@@ -962,16 +962,17 @@ func TestMilestoneStats_String(t *testing.T) {
 
 func TestNewTeam_String(t *testing.T) {
 	v := NewTeam{
-		Name:         "",
-		Description:  String(""),
-		Maintainers:  []string{""},
-		RepoNames:    []string{""},
-		ParentTeamID: Int64(0),
-		Permission:   String(""),
-		Privacy:      String(""),
-		LDAPDN:       String(""),
-	}
-	want := `github.NewTeam{Name:"", Description:"", Maintainers:[""], RepoNames:[""], ParentTeamID:0, Permission:"", Privacy:"", LDAPDN:""}`
+		Name:                "",
+		Description:         String(""),
+		Maintainers:         []string{""},
+		RepoNames:           []string{""},
+		ParentTeamID:        Int64(0),
+		NotificationSetting: String(""),
+		Permission:          String(""),
+		Privacy:             String(""),
+		LDAPDN:              String(""),
+	}
+	want := `github.NewTeam{Name:"", Description:"", Maintainers:[""], RepoNames:[""], ParentTeamID:0, NotificationSetting:"", Permission:"", Privacy:"", LDAPDN:""}`
 	if got := v.String(); got != want {
 		t.Errorf("NewTeam.String = %v, want %v", got, want)
 	}
diff --git a/github/teams_test.go b/github/teams_test.go
index c0ca1f6d..516c88f4 100644
--- a/github/teams_test.go
+++ b/github/teams_test.go
@@ -1590,14 +1590,15 @@ func TestNewTeam_Marshal(t *testing.T) {
 	testJSONMarshal(t, &NewTeam{}, "{}")
 
 	u := &NewTeam{
-		Name:         "n",
-		Description:  String("d"),
-		Maintainers:  []string{"m1", "m2"},
-		RepoNames:    []string{"repo1", "repo2"},
-		ParentTeamID: Int64(1),
-		Permission:   String("perm"),
-		Privacy:      String("p"),
-		LDAPDN:       String("l"),
+		Name:                "n",
+		Description:         String("d"),
+		Maintainers:         []string{"m1", "m2"},
+		RepoNames:           []string{"repo1", "repo2"},
+		NotificationSetting: String("notifications_enabled"),
+		ParentTeamID:        Int64(1),
+		Permission:          String("perm"),
+		Privacy:             String("p"),
+		LDAPDN:              String("l"),
 	}
 
 	want := `{
@@ -1606,6 +1607,7 @@ func TestNewTeam_Marshal(t *testing.T) {
 		"maintainers":    ["m1", "m2"],
 		"repo_names":     ["repo1", "repo2"],
 		"parent_team_id": 1,
+		"notification_setting": "notifications_enabled",
 		"permission":     "perm",
 		"privacy":        "p",
 		"ldap_dn":        "l"