session_time.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. from collections.abc import Mapping
  2. from typing import Any, TypeVar, Union
  3. from attrs import define as _attrs_define
  4. from attrs import field as _attrs_field
  5. from ..types import UNSET, Unset
  6. T = TypeVar("T", bound="SessionTime")
  7. @_attrs_define
  8. class SessionTime:
  9. """
  10. Attributes:
  11. created (float):
  12. updated (float):
  13. compacting (Union[Unset, float]):
  14. """
  15. created: float
  16. updated: float
  17. compacting: Union[Unset, float] = UNSET
  18. additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
  19. def to_dict(self) -> dict[str, Any]:
  20. created = self.created
  21. updated = self.updated
  22. compacting = self.compacting
  23. field_dict: dict[str, Any] = {}
  24. field_dict.update(self.additional_properties)
  25. field_dict.update(
  26. {
  27. "created": created,
  28. "updated": updated,
  29. }
  30. )
  31. if compacting is not UNSET:
  32. field_dict["compacting"] = compacting
  33. return field_dict
  34. @classmethod
  35. def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
  36. d = dict(src_dict)
  37. created = d.pop("created")
  38. updated = d.pop("updated")
  39. compacting = d.pop("compacting", UNSET)
  40. session_time = cls(
  41. created=created,
  42. updated=updated,
  43. compacting=compacting,
  44. )
  45. session_time.additional_properties = d
  46. return session_time
  47. @property
  48. def additional_keys(self) -> list[str]:
  49. return list(self.additional_properties.keys())
  50. def __getitem__(self, key: str) -> Any:
  51. return self.additional_properties[key]
  52. def __setitem__(self, key: str, value: Any) -> None:
  53. self.additional_properties[key] = value
  54. def __delitem__(self, key: str) -> None:
  55. del self.additional_properties[key]
  56. def __contains__(self, key: str) -> bool:
  57. return key in self.additional_properties