Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

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