|
12 | 12 | from ..core.api_error import ApiError |
13 | 13 | from ..types.browser_get_cdp_url_response import BrowserGetCdpUrlResponse |
14 | 14 | from ..types.save_browser_auth_response import SaveBrowserAuthResponse |
| 15 | +from ..types.modify_browser_auth_response import ModifyBrowserAuthResponse |
15 | 16 | from ..types.browser_authenticate_response import BrowserAuthenticateResponse |
16 | 17 | from ..types.stop_browser_response import StopBrowserResponse |
17 | 18 | from ..core.client_wrapper import AsyncClientWrapper |
@@ -198,6 +199,76 @@ def save_auth( |
198 | 199 | raise ApiError(status_code=_response.status_code, body=_response.text) |
199 | 200 | raise ApiError(status_code=_response.status_code, body=_response_json) |
200 | 201 |
|
| 202 | + def modify_auth( |
| 203 | + self, |
| 204 | + instance_id: str, |
| 205 | + *, |
| 206 | + auth_state_id: str, |
| 207 | + name: typing.Optional[str] = None, |
| 208 | + request_options: typing.Optional[RequestOptions] = None, |
| 209 | + ) -> ModifyBrowserAuthResponse: |
| 210 | + """ |
| 211 | + Parameters |
| 212 | + ---------- |
| 213 | + instance_id : str |
| 214 | +
|
| 215 | + auth_state_id : str |
| 216 | +
|
| 217 | + name : typing.Optional[str] |
| 218 | +
|
| 219 | + request_options : typing.Optional[RequestOptions] |
| 220 | + Request-specific configuration. |
| 221 | +
|
| 222 | + Returns |
| 223 | + ------- |
| 224 | + ModifyBrowserAuthResponse |
| 225 | + Successful Response |
| 226 | +
|
| 227 | + Examples |
| 228 | + -------- |
| 229 | + from scrapybara import Scrapybara |
| 230 | +
|
| 231 | + client = Scrapybara( |
| 232 | + api_key="YOUR_API_KEY", |
| 233 | + ) |
| 234 | + client.browser.modify_auth( |
| 235 | + instance_id="instance_id", |
| 236 | + auth_state_id="auth_state_id", |
| 237 | + ) |
| 238 | + """ |
| 239 | + _response = self._client_wrapper.httpx_client.request( |
| 240 | + f"v1/instance/{jsonable_encoder(instance_id)}/browser/modify_auth", |
| 241 | + method="POST", |
| 242 | + params={ |
| 243 | + "auth_state_id": auth_state_id, |
| 244 | + "name": name, |
| 245 | + }, |
| 246 | + request_options=request_options, |
| 247 | + ) |
| 248 | + try: |
| 249 | + if 200 <= _response.status_code < 300: |
| 250 | + return typing.cast( |
| 251 | + ModifyBrowserAuthResponse, |
| 252 | + parse_obj_as( |
| 253 | + type_=ModifyBrowserAuthResponse, # type: ignore |
| 254 | + object_=_response.json(), |
| 255 | + ), |
| 256 | + ) |
| 257 | + if _response.status_code == 422: |
| 258 | + raise UnprocessableEntityError( |
| 259 | + typing.cast( |
| 260 | + HttpValidationError, |
| 261 | + parse_obj_as( |
| 262 | + type_=HttpValidationError, # type: ignore |
| 263 | + object_=_response.json(), |
| 264 | + ), |
| 265 | + ) |
| 266 | + ) |
| 267 | + _response_json = _response.json() |
| 268 | + except JSONDecodeError: |
| 269 | + raise ApiError(status_code=_response.status_code, body=_response.text) |
| 270 | + raise ApiError(status_code=_response.status_code, body=_response_json) |
| 271 | + |
201 | 272 | def authenticate( |
202 | 273 | self, instance_id: str, *, auth_state_id: str, request_options: typing.Optional[RequestOptions] = None |
203 | 274 | ) -> BrowserAuthenticateResponse: |
@@ -520,6 +591,84 @@ async def main() -> None: |
520 | 591 | raise ApiError(status_code=_response.status_code, body=_response.text) |
521 | 592 | raise ApiError(status_code=_response.status_code, body=_response_json) |
522 | 593 |
|
| 594 | + async def modify_auth( |
| 595 | + self, |
| 596 | + instance_id: str, |
| 597 | + *, |
| 598 | + auth_state_id: str, |
| 599 | + name: typing.Optional[str] = None, |
| 600 | + request_options: typing.Optional[RequestOptions] = None, |
| 601 | + ) -> ModifyBrowserAuthResponse: |
| 602 | + """ |
| 603 | + Parameters |
| 604 | + ---------- |
| 605 | + instance_id : str |
| 606 | +
|
| 607 | + auth_state_id : str |
| 608 | +
|
| 609 | + name : typing.Optional[str] |
| 610 | +
|
| 611 | + request_options : typing.Optional[RequestOptions] |
| 612 | + Request-specific configuration. |
| 613 | +
|
| 614 | + Returns |
| 615 | + ------- |
| 616 | + ModifyBrowserAuthResponse |
| 617 | + Successful Response |
| 618 | +
|
| 619 | + Examples |
| 620 | + -------- |
| 621 | + import asyncio |
| 622 | +
|
| 623 | + from scrapybara import AsyncScrapybara |
| 624 | +
|
| 625 | + client = AsyncScrapybara( |
| 626 | + api_key="YOUR_API_KEY", |
| 627 | + ) |
| 628 | +
|
| 629 | +
|
| 630 | + async def main() -> None: |
| 631 | + await client.browser.modify_auth( |
| 632 | + instance_id="instance_id", |
| 633 | + auth_state_id="auth_state_id", |
| 634 | + ) |
| 635 | +
|
| 636 | +
|
| 637 | + asyncio.run(main()) |
| 638 | + """ |
| 639 | + _response = await self._client_wrapper.httpx_client.request( |
| 640 | + f"v1/instance/{jsonable_encoder(instance_id)}/browser/modify_auth", |
| 641 | + method="POST", |
| 642 | + params={ |
| 643 | + "auth_state_id": auth_state_id, |
| 644 | + "name": name, |
| 645 | + }, |
| 646 | + request_options=request_options, |
| 647 | + ) |
| 648 | + try: |
| 649 | + if 200 <= _response.status_code < 300: |
| 650 | + return typing.cast( |
| 651 | + ModifyBrowserAuthResponse, |
| 652 | + parse_obj_as( |
| 653 | + type_=ModifyBrowserAuthResponse, # type: ignore |
| 654 | + object_=_response.json(), |
| 655 | + ), |
| 656 | + ) |
| 657 | + if _response.status_code == 422: |
| 658 | + raise UnprocessableEntityError( |
| 659 | + typing.cast( |
| 660 | + HttpValidationError, |
| 661 | + parse_obj_as( |
| 662 | + type_=HttpValidationError, # type: ignore |
| 663 | + object_=_response.json(), |
| 664 | + ), |
| 665 | + ) |
| 666 | + ) |
| 667 | + _response_json = _response.json() |
| 668 | + except JSONDecodeError: |
| 669 | + raise ApiError(status_code=_response.status_code, body=_response.text) |
| 670 | + raise ApiError(status_code=_response.status_code, body=_response_json) |
| 671 | + |
523 | 672 | async def authenticate( |
524 | 673 | self, instance_id: str, *, auth_state_id: str, request_options: typing.Optional[RequestOptions] = None |
525 | 674 | ) -> BrowserAuthenticateResponse: |
|
0 commit comments