Skip to content

Commit a0b3761

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
feat: update via SDK Studio (#106)
1 parent 7c51aa2 commit a0b3761

File tree

14 files changed

+132
-91
lines changed

14 files changed

+132
-91
lines changed

api.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2925,7 +2925,7 @@ from cloudflare.types.kv.namespaces import WorkersKVKey
29252925

29262926
Methods:
29272927

2928-
- <code title="get /accounts/{account_id}/storage/kv/namespaces/{namespace_id}/keys">client.kv.namespaces.keys.<a href="./src/cloudflare/resources/kv/namespaces/keys.py">list</a>(namespace_id, \*, account_id, \*\*<a href="src/cloudflare/types/kv/namespaces/key_list_params.py">params</a>) -> <a href="./src/cloudflare/types/kv/namespaces/workers_kv_key.py">SyncCursorPagination[WorkersKVKey]</a></code>
2928+
- <code title="get /accounts/{account_id}/storage/kv/namespaces/{namespace_id}/keys">client.kv.namespaces.keys.<a href="./src/cloudflare/resources/kv/namespaces/keys.py">list</a>(namespace_id, \*, account_id, \*\*<a href="src/cloudflare/types/kv/namespaces/key_list_params.py">params</a>) -> <a href="./src/cloudflare/types/kv/namespaces/workers_kv_key.py">SyncCursorLimitPagination[WorkersKVKey]</a></code>
29292929

29302930
### Metadata
29312931

@@ -2981,7 +2981,7 @@ from cloudflare.types.durable_objects.namespaces import WorkersObject
29812981

29822982
Methods:
29832983

2984-
- <code title="get /accounts/{account_id}/workers/durable_objects/namespaces/{id}/objects">client.durable_objects.namespaces.objects.<a href="./src/cloudflare/resources/durable_objects/namespaces/objects.py">list</a>(id, \*, account_id, \*\*<a href="src/cloudflare/types/durable_objects/namespaces/object_list_params.py">params</a>) -> <a href="./src/cloudflare/types/durable_objects/namespaces/workers_object.py">SyncCursorPagination[WorkersObject]</a></code>
2984+
- <code title="get /accounts/{account_id}/workers/durable_objects/namespaces/{id}/objects">client.durable_objects.namespaces.objects.<a href="./src/cloudflare/resources/durable_objects/namespaces/objects.py">list</a>(id, \*, account_id, \*\*<a href="src/cloudflare/types/durable_objects/namespaces/object_list_params.py">params</a>) -> <a href="./src/cloudflare/types/durable_objects/namespaces/workers_object.py">SyncCursorLimitPagination[WorkersObject]</a></code>
29852985

29862986
# Queues
29872987

@@ -4100,7 +4100,7 @@ Methods:
41004100

41014101
- <code title="post /accounts/{account_id}/rules/lists/{list_id}/items">client.rules.lists.items.<a href="./src/cloudflare/resources/rules/lists/items.py">create</a>(list_id, \*, account_id, \*\*<a href="src/cloudflare/types/rules/lists/item_create_params.py">params</a>) -> <a href="./src/cloudflare/types/rules/lists/item_create_response.py">Optional</a></code>
41024102
- <code title="put /accounts/{account_id}/rules/lists/{list_id}/items">client.rules.lists.items.<a href="./src/cloudflare/resources/rules/lists/items.py">update</a>(list_id, \*, account_id, \*\*<a href="src/cloudflare/types/rules/lists/item_update_params.py">params</a>) -> <a href="./src/cloudflare/types/rules/lists/item_update_response.py">Optional</a></code>
4103-
- <code title="get /accounts/{account_id}/rules/lists/{list_id}/items">client.rules.lists.items.<a href="./src/cloudflare/resources/rules/lists/items.py">list</a>(list_id, \*, account_id, \*\*<a href="src/cloudflare/types/rules/lists/item_list_params.py">params</a>) -> <a href="./src/cloudflare/types/rules/lists/item_list_response.py">Optional</a></code>
4103+
- <code title="get /accounts/{account_id}/rules/lists/{list_id}/items">client.rules.lists.items.<a href="./src/cloudflare/resources/rules/lists/items.py">list</a>(list_id, \*, account_id, \*\*<a href="src/cloudflare/types/rules/lists/item_list_params.py">params</a>) -> <a href="./src/cloudflare/types/rules/lists/item_list_response.py">SyncCursorPagination[object]</a></code>
41044104
- <code title="delete /accounts/{account_id}/rules/lists/{list_id}/items">client.rules.lists.items.<a href="./src/cloudflare/resources/rules/lists/items.py">delete</a>(list_id, \*, account_id, \*\*<a href="src/cloudflare/types/rules/lists/item_delete_params.py">params</a>) -> <a href="./src/cloudflare/types/rules/lists/item_delete_response.py">Optional</a></code>
41054105
- <code title="get /accounts/{account_identifier}/rules/lists/{list_id}/items/{item_id}">client.rules.lists.items.<a href="./src/cloudflare/resources/rules/lists/items.py">get</a>(item_id, \*, account_identifier, list_id) -> <a href="./src/cloudflare/types/rules/lists/item_get_response.py">Optional</a></code>
41064106

@@ -4472,13 +4472,13 @@ Methods:
44724472
Types:
44734473

44744474
```python
4475-
from cloudflare.types.r2 import R2Bucket, BucketListResponse, BucketDeleteResponse
4475+
from cloudflare.types.r2 import R2Bucket, BucketDeleteResponse
44764476
```
44774477

44784478
Methods:
44794479

44804480
- <code title="post /accounts/{account_id}/r2/buckets">client.r2.buckets.<a href="./src/cloudflare/resources/r2/buckets.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/r2/bucket_create_params.py">params</a>) -> <a href="./src/cloudflare/types/r2/r2_bucket.py">R2Bucket</a></code>
4481-
- <code title="get /accounts/{account_id}/r2/buckets">client.r2.buckets.<a href="./src/cloudflare/resources/r2/buckets.py">list</a>(\*, account_id, \*\*<a href="src/cloudflare/types/r2/bucket_list_params.py">params</a>) -> <a href="./src/cloudflare/types/r2/bucket_list_response.py">BucketListResponse</a></code>
4481+
- <code title="get /accounts/{account_id}/r2/buckets">client.r2.buckets.<a href="./src/cloudflare/resources/r2/buckets.py">list</a>(\*, account_id, \*\*<a href="src/cloudflare/types/r2/bucket_list_params.py">params</a>) -> <a href="./src/cloudflare/types/r2/r2_bucket.py">SyncCursorPagination[R2Bucket]</a></code>
44824482
- <code title="delete /accounts/{account_id}/r2/buckets/{bucket_name}">client.r2.buckets.<a href="./src/cloudflare/resources/r2/buckets.py">delete</a>(bucket_name, \*, account_id) -> <a href="./src/cloudflare/types/r2/bucket_delete_response.py">object</a></code>
44834483
- <code title="get /accounts/{account_id}/r2/buckets/{bucket_name}">client.r2.buckets.<a href="./src/cloudflare/resources/r2/buckets.py">get</a>(bucket_name, \*, account_id) -> <a href="./src/cloudflare/types/r2/r2_bucket.py">R2Bucket</a></code>
44844484

src/cloudflare/pagination.py

+55
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
"CursorPaginationResultInfo",
1818
"SyncCursorPagination",
1919
"AsyncCursorPagination",
20+
"CursorLimitPaginationResultInfo",
21+
"SyncCursorLimitPagination",
22+
"AsyncCursorLimitPagination",
2023
]
2124

2225
_T = TypeVar("_T")
@@ -192,3 +195,55 @@ def next_page_info(self) -> Optional[PageInfo]:
192195
return None
193196

194197
return PageInfo(params={"cursor": cursor})
198+
199+
200+
class CursorLimitPaginationResultInfo(BaseModel):
201+
count: Optional[int] = None
202+
203+
cursor: Optional[str] = None
204+
205+
per_page: Optional[int] = None
206+
207+
208+
class SyncCursorLimitPagination(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
209+
result: List[_T]
210+
result_info: Optional[CursorLimitPaginationResultInfo] = None
211+
212+
@override
213+
def _get_page_items(self) -> List[_T]:
214+
result = self.result
215+
if not result:
216+
return []
217+
return result
218+
219+
@override
220+
def next_page_info(self) -> Optional[PageInfo]:
221+
cursor = None
222+
if self.result_info is not None:
223+
cursor = self.result_info.cursor
224+
if not cursor:
225+
return None
226+
227+
return PageInfo(params={"cursor": cursor})
228+
229+
230+
class AsyncCursorLimitPagination(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
231+
result: List[_T]
232+
result_info: Optional[CursorLimitPaginationResultInfo] = None
233+
234+
@override
235+
def _get_page_items(self) -> List[_T]:
236+
result = self.result
237+
if not result:
238+
return []
239+
return result
240+
241+
@override
242+
def next_page_info(self) -> Optional[PageInfo]:
243+
cursor = None
244+
if self.result_info is not None:
245+
cursor = self.result_info.cursor
246+
if not cursor:
247+
return None
248+
249+
return PageInfo(params={"cursor": cursor})

src/cloudflare/resources/durable_objects/namespaces/objects.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
async_to_raw_response_wrapper,
1515
async_to_streamed_response_wrapper,
1616
)
17-
from ....pagination import SyncCursorPagination, AsyncCursorPagination
17+
from ....pagination import SyncCursorLimitPagination, AsyncCursorLimitPagination
1818
from ...._base_client import (
1919
AsyncPaginator,
2020
make_request_options,
@@ -46,7 +46,7 @@ def list(
4646
extra_query: Query | None = None,
4747
extra_body: Body | None = None,
4848
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
49-
) -> SyncCursorPagination[WorkersObject]:
49+
) -> SyncCursorLimitPagination[WorkersObject]:
5050
"""
5151
Returns the Durable Objects in a given namespace.
5252
@@ -76,7 +76,7 @@ def list(
7676
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
7777
return self._get_api_list(
7878
f"/accounts/{account_id}/workers/durable_objects/namespaces/{id}/objects",
79-
page=SyncCursorPagination[WorkersObject],
79+
page=SyncCursorLimitPagination[WorkersObject],
8080
options=make_request_options(
8181
extra_headers=extra_headers,
8282
extra_query=extra_query,
@@ -116,7 +116,7 @@ def list(
116116
extra_query: Query | None = None,
117117
extra_body: Body | None = None,
118118
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
119-
) -> AsyncPaginator[WorkersObject, AsyncCursorPagination[WorkersObject]]:
119+
) -> AsyncPaginator[WorkersObject, AsyncCursorLimitPagination[WorkersObject]]:
120120
"""
121121
Returns the Durable Objects in a given namespace.
122122
@@ -146,7 +146,7 @@ def list(
146146
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
147147
return self._get_api_list(
148148
f"/accounts/{account_id}/workers/durable_objects/namespaces/{id}/objects",
149-
page=AsyncCursorPagination[WorkersObject],
149+
page=AsyncCursorLimitPagination[WorkersObject],
150150
options=make_request_options(
151151
extra_headers=extra_headers,
152152
extra_query=extra_query,

src/cloudflare/resources/kv/namespaces/keys.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
async_to_raw_response_wrapper,
1515
async_to_streamed_response_wrapper,
1616
)
17-
from ....pagination import SyncCursorPagination, AsyncCursorPagination
17+
from ....pagination import SyncCursorLimitPagination, AsyncCursorLimitPagination
1818
from ...._base_client import (
1919
AsyncPaginator,
2020
make_request_options,
@@ -47,7 +47,7 @@ def list(
4747
extra_query: Query | None = None,
4848
extra_body: Body | None = None,
4949
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
50-
) -> SyncCursorPagination[WorkersKVKey]:
50+
) -> SyncCursorLimitPagination[WorkersKVKey]:
5151
"""
5252
Lists a namespace's keys.
5353
@@ -81,7 +81,7 @@ def list(
8181
raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}")
8282
return self._get_api_list(
8383
f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/keys",
84-
page=SyncCursorPagination[WorkersKVKey],
84+
page=SyncCursorLimitPagination[WorkersKVKey],
8585
options=make_request_options(
8686
extra_headers=extra_headers,
8787
extra_query=extra_query,
@@ -123,7 +123,7 @@ def list(
123123
extra_query: Query | None = None,
124124
extra_body: Body | None = None,
125125
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
126-
) -> AsyncPaginator[WorkersKVKey, AsyncCursorPagination[WorkersKVKey]]:
126+
) -> AsyncPaginator[WorkersKVKey, AsyncCursorLimitPagination[WorkersKVKey]]:
127127
"""
128128
Lists a namespace's keys.
129129
@@ -157,7 +157,7 @@ def list(
157157
raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}")
158158
return self._get_api_list(
159159
f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/keys",
160-
page=AsyncCursorPagination[WorkersKVKey],
160+
page=AsyncCursorLimitPagination[WorkersKVKey],
161161
options=make_request_options(
162162
extra_headers=extra_headers,
163163
extra_query=extra_query,

src/cloudflare/resources/r2/buckets.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
async_maybe_transform,
1414
)
1515
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
1717
from ..._resource import SyncAPIResource, AsyncAPIResource
1818
from ..._response import (
1919
to_raw_response_wrapper,
@@ -22,7 +22,9 @@
2222
async_to_streamed_response_wrapper,
2323
)
2424
from ..._wrappers import ResultWrapper
25+
from ...pagination import SyncCursorPagination, AsyncCursorPagination
2526
from ..._base_client import (
27+
AsyncPaginator,
2628
make_request_options,
2729
)
2830

@@ -106,7 +108,7 @@ def list(
106108
extra_query: Query | None = None,
107109
extra_body: Body | None = None,
108110
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
109-
) -> BucketListResponse:
111+
) -> SyncCursorPagination[R2Bucket]:
110112
"""
111113
Lists all R2 buckets on your account
112114
@@ -137,8 +139,9 @@ def list(
137139
"""
138140
if not account_id:
139141
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(
141143
f"/accounts/{account_id}/r2/buckets",
144+
page=SyncCursorPagination[R2Bucket],
142145
options=make_request_options(
143146
extra_headers=extra_headers,
144147
extra_query=extra_query,
@@ -155,9 +158,8 @@ def list(
155158
},
156159
bucket_list_params.BucketListParams,
157160
),
158-
post_parser=ResultWrapper._unwrapper,
159161
),
160-
cast_to=cast(Type[BucketListResponse], ResultWrapper[BucketListResponse]),
162+
model=R2Bucket,
161163
)
162164

163165
def delete(
@@ -310,7 +312,7 @@ async def create(
310312
cast_to=cast(Type[R2Bucket], ResultWrapper[R2Bucket]),
311313
)
312314

313-
async def list(
315+
def list(
314316
self,
315317
*,
316318
account_id: str,
@@ -326,7 +328,7 @@ async def list(
326328
extra_query: Query | None = None,
327329
extra_body: Body | None = None,
328330
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
329-
) -> BucketListResponse:
331+
) -> AsyncPaginator[R2Bucket, AsyncCursorPagination[R2Bucket]]:
330332
"""
331333
Lists all R2 buckets on your account
332334
@@ -357,14 +359,15 @@ async def list(
357359
"""
358360
if not account_id:
359361
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(
361363
f"/accounts/{account_id}/r2/buckets",
364+
page=AsyncCursorPagination[R2Bucket],
362365
options=make_request_options(
363366
extra_headers=extra_headers,
364367
extra_query=extra_query,
365368
extra_body=extra_body,
366369
timeout=timeout,
367-
query=await async_maybe_transform(
370+
query=maybe_transform(
368371
{
369372
"cursor": cursor,
370373
"direction": direction,
@@ -375,9 +378,8 @@ async def list(
375378
},
376379
bucket_list_params.BucketListParams,
377380
),
378-
post_parser=ResultWrapper._unwrapper,
379381
),
380-
cast_to=cast(Type[BucketListResponse], ResultWrapper[BucketListResponse]),
382+
model=R2Bucket,
381383
)
382384

383385
async def delete(

src/cloudflare/resources/rules/lists/items.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
async_to_streamed_response_wrapper,
2121
)
2222
from ...._wrappers import ResultWrapper
23+
from ....pagination import SyncCursorPagination, AsyncCursorPagination
2324
from ...._base_client import (
25+
AsyncPaginator,
2426
make_request_options,
2527
)
2628
from ....types.rules.lists import (
2729
ItemGetResponse,
28-
ItemListResponse,
2930
ItemCreateResponse,
3031
ItemDeleteResponse,
3132
ItemUpdateResponse,
@@ -163,7 +164,7 @@ def list(
163164
extra_query: Query | None = None,
164165
extra_body: Body | None = None,
165166
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
166-
) -> Optional[ItemListResponse]:
167+
) -> SyncCursorPagination[object]:
167168
"""
168169
Fetches all the items in the list.
169170
@@ -197,8 +198,9 @@ def list(
197198
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
198199
if not list_id:
199200
raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}")
200-
return self._get(
201+
return self._get_api_list(
201202
f"/accounts/{account_id}/rules/lists/{list_id}/items",
203+
page=SyncCursorPagination[object],
202204
options=make_request_options(
203205
extra_headers=extra_headers,
204206
extra_query=extra_query,
@@ -212,9 +214,8 @@ def list(
212214
},
213215
item_list_params.ItemListParams,
214216
),
215-
post_parser=ResultWrapper._unwrapper,
216217
),
217-
cast_to=cast(Type[Optional[ItemListResponse]], ResultWrapper[ItemListResponse]),
218+
model=object,
218219
)
219220

220221
def delete(
@@ -434,7 +435,7 @@ async def update(
434435
cast_to=cast(Type[Optional[ItemUpdateResponse]], ResultWrapper[ItemUpdateResponse]),
435436
)
436437

437-
async def list(
438+
def list(
438439
self,
439440
list_id: str,
440441
*,
@@ -448,7 +449,7 @@ async def list(
448449
extra_query: Query | None = None,
449450
extra_body: Body | None = None,
450451
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
451-
) -> Optional[ItemListResponse]:
452+
) -> AsyncPaginator[object, AsyncCursorPagination[object]]:
452453
"""
453454
Fetches all the items in the list.
454455
@@ -482,24 +483,24 @@ async def list(
482483
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
483484
if not list_id:
484485
raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}")
485-
return await self._get(
486+
return self._get_api_list(
486487
f"/accounts/{account_id}/rules/lists/{list_id}/items",
488+
page=AsyncCursorPagination[object],
487489
options=make_request_options(
488490
extra_headers=extra_headers,
489491
extra_query=extra_query,
490492
extra_body=extra_body,
491493
timeout=timeout,
492-
query=await async_maybe_transform(
494+
query=maybe_transform(
493495
{
494496
"cursor": cursor,
495497
"per_page": per_page,
496498
"search": search,
497499
},
498500
item_list_params.ItemListParams,
499501
),
500-
post_parser=ResultWrapper._unwrapper,
501502
),
502-
cast_to=cast(Type[Optional[ItemListResponse]], ResultWrapper[ItemListResponse]),
503+
model=object,
503504
)
504505

505506
async def delete(

src/cloudflare/types/r2/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77
from .bucket_list_params import BucketListParams as BucketListParams
88
from .sippy_update_params import SippyUpdateParams as SippyUpdateParams
99
from .bucket_create_params import BucketCreateParams as BucketCreateParams
10-
from .bucket_list_response import BucketListResponse as BucketListResponse
1110
from .sippy_delete_response import SippyDeleteResponse as SippyDeleteResponse

0 commit comments

Comments
 (0)