diff --git a/ReferenceOfApis.md b/ReferenceOfApis.md index b5cc3eee..df596c54 100644 --- a/ReferenceOfApis.md +++ b/ReferenceOfApis.md @@ -220,14 +220,14 @@ API `/repos/:user/:repo/git/trees/:sha?recursive=1` API `/repos/:user/:repo/hooks` ============================== -* GET: (TODO SOON) -* POST: (TODO SOON) +* GET: `Repository.get_hooks` +* POST: `Repository.create_hook` API `/repos/:user/:repo/hooks/:id` ================================== -* GET: (TODO SOON) -* PATCH: (TODO SOON) -* DELETE: (TODO SOON) +* GET: `Repository.get_hook` +* PATCH: `Hook.edit` +* DELETE: `Hook.delete` API `/repos/:user/:repo/hooks/:id/test` ======================================= diff --git a/ReferenceOfClasses.md b/ReferenceOfClasses.md index d26aed04..88be7b4a 100644 --- a/ReferenceOfClasses.md +++ b/ReferenceOfClasses.md @@ -341,6 +341,20 @@ Attributes * `url` * `tree` +Class `Hook` +============ + +Attributes +---------- + +Modification +------------ +* `edit()` + +Deletion +-------- +* `delete()` + Class `Issue` ============= @@ -710,6 +724,12 @@ Languages --------- * `get_languages()`: dictionary of strings to integers +Hooks +----- +* `get_hooks()`: list of `Hook` +* `get_hook( id )`: `Hook` +* `create_hook()`: `Hook` + Keys ---- * `get_keys()`: list of `RepositoryKey` diff --git a/github/GithubObjects.py b/github/GithubObjects.py index 7d925d51..3ff85f2c 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -3,6 +3,17 @@ import urllib from GithubObject import * +Hook = GithubObject( + "Hook", + BaseUrl( lambda obj: obj._repo._baseUrl + "/hooks/" + obj.id ), + InternalSimpleAttributes( + ### @todo + "_repo", ### Ugly hack + ), + Editable( [], [] ), #### @todo + Deletable(), +) + Authorization = GithubObject( "Authorization", BaseUrl( lambda obj: "/authorizations/" + str( obj.id ) ), ### @todo make the lambda return a tuple, and BaseUrl convert elements to strings and join them with "/" @@ -408,6 +419,11 @@ Repository._addAttributePolicy( SeveralAttributePolicies( [ ExternalSimpleAttribute( "languages", "dictionary of strings to integers" ) ], "Languages" ) ) Repository._addAttributePolicy( SeveralAttributePolicies( [ + ExternalListOfObjects( "hooks", "hook", Hook, + ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ), + ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingRepo ), + ElementCreatable( [], [], __modifyAttributesForObjectsReferingReferedRepo ), ### @todo + ), ExternalListOfObjects( "keys", "key", RepositoryKey, ListGetable( [], [], __modifyAttributesForObjectsReferingRepo ), ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingRepo ),