Skip to main content

An async GitLab API library

Project description

https://img.shields.io/badge/code%20style-black-000000.svg pre-commit Documentation Status https://gitlab.com/beenje/gidgetlab/badges/master/pipeline.svg https://gitlab.com/beenje/gidgetlab/badges/master/coverage.svg

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 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gidgetlab-2.1.1.tar.gz (33.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gidgetlab-2.1.1-py3-none-any.whl (26.9 kB view details)

Uploaded Python 3

File details

Details for the file gidgetlab-2.1.1.tar.gz.

File metadata

  • Download URL: gidgetlab-2.1.1.tar.gz
  • Upload date:
  • Size: 33.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for gidgetlab-2.1.1.tar.gz
Algorithm Hash digest
SHA256 85da471d25bbb96fdae6c69fa4dffb4fb22c8b55da0ceae6fb0e1d948e5efc6b
MD5 9cd9bef64778d9eb23ad39770039470c
BLAKE2b-256 cd022293dad6b3b6c6aca7a33f7e36c72b13e7253fe8307af8a2f395c2ab991e

See more details on using hashes here.

File details

Details for the file gidgetlab-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: gidgetlab-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for gidgetlab-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9d00a0f5c1b5ced7580a20d5801c430f28e4fbe62f07f17becda8c7815fbbb0f
MD5 99e06376695f0f45c0bd4e85453bc4c8
BLAKE2b-256 511f68403185d3c6c6583b74bce5f4fc187c00b6fe13a1d0c256b8c7205cba2c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page