Pydantic models for GitLab Webhooks
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)
| File | Size | Uploaded | |
|---|---|---|---|
| pydantic_gitlab_webhooks-0.3.54.tar.gz | 9.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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 logRelease 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