From 5b1bfe7c39b0eee560eb300ebfba2e0d300ec795 Mon Sep 17 00:00:00 2001 From: Vincent Jacques Date: Fri, 4 May 2012 14:11:01 +0200 Subject: [PATCH] Fix testCommentCommit (create_xxx, delete, edit) --- IntegrationTest.py | 22 +- .../description.001.normalized.json | 627 +++++++++++++++++- JsonDescriptionOfGithubApiV3/normalize.py | 26 +- github/GithubObjects/AuthenticatedUser.py | 67 +- github/GithubObjects/Authorization.py | 9 +- github/GithubObjects/Commit.py | 19 +- github/GithubObjects/CommitComment.py | 9 +- github/GithubObjects/Download.py | 7 +- github/GithubObjects/Gist.py | 20 +- github/GithubObjects/GistComment.py | 9 +- github/GithubObjects/GitRef.py | 9 +- github/GithubObjects/Hook.py | 9 +- github/GithubObjects/Issue.py | 13 +- github/GithubObjects/IssueComment.py | 9 +- github/GithubObjects/Label.py | 9 +- github/GithubObjects/Milestone.py | 9 +- github/GithubObjects/NamedUser.py | 14 +- github/GithubObjects/Organization.py | 42 +- github/GithubObjects/PullRequest.py | 2 +- github/GithubObjects/PullRequestComment.py | 9 +- github/GithubObjects/Repository.py | 164 ++++- github/GithubObjects/RepositoryKey.py | 9 +- github/GithubObjects/Team.py | 9 +- github/GithubObjects/UserKey.py | 9 +- 24 files changed, 1031 insertions(+), 100 deletions(-) diff --git a/IntegrationTest.py b/IntegrationTest.py index b609442b..4493a263 100644 --- a/IntegrationTest.py +++ b/IntegrationTest.py @@ -230,17 +230,17 @@ class IntegrationTest: assert not r.has_in_collaborators( cobaye ) self.printList( "Collaborators", r.get_collaborators(), lambda m: m.login ) - # def testCommentCommit( self ): - # r = self.g.get_user().get_repo( "TestPyGithub" ) - # c = r.get_commits()[ 0 ] - # self.printList( "Comments", c.get_comments(), lambda c: c.body ) - # com1 = c.create_comment( "Comment created by PyGithub" ) - # self.printList( "Comments", c.get_comments(), lambda c: c.body ) - # com2 = c.create_comment( "Comment also created by PyGithub", path = "ReadMe.md", line = 1 ) - # self.printList( "Comments", c.get_comments(), lambda c: c.body ) - # com2.delete() - # com1.edit( body = "Comment edited by PyGithub" ) - # self.printList( "Comments", c.get_comments(), lambda c: c.body ) + def testCommentCommit( self ): + r = self.g.get_user().get_repo( "TestPyGithub" ) + c = r.get_commits()[ 0 ] + self.printList( "Comments", c.get_comments(), lambda c: c.body ) + com1 = c.create_comment( "Comment created by PyGithub" ) + self.printList( "Comments", c.get_comments(), lambda c: c.body ) + com2 = c.create_comment( "Comment also created by PyGithub", path = "ReadMe.md", line = 1 ) + self.printList( "Comments", c.get_comments(), lambda c: c.body ) + com2.delete() + com1.edit( body = "Comment edited by PyGithub" ) + self.printList( "Comments", c.get_comments(), lambda c: c.body ) # def testCreateForkForOrganization( self ): # o = self.g.get_organization( self.cobayeOrganization ) diff --git a/JsonDescriptionOfGithubApiV3/description.001.normalized.json b/JsonDescriptionOfGithubApiV3/description.001.normalized.json index cc955df4..2dcff910 100644 --- a/JsonDescriptionOfGithubApiV3/description.001.normalized.json +++ b/JsonDescriptionOfGithubApiV3/description.001.normalized.json @@ -294,6 +294,23 @@ "create", "authorization" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/authorizations" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [ { "type": { @@ -468,6 +485,23 @@ "create", "key" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/keys" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [], "type": { "simple": false, @@ -547,6 +581,23 @@ "create", "repo" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/repos" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [ { "type": { @@ -1217,6 +1268,23 @@ "create", "gist" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/gists" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [ { "type": { @@ -1451,8 +1519,10 @@ "request": { "url": [ { - "type": "constant", - "value": "https://api.github.com/user" + "type": "attribute", + "value": [ + "url" + ] } ], "information": "data", @@ -1514,6 +1584,18 @@ "name": [ "delete" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + } + ], + "information": "data", + "verb": "DELETE" + }, "optional_parameters": [], "type": { "simple": true, @@ -1631,6 +1713,23 @@ "create", "comment" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/comments" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [ { "type": { @@ -1816,8 +1915,10 @@ "request": { "url": [ { - "type": "constant", - "value": "https://api.github.com/user" + "type": "attribute", + "value": [ + "url" + ] } ], "information": "data", @@ -1838,6 +1939,18 @@ "name": [ "delete" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + } + ], + "information": "data", + "verb": "DELETE" + }, "optional_parameters": [], "type": { "simple": true, @@ -2019,6 +2132,18 @@ "name": [ "delete" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + } + ], + "information": "data", + "verb": "DELETE" + }, "optional_parameters": [], "type": { "simple": true, @@ -2257,8 +2382,10 @@ "request": { "url": [ { - "type": "constant", - "value": "https://api.github.com/user" + "type": "attribute", + "value": [ + "url" + ] } ], "information": "data", @@ -2296,6 +2423,18 @@ "name": [ "delete" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + } + ], + "information": "data", + "verb": "DELETE" + }, "optional_parameters": [], "type": { "simple": true, @@ -2320,6 +2459,23 @@ "create", "comment" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/comments" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [], "type": { "simple": false, @@ -2516,8 +2672,10 @@ "request": { "url": [ { - "type": "constant", - "value": "https://api.github.com/user" + "type": "attribute", + "value": [ + "url" + ] } ], "information": "data", @@ -2538,6 +2696,18 @@ "name": [ "delete" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + } + ], + "information": "data", + "verb": "DELETE" + }, "optional_parameters": [], "type": { "simple": true, @@ -2703,8 +2873,10 @@ "request": { "url": [ { - "type": "constant", - "value": "https://api.github.com/user" + "type": "attribute", + "value": [ + "url" + ] } ], "information": "data", @@ -2734,6 +2906,18 @@ "name": [ "delete" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + } + ], + "information": "data", + "verb": "DELETE" + }, "optional_parameters": [], "type": { "simple": true, @@ -2939,8 +3123,10 @@ "request": { "url": [ { - "type": "constant", - "value": "https://api.github.com/user" + "type": "attribute", + "value": [ + "url" + ] } ], "information": "data", @@ -2994,6 +3180,18 @@ "name": [ "delete" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + } + ], + "information": "data", + "verb": "DELETE" + }, "optional_parameters": [], "type": { "simple": true, @@ -3168,8 +3366,10 @@ "request": { "url": [ { - "type": "constant", - "value": "https://api.github.com/user" + "type": "attribute", + "value": [ + "url" + ] } ], "information": "data", @@ -3249,6 +3449,23 @@ "create", "comment" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/comments" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [], "type": { "simple": false, @@ -3557,8 +3774,10 @@ "request": { "url": [ { - "type": "constant", - "value": "https://api.github.com/user" + "type": "attribute", + "value": [ + "url" + ] } ], "information": "data", @@ -3579,6 +3798,18 @@ "name": [ "delete" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + } + ], + "information": "data", + "verb": "DELETE" + }, "optional_parameters": [], "type": { "simple": true, @@ -3706,8 +3937,10 @@ "request": { "url": [ { - "type": "constant", - "value": "https://api.github.com/user" + "type": "attribute", + "value": [ + "url" + ] } ], "information": "data", @@ -3728,6 +3961,18 @@ "name": [ "delete" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + } + ], + "information": "data", + "verb": "DELETE" + }, "optional_parameters": [], "type": { "simple": true, @@ -3841,8 +4086,10 @@ "request": { "url": [ { - "type": "constant", - "value": "https://api.github.com/user" + "type": "attribute", + "value": [ + "url" + ] } ], "information": "data", @@ -3888,6 +4135,18 @@ "name": [ "delete" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + } + ], + "information": "data", + "verb": "DELETE" + }, "optional_parameters": [], "type": { "simple": true, @@ -4411,6 +4670,23 @@ "create", "gist" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/gists" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [ { "type": { @@ -4716,8 +4992,10 @@ "request": { "url": [ { - "type": "constant", - "value": "https://api.github.com/user" + "type": "attribute", + "value": [ + "url" + ] } ], "information": "data", @@ -5130,6 +5408,23 @@ "create", "repo" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/repos" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [ { "type": { @@ -5301,6 +5596,23 @@ "create", "team" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/teams" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [ { "type": { @@ -5605,8 +5917,10 @@ "request": { "url": [ { - "type": "constant", - "value": "https://api.github.com/user" + "type": "attribute", + "value": [ + "url" + ] } ], "information": "data", @@ -5914,8 +6228,10 @@ "request": { "url": [ { - "type": "constant", - "value": "https://api.github.com/user" + "type": "attribute", + "value": [ + "url" + ] } ], "information": "data", @@ -5936,6 +6252,18 @@ "name": [ "delete" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + } + ], + "information": "data", + "verb": "DELETE" + }, "optional_parameters": [], "type": { "simple": true, @@ -6287,8 +6615,10 @@ "request": { "url": [ { - "type": "constant", - "value": "https://api.github.com/user" + "type": "attribute", + "value": [ + "url" + ] } ], "information": "data", @@ -6740,6 +7070,23 @@ "create", "download" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/downloads" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [ { "type": { @@ -6906,6 +7253,23 @@ "create", "git_blob" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/git_blobs" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [], "type": { "simple": false, @@ -6970,6 +7334,23 @@ "create", "git_commit" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/git_commits" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [ { "type": { @@ -7043,6 +7424,23 @@ "create", "git_ref" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/git_refs" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [], "type": { "simple": false, @@ -7146,6 +7544,23 @@ "create", "git_tag" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/git_tags" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [ { "type": { @@ -7203,6 +7618,23 @@ "create", "git_tree" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/git_trees" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [ { "type": { @@ -7277,6 +7709,23 @@ "create", "hook" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/hooks" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [ { "type": { @@ -7373,6 +7822,23 @@ "create", "issue" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/issues" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [ { "type": { @@ -7613,6 +8079,23 @@ "create", "key" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/keys" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [], "type": { "simple": false, @@ -7700,6 +8183,23 @@ "create", "label" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/labels" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [], "type": { "simple": false, @@ -7779,6 +8279,23 @@ "create", "milestone" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + }, + { + "type": "constant", + "value": "/milestones" + } + ], + "information": "status", + "post_parameters": true, + "verb": "POST" + }, "optional_parameters": [ { "type": { @@ -8176,8 +8693,10 @@ "request": { "url": [ { - "type": "constant", - "value": "https://api.github.com/user" + "type": "attribute", + "value": [ + "url" + ] } ], "information": "data", @@ -8198,6 +8717,18 @@ "name": [ "delete" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + } + ], + "information": "data", + "verb": "DELETE" + }, "optional_parameters": [], "type": { "simple": true, @@ -8317,8 +8848,10 @@ "request": { "url": [ { - "type": "constant", - "value": "https://api.github.com/user" + "type": "attribute", + "value": [ + "url" + ] } ], "information": "data", @@ -8348,6 +8881,18 @@ "name": [ "delete" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + } + ], + "information": "data", + "verb": "DELETE" + }, "optional_parameters": [], "type": { "simple": true, @@ -8754,8 +9299,10 @@ "request": { "url": [ { - "type": "constant", - "value": "https://api.github.com/user" + "type": "attribute", + "value": [ + "url" + ] } ], "information": "data", @@ -8793,6 +9340,18 @@ "name": [ "delete" ], + "request": { + "url": [ + { + "type": "attribute", + "value": [ + "url" + ] + } + ], + "information": "data", + "verb": "DELETE" + }, "optional_parameters": [], "type": { "simple": true, diff --git a/JsonDescriptionOfGithubApiV3/normalize.py b/JsonDescriptionOfGithubApiV3/normalize.py index 33e7478a..77e23b5d 100644 --- a/JsonDescriptionOfGithubApiV3/normalize.py +++ b/JsonDescriptionOfGithubApiV3/normalize.py @@ -131,7 +131,18 @@ class Collection: assert desc[ "add_several_elements" ] is True self.methods.append( Function( { "name": [ "add", "to" ] + name, "type": "void", "group": desc[ "name" ], "variadic_parameter": { "name": desc[ "singular_name" ], "type": desc[ "type" ] } } ) ) if "create_element" in desc: - self.methods.append( Function( desc[ "create_element" ], { "name": [ "create", desc[ "singular_name" ] ], "type": desc[ "type" ], "group": desc[ "name" ] } ) ) + self.methods.append( Function( + desc[ "create_element" ], + { "name": [ "create", desc[ "singular_name" ] ], "type": desc[ "type" ], "group": desc[ "name" ] }, + { + "request": { + "verb": "POST", + "url": [ { "type": "attribute", "value": [ "url" ] }, { "type": "constant", "value": "/" + desc[ "name" ] } ], + "information": "status", + "post_parameters": True, + } + } + ) ) if "delete_list" in desc: assert desc[ "delete_list" ] is True self.methods.append( Function( { "name": [ "delete" ] + name, "type": "void", "group": desc[ "name" ] } ) ) @@ -230,14 +241,23 @@ class Class: { "request": { "verb": "PATCH", - "url": [ { "type": "constant", "value": "https://api.github.com/user" } ], # @todo + "url": [ { "type": "constant", "value": "https://api.github.com/user" } if desc[ "name" ] == "AuthenticatedUser" else { "type": "attribute", "value": [ "url" ] } ], # @todo "post_parameters": True, # @todo "information": "data", }, } ) ) if "delete" in desc: - self.methods.append( Function( { "name": [ "delete" ], "type": "void", "group": "deletion" } ) ) + self.methods.append( Function( + { "name": [ "delete" ], "type": "void", "group": "deletion" }, + { + "request": { + "verb": "DELETE", + "url": [ { "type": "attribute", "value": [ "url" ] } ], + "information": "data", + }, + } + ) ) for collection in [ Collection( collection ) for collection in desc[ "collections" ] ]: self.methods += collection.methods if "additional_methods" in desc: diff --git a/github/GithubObjects/AuthenticatedUser.py b/github/GithubObjects/AuthenticatedUser.py index 6c7b2fb4..c9e9b76e 100644 --- a/github/GithubObjects/AuthenticatedUser.py +++ b/github/GithubObjects/AuthenticatedUser.py @@ -164,7 +164,21 @@ class AuthenticatedUser( object ): ) def create_authorization( self, scopes = None, note = None, note_url = None ): - pass + post_parameters = { + } + if scopes is not None: + post_parameters[ "scopes" ] = scopes + if note is not None: + post_parameters[ "note" ] = note + if note_url is not None: + post_parameters[ "note_url" ] = note_url + status, headers, data = self.__requester.request( + "POST", + self.url + "/authorizations", + None, + post_parameters + ) + return Authorization.Authorization( self.__requester, data, lazy = True ) def create_fork( self, repo ): status, headers, data = self.__requester.request( @@ -176,13 +190,58 @@ class AuthenticatedUser( object ): return Repository.Repository( self.__requester, data, lazy = True ) def create_gist( self, public, files, description = None ): - pass + post_parameters = { + "public": public, + "files": files, + } + if description is not None: + post_parameters[ "description" ] = description + status, headers, data = self.__requester.request( + "POST", + self.url + "/gists", + None, + post_parameters + ) + return Gist.Gist( self.__requester, data, lazy = True ) def create_key( self, title, key ): - pass + post_parameters = { + "title": title, + "key": key, + } + status, headers, data = self.__requester.request( + "POST", + self.url + "/keys", + None, + post_parameters + ) + return UserKey.UserKey( self.__requester, data, lazy = True ) def create_repo( self, name, description = None, homepage = None, private = None, has_issues = None, has_wiki = None, has_downloads = None, team_id = None ): - pass + post_parameters = { + "name": name, + } + if description is not None: + post_parameters[ "description" ] = description + if homepage is not None: + post_parameters[ "homepage" ] = homepage + if private is not None: + post_parameters[ "private" ] = private + if has_issues is not None: + post_parameters[ "has_issues" ] = has_issues + if has_wiki is not None: + post_parameters[ "has_wiki" ] = has_wiki + if has_downloads is not None: + post_parameters[ "has_downloads" ] = has_downloads + if team_id is not None: + post_parameters[ "team_id" ] = team_id + status, headers, data = self.__requester.request( + "POST", + self.url + "/repos", + None, + post_parameters + ) + return Repository.Repository( self.__requester, data, lazy = True ) def edit( self, name = None, email = None, blog = None, company = None, location = None, hireable = None, bio = None ): post_parameters = { diff --git a/github/GithubObjects/Authorization.py b/github/GithubObjects/Authorization.py index ffffe543..1fbcd81c 100644 --- a/github/GithubObjects/Authorization.py +++ b/github/GithubObjects/Authorization.py @@ -57,7 +57,12 @@ class Authorization( object ): return self.__url def delete( self ): - pass + status, headers, data = self.__requester.request( + "DELETE", + self.url, + None, + None + ) def edit( self, scopes = None, add_scopes = None, remove_scopes = None, note = None, note_url = None ): post_parameters = { @@ -74,7 +79,7 @@ class Authorization( object ): post_parameters[ "note_url" ] = note_url status, headers, data = self.__requester.request( "PATCH", - "https://api.github.com/user", + self.url, None, post_parameters ) diff --git a/github/GithubObjects/Commit.py b/github/GithubObjects/Commit.py index b947000f..e48388ad 100644 --- a/github/GithubObjects/Commit.py +++ b/github/GithubObjects/Commit.py @@ -55,7 +55,24 @@ class Commit( object ): return self.__url def create_comment( self, body, commit_id = None, line = None, path = None, position = None ): - pass + post_parameters = { + "body": body, + } + if commit_id is not None: + post_parameters[ "commit_id" ] = commit_id + if line is not None: + post_parameters[ "line" ] = line + if path is not None: + post_parameters[ "path" ] = path + if position is not None: + post_parameters[ "position" ] = position + status, headers, data = self.__requester.request( + "POST", + self.url + "/comments", + None, + post_parameters + ) + return CommitComment.CommitComment( self.__requester, data, lazy = True ) def get_comments( self ): status, headers, data = self.__requester.request( diff --git a/github/GithubObjects/CommitComment.py b/github/GithubObjects/CommitComment.py index 1b21f001..ee22ba77 100644 --- a/github/GithubObjects/CommitComment.py +++ b/github/GithubObjects/CommitComment.py @@ -68,7 +68,12 @@ class CommitComment( object ): return self.__user def delete( self ): - pass + status, headers, data = self.__requester.request( + "DELETE", + self.url, + None, + None + ) def edit( self, body ): post_parameters = { @@ -76,7 +81,7 @@ class CommitComment( object ): } status, headers, data = self.__requester.request( "PATCH", - "https://api.github.com/user", + self.url, None, post_parameters ) diff --git a/github/GithubObjects/Download.py b/github/GithubObjects/Download.py index 594473bc..fd3b360a 100644 --- a/github/GithubObjects/Download.py +++ b/github/GithubObjects/Download.py @@ -112,7 +112,12 @@ class Download( object ): return self.__url def delete( self ): - pass + status, headers, data = self.__requester.request( + "DELETE", + self.url, + None, + None + ) def __initAttributes( self ): self.__accesskeyid = None diff --git a/github/GithubObjects/Gist.py b/github/GithubObjects/Gist.py index 8ccd50ba..64ce58a2 100644 --- a/github/GithubObjects/Gist.py +++ b/github/GithubObjects/Gist.py @@ -85,13 +85,27 @@ class Gist( object ): return self.__user def create_comment( self, body ): - pass + post_parameters = { + "body": body, + } + status, headers, data = self.__requester.request( + "POST", + self.url + "/comments", + None, + post_parameters + ) + return GistComment.GistComment( self.__requester, data, lazy = True ) def create_fork( self ): pass def delete( self ): - pass + status, headers, data = self.__requester.request( + "DELETE", + self.url, + None, + None + ) def edit( self, description = None, files = None ): post_parameters = { @@ -102,7 +116,7 @@ class Gist( object ): post_parameters[ "files" ] = files status, headers, data = self.__requester.request( "PATCH", - "https://api.github.com/user", + self.url, None, post_parameters ) diff --git a/github/GithubObjects/GistComment.py b/github/GithubObjects/GistComment.py index e170b738..037b9482 100644 --- a/github/GithubObjects/GistComment.py +++ b/github/GithubObjects/GistComment.py @@ -43,7 +43,12 @@ class GistComment( object ): return self.__user def delete( self ): - pass + status, headers, data = self.__requester.request( + "DELETE", + self.url, + None, + None + ) def edit( self, body ): post_parameters = { @@ -51,7 +56,7 @@ class GistComment( object ): } status, headers, data = self.__requester.request( "PATCH", - "https://api.github.com/user", + self.url, None, post_parameters ) diff --git a/github/GithubObjects/GitRef.py b/github/GithubObjects/GitRef.py index 2d24dd71..a77e2d35 100644 --- a/github/GithubObjects/GitRef.py +++ b/github/GithubObjects/GitRef.py @@ -27,7 +27,12 @@ class GitRef( object ): return self.__url def delete( self ): - pass + status, headers, data = self.__requester.request( + "DELETE", + self.url, + None, + None + ) def edit( self, sha, force = None ): post_parameters = { @@ -37,7 +42,7 @@ class GitRef( object ): post_parameters[ "force" ] = force status, headers, data = self.__requester.request( "PATCH", - "https://api.github.com/user", + self.url, None, post_parameters ) diff --git a/github/GithubObjects/Hook.py b/github/GithubObjects/Hook.py index 90ead1bc..67250ad5 100644 --- a/github/GithubObjects/Hook.py +++ b/github/GithubObjects/Hook.py @@ -57,7 +57,12 @@ class Hook( object ): return self.__url def delete( self ): - pass + status, headers, data = self.__requester.request( + "DELETE", + self.url, + None, + None + ) def edit( self, name, config, events = None, add_events = None, remove_events = None, active = None ): post_parameters = { @@ -74,7 +79,7 @@ class Hook( object ): post_parameters[ "active" ] = active status, headers, data = self.__requester.request( "PATCH", - "https://api.github.com/user", + self.url, None, post_parameters ) diff --git a/github/GithubObjects/Issue.py b/github/GithubObjects/Issue.py index 9e5b62e4..f49f7b30 100644 --- a/github/GithubObjects/Issue.py +++ b/github/GithubObjects/Issue.py @@ -105,7 +105,16 @@ class Issue( object ): pass def create_comment( self, body ): - pass + post_parameters = { + "body": body, + } + status, headers, data = self.__requester.request( + "POST", + self.url + "/comments", + None, + post_parameters + ) + return IssueComment.IssueComment( self.__requester, data, lazy = True ) def delete_labels( self ): pass @@ -127,7 +136,7 @@ class Issue( object ): post_parameters[ "labels" ] = labels status, headers, data = self.__requester.request( "PATCH", - "https://api.github.com/user", + self.url, None, post_parameters ) diff --git a/github/GithubObjects/IssueComment.py b/github/GithubObjects/IssueComment.py index ecfd333d..2e802637 100644 --- a/github/GithubObjects/IssueComment.py +++ b/github/GithubObjects/IssueComment.py @@ -43,7 +43,12 @@ class IssueComment( object ): return self.__user def delete( self ): - pass + status, headers, data = self.__requester.request( + "DELETE", + self.url, + None, + None + ) def edit( self, body ): post_parameters = { @@ -51,7 +56,7 @@ class IssueComment( object ): } status, headers, data = self.__requester.request( "PATCH", - "https://api.github.com/user", + self.url, None, post_parameters ) diff --git a/github/GithubObjects/Label.py b/github/GithubObjects/Label.py index 70c732c2..a46871ee 100644 --- a/github/GithubObjects/Label.py +++ b/github/GithubObjects/Label.py @@ -27,7 +27,12 @@ class Label( object ): return self.__url def delete( self ): - pass + status, headers, data = self.__requester.request( + "DELETE", + self.url, + None, + None + ) def edit( self, name, color ): post_parameters = { @@ -36,7 +41,7 @@ class Label( object ): } status, headers, data = self.__requester.request( "PATCH", - "https://api.github.com/user", + self.url, None, post_parameters ) diff --git a/github/GithubObjects/Milestone.py b/github/GithubObjects/Milestone.py index fadd1c5a..1384b162 100644 --- a/github/GithubObjects/Milestone.py +++ b/github/GithubObjects/Milestone.py @@ -64,7 +64,12 @@ class Milestone( object ): return self.__url def delete( self ): - pass + status, headers, data = self.__requester.request( + "DELETE", + self.url, + None, + None + ) def edit( self, title, state = None, description = None, due_on = None ): post_parameters = { @@ -78,7 +83,7 @@ class Milestone( object ): post_parameters[ "due_on" ] = due_on status, headers, data = self.__requester.request( "PATCH", - "https://api.github.com/user", + self.url, None, post_parameters ) diff --git a/github/GithubObjects/NamedUser.py b/github/GithubObjects/NamedUser.py index 87a3c3f9..fadb3709 100644 --- a/github/GithubObjects/NamedUser.py +++ b/github/GithubObjects/NamedUser.py @@ -147,7 +147,19 @@ class NamedUser( object ): return self.__url def create_gist( self, public, files, description = None ): - pass + post_parameters = { + "public": public, + "files": files, + } + if description is not None: + post_parameters[ "description" ] = description + status, headers, data = self.__requester.request( + "POST", + self.url + "/gists", + None, + post_parameters + ) + return Gist.Gist( self.__requester, data, lazy = True ) def get_events( self ): status, headers, data = self.__requester.request( diff --git a/github/GithubObjects/Organization.py b/github/GithubObjects/Organization.py index a0b209ab..8061d6bf 100644 --- a/github/GithubObjects/Organization.py +++ b/github/GithubObjects/Organization.py @@ -147,10 +147,46 @@ class Organization( object ): pass def create_repo( self, name, description = None, homepage = None, private = None, has_issues = None, has_wiki = None, has_downloads = None, team_id = None ): - pass + post_parameters = { + "name": name, + } + if description is not None: + post_parameters[ "description" ] = description + if homepage is not None: + post_parameters[ "homepage" ] = homepage + if private is not None: + post_parameters[ "private" ] = private + if has_issues is not None: + post_parameters[ "has_issues" ] = has_issues + if has_wiki is not None: + post_parameters[ "has_wiki" ] = has_wiki + if has_downloads is not None: + post_parameters[ "has_downloads" ] = has_downloads + if team_id is not None: + post_parameters[ "team_id" ] = team_id + status, headers, data = self.__requester.request( + "POST", + self.url + "/repos", + None, + post_parameters + ) + return Repository.Repository( self.__requester, data, lazy = True ) def create_team( self, name, repo_names = None, permission = None ): - pass + post_parameters = { + "name": name, + } + if repo_names is not None: + post_parameters[ "repo_names" ] = repo_names + if permission is not None: + post_parameters[ "permission" ] = permission + status, headers, data = self.__requester.request( + "POST", + self.url + "/teams", + None, + post_parameters + ) + return Team.Team( self.__requester, data, lazy = True ) def edit( self, billing_email = None, blog = None, company = None, email = None, location = None, name = None ): post_parameters = { @@ -169,7 +205,7 @@ class Organization( object ): post_parameters[ "name" ] = name status, headers, data = self.__requester.request( "PATCH", - "https://api.github.com/user", + self.url, None, post_parameters ) diff --git a/github/GithubObjects/PullRequest.py b/github/GithubObjects/PullRequest.py index 73762e5f..133f7518 100644 --- a/github/GithubObjects/PullRequest.py +++ b/github/GithubObjects/PullRequest.py @@ -156,7 +156,7 @@ class PullRequest( object ): post_parameters[ "state" ] = state status, headers, data = self.__requester.request( "PATCH", - "https://api.github.com/user", + self.url, None, post_parameters ) diff --git a/github/GithubObjects/PullRequestComment.py b/github/GithubObjects/PullRequestComment.py index a6c0db56..7dd09e57 100644 --- a/github/GithubObjects/PullRequestComment.py +++ b/github/GithubObjects/PullRequestComment.py @@ -68,7 +68,12 @@ class PullRequestComment( object ): return self.__user def delete( self ): - pass + status, headers, data = self.__requester.request( + "DELETE", + self.url, + None, + None + ) def edit( self, body ): post_parameters = { @@ -76,7 +81,7 @@ class PullRequestComment( object ): } status, headers, data = self.__requester.request( "PATCH", - "https://api.github.com/user", + self.url, None, post_parameters ) diff --git a/github/GithubObjects/Repository.py b/github/GithubObjects/Repository.py index 643a5fbb..fc6dbe85 100644 --- a/github/GithubObjects/Repository.py +++ b/github/GithubObjects/Repository.py @@ -194,37 +194,177 @@ class Repository( object ): pass def create_download( self, name, size, description = None, content_type = None ): - pass + post_parameters = { + "name": name, + "size": size, + } + if description is not None: + post_parameters[ "description" ] = description + if content_type is not None: + post_parameters[ "content_type" ] = content_type + status, headers, data = self.__requester.request( + "POST", + self.url + "/downloads", + None, + post_parameters + ) + return Download.Download( self.__requester, data, lazy = True ) def create_git_blob( self, content, encoding ): - pass + post_parameters = { + "content": content, + "encoding": encoding, + } + status, headers, data = self.__requester.request( + "POST", + self.url + "/git_blobs", + None, + post_parameters + ) + return GitBlob.GitBlob( self.__requester, data, lazy = True ) def create_git_commit( self, message, tree, parents, author = None, committer = None ): - pass + post_parameters = { + "message": message, + "tree": tree, + "parents": parents, + } + if author is not None: + post_parameters[ "author" ] = author + if committer is not None: + post_parameters[ "committer" ] = committer + status, headers, data = self.__requester.request( + "POST", + self.url + "/git_commits", + None, + post_parameters + ) + return GitCommit.GitCommit( self.__requester, data, lazy = True ) def create_git_ref( self, ref, sha ): - pass + post_parameters = { + "ref": ref, + "sha": sha, + } + status, headers, data = self.__requester.request( + "POST", + self.url + "/git_refs", + None, + post_parameters + ) + return GitRef.GitRef( self.__requester, data, lazy = True ) def create_git_tag( self, tag, message, object, type, tagger = None ): - pass + post_parameters = { + "tag": tag, + "message": message, + "object": object, + "type": type, + } + if tagger is not None: + post_parameters[ "tagger" ] = tagger + status, headers, data = self.__requester.request( + "POST", + self.url + "/git_tags", + None, + post_parameters + ) + return GitTag.GitTag( self.__requester, data, lazy = True ) def create_git_tree( self, tree, base_tree = None ): - pass + post_parameters = { + "tree": tree, + } + if base_tree is not None: + post_parameters[ "base_tree" ] = base_tree + status, headers, data = self.__requester.request( + "POST", + self.url + "/git_trees", + None, + post_parameters + ) + return GitTree.GitTree( self.__requester, data, lazy = True ) def create_hook( self, name, config, events = None, active = None ): - pass + post_parameters = { + "name": name, + "config": config, + } + if events is not None: + post_parameters[ "events" ] = events + if active is not None: + post_parameters[ "active" ] = active + status, headers, data = self.__requester.request( + "POST", + self.url + "/hooks", + None, + post_parameters + ) + return Hook.Hook( self.__requester, data, lazy = True ) def create_issue( self, title, body = None, assignee = None, milestone = None, labels = None ): - pass + post_parameters = { + "title": title, + } + if body is not None: + post_parameters[ "body" ] = body + if assignee is not None: + post_parameters[ "assignee" ] = assignee + if milestone is not None: + post_parameters[ "milestone" ] = milestone + if labels is not None: + post_parameters[ "labels" ] = labels + status, headers, data = self.__requester.request( + "POST", + self.url + "/issues", + None, + post_parameters + ) + return Issue.Issue( self.__requester, data, lazy = True ) def create_key( self, title, key ): - pass + post_parameters = { + "title": title, + "key": key, + } + status, headers, data = self.__requester.request( + "POST", + self.url + "/keys", + None, + post_parameters + ) + return RepositoryKey.RepositoryKey( self.__requester, data, lazy = True ) def create_label( self, name, color ): - pass + post_parameters = { + "name": name, + "color": color, + } + status, headers, data = self.__requester.request( + "POST", + self.url + "/labels", + None, + post_parameters + ) + return Label.Label( self.__requester, data, lazy = True ) def create_milestone( self, title, state = None, description = None, due_on = None ): - pass + post_parameters = { + "title": title, + } + if state is not None: + post_parameters[ "state" ] = state + if description is not None: + post_parameters[ "description" ] = description + if due_on is not None: + post_parameters[ "due_on" ] = due_on + status, headers, data = self.__requester.request( + "POST", + self.url + "/milestones", + None, + post_parameters + ) + return Milestone.Milestone( self.__requester, data, lazy = True ) def edit( self, name, description = None, homepage = None, public = None, has_issues = None, has_wiki = None, has_downloads = None ): post_parameters = { @@ -244,7 +384,7 @@ class Repository( object ): post_parameters[ "has_downloads" ] = has_downloads status, headers, data = self.__requester.request( "PATCH", - "https://api.github.com/user", + self.url, None, post_parameters ) diff --git a/github/GithubObjects/RepositoryKey.py b/github/GithubObjects/RepositoryKey.py index d725c8a1..df3ef3d2 100644 --- a/github/GithubObjects/RepositoryKey.py +++ b/github/GithubObjects/RepositoryKey.py @@ -32,7 +32,12 @@ class RepositoryKey( object ): return self.__url def delete( self ): - pass + status, headers, data = self.__requester.request( + "DELETE", + self.url, + None, + None + ) def edit( self, title, key ): post_parameters = { @@ -41,7 +46,7 @@ class RepositoryKey( object ): } status, headers, data = self.__requester.request( "PATCH", - "https://api.github.com/user", + self.url, None, post_parameters ) diff --git a/github/GithubObjects/Team.py b/github/GithubObjects/Team.py index 3f3fd4e8..28035be1 100644 --- a/github/GithubObjects/Team.py +++ b/github/GithubObjects/Team.py @@ -60,7 +60,12 @@ class Team( object ): ) def delete( self ): - pass + status, headers, data = self.__requester.request( + "DELETE", + self.url, + None, + None + ) def edit( self, name, permission = None ): post_parameters = { @@ -70,7 +75,7 @@ class Team( object ): post_parameters[ "permission" ] = permission status, headers, data = self.__requester.request( "PATCH", - "https://api.github.com/user", + self.url, None, post_parameters ) diff --git a/github/GithubObjects/UserKey.py b/github/GithubObjects/UserKey.py index 9cb75343..6f10c011 100644 --- a/github/GithubObjects/UserKey.py +++ b/github/GithubObjects/UserKey.py @@ -32,7 +32,12 @@ class UserKey( object ): return self.__url def delete( self ): - pass + status, headers, data = self.__requester.request( + "DELETE", + self.url, + None, + None + ) def edit( self, title = None, key = None ): post_parameters = { @@ -43,7 +48,7 @@ class UserKey( object ): post_parameters[ "key" ] = key status, headers, data = self.__requester.request( "PATCH", - "https://api.github.com/user", + self.url, None, post_parameters )