From f02c938974b0faa620934059cb677ea2558a5d67 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Thu, 1 Mar 2012 07:53:32 +0100 Subject: [PATCH] UserKey: step 1 --- ReferenceOfApis.md | 10 +++++----- ReferenceOfClasses.md | 20 ++++++++++++++++++++ github/GithubObjects.py | 17 ++++++++++++++++- 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/ReferenceOfApis.md b/ReferenceOfApis.md index 8d350016..cfc219b6 100644 --- a/ReferenceOfApis.md +++ b/ReferenceOfApis.md @@ -417,14 +417,14 @@ API `/user/following/:user` API `/user/keys` ================ -* GET: (TODO SOON) -* POST: (TODO SOON) +* GET: `AuthenticatedUser.get_keys` +* POST: `AuthenticatedUser.create_key` API `/user/keys/:id` ==================== -* GET: (TODO SOON) -* PATCH: (TODO SOON) -* DELETE: (TODO SOON) +* GET: `AuthenticatedUser.get_key` +* PATCH: `UserKey.edit` +* DELETE: `UserKey.delete` API `/user/orgs` ================ diff --git a/ReferenceOfClasses.md b/ReferenceOfClasses.md index 11deaffe..d86ab9e4 100644 --- a/ReferenceOfClasses.md +++ b/ReferenceOfClasses.md @@ -64,6 +64,12 @@ Authorizations * `get_authorization( id )`: `Authorization` * `create_authorization()`: `Authorization` +Keys +---- +* `get_keys()`: list of `UserKey` +* `get_key( id )`: `UserKey` +* `create_key()`: `UserKey` + Followers --------- * `get_followers()`: list of `NamedUser` @@ -841,4 +847,18 @@ Repos * `has_in_repos( repo )`: `bool` * `repo`: `Repository` +Class `UserKey` +=============== + +Attributes +---------- + +Modification +------------ +* `edit()` + +Deletion +-------- +* `delete()` + diff --git a/github/GithubObjects.py b/github/GithubObjects.py index 5b935e06..a412e588 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -5,7 +5,17 @@ from GithubObject import * Authorization = GithubObject( "Authorization", - BaseUrl( lambda obj: "/authorizations/" + str( obj.id ) ), + BaseUrl( lambda obj: "/authorizations/" + str( obj.id ) ), ### @todo make the lambda return a tuple, and BaseUrl convert elements to strings and join them with "/" + InternalSimpleAttributes( + ### @todo + ), + Editable( [], [] ), ### @todo + Deletable(), +) + +UserKey = GithubObject( + "UserKey", + BaseUrl( lambda obj: "/user/keys/" + str( obj.id ) ), InternalSimpleAttributes( ### @todo ), @@ -36,6 +46,11 @@ AuthenticatedUser = GithubObject( ElementCreatable( [], [] ), ### @todo ### url = "/authorizations", ### @todo ), + ExternalListOfObjects( "keys", "key", UserKey, + ListGetable( [], [] ), + ElementGetable( [ "id" ], [] ), + ElementCreatable( [], [] ), ### @todo + ), ) NamedUser = GithubObject(