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.go35
1 files changed, 32 insertions, 3 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 68a9f46..a19a14a 100644
--- a/vendor/github.com/google/go-github/github/repos_collaborators.go
+++ b/vendor/github.com/google/go-github/github/repos_collaborators.go
@@ -22,13 +22,13 @@ func (s *RepositoriesService) ListCollaborators(owner, repo string, opt *ListOpt
return nil, nil, err
}
- users := new([]*User)
- resp, err := s.client.Do(req, users)
+ var users []*User
+ resp, err := s.client.Do(req, &users)
if err != nil {
return nil, resp, err
}
- return *users, resp, err
+ return users, resp, nil
}
// IsCollaborator checks whether the specified Github user has collaborator
@@ -49,6 +49,35 @@ func (s *RepositoriesService) IsCollaborator(owner, repo, user string) (bool, *R
return isCollab, resp, err
}
+// RepositoryPermissionLevel represents the permission level an organization
+// member has for a given repository.
+type RepositoryPermissionLevel struct {
+ // Possible values: "admin", "write", "read", "none"
+ Permission *string `json:"permission,omitempty"`
+
+ User *User `json:"user,omitempty"`
+}
+
+// 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) {
+ 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)
+ if err != nil {
+ return nil, resp, err
+ }
+ return rpl, resp, nil
+}
+
// RepositoryAddCollaboratorOptions specifies the optional parameters to the
// RepositoriesService.AddCollaborator method.
type RepositoryAddCollaboratorOptions struct {