選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

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