diff options
author | Niall Sheridan <nsheridan@gmail.com> | 2017-02-12 22:24:33 +0000 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2017-02-12 22:24:33 +0000 |
commit | ba4840c52becf73c2749c9ef0f2f09ed0b9d5c7f (patch) | |
tree | 61b839884d66c9dd8269e26117aa4e4c995ad119 /vendor/github.com/google/go-github/github/repos_collaborators.go | |
parent | 6e00d0000e54f21a4a393e67fd914bda4d394f4a (diff) |
Update dependencies
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.go | 35 |
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 { |