|
| 1 | +.. _Events service: |
| 2 | + |
| 3 | +Events service |
| 4 | +============== |
| 5 | + |
| 6 | +This service exposes the `Events API`. Much of this API is read-only, and while |
| 7 | +pagination is supported, there is a fixed page size of 30 with a limit of 10 |
| 8 | +page requests. |
| 9 | + |
| 10 | +Many events have an `actor` which denotes the user that performed an event. |
| 11 | +Additionally, there may be `org` or `repo` attributes for events related to |
| 12 | +Organizations and Repos. Finally, each event object contains a `payload` |
| 13 | +attribute containing more detailed information about the event. |
| 14 | +.. _public events: |
| 15 | + |
| 16 | +Public Events |
| 17 | +------------- |
| 18 | +Yields the most recent public events from Github. |
| 19 | + |
| 20 | +:: |
| 21 | + |
| 22 | + from pygithub3 import Github |
| 23 | + |
| 24 | + gh = Github() |
| 25 | + |
| 26 | + events = gh.events.list().all() |
| 27 | + print events[0].payload |
| 28 | + |
| 29 | + |
| 30 | +.. _repository events: |
| 31 | + |
| 32 | +Repo Events |
| 33 | +----------- |
| 34 | + |
| 35 | +These are events for a specific repo, including issue and network events. The |
| 36 | +Issues events are proxied to the `Issues Service`_. |
| 37 | + |
| 38 | +:: |
| 39 | + |
| 40 | + events = gh.events.repos.list(user="copitux", repo="python-github3") |
| 41 | + for e in events.next(): |
| 42 | + print("{t}".format(t=e.type)) |
| 43 | + |
| 44 | + # Get the issue Events |
| 45 | + events = gh.events.issues.list_by_repo(user="copitux", |
| 46 | + repo="python-github3") |
| 47 | + |
| 48 | + # Get the Public Events for a Repo's Network |
| 49 | + events = gh.events.networks.list(user="copitux", repo="python-github3") |
| 50 | + |
| 51 | +.. _organziation events: |
| 52 | + |
| 53 | +Organization Events |
| 54 | +------------------- |
| 55 | + |
| 56 | +These are the public events for an Organization |
| 57 | + |
| 58 | +:: |
| 59 | + |
| 60 | + events = gh.events.orgs.list(org="Acme") |
| 61 | + |
| 62 | +You may also get a user's feed of events for an Organization, but you *must* be |
| 63 | +authenticated as the provided user, and you must be a member of the given |
| 64 | +organization. |
| 65 | + |
| 66 | +:: |
| 67 | + |
| 68 | + events = gh.events.users.orgs(user="copitux", org="acme") |
| 69 | + |
| 70 | +.. _user events: |
| 71 | + |
| 72 | +User Events |
| 73 | +----------- |
| 74 | + |
| 75 | +You can retrieve the public events performed by a user and the public events |
| 76 | +that a user receives. If you're authenticated, you may also receive private |
| 77 | +events. |
| 78 | + |
| 79 | +:: |
| 80 | + |
| 81 | + received_events = gh.events.users.list_received_public(user="copitux") |
| 82 | + performed_events = gh.events.users.list_performed_public(user="copitux") |
| 83 | + |
| 84 | +If authenticated as `copitux`, you could get private events with the |
| 85 | +following, otherwise you'll just get the public events as above: |
| 86 | + |
| 87 | +:: |
| 88 | + |
| 89 | + received_events = gh.events.users.list_received(user="copitux") |
| 90 | + performed_events = gh.events.users.list_performed(user="copitux") |
| 91 | + |
| 92 | + |
| 93 | +.. _Events API: http://developer.github.com/v3/events/ |
0 commit comments