11from http import HTTPStatus
2- from typing import Any , Dict , Optional , Union
2+ from typing import Any , Optional , Union
33
44import httpx
55
66from ... import errors
77from ...client import AuthenticatedClient , Client
8- from ...models .add_peer_json_body import AddPeerJsonBody
8+ from ...models .add_peer_body import AddPeerBody
99from ...models .error import Error
1010from ...models .peer_details_response import PeerDetailsResponse
1111from ...types import Response
1414def _get_kwargs (
1515 room_id : str ,
1616 * ,
17- json_body : AddPeerJsonBody ,
18- ) -> Dict [str , Any ]:
19- json_json_body = json_body . to_dict ()
17+ body : AddPeerBody ,
18+ ) -> dict [str , Any ]:
19+ headers : dict [ str , Any ] = {}
2020
21- return {
21+ _kwargs : dict [ str , Any ] = {
2222 "method" : "post" ,
2323 "url" : "/room/{room_id}/peer" .format (
2424 room_id = room_id ,
2525 ),
26- "json" : json_json_body ,
2726 }
2827
28+ _kwargs ["json" ] = body .to_dict ()
29+
30+ headers ["Content-Type" ] = "application/json"
31+
32+ _kwargs ["headers" ] = headers
33+ return _kwargs
34+
2935
3036def _parse_response (
3137 * , client : Union [AuthenticatedClient , Client ], response : httpx .Response
3238) -> Optional [Union [Error , PeerDetailsResponse ]]:
33- if response .status_code == HTTPStatus . CREATED :
39+ if response .status_code == 201 :
3440 response_201 = PeerDetailsResponse .from_dict (response .json ())
3541
3642 return response_201
37- if response .status_code == HTTPStatus . BAD_REQUEST :
43+ if response .status_code == 400 :
3844 response_400 = Error .from_dict (response .json ())
3945
4046 return response_400
41- if response .status_code == HTTPStatus . UNAUTHORIZED :
47+ if response .status_code == 401 :
4248 response_401 = Error .from_dict (response .json ())
4349
4450 return response_401
45- if response .status_code == HTTPStatus . NOT_FOUND :
51+ if response .status_code == 404 :
4652 response_404 = Error .from_dict (response .json ())
4753
4854 return response_404
49- if response .status_code == HTTPStatus . SERVICE_UNAVAILABLE :
55+ if response .status_code == 503 :
5056 response_503 = Error .from_dict (response .json ())
5157
5258 return response_503
@@ -71,13 +77,13 @@ def sync_detailed(
7177 room_id : str ,
7278 * ,
7379 client : AuthenticatedClient ,
74- json_body : AddPeerJsonBody ,
80+ body : AddPeerBody ,
7581) -> Response [Union [Error , PeerDetailsResponse ]]:
7682 """Create peer
7783
7884 Args:
7985 room_id (str):
80- json_body (AddPeerJsonBody ):
86+ body (AddPeerBody ):
8187
8288 Raises:
8389 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -89,7 +95,7 @@ def sync_detailed(
8995
9096 kwargs = _get_kwargs (
9197 room_id = room_id ,
92- json_body = json_body ,
98+ body = body ,
9399 )
94100
95101 response = client .get_httpx_client ().request (
@@ -103,13 +109,13 @@ def sync(
103109 room_id : str ,
104110 * ,
105111 client : AuthenticatedClient ,
106- json_body : AddPeerJsonBody ,
112+ body : AddPeerBody ,
107113) -> Optional [Union [Error , PeerDetailsResponse ]]:
108114 """Create peer
109115
110116 Args:
111117 room_id (str):
112- json_body (AddPeerJsonBody ):
118+ body (AddPeerBody ):
113119
114120 Raises:
115121 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -122,21 +128,21 @@ def sync(
122128 return sync_detailed (
123129 room_id = room_id ,
124130 client = client ,
125- json_body = json_body ,
131+ body = body ,
126132 ).parsed
127133
128134
129135async def asyncio_detailed (
130136 room_id : str ,
131137 * ,
132138 client : AuthenticatedClient ,
133- json_body : AddPeerJsonBody ,
139+ body : AddPeerBody ,
134140) -> Response [Union [Error , PeerDetailsResponse ]]:
135141 """Create peer
136142
137143 Args:
138144 room_id (str):
139- json_body (AddPeerJsonBody ):
145+ body (AddPeerBody ):
140146
141147 Raises:
142148 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -148,7 +154,7 @@ async def asyncio_detailed(
148154
149155 kwargs = _get_kwargs (
150156 room_id = room_id ,
151- json_body = json_body ,
157+ body = body ,
152158 )
153159
154160 response = await client .get_async_httpx_client ().request (** kwargs )
@@ -160,13 +166,13 @@ async def asyncio(
160166 room_id : str ,
161167 * ,
162168 client : AuthenticatedClient ,
163- json_body : AddPeerJsonBody ,
169+ body : AddPeerBody ,
164170) -> Optional [Union [Error , PeerDetailsResponse ]]:
165171 """Create peer
166172
167173 Args:
168174 room_id (str):
169- json_body (AddPeerJsonBody ):
175+ body (AddPeerBody ):
170176
171177 Raises:
172178 errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
@@ -180,6 +186,6 @@ async def asyncio(
180186 await asyncio_detailed (
181187 room_id = room_id ,
182188 client = client ,
183- json_body = json_body ,
189+ body = body ,
184190 )
185191 ).parsed
0 commit comments