Keycloak IAM Admin Pydantic Models
Project description
Keycloak Admin Model Representation Pydantic v2 Bindings
This project contains ONLY the pydantic v2 bindings for Keycloak model representations for use in Python based projects utilizing Keycloak admin APIs.
For APIs, I recommend Mantelo. Since this library itself doesn't offer any model representation bindings, projects can use both these libraries together for a complete pydantic compliant experience.
Caveats
-
Transform model representations to python dictionaries using pydantic
model_dump(). Mantelo client expects python dictionaries for write operations. Keycloak API semantics expect that all unset attributes are excluded.class TenantAdapter: @classmethod def model_new(cls, schema: TenantReqSchema) -> OrganizationRepresentation: """Convert `TenantReqSchema` to `OrganizationRepresentation`.""" return OrganizationRepresentation( name=schema.name, alias=schema.name.replace(" ", "_"), domains=[OrganizationDomainRepresentation(name=f"{schema.name.replace(' ', '-').lower()}.org", verified=False)], enabled=schema.active, attributes={"tax_id": [schema.tax_id], "address": [schema.address]}, ).model_dump(exclude_unset=True)
-
Transform python dictionaries to model representations using python dictionary unpacking operator
**. Mantelo client returns python dictionaries for read operations.class TenantAdapter: @classmethod def schema(cls, data: Any | None) -> TenantResSchema | None: """Convert `Dict` to `TenantResSchema`.""" if data is None: return None # Coerse data dict to `OrganizationRepresentation` # representation = OrganizationRepresentation(**data) return TenantResSchema( id=representation.id, name=representation.name, address=representation.attributes["address"][0], tax_id=representation.attributes["tax_id"][0], active=representation.enabled, )
Versioning
I intend to keep the library versioning synced with the latest stable Keycloak release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file keycloak_admin_client-26.0.8.tar.gz.
File metadata
- Download URL: keycloak_admin_client-26.0.8.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.13.1 Darwin/24.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df5cdebf500f7e1cfa7e21b5b5d7383a3d42d9958f09221083e8d0962fdbcaec
|
|
| MD5 |
19e2c6fa43f94400b8fa670aea5ddb2f
|
|
| BLAKE2b-256 |
183984a1941082040ddae9fcbb6c5fa0682e2ecd1b9441f5457966573afaf69e
|
File details
Details for the file keycloak_admin_client-26.0.8-py3-none-any.whl.
File metadata
- Download URL: keycloak_admin_client-26.0.8-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.13.1 Darwin/24.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
311359308535acae547b5da3d0b0385fe3dd3eadfddc20b635f039997f5b7945
|
|
| MD5 |
90d1a6614cc783f470a98c07a40f437f
|
|
| BLAKE2b-256 |
c39ac1ff2488ddec624ad7bb6817b040d5b43d3cb15f5f0c6d171b65fbcba860
|