From 70588ba60165370b1262581b1fc620e3bbde3d94 Mon Sep 17 00:00:00 2001 From: Daniel <d.hornung@indiscale.com> Date: Tue, 8 Apr 2025 14:40:34 +0200 Subject: [PATCH] DOCS: More documentation for the high level api serialization. --- CHANGELOG.md | 2 ++ src/linkahead/high_level_api.py | 28 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20f2498a..33142766 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ## ### Added ### + - convenience functions `value_matches_versionid`, `get_id_from_versionid` and `get_versionid` +- Parameter for high level API serialization to output a plain JSON. ### Changed ### diff --git a/src/linkahead/high_level_api.py b/src/linkahead/high_level_api.py index a835fbb3..a0137dac 100644 --- a/src/linkahead/high_level_api.py +++ b/src/linkahead/high_level_api.py @@ -683,20 +683,28 @@ class CaosDBPythonEntity(object): return entity def serialize(self, without_metadata: bool = None, plain_json: bool = False, - visited: dict = None): + visited: dict = None) -> dict: """Serialize necessary information into a dict. -Parameters ----------- + Parameters + ---------- -without_metadata: bool, optional - If True don't set the metadata field in order to increase - readability. Not recommended if deserialization is needed. + without_metadata: bool, optional + If True don't set the metadata field in order to increase + readability. Not recommended if deserialization is needed. -plain_json: bool, optional - If True, serialize to a plain dict without any additional information besides the property values, - name and id. This should conform to the format as specified by the json schema generated by the - advanced user tools. This implies ``without_metadata = True``. + plain_json: bool, optional + If True, serialize to a plain dict without any additional information besides the property values, + name and id. This should conform to the format as specified by the json schema generated by the + advanced user tools. It also sets all properties as top level items of the resulting dict. This + implies ``without_metadata = True + + Returns + ------- + + out: dict + A dict corresponding to this entity. + ``. """ if plain_json: if without_metadata is None: -- GitLab