@@ -39,6 +39,7 @@ type Team struct {
39
39
Organization * Organization `json:"organization,omitempty"`
40
40
MembersURL * string `json:"members_url,omitempty"`
41
41
RepositoriesURL * string `json:"repositories_url,omitempty"`
42
+ Parent * Team `json:"parent,omitempty"`
42
43
43
44
// LDAPDN is only available in GitHub Enterprise and when the team
44
45
// membership is synchronized with LDAP.
@@ -79,6 +80,9 @@ func (s *OrganizationsService) ListTeams(ctx context.Context, org string, opt *L
79
80
return nil , nil , err
80
81
}
81
82
83
+ // TODO: remove custom Accept header when this API fully launches.
84
+ req .Header .Set ("Accept" , mediaTypeNestedTeamsPreview )
85
+
82
86
var teams []* Team
83
87
resp , err := s .client .Do (ctx , req , & teams )
84
88
if err != nil {
@@ -98,6 +102,9 @@ func (s *OrganizationsService) GetTeam(ctx context.Context, team int) (*Team, *R
98
102
return nil , nil , err
99
103
}
100
104
105
+ // TODO: remove custom Accept header when this API fully launches.
106
+ req .Header .Set ("Accept" , mediaTypeNestedTeamsPreview )
107
+
101
108
t := new (Team )
102
109
resp , err := s .client .Do (ctx , req , t )
103
110
if err != nil {
@@ -107,16 +114,48 @@ func (s *OrganizationsService) GetTeam(ctx context.Context, team int) (*Team, *R
107
114
return t , resp , nil
108
115
}
109
116
117
+ // NewTeam represents a team to be created or modified.
118
+ type NewTeam struct {
119
+
120
+ // The name of the team (Required.)
121
+ Name string `json:"name"`
122
+ Description * string `json:"description,omitempty"`
123
+ Maintainers []string `json:"maintainers,omitempty"`
124
+ RepoNames []string `json:"repo_names,omitempty"`
125
+ ParentTeamID * string `json:"parent_team_id,omitempty"`
126
+
127
+ // Permission is deprecated when creating or editing a team in an org
128
+ // using the new GitHub permission model. It no longer identifies the
129
+ // permission a team has on its repos, but only specifies the default
130
+ // permission a repo is initially added with. Avoid confusion by
131
+ // specifying a permission value when calling AddTeamRepo.
132
+ Permission * string `json:"permission,omitempty"`
133
+
134
+ // Privacy identifies the level of privacy this team should have.
135
+ // Possible values are:
136
+ // secret - only visible to organization owners and members of this team
137
+ // closed - visible to all members of this organization
138
+ // Default is "secret".
139
+ Privacy * string `json:"privacy,omitempty"`
140
+
141
+ // LDAPDN may be used in GitHub Enterprise when the team membership
142
+ // is synchronized with LDAP.
143
+ LDAPDN * string `json:"ldap_dn,omitempty"`
144
+ }
145
+
110
146
// CreateTeam creates a new team within an organization.
111
147
//
112
148
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#create-team
113
- func (s * OrganizationsService ) CreateTeam (ctx context.Context , org string , team * Team ) (* Team , * Response , error ) {
149
+ func (s * OrganizationsService ) CreateTeam (ctx context.Context , org string , team * NewTeam ) (* Team , * Response , error ) {
114
150
u := fmt .Sprintf ("orgs/%v/teams" , org )
115
151
req , err := s .client .NewRequest ("POST" , u , team )
116
152
if err != nil {
117
153
return nil , nil , err
118
154
}
119
155
156
+ // TODO: remove custom Accept header when this API fully launches.
157
+ req .Header .Set ("Accept" , mediaTypeNestedTeamsPreview )
158
+
120
159
t := new (Team )
121
160
resp , err := s .client .Do (ctx , req , t )
122
161
if err != nil {
@@ -129,13 +168,16 @@ func (s *OrganizationsService) CreateTeam(ctx context.Context, org string, team
129
168
// EditTeam edits a team.
130
169
//
131
170
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#edit-team
132
- func (s * OrganizationsService ) EditTeam (ctx context.Context , id int , team * Team ) (* Team , * Response , error ) {
171
+ func (s * OrganizationsService ) EditTeam (ctx context.Context , id int , team * NewTeam ) (* Team , * Response , error ) {
133
172
u := fmt .Sprintf ("teams/%v" , id )
134
173
req , err := s .client .NewRequest ("PATCH" , u , team )
135
174
if err != nil {
136
175
return nil , nil , err
137
176
}
138
177
178
+ // TODO: remove custom Accept header when this API fully launches.
179
+ req .Header .Set ("Accept" , mediaTypeNestedTeamsPreview )
180
+
139
181
t := new (Team )
140
182
resp , err := s .client .Do (ctx , req , t )
141
183
if err != nil {
@@ -315,6 +357,9 @@ func (s *OrganizationsService) ListUserTeams(ctx context.Context, opt *ListOptio
315
357
return nil , nil , err
316
358
}
317
359
360
+ // TODO: remove custom Accept header when this API fully launches.
361
+ req .Header .Set ("Accept" , mediaTypeNestedTeamsPreview )
362
+
318
363
var teams []* Team
319
364
resp , err := s .client .Do (ctx , req , & teams )
320
365
if err != nil {
0 commit comments