Merge v1.2.1-master
Signed-off-by: Emile Vauge <emile@vauge.com>
This commit is contained in:
parent
a590155b0b
commit
aeb17182b4
396 changed files with 27271 additions and 9969 deletions
55
vendor/github.com/google/go-github/github/users.go
generated
vendored
55
vendor/github.com/google/go-github/github/users.go
generated
vendored
|
@ -5,12 +5,15 @@
|
|||
|
||||
package github
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// UsersService handles communication with the user related
|
||||
// methods of the GitHub API.
|
||||
//
|
||||
// GitHub API docs: http://developer.github.com/v3/users/
|
||||
// GitHub API docs: https://developer.github.com/v3/users/
|
||||
type UsersService service
|
||||
|
||||
// User represents a GitHub user.
|
||||
|
@ -68,11 +71,11 @@ func (u User) String() string {
|
|||
return Stringify(u)
|
||||
}
|
||||
|
||||
// Get fetches a user. Passing the empty string will fetch the authenticated
|
||||
// Get fetches a user. Passing the empty string will fetch the authenticated
|
||||
// user.
|
||||
//
|
||||
// GitHub API docs: http://developer.github.com/v3/users/#get-a-single-user
|
||||
func (s *UsersService) Get(user string) (*User, *Response, error) {
|
||||
// GitHub API docs: https://developer.github.com/v3/users/#get-a-single-user
|
||||
func (s *UsersService) Get(ctx context.Context, user string) (*User, *Response, error) {
|
||||
var u string
|
||||
if user != "" {
|
||||
u = fmt.Sprintf("users/%v", user)
|
||||
|
@ -85,18 +88,18 @@ func (s *UsersService) Get(user string) (*User, *Response, error) {
|
|||
}
|
||||
|
||||
uResp := new(User)
|
||||
resp, err := s.client.Do(req, uResp)
|
||||
resp, err := s.client.Do(ctx, req, uResp)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return uResp, resp, err
|
||||
return uResp, resp, nil
|
||||
}
|
||||
|
||||
// GetByID fetches a user.
|
||||
//
|
||||
// Note: GetByID uses the undocumented GitHub API endpoint /user/:id.
|
||||
func (s *UsersService) GetByID(id int) (*User, *Response, error) {
|
||||
func (s *UsersService) GetByID(ctx context.Context, id int) (*User, *Response, error) {
|
||||
u := fmt.Sprintf("user/%d", id)
|
||||
req, err := s.client.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
|
@ -104,18 +107,18 @@ func (s *UsersService) GetByID(id int) (*User, *Response, error) {
|
|||
}
|
||||
|
||||
user := new(User)
|
||||
resp, err := s.client.Do(req, user)
|
||||
resp, err := s.client.Do(ctx, req, user)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return user, resp, err
|
||||
return user, resp, nil
|
||||
}
|
||||
|
||||
// Edit the authenticated user.
|
||||
//
|
||||
// GitHub API docs: http://developer.github.com/v3/users/#update-the-authenticated-user
|
||||
func (s *UsersService) Edit(user *User) (*User, *Response, error) {
|
||||
// GitHub API docs: https://developer.github.com/v3/users/#update-the-authenticated-user
|
||||
func (s *UsersService) Edit(ctx context.Context, user *User) (*User, *Response, error) {
|
||||
u := "user"
|
||||
req, err := s.client.NewRequest("PATCH", u, user)
|
||||
if err != nil {
|
||||
|
@ -123,12 +126,12 @@ func (s *UsersService) Edit(user *User) (*User, *Response, error) {
|
|||
}
|
||||
|
||||
uResp := new(User)
|
||||
resp, err := s.client.Do(req, uResp)
|
||||
resp, err := s.client.Do(ctx, req, uResp)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return uResp, resp, err
|
||||
return uResp, resp, nil
|
||||
}
|
||||
|
||||
// UserListOptions specifies optional parameters to the UsersService.ListAll
|
||||
|
@ -144,8 +147,8 @@ type UserListOptions struct {
|
|||
//
|
||||
// To paginate through all users, populate 'Since' with the ID of the last user.
|
||||
//
|
||||
// GitHub API docs: http://developer.github.com/v3/users/#get-all-users
|
||||
func (s *UsersService) ListAll(opt *UserListOptions) ([]*User, *Response, error) {
|
||||
// GitHub API docs: https://developer.github.com/v3/users/#get-all-users
|
||||
func (s *UsersService) ListAll(ctx context.Context, opt *UserListOptions) ([]*User, *Response, error) {
|
||||
u, err := addOptions("users", opt)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
@ -156,20 +159,20 @@ func (s *UsersService) ListAll(opt *UserListOptions) ([]*User, *Response, error)
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
users := new([]*User)
|
||||
resp, err := s.client.Do(req, users)
|
||||
var users []*User
|
||||
resp, err := s.client.Do(ctx, req, &users)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return *users, resp, err
|
||||
return users, resp, nil
|
||||
}
|
||||
|
||||
// ListInvitations lists all currently-open repository invitations for the
|
||||
// authenticated user.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/repos/invitations/#list-a-users-repository-invitations
|
||||
func (s *UsersService) ListInvitations() ([]*RepositoryInvitation, *Response, error) {
|
||||
func (s *UsersService) ListInvitations(ctx context.Context) ([]*RepositoryInvitation, *Response, error) {
|
||||
req, err := s.client.NewRequest("GET", "user/repository_invitations", nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
@ -179,19 +182,19 @@ func (s *UsersService) ListInvitations() ([]*RepositoryInvitation, *Response, er
|
|||
req.Header.Set("Accept", mediaTypeRepositoryInvitationsPreview)
|
||||
|
||||
invites := []*RepositoryInvitation{}
|
||||
resp, err := s.client.Do(req, &invites)
|
||||
resp, err := s.client.Do(ctx, req, &invites)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return invites, resp, err
|
||||
return invites, resp, nil
|
||||
}
|
||||
|
||||
// AcceptInvitation accepts the currently-open repository invitation for the
|
||||
// authenticated user.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/repos/invitations/#accept-a-repository-invitation
|
||||
func (s *UsersService) AcceptInvitation(invitationID int) (*Response, error) {
|
||||
func (s *UsersService) AcceptInvitation(ctx context.Context, invitationID int) (*Response, error) {
|
||||
u := fmt.Sprintf("user/repository_invitations/%v", invitationID)
|
||||
req, err := s.client.NewRequest("PATCH", u, nil)
|
||||
if err != nil {
|
||||
|
@ -201,14 +204,14 @@ func (s *UsersService) AcceptInvitation(invitationID int) (*Response, error) {
|
|||
// 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)
|
||||
}
|
||||
|
||||
// DeclineInvitation declines the currently-open repository invitation for the
|
||||
// authenticated user.
|
||||
//
|
||||
// GitHub API docs: https://developer.github.com/v3/repos/invitations/#decline-a-repository-invitation
|
||||
func (s *UsersService) DeclineInvitation(invitationID int) (*Response, error) {
|
||||
func (s *UsersService) DeclineInvitation(ctx context.Context, invitationID int) (*Response, error) {
|
||||
u := fmt.Sprintf("user/repository_invitations/%v", invitationID)
|
||||
req, err := s.client.NewRequest("DELETE", u, nil)
|
||||
if err != nil {
|
||||
|
@ -218,5 +221,5 @@ func (s *UsersService) DeclineInvitation(invitationID int) (*Response, error) {
|
|||
// 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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue