异步Gitlab API库
gidgetlab的Python项目详细描述
异步GitLab API库。
这个库基于brett cannon的gidgethub, 异步GitHub API库。
我喜欢异步和sans-I/O的概念 方法并决定使其适应Gitlab的API。 初始库的所有功劳都归于Brett Cannon!
快速启动
下面是响应 webhooks将向作者致意并表示感谢 每当打开问题时:
from gidgetlab.aiohttp import GitLabBot bot = GitLabBot("beenje") @bot.router.register("Issue Hook", action="open") async def issue_opened_event(event, gl, *args, **kwargs): """Whenever an issue is opened, greet the author and say thanks.""" url = f"/projects/{event.project_id}/issues/{event.object_attributes['iid']}/notes" message = f"Thanks for the report @{event.data['user']['username']}! I will look into it ASAP! (I'm a bot)." await gl.post(url, data={"body": message}) if __name__ == "__main__": bot.run()
安装
gidgetlab是available on PyPI。
python3 -m pip install gidgetlab
要安装Web服务器支持(例如,^{TT1}$、^{TT2}$或^{TT3}$),请将其指定为额外的依赖项:
python3 -m pip install gidgetlab[aiohttp]
请注意,库仍处于alpha开发阶段。
目标
关键目标与gidgethub相同(但对于gitlab): 为GitLab API提供异步基库 它不执行自己的I/O(一个sans-I/O库)。
另一个目标是轻松编写gitlab bots: 使用gitlab webhooks和api在gitlab上运行自动化。 这是受到MariattaPycon 2018研讨会的启发: Build-a-GitHub-Bot Workshop。
替代库
如果您认为需要对gitlab api使用不同的方法, GitLab maintains a list of libraries。