Skip to main content

Pydantic models for GitLab Webhooks

PyPI - Version PyPI - Python Version GitHub Release Test suite status

Module containing Pydantic models for validating bodies from GitLab webhook requests.

Documentation

The project documentation including an API reference can be found at https://rjw57.github.io/pydantic-gitlab-webhooks/.

Usage example

Intended usage is via a single validate_event_header_and_body function which will validate an incoming webhook's X-Gitlab-Event header and the body after being parsed into a Python dict.

from pydantic import ValidationError
from pydantic_gitlab_webhooks import (
    validate_event_body_dict,
    validate_event_header_and_body_dict,
)

event_body = {
    "object_kind": "access_token",
    "group": {
        "group_name": "Twitter",
        "group_path": "twitter",
        "group_id": 35,
        "full_path": "twitter"
    },
    "object_attributes": {
        "user_id": 90,
        "created_at": "2024-01-24 16:27:40 UTC",
        "id": 25,
        "name": "acd",
        "expires_at": "2024-01-26"
    },
    "event_name": "expiring_access_token"
}

# Use the value of the "X-Gitlab-Event" header and event body to validate
# the incoming event.
parsed_event = validate_event_header_and_body_dict(
    "Resource Access Token Hook",
    event_body
)
assert parsed_event.group.full_path == "twitter"

# Invalid event bodies or hook headers raise Pydantic validation errors
try:
    validate_event_header_and_body_dict("invalid hook", event_body)
except ValidationError:
    pass  # ok - expected error raised
else:
    assert False, "ValidationError was not raised"

# Event bodies can be parsed without the header hook if necessary although using
# the hook header is more efficient.
parsed_event = validate_event_body_dict(event_body)
assert parsed_event.group.full_path == "twitter"

# Event models may be imported individually. For example:
from pydantic_gitlab_webhooks.events import GroupAccessTokenEvent

parsed_event = GroupAccessTokenEvent.model_validate(event_body)

Metadata

Release files for pydantic-gitlab-webhooks 0.3.54

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydantic-gitlab-webhooks 0.3.54
File Size Uploaded
pydantic_gitlab_webhooks-0.3.54.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pydantic-gitlab-webhooks 0.3.54
File Interpreter ABI Platform
pydantic_gitlab_webhooks-0.3.54-py3-none-any.whl Python 3 none any Details

Total release size: 21.6 kB

Release files / pydantic_gitlab_webhooks-0.3.54.tar.gz

Download URL pydantic_gitlab_webhooks-0.3.54.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1afa58192a44c9f53c290b1a24bc47cbdaf370b40f5f4092ecc99481abecd355
BLAKE2b-256 checksum
How to use checksums
222efbee45f835b95ac2470ed86ccb72a5b996cc63cd85331a8be70b8828dafd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / pydantic_gitlab_webhooks-0.3.54-py3-none-any.whl

Download URL pydantic_gitlab_webhooks-0.3.54-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
479f3ac448982fb4582b6046010f6c27d2b9a87567a79eb8feff4438713fe7f6
BLAKE2b-256 checksum
How to use checksums
73351375b477c7753441d4bd0fbebaec50f62c48a073c5d56bcd7e0debb618ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.54 This release

2 release files

0.3.53

2 release files

0.3.52

2 release files

0.3.51

2 release files

0.3.49

2 release files

0.3.46

2 release files

0.3.45

2 release files

0.3.43

2 release files

0.3.42

2 release files

0.3.39

2 release files

0.3.38

2 release files

0.3.37

2 release files

0.3.36

2 release files

0.3.35

2 release files

0.3.34

2 release files

0.3.33

2 release files

0.3.30

2 release files

0.3.29

2 release files

0.3.27

2 release files

0.3.26

2 release files

0.3.25

2 release files

0.3.24

2 release files

0.3.23

2 release files

0.3.22

2 release files

0.3.21

2 release files

0.3.20

2 release files

0.3.19

2 release files

0.3.18

2 release files

0.3.15

2 release files

0.3.14

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page