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