diff --git a/IntegrationTest.py b/IntegrationTest.py index 2e5c2edd..bf38bb53 100644 --- a/IntegrationTest.py +++ b/IntegrationTest.py @@ -306,6 +306,9 @@ class IntegrationTest: t.delete() self.printList( "Teams", o.get_teams(), lambda t: t.name ) + def testEvents( self ): + self.g.get_user().get_repo( "TestPyGithub" ).get_events() + def testFollow( self ): cobaye = self.g.get_user( self.cobayeUser ) u = self.g.get_user() diff --git a/ReferenceOfApis.md b/ReferenceOfApis.md index d0b23274..f175d68d 100644 --- a/ReferenceOfApis.md +++ b/ReferenceOfApis.md @@ -11,7 +11,7 @@ API `/authorizations/:id` API `/events` ============= -* GET: (TODO SOON) +* GET: `AuthenticatedUser.get_events` API `/gists` ============ @@ -59,7 +59,7 @@ API `/issues` API `/networks/:user/:repo/events` ================================== -* GET: (TODO SOON) +* GET: `Repository.get_network_events` API `/orgs/:org` ================ @@ -68,7 +68,7 @@ API `/orgs/:org` API `/orgs/:org/events` ======================= -* GET: (TODO SOON) +* GET: `Organization.get_events` API `/orgs/:org/members` ======================== @@ -161,7 +161,7 @@ API `/repos/:user/:repo/downloads/:id` API `/repos/:user/:repo/events` =============================== -* GET: (TODO SOON) +* GET: `Repository.get_events` API `/repos/:user/:repo/forks` ============================== @@ -261,7 +261,7 @@ API `/repos/:user/:repo/issues/:id/labels/:name` API `/repos/:user/:repo/issues/:id/events` ========================================== -* GET: (TODO SOON) +* GET: `Issue.get_events` API `/repos/:user/:repo/issues/comments/:id` ============================================ @@ -271,7 +271,7 @@ API `/repos/:user/:repo/issues/comments/:id` API `/repos/:user/:repo/issues/events` ====================================== -* GET: (TODO SOON) +* GET: `Repository.get_issues_events` API `/repos/:user/:repo/issues/events/:id` ========================================== @@ -451,7 +451,7 @@ API `/users/:user` API `/users/:user/events` ========================= -* GET: (TODO SOON) +* GET: `NamedUser.get_events` API `/users/:user/events/orgs/:org` =================================== @@ -459,7 +459,7 @@ API `/users/:user/events/orgs/:org` API `/users/:user/events/public` ================================ -* GET: (TODO SOON) +* GET: `NamedUser.get_public_events` API `/users/:user/followers` ============================ @@ -479,11 +479,11 @@ API `/users/:user/orgs` API `/users/:user/received_events` ================================== -* GET: (TODO SOON) +* GET: `NamedUser.get_received_events` API `/users/:user/received_events/public` ========================================= -* GET: (TODO SOON) +* GET: `NamedUser.get_public_received_events` API `/users/:user/repos` ======================== diff --git a/ReferenceOfClasses.md b/ReferenceOfClasses.md index e17261cd..7fc33028 100644 --- a/ReferenceOfClasses.md +++ b/ReferenceOfClasses.md @@ -70,6 +70,10 @@ Keys * `get_key( id )`: `UserKey` * `create_key( title, key )`: `UserKey` +Events +------ +* `get_events()`: list of `Event` + Followers --------- * `get_followers()`: list of `NamedUser` @@ -219,6 +223,19 @@ Deletion -------- * `delete()` +Class `Event` +============= + +Attributes +---------- +* `type` +* `public` +* `payload` +* `created_at` +* `repo`: `Repository` +* `actor`: `NamedUser` +* `org`: `Organization` + Class `Gist` ============ @@ -412,6 +429,10 @@ Comments * `get_comment( id )`: `IssueComment` * `create_comment( body )`: `IssueComment` +Events +------ +* `get_events()`: list of `Event` + Class `IssueComment` ==================== @@ -517,6 +538,13 @@ Following --------- * `get_following()`: list of `NamedUser` +Events +------ +* `get_events()`: list of `Event` +* `get_public_events()`: list of `Event` +* `get_received_events()`: list of `Event` +* `get_public_received_events()`: list of `Event` + Orgs ---- * `get_orgs()`: list of `Organization` @@ -585,6 +613,10 @@ Members * `has_in_members( member )`: `bool` * `member`: `NamedUser` +Events +------ +* `get_events()`: list of `Event` + Repos ----- * `get_repos( [type] )`: list of `Repository` @@ -725,6 +757,12 @@ Attributes * `parent`: `Repository` * `source`: `Repository` +Events +------ +* `get_events()`: list of `Event` +* `get_network_events()`: list of `Event` +* `get_issues_events()`: list of `Event` + Forks ----- * `get_forks()`: list of `Repository` diff --git a/github/GithubObjects.py b/github/GithubObjects.py index b8217841..35f6cc85 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -3,6 +3,13 @@ import urllib from GithubObject import * +Event = GithubObject( + "Event", + InternalSimpleAttributes( + "type", "public", "payload", "created_at", "id", + ), +) + def __testHook( hook ): hook._github._statusRequest( "POST", hook._baseUrl + "/test", None, None ) Hook = GithubObject( @@ -67,6 +74,10 @@ AuthenticatedUser = GithubObject( ElementGetable( [ "id" ], [] ), ElementCreatable( [ "title", "key" ], [] ), ), + ExternalListOfObjects( "events", "event", Event, + ListGetable( [], [] ), + url = "/events" + ), ) NamedUser = GithubObject( @@ -110,6 +121,38 @@ NamedUser._addAttributePolicy( ListGetable( [], [] ) ) ) +NamedUser._addAttributePolicy( + ExternalListOfObjects( "events", "event", Event, + ListGetable( [], [] ) + ), +) +def __getPublicEvents( user ): + return [ + Event( user._github, attributes ) + for attributes + in user._github._dataRequest( "GET", user._baseUrl + "/events/public", None, None ) + ] +NamedUser._addAttributePolicy( + MethodFromCallable( "get_public_events", [], [], __getPublicEvents, SimpleTypePolicy( "list of `Event`" ) ) +) +def __getReceivedEvents( user ): + return [ + Event( user._github, attributes ) + for attributes + in user._github._dataRequest( "GET", user._baseUrl + "/received_events", None, None ) + ] +NamedUser._addAttributePolicy( + MethodFromCallable( "get_received_events", [], [], __getReceivedEvents, SimpleTypePolicy( "list of `Event`" ) ) +) +def __getPublicReceivedEvents( user ): + return [ + Event( user._github, attributes ) + for attributes + in user._github._dataRequest( "GET", user._baseUrl + "/received_events/public", None, None ) + ] +NamedUser._addAttributePolicy( + MethodFromCallable( "get_public_received_events", [], [], __getPublicReceivedEvents, SimpleTypePolicy( "list of `Event`" ) ) +) Organization = GithubObject( "Organization", @@ -135,6 +178,9 @@ Organization = GithubObject( ElementRemovable(), ElementHasable() ), + ExternalListOfObjects( "events", "event", Event, + ListGetable( [], [] ) + ), ) AuthenticatedUser._addAttributePolicy( @@ -270,6 +316,9 @@ Issue = GithubObject( ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingReferedRepo ), ElementCreatable( [ "body" ], [], __modifyAttributesForObjectsReferingReferedRepo ), ), + ExternalListOfObjects( "events", "event", Event, + ListGetable( [], [] ) + ), ) Download = GithubObject( @@ -411,6 +460,29 @@ Repository = GithubObject( ) Repository._addAttributePolicy( InternalObjectAttribute( "parent", Repository ) ) Repository._addAttributePolicy( InternalObjectAttribute( "source", Repository ) ) +Repository._addAttributePolicy( + ExternalListOfObjects( "events", "event", Event, + ListGetable( [], [] ) + ), +) +def __getNetworkEvents( repo ): + return [ + Event( repo._github, attributes ) + for attributes + in repo._github._dataRequest( "GET", repo._baseUrl + "/events", None, None ) + ] +def __getIssuesEvents( repo ): + return [ + Event( repo._github, attributes ) + for attributes + in repo._github._dataRequest( "GET", repo._baseUrl + "/issues/events", None, None ) + ] +Repository._addAttributePolicy( + MethodFromCallable( "get_network_events", [], [], __getNetworkEvents, SimpleTypePolicy( "list of `Event`" ) ) +) +Repository._addAttributePolicy( + MethodFromCallable( "get_issues_events", [], [], __getNetworkEvents, SimpleTypePolicy( "list of `Event`" ) ) +) Repository._addAttributePolicy( ExternalListOfObjects( "forks", "fork", Repository, ListGetable( [], [] ) @@ -657,3 +729,13 @@ def __getStaredGists( user ): AuthenticatedUser._addAttributePolicy( MethodFromCallable( "get_starred_gists", [], [], __getStaredGists, SimpleTypePolicy( "list of `Gist`" ) ), ) + +Event._addAttributePolicy( + InternalObjectAttribute( "repo", Repository ), +) +Event._addAttributePolicy( + InternalObjectAttribute( "actor", NamedUser ), +) +Event._addAttributePolicy( + InternalObjectAttribute( "org", Organization ), +)