|
| 1 | +from typing import Any, Dict, List, Type, TypeVar, Union |
| 2 | + |
| 3 | +import attr |
| 4 | + |
| 5 | +from ..models.model_with_circular_ref_b import ModelWithCircularRefB |
| 6 | +from ..types import UNSET, Unset |
| 7 | + |
| 8 | +T = TypeVar("T", bound="ModelWithCircularRefA") |
| 9 | + |
| 10 | + |
| 11 | +@attr.s(auto_attribs=True) |
| 12 | +class ModelWithCircularRefA: |
| 13 | + """ |
| 14 | + Attributes: |
| 15 | + circular (Union[Unset, ModelWithCircularRefB]): |
| 16 | + """ |
| 17 | + |
| 18 | + circular: Union[Unset, ModelWithCircularRefB] = UNSET |
| 19 | + additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) |
| 20 | + |
| 21 | + def to_dict(self) -> Dict[str, Any]: |
| 22 | + circular: Union[Unset, Dict[str, Any]] = UNSET |
| 23 | + if not isinstance(self.circular, Unset): |
| 24 | + circular = self.circular.to_dict() |
| 25 | + |
| 26 | + field_dict: Dict[str, Any] = {} |
| 27 | + field_dict.update(self.additional_properties) |
| 28 | + field_dict.update({}) |
| 29 | + if circular is not UNSET: |
| 30 | + field_dict["circular"] = circular |
| 31 | + |
| 32 | + return field_dict |
| 33 | + |
| 34 | + @classmethod |
| 35 | + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: |
| 36 | + d = src_dict.copy() |
| 37 | + _circular = d.pop("circular", UNSET) |
| 38 | + circular: Union[Unset, ModelWithCircularRefB] |
| 39 | + if isinstance(_circular, Unset): |
| 40 | + circular = UNSET |
| 41 | + else: |
| 42 | + circular = ModelWithCircularRefB.from_dict(_circular) |
| 43 | + |
| 44 | + model_with_circular_ref_a = cls( |
| 45 | + circular=circular, |
| 46 | + ) |
| 47 | + |
| 48 | + model_with_circular_ref_a.additional_properties = d |
| 49 | + return model_with_circular_ref_a |
| 50 | + |
| 51 | + @property |
| 52 | + def additional_keys(self) -> List[str]: |
| 53 | + return list(self.additional_properties.keys()) |
| 54 | + |
| 55 | + def __getitem__(self, key: str) -> Any: |
| 56 | + return self.additional_properties[key] |
| 57 | + |
| 58 | + def __setitem__(self, key: str, value: Any) -> None: |
| 59 | + self.additional_properties[key] = value |
| 60 | + |
| 61 | + def __delitem__(self, key: str) -> None: |
| 62 | + del self.additional_properties[key] |
| 63 | + |
| 64 | + def __contains__(self, key: str) -> bool: |
| 65 | + return key in self.additional_properties |
0 commit comments