8
8
import httpx
9
9
10
10
from .. import _legacy_response
11
- from ..types import Batch , batch_create_params
11
+ from ..types import Batch , batch_list_params , batch_create_params
12
12
from .._types import NOT_GIVEN , Body , Query , Headers , NotGiven
13
13
from .._utils import (
14
14
maybe_transform ,
17
17
from .._compat import cached_property
18
18
from .._resource import SyncAPIResource , AsyncAPIResource
19
19
from .._response import to_streamed_response_wrapper , async_to_streamed_response_wrapper
20
+ from ..pagination import SyncCursorPage , AsyncCursorPage
20
21
from .._base_client import (
22
+ AsyncPaginator ,
21
23
make_request_options ,
22
24
)
23
25
@@ -125,6 +127,58 @@ def retrieve(
125
127
cast_to = Batch ,
126
128
)
127
129
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
+
128
182
def cancel (
129
183
self ,
130
184
batch_id : str ,
@@ -260,6 +314,58 @@ async def retrieve(
260
314
cast_to = Batch ,
261
315
)
262
316
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
+
263
369
async def cancel (
264
370
self ,
265
371
batch_id : str ,
@@ -304,6 +410,9 @@ def __init__(self, batches: Batches) -> None:
304
410
self .retrieve = _legacy_response .to_raw_response_wrapper (
305
411
batches .retrieve ,
306
412
)
413
+ self .list = _legacy_response .to_raw_response_wrapper (
414
+ batches .list ,
415
+ )
307
416
self .cancel = _legacy_response .to_raw_response_wrapper (
308
417
batches .cancel ,
309
418
)
@@ -319,6 +428,9 @@ def __init__(self, batches: AsyncBatches) -> None:
319
428
self .retrieve = _legacy_response .async_to_raw_response_wrapper (
320
429
batches .retrieve ,
321
430
)
431
+ self .list = _legacy_response .async_to_raw_response_wrapper (
432
+ batches .list ,
433
+ )
322
434
self .cancel = _legacy_response .async_to_raw_response_wrapper (
323
435
batches .cancel ,
324
436
)
@@ -334,6 +446,9 @@ def __init__(self, batches: Batches) -> None:
334
446
self .retrieve = to_streamed_response_wrapper (
335
447
batches .retrieve ,
336
448
)
449
+ self .list = to_streamed_response_wrapper (
450
+ batches .list ,
451
+ )
337
452
self .cancel = to_streamed_response_wrapper (
338
453
batches .cancel ,
339
454
)
@@ -349,6 +464,9 @@ def __init__(self, batches: AsyncBatches) -> None:
349
464
self .retrieve = async_to_streamed_response_wrapper (
350
465
batches .retrieve ,
351
466
)
467
+ self .list = async_to_streamed_response_wrapper (
468
+ batches .list ,
469
+ )
352
470
self .cancel = async_to_streamed_response_wrapper (
353
471
batches .cancel ,
354
472
)
0 commit comments