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="PatchedNodeAccess") @_attrs_define class PatchedNodeAccess: """Serializer (read/write) for `NodeAccess` model Attributes: event (Union[Unset, int]): event_id (Union[Unset, int]): id (Union[Unset, int]): label (Union[Unset, str]): node_configuration_ids (Union[Unset, list[int]]): condition_id (Union[Unset, int]): is_accessible (Union[Unset, bool]): if True and user matches the conditions they should have access to the node, if False and user matches the conditions they should not have access to the node """ event: Union[Unset, int] = UNSET event_id: Union[Unset, int] = UNSET id: Union[Unset, int] = UNSET label: Union[Unset, str] = UNSET node_configuration_ids: Union[Unset, list[int]] = UNSET condition_id: Union[Unset, int] = UNSET is_accessible: Union[Unset, bool] = 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 label = self.label 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 is_accessible = self.is_accessible 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 label is not UNSET: field_dict["label"] = label 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 if is_accessible is not UNSET: field_dict["is_accessible"] = is_accessible 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.label, Unset): files.append(("label", (None, str(self.label).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"))) if not isinstance(self.is_accessible, Unset): files.append(("is_accessible", (None, str(self.is_accessible).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) label = d.pop("label", UNSET) node_configuration_ids = cast(list[int], d.pop("node_configuration_ids", UNSET)) condition_id = d.pop("condition_id", UNSET) is_accessible = d.pop("is_accessible", UNSET) patched_node_access = cls( event=event, event_id=event_id, id=id, label=label, node_configuration_ids=node_configuration_ids, condition_id=condition_id, is_accessible=is_accessible, ) patched_node_access.additional_properties = d return patched_node_access @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