Skip to main content

No project description provided

Project description

pjdev-gitlab

PyPI - Version PyPI - Python Version

Async GitLab automation SDK. Wraps the GitLab REST API v4 directly with httpx.AsyncClient and Pydantic models. Covers issues, merge requests, repository files, and the generic package registry.


Installation

pip install pjdev-gitlab

Configuration

pjdev-gitlab reads GL_* environment variables (or accepts the same values via init()):

variable required purpose
GL_TOKEN yes personal/group/project access token (api scope)
GL_GITLAB_URL yes base URL, e.g. https://gitlab.com
GL_DEFAULT_PROJECT_ID no default project for service helpers
GL_OUTPUT_PATH no directory for downloaded files

Recommended: 1Password + op run

On a developer laptop, keep the token in 1Password and inject it into the host process with op run — the secret never sits in your shell environment or on disk in plaintext.

  1. Install the 1Password CLI (brew install --cask 1password-cli) and turn on Settings → Developer → Integrate with 1Password CLI in the desktop app.

  2. Store the token in 1Password (e.g. an API Credential titled GitLab — purplejay with a credential field).

  3. Drop a committable .env.op next to your project — references only, no real secrets:

    # .env.op
    GL_TOKEN="op://Private/GitLab — purplejay/credential"
    GL_GITLAB_URL="https://gitlab.purplejay.io"
    
  4. Launch your script — or the entire Claude Code session that will use this library — under op run:

    op run --env-file=.env.op -- python my_script.py
    op run --env-file=.env.op -- claude
    

op run resolves the references, exports them to the subprocess, and tears them down on exit. Inside Python, just call config_service.init() with no arguments and the values flow in from the environment.

In CI, skip 1Password and set GL_TOKEN/GL_GITLAB_URL from the job's existing variables (e.g. CI_JOB_TOKEN for project-scoped operations).

Usage

import asyncio
from pjdev_gitlab import config_service, issues_service
from pjdev_gitlab.models import StateEvent

async def main() -> None:
    # Token & URL come from GL_TOKEN / GL_GITLAB_URL (e.g. via `op run`).
    config_service.init(default_project_id="my-group/my-project")

    issue = await issues_service.create_issue(
        project_id="my-group/my-project",
        title="Bug: timeout on /widgets",
        description="The endpoint times out under load.\n\n/label ~bug ~priority::high",
        labels=["bug"],
    )
    await issues_service.comment_on_issue(
        project_id="my-group/my-project",
        issue_iid=issue.iid,
        body="Investigating now.",
    )
    await issues_service.set_issue_state(
        project_id="my-group/my-project",
        issue_iid=issue.iid,
        state_event=StateEvent.close,
    )

asyncio.run(main())

Run it: op run --env-file=.env.op -- python my_script.py.

Bundled agent skills

Skill files for AI agents ship under .agents/skills/ inside the installed package, following the library-skills.io convention. Topics: issues, merge requests, repository files, generic packages.

License

pjdev-gitlab is distributed under the terms of the MIT license.

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

pjdev_gitlab-5.0.1.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

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

pjdev_gitlab-5.0.1-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file pjdev_gitlab-5.0.1.tar.gz.

File metadata

  • Download URL: pjdev_gitlab-5.0.1.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1

File hashes

Hashes for pjdev_gitlab-5.0.1.tar.gz
Algorithm Hash digest
SHA256 0254e7157582153f0a1fda9f3ab6aaddf306bdbe51857d6aa042e90eb542ed4e
MD5 7526178b1e1e5e1d0a1cc18239f91129
BLAKE2b-256 a749c27e1af3410ea447bc25ad6cd7504b312d7623cd759a9d9e8e7c48d8272f

See more details on using hashes here.

File details

Details for the file pjdev_gitlab-5.0.1-py3-none-any.whl.

File metadata

  • Download URL: pjdev_gitlab-5.0.1-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1

File hashes

Hashes for pjdev_gitlab-5.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e858e7e6cb6d196d64ec3a273581c6ba39b1e2c4d8927921a4cfd182d773c278
MD5 747b2a969af243f6ca149ac6798cf8e6
BLAKE2b-256 1f67541b6f43c804c9a1b2555cf57fa90756bcf43bae345ef6e5b541bde27197

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