diff --git a/github/orgs_teams.go b/github/orgs_teams.go index d66bbed..f1434d0 100644 --- a/github/orgs_teams.go +++ b/github/orgs_teams.go @@ -22,6 +22,13 @@ type Team struct { // specifying a permission value when calling AddTeamRepo. Permission *string `json:"permission,omitempty"` + // Privacy identifies the level of privacy this team should have. + // Possible values are: + // secret - only visible to organization owners and members of this team + // closed - visible to all members of this organization + // Default is "secret". + Privacy *string `json:"privacy,omitempty"` + MembersCount *int `json:"members_count,omitempty"` ReposCount *int `json:"repos_count,omitempty"` Organization *Organization `json:"organization,omitempty"` @@ -84,6 +91,10 @@ func (s *OrganizationsService) CreateTeam(org string, team *Team) (*Team, *Respo return nil, nil, err } + if team.Privacy != nil { + req.Header.Set("Accept", mediaTypeOrgPermissionPreview) + } + t := new(Team) resp, err := s.client.Do(req, t) if err != nil { @@ -103,6 +114,10 @@ func (s *OrganizationsService) EditTeam(id int, team *Team) (*Team, *Response, e return nil, nil, err } + if team.Privacy != nil { + req.Header.Set("Accept", mediaTypeOrgPermissionPreview) + } + t := new(Team) resp, err := s.client.Do(req, t) if err != nil { diff --git a/github/orgs_teams_test.go b/github/orgs_teams_test.go index 9af130c..e8c4280 100644 --- a/github/orgs_teams_test.go +++ b/github/orgs_teams_test.go @@ -64,13 +64,14 @@ func TestOrganizationsService_CreateTeam(t *testing.T) { setup() defer teardown() - input := &Team{Name: String("n")} + input := &Team{Name: String("n"), Privacy: String("closed")} mux.HandleFunc("/orgs/o/teams", func(w http.ResponseWriter, r *http.Request) { v := new(Team) json.NewDecoder(r.Body).Decode(v) testMethod(t, r, "POST") + testHeader(t, r, "Accept", mediaTypeOrgPermissionPreview) if !reflect.DeepEqual(v, input) { t.Errorf("Request body = %+v, want %+v", v, input) } @@ -98,13 +99,14 @@ func TestOrganizationsService_EditTeam(t *testing.T) { setup() defer teardown() - input := &Team{Name: String("n")} + input := &Team{Name: String("n"), Privacy: String("closed")} mux.HandleFunc("/teams/1", func(w http.ResponseWriter, r *http.Request) { v := new(Team) json.NewDecoder(r.Body).Decode(v) testMethod(t, r, "PATCH") + testHeader(t, r, "Accept", mediaTypeOrgPermissionPreview) if !reflect.DeepEqual(v, input) { t.Errorf("Request body = %+v, want %+v", v, input) }