Skip to content

Commit

Permalink
Also serialize BoundModels
Browse files Browse the repository at this point in the history
  • Loading branch information
jooola committed Aug 4, 2023
1 parent beed68b commit 3108701
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hcloud/core/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from datetime import datetime

from .client import BoundModelBase


class BaseDomain:
__slots__: tuple[str, ...] = ()
Expand All @@ -22,6 +24,9 @@ def __repr__(self) -> str:


def _make_serializable(value) -> dict | list | str | int | float:
if isinstance(value, BoundModelBase):
value = value.data_model

if isinstance(value, BaseDomain):
return {key: _make_serializable(getattr(value, key)) for key in value.__slots__}

Expand Down

0 comments on commit 3108701

Please sign in to comment.