An async GitLab API library
Project description
An asynchronous GitLab API library.
This library is based on gidgethub from Brett Cannon, an async GitHub API library.
I liked the concept with the asynchronous and sans-I/O approach and decided to adapt it to the GitLab’s API. All credit to Brett Cannon for the initial library!
Quick start
Here is a complete example of a server that responds to webhooks which will greet the author and say thanks whenever an issue is opened:
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()
Installation
Gidgetlab is available on PyPI.
python3 -m pip install gidgetlab
To install web server support (e.g. for aiohttp, treq, or tornado), specify it as an extra dependency:
python3 -m pip install gidgetlab[aiohttp]
Note that the library is still in alpha development stage.
Goals
The key goal is the same as gidgethub (but for GitLab): to provide an async base library for the GitLab API which performs no I/O of its own (a sans-I/O library).
Another goal is to easily write GitLab bots: applications that run automation on GitLab, using GitLab WebHooks and API. This was inspired by Mariatta PyCon 2018 workshop: Build-a-GitHub-Bot Workshop.
Alternative libraries
If you think you want a different approach to the GitLab API, GitLab maintains a list of libraries.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gidgetlab-2.0.0.tar.gz
.
File metadata
- Download URL: gidgetlab-2.0.0.tar.gz
- Upload date:
- Size: 34.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f109c12a47c4b2cadd5485c6574d003807a07796585d75a21bd9e0d4ecd63c14 |
|
MD5 | d73ca68a225d94658c3a1c914cfa92af |
|
BLAKE2b-256 | 8021bf599a5b51f430c961d0b804bf71d98deff38d61afade22492190857decc |
File details
Details for the file gidgetlab-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: gidgetlab-2.0.0-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6276b21eee4a9ba46720a0489551a60e9cfad3a8de8b8c795ec7d4d4758e78ca |
|
MD5 | b1f6ebeb741af2e34071836d4bf3cf3f |
|
BLAKE2b-256 | 33b1da4486b15397df14af39e8eaede573a86e0caf82d040ac93d4f17877f2ec |