Skip to content

Commit

Permalink
feat: update via SDK Studio (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Mar 12, 2024
1 parent 7c51aa2 commit a0b3761
Show file tree
Hide file tree
Showing 14 changed files with 132 additions and 91 deletions.
10 changes: 5 additions & 5 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2925,7 +2925,7 @@ from cloudflare.types.kv.namespaces import WorkersKVKey

Methods:

- <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>
- <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>

### Metadata

Expand Down Expand Up @@ -2981,7 +2981,7 @@ from cloudflare.types.durable_objects.namespaces import WorkersObject

Methods:

- <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>
- <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>

# Queues

Expand Down Expand Up @@ -4100,7 +4100,7 @@ Methods:

- <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>
- <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>
- <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>
- <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>
- <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>
- <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>

Expand Down Expand Up @@ -4472,13 +4472,13 @@ Methods:
Types:

```python
from cloudflare.types.r2 import R2Bucket, BucketListResponse, BucketDeleteResponse
from cloudflare.types.r2 import R2Bucket, BucketDeleteResponse
```

Methods:

- <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>
- <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>
- <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>
- <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>
- <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>

Expand Down
55 changes: 55 additions & 0 deletions src/cloudflare/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"CursorPaginationResultInfo",
"SyncCursorPagination",
"AsyncCursorPagination",
"CursorLimitPaginationResultInfo",
"SyncCursorLimitPagination",
"AsyncCursorLimitPagination",
]

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

return PageInfo(params={"cursor": cursor})


class CursorLimitPaginationResultInfo(BaseModel):
count: Optional[int] = None

cursor: Optional[str] = None

per_page: Optional[int] = None


class SyncCursorLimitPagination(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
result: List[_T]
result_info: Optional[CursorLimitPaginationResultInfo] = None

@override
def _get_page_items(self) -> List[_T]:
result = self.result
if not result:
return []
return result

@override
def next_page_info(self) -> Optional[PageInfo]:
cursor = None
if self.result_info is not None:
cursor = self.result_info.cursor
if not cursor:
return None

return PageInfo(params={"cursor": cursor})


class AsyncCursorLimitPagination(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
result: List[_T]
result_info: Optional[CursorLimitPaginationResultInfo] = None

@override
def _get_page_items(self) -> List[_T]:
result = self.result
if not result:
return []
return result

@override
def next_page_info(self) -> Optional[PageInfo]:
cursor = None
if self.result_info is not None:
cursor = self.result_info.cursor
if not cursor:
return None

return PageInfo(params={"cursor": cursor})
10 changes: 5 additions & 5 deletions src/cloudflare/resources/durable_objects/namespaces/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
from ....pagination import SyncCursorPagination, AsyncCursorPagination
from ....pagination import SyncCursorLimitPagination, AsyncCursorLimitPagination
from ...._base_client import (
AsyncPaginator,
make_request_options,
Expand Down Expand Up @@ -46,7 +46,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> SyncCursorPagination[WorkersObject]:
) -> SyncCursorLimitPagination[WorkersObject]:
"""
Returns the Durable Objects in a given namespace.
Expand Down Expand Up @@ -76,7 +76,7 @@ def list(
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
return self._get_api_list(
f"/accounts/{account_id}/workers/durable_objects/namespaces/{id}/objects",
page=SyncCursorPagination[WorkersObject],
page=SyncCursorLimitPagination[WorkersObject],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down Expand Up @@ -116,7 +116,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AsyncPaginator[WorkersObject, AsyncCursorPagination[WorkersObject]]:
) -> AsyncPaginator[WorkersObject, AsyncCursorLimitPagination[WorkersObject]]:
"""
Returns the Durable Objects in a given namespace.
Expand Down Expand Up @@ -146,7 +146,7 @@ def list(
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
return self._get_api_list(
f"/accounts/{account_id}/workers/durable_objects/namespaces/{id}/objects",
page=AsyncCursorPagination[WorkersObject],
page=AsyncCursorLimitPagination[WorkersObject],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down
10 changes: 5 additions & 5 deletions src/cloudflare/resources/kv/namespaces/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
from ....pagination import SyncCursorPagination, AsyncCursorPagination
from ....pagination import SyncCursorLimitPagination, AsyncCursorLimitPagination
from ...._base_client import (
AsyncPaginator,
make_request_options,
Expand Down Expand Up @@ -47,7 +47,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> SyncCursorPagination[WorkersKVKey]:
) -> SyncCursorLimitPagination[WorkersKVKey]:
"""
Lists a namespace's keys.
Expand Down Expand Up @@ -81,7 +81,7 @@ def list(
raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}")
return self._get_api_list(
f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/keys",
page=SyncCursorPagination[WorkersKVKey],
page=SyncCursorLimitPagination[WorkersKVKey],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down Expand Up @@ -123,7 +123,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AsyncPaginator[WorkersKVKey, AsyncCursorPagination[WorkersKVKey]]:
) -> AsyncPaginator[WorkersKVKey, AsyncCursorLimitPagination[WorkersKVKey]]:
"""
Lists a namespace's keys.
Expand Down Expand Up @@ -157,7 +157,7 @@ def list(
raise ValueError(f"Expected a non-empty value for `namespace_id` but received {namespace_id!r}")
return self._get_api_list(
f"/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/keys",
page=AsyncCursorPagination[WorkersKVKey],
page=AsyncCursorLimitPagination[WorkersKVKey],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand Down
24 changes: 13 additions & 11 deletions src/cloudflare/resources/r2/buckets.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
async_maybe_transform,
)
from ..._compat import cached_property
from ...types.r2 import R2Bucket, BucketListResponse, bucket_list_params, bucket_create_params
from ...types.r2 import R2Bucket, bucket_list_params, bucket_create_params
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import (
to_raw_response_wrapper,
Expand All @@ -22,7 +22,9 @@
async_to_streamed_response_wrapper,
)
from ..._wrappers import ResultWrapper
from ...pagination import SyncCursorPagination, AsyncCursorPagination
from ..._base_client import (
AsyncPaginator,
make_request_options,
)

Expand Down Expand Up @@ -106,7 +108,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> BucketListResponse:
) -> SyncCursorPagination[R2Bucket]:
"""
Lists all R2 buckets on your account
Expand Down Expand Up @@ -137,8 +139,9 @@ def list(
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return self._get(
return self._get_api_list(
f"/accounts/{account_id}/r2/buckets",
page=SyncCursorPagination[R2Bucket],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand All @@ -155,9 +158,8 @@ def list(
},
bucket_list_params.BucketListParams,
),
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[BucketListResponse], ResultWrapper[BucketListResponse]),
model=R2Bucket,
)

def delete(
Expand Down Expand Up @@ -310,7 +312,7 @@ async def create(
cast_to=cast(Type[R2Bucket], ResultWrapper[R2Bucket]),
)

async def list(
def list(
self,
*,
account_id: str,
Expand All @@ -326,7 +328,7 @@ async def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> BucketListResponse:
) -> AsyncPaginator[R2Bucket, AsyncCursorPagination[R2Bucket]]:
"""
Lists all R2 buckets on your account
Expand Down Expand Up @@ -357,14 +359,15 @@ async def list(
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return await self._get(
return self._get_api_list(
f"/accounts/{account_id}/r2/buckets",
page=AsyncCursorPagination[R2Bucket],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=await async_maybe_transform(
query=maybe_transform(
{
"cursor": cursor,
"direction": direction,
Expand All @@ -375,9 +378,8 @@ async def list(
},
bucket_list_params.BucketListParams,
),
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[BucketListResponse], ResultWrapper[BucketListResponse]),
model=R2Bucket,
)

async def delete(
Expand Down
23 changes: 12 additions & 11 deletions src/cloudflare/resources/rules/lists/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
async_to_streamed_response_wrapper,
)
from ...._wrappers import ResultWrapper
from ....pagination import SyncCursorPagination, AsyncCursorPagination
from ...._base_client import (
AsyncPaginator,
make_request_options,
)
from ....types.rules.lists import (
ItemGetResponse,
ItemListResponse,
ItemCreateResponse,
ItemDeleteResponse,
ItemUpdateResponse,
Expand Down Expand Up @@ -163,7 +164,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[ItemListResponse]:
) -> SyncCursorPagination[object]:
"""
Fetches all the items in the list.
Expand Down Expand Up @@ -197,8 +198,9 @@ def list(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not list_id:
raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}")
return self._get(
return self._get_api_list(
f"/accounts/{account_id}/rules/lists/{list_id}/items",
page=SyncCursorPagination[object],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand All @@ -212,9 +214,8 @@ def list(
},
item_list_params.ItemListParams,
),
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[ItemListResponse]], ResultWrapper[ItemListResponse]),
model=object,
)

def delete(
Expand Down Expand Up @@ -434,7 +435,7 @@ async def update(
cast_to=cast(Type[Optional[ItemUpdateResponse]], ResultWrapper[ItemUpdateResponse]),
)

async def list(
def list(
self,
list_id: str,
*,
Expand All @@ -448,7 +449,7 @@ async def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[ItemListResponse]:
) -> AsyncPaginator[object, AsyncCursorPagination[object]]:
"""
Fetches all the items in the list.
Expand Down Expand Up @@ -482,24 +483,24 @@ async def list(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not list_id:
raise ValueError(f"Expected a non-empty value for `list_id` but received {list_id!r}")
return await self._get(
return self._get_api_list(
f"/accounts/{account_id}/rules/lists/{list_id}/items",
page=AsyncCursorPagination[object],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=await async_maybe_transform(
query=maybe_transform(
{
"cursor": cursor,
"per_page": per_page,
"search": search,
},
item_list_params.ItemListParams,
),
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[ItemListResponse]], ResultWrapper[ItemListResponse]),
model=object,
)

async def delete(
Expand Down
1 change: 0 additions & 1 deletion src/cloudflare/types/r2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
from .bucket_list_params import BucketListParams as BucketListParams
from .sippy_update_params import SippyUpdateParams as SippyUpdateParams
from .bucket_create_params import BucketCreateParams as BucketCreateParams
from .bucket_list_response import BucketListResponse as BucketListResponse
from .sippy_delete_response import SippyDeleteResponse as SippyDeleteResponse
Loading

0 comments on commit a0b3761

Please sign in to comment.