Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): update via SDK Studio #183

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5842,17 +5842,17 @@ Methods:
Types:

```python
from cloudflare.types.challenges import NcChallengesAdminWidgetDetail, NcChallengesAdminWidgetList
from cloudflare.types.challenges import ChallengesWidget, ChallengesWidgetList
```

Methods:

- <code title="post /accounts/{account_id}/challenges/widgets">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/challenges/widget_create_params.py">params</a>) -> <a href="./src/cloudflare/types/challenges/nc_challenges_admin_widget_detail.py">Optional</a></code>
- <code title="put /accounts/{account_id}/challenges/widgets/{sitekey}">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">update</a>(sitekey, \*, account_id, \*\*<a href="src/cloudflare/types/challenges/widget_update_params.py">params</a>) -> <a href="./src/cloudflare/types/challenges/nc_challenges_admin_widget_detail.py">Optional</a></code>
- <code title="get /accounts/{account_id}/challenges/widgets">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">list</a>(\*, account_id, \*\*<a href="src/cloudflare/types/challenges/widget_list_params.py">params</a>) -> <a href="./src/cloudflare/types/challenges/nc_challenges_admin_widget_list.py">SyncV4PagePaginationArray[NcChallengesAdminWidgetList]</a></code>
- <code title="delete /accounts/{account_id}/challenges/widgets/{sitekey}">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">delete</a>(sitekey, \*, account_id) -> <a href="./src/cloudflare/types/challenges/nc_challenges_admin_widget_detail.py">Optional</a></code>
- <code title="get /accounts/{account_id}/challenges/widgets/{sitekey}">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">get</a>(sitekey, \*, account_id) -> <a href="./src/cloudflare/types/challenges/nc_challenges_admin_widget_detail.py">Optional</a></code>
- <code title="post /accounts/{account_id}/challenges/widgets/{sitekey}/rotate_secret">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">rotate_secret</a>(sitekey, \*, account_id, \*\*<a href="src/cloudflare/types/challenges/widget_rotate_secret_params.py">params</a>) -> <a href="./src/cloudflare/types/challenges/nc_challenges_admin_widget_detail.py">Optional</a></code>
- <code title="post /accounts/{account_id}/challenges/widgets">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">create</a>(\*, account_id, \*\*<a href="src/cloudflare/types/challenges/widget_create_params.py">params</a>) -> <a href="./src/cloudflare/types/challenges/challenges_widget.py">Optional</a></code>
- <code title="put /accounts/{account_id}/challenges/widgets/{sitekey}">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">update</a>(sitekey, \*, account_id, \*\*<a href="src/cloudflare/types/challenges/widget_update_params.py">params</a>) -> <a href="./src/cloudflare/types/challenges/challenges_widget.py">Optional</a></code>
- <code title="get /accounts/{account_id}/challenges/widgets">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">list</a>(\*, account_id, \*\*<a href="src/cloudflare/types/challenges/widget_list_params.py">params</a>) -> <a href="./src/cloudflare/types/challenges/challenges_widget_list.py">SyncV4PagePaginationArray[ChallengesWidgetList]</a></code>
- <code title="delete /accounts/{account_id}/challenges/widgets/{sitekey}">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">delete</a>(sitekey, \*, account_id) -> <a href="./src/cloudflare/types/challenges/challenges_widget.py">Optional</a></code>
- <code title="get /accounts/{account_id}/challenges/widgets/{sitekey}">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">get</a>(sitekey, \*, account_id) -> <a href="./src/cloudflare/types/challenges/challenges_widget.py">Optional</a></code>
- <code title="post /accounts/{account_id}/challenges/widgets/{sitekey}/rotate_secret">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">rotate_secret</a>(sitekey, \*, account_id, \*\*<a href="src/cloudflare/types/challenges/widget_rotate_secret_params.py">params</a>) -> <a href="./src/cloudflare/types/challenges/challenges_widget.py">Optional</a></code>

# Hyperdrive

Expand All @@ -5862,7 +5862,7 @@ Types:

```python
from cloudflare.types.hyperdrive import (
HyperdriveHyperdriveWithIdentifier,
Hyperdrive,
ConfigCreateResponse,
ConfigUpdateResponse,
ConfigListResponse,
Expand Down Expand Up @@ -7115,12 +7115,12 @@ Methods:
Types:

```python
from cloudflare.types.dcv_delegation import TLSCertificatesAndHostnamesUUIDObject
from cloudflare.types.dcv_delegation import DCVDelegationUUID
```

Methods:

- <code title="get /zones/{zone_id}/dcv_delegation/uuid">client.dcv_delegation.uuid.<a href="./src/cloudflare/resources/dcv_delegation/uuid.py">get</a>(\*, zone_id) -> <a href="./src/cloudflare/types/dcv_delegation/tls_certificates_and_hostnames_uuid_object.py">TLSCertificatesAndHostnamesUUIDObject</a></code>
- <code title="get /zones/{zone_id}/dcv_delegation/uuid">client.dcv_delegation.uuid.<a href="./src/cloudflare/resources/dcv_delegation/uuid.py">get</a>(\*, zone_id) -> <a href="./src/cloudflare/types/dcv_delegation/dcv_delegation_uuid.py">DCVDelegationUUID</a></code>

# Hostnames

Expand All @@ -7132,16 +7132,16 @@ Types:

```python
from cloudflare.types.hostnames.settings import (
TLSCertificatesAndHostnamesSettingObject,
TLSCertificatesAndHostnamesSettingObjectDelete,
HostnameSettingDelete,
HostnameStting,
TLSGetResponse,
)
```

Methods:

- <code title="put /zones/{zone_id}/hostnames/settings/{setting_id}/{hostname}">client.hostnames.settings.tls.<a href="./src/cloudflare/resources/hostnames/settings/tls.py">update</a>(hostname, \*, zone_id, setting_id, \*\*<a href="src/cloudflare/types/hostnames/settings/tls_update_params.py">params</a>) -> <a href="./src/cloudflare/types/hostnames/settings/tls_certificates_and_hostnames_setting_object.py">TLSCertificatesAndHostnamesSettingObject</a></code>
- <code title="delete /zones/{zone_id}/hostnames/settings/{setting_id}/{hostname}">client.hostnames.settings.tls.<a href="./src/cloudflare/resources/hostnames/settings/tls.py">delete</a>(hostname, \*, zone_id, setting_id) -> <a href="./src/cloudflare/types/hostnames/settings/tls_certificates_and_hostnames_setting_object_delete.py">TLSCertificatesAndHostnamesSettingObjectDelete</a></code>
- <code title="put /zones/{zone_id}/hostnames/settings/{setting_id}/{hostname}">client.hostnames.settings.tls.<a href="./src/cloudflare/resources/hostnames/settings/tls.py">update</a>(hostname, \*, zone_id, setting_id, \*\*<a href="src/cloudflare/types/hostnames/settings/tls_update_params.py">params</a>) -> <a href="./src/cloudflare/types/hostnames/settings/hostname_stting.py">HostnameStting</a></code>
- <code title="delete /zones/{zone_id}/hostnames/settings/{setting_id}/{hostname}">client.hostnames.settings.tls.<a href="./src/cloudflare/resources/hostnames/settings/tls.py">delete</a>(hostname, \*, zone_id, setting_id) -> <a href="./src/cloudflare/types/hostnames/settings/hostname_setting_delete.py">HostnameSettingDelete</a></code>
- <code title="get /zones/{zone_id}/hostnames/settings/{setting_id}">client.hostnames.settings.tls.<a href="./src/cloudflare/resources/hostnames/settings/tls.py">get</a>(setting_id, \*, zone_id) -> <a href="./src/cloudflare/types/hostnames/settings/tls_get_response.py">Optional</a></code>

# Snippets
Expand Down
41 changes: 9 additions & 32 deletions src/cloudflare/pagination.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Any, List, Type, Generic, Mapping, TypeVar, Optional, cast
from typing import List, Generic, TypeVar, Optional, cast
from typing_extensions import override

from httpx import Response

from ._utils import is_mapping
from ._models import BaseModel, GenericModel
from ._base_client import BasePage, PageInfo, BaseSyncPage, BaseAsyncPage

Expand All @@ -27,8 +24,6 @@
"AsyncSinglePage",
]

_BaseModelT = TypeVar("_BaseModelT", bound=BaseModel)

_T = TypeVar("_T")


Expand Down Expand Up @@ -257,14 +252,14 @@ def next_page_info(self) -> Optional[PageInfo]:


class SyncSinglePage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
result: List[_T]
items: List[_T]

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

@override
def next_page_info(self) -> None:
Expand All @@ -274,25 +269,16 @@ def next_page_info(self) -> None:
"""
return None

@classmethod
def build(cls: Type[_BaseModelT], *, response: Response, data: object) -> _BaseModelT: # noqa: ARG003
return cls.construct(
None,
**{
**(cast(Mapping[str, Any], data) if is_mapping(data) else {"result": data}),
},
)


class AsyncSinglePage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
result: List[_T]
items: List[_T]

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

@override
def next_page_info(self) -> None:
Expand All @@ -301,12 +287,3 @@ def next_page_info(self) -> None:
so there will never be a next page.
"""
return None

@classmethod
def build(cls: Type[_BaseModelT], *, response: Response, data: object) -> _BaseModelT: # noqa: ARG003
return cls.construct(
None,
**{
**(cast(Mapping[str, Any], data) if is_mapping(data) else {"result": data}),
},
)
56 changes: 28 additions & 28 deletions src/cloudflare/resources/challenges/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
make_request_options,
)
from ...types.challenges import (
NcChallengesAdminWidgetList,
NcChallengesAdminWidgetDetail,
ChallengesWidget,
ChallengesWidgetList,
widget_list_params,
widget_create_params,
widget_update_params,
Expand Down Expand Up @@ -68,7 +68,7 @@ def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
) -> Optional[ChallengesWidget]:
"""
Lists challenge widgets.

Expand Down Expand Up @@ -139,7 +139,7 @@ def create(
),
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
cast_to=cast(Type[Optional[ChallengesWidget]], ResultWrapper[ChallengesWidget]),
)

def update(
Expand All @@ -159,7 +159,7 @@ def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
) -> Optional[ChallengesWidget]:
"""
Update the configuration of a widget.

Expand Down Expand Up @@ -214,7 +214,7 @@ def update(
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
cast_to=cast(Type[Optional[ChallengesWidget]], ResultWrapper[ChallengesWidget]),
)

def list(
Expand All @@ -231,7 +231,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> SyncV4PagePaginationArray[NcChallengesAdminWidgetList]:
) -> SyncV4PagePaginationArray[ChallengesWidgetList]:
"""
Lists all turnstile widgets of an account.

Expand All @@ -258,7 +258,7 @@ def list(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return self._get_api_list(
f"/accounts/{account_id}/challenges/widgets",
page=SyncV4PagePaginationArray[NcChallengesAdminWidgetList],
page=SyncV4PagePaginationArray[ChallengesWidgetList],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand All @@ -274,7 +274,7 @@ def list(
widget_list_params.WidgetListParams,
),
),
model=NcChallengesAdminWidgetList,
model=ChallengesWidgetList,
)

def delete(
Expand All @@ -288,7 +288,7 @@ def delete(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
) -> Optional[ChallengesWidget]:
"""
Destroy a Turnstile Widget.

Expand Down Expand Up @@ -318,7 +318,7 @@ def delete(
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
cast_to=cast(Type[Optional[ChallengesWidget]], ResultWrapper[ChallengesWidget]),
)

def get(
Expand All @@ -332,7 +332,7 @@ def get(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
) -> Optional[ChallengesWidget]:
"""
Show a single challenge widget configuration.

Expand Down Expand Up @@ -362,7 +362,7 @@ def get(
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
cast_to=cast(Type[Optional[ChallengesWidget]], ResultWrapper[ChallengesWidget]),
)

def rotate_secret(
Expand All @@ -377,7 +377,7 @@ def rotate_secret(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
) -> Optional[ChallengesWidget]:
"""Generate a new secret key for this widget.

If `invalidate_immediately` is set to
Expand Down Expand Up @@ -418,7 +418,7 @@ def rotate_secret(
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
cast_to=cast(Type[Optional[ChallengesWidget]], ResultWrapper[ChallengesWidget]),
)


Expand Down Expand Up @@ -452,7 +452,7 @@ async def create(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
) -> Optional[ChallengesWidget]:
"""
Lists challenge widgets.

Expand Down Expand Up @@ -523,7 +523,7 @@ async def create(
),
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
cast_to=cast(Type[Optional[ChallengesWidget]], ResultWrapper[ChallengesWidget]),
)

async def update(
Expand All @@ -543,7 +543,7 @@ async def update(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
) -> Optional[ChallengesWidget]:
"""
Update the configuration of a widget.

Expand Down Expand Up @@ -598,7 +598,7 @@ async def update(
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
cast_to=cast(Type[Optional[ChallengesWidget]], ResultWrapper[ChallengesWidget]),
)

def list(
Expand All @@ -615,7 +615,7 @@ def list(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AsyncPaginator[NcChallengesAdminWidgetList, AsyncV4PagePaginationArray[NcChallengesAdminWidgetList]]:
) -> AsyncPaginator[ChallengesWidgetList, AsyncV4PagePaginationArray[ChallengesWidgetList]]:
"""
Lists all turnstile widgets of an account.

Expand All @@ -642,7 +642,7 @@ def list(
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return self._get_api_list(
f"/accounts/{account_id}/challenges/widgets",
page=AsyncV4PagePaginationArray[NcChallengesAdminWidgetList],
page=AsyncV4PagePaginationArray[ChallengesWidgetList],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand All @@ -658,7 +658,7 @@ def list(
widget_list_params.WidgetListParams,
),
),
model=NcChallengesAdminWidgetList,
model=ChallengesWidgetList,
)

async def delete(
Expand All @@ -672,7 +672,7 @@ async def delete(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
) -> Optional[ChallengesWidget]:
"""
Destroy a Turnstile Widget.

Expand Down Expand Up @@ -702,7 +702,7 @@ async def delete(
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
cast_to=cast(Type[Optional[ChallengesWidget]], ResultWrapper[ChallengesWidget]),
)

async def get(
Expand All @@ -716,7 +716,7 @@ async def get(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
) -> Optional[ChallengesWidget]:
"""
Show a single challenge widget configuration.

Expand Down Expand Up @@ -746,7 +746,7 @@ async def get(
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
cast_to=cast(Type[Optional[ChallengesWidget]], ResultWrapper[ChallengesWidget]),
)

async def rotate_secret(
Expand All @@ -761,7 +761,7 @@ async def rotate_secret(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
) -> Optional[ChallengesWidget]:
"""Generate a new secret key for this widget.

If `invalidate_immediately` is set to
Expand Down Expand Up @@ -802,7 +802,7 @@ async def rotate_secret(
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
cast_to=cast(Type[Optional[ChallengesWidget]], ResultWrapper[ChallengesWidget]),
)


Expand Down
Loading