您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

167 行
4.2 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="TrackerItem")
  8. @_attrs_define
  9. class TrackerItem:
  10. """A tracker of the system
  11. Attributes:
  12. id (UUID): ID
  13. name (str): Name
  14. mac (Union[Unset, str]): MAC
  15. status (Union[Unset, str]): Status
  16. model (Union[Unset, str]): Model
  17. position (Union[Unset, str]): Position
  18. x (Union[Unset, float]): X
  19. y (Union[Unset, float]): Y
  20. zone (Union[Unset, UUID]): Zone
  21. building (Union[Unset, UUID]): Building
  22. notes (Union[Unset, str]): Notes
  23. """
  24. id: UUID
  25. name: str
  26. mac: Union[Unset, str] = UNSET
  27. status: Union[Unset, str] = UNSET
  28. model: Union[Unset, str] = UNSET
  29. position: Union[Unset, str] = UNSET
  30. x: Union[Unset, float] = UNSET
  31. y: Union[Unset, float] = UNSET
  32. zone: Union[Unset, UUID] = UNSET
  33. building: Union[Unset, UUID] = UNSET
  34. notes: Union[Unset, str] = UNSET
  35. additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
  36. def to_dict(self) -> dict[str, Any]:
  37. id = str(self.id)
  38. name = self.name
  39. mac = self.mac
  40. status = self.status
  41. model = self.model
  42. position = self.position
  43. x = self.x
  44. y = self.y
  45. zone: Union[Unset, str] = UNSET
  46. if not isinstance(self.zone, Unset):
  47. zone = str(self.zone)
  48. building: Union[Unset, str] = UNSET
  49. if not isinstance(self.building, Unset):
  50. building = str(self.building)
  51. notes = self.notes
  52. field_dict: dict[str, Any] = {}
  53. field_dict.update(self.additional_properties)
  54. field_dict.update(
  55. {
  56. "id": id,
  57. "name": name,
  58. }
  59. )
  60. if mac is not UNSET:
  61. field_dict["mac"] = mac
  62. if status is not UNSET:
  63. field_dict["status"] = status
  64. if model is not UNSET:
  65. field_dict["model"] = model
  66. if position is not UNSET:
  67. field_dict["position"] = position
  68. if x is not UNSET:
  69. field_dict["x"] = x
  70. if y is not UNSET:
  71. field_dict["y"] = y
  72. if zone is not UNSET:
  73. field_dict["zone"] = zone
  74. if building is not UNSET:
  75. field_dict["building"] = building
  76. if notes is not UNSET:
  77. field_dict["notes"] = notes
  78. return field_dict
  79. @classmethod
  80. def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
  81. d = dict(src_dict)
  82. id = UUID(d.pop("id"))
  83. name = d.pop("name")
  84. mac = d.pop("mac", UNSET)
  85. status = d.pop("status", UNSET)
  86. model = d.pop("model", UNSET)
  87. position = d.pop("position", UNSET)
  88. x = d.pop("x", UNSET)
  89. y = d.pop("y", UNSET)
  90. _zone = d.pop("zone", UNSET)
  91. zone: Union[Unset, UUID]
  92. if isinstance(_zone, Unset):
  93. zone = UNSET
  94. else:
  95. zone = UUID(_zone)
  96. _building = d.pop("building", UNSET)
  97. building: Union[Unset, UUID]
  98. if isinstance(_building, Unset):
  99. building = UNSET
  100. else:
  101. building = UUID(_building)
  102. notes = d.pop("notes", UNSET)
  103. tracker_item = cls(
  104. id=id,
  105. name=name,
  106. mac=mac,
  107. status=status,
  108. model=model,
  109. position=position,
  110. x=x,
  111. y=y,
  112. zone=zone,
  113. building=building,
  114. notes=notes,
  115. )
  116. tracker_item.additional_properties = d
  117. return tracker_item
  118. @property
  119. def additional_keys(self) -> list[str]:
  120. return list(self.additional_properties.keys())
  121. def __getitem__(self, key: str) -> Any:
  122. return self.additional_properties[key]
  123. def __setitem__(self, key: str, value: Any) -> None:
  124. self.additional_properties[key] = value
  125. def __delitem__(self, key: str) -> None:
  126. del self.additional_properties[key]
  127. def __contains__(self, key: str) -> bool:
  128. return key in self.additional_properties