diff --git a/doc/ReferenceOfApis.md b/doc/ReferenceOfApis.md index d9e91295..8165510f 100644 --- a/doc/ReferenceOfApis.md +++ b/doc/ReferenceOfApis.md @@ -127,6 +127,7 @@ API `/repos/:user/:repo` ======================== * GET: `AuthenticatedUser.get_repo`, `NamedUser.get_repo` or `Organization.get_repo` * PATCH: `Repository.edit` +* DELETE: `Repository.delete` API `/repos/:user/:repo/branches` ================================= diff --git a/doc/ReferenceOfClasses.md b/doc/ReferenceOfClasses.md index dad3e8db..5bab56dc 100644 --- a/doc/ReferenceOfClasses.md +++ b/doc/ReferenceOfClasses.md @@ -1076,6 +1076,10 @@ Attributes * `url`: string * `watchers`: integer +Deletion +-------- +* `delete()` + Comparison ---------- * `compare( base, head )`: `Comparison` diff --git a/github/Repository.py b/github/Repository.py index 1779d31d..b78fe96d 100644 --- a/github/Repository.py +++ b/github/Repository.py @@ -458,6 +458,14 @@ class Repository( GithubObject.GithubObject ): ) return PullRequest.PullRequest( self._requester, data, completed = True ) + def delete( self ): + headers, data = self._requester.requestAndCheck( + "DELETE", + self.url, + None, + None + ) + def edit( self, name, description = GithubObject.NotSet, homepage = GithubObject.NotSet, public = GithubObject.NotSet, has_issues = GithubObject.NotSet, has_wiki = GithubObject.NotSet, has_downloads = GithubObject.NotSet ): assert isinstance( name, ( str, unicode ) ), name assert description is GithubObject.NotSet or isinstance( description, ( str, unicode ) ), description diff --git a/test/ReplayData/Repository.testDelete.txt b/test/ReplayData/Repository.testDelete.txt new file mode 100644 index 00000000..7fda0291 --- /dev/null +++ b/test/ReplayData/Repository.testDelete.txt @@ -0,0 +1,15 @@ +https GET api.github.com None /user {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4987'), ('x-ratelimit-limit', '5000'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '806'), ('server', 'nginx/1.0.13'), ('last-modified', 'Tue, 14 Aug 2012 18:41:03 GMT'), ('connection', 'keep-alive'), ('etag', '"a16173bc016f1c15e3e635051c76c388"'), ('cache-control', 'private, s-maxage=60, max-age=60'), ('date', 'Thu, 23 Aug 2012 07:30:50 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"private_gists":5,"plan":{"private_repos":5,"space":614400,"collaborators":1,"name":"micro"},"type":"User","public_repos":12,"followers":13,"following":28,"location":"Paris, France","hireable":false,"disk_usage":14544,"created_at":"2010-07-09T06:10:06Z","login":"jacquev6","bio":"","blog":"http://vincent-jacques.net","total_private_repos":5,"collaborators":0,"email":"vincent@vincent-jacques.net","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","name":"Vincent Jacques","url":"https://api.github.com/users/jacquev6","avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","owned_private_repos":5,"public_gists":3,"id":327146,"html_url":"https://github.com/jacquev6","company":"Criteo"} + +https GET api.github.com None /repos/jacquev6/TestPyGithub {'Authorization': 'Basic login_and_password_removed'} null +200 +[('status', '200 OK'), ('x-ratelimit-remaining', '4986'), ('x-ratelimit-limit', '5000'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('content-length', '1176'), ('server', 'nginx/1.0.13'), ('last-modified', 'Thu, 23 Aug 2012 07:30:19 GMT'), ('connection', 'keep-alive'), ('etag', '"b997e723dda2e6baea587ef9b5b94e73"'), ('cache-control', 'private, max-age=60, s-maxage=60'), ('date', 'Thu, 23 Aug 2012 07:30:51 GMT'), ('content-type', 'application/json; charset=utf-8')] +{"clone_url":"https://github.com/jacquev6/TestPyGithub.git","git_url":"git://github.com/jacquev6/TestPyGithub.git","full_name":"jacquev6/TestPyGithub","open_issues":0,"has_issues":true,"owner":{"avatar_url":"https://secure.gravatar.com/avatar/b68de5ae38616c296fa345d2b9df2225?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png","login":"jacquev6","gravatar_id":"b68de5ae38616c296fa345d2b9df2225","url":"https://api.github.com/users/jacquev6","id":327146},"watchers_count":0,"homepage":null,"ssh_url":"git@github.com:jacquev6/TestPyGithub.git","master_branch":"master","open_issues_count":0,"language":null,"created_at":"2012-08-23T07:30:19Z","permissions":{"admin":true,"push":true,"pull":true},"mirror_url":null,"has_downloads":true,"description":null,"pushed_at":"2012-08-23T07:30:19Z","forks":0,"forks_count":0,"size":0,"fork":false,"svn_url":"https://github.com/jacquev6/TestPyGithub","updated_at":"2012-08-23T07:30:19Z","name":"TestPyGithub","url":"https://api.github.com/repos/jacquev6/TestPyGithub","network_count":0,"has_wiki":true,"private":false,"id":5520886,"watchers":0,"html_url":"https://github.com/jacquev6/TestPyGithub"} + +https DELETE api.github.com None /repos/jacquev6/TestPyGithub {'Authorization': 'Basic login_and_password_removed'} null +204 +[('status', '204 No Content'), ('x-ratelimit-remaining', '4985'), ('x-content-type-options', 'nosniff'), ('server', 'nginx/1.0.13'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('cache-control', ''), ('date', 'Thu, 23 Aug 2012 07:30:52 GMT')] + + diff --git a/test/Repository.py b/test/Repository.py index ea261673..150cd084 100644 --- a/test/Repository.py +++ b/test/Repository.py @@ -64,6 +64,10 @@ class Repository( Framework.TestCase ): self.repo.edit( "PyGithub", "Python library implementing the full Github API v3" ) self.assertEqual( self.repo.description, "Python library implementing the full Github API v3" ) + def testDelete( self ): + repo = self.g.get_user().get_repo( "TestPyGithub" ) + repo.delete() + def testGetContributors( self ): self.assertListKeyEqual( self.repo.get_contributors(), lambda c: ( c.login, c.contributions ), [ ( "jacquev6", 355 ) ] )