用于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,其中specificationapi.github.comghe-2.15等中的一个。

待办事项

Github API

[-] REST (see best practices, integration tests, and errors)

[ ] GraphQL client

[x] GitHub Apps

[ ] OAuth Apps

[x] Webhooks

数据

基于可用route datawebhook data

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。

学分

基于cookiecutter-pylibrary

的包

许可证

麻省理工学院

更改日志

0.1.0(?)

  • pypi上的第一个版本。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
带有字符串的java JNA调用与带有字节[]的java JNA调用的行为不同   java基于键列表获取子映射   重启后永久增加java堆大小?   JavaHTTPS服务器:相互SSL身份验证   java为什么接受接口的方法会拒绝该接口的实现?   片段中的java视图无法应用于()   ms access Java SQL更新命令不工作   java将web服务自动打包和部署到Oracle Application Server 10g   java有没有办法在安卓 studio中为安卓时钟设置多个警报?   位于FTP服务器上的文件上的Java校验和md5   在Java中创建类时遇到问题。有些方法不太确定   java错误:在类chrome\u驱动程序中找不到主方法   通用海图(Javascript\Java)