github v3 API - 删除/删除回购

时间:2012-01-19 03:32:24

标签: api github github-api http-delete

在为我的应用程序设置单元测试环境时,我想以编程方式删除github仓库。

我已经在使用v3 API,这似乎是最受支持的,也是前进的道路。我正在使用以下python行来成功创建一个repo,就好了:

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)

如何将其设置为删除回购?我在http://developer.github.com/v3/repos/

找不到删除规范

我已经尝试过,基于guestimating,以下代码,因为它遵循API模式,但它不起作用。回到urllib2.HTTPError:HTTP错误404:找不到

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)

我从How to make HTTP DELETE method using urllib2?

获得了python http DELETE代码

1 个答案:

答案 0 :(得分:4)