146 lines
3.7 KiB
Python
146 lines
3.7 KiB
Python
from collections.abc import Mapping
|
|
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
|
|
from uuid import UUID
|
|
|
|
from attrs import define as _attrs_define
|
|
from attrs import field as _attrs_field
|
|
|
|
from .zone_state_enum import ZoneStateEnum
|
|
from .zone_type_enum import ZoneTypeEnum
|
|
|
|
if TYPE_CHECKING:
|
|
from .zone_area_type_0 import ZoneAreaType0
|
|
|
|
|
|
T = TypeVar("T", bound="Zone")
|
|
|
|
|
|
@_attrs_define
|
|
class Zone:
|
|
"""
|
|
Attributes:
|
|
uuid (UUID):
|
|
name (str):
|
|
type_ (ZoneTypeEnum): * `1` - manual
|
|
* `2` - neighborhood partition
|
|
area (Union['ZoneAreaType0', None]):
|
|
state (ZoneStateEnum): * `1` - not_active
|
|
* `10` - active
|
|
total_score (int):
|
|
activation_score (str):
|
|
location (Any):
|
|
"""
|
|
|
|
uuid: UUID
|
|
name: str
|
|
type_: ZoneTypeEnum
|
|
area: Union["ZoneAreaType0", None]
|
|
state: ZoneStateEnum
|
|
total_score: int
|
|
activation_score: str
|
|
location: Any
|
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
from .zone_area_type_0 import ZoneAreaType0
|
|
|
|
uuid = str(self.uuid)
|
|
|
|
name = self.name
|
|
|
|
type_ = self.type_.value
|
|
|
|
area: Union[None, dict[str, Any]]
|
|
if isinstance(self.area, ZoneAreaType0):
|
|
area = self.area.to_dict()
|
|
else:
|
|
area = self.area
|
|
|
|
state = self.state.value
|
|
|
|
total_score = self.total_score
|
|
|
|
activation_score = self.activation_score
|
|
|
|
location = self.location
|
|
|
|
field_dict: dict[str, Any] = {}
|
|
field_dict.update(self.additional_properties)
|
|
field_dict.update(
|
|
{
|
|
"uuid": uuid,
|
|
"name": name,
|
|
"type": type_,
|
|
"area": area,
|
|
"state": state,
|
|
"total_score": total_score,
|
|
"activation_score": activation_score,
|
|
"location": location,
|
|
}
|
|
)
|
|
|
|
return field_dict
|
|
|
|
@classmethod
|
|
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
from .zone_area_type_0 import ZoneAreaType0
|
|
|
|
d = dict(src_dict)
|
|
uuid = UUID(d.pop("uuid"))
|
|
|
|
name = d.pop("name")
|
|
|
|
type_ = ZoneTypeEnum(d.pop("type"))
|
|
|
|
def _parse_area(data: object) -> Union["ZoneAreaType0", None]:
|
|
if data is None:
|
|
return data
|
|
try:
|
|
if not isinstance(data, dict):
|
|
raise TypeError()
|
|
area_type_0 = ZoneAreaType0.from_dict(data)
|
|
|
|
return area_type_0
|
|
except: # noqa: E722
|
|
pass
|
|
return cast(Union["ZoneAreaType0", None], data)
|
|
|
|
area = _parse_area(d.pop("area"))
|
|
|
|
state = ZoneStateEnum(d.pop("state"))
|
|
|
|
total_score = d.pop("total_score")
|
|
|
|
activation_score = d.pop("activation_score")
|
|
|
|
location = d.pop("location")
|
|
|
|
zone = cls(
|
|
uuid=uuid,
|
|
name=name,
|
|
type_=type_,
|
|
area=area,
|
|
state=state,
|
|
total_score=total_score,
|
|
activation_score=activation_score,
|
|
location=location,
|
|
)
|
|
|
|
zone.additional_properties = d
|
|
return zone
|
|
|
|
@property
|
|
def additional_keys(self) -> list[str]:
|
|
return list(self.additional_properties.keys())
|
|
|
|
def __getitem__(self, key: str) -> Any:
|
|
return self.additional_properties[key]
|
|
|
|
def __setitem__(self, key: str, value: Any) -> None:
|
|
self.additional_properties[key] = value
|
|
|
|
def __delitem__(self, key: str) -> None:
|
|
del self.additional_properties[key]
|
|
|
|
def __contains__(self, key: str) -> bool:
|
|
return key in self.additional_properties
|