github v3 API - delete / remove a repo

老子叫甜甜 提交于 2019-12-09 07:01:44

问题


I would like to programmatically delete a github repo, when setting up a unit test environment for my application.

I am already using the v3 API, which seems to be most supported and the path going forward. I am using the following python lines to successfully CREATE a repo, just fine:

import urllib2, base64
createData = '{\"name\": \"UnitTest-SubModules\", \"description\": \"This is a Fake repo used for testing\"}'
request = urllib2.Request("https://api.github.com/user/repos")
base64string = base64.encodestring('%s:%s' % ('user', 'pass')).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string)
result = urllib2.urlopen(request, data=createData)

How do I set this up to DELETE a repo? I cannot find the specification for deleting at http://developer.github.com/v3/repos/

I have tried, based off guestimating, the following code, as it follows the API pattern, but it did not work. Came back with urllib2.HTTPError: HTTP Error 404: Not Found

request = urllib2.Request("https://api.github.com/repos/nyeates/UnitTest-SubModules")
base64string = base64.encodestring('%s:%s' % ('user', 'pass')).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string)
request.get_method = lambda: 'DELETE'
result = urllib2.urlopen(request)

I got the python http DELETE code from: How to make HTTP DELETE method using urllib2?


回答1:


The DELETE method is now here: http://developer.github.com/v3/repos/#delete-a-repository



来源:https://stackoverflow.com/questions/8920696/github-v3-api-delete-remove-a-repo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!