用于github api的python客户端
octokitp的Python项目详细描述
用于Github API的Python客户端
安装
需要python 3.5+
note octokit和octokit.py已经在奶酪店被拿走了
pip install octokitpy
文档
https://octokitpy.readthedocs.io/en/latest/
示例
rest api:
from octokit import Octokit repos = Octokit().repos.get_for_org(org='octokit', type='public') # Make an unauthenticated request for the public repositories of the octokit organization
网络挂钩:
from octokit import webhook webhook.verify(headers, payload, secret, events=['push'])
octokit.py
提供一个函数来验证发送到应用程序的webhooks。
- headers
- dictionary of request headers
- payload
- string; payload of request
- secret
- string; secret provided to GitHub to sign webhook
- events
- list; events that you want to receive
- verify_user_agent
- boolean; whether or not you want to verify the user agent string of the request
- return_app_id
- boolean; whether or not you want to return the app id from the ping event for GitHub applications. This will only return the ^{tt1}$ if the event is the ^{tt2}$ event. Otherwise the return value will be boolean.
认证
使用要使用的身份验证方案和凭据安装客户端。
基本:
octokit = Octokit(auth='basic', username='myuser', password='mypassword') octokit.repos.get_for_org(org='octokit', type='private')
令牌:
response = Octokit(auth='token', token='yak').authorization.get(id=100)
应用程序:
octokit = Octokit(auth='app', app_id='42', private_key=private_key)
应用程序安装:
octokit = Octokit(auth='installation', app_id='42', private_key=private_key)
对于应用程序,请从ping webhook或github上的应用程序页面提供应用程序id。
private_key
是为应用程序提供的私钥字符串。
app
方案将使用应用程序id和私钥为应用程序的第一个安装id获取令牌。
API架构/路由/规范
可以用routes=specification实例化Octokit,其中specification是api.github.com、ghe-2.15等中的一个。
待办事项
Github API
[-] REST (see best practices, integration tests, and errors) [ ] GraphQL client [x] GitHub Apps [ ] OAuth Apps [x] Webhooks
数据
的octokit
客户端
[x] Periodically, check if ``routes.json`` has changed and if so fetch and open a PR for it to be merged [ ] Periodically, check if ``webhook-names.json`` has changed and if so fetch and open a PR for it to be merged
测试
[x] unit tests [ ] integration tests - need fixtures to assert against [ ] coverage uploaded to code climate -- not sure why it is not working
错误
[ ] Raise :code:`OctokitValidationError` for param validation error [ ] Raise :code:`OctokitAuthenticationError` for auth error [ ] Raise :code:`OctokitRateLimitError` for rate limiting errors
最佳实践
[ ] throttling [ ] handles rate limiting [x] pagination
文件
[ ] Auto generated documentation
部署
[x] Deploy wheels [x] Make GitHub releases work
复选框指南
[ ] Incomplete [-] Partially completed [x] Completed
开发
要运行所有测试,请运行:
tox
贡献
拉请求非常欢迎!
更多信息请参见contribution.md。
学分
的包许可证
麻省理工学院
更改日志
0.1.0(?)
- pypi上的第一个版本。