|
| 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="AModelWithIndirectSelfReferenceProperty") |
| 9 | + |
| 10 | + |
| 11 | +@attr.s(auto_attribs=True) |
| 12 | +class AModelWithIndirectSelfReferenceProperty: |
| 13 | + """ """ |
| 14 | + |
| 15 | + required_self_ref: AModelWithIndirectSelfReferenceProperty |
| 16 | + an_enum: Union[Unset, AnEnum] = UNSET |
| 17 | + optional_self_ref: Union[Unset, AModelWithIndirectSelfReferenceProperty] = UNSET |
| 18 | + additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) |
| 19 | + |
| 20 | + def to_dict(self) -> Dict[str, Any]: |
| 21 | + required_self_ref = self.required_self_ref |
| 22 | + an_enum: Union[Unset, str] = UNSET |
| 23 | + if not isinstance(self.an_enum, Unset): |
| 24 | + an_enum = self.an_enum.value |
| 25 | + |
| 26 | + optional_self_ref = self.optional_self_ref |
| 27 | + |
| 28 | + field_dict: Dict[str, Any] = {} |
| 29 | + field_dict.update(self.additional_properties) |
| 30 | + field_dict.update( |
| 31 | + { |
| 32 | + "required_self_ref": required_self_ref, |
| 33 | + } |
| 34 | + ) |
| 35 | + if an_enum is not UNSET: |
| 36 | + field_dict["an_enum"] = an_enum |
| 37 | + if optional_self_ref is not UNSET: |
| 38 | + field_dict["optional_self_ref"] = optional_self_ref |
| 39 | + |
| 40 | + return field_dict |
| 41 | + |
| 42 | + @classmethod |
| 43 | + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: |
| 44 | + d = src_dict.copy() |
| 45 | + required_self_ref = d.pop("required_self_ref") |
| 46 | + |
| 47 | + an_enum: Union[Unset, AnEnum] = UNSET |
| 48 | + _an_enum = d.pop("an_enum", UNSET) |
| 49 | + if not isinstance(_an_enum, Unset): |
| 50 | + an_enum = AnEnum(_an_enum) |
| 51 | + |
| 52 | + optional_self_ref = d.pop("optional_self_ref", UNSET) |
| 53 | + |
| 54 | + a_model_with_indirect_self_reference_property = cls( |
| 55 | + required_self_ref=required_self_ref, |
| 56 | + an_enum=an_enum, |
| 57 | + optional_self_ref=optional_self_ref, |
| 58 | + ) |
| 59 | + |
| 60 | + a_model_with_indirect_self_reference_property.additional_properties = d |
| 61 | + return a_model_with_indirect_self_reference_property |
| 62 | + |
| 63 | + @property |
| 64 | + def additional_keys(self) -> List[str]: |
| 65 | + return list(self.additional_properties.keys()) |
| 66 | + |
| 67 | + def __getitem__(self, key: str) -> Any: |
| 68 | + return self.additional_properties[key] |
| 69 | + |
| 70 | + def __setitem__(self, key: str, value: Any) -> None: |
| 71 | + self.additional_properties[key] = value |
| 72 | + |
| 73 | + def __delitem__(self, key: str) -> None: |
| 74 | + del self.additional_properties[key] |
| 75 | + |
| 76 | + def __contains__(self, key: str) -> bool: |
| 77 | + return key in self.additional_properties |
0 commit comments