|
- from collections.abc import Mapping
- from typing import Any, TypeVar, Union
- from uuid import UUID
-
- from attrs import define as _attrs_define
- from attrs import field as _attrs_field
-
- from app_types import UNSET, Unset
-
- T = TypeVar("T", bound="ZoneItem")
-
-
- @_attrs_define
- class ZoneItem:
- """A zone is a room or a sub-area of a plan
-
- Attributes:
- id (UUID): ID
- name (str): Name Example: Floor 1 - Room 1.
- groups (Union[Unset, str]): Groups
- plan (Union[Unset, UUID]): Plan
- building (Union[Unset, UUID]): Building
- """
-
- id: UUID
- name: str
- groups: Union[Unset, str] = UNSET
- plan: Union[Unset, UUID] = UNSET
- building: Union[Unset, UUID] = UNSET
- additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
-
- def to_dict(self) -> dict[str, Any]:
- id = str(self.id)
-
- name = self.name
-
- groups = self.groups
-
- plan: Union[Unset, str] = UNSET
- if not isinstance(self.plan, Unset):
- plan = str(self.plan)
-
- building: Union[Unset, str] = UNSET
- if not isinstance(self.building, Unset):
- building = str(self.building)
-
- field_dict: dict[str, Any] = {}
- field_dict.update(self.additional_properties)
- field_dict.update(
- {
- "id": id,
- "name": name,
- }
- )
- if groups is not UNSET:
- field_dict["groups"] = groups
- if plan is not UNSET:
- field_dict["plan"] = plan
- if building is not UNSET:
- field_dict["building"] = building
-
- return field_dict
-
- @classmethod
- def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- d = dict(src_dict)
- id = UUID(d.pop("id"))
-
- name = d.pop("name")
-
- groups = d.pop("groups", UNSET)
-
- _plan = d.pop("plan", UNSET)
- plan: Union[Unset, UUID]
- if isinstance(_plan, Unset):
- plan = UNSET
- else:
- plan = UUID(_plan)
-
- _building = d.pop("building", UNSET)
- building: Union[Unset, UUID]
- if isinstance(_building, Unset):
- building = UNSET
- else:
- building = UUID(_building)
-
- zone_item = cls(
- id=id,
- name=name,
- groups=groups,
- plan=plan,
- building=building,
- )
-
- zone_item.additional_properties = d
- return zone_item
-
- @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
|