11from http import HTTPStatus
2- from typing import Any , Optional , Union
2+ from typing import Any
3+ from urllib .parse import quote
34
45import httpx
56
89from ...models .error import Error
910from ...models .peer_config import PeerConfig
1011from ...models .peer_details_response import PeerDetailsResponse
11- from ...types import Response
12+ from ...types import UNSET , Response , Unset
1213
1314
1415def _get_kwargs (
1516 room_id : str ,
1617 * ,
17- body : PeerConfig ,
18+ body : PeerConfig | Unset = UNSET ,
1819) -> dict [str , Any ]:
1920 headers : dict [str , Any ] = {}
2021
2122 _kwargs : dict [str , Any ] = {
2223 "method" : "post" ,
2324 "url" : "/room/{room_id}/peer" .format (
24- room_id = room_id ,
25+ room_id = quote ( str ( room_id ), safe = "" ) ,
2526 ),
2627 }
2728
28- _kwargs ["json" ] = body .to_dict ()
29+ if not isinstance (body , Unset ):
30+ _kwargs ["json" ] = body .to_dict ()
2931
3032 headers ["Content-Type" ] = "application/json"
3133
@@ -34,45 +36,52 @@ def _get_kwargs(
3436
3537
3638def _parse_response (
37- * , client : Union [ AuthenticatedClient , Client ] , response : httpx .Response
38- ) -> Optional [ Union [ Error , PeerDetailsResponse ]] :
39+ * , client : AuthenticatedClient | Client , response : httpx .Response
40+ ) -> Error | PeerDetailsResponse | None :
3941 if response .status_code == 201 :
4042 response_201 = PeerDetailsResponse .from_dict (response .json ())
4143
4244 return response_201
45+
4346 if response .status_code == 400 :
4447 response_400 = Error .from_dict (response .json ())
4548
4649 return response_400
50+
4751 if response .status_code == 401 :
4852 response_401 = Error .from_dict (response .json ())
4953
5054 return response_401
55+
5156 if response .status_code == 402 :
5257 response_402 = Error .from_dict (response .json ())
5358
5459 return response_402
60+
5561 if response .status_code == 404 :
5662 response_404 = Error .from_dict (response .json ())
5763
5864 return response_404
65+
5966 if response .status_code == 409 :
6067 response_409 = Error .from_dict (response .json ())
6168
6269 return response_409
70+
6371 if response .status_code == 503 :
6472 response_503 = Error .from_dict (response .json ())
6573
6674 return response_503
75+
6776 if client .raise_on_unexpected_status :
6877 raise errors .UnexpectedStatus (response .status_code , response .content )
6978 else :
7079 return None
7180
7281
7382def _build_response (
74- * , client : Union [ AuthenticatedClient , Client ] , response : httpx .Response
75- ) -> Response [Union [ Error , PeerDetailsResponse ] ]:
83+ * , client : AuthenticatedClient | Client , response : httpx .Response
84+ ) -> Response [Error | PeerDetailsResponse ]:
7685 return Response (
7786 status_code = HTTPStatus (response .status_code ),
7887 content = response .content ,
@@ -85,20 +94,20 @@ def sync_detailed(
8594 room_id : str ,
8695 * ,
8796 client : AuthenticatedClient ,
88- body : PeerConfig ,
89- ) -> Response [Union [ Error , PeerDetailsResponse ] ]:
97+ body : PeerConfig | Unset = UNSET ,
98+ ) -> Response [Error | PeerDetailsResponse ]:
9099 """Create peer
91100
92101 Args:
93102 room_id (str):
94- body (PeerConfig): Peer configuration
103+ body (PeerConfig | Unset ): Peer configuration
95104
96105 Raises:
97106 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
98107 httpx.TimeoutException: If the request takes longer than Client.timeout.
99108
100109 Returns:
101- Response[Union[ Error, PeerDetailsResponse] ]
110+ Response[Error | PeerDetailsResponse]
102111 """
103112
104113 kwargs = _get_kwargs (
@@ -117,20 +126,20 @@ def sync(
117126 room_id : str ,
118127 * ,
119128 client : AuthenticatedClient ,
120- body : PeerConfig ,
121- ) -> Optional [ Union [ Error , PeerDetailsResponse ]] :
129+ body : PeerConfig | Unset = UNSET ,
130+ ) -> Error | PeerDetailsResponse | None :
122131 """Create peer
123132
124133 Args:
125134 room_id (str):
126- body (PeerConfig): Peer configuration
135+ body (PeerConfig | Unset ): Peer configuration
127136
128137 Raises:
129138 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
130139 httpx.TimeoutException: If the request takes longer than Client.timeout.
131140
132141 Returns:
133- Union[ Error, PeerDetailsResponse]
142+ Error | PeerDetailsResponse
134143 """
135144
136145 return sync_detailed (
@@ -144,20 +153,20 @@ async def asyncio_detailed(
144153 room_id : str ,
145154 * ,
146155 client : AuthenticatedClient ,
147- body : PeerConfig ,
148- ) -> Response [Union [ Error , PeerDetailsResponse ] ]:
156+ body : PeerConfig | Unset = UNSET ,
157+ ) -> Response [Error | PeerDetailsResponse ]:
149158 """Create peer
150159
151160 Args:
152161 room_id (str):
153- body (PeerConfig): Peer configuration
162+ body (PeerConfig | Unset ): Peer configuration
154163
155164 Raises:
156165 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
157166 httpx.TimeoutException: If the request takes longer than Client.timeout.
158167
159168 Returns:
160- Response[Union[ Error, PeerDetailsResponse] ]
169+ Response[Error | PeerDetailsResponse]
161170 """
162171
163172 kwargs = _get_kwargs (
@@ -174,20 +183,20 @@ async def asyncio(
174183 room_id : str ,
175184 * ,
176185 client : AuthenticatedClient ,
177- body : PeerConfig ,
178- ) -> Optional [ Union [ Error , PeerDetailsResponse ]] :
186+ body : PeerConfig | Unset = UNSET ,
187+ ) -> Error | PeerDetailsResponse | None :
179188 """Create peer
180189
181190 Args:
182191 room_id (str):
183- body (PeerConfig): Peer configuration
192+ body (PeerConfig | Unset ): Peer configuration
184193
185194 Raises:
186195 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
187196 httpx.TimeoutException: If the request takes longer than Client.timeout.
188197
189198 Returns:
190- Union[ Error, PeerDetailsResponse]
199+ Error | PeerDetailsResponse
191200 """
192201
193202 return (
0 commit comments