44
55import httpx
66
7- from .._types import NOT_GIVEN , Body , Query , Headers , NoneType , NotGiven
7+ from .._types import NOT_GIVEN , Body , Query , Headers , NotGiven
88from .._compat import cached_property
99from .._resource import SyncAPIResource , AsyncAPIResource
1010from .._response import (
1313 async_to_raw_response_wrapper ,
1414 async_to_streamed_response_wrapper ,
1515)
16- from .._base_client import make_request_options
16+ from ..pagination import SyncCursorURLPage , AsyncCursorURLPage
17+ from .._base_client import AsyncPaginator , make_request_options
18+ from ..types .training_list_response import TrainingListResponse
19+ from ..types .training_cancel_response import TrainingCancelResponse
20+ from ..types .training_retrieve_response import TrainingRetrieveResponse
1721
1822__all__ = ["TrainingsResource" , "AsyncTrainingsResource" ]
1923
@@ -48,7 +52,7 @@ def retrieve(
4852 extra_query : Query | None = None ,
4953 extra_body : Body | None = None ,
5054 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
51- ) -> None :
55+ ) -> TrainingRetrieveResponse :
5256 """
5357 Get the current state of a training.
5458
@@ -123,13 +127,12 @@ def retrieve(
123127 """
124128 if not training_id :
125129 raise ValueError (f"Expected a non-empty value for `training_id` but received { training_id !r} " )
126- extra_headers = {"Accept" : "*/*" , ** (extra_headers or {})}
127130 return self ._get (
128131 f"/trainings/{ training_id } " ,
129132 options = make_request_options (
130133 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
131134 ),
132- cast_to = NoneType ,
135+ cast_to = TrainingRetrieveResponse ,
133136 )
134137
135138 def list (
@@ -141,7 +144,7 @@ def list(
141144 extra_query : Query | None = None ,
142145 extra_body : Body | None = None ,
143146 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
144- ) -> None :
147+ ) -> SyncCursorURLPage [ TrainingListResponse ] :
145148 """
146149 Get a paginated list of all trainings created by the user or organization
147150 associated with the provided API token.
@@ -207,13 +210,13 @@ def list(
207210
208211 `version` will be the unique ID of model version used to create the training.
209212 """
210- extra_headers = {"Accept" : "*/*" , ** (extra_headers or {})}
211- return self ._get (
213+ return self ._get_api_list (
212214 "/trainings" ,
215+ page = SyncCursorURLPage [TrainingListResponse ],
213216 options = make_request_options (
214217 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
215218 ),
216- cast_to = NoneType ,
219+ model = TrainingListResponse ,
217220 )
218221
219222 def cancel (
@@ -226,7 +229,7 @@ def cancel(
226229 extra_query : Query | None = None ,
227230 extra_body : Body | None = None ,
228231 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
229- ) -> None :
232+ ) -> TrainingCancelResponse :
230233 """
231234 Cancel a training
232235
@@ -241,13 +244,12 @@ def cancel(
241244 """
242245 if not training_id :
243246 raise ValueError (f"Expected a non-empty value for `training_id` but received { training_id !r} " )
244- extra_headers = {"Accept" : "*/*" , ** (extra_headers or {})}
245247 return self ._post (
246248 f"/trainings/{ training_id } /cancel" ,
247249 options = make_request_options (
248250 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
249251 ),
250- cast_to = NoneType ,
252+ cast_to = TrainingCancelResponse ,
251253 )
252254
253255
@@ -281,7 +283,7 @@ async def retrieve(
281283 extra_query : Query | None = None ,
282284 extra_body : Body | None = None ,
283285 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
284- ) -> None :
286+ ) -> TrainingRetrieveResponse :
285287 """
286288 Get the current state of a training.
287289
@@ -356,16 +358,15 @@ async def retrieve(
356358 """
357359 if not training_id :
358360 raise ValueError (f"Expected a non-empty value for `training_id` but received { training_id !r} " )
359- extra_headers = {"Accept" : "*/*" , ** (extra_headers or {})}
360361 return await self ._get (
361362 f"/trainings/{ training_id } " ,
362363 options = make_request_options (
363364 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
364365 ),
365- cast_to = NoneType ,
366+ cast_to = TrainingRetrieveResponse ,
366367 )
367368
368- async def list (
369+ def list (
369370 self ,
370371 * ,
371372 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -374,7 +375,7 @@ async def list(
374375 extra_query : Query | None = None ,
375376 extra_body : Body | None = None ,
376377 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
377- ) -> None :
378+ ) -> AsyncPaginator [ TrainingListResponse , AsyncCursorURLPage [ TrainingListResponse ]] :
378379 """
379380 Get a paginated list of all trainings created by the user or organization
380381 associated with the provided API token.
@@ -440,13 +441,13 @@ async def list(
440441
441442 `version` will be the unique ID of model version used to create the training.
442443 """
443- extra_headers = {"Accept" : "*/*" , ** (extra_headers or {})}
444- return await self ._get (
444+ return self ._get_api_list (
445445 "/trainings" ,
446+ page = AsyncCursorURLPage [TrainingListResponse ],
446447 options = make_request_options (
447448 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
448449 ),
449- cast_to = NoneType ,
450+ model = TrainingListResponse ,
450451 )
451452
452453 async def cancel (
@@ -459,7 +460,7 @@ async def cancel(
459460 extra_query : Query | None = None ,
460461 extra_body : Body | None = None ,
461462 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
462- ) -> None :
463+ ) -> TrainingCancelResponse :
463464 """
464465 Cancel a training
465466
@@ -474,13 +475,12 @@ async def cancel(
474475 """
475476 if not training_id :
476477 raise ValueError (f"Expected a non-empty value for `training_id` but received { training_id !r} " )
477- extra_headers = {"Accept" : "*/*" , ** (extra_headers or {})}
478478 return await self ._post (
479479 f"/trainings/{ training_id } /cancel" ,
480480 options = make_request_options (
481481 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
482482 ),
483- cast_to = NoneType ,
483+ cast_to = TrainingCancelResponse ,
484484 )
485485
486486
0 commit comments