2019-05-07 01:12:51 +00:00
|
|
|
|
// Copyright 2013 The go-github AUTHORS. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
package github
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ListEvents drinks from the firehose of all public events across GitHub.
|
|
|
|
|
//
|
|
|
|
|
// GitHub API docs: https://developer.github.com/v3/activity/events/#list-public-events
|
2020-07-31 14:22:34 +00:00
|
|
|
|
func (s *ActivityService) ListEvents(ctx context.Context, opts *ListOptions) ([]*Event, *Response, error) {
|
|
|
|
|
u, err := addOptions("events", opts)
|
2019-05-07 01:12:51 +00:00
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
req, err := s.client.NewRequest("GET", u, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var events []*Event
|
|
|
|
|
resp, err := s.client.Do(ctx, req, &events)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, resp, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return events, resp, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ListRepositoryEvents lists events for a repository.
|
|
|
|
|
//
|
|
|
|
|
// GitHub API docs: https://developer.github.com/v3/activity/events/#list-repository-events
|
2020-07-31 14:22:34 +00:00
|
|
|
|
func (s *ActivityService) ListRepositoryEvents(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Event, *Response, error) {
|
2019-05-07 01:12:51 +00:00
|
|
|
|
u := fmt.Sprintf("repos/%v/%v/events", owner, repo)
|
2020-07-31 14:22:34 +00:00
|
|
|
|
u, err := addOptions(u, opts)
|
2019-05-07 01:12:51 +00:00
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
req, err := s.client.NewRequest("GET", u, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var events []*Event
|
|
|
|
|
resp, err := s.client.Do(ctx, req, &events)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, resp, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return events, resp, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ListIssueEventsForRepository lists issue events for a repository.
|
|
|
|
|
//
|
2020-07-31 14:22:34 +00:00
|
|
|
|
// GitHub API docs: https://developer.github.com/v3/issues/events/#list-issue-events-for-a-repository
|
|
|
|
|
func (s *ActivityService) ListIssueEventsForRepository(ctx context.Context, owner, repo string, opts *ListOptions) ([]*IssueEvent, *Response, error) {
|
2019-05-07 01:12:51 +00:00
|
|
|
|
u := fmt.Sprintf("repos/%v/%v/issues/events", owner, repo)
|
2020-07-31 14:22:34 +00:00
|
|
|
|
u, err := addOptions(u, opts)
|
2019-05-07 01:12:51 +00:00
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
req, err := s.client.NewRequest("GET", u, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var events []*IssueEvent
|
|
|
|
|
resp, err := s.client.Do(ctx, req, &events)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, resp, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return events, resp, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ListEventsForRepoNetwork lists public events for a network of repositories.
|
|
|
|
|
//
|
|
|
|
|
// GitHub API docs: https://developer.github.com/v3/activity/events/#list-public-events-for-a-network-of-repositories
|
2020-07-31 14:22:34 +00:00
|
|
|
|
func (s *ActivityService) ListEventsForRepoNetwork(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Event, *Response, error) {
|
2019-05-07 01:12:51 +00:00
|
|
|
|
u := fmt.Sprintf("networks/%v/%v/events", owner, repo)
|
2020-07-31 14:22:34 +00:00
|
|
|
|
u, err := addOptions(u, opts)
|
2019-05-07 01:12:51 +00:00
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
req, err := s.client.NewRequest("GET", u, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var events []*Event
|
|
|
|
|
resp, err := s.client.Do(ctx, req, &events)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, resp, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return events, resp, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ListEventsForOrganization lists public events for an organization.
|
|
|
|
|
//
|
2020-07-31 14:22:34 +00:00
|
|
|
|
// GitHub API docs: https://developer.github.com/v3/activity/events/#list-public-organization-events
|
|
|
|
|
func (s *ActivityService) ListEventsForOrganization(ctx context.Context, org string, opts *ListOptions) ([]*Event, *Response, error) {
|
2019-05-07 01:12:51 +00:00
|
|
|
|
u := fmt.Sprintf("orgs/%v/events", org)
|
2020-07-31 14:22:34 +00:00
|
|
|
|
u, err := addOptions(u, opts)
|
2019-05-07 01:12:51 +00:00
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
req, err := s.client.NewRequest("GET", u, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var events []*Event
|
|
|
|
|
resp, err := s.client.Do(ctx, req, &events)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, resp, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return events, resp, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ListEventsPerformedByUser lists the events performed by a user. If publicOnly is
|
|
|
|
|
// true, only public events will be returned.
|
|
|
|
|
//
|
2020-07-31 14:22:34 +00:00
|
|
|
|
// GitHub API docs: https://developer.github.com/v3/activity/events/#list-events-for-the-authenticated-user
|
|
|
|
|
// GitHub API docs: https://developer.github.com/v3/activity/events/#list-public-events-for-a-user
|
|
|
|
|
func (s *ActivityService) ListEventsPerformedByUser(ctx context.Context, user string, publicOnly bool, opts *ListOptions) ([]*Event, *Response, error) {
|
2019-05-07 01:12:51 +00:00
|
|
|
|
var u string
|
|
|
|
|
if publicOnly {
|
|
|
|
|
u = fmt.Sprintf("users/%v/events/public", user)
|
|
|
|
|
} else {
|
|
|
|
|
u = fmt.Sprintf("users/%v/events", user)
|
|
|
|
|
}
|
2020-07-31 14:22:34 +00:00
|
|
|
|
u, err := addOptions(u, opts)
|
2019-05-07 01:12:51 +00:00
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
req, err := s.client.NewRequest("GET", u, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var events []*Event
|
|
|
|
|
resp, err := s.client.Do(ctx, req, &events)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, resp, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return events, resp, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ListEventsReceivedByUser lists the events received by a user. If publicOnly is
|
|
|
|
|
// true, only public events will be returned.
|
|
|
|
|
//
|
2020-07-31 14:22:34 +00:00
|
|
|
|
// GitHub API docs: https://developer.github.com/v3/activity/events/#list-events-received-by-the-authenticated-user
|
|
|
|
|
// GitHub API docs: https://developer.github.com/v3/activity/events/#list-public-events-received-by-a-user
|
|
|
|
|
func (s *ActivityService) ListEventsReceivedByUser(ctx context.Context, user string, publicOnly bool, opts *ListOptions) ([]*Event, *Response, error) {
|
2019-05-07 01:12:51 +00:00
|
|
|
|
var u string
|
|
|
|
|
if publicOnly {
|
|
|
|
|
u = fmt.Sprintf("users/%v/received_events/public", user)
|
|
|
|
|
} else {
|
|
|
|
|
u = fmt.Sprintf("users/%v/received_events", user)
|
|
|
|
|
}
|
2020-07-31 14:22:34 +00:00
|
|
|
|
u, err := addOptions(u, opts)
|
2019-05-07 01:12:51 +00:00
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
req, err := s.client.NewRequest("GET", u, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var events []*Event
|
|
|
|
|
resp, err := s.client.Do(ctx, req, &events)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, resp, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return events, resp, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ListUserEventsForOrganization provides the user’s organization dashboard. You
|
|
|
|
|
// must be authenticated as the user to view this.
|
|
|
|
|
//
|
2020-07-31 14:22:34 +00:00
|
|
|
|
// GitHub API docs: https://developer.github.com/v3/activity/events/#list-organization-events-for-the-authenticated-user
|
|
|
|
|
func (s *ActivityService) ListUserEventsForOrganization(ctx context.Context, org, user string, opts *ListOptions) ([]*Event, *Response, error) {
|
2019-05-07 01:12:51 +00:00
|
|
|
|
u := fmt.Sprintf("users/%v/events/orgs/%v", user, org)
|
2020-07-31 14:22:34 +00:00
|
|
|
|
u, err := addOptions(u, opts)
|
2019-05-07 01:12:51 +00:00
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
req, err := s.client.NewRequest("GET", u, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var events []*Event
|
|
|
|
|
resp, err := s.client.Do(ctx, req, &events)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, resp, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return events, resp, nil
|
|
|
|
|
}
|