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


Download files

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

Source Distribution

gidgetlab-1.0.0.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

gidgetlab-1.0.0-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gidgetlab-1.0.0.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for gidgetlab-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5fd963c5a6dc0a1eec30f06af5e6d2698bae70f8421644dfb156e83cb9014af2
MD5 070790de7e6fa37a20f86d396eeda2f6
BLAKE2b-256 4b8ab3c7d92d1377cf416fd4bcd80469c40e1f3c5920c33ecc3853e0d16e2701

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gidgetlab-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for gidgetlab-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae505a29d270b4c9086aac2450e05913bfebe3d10f22b7e4249a95344a0375c4
MD5 4ef436be7d0cba01bd23053aa39b3882
BLAKE2b-256 4729a6805b018432e0a8ff9f3f8a4450042f15b33223d4bd67186d6ea5c94df6

See more details on using hashes here.

Supported by

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