|
- 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 ..types import UNSET, Unset
-
- T = TypeVar("T", bound="PlanItem")
-
-
- @_attrs_define
- class PlanItem:
- """A plan is floor or a space of a building
-
- Attributes:
- id (UUID): ID
- name (str): Name Example: Building 1 - Floor 1.
- image (Union[Unset, str]): Image Example: The URL of the image.
- scale (Union[Unset, float]): Scale Example: 1.
- building (Union[Unset, UUID]): Building
- """
-
- id: UUID
- name: str
- image: Union[Unset, str] = UNSET
- scale: Union[Unset, float] = 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
-
- image = self.image
-
- scale = self.scale
-
- 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 image is not UNSET:
- field_dict["image"] = image
- if scale is not UNSET:
- field_dict["scale"] = scale
- 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")
-
- image = d.pop("image", UNSET)
-
- scale = d.pop("scale", UNSET)
-
- _building = d.pop("building", UNSET)
- building: Union[Unset, UUID]
- if isinstance(_building, Unset):
- building = UNSET
- else:
- building = UUID(_building)
-
- plan_item = cls(
- id=id,
- name=name,
- image=image,
- scale=scale,
- building=building,
- )
-
- plan_item.additional_properties = d
- return plan_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
|