2024-08-20 13:10:56 -04:00
|
|
|
from typing import Dict, List, Literal, Union
|
2023-08-17 12:48:13 -07:00
|
|
|
|
2024-07-28 15:21:51 -07:00
|
|
|
from pydantic import BaseModel, ConfigDict, Field, RootModel
|
2023-11-29 10:32:31 -08:00
|
|
|
from typing_extensions import Annotated
|
2023-08-17 12:48:13 -07:00
|
|
|
|
2023-09-29 15:51:03 -07:00
|
|
|
from ..models.client_metrics import ClientMetrics
|
2023-08-17 12:48:13 -07:00
|
|
|
from ..models.modeling_cmd import ModelingCmd
|
|
|
|
from ..models.modeling_cmd_id import ModelingCmdId
|
2023-11-28 23:50:50 -08:00
|
|
|
from ..models.modeling_cmd_req import ModelingCmdReq
|
2023-08-17 12:48:13 -07:00
|
|
|
from ..models.rtc_ice_candidate_init import RtcIceCandidateInit
|
|
|
|
from ..models.rtc_session_description import RtcSessionDescription
|
|
|
|
|
2023-11-27 16:01:20 -08:00
|
|
|
|
2024-09-10 15:24:19 -07:00
|
|
|
class OptionTrickleIce(BaseModel):
|
2023-11-28 23:50:50 -08:00
|
|
|
"""The trickle ICE candidate request."""
|
2023-08-17 12:48:13 -07:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
candidate: RtcIceCandidateInit
|
2023-08-17 12:48:13 -07:00
|
|
|
|
2023-11-29 10:32:31 -08:00
|
|
|
type: Literal["trickle_ice"] = "trickle_ice"
|
2023-08-17 12:48:13 -07:00
|
|
|
|
2024-01-06 18:32:21 -08:00
|
|
|
model_config = ConfigDict(protected_namespaces=())
|
|
|
|
|
2023-08-17 12:48:13 -07:00
|
|
|
|
2024-09-10 15:24:19 -07:00
|
|
|
class OptionSdpOffer(BaseModel):
|
2023-11-28 23:50:50 -08:00
|
|
|
"""The SDP offer request."""
|
2023-08-17 12:48:13 -07:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
offer: RtcSessionDescription
|
2023-08-17 12:48:13 -07:00
|
|
|
|
2023-11-29 10:32:31 -08:00
|
|
|
type: Literal["sdp_offer"] = "sdp_offer"
|
2023-08-17 12:48:13 -07:00
|
|
|
|
2024-01-06 18:32:21 -08:00
|
|
|
model_config = ConfigDict(protected_namespaces=())
|
|
|
|
|
2023-08-17 12:48:13 -07:00
|
|
|
|
2024-09-10 15:24:19 -07:00
|
|
|
class OptionModelingCmdReq(BaseModel):
|
2023-11-28 23:50:50 -08:00
|
|
|
"""The modeling command request."""
|
2023-08-17 12:48:13 -07:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
cmd: ModelingCmd
|
2023-08-17 12:48:13 -07:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
cmd_id: ModelingCmdId
|
2023-09-29 16:05:40 -07:00
|
|
|
|
2023-11-29 10:32:31 -08:00
|
|
|
type: Literal["modeling_cmd_req"] = "modeling_cmd_req"
|
2023-08-17 12:48:13 -07:00
|
|
|
|
2024-01-06 18:32:21 -08:00
|
|
|
model_config = ConfigDict(protected_namespaces=())
|
|
|
|
|
2023-08-17 12:48:13 -07:00
|
|
|
|
2024-09-10 15:24:19 -07:00
|
|
|
class OptionModelingCmdBatchReq(BaseModel):
|
2023-11-28 23:50:50 -08:00
|
|
|
"""A sequence of modeling requests. If any request fails, following requests will not be tried."""
|
2023-09-29 16:05:40 -07:00
|
|
|
|
2024-04-05 13:12:19 -07:00
|
|
|
batch_id: ModelingCmdId
|
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
requests: List[ModelingCmdReq]
|
2023-08-17 12:48:13 -07:00
|
|
|
|
2024-08-20 13:10:56 -04:00
|
|
|
responses: bool = False
|
2024-04-05 13:12:19 -07:00
|
|
|
|
2023-11-29 10:32:31 -08:00
|
|
|
type: Literal["modeling_cmd_batch_req"] = "modeling_cmd_batch_req"
|
2023-10-17 15:35:56 -07:00
|
|
|
|
2024-01-06 18:32:21 -08:00
|
|
|
model_config = ConfigDict(protected_namespaces=())
|
|
|
|
|
2023-10-17 15:35:56 -07:00
|
|
|
|
2024-09-10 15:24:19 -07:00
|
|
|
class OptionPing(BaseModel):
|
2023-11-28 23:50:50 -08:00
|
|
|
"""The client-to-server Ping to ensure the WebSocket stays alive."""
|
2023-08-30 15:59:51 -07:00
|
|
|
|
2023-11-29 10:32:31 -08:00
|
|
|
type: Literal["ping"] = "ping"
|
2023-08-30 15:59:51 -07:00
|
|
|
|
2024-01-06 18:32:21 -08:00
|
|
|
model_config = ConfigDict(protected_namespaces=())
|
|
|
|
|
2023-08-30 15:59:51 -07:00
|
|
|
|
2024-09-10 15:24:19 -07:00
|
|
|
class OptionMetricsResponse(BaseModel):
|
2023-11-28 23:50:50 -08:00
|
|
|
"""The response to a metrics collection request from the server."""
|
2023-08-30 15:59:51 -07:00
|
|
|
|
2023-11-28 23:50:50 -08:00
|
|
|
metrics: ClientMetrics
|
2023-08-30 15:59:51 -07:00
|
|
|
|
2023-11-29 10:32:31 -08:00
|
|
|
type: Literal["metrics_response"] = "metrics_response"
|
2023-09-29 15:51:03 -07:00
|
|
|
|
2024-01-06 18:32:21 -08:00
|
|
|
model_config = ConfigDict(protected_namespaces=())
|
|
|
|
|
2023-09-29 15:51:03 -07:00
|
|
|
|
2024-09-10 15:24:19 -07:00
|
|
|
class OptionHeaders(BaseModel):
|
2024-04-17 09:49:04 -07:00
|
|
|
"""Authentication header request."""
|
|
|
|
|
|
|
|
headers: Dict[str, str]
|
|
|
|
|
|
|
|
type: Literal["headers"] = "headers"
|
|
|
|
|
|
|
|
model_config = ConfigDict(protected_namespaces=())
|
|
|
|
|
|
|
|
|
2023-11-29 00:39:14 -08:00
|
|
|
WebSocketRequest = RootModel[
|
2023-11-29 10:32:31 -08:00
|
|
|
Annotated[
|
|
|
|
Union[
|
2024-09-10 15:24:19 -07:00
|
|
|
OptionTrickleIce,
|
|
|
|
OptionSdpOffer,
|
|
|
|
OptionModelingCmdReq,
|
|
|
|
OptionModelingCmdBatchReq,
|
|
|
|
OptionPing,
|
|
|
|
OptionMetricsResponse,
|
|
|
|
OptionHeaders,
|
2023-11-29 10:32:31 -08:00
|
|
|
],
|
|
|
|
Field(discriminator="type"),
|
2023-11-28 14:29:16 -08:00
|
|
|
]
|
2023-11-29 00:39:14 -08:00
|
|
|
]
|