77 serialize_optional_model_dump_to_dict ,
88)
99from ..session_profile_update_utils import resolve_update_profile_params
10+ from ..session_request_utils import (
11+ get_session_resource_async ,
12+ post_session_resource_async ,
13+ put_session_resource_async ,
14+ )
1015from ..session_upload_utils import open_upload_files_from_input
1116from ..session_operation_metadata import SESSION_OPERATION_METADATA
1217from ..session_route_constants import (
@@ -61,14 +66,13 @@ async def list(
6166 default_factory = SessionEventLogListParams ,
6267 error_message = "Failed to serialize session event log params" ,
6368 )
64- response = await self ._client .transport .get (
65- self ._client ._build_url (
66- f"{ self ._ROUTE_PREFIX } /{ session_id } { SESSION_EVENT_LOGS_ROUTE_SUFFIX } "
67- ),
69+ response_data = await get_session_resource_async (
70+ client = self ._client ,
71+ route_path = f"{ self ._ROUTE_PREFIX } /{ session_id } { SESSION_EVENT_LOGS_ROUTE_SUFFIX } " ,
6872 params = query_params ,
6973 )
7074 return parse_session_response_model (
71- response . data ,
75+ response_data ,
7276 model = SessionEventLogListResponse ,
7377 operation_name = self ._OPERATION_METADATA .event_logs_operation_name ,
7478 )
@@ -91,12 +95,13 @@ async def create(
9195 params ,
9296 error_message = "Failed to serialize session create params" ,
9397 )
94- response = await self ._client .transport .post (
95- self ._client ._build_url (self ._ROUTE_PREFIX ),
98+ response_data = await post_session_resource_async (
99+ client = self ._client ,
100+ route_path = self ._ROUTE_PREFIX ,
96101 data = payload ,
97102 )
98103 return parse_session_response_model (
99- response . data ,
104+ response_data ,
100105 model = SessionDetail ,
101106 operation_name = self ._OPERATION_METADATA .detail_operation_name ,
102107 )
@@ -109,22 +114,24 @@ async def get(
109114 default_factory = SessionGetParams ,
110115 error_message = "Failed to serialize session get params" ,
111116 )
112- response = await self ._client .transport .get (
113- self ._client ._build_url (f"{ self ._ROUTE_PREFIX } /{ id } " ),
117+ response_data = await get_session_resource_async (
118+ client = self ._client ,
119+ route_path = f"{ self ._ROUTE_PREFIX } /{ id } " ,
114120 params = query_params ,
115121 )
116122 return parse_session_response_model (
117- response . data ,
123+ response_data ,
118124 model = SessionDetail ,
119125 operation_name = self ._OPERATION_METADATA .detail_operation_name ,
120126 )
121127
122128 async def stop (self , id : str ) -> BasicResponse :
123- response = await self ._client .transport .put (
124- self ._client ._build_url (f"{ self ._ROUTE_PREFIX } /{ id } { SESSION_STOP_ROUTE_SUFFIX } " )
129+ response_data = await put_session_resource_async (
130+ client = self ._client ,
131+ route_path = f"{ self ._ROUTE_PREFIX } /{ id } { SESSION_STOP_ROUTE_SUFFIX } " ,
125132 )
126133 return parse_session_response_model (
127- response . data ,
134+ response_data ,
128135 model = BasicResponse ,
129136 operation_name = self ._OPERATION_METADATA .stop_operation_name ,
130137 )
@@ -137,60 +144,56 @@ async def list(
137144 default_factory = SessionListParams ,
138145 error_message = "Failed to serialize session list params" ,
139146 )
140- response = await self ._client .transport .get (
141- self ._client ._build_url (self ._LIST_ROUTE_PATH ),
147+ response_data = await get_session_resource_async (
148+ client = self ._client ,
149+ route_path = self ._LIST_ROUTE_PATH ,
142150 params = query_params ,
143151 )
144152 return parse_session_response_model (
145- response . data ,
153+ response_data ,
146154 model = SessionListResponse ,
147155 operation_name = self ._OPERATION_METADATA .list_operation_name ,
148156 )
149157
150158 async def get_recording (self , id : str ) -> List [SessionRecording ]:
151- response = await self ._client .transport .get (
152- self ._client ._build_url (
153- f"{ self ._ROUTE_PREFIX } /{ id } { SESSION_RECORDING_ROUTE_SUFFIX } "
154- ),
155- None ,
156- True ,
159+ response_data = await get_session_resource_async (
160+ client = self ._client ,
161+ route_path = f"{ self ._ROUTE_PREFIX } /{ id } { SESSION_RECORDING_ROUTE_SUFFIX } " ,
162+ follow_redirects = True ,
157163 )
158- return parse_session_recordings_response_data (response . data )
164+ return parse_session_recordings_response_data (response_data )
159165
160166 async def get_recording_url (self , id : str ) -> GetSessionRecordingUrlResponse :
161- response = await self ._client .transport .get (
162- self ._client ._build_url (
163- f"{ self ._ROUTE_PREFIX } /{ id } { SESSION_RECORDING_URL_ROUTE_SUFFIX } "
164- )
167+ response_data = await get_session_resource_async (
168+ client = self ._client ,
169+ route_path = f"{ self ._ROUTE_PREFIX } /{ id } { SESSION_RECORDING_URL_ROUTE_SUFFIX } " ,
165170 )
166171 return parse_session_response_model (
167- response . data ,
172+ response_data ,
168173 model = GetSessionRecordingUrlResponse ,
169174 operation_name = self ._OPERATION_METADATA .recording_url_operation_name ,
170175 )
171176
172177 async def get_video_recording_url (
173178 self , id : str
174179 ) -> GetSessionVideoRecordingUrlResponse :
175- response = await self ._client .transport .get (
176- self ._client ._build_url (
177- f"{ self ._ROUTE_PREFIX } /{ id } { SESSION_VIDEO_RECORDING_URL_ROUTE_SUFFIX } "
178- )
180+ response_data = await get_session_resource_async (
181+ client = self ._client ,
182+ route_path = f"{ self ._ROUTE_PREFIX } /{ id } { SESSION_VIDEO_RECORDING_URL_ROUTE_SUFFIX } " ,
179183 )
180184 return parse_session_response_model (
181- response . data ,
185+ response_data ,
182186 model = GetSessionVideoRecordingUrlResponse ,
183187 operation_name = self ._OPERATION_METADATA .video_recording_url_operation_name ,
184188 )
185189
186190 async def get_downloads_url (self , id : str ) -> GetSessionDownloadsUrlResponse :
187- response = await self ._client .transport .get (
188- self ._client ._build_url (
189- f"{ self ._ROUTE_PREFIX } /{ id } { SESSION_DOWNLOADS_URL_ROUTE_SUFFIX } "
190- )
191+ response_data = await get_session_resource_async (
192+ client = self ._client ,
193+ route_path = f"{ self ._ROUTE_PREFIX } /{ id } { SESSION_DOWNLOADS_URL_ROUTE_SUFFIX } " ,
191194 )
192195 return parse_session_response_model (
193- response . data ,
196+ response_data ,
194197 model = GetSessionDownloadsUrlResponse ,
195198 operation_name = self ._OPERATION_METADATA .downloads_url_operation_name ,
196199 )
@@ -199,28 +202,26 @@ async def upload_file(
199202 self , id : str , file_input : Union [str , PathLike [str ], IO ]
200203 ) -> UploadFileResponse :
201204 with open_upload_files_from_input (file_input ) as files :
202- response = await self ._client .transport .post (
203- self ._client ._build_url (
204- f"{ self ._ROUTE_PREFIX } /{ id } { SESSION_UPLOADS_ROUTE_SUFFIX } "
205- ),
205+ response_data = await post_session_resource_async (
206+ client = self ._client ,
207+ route_path = f"{ self ._ROUTE_PREFIX } /{ id } { SESSION_UPLOADS_ROUTE_SUFFIX } " ,
206208 files = files ,
207209 )
208210
209211 return parse_session_response_model (
210- response . data ,
212+ response_data ,
211213 model = UploadFileResponse ,
212214 operation_name = self ._OPERATION_METADATA .upload_file_operation_name ,
213215 )
214216
215217 async def extend_session (self , id : str , duration_minutes : int ) -> BasicResponse :
216- response = await self ._client .transport .put (
217- self ._client ._build_url (
218- f"{ self ._ROUTE_PREFIX } /{ id } { SESSION_EXTEND_ROUTE_SUFFIX } "
219- ),
218+ response_data = await put_session_resource_async (
219+ client = self ._client ,
220+ route_path = f"{ self ._ROUTE_PREFIX } /{ id } { SESSION_EXTEND_ROUTE_SUFFIX } " ,
220221 data = {"durationMinutes" : duration_minutes },
221222 )
222223 return parse_session_response_model (
223- response . data ,
224+ response_data ,
224225 model = BasicResponse ,
225226 operation_name = self ._OPERATION_METADATA .extend_operation_name ,
226227 )
@@ -253,17 +254,16 @@ async def update_profile_params(
253254 error_message = "Failed to serialize update_profile_params payload" ,
254255 )
255256
256- response = await self ._client .transport .put (
257- self ._client ._build_url (
258- f"{ self ._ROUTE_PREFIX } /{ id } { SESSION_UPDATE_ROUTE_SUFFIX } "
259- ),
257+ response_data = await put_session_resource_async (
258+ client = self ._client ,
259+ route_path = f"{ self ._ROUTE_PREFIX } /{ id } { SESSION_UPDATE_ROUTE_SUFFIX } " ,
260260 data = {
261261 "type" : "profile" ,
262262 "params" : serialized_params ,
263263 },
264264 )
265265 return parse_session_response_model (
266- response . data ,
266+ response_data ,
267267 model = BasicResponse ,
268268 operation_name = self ._OPERATION_METADATA .update_profile_operation_name ,
269269 )
0 commit comments