|
10 | 10 | from ..core.request_options import RequestOptions
|
11 | 11 | from ..core.unchecked_base_model import construct_type
|
12 | 12 | from ..errors.not_found_error import NotFoundError
|
| 13 | +from ..errors.too_many_requests_error import TooManyRequestsError |
13 | 14 | from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
14 | 15 | from ..types.proxy_country_code import ProxyCountryCode
|
15 | 16 | from ..types.session_item_view import SessionItemView
|
16 | 17 | from ..types.session_list_response import SessionListResponse
|
17 | 18 | from ..types.session_status import SessionStatus
|
18 | 19 | from ..types.session_view import SessionView
|
19 | 20 | from ..types.share_view import ShareView
|
| 21 | +from ..types.too_many_concurrent_active_sessions_error import TooManyConcurrentActiveSessionsError |
20 | 22 |
|
21 | 23 | # this is used as the default value for optional parameters
|
22 | 24 | OMIT = typing.cast(typing.Any, ...)
|
@@ -160,6 +162,17 @@ def create_session(
|
160 | 162 | ),
|
161 | 163 | ),
|
162 | 164 | )
|
| 165 | + if _response.status_code == 429: |
| 166 | + raise TooManyRequestsError( |
| 167 | + headers=dict(_response.headers), |
| 168 | + body=typing.cast( |
| 169 | + TooManyConcurrentActiveSessionsError, |
| 170 | + construct_type( |
| 171 | + type_=TooManyConcurrentActiveSessionsError, # type: ignore |
| 172 | + object_=_response.json(), |
| 173 | + ), |
| 174 | + ), |
| 175 | + ) |
163 | 176 | _response_json = _response.json()
|
164 | 177 | except JSONDecodeError:
|
165 | 178 | raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
@@ -225,47 +238,6 @@ def get_session(
|
225 | 238 | raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
226 | 239 | raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
227 | 240 |
|
228 |
| - def delete_session( |
229 |
| - self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None |
230 |
| - ) -> HttpResponse[None]: |
231 |
| - """ |
232 |
| - Permanently delete a session and all associated data. |
233 |
| -
|
234 |
| - Parameters |
235 |
| - ---------- |
236 |
| - session_id : str |
237 |
| -
|
238 |
| - request_options : typing.Optional[RequestOptions] |
239 |
| - Request-specific configuration. |
240 |
| -
|
241 |
| - Returns |
242 |
| - ------- |
243 |
| - HttpResponse[None] |
244 |
| - """ |
245 |
| - _response = self._client_wrapper.httpx_client.request( |
246 |
| - f"sessions/{jsonable_encoder(session_id)}", |
247 |
| - method="DELETE", |
248 |
| - request_options=request_options, |
249 |
| - ) |
250 |
| - try: |
251 |
| - if 200 <= _response.status_code < 300: |
252 |
| - return HttpResponse(response=_response, data=None) |
253 |
| - if _response.status_code == 422: |
254 |
| - raise UnprocessableEntityError( |
255 |
| - headers=dict(_response.headers), |
256 |
| - body=typing.cast( |
257 |
| - typing.Optional[typing.Any], |
258 |
| - construct_type( |
259 |
| - type_=typing.Optional[typing.Any], # type: ignore |
260 |
| - object_=_response.json(), |
261 |
| - ), |
262 |
| - ), |
263 |
| - ) |
264 |
| - _response_json = _response.json() |
265 |
| - except JSONDecodeError: |
266 |
| - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
267 |
| - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
268 |
| - |
269 | 241 | def update_session(
|
270 | 242 | self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
271 | 243 | ) -> HttpResponse[SessionView]:
|
@@ -644,6 +616,17 @@ async def create_session(
|
644 | 616 | ),
|
645 | 617 | ),
|
646 | 618 | )
|
| 619 | + if _response.status_code == 429: |
| 620 | + raise TooManyRequestsError( |
| 621 | + headers=dict(_response.headers), |
| 622 | + body=typing.cast( |
| 623 | + TooManyConcurrentActiveSessionsError, |
| 624 | + construct_type( |
| 625 | + type_=TooManyConcurrentActiveSessionsError, # type: ignore |
| 626 | + object_=_response.json(), |
| 627 | + ), |
| 628 | + ), |
| 629 | + ) |
647 | 630 | _response_json = _response.json()
|
648 | 631 | except JSONDecodeError:
|
649 | 632 | raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
@@ -709,47 +692,6 @@ async def get_session(
|
709 | 692 | raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
710 | 693 | raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
711 | 694 |
|
712 |
| - async def delete_session( |
713 |
| - self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None |
714 |
| - ) -> AsyncHttpResponse[None]: |
715 |
| - """ |
716 |
| - Permanently delete a session and all associated data. |
717 |
| -
|
718 |
| - Parameters |
719 |
| - ---------- |
720 |
| - session_id : str |
721 |
| -
|
722 |
| - request_options : typing.Optional[RequestOptions] |
723 |
| - Request-specific configuration. |
724 |
| -
|
725 |
| - Returns |
726 |
| - ------- |
727 |
| - AsyncHttpResponse[None] |
728 |
| - """ |
729 |
| - _response = await self._client_wrapper.httpx_client.request( |
730 |
| - f"sessions/{jsonable_encoder(session_id)}", |
731 |
| - method="DELETE", |
732 |
| - request_options=request_options, |
733 |
| - ) |
734 |
| - try: |
735 |
| - if 200 <= _response.status_code < 300: |
736 |
| - return AsyncHttpResponse(response=_response, data=None) |
737 |
| - if _response.status_code == 422: |
738 |
| - raise UnprocessableEntityError( |
739 |
| - headers=dict(_response.headers), |
740 |
| - body=typing.cast( |
741 |
| - typing.Optional[typing.Any], |
742 |
| - construct_type( |
743 |
| - type_=typing.Optional[typing.Any], # type: ignore |
744 |
| - object_=_response.json(), |
745 |
| - ), |
746 |
| - ), |
747 |
| - ) |
748 |
| - _response_json = _response.json() |
749 |
| - except JSONDecodeError: |
750 |
| - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
751 |
| - raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
752 |
| - |
753 | 695 | async def update_session(
|
754 | 696 | self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
755 | 697 | ) -> AsyncHttpResponse[SessionView]:
|
|
0 commit comments