aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/google/go-github/github/orgs_teams.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/google/go-github/github/orgs_teams.go')
-rw-r--r--vendor/github.com/google/go-github/github/orgs_teams.go72
1 files changed, 37 insertions, 35 deletions
diff --git a/vendor/github.com/google/go-github/github/orgs_teams.go b/vendor/github.com/google/go-github/github/orgs_teams.go
index c1818e5..70b090d 100644
--- a/vendor/github.com/google/go-github/github/orgs_teams.go
+++ b/vendor/github.com/google/go-github/github/orgs_teams.go
@@ -6,6 +6,7 @@
package github
import (
+ "context"
"fmt"
"time"
)
@@ -38,6 +39,10 @@ type Team struct {
Organization *Organization `json:"organization,omitempty"`
MembersURL *string `json:"members_url,omitempty"`
RepositoriesURL *string `json:"repositories_url,omitempty"`
+
+ // LDAPDN is only available in GitHub Enterprise and when the team
+ // membership is synchronized with LDAP.
+ LDAPDN *string `json:"ldap_dn,omitempty"`
}
func (t Team) String() string {
@@ -62,7 +67,7 @@ func (i Invitation) String() string {
// ListTeams lists all of the teams for an organization.
//
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#list-teams
-func (s *OrganizationsService) ListTeams(org string, opt *ListOptions) ([]*Team, *Response, error) {
+func (s *OrganizationsService) ListTeams(ctx context.Context, org string, opt *ListOptions) ([]*Team, *Response, error) {
u := fmt.Sprintf("orgs/%v/teams", org)
u, err := addOptions(u, opt)
if err != nil {
@@ -75,7 +80,7 @@ func (s *OrganizationsService) ListTeams(org string, opt *ListOptions) ([]*Team,
}
var teams []*Team
- resp, err := s.client.Do(req, &teams)
+ resp, err := s.client.Do(ctx, req, &teams)
if err != nil {
return nil, resp, err
}
@@ -86,7 +91,7 @@ func (s *OrganizationsService) ListTeams(org string, opt *ListOptions) ([]*Team,
// GetTeam fetches a team by ID.
//
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#get-team
-func (s *OrganizationsService) GetTeam(team int) (*Team, *Response, error) {
+func (s *OrganizationsService) GetTeam(ctx context.Context, team int) (*Team, *Response, error) {
u := fmt.Sprintf("teams/%v", team)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
@@ -94,7 +99,7 @@ func (s *OrganizationsService) GetTeam(team int) (*Team, *Response, error) {
}
t := new(Team)
- resp, err := s.client.Do(req, t)
+ resp, err := s.client.Do(ctx, req, t)
if err != nil {
return nil, resp, err
}
@@ -105,7 +110,7 @@ func (s *OrganizationsService) GetTeam(team int) (*Team, *Response, error) {
// CreateTeam creates a new team within an organization.
//
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#create-team
-func (s *OrganizationsService) CreateTeam(org string, team *Team) (*Team, *Response, error) {
+func (s *OrganizationsService) CreateTeam(ctx context.Context, org string, team *Team) (*Team, *Response, error) {
u := fmt.Sprintf("orgs/%v/teams", org)
req, err := s.client.NewRequest("POST", u, team)
if err != nil {
@@ -113,7 +118,7 @@ func (s *OrganizationsService) CreateTeam(org string, team *Team) (*Team, *Respo
}
t := new(Team)
- resp, err := s.client.Do(req, t)
+ resp, err := s.client.Do(ctx, req, t)
if err != nil {
return nil, resp, err
}
@@ -124,7 +129,7 @@ func (s *OrganizationsService) CreateTeam(org string, team *Team) (*Team, *Respo
// EditTeam edits a team.
//
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#edit-team
-func (s *OrganizationsService) EditTeam(id int, team *Team) (*Team, *Response, error) {
+func (s *OrganizationsService) EditTeam(ctx context.Context, id int, team *Team) (*Team, *Response, error) {
u := fmt.Sprintf("teams/%v", id)
req, err := s.client.NewRequest("PATCH", u, team)
if err != nil {
@@ -132,7 +137,7 @@ func (s *OrganizationsService) EditTeam(id int, team *Team) (*Team, *Response, e
}
t := new(Team)
- resp, err := s.client.Do(req, t)
+ resp, err := s.client.Do(ctx, req, t)
if err != nil {
return nil, resp, err
}
@@ -143,14 +148,14 @@ func (s *OrganizationsService) EditTeam(id int, team *Team) (*Team, *Response, e
// DeleteTeam deletes a team.
//
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#delete-team
-func (s *OrganizationsService) DeleteTeam(team int) (*Response, error) {
+func (s *OrganizationsService) DeleteTeam(ctx context.Context, team int) (*Response, error) {
u := fmt.Sprintf("teams/%v", team)
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return nil, err
}
- return s.client.Do(req, nil)
+ return s.client.Do(ctx, req, nil)
}
// OrganizationListTeamMembersOptions specifies the optional parameters to the
@@ -167,7 +172,7 @@ type OrganizationListTeamMembersOptions struct {
// team.
//
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#list-team-members
-func (s *OrganizationsService) ListTeamMembers(team int, opt *OrganizationListTeamMembersOptions) ([]*User, *Response, error) {
+func (s *OrganizationsService) ListTeamMembers(ctx context.Context, team int, opt *OrganizationListTeamMembersOptions) ([]*User, *Response, error) {
u := fmt.Sprintf("teams/%v/members", team)
u, err := addOptions(u, opt)
if err != nil {
@@ -180,7 +185,7 @@ func (s *OrganizationsService) ListTeamMembers(team int, opt *OrganizationListTe
}
var members []*User
- resp, err := s.client.Do(req, &members)
+ resp, err := s.client.Do(ctx, req, &members)
if err != nil {
return nil, resp, err
}
@@ -191,14 +196,14 @@ func (s *OrganizationsService) ListTeamMembers(team int, opt *OrganizationListTe
// IsTeamMember checks if a user is a member of the specified team.
//
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#get-team-member
-func (s *OrganizationsService) IsTeamMember(team int, user string) (bool, *Response, error) {
+func (s *OrganizationsService) IsTeamMember(ctx context.Context, team int, user string) (bool, *Response, error) {
u := fmt.Sprintf("teams/%v/members/%v", team, user)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return false, nil, err
}
- resp, err := s.client.Do(req, nil)
+ resp, err := s.client.Do(ctx, req, nil)
member, err := parseBoolResponse(err)
return member, resp, err
}
@@ -206,7 +211,7 @@ func (s *OrganizationsService) IsTeamMember(team int, user string) (bool, *Respo
// ListTeamRepos lists the repositories that the specified team has access to.
//
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#list-team-repos
-func (s *OrganizationsService) ListTeamRepos(team int, opt *ListOptions) ([]*Repository, *Response, error) {
+func (s *OrganizationsService) ListTeamRepos(ctx context.Context, team int, opt *ListOptions) ([]*Repository, *Response, error) {
u := fmt.Sprintf("teams/%v/repos", team)
u, err := addOptions(u, opt)
if err != nil {
@@ -219,7 +224,7 @@ func (s *OrganizationsService) ListTeamRepos(team int, opt *ListOptions) ([]*Rep
}
var repos []*Repository
- resp, err := s.client.Do(req, &repos)
+ resp, err := s.client.Do(ctx, req, &repos)
if err != nil {
return nil, resp, err
}
@@ -232,7 +237,7 @@ func (s *OrganizationsService) ListTeamRepos(team int, opt *ListOptions) ([]*Rep
// permissions team has for that repo.
//
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#check-if-a-team-manages-a-repository
-func (s *OrganizationsService) IsTeamRepo(team int, owner string, repo string) (*Repository, *Response, error) {
+func (s *OrganizationsService) IsTeamRepo(ctx context.Context, team int, owner string, repo string) (*Repository, *Response, error) {
u := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
@@ -242,7 +247,7 @@ func (s *OrganizationsService) IsTeamRepo(team int, owner string, repo string) (
req.Header.Set("Accept", mediaTypeOrgPermissionRepo)
repository := new(Repository)
- resp, err := s.client.Do(req, repository)
+ resp, err := s.client.Do(ctx, req, repository)
if err != nil {
return nil, resp, err
}
@@ -268,14 +273,14 @@ type OrganizationAddTeamRepoOptions struct {
// belongs, or a direct fork of a repository owned by the organization.
//
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#add-team-repo
-func (s *OrganizationsService) AddTeamRepo(team int, owner string, repo string, opt *OrganizationAddTeamRepoOptions) (*Response, error) {
+func (s *OrganizationsService) AddTeamRepo(ctx context.Context, team int, owner string, repo string, opt *OrganizationAddTeamRepoOptions) (*Response, error) {
u := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo)
req, err := s.client.NewRequest("PUT", u, opt)
if err != nil {
return nil, err
}
- return s.client.Do(req, nil)
+ return s.client.Do(ctx, req, nil)
}
// RemoveTeamRepo removes a repository from being managed by the specified
@@ -283,19 +288,19 @@ func (s *OrganizationsService) AddTeamRepo(team int, owner string, repo string,
// from the team.
//
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#remove-team-repo
-func (s *OrganizationsService) RemoveTeamRepo(team int, owner string, repo string) (*Response, error) {
+func (s *OrganizationsService) RemoveTeamRepo(ctx context.Context, team int, owner string, repo string) (*Response, error) {
u := fmt.Sprintf("teams/%v/repos/%v/%v", team, owner, repo)
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return nil, err
}
- return s.client.Do(req, nil)
+ return s.client.Do(ctx, req, nil)
}
// ListUserTeams lists a user's teams
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#list-user-teams
-func (s *OrganizationsService) ListUserTeams(opt *ListOptions) ([]*Team, *Response, error) {
+func (s *OrganizationsService) ListUserTeams(ctx context.Context, opt *ListOptions) ([]*Team, *Response, error) {
u := "user/teams"
u, err := addOptions(u, opt)
if err != nil {
@@ -308,7 +313,7 @@ func (s *OrganizationsService) ListUserTeams(opt *ListOptions) ([]*Team, *Respon
}
var teams []*Team
- resp, err := s.client.Do(req, &teams)
+ resp, err := s.client.Do(ctx, req, &teams)
if err != nil {
return nil, resp, err
}
@@ -319,7 +324,7 @@ func (s *OrganizationsService) ListUserTeams(opt *ListOptions) ([]*Team, *Respon
// GetTeamMembership returns the membership status for a user in a team.
//
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#get-team-membership
-func (s *OrganizationsService) GetTeamMembership(team int, user string) (*Membership, *Response, error) {
+func (s *OrganizationsService) GetTeamMembership(ctx context.Context, team int, user string) (*Membership, *Response, error) {
u := fmt.Sprintf("teams/%v/memberships/%v", team, user)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
@@ -327,7 +332,7 @@ func (s *OrganizationsService) GetTeamMembership(team int, user string) (*Member
}
t := new(Membership)
- resp, err := s.client.Do(req, t)
+ resp, err := s.client.Do(ctx, req, t)
if err != nil {
return nil, resp, err
}
@@ -367,7 +372,7 @@ type OrganizationAddTeamMembershipOptions struct {
// added as a member of the team.
//
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#add-team-membership
-func (s *OrganizationsService) AddTeamMembership(team int, user string, opt *OrganizationAddTeamMembershipOptions) (*Membership, *Response, error) {
+func (s *OrganizationsService) AddTeamMembership(ctx context.Context, team int, user string, opt *OrganizationAddTeamMembershipOptions) (*Membership, *Response, error) {
u := fmt.Sprintf("teams/%v/memberships/%v", team, user)
req, err := s.client.NewRequest("PUT", u, opt)
if err != nil {
@@ -375,7 +380,7 @@ func (s *OrganizationsService) AddTeamMembership(team int, user string, opt *Org
}
t := new(Membership)
- resp, err := s.client.Do(req, t)
+ resp, err := s.client.Do(ctx, req, t)
if err != nil {
return nil, resp, err
}
@@ -386,14 +391,14 @@ func (s *OrganizationsService) AddTeamMembership(team int, user string, opt *Org
// RemoveTeamMembership removes a user from a team.
//
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#remove-team-membership
-func (s *OrganizationsService) RemoveTeamMembership(team int, user string) (*Response, error) {
+func (s *OrganizationsService) RemoveTeamMembership(ctx context.Context, team int, user string) (*Response, error) {
u := fmt.Sprintf("teams/%v/memberships/%v", team, user)
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return nil, err
}
- return s.client.Do(req, nil)
+ return s.client.Do(ctx, req, nil)
}
// ListPendingTeamInvitations get pending invitaion list in team.
@@ -401,7 +406,7 @@ func (s *OrganizationsService) RemoveTeamMembership(team int, user string) (*Res
// Preview features are not supported for production use.
//
// GitHub API docs: https://developer.github.com/v3/orgs/teams/#list-pending-team-invitations
-func (s *OrganizationsService) ListPendingTeamInvitations(team int, opt *ListOptions) ([]*Invitation, *Response, error) {
+func (s *OrganizationsService) ListPendingTeamInvitations(ctx context.Context, team int, opt *ListOptions) ([]*Invitation, *Response, error) {
u := fmt.Sprintf("teams/%v/invitations", team)
u, err := addOptions(u, opt)
if err != nil {
@@ -413,11 +418,8 @@ func (s *OrganizationsService) ListPendingTeamInvitations(team int, opt *ListOpt
return nil, nil, err
}
- // TODO: remove custom Accept header when this API fully launches.
- req.Header.Set("Accept", mediaTypeOrgMembershipPreview)
-
var pendingInvitations []*Invitation
- resp, err := s.client.Do(req, &pendingInvitations)
+ resp, err := s.client.Do(ctx, req, &pendingInvitations)
if err != nil {
return nil, resp, err
}