@@ -522,78 +522,6 @@ def file(
522522 raise ApiError (status_code = _response .status_code , body = _response .text )
523523 raise ApiError (status_code = _response .status_code , body = _response_json )
524524
525- def download (
526- self , instance_id : str , * , path : str , local_path : str , request_options : typing .Optional [RequestOptions ] = None
527- ) -> FileResponse :
528- """
529- Download a file from the instance and save it to a local path.
530-
531- Args:
532- path: Path of the file on the instance
533- local_path: Path where to save the file locally
534-
535- Parameters
536- ----------
537- instance_id : str
538-
539- path : str
540-
541- local_path : str
542-
543- request_options : typing.Optional[RequestOptions]
544- Request-specific configuration.
545-
546- Returns
547- -------
548- FileResponse
549- Successful Response
550-
551- Examples
552- --------
553- from scrapybara import Scrapybara
554-
555- client = Scrapybara(
556- api_key="YOUR_API_KEY",
557- )
558- client.instance.download(
559- instance_id="instance_id",
560- path="path",
561- local_path="local_path",
562- )
563- """
564- _response = self ._client_wrapper .httpx_client .request (
565- f"v1/instance/{ jsonable_encoder (instance_id )} /download" ,
566- method = "GET" ,
567- params = {
568- "path" : path ,
569- "local_path" : local_path ,
570- },
571- request_options = request_options ,
572- )
573- try :
574- if 200 <= _response .status_code < 300 :
575- return typing .cast (
576- FileResponse ,
577- parse_obj_as (
578- type_ = FileResponse , # type: ignore
579- object_ = _response .json (),
580- ),
581- )
582- if _response .status_code == 422 :
583- raise UnprocessableEntityError (
584- typing .cast (
585- HttpValidationError ,
586- parse_obj_as (
587- type_ = HttpValidationError , # type: ignore
588- object_ = _response .json (),
589- ),
590- )
591- )
592- _response_json = _response .json ()
593- except JSONDecodeError :
594- raise ApiError (status_code = _response .status_code , body = _response .text )
595- raise ApiError (status_code = _response .status_code , body = _response_json )
596-
597525 def upload (
598526 self , instance_id : str , * , file : core .File , path : str , request_options : typing .Optional [RequestOptions ] = None
599527 ) -> UploadResponse :
@@ -1385,86 +1313,6 @@ async def main() -> None:
13851313 raise ApiError (status_code = _response .status_code , body = _response .text )
13861314 raise ApiError (status_code = _response .status_code , body = _response_json )
13871315
1388- async def download (
1389- self , instance_id : str , * , path : str , local_path : str , request_options : typing .Optional [RequestOptions ] = None
1390- ) -> FileResponse :
1391- """
1392- Download a file from the instance and save it to a local path.
1393-
1394- Args:
1395- path: Path of the file on the instance
1396- local_path: Path where to save the file locally
1397-
1398- Parameters
1399- ----------
1400- instance_id : str
1401-
1402- path : str
1403-
1404- local_path : str
1405-
1406- request_options : typing.Optional[RequestOptions]
1407- Request-specific configuration.
1408-
1409- Returns
1410- -------
1411- FileResponse
1412- Successful Response
1413-
1414- Examples
1415- --------
1416- import asyncio
1417-
1418- from scrapybara import AsyncScrapybara
1419-
1420- client = AsyncScrapybara(
1421- api_key="YOUR_API_KEY",
1422- )
1423-
1424-
1425- async def main() -> None:
1426- await client.instance.download(
1427- instance_id="instance_id",
1428- path="path",
1429- local_path="local_path",
1430- )
1431-
1432-
1433- asyncio.run(main())
1434- """
1435- _response = await self ._client_wrapper .httpx_client .request (
1436- f"v1/instance/{ jsonable_encoder (instance_id )} /download" ,
1437- method = "GET" ,
1438- params = {
1439- "path" : path ,
1440- "local_path" : local_path ,
1441- },
1442- request_options = request_options ,
1443- )
1444- try :
1445- if 200 <= _response .status_code < 300 :
1446- return typing .cast (
1447- FileResponse ,
1448- parse_obj_as (
1449- type_ = FileResponse , # type: ignore
1450- object_ = _response .json (),
1451- ),
1452- )
1453- if _response .status_code == 422 :
1454- raise UnprocessableEntityError (
1455- typing .cast (
1456- HttpValidationError ,
1457- parse_obj_as (
1458- type_ = HttpValidationError , # type: ignore
1459- object_ = _response .json (),
1460- ),
1461- )
1462- )
1463- _response_json = _response .json ()
1464- except JSONDecodeError :
1465- raise ApiError (status_code = _response .status_code , body = _response .text )
1466- raise ApiError (status_code = _response .status_code , body = _response_json )
1467-
14681316 async def upload (
14691317 self , instance_id : str , * , file : core .File , path : str , request_options : typing .Optional [RequestOptions ] = None
14701318 ) -> UploadResponse :
0 commit comments