88import httpx
99
1010from .. import _legacy_response
11- from ..types import Batch , batch_create_params
11+ from ..types import Batch , batch_list_params , batch_create_params
1212from .._types import NOT_GIVEN , Body , Query , Headers , NotGiven
1313from .._utils import (
1414 maybe_transform ,
1717from .._compat import cached_property
1818from .._resource import SyncAPIResource , AsyncAPIResource
1919from .._response import to_streamed_response_wrapper , async_to_streamed_response_wrapper
20+ from ..pagination import SyncCursorPage , AsyncCursorPage
2021from .._base_client import (
22+ AsyncPaginator ,
2123 make_request_options ,
2224)
2325
@@ -125,6 +127,58 @@ def retrieve(
125127 cast_to = Batch ,
126128 )
127129
130+ def list (
131+ self ,
132+ * ,
133+ after : str | NotGiven = NOT_GIVEN ,
134+ limit : int | NotGiven = NOT_GIVEN ,
135+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
136+ # The extra values given here take precedence over values defined on the client or passed to this method.
137+ extra_headers : Headers | None = None ,
138+ extra_query : Query | None = None ,
139+ extra_body : Body | None = None ,
140+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
141+ ) -> SyncCursorPage [Batch ]:
142+ """List your organization's batches.
143+
144+ Args:
145+ after: A cursor for use in pagination.
146+
147+ `after` is an object ID that defines your place
148+ in the list. For instance, if you make a list request and receive 100 objects,
149+ ending with obj_foo, your subsequent call can include after=obj_foo in order to
150+ fetch the next page of the list.
151+
152+ limit: A limit on the number of objects to be returned. Limit can range between 1 and
153+ 100, and the default is 20.
154+
155+ extra_headers: Send extra headers
156+
157+ extra_query: Add additional query parameters to the request
158+
159+ extra_body: Add additional JSON properties to the request
160+
161+ timeout: Override the client-level default timeout for this request, in seconds
162+ """
163+ return self ._get_api_list (
164+ "/batches" ,
165+ page = SyncCursorPage [Batch ],
166+ options = make_request_options (
167+ extra_headers = extra_headers ,
168+ extra_query = extra_query ,
169+ extra_body = extra_body ,
170+ timeout = timeout ,
171+ query = maybe_transform (
172+ {
173+ "after" : after ,
174+ "limit" : limit ,
175+ },
176+ batch_list_params .BatchListParams ,
177+ ),
178+ ),
179+ model = Batch ,
180+ )
181+
128182 def cancel (
129183 self ,
130184 batch_id : str ,
@@ -260,6 +314,58 @@ async def retrieve(
260314 cast_to = Batch ,
261315 )
262316
317+ def list (
318+ self ,
319+ * ,
320+ after : str | NotGiven = NOT_GIVEN ,
321+ limit : int | NotGiven = NOT_GIVEN ,
322+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
323+ # The extra values given here take precedence over values defined on the client or passed to this method.
324+ extra_headers : Headers | None = None ,
325+ extra_query : Query | None = None ,
326+ extra_body : Body | None = None ,
327+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
328+ ) -> AsyncPaginator [Batch , AsyncCursorPage [Batch ]]:
329+ """List your organization's batches.
330+
331+ Args:
332+ after: A cursor for use in pagination.
333+
334+ `after` is an object ID that defines your place
335+ in the list. For instance, if you make a list request and receive 100 objects,
336+ ending with obj_foo, your subsequent call can include after=obj_foo in order to
337+ fetch the next page of the list.
338+
339+ limit: A limit on the number of objects to be returned. Limit can range between 1 and
340+ 100, and the default is 20.
341+
342+ extra_headers: Send extra headers
343+
344+ extra_query: Add additional query parameters to the request
345+
346+ extra_body: Add additional JSON properties to the request
347+
348+ timeout: Override the client-level default timeout for this request, in seconds
349+ """
350+ return self ._get_api_list (
351+ "/batches" ,
352+ page = AsyncCursorPage [Batch ],
353+ options = make_request_options (
354+ extra_headers = extra_headers ,
355+ extra_query = extra_query ,
356+ extra_body = extra_body ,
357+ timeout = timeout ,
358+ query = maybe_transform (
359+ {
360+ "after" : after ,
361+ "limit" : limit ,
362+ },
363+ batch_list_params .BatchListParams ,
364+ ),
365+ ),
366+ model = Batch ,
367+ )
368+
263369 async def cancel (
264370 self ,
265371 batch_id : str ,
@@ -304,6 +410,9 @@ def __init__(self, batches: Batches) -> None:
304410 self .retrieve = _legacy_response .to_raw_response_wrapper (
305411 batches .retrieve ,
306412 )
413+ self .list = _legacy_response .to_raw_response_wrapper (
414+ batches .list ,
415+ )
307416 self .cancel = _legacy_response .to_raw_response_wrapper (
308417 batches .cancel ,
309418 )
@@ -319,6 +428,9 @@ def __init__(self, batches: AsyncBatches) -> None:
319428 self .retrieve = _legacy_response .async_to_raw_response_wrapper (
320429 batches .retrieve ,
321430 )
431+ self .list = _legacy_response .async_to_raw_response_wrapper (
432+ batches .list ,
433+ )
322434 self .cancel = _legacy_response .async_to_raw_response_wrapper (
323435 batches .cancel ,
324436 )
@@ -334,6 +446,9 @@ def __init__(self, batches: Batches) -> None:
334446 self .retrieve = to_streamed_response_wrapper (
335447 batches .retrieve ,
336448 )
449+ self .list = to_streamed_response_wrapper (
450+ batches .list ,
451+ )
337452 self .cancel = to_streamed_response_wrapper (
338453 batches .cancel ,
339454 )
@@ -349,6 +464,9 @@ def __init__(self, batches: AsyncBatches) -> None:
349464 self .retrieve = async_to_streamed_response_wrapper (
350465 batches .retrieve ,
351466 )
467+ self .list = async_to_streamed_response_wrapper (
468+ batches .list ,
469+ )
352470 self .cancel = async_to_streamed_response_wrapper (
353471 batches .cancel ,
354472 )
0 commit comments