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.
 
 
 
 

124 regels
3.1 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="OperatorItem")
  8. @_attrs_define
  9. class OperatorItem:
  10. """An operator who monitors the subjects
  11. Attributes:
  12. id (str): ID
  13. name (str): Name
  14. phone (Union[Unset, str]): Phone
  15. zones (Union[Unset, str]): Zones
  16. groups (Union[Unset, str]): Groups
  17. notes (Union[Unset, str]): Notes
  18. building (Union[Unset, UUID]): Building
  19. """
  20. id: str
  21. name: str
  22. phone: Union[Unset, str] = UNSET
  23. zones: Union[Unset, str] = UNSET
  24. groups: Union[Unset, str] = UNSET
  25. notes: Union[Unset, str] = UNSET
  26. building: Union[Unset, UUID] = UNSET
  27. additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
  28. def to_dict(self) -> dict[str, Any]:
  29. id = self.id
  30. name = self.name
  31. phone = self.phone
  32. zones = self.zones
  33. groups = self.groups
  34. notes = self.notes
  35. building: Union[Unset, str] = UNSET
  36. if not isinstance(self.building, Unset):
  37. building = str(self.building)
  38. field_dict: dict[str, Any] = {}
  39. field_dict.update(self.additional_properties)
  40. field_dict.update(
  41. {
  42. "id": id,
  43. "name": name,
  44. }
  45. )
  46. if phone is not UNSET:
  47. field_dict["phone"] = phone
  48. if zones is not UNSET:
  49. field_dict["zones"] = zones
  50. if groups is not UNSET:
  51. field_dict["groups"] = groups
  52. if notes is not UNSET:
  53. field_dict["notes"] = notes
  54. if building is not UNSET:
  55. field_dict["building"] = building
  56. return field_dict
  57. @classmethod
  58. def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
  59. d = dict(src_dict)
  60. id = d.pop("id")
  61. name = d.pop("name")
  62. phone = d.pop("phone", UNSET)
  63. zones = d.pop("zones", UNSET)
  64. groups = d.pop("groups", UNSET)
  65. notes = d.pop("notes", UNSET)
  66. _building = d.pop("building", UNSET)
  67. building: Union[Unset, UUID]
  68. if isinstance(_building, Unset):
  69. building = UNSET
  70. else:
  71. building = UUID(_building)
  72. operator_item = cls(
  73. id=id,
  74. name=name,
  75. phone=phone,
  76. zones=zones,
  77. groups=groups,
  78. notes=notes,
  79. building=building,
  80. )
  81. operator_item.additional_properties = d
  82. return operator_item
  83. @property
  84. def additional_keys(self) -> list[str]:
  85. return list(self.additional_properties.keys())
  86. def __getitem__(self, key: str) -> Any:
  87. return self.additional_properties[key]
  88. def __setitem__(self, key: str, value: Any) -> None:
  89. self.additional_properties[key] = value
  90. def __delitem__(self, key: str) -> None:
  91. del self.additional_properties[key]
  92. def __contains__(self, key: str) -> bool:
  93. return key in self.additional_properties