2020 BATCH_SCRAPE_OPERATION_METADATA ,
2121 SCRAPE_OPERATION_METADATA ,
2222)
23+ from ..job_request_utils import get_job_async , get_job_status_async , start_job_async
2324from ..job_route_constants import (
2425 BATCH_SCRAPE_JOB_ROUTE_PREFIX ,
2526 SCRAPE_JOB_ROUTE_PREFIX ,
3435 build_batch_scrape_start_payload ,
3536 build_scrape_start_payload ,
3637)
37- from ..response_utils import parse_response_model
3838from ..start_job_utils import build_started_job_context
3939from ....models .scrape import (
4040 BatchScrapeJobResponse ,
@@ -60,22 +60,19 @@ async def start(
6060 self , params : StartBatchScrapeJobParams
6161 ) -> StartBatchScrapeJobResponse :
6262 payload = build_batch_scrape_start_payload (params )
63- response = await self ._client .transport .post (
64- self ._client ._build_url (self ._ROUTE_PREFIX ),
65- data = payload ,
66- )
67- return parse_response_model (
68- response .data ,
63+ return await start_job_async (
64+ client = self ._client ,
65+ route_prefix = self ._ROUTE_PREFIX ,
66+ payload = payload ,
6967 model = StartBatchScrapeJobResponse ,
7068 operation_name = self ._OPERATION_METADATA .start_operation_name ,
7169 )
7270
7371 async def get_status (self , job_id : str ) -> BatchScrapeJobStatusResponse :
74- response = await self ._client .transport .get (
75- self ._client ._build_url (f"{ self ._ROUTE_PREFIX } /{ job_id } /status" )
76- )
77- return parse_response_model (
78- response .data ,
72+ return await get_job_status_async (
73+ client = self ._client ,
74+ route_prefix = self ._ROUTE_PREFIX ,
75+ job_id = job_id ,
7976 model = BatchScrapeJobStatusResponse ,
8077 operation_name = self ._OPERATION_METADATA .status_operation_name ,
8178 )
@@ -84,12 +81,11 @@ async def get(
8481 self , job_id : str , params : Optional [GetBatchScrapeJobParams ] = None
8582 ) -> BatchScrapeJobResponse :
8683 query_params = build_batch_scrape_get_params (params )
87- response = await self ._client .transport .get (
88- self ._client ._build_url (f"{ self ._ROUTE_PREFIX } /{ job_id } " ),
84+ return await get_job_async (
85+ client = self ._client ,
86+ route_prefix = self ._ROUTE_PREFIX ,
87+ job_id = job_id ,
8988 params = query_params ,
90- )
91- return parse_response_model (
92- response .data ,
9389 model = BatchScrapeJobResponse ,
9490 operation_name = self ._OPERATION_METADATA .job_operation_name ,
9591 )
@@ -162,32 +158,29 @@ def __init__(self, client):
162158
163159 async def start (self , params : StartScrapeJobParams ) -> StartScrapeJobResponse :
164160 payload = build_scrape_start_payload (params )
165- response = await self ._client .transport .post (
166- self ._client ._build_url (self ._ROUTE_PREFIX ),
167- data = payload ,
168- )
169- return parse_response_model (
170- response .data ,
161+ return await start_job_async (
162+ client = self ._client ,
163+ route_prefix = self ._ROUTE_PREFIX ,
164+ payload = payload ,
171165 model = StartScrapeJobResponse ,
172166 operation_name = self ._OPERATION_METADATA .start_operation_name ,
173167 )
174168
175169 async def get_status (self , job_id : str ) -> ScrapeJobStatusResponse :
176- response = await self ._client .transport .get (
177- self ._client ._build_url (f"{ self ._ROUTE_PREFIX } /{ job_id } /status" )
178- )
179- return parse_response_model (
180- response .data ,
170+ return await get_job_status_async (
171+ client = self ._client ,
172+ route_prefix = self ._ROUTE_PREFIX ,
173+ job_id = job_id ,
181174 model = ScrapeJobStatusResponse ,
182175 operation_name = self ._OPERATION_METADATA .status_operation_name ,
183176 )
184177
185178 async def get (self , job_id : str ) -> ScrapeJobResponse :
186- response = await self . _client . transport . get (
187- self ._client . _build_url ( f" { self . _ROUTE_PREFIX } / { job_id } " )
188- )
189- return parse_response_model (
190- response . data ,
179+ return await get_job_async (
180+ client = self ._client ,
181+ route_prefix = self . _ROUTE_PREFIX ,
182+ job_id = job_id ,
183+ params = None ,
191184 model = ScrapeJobResponse ,
192185 operation_name = self ._OPERATION_METADATA .job_operation_name ,
193186 )
0 commit comments