13
13
async_maybe_transform ,
14
14
)
15
15
from ..._compat import cached_property
16
- from ...types .r2 import R2Bucket , BucketListResponse , bucket_list_params , bucket_create_params
16
+ from ...types .r2 import R2Bucket , bucket_list_params , bucket_create_params
17
17
from ..._resource import SyncAPIResource , AsyncAPIResource
18
18
from ..._response import (
19
19
to_raw_response_wrapper ,
22
22
async_to_streamed_response_wrapper ,
23
23
)
24
24
from ..._wrappers import ResultWrapper
25
+ from ...pagination import SyncCursorPagination , AsyncCursorPagination
25
26
from ..._base_client import (
27
+ AsyncPaginator ,
26
28
make_request_options ,
27
29
)
28
30
@@ -106,7 +108,7 @@ def list(
106
108
extra_query : Query | None = None ,
107
109
extra_body : Body | None = None ,
108
110
timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
109
- ) -> BucketListResponse :
111
+ ) -> SyncCursorPagination [ R2Bucket ] :
110
112
"""
111
113
Lists all R2 buckets on your account
112
114
@@ -137,8 +139,9 @@ def list(
137
139
"""
138
140
if not account_id :
139
141
raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
140
- return self ._get (
142
+ return self ._get_api_list (
141
143
f"/accounts/{ account_id } /r2/buckets" ,
144
+ page = SyncCursorPagination [R2Bucket ],
142
145
options = make_request_options (
143
146
extra_headers = extra_headers ,
144
147
extra_query = extra_query ,
@@ -155,9 +158,8 @@ def list(
155
158
},
156
159
bucket_list_params .BucketListParams ,
157
160
),
158
- post_parser = ResultWrapper ._unwrapper ,
159
161
),
160
- cast_to = cast ( Type [ BucketListResponse ], ResultWrapper [ BucketListResponse ]) ,
162
+ model = R2Bucket ,
161
163
)
162
164
163
165
def delete (
@@ -310,7 +312,7 @@ async def create(
310
312
cast_to = cast (Type [R2Bucket ], ResultWrapper [R2Bucket ]),
311
313
)
312
314
313
- async def list (
315
+ def list (
314
316
self ,
315
317
* ,
316
318
account_id : str ,
@@ -326,7 +328,7 @@ async def list(
326
328
extra_query : Query | None = None ,
327
329
extra_body : Body | None = None ,
328
330
timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
329
- ) -> BucketListResponse :
331
+ ) -> AsyncPaginator [ R2Bucket , AsyncCursorPagination [ R2Bucket ]] :
330
332
"""
331
333
Lists all R2 buckets on your account
332
334
@@ -357,14 +359,15 @@ async def list(
357
359
"""
358
360
if not account_id :
359
361
raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
360
- return await self ._get (
362
+ return self ._get_api_list (
361
363
f"/accounts/{ account_id } /r2/buckets" ,
364
+ page = AsyncCursorPagination [R2Bucket ],
362
365
options = make_request_options (
363
366
extra_headers = extra_headers ,
364
367
extra_query = extra_query ,
365
368
extra_body = extra_body ,
366
369
timeout = timeout ,
367
- query = await async_maybe_transform (
370
+ query = maybe_transform (
368
371
{
369
372
"cursor" : cursor ,
370
373
"direction" : direction ,
@@ -375,9 +378,8 @@ async def list(
375
378
},
376
379
bucket_list_params .BucketListParams ,
377
380
),
378
- post_parser = ResultWrapper ._unwrapper ,
379
381
),
380
- cast_to = cast ( Type [ BucketListResponse ], ResultWrapper [ BucketListResponse ]) ,
382
+ model = R2Bucket ,
381
383
)
382
384
383
385
async def delete (
0 commit comments