Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

106 строки
2.7 KiB

  1. from collections.abc import Mapping
  2. from typing import Any, TypeVar, Union
  3. from uuid import UUID
  4. from attrs import define as _attrs_define
  5. from attrs import field as _attrs_field
  6. from app_types import UNSET, Unset
  7. T = TypeVar("T", bound="PlanItem")
  8. @_attrs_define
  9. class PlanItem:
  10. """A plan is floor or a space of a building
  11. Attributes:
  12. id (UUID): ID
  13. name (str): Name Example: Building 1 - Floor 1.
  14. image (Union[Unset, str]): Image Example: The URL of the image.
  15. scale (Union[Unset, float]): Scale Example: 1.
  16. building (Union[Unset, UUID]): Building
  17. """
  18. id: UUID
  19. name: str
  20. image: Union[Unset, str] = UNSET
  21. scale: Union[Unset, float] = UNSET
  22. building: Union[Unset, UUID] = UNSET
  23. additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
  24. def to_dict(self) -> dict[str, Any]:
  25. id = str(self.id)
  26. name = self.name
  27. image = self.image
  28. scale = self.scale
  29. building: Union[Unset, str] = UNSET
  30. if not isinstance(self.building, Unset):
  31. building = str(self.building)
  32. field_dict: dict[str, Any] = {}
  33. field_dict.update(self.additional_properties)
  34. field_dict.update(
  35. {
  36. "id": id,
  37. "name": name,
  38. }
  39. )
  40. if image is not UNSET:
  41. field_dict["image"] = image
  42. if scale is not UNSET:
  43. field_dict["scale"] = scale
  44. if building is not UNSET:
  45. field_dict["building"] = building
  46. return field_dict
  47. @classmethod
  48. def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
  49. d = dict(src_dict)
  50. id = UUID(d.pop("id"))
  51. name = d.pop("name")
  52. image = d.pop("image", UNSET)
  53. scale = d.pop("scale", UNSET)
  54. _building = d.pop("building", UNSET)
  55. building: Union[Unset, UUID]
  56. if isinstance(_building, Unset):
  57. building = UNSET
  58. else:
  59. building = UUID(_building)
  60. plan_item = cls(
  61. id=id,
  62. name=name,
  63. image=image,
  64. scale=scale,
  65. building=building,
  66. )
  67. plan_item.additional_properties = d
  68. return plan_item
  69. @property
  70. def additional_keys(self) -> list[str]:
  71. return list(self.additional_properties.keys())
  72. def __getitem__(self, key: str) -> Any:
  73. return self.additional_properties[key]
  74. def __setitem__(self, key: str, value: Any) -> None:
  75. self.additional_properties[key] = value
  76. def __delitem__(self, key: str) -> None:
  77. del self.additional_properties[key]
  78. def __contains__(self, key: str) -> bool:
  79. return key in self.additional_properties