From 3b523190a0495c9ea25d589c8ff01d5a92a62751 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Thu, 23 Feb 2012 21:38:43 +0000 Subject: [PATCH 1/6] Todos for authorizations and keys --- ReferenceOfApis.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/ReferenceOfApis.md b/ReferenceOfApis.md index 5c071266..8454c441 100644 --- a/ReferenceOfApis.md +++ b/ReferenceOfApis.md @@ -1,13 +1,13 @@ API `/authorizations` ===================== -* GET: (TODO) -* POST: (TODO) +* GET: (TODO SOON) +* POST: (TODO SOON) API `/authorizations/:id` ========================= -* GET: (TODO) -* PATCH: (TODO) -* DELETE: (TODO) +* GET: (TODO SOON) +* PATCH: (TODO SOON) +* DELETE: (TODO SOON) API `/events` ============= @@ -279,14 +279,14 @@ API `/repos/:user/:repo/issues/events/:id` API `/repos/:user/:repo/keys` ============================= -* GET: (TODO) -* POST: (TODO) +* GET: (TODO SOON) +* POST: (TODO SOON) API `/repos/:user/:repo/keys/:id` ================================= -* GET: (TODO) -* PATCH: (TODO) -* DELETE: (TODO) +* GET: (TODO SOON) +* PATCH: (TODO SOON) +* DELETE: (TODO SOON) API `/repos/:user/:repo/labels` =============================== @@ -417,14 +417,14 @@ API `/user/following/:user` API `/user/keys` ================ -* GET: (TODO) -* POST: (TODO) +* GET: (TODO SOON) +* POST: (TODO SOON) API `/user/keys/:id` ==================== -* GET: (TODO) -* PATCH: (TODO) -* DELETE: (TODO) +* GET: (TODO SOON) +* PATCH: (TODO SOON) +* DELETE: (TODO SOON) API `/user/orgs` ================ From b53f96bafae6c6502ffcfd029338df2f02ac0faa Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Thu, 1 Mar 2012 07:50:15 +0100 Subject: [PATCH 2/6] Authorizations: step 1 --- ReferenceOfApis.md | 10 +++++----- ReferenceOfClasses.md | 20 ++++++++++++++++++++ github/GithubObjects.py | 16 ++++++++++++++++ 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/ReferenceOfApis.md b/ReferenceOfApis.md index 8454c441..8d350016 100644 --- a/ReferenceOfApis.md +++ b/ReferenceOfApis.md @@ -1,13 +1,13 @@ API `/authorizations` ===================== -* GET: (TODO SOON) -* POST: (TODO SOON) +* GET: `AuthenticatedUser.get_authorizations` +* POST: `AuthenticatedUser.create_authorization` API `/authorizations/:id` ========================= -* GET: (TODO SOON) -* PATCH: (TODO SOON) -* DELETE: (TODO SOON) +* GET: `AuthenticatedUser.get_authorization` +* PATCH: `Authorization.edit` +* DELETE: `Authorization.delete` API `/events` ============= diff --git a/ReferenceOfClasses.md b/ReferenceOfClasses.md index 1b9079b9..11deaffe 100644 --- a/ReferenceOfClasses.md +++ b/ReferenceOfClasses.md @@ -58,6 +58,12 @@ Emails * `remove_from_emails( email, ... )` * `email`: string +Authorizations +-------------- +* `get_authorizations()`: list of `Authorization` +* `get_authorization( id )`: `Authorization` +* `create_authorization()`: `Authorization` + Followers --------- * `get_followers()`: list of `NamedUser` @@ -102,6 +108,20 @@ Gists * `create_gist( public, files, [description] )`: `Gist` * `get_starred_gists()`: list of `Gist` +Class `Authorization` +===================== + +Attributes +---------- + +Modification +------------ +* `edit()` + +Deletion +-------- +* `delete()` + Class `Branch` ============== diff --git a/github/GithubObjects.py b/github/GithubObjects.py index f8d1e603..5b935e06 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -3,6 +3,16 @@ import urllib from GithubObject import * +Authorization = GithubObject( + "Authorization", + BaseUrl( lambda obj: "/authorizations/" + str( obj.id ) ), + InternalSimpleAttributes( + ### @todo + ), + Editable( [], [] ), ### @todo + Deletable(), +) + AuthenticatedUser = GithubObject( "AuthenticatedUser", BaseUrl( lambda obj: "/user" ), @@ -20,6 +30,12 @@ AuthenticatedUser = GithubObject( SeveralElementsAddable(), SeveralElementsRemovable() ), + ExternalListOfObjects( "authorizations", "authorization", Authorization, + ListGetable( [], [] ), + ElementGetable( [ "id" ], [] ), + ElementCreatable( [], [] ), ### @todo + ### url = "/authorizations", ### @todo + ), ) NamedUser = GithubObject( From f02c938974b0faa620934059cb677ea2558a5d67 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Thu, 1 Mar 2012 07:53:32 +0100 Subject: [PATCH 3/6] 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( From 2ea7ce772342479c90ca646f837ba92d6a02a8f5 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Thu, 1 Mar 2012 07:59:02 +0100 Subject: [PATCH 4/6] RepositoryKey: first step --- ReferenceOfApis.md | 10 +++++----- ReferenceOfClasses.md | 20 ++++++++++++++++++++ github/GithubObjects.py | 16 ++++++++++++++++ 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/ReferenceOfApis.md b/ReferenceOfApis.md index cfc219b6..fa94f5e2 100644 --- a/ReferenceOfApis.md +++ b/ReferenceOfApis.md @@ -279,14 +279,14 @@ API `/repos/:user/:repo/issues/events/:id` API `/repos/:user/:repo/keys` ============================= -* GET: (TODO SOON) -* POST: (TODO SOON) +* GET: `Repository.get_keys` +* POST: `Repository.create_key` API `/repos/:user/:repo/keys/:id` ================================= -* GET: (TODO SOON) -* PATCH: (TODO SOON) -* DELETE: (TODO SOON) +* GET: `Repository.get_key` +* PATCH: `RepositoryKey.edit` +* DELETE: `RepositoryKey.delete` API `/repos/:user/:repo/labels` =============================== diff --git a/ReferenceOfClasses.md b/ReferenceOfClasses.md index d86ab9e4..b8a059e8 100644 --- a/ReferenceOfClasses.md +++ b/ReferenceOfClasses.md @@ -701,6 +701,12 @@ Languages --------- * `get_languages()`: dictionary of strings to integers +Keys +---- +* `get_keys()`: list of `RepositoryKey` +* `get_key( id )`: `RepositoryKey` +* `create_key()`: `RepositoryKey` + Collaborators ------------- * `get_collaborators()`: list of `NamedUser` @@ -797,6 +803,20 @@ Teams ----- * `get_teams()`: list of `Team` +Class `RepositoryKey` +===================== + +Attributes +---------- + +Modification +------------ +* `edit()` + +Deletion +-------- +* `delete()` + Class `Tag` =========== diff --git a/github/GithubObjects.py b/github/GithubObjects.py index a412e588..2ae7a165 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -368,6 +368,17 @@ PullRequest = GithubObject( ), ) +RepositoryKey = GithubObject( + "RepositoryKey", + BaseUrl( lambda obj: obj._repo._baseUrl + "/keys/" + str( obj.id ) ), + InternalSimpleAttributes( + ### @todo + "_repo", ### Ugly hack + ), + Editable( [], [] ), ### @todo + Deletable() +) + Repository = GithubObject( "Repository", BaseUrl( lambda obj: "/repos/" + obj.owner.login + "/" + obj.name ), @@ -397,6 +408,11 @@ Repository._addAttributePolicy( SeveralAttributePolicies( [ ExternalSimpleAttribute( "languages", "dictionary of strings to integers" ) ], "Languages" ) ) Repository._addAttributePolicy( SeveralAttributePolicies( [ + ExternalListOfObjects( "keys", "key", RepositoryKey, + ListGetable( [], [] ), + ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingRepo ), + ElementCreatable( [], [] ), ### @todo + ), ExternalListOfObjects( "collaborators", "collaborator", NamedUser, ListGetable( [], [] ), ElementAddable(), From 3bf073954ca1cf7cf35393fcddd8424c35d92d7c Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Thu, 1 Mar 2012 17:53:53 +0000 Subject: [PATCH 5/6] Authorizations: step 2 --- ReferenceOfClasses.md | 13 +++++++++++-- github/GithubObjects.py | 9 +++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ReferenceOfClasses.md b/ReferenceOfClasses.md index b8a059e8..687e4a28 100644 --- a/ReferenceOfClasses.md +++ b/ReferenceOfClasses.md @@ -62,7 +62,7 @@ Authorizations -------------- * `get_authorizations()`: list of `Authorization` * `get_authorization( id )`: `Authorization` -* `create_authorization()`: `Authorization` +* `create_authorization( [scopes, note, note_url] )`: `Authorization` Keys ---- @@ -119,10 +119,19 @@ Class `Authorization` Attributes ---------- +* `id` +* `url` +* `scopes` +* `token` +* `app` +* `note` +* `note_url` +* `updated_at` +* `created_at` Modification ------------ -* `edit()` +* `edit( [scopes, add_scopes, remove_scopes, note, note_url] )` Deletion -------- diff --git a/github/GithubObjects.py b/github/GithubObjects.py index 2ae7a165..051800cb 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -7,9 +7,10 @@ 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 "/" InternalSimpleAttributes( - ### @todo + "id", "url", "scopes", "token", "app", "note", "note_url", "updated_at", + "created_at", ), - Editable( [], [] ), ### @todo + Editable( [], [ "scopes", "add_scopes", "remove_scopes", "note", "note_url" ] ), Deletable(), ) @@ -43,8 +44,8 @@ AuthenticatedUser = GithubObject( ExternalListOfObjects( "authorizations", "authorization", Authorization, ListGetable( [], [] ), ElementGetable( [ "id" ], [] ), - ElementCreatable( [], [] ), ### @todo - ### url = "/authorizations", ### @todo + ElementCreatable( [], [ "scopes", "note", "note_url" ] ), + url = "/authorizations", ), ExternalListOfObjects( "keys", "key", UserKey, ListGetable( [], [] ), From df1143107cb3f59b53428c7fd1786def06ed50d6 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Thu, 1 Mar 2012 17:56:50 +0000 Subject: [PATCH 6/6] Keys: step 2 --- ReferenceOfClasses.md | 16 ++++++++++++---- github/GithubObjects.py | 12 ++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ReferenceOfClasses.md b/ReferenceOfClasses.md index 687e4a28..d26aed04 100644 --- a/ReferenceOfClasses.md +++ b/ReferenceOfClasses.md @@ -68,7 +68,7 @@ Keys ---- * `get_keys()`: list of `UserKey` * `get_key( id )`: `UserKey` -* `create_key()`: `UserKey` +* `create_key( title, key )`: `UserKey` Followers --------- @@ -714,7 +714,7 @@ Keys ---- * `get_keys()`: list of `RepositoryKey` * `get_key( id )`: `RepositoryKey` -* `create_key()`: `RepositoryKey` +* `create_key( title, key )`: `RepositoryKey` Collaborators ------------- @@ -817,10 +817,14 @@ Class `RepositoryKey` Attributes ---------- +* `url` +* `id` +* `title` +* `key` Modification ------------ -* `edit()` +* `edit( title, key )` Deletion -------- @@ -881,10 +885,14 @@ Class `UserKey` Attributes ---------- +* `url` +* `id` +* `title` +* `key` Modification ------------ -* `edit()` +* `edit( title, key )` Deletion -------- diff --git a/github/GithubObjects.py b/github/GithubObjects.py index 051800cb..b0dca1b0 100644 --- a/github/GithubObjects.py +++ b/github/GithubObjects.py @@ -18,9 +18,9 @@ UserKey = GithubObject( "UserKey", BaseUrl( lambda obj: "/user/keys/" + str( obj.id ) ), InternalSimpleAttributes( - ### @todo + "url", "id", "title", "key", ), - Editable( [], [] ), ### @todo + Editable( [ "title", "key" ], [] ), Deletable(), ) @@ -50,7 +50,7 @@ AuthenticatedUser = GithubObject( ExternalListOfObjects( "keys", "key", UserKey, ListGetable( [], [] ), ElementGetable( [ "id" ], [] ), - ElementCreatable( [], [] ), ### @todo + ElementCreatable( [ "title", "key" ], [] ), ), ) @@ -373,10 +373,10 @@ RepositoryKey = GithubObject( "RepositoryKey", BaseUrl( lambda obj: obj._repo._baseUrl + "/keys/" + str( obj.id ) ), InternalSimpleAttributes( - ### @todo + "url", "id", "title", "key", "_repo", ### Ugly hack ), - Editable( [], [] ), ### @todo + Editable( [ "title", "key" ], [] ), Deletable() ) @@ -412,7 +412,7 @@ Repository._addAttributePolicy( SeveralAttributePolicies( [ ExternalListOfObjects( "keys", "key", RepositoryKey, ListGetable( [], [] ), ElementGetable( [ "id" ], [], __modifyAttributesForObjectsReferingRepo ), - ElementCreatable( [], [] ), ### @todo + ElementCreatable( [ "title", "key" ], [] ), ), ExternalListOfObjects( "collaborators", "collaborator", NamedUser, ListGetable( [], [] ),