github.com/google/go-github/v66@v66.0.0/github/orgs_security_managers.go (about) 1 // Copyright 2022 The go-github AUTHORS. All rights reserved. 2 // 3 // Use of this source code is governed by a BSD-style 4 // license that can be found in the LICENSE file. 5 6 package github 7 8 import ( 9 "context" 10 "fmt" 11 ) 12 13 // ListSecurityManagerTeams lists all security manager teams for an organization. 14 // 15 // GitHub API docs: https://docs.github.com/rest/orgs/security-managers#list-security-manager-teams 16 // 17 //meta:operation GET /orgs/{org}/security-managers 18 func (s *OrganizationsService) ListSecurityManagerTeams(ctx context.Context, org string) ([]*Team, *Response, error) { 19 u := fmt.Sprintf("orgs/%v/security-managers", org) 20 21 req, err := s.client.NewRequest("GET", u, nil) 22 if err != nil { 23 return nil, nil, err 24 } 25 26 var teams []*Team 27 resp, err := s.client.Do(ctx, req, &teams) 28 if err != nil { 29 return nil, resp, err 30 } 31 32 return teams, resp, nil 33 } 34 35 // AddSecurityManagerTeam adds a team to the list of security managers for an organization. 36 // 37 // GitHub API docs: https://docs.github.com/rest/orgs/security-managers#add-a-security-manager-team 38 // 39 //meta:operation PUT /orgs/{org}/security-managers/teams/{team_slug} 40 func (s *OrganizationsService) AddSecurityManagerTeam(ctx context.Context, org, team string) (*Response, error) { 41 u := fmt.Sprintf("orgs/%v/security-managers/teams/%v", org, team) 42 req, err := s.client.NewRequest("PUT", u, nil) 43 if err != nil { 44 return nil, err 45 } 46 47 return s.client.Do(ctx, req, nil) 48 } 49 50 // RemoveSecurityManagerTeam removes a team from the list of security managers for an organization. 51 // 52 // GitHub API docs: https://docs.github.com/rest/orgs/security-managers#remove-a-security-manager-team 53 // 54 //meta:operation DELETE /orgs/{org}/security-managers/teams/{team_slug} 55 func (s *OrganizationsService) RemoveSecurityManagerTeam(ctx context.Context, org, team string) (*Response, error) { 56 u := fmt.Sprintf("orgs/%v/security-managers/teams/%v", org, team) 57 req, err := s.client.NewRequest("DELETE", u, nil) 58 if err != nil { 59 return nil, err 60 } 61 62 return s.client.Do(ctx, req, nil) 63 }