142 lines
4.2 KiB
Python
142 lines
4.2 KiB
Python
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="NodeAccess")
|
|
|
|
|
|
@_attrs_define
|
|
class NodeAccess:
|
|
"""Serializer (read/write) for `NodeAccess` model
|
|
|
|
Attributes:
|
|
event (int):
|
|
event_id (int):
|
|
id (int):
|
|
label (str):
|
|
node_configuration_ids (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: int
|
|
event_id: int
|
|
id: int
|
|
label: str
|
|
node_configuration_ids: list[int]
|
|
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 = 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(
|
|
{
|
|
"event": event,
|
|
"event_id": event_id,
|
|
"id": id,
|
|
"label": label,
|
|
"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 = []
|
|
|
|
files.append(("event", (None, str(self.event).encode(), "text/plain")))
|
|
|
|
files.append(("event_id", (None, str(self.event_id).encode(), "text/plain")))
|
|
|
|
files.append(("id", (None, str(self.id).encode(), "text/plain")))
|
|
|
|
files.append(("label", (None, str(self.label).encode(), "text/plain")))
|
|
|
|
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")
|
|
|
|
event_id = d.pop("event_id")
|
|
|
|
id = d.pop("id")
|
|
|
|
label = d.pop("label")
|
|
|
|
node_configuration_ids = cast(list[int], d.pop("node_configuration_ids"))
|
|
|
|
condition_id = d.pop("condition_id", UNSET)
|
|
|
|
is_accessible = d.pop("is_accessible", UNSET)
|
|
|
|
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,
|
|
)
|
|
|
|
node_access.additional_properties = d
|
|
return 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
|