from collections.abc import Mapping from typing import Any, TypeVar, Union, cast from attrs import define as _attrs_define from attrs import field as _attrs_field from .. import types from ..types import UNSET, Unset T = TypeVar("T", bound="PatchedNodeLimit") @_attrs_define class PatchedNodeLimit: """Serializer (read/write) for `NodeLimit` model Attributes: event (Union[Unset, int]): event_id (Union[Unset, int]): id (Union[Unset, int]): is_deleted (Union[Unset, bool]): key (Union[Unset, str]): label (Union[Unset, str]): maximum (Union[Unset, int]): order (Union[Unset, int]): global_order (Union[Unset, int]): node_configuration_ids (Union[Unset, list[int]]): condition_id (Union[Unset, int]): """ event: Union[Unset, int] = UNSET event_id: Union[Unset, int] = UNSET id: Union[Unset, int] = UNSET is_deleted: Union[Unset, bool] = UNSET key: Union[Unset, str] = UNSET label: Union[Unset, str] = UNSET maximum: Union[Unset, int] = UNSET order: Union[Unset, int] = UNSET global_order: Union[Unset, int] = UNSET node_configuration_ids: Union[Unset, list[int]] = UNSET condition_id: Union[Unset, int] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: event = self.event event_id = self.event_id id = self.id is_deleted = self.is_deleted key = self.key label = self.label maximum = self.maximum order = self.order global_order = self.global_order node_configuration_ids: Union[Unset, list[int]] = UNSET if not isinstance(self.node_configuration_ids, Unset): node_configuration_ids = self.node_configuration_ids condition_id = self.condition_id field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if event is not UNSET: field_dict["event"] = event if event_id is not UNSET: field_dict["event_id"] = event_id if id is not UNSET: field_dict["id"] = id if is_deleted is not UNSET: field_dict["is_deleted"] = is_deleted if key is not UNSET: field_dict["key"] = key if label is not UNSET: field_dict["label"] = label if maximum is not UNSET: field_dict["maximum"] = maximum if order is not UNSET: field_dict["order"] = order if global_order is not UNSET: field_dict["global_order"] = global_order if node_configuration_ids is not UNSET: field_dict["node_configuration_ids"] = node_configuration_ids if condition_id is not UNSET: field_dict["condition_id"] = condition_id return field_dict def to_multipart(self) -> types.RequestFiles: files: types.RequestFiles = [] if not isinstance(self.event, Unset): files.append(("event", (None, str(self.event).encode(), "text/plain"))) if not isinstance(self.event_id, Unset): files.append(("event_id", (None, str(self.event_id).encode(), "text/plain"))) if not isinstance(self.id, Unset): files.append(("id", (None, str(self.id).encode(), "text/plain"))) if not isinstance(self.is_deleted, Unset): files.append(("is_deleted", (None, str(self.is_deleted).encode(), "text/plain"))) if not isinstance(self.key, Unset): files.append(("key", (None, str(self.key).encode(), "text/plain"))) if not isinstance(self.label, Unset): files.append(("label", (None, str(self.label).encode(), "text/plain"))) if not isinstance(self.maximum, Unset): files.append(("maximum", (None, str(self.maximum).encode(), "text/plain"))) if not isinstance(self.order, Unset): files.append(("order", (None, str(self.order).encode(), "text/plain"))) if not isinstance(self.global_order, Unset): files.append(("global_order", (None, str(self.global_order).encode(), "text/plain"))) if not isinstance(self.node_configuration_ids, Unset): for node_configuration_ids_item_element in self.node_configuration_ids: files.append( ("node_configuration_ids", (None, str(node_configuration_ids_item_element).encode(), "text/plain")) ) if not isinstance(self.condition_id, Unset): files.append(("condition_id", (None, str(self.condition_id).encode(), "text/plain"))) for prop_name, prop in self.additional_properties.items(): files.append((prop_name, (None, str(prop).encode(), "text/plain"))) return files @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) event = d.pop("event", UNSET) event_id = d.pop("event_id", UNSET) id = d.pop("id", UNSET) is_deleted = d.pop("is_deleted", UNSET) key = d.pop("key", UNSET) label = d.pop("label", UNSET) maximum = d.pop("maximum", UNSET) order = d.pop("order", UNSET) global_order = d.pop("global_order", UNSET) node_configuration_ids = cast(list[int], d.pop("node_configuration_ids", UNSET)) condition_id = d.pop("condition_id", UNSET) patched_node_limit = cls( event=event, event_id=event_id, id=id, is_deleted=is_deleted, key=key, label=label, maximum=maximum, order=order, global_order=global_order, node_configuration_ids=node_configuration_ids, condition_id=condition_id, ) patched_node_limit.additional_properties = d return patched_node_limit @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) def __getitem__(self, key: str) -> Any: return self.additional_properties[key] def __setitem__(self, key: str, value: Any) -> None: self.additional_properties[key] = value def __delitem__(self, key: str) -> None: del self.additional_properties[key] def __contains__(self, key: str) -> bool: return key in self.additional_properties