Skip to content

Hochfrequenz/verzeichnisdienst-python-models

Repository files navigation

Verzeichnisdienst Python Models

License: MIT Python Versions (officially) supported Pypi status badge Unittests status badge Coverage status badge Linting status badge Black status badge

This package provides mostly autogenerated pydantic-based model classes for the Verzeichnisdienst API.

It does not provide you with an HTTP client.

Installation

Install it from PyPI

pip install verzeichnisdienst

Then use it:

from verzeichnisdienst.v1.models import ApiRecord

my_json = {
    "providerId": "1234567890123",
    "apiId": "example",
    "majorVersion": 1,
    "url": "https://www.example.org/api/resource/v1",
    "additionalMetadata": None,
    "lastUpdated": "2024-10-01T00:00:00+00:00",
    "revision": 1,
    "status": "Test",
}
my_strongly_typed_record = ApiRecord.model_validate(my_json)

or

from verzeichnisdienst.v1.websocket import Contact

my_json_contact = {
    "email": "[email protected]",
    "phone": "0049123457890"
}
my_strongly_typed_contact = Contact.model_validate(my_json_contact)

See the tests for more examples.

Project Structure

This project is based on datamodel-code-generator. Most of the classes are autogenerated from the openapi.yml which can be found on SwaggerHub.

After updating the openapi.yml file, use

tox -e codegen

to re-generate the model classes.

Contribute

You are very welcome to contribute to this template repository by opening a pull request against the main branch.