|
| 1 | +from typing import Any, Dict, List, Literal, Type, TypeVar, Union, cast |
| 2 | + |
| 3 | +from attrs import define as _attrs_define |
| 4 | +from attrs import field as _attrs_field |
| 5 | + |
| 6 | +from ..types import UNSET, Unset |
| 7 | + |
| 8 | +T = TypeVar("T", bound="PostPrefixItemsBody") |
| 9 | + |
| 10 | + |
| 11 | +@_attrs_define |
| 12 | +class PostPrefixItemsBody: |
| 13 | + """ |
| 14 | + Attributes: |
| 15 | + prefix_items_and_items (Union[Unset, List[Union[Literal['prefix'], float, str]]]): |
| 16 | + prefix_items_only (Union[Unset, List[Union[float, str]]]): |
| 17 | + """ |
| 18 | + |
| 19 | + prefix_items_and_items: Union[Unset, List[Union[Literal["prefix"], float, str]]] = UNSET |
| 20 | + prefix_items_only: Union[Unset, List[Union[float, str]]] = UNSET |
| 21 | + additional_properties: Dict[str, Any] = _attrs_field(init=False, factory=dict) |
| 22 | + |
| 23 | + def to_dict(self) -> Dict[str, Any]: |
| 24 | + prefix_items_and_items: Union[Unset, List[Union[Literal["prefix"], float, str]]] = UNSET |
| 25 | + if not isinstance(self.prefix_items_and_items, Unset): |
| 26 | + prefix_items_and_items = [] |
| 27 | + for prefix_items_and_items_item_data in self.prefix_items_and_items: |
| 28 | + prefix_items_and_items_item: Union[Literal["prefix"], float, str] |
| 29 | + prefix_items_and_items_item = prefix_items_and_items_item_data |
| 30 | + prefix_items_and_items.append(prefix_items_and_items_item) |
| 31 | + |
| 32 | + prefix_items_only: Union[Unset, List[Union[float, str]]] = UNSET |
| 33 | + if not isinstance(self.prefix_items_only, Unset): |
| 34 | + prefix_items_only = [] |
| 35 | + for prefix_items_only_item_data in self.prefix_items_only: |
| 36 | + prefix_items_only_item: Union[float, str] |
| 37 | + prefix_items_only_item = prefix_items_only_item_data |
| 38 | + prefix_items_only.append(prefix_items_only_item) |
| 39 | + |
| 40 | + field_dict: Dict[str, Any] = {} |
| 41 | + field_dict.update(self.additional_properties) |
| 42 | + field_dict.update({}) |
| 43 | + if prefix_items_and_items is not UNSET: |
| 44 | + field_dict["prefixItemsAndItems"] = prefix_items_and_items |
| 45 | + if prefix_items_only is not UNSET: |
| 46 | + field_dict["prefixItemsOnly"] = prefix_items_only |
| 47 | + |
| 48 | + return field_dict |
| 49 | + |
| 50 | + @classmethod |
| 51 | + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: |
| 52 | + d = src_dict.copy() |
| 53 | + prefix_items_and_items = [] |
| 54 | + _prefix_items_and_items = d.pop("prefixItemsAndItems", UNSET) |
| 55 | + for prefix_items_and_items_item_data in _prefix_items_and_items or []: |
| 56 | + |
| 57 | + def _parse_prefix_items_and_items_item(data: object) -> Union[Literal["prefix"], float, str]: |
| 58 | + prefix_items_and_items_item_type_0 = cast(Literal["prefix"], data) |
| 59 | + if prefix_items_and_items_item_type_0 != "prefix": |
| 60 | + raise ValueError( |
| 61 | + f"prefixItemsAndItems_item_type_0 must match const 'prefix', got '{prefix_items_and_items_item_type_0}'" |
| 62 | + ) |
| 63 | + return prefix_items_and_items_item_type_0 |
| 64 | + return cast(Union[Literal["prefix"], float, str], data) |
| 65 | + |
| 66 | + prefix_items_and_items_item = _parse_prefix_items_and_items_item(prefix_items_and_items_item_data) |
| 67 | + |
| 68 | + prefix_items_and_items.append(prefix_items_and_items_item) |
| 69 | + |
| 70 | + prefix_items_only = [] |
| 71 | + _prefix_items_only = d.pop("prefixItemsOnly", UNSET) |
| 72 | + for prefix_items_only_item_data in _prefix_items_only or []: |
| 73 | + |
| 74 | + def _parse_prefix_items_only_item(data: object) -> Union[float, str]: |
| 75 | + return cast(Union[float, str], data) |
| 76 | + |
| 77 | + prefix_items_only_item = _parse_prefix_items_only_item(prefix_items_only_item_data) |
| 78 | + |
| 79 | + prefix_items_only.append(prefix_items_only_item) |
| 80 | + |
| 81 | + post_prefix_items_body = cls( |
| 82 | + prefix_items_and_items=prefix_items_and_items, |
| 83 | + prefix_items_only=prefix_items_only, |
| 84 | + ) |
| 85 | + |
| 86 | + post_prefix_items_body.additional_properties = d |
| 87 | + return post_prefix_items_body |
| 88 | + |
| 89 | + @property |
| 90 | + def additional_keys(self) -> List[str]: |
| 91 | + return list(self.additional_properties.keys()) |
| 92 | + |
| 93 | + def __getitem__(self, key: str) -> Any: |
| 94 | + return self.additional_properties[key] |
| 95 | + |
| 96 | + def __setitem__(self, key: str, value: Any) -> None: |
| 97 | + self.additional_properties[key] = value |
| 98 | + |
| 99 | + def __delitem__(self, key: str) -> None: |
| 100 | + del self.additional_properties[key] |
| 101 | + |
| 102 | + def __contains__(self, key: str) -> bool: |
| 103 | + return key in self.additional_properties |
0 commit comments