aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/google/go-github/github/repos_collaborators.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/google/go-github/github/repos_collaborators.go')
-rw-r--r--vendor/github.com/google/go-github/github/repos_collaborators.go36
1 files changed, 18 insertions, 18 deletions
diff --git a/vendor/github.com/google/go-github/github/repos_collaborators.go b/vendor/github.com/google/go-github/github/repos_collaborators.go
index ddb88f5..76e8a1f 100644
--- a/vendor/github.com/google/go-github/github/repos_collaborators.go
+++ b/vendor/github.com/google/go-github/github/repos_collaborators.go
@@ -5,12 +5,15 @@
package github
-import "fmt"
+import (
+ "context"
+ "fmt"
+)
-// ListCollaborators lists the Github users that have access to the repository.
+// ListCollaborators lists the GitHub users that have access to the repository.
//
// GitHub API docs: https://developer.github.com/v3/repos/collaborators/#list
-func (s *RepositoriesService) ListCollaborators(owner, repo string, opt *ListOptions) ([]*User, *Response, error) {
+func (s *RepositoriesService) ListCollaborators(ctx context.Context, owner, repo string, opt *ListOptions) ([]*User, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/collaborators", owner, repo)
u, err := addOptions(u, opt)
if err != nil {
@@ -23,7 +26,7 @@ func (s *RepositoriesService) ListCollaborators(owner, repo string, opt *ListOpt
}
var users []*User
- resp, err := s.client.Do(req, &users)
+ resp, err := s.client.Do(ctx, req, &users)
if err != nil {
return nil, resp, err
}
@@ -31,20 +34,20 @@ func (s *RepositoriesService) ListCollaborators(owner, repo string, opt *ListOpt
return users, resp, nil
}
-// IsCollaborator checks whether the specified Github user has collaborator
+// IsCollaborator checks whether the specified GitHub user has collaborator
// access to the given repo.
// Note: This will return false if the user is not a collaborator OR the user
// is not a GitHub user.
//
// GitHub API docs: https://developer.github.com/v3/repos/collaborators/#get
-func (s *RepositoriesService) IsCollaborator(owner, repo, user string) (bool, *Response, error) {
+func (s *RepositoriesService) IsCollaborator(ctx context.Context, owner, repo, user string) (bool, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/collaborators/%v", owner, repo, 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)
isCollab, err := parseBoolResponse(err)
return isCollab, resp, err
}
@@ -60,18 +63,15 @@ type RepositoryPermissionLevel struct {
// GetPermissionLevel retrieves the specific permission level a collaborator has for a given repository.
// GitHub API docs: https://developer.github.com/v3/repos/collaborators/#review-a-users-permission-level
-func (s *RepositoriesService) GetPermissionLevel(owner, repo, user string) (*RepositoryPermissionLevel, *Response, error) {
+func (s *RepositoriesService) GetPermissionLevel(ctx context.Context, owner, repo, user string) (*RepositoryPermissionLevel, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/collaborators/%v/permission", owner, repo, user)
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}
- // TODO: remove custom Accept header when this API fully launches.
- req.Header.Set("Accept", mediaTypeOrgMembershipPreview)
-
rpl := new(RepositoryPermissionLevel)
- resp, err := s.client.Do(req, rpl)
+ resp, err := s.client.Do(ctx, req, rpl)
if err != nil {
return nil, resp, err
}
@@ -91,10 +91,10 @@ type RepositoryAddCollaboratorOptions struct {
Permission string `json:"permission,omitempty"`
}
-// AddCollaborator adds the specified Github user as collaborator to the given repo.
+// AddCollaborator adds the specified GitHub user as collaborator to the given repo.
//
// GitHub API docs: https://developer.github.com/v3/repos/collaborators/#add-user-as-a-collaborator
-func (s *RepositoriesService) AddCollaborator(owner, repo, user string, opt *RepositoryAddCollaboratorOptions) (*Response, error) {
+func (s *RepositoriesService) AddCollaborator(ctx context.Context, owner, repo, user string, opt *RepositoryAddCollaboratorOptions) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/collaborators/%v", owner, repo, user)
req, err := s.client.NewRequest("PUT", u, opt)
if err != nil {
@@ -104,18 +104,18 @@ func (s *RepositoriesService) AddCollaborator(owner, repo, user string, opt *Rep
// TODO: remove custom Accept header when this API fully launches.
req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview)
- return s.client.Do(req, nil)
+ return s.client.Do(ctx, req, nil)
}
-// RemoveCollaborator removes the specified Github user as collaborator from the given repo.
+// RemoveCollaborator removes the specified GitHub user as collaborator from the given repo.
// Note: Does not return error if a valid user that is not a collaborator is removed.
//
// GitHub API docs: https://developer.github.com/v3/repos/collaborators/#remove-collaborator
-func (s *RepositoriesService) RemoveCollaborator(owner, repo, user string) (*Response, error) {
+func (s *RepositoriesService) RemoveCollaborator(ctx context.Context, owner, repo, user string) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/collaborators/%v", owner, repo, 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)
}