You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

113 lines
2.9 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 ..types import UNSET, Unset
  7. T = TypeVar("T", bound="ZoneItem")
  8. @_attrs_define
  9. class ZoneItem:
  10. """A zone is a room or a sub-area of a plan
  11. Attributes:
  12. id (UUID): ID
  13. name (str): Name Example: Floor 1 - Room 1.
  14. groups (Union[Unset, str]): Groups
  15. plan (Union[Unset, UUID]): Plan
  16. building (Union[Unset, UUID]): Building
  17. """
  18. id: UUID
  19. name: str
  20. groups: Union[Unset, str] = UNSET
  21. plan: Union[Unset, UUID] = 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. groups = self.groups
  28. plan: Union[Unset, str] = UNSET
  29. if not isinstance(self.plan, Unset):
  30. plan = str(self.plan)
  31. building: Union[Unset, str] = UNSET
  32. if not isinstance(self.building, Unset):
  33. building = str(self.building)
  34. field_dict: dict[str, Any] = {}
  35. field_dict.update(self.additional_properties)
  36. field_dict.update(
  37. {
  38. "id": id,
  39. "name": name,
  40. }
  41. )
  42. if groups is not UNSET:
  43. field_dict["groups"] = groups
  44. if plan is not UNSET:
  45. field_dict["plan"] = plan
  46. if building is not UNSET:
  47. field_dict["building"] = building
  48. return field_dict
  49. @classmethod
  50. def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
  51. d = dict(src_dict)
  52. id = UUID(d.pop("id"))
  53. name = d.pop("name")
  54. groups = d.pop("groups", UNSET)
  55. _plan = d.pop("plan", UNSET)
  56. plan: Union[Unset, UUID]
  57. if isinstance(_plan, Unset):
  58. plan = UNSET
  59. else:
  60. plan = UUID(_plan)
  61. _building = d.pop("building", UNSET)
  62. building: Union[Unset, UUID]
  63. if isinstance(_building, Unset):
  64. building = UNSET
  65. else:
  66. building = UUID(_building)
  67. zone_item = cls(
  68. id=id,
  69. name=name,
  70. groups=groups,
  71. plan=plan,
  72. building=building,
  73. )
  74. zone_item.additional_properties = d
  75. return zone_item
  76. @property
  77. def additional_keys(self) -> list[str]:
  78. return list(self.additional_properties.keys())
  79. def __getitem__(self, key: str) -> Any:
  80. return self.additional_properties[key]
  81. def __setitem__(self, key: str, value: Any) -> None:
  82. self.additional_properties[key] = value
  83. def __delitem__(self, key: str) -> None:
  84. del self.additional_properties[key]
  85. def __contains__(self, key: str) -> bool:
  86. return key in self.additional_properties