|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +from collections.abc import Mapping |
| 4 | +from typing import Any, TypeVar |
| 5 | + |
| 6 | +from attrs import define as _attrs_define |
| 7 | +from attrs import field as _attrs_field |
| 8 | + |
| 9 | +from ..types import UNSET, Unset |
| 10 | + |
| 11 | +T = TypeVar("T", bound="AllOfRequiredBase") |
| 12 | + |
| 13 | + |
| 14 | +@_attrs_define |
| 15 | +class AllOfRequiredBase: |
| 16 | + """ |
| 17 | + Attributes: |
| 18 | + bar (str | Unset): The bar property |
| 19 | + baz (str | Unset): The baz property |
| 20 | + """ |
| 21 | + |
| 22 | + bar: str | Unset = UNSET |
| 23 | + baz: str | Unset = UNSET |
| 24 | + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) |
| 25 | + |
| 26 | + def to_dict(self) -> dict[str, Any]: |
| 27 | + bar = self.bar |
| 28 | + |
| 29 | + baz = self.baz |
| 30 | + |
| 31 | + field_dict: dict[str, Any] = {} |
| 32 | + field_dict.update(self.additional_properties) |
| 33 | + field_dict.update({}) |
| 34 | + if bar is not UNSET: |
| 35 | + field_dict["bar"] = bar |
| 36 | + if baz is not UNSET: |
| 37 | + field_dict["baz"] = baz |
| 38 | + |
| 39 | + return field_dict |
| 40 | + |
| 41 | + @classmethod |
| 42 | + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: |
| 43 | + d = dict(src_dict) |
| 44 | + bar = d.pop("bar", UNSET) |
| 45 | + |
| 46 | + baz = d.pop("baz", UNSET) |
| 47 | + |
| 48 | + all_of_required_base = cls( |
| 49 | + bar=bar, |
| 50 | + baz=baz, |
| 51 | + ) |
| 52 | + |
| 53 | + all_of_required_base.additional_properties = d |
| 54 | + return all_of_required_base |
| 55 | + |
| 56 | + @property |
| 57 | + def additional_keys(self) -> list[str]: |
| 58 | + return list(self.additional_properties.keys()) |
| 59 | + |
| 60 | + def __getitem__(self, key: str) -> Any: |
| 61 | + return self.additional_properties[key] |
| 62 | + |
| 63 | + def __setitem__(self, key: str, value: Any) -> None: |
| 64 | + self.additional_properties[key] = value |
| 65 | + |
| 66 | + def __delitem__(self, key: str) -> None: |
| 67 | + del self.additional_properties[key] |
| 68 | + |
| 69 | + def __contains__(self, key: str) -> bool: |
| 70 | + return key in self.additional_properties |
0 commit comments