switch to pydantic

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2023-11-28 23:50:50 -08:00
parent d9d73522fd
commit bc3d698539
230 changed files with 4467 additions and 25280 deletions

View File

@ -1,344 +1,97 @@
from typing import Any, Dict, List, Type, TypeVar, Union
import attr
from pydantic import BaseModel, GetCoreSchemaHandler
from pydantic_core import CoreSchema, core_schema
from ..types import UNSET, Unset
DE = TypeVar("DE", bound="ice_server_info")
from ..models.ice_server import IceServer
from ..models.ok_modeling_cmd_response import OkModelingCmdResponse
from ..models.raw_file import RawFile
from ..models.rtc_ice_candidate_init import RtcIceCandidateInit
from ..models.rtc_session_description import RtcSessionDescription
@attr.s(auto_attribs=True)
class ice_server_info:
"""Information about the ICE servers.""" # noqa: E501
class IceServerInfoData(BaseModel):
""""""
ice_servers: List[IceServer]
class ice_server_info(BaseModel):
"""Information about the ICE servers."""
data: IceServerInfoData
data: Union[Unset, Any] = UNSET
type: str = "ice_server_info"
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
data = self.data
type = self.type
class TrickleIceData(BaseModel):
""""""
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if data is not UNSET:
field_dict["data"] = data
field_dict["type"] = type
return field_dict
@classmethod
def from_dict(cls: Type[DE], src_dict: Dict[str, Any]) -> DE:
d = src_dict.copy()
data = d.pop("data", UNSET)
type = d.pop("type", UNSET)
ice_server_info = cls(
data=data,
type=type,
)
ice_server_info.additional_properties = d
return ice_server_info
@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
candidate: RtcIceCandidateInit
PU = TypeVar("PU", bound="trickle_ice")
class trickle_ice(BaseModel):
"""The trickle ICE candidate response."""
data: TrickleIceData
@attr.s(auto_attribs=True)
class trickle_ice:
"""The trickle ICE candidate response.""" # noqa: E501
data: Union[Unset, Any] = UNSET
type: str = "trickle_ice"
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
data = self.data
type = self.type
class SdpAnswerData(BaseModel):
""""""
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if data is not UNSET:
field_dict["data"] = data
field_dict["type"] = type
return field_dict
@classmethod
def from_dict(cls: Type[PU], src_dict: Dict[str, Any]) -> PU:
d = src_dict.copy()
data = d.pop("data", UNSET)
type = d.pop("type", UNSET)
trickle_ice = cls(
data=data,
type=type,
)
trickle_ice.additional_properties = d
return trickle_ice
@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
answer: RtcSessionDescription
AP = TypeVar("AP", bound="sdp_answer")
class sdp_answer(BaseModel):
"""The SDP answer response."""
data: SdpAnswerData
@attr.s(auto_attribs=True)
class sdp_answer:
"""The SDP answer response.""" # noqa: E501
data: Union[Unset, Any] = UNSET
type: str = "sdp_answer"
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
data = self.data
type = self.type
class ModelingData(BaseModel):
""""""
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if data is not UNSET:
field_dict["data"] = data
field_dict["type"] = type
return field_dict
@classmethod
def from_dict(cls: Type[AP], src_dict: Dict[str, Any]) -> AP:
d = src_dict.copy()
data = d.pop("data", UNSET)
type = d.pop("type", UNSET)
sdp_answer = cls(
data=data,
type=type,
)
sdp_answer.additional_properties = d
return sdp_answer
@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
modeling_response: OkModelingCmdResponse
AA = TypeVar("AA", bound="modeling")
class modeling(BaseModel):
"""The modeling command response."""
data: ModelingData
@attr.s(auto_attribs=True)
class modeling:
"""The modeling command response.""" # noqa: E501
data: Union[Unset, Any] = UNSET
type: str = "modeling"
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
data = self.data
type = self.type
class ExportData(BaseModel):
""""""
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if data is not UNSET:
field_dict["data"] = data
field_dict["type"] = type
return field_dict
@classmethod
def from_dict(cls: Type[AA], src_dict: Dict[str, Any]) -> AA:
d = src_dict.copy()
data = d.pop("data", UNSET)
type = d.pop("type", UNSET)
modeling = cls(
data=data,
type=type,
)
modeling.additional_properties = d
return modeling
@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
files: List[RawFile]
MH = TypeVar("MH", bound="export")
class export(BaseModel):
"""The exported files."""
data: ExportData
@attr.s(auto_attribs=True)
class export:
"""The exported files.""" # noqa: E501
data: Union[Unset, Any] = UNSET
type: str = "export"
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
data = self.data
type = self.type
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if data is not UNSET:
field_dict["data"] = data
field_dict["type"] = type
return field_dict
@classmethod
def from_dict(cls: Type[MH], src_dict: Dict[str, Any]) -> MH:
d = src_dict.copy()
data = d.pop("data", UNSET)
type = d.pop("type", UNSET)
export = cls(
data=data,
type=type,
)
export.additional_properties = d
return export
@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
class MetricsRequestData(BaseModel):
""""""
OL = TypeVar("OL", bound="metrics_request")
class metrics_request(BaseModel):
"""Request a collection of metrics, to include WebRTC."""
data: MetricsRequestData
@attr.s(auto_attribs=True)
class metrics_request:
"""Request a collection of metrics, to include WebRTC.""" # noqa: E501
data: Union[Unset, Any] = UNSET
type: str = "metrics_request"
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
data = self.data
type = self.type
field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if data is not UNSET:
field_dict["data"] = data
field_dict["type"] = type
return field_dict
@classmethod
def from_dict(cls: Type[OL], src_dict: Dict[str, Any]) -> OL:
d = src_dict.copy()
data = d.pop("data", UNSET)
type = d.pop("type", UNSET)
metrics_request = cls(
data=data,
type=type,
)
metrics_request.additional_properties = d
return metrics_request
@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
GY = TypeVar("GY", bound="OkWebSocketResponseData")
@ -370,53 +123,65 @@ class OkWebSocketResponseData:
):
self.type = type
def to_dict(self) -> Dict[str, Any]:
def model_dump(self) -> Dict[str, Any]:
if isinstance(self.type, ice_server_info):
WA: ice_server_info = self.type
return WA.to_dict()
VY: ice_server_info = self.type
return VY.model_dump()
elif isinstance(self.type, trickle_ice):
EP: trickle_ice = self.type
return EP.to_dict()
MC: trickle_ice = self.type
return MC.model_dump()
elif isinstance(self.type, sdp_answer):
JY: sdp_answer = self.type
return JY.to_dict()
BR: sdp_answer = self.type
return BR.model_dump()
elif isinstance(self.type, modeling):
BZ: modeling = self.type
return BZ.to_dict()
OK: modeling = self.type
return OK.model_dump()
elif isinstance(self.type, export):
NL: export = self.type
return NL.to_dict()
OP: export = self.type
return OP.model_dump()
elif isinstance(self.type, metrics_request):
MI: metrics_request = self.type
return MI.to_dict()
LV: metrics_request = self.type
return LV.model_dump()
raise Exception("Unknown type")
@classmethod
def from_dict(cls: Type[GY], d: Dict[str, Any]) -> GY:
if d.get("type") == "ice_server_info":
LA: ice_server_info = ice_server_info()
LA.from_dict(d)
return cls(type=LA)
DW: ice_server_info = ice_server_info(**d)
return cls(type=DW)
elif d.get("type") == "trickle_ice":
CJ: trickle_ice = trickle_ice()
CJ.from_dict(d)
return cls(type=CJ)
AV: trickle_ice = trickle_ice(**d)
return cls(type=AV)
elif d.get("type") == "sdp_answer":
FE: sdp_answer = sdp_answer()
FE.from_dict(d)
return cls(type=FE)
WM: sdp_answer = sdp_answer(**d)
return cls(type=WM)
elif d.get("type") == "modeling":
NB: modeling = modeling()
NB.from_dict(d)
return cls(type=NB)
MU: modeling = modeling(**d)
return cls(type=MU)
elif d.get("type") == "export":
TJ: export = export()
TJ.from_dict(d)
return cls(type=TJ)
WW: export = export(**d)
return cls(type=WW)
elif d.get("type") == "metrics_request":
KS: metrics_request = metrics_request()
KS.from_dict(d)
return cls(type=KS)
II: metrics_request = metrics_request(**d)
return cls(type=II)
raise Exception("Unknown type")
@classmethod
def __get_pydantic_core_schema__(
cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
return core_schema.no_info_after_validator_function(
cls,
handler(
Union[
ice_server_info,
trickle_ice,
sdp_answer,
modeling,
export,
metrics_request,
]
),
)