feat: update via SDK Studio (#126)

This commit is contained in:
stainless-app[bot] 2024-03-13 03:19:27 +00:00
parent d96fe7f367
commit 62f33936fc
30 changed files with 2165 additions and 360 deletions

View file

@ -1 +1 @@
configured_endpoints: 1282
configured_endpoints: 1288

32
api.md
View file

@ -4489,6 +4489,7 @@ Types:
```python
from cloudflare.types.alerting.v3.destinations import (
AaaPagerduty,
PagerdutyCreateResponse,
PagerdutyDeleteResponse,
PagerdutyGetResponse,
@ -4509,11 +4510,11 @@ Types:
```python
from cloudflare.types.alerting.v3.destinations import (
AaaWebhooks,
WebhookCreateResponse,
WebhookUpdateResponse,
WebhookListResponse,
WebhookDeleteResponse,
WebhookGetResponse,
)
```
@ -4523,19 +4524,19 @@ Methods:
- <code title="put /accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}">client.alerting.v3.destinations.webhooks.<a href="./src/cloudflare/resources/alerting/v3/destinations/webhooks.py">update</a>(webhook_id, \*, account_id, \*\*<a href="src/cloudflare/types/alerting/v3/destinations/webhook_update_params.py">params</a>) -> <a href="./src/cloudflare/types/alerting/v3/destinations/webhook_update_response.py">WebhookUpdateResponse</a></code>
- <code title="get /accounts/{account_id}/alerting/v3/destinations/webhooks">client.alerting.v3.destinations.webhooks.<a href="./src/cloudflare/resources/alerting/v3/destinations/webhooks.py">list</a>(\*, account_id) -> <a href="./src/cloudflare/types/alerting/v3/destinations/webhook_list_response.py">Optional</a></code>
- <code title="delete /accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}">client.alerting.v3.destinations.webhooks.<a href="./src/cloudflare/resources/alerting/v3/destinations/webhooks.py">delete</a>(webhook_id, \*, account_id) -> <a href="./src/cloudflare/types/alerting/v3/destinations/webhook_delete_response.py">Optional</a></code>
- <code title="get /accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}">client.alerting.v3.destinations.webhooks.<a href="./src/cloudflare/resources/alerting/v3/destinations/webhooks.py">get</a>(webhook_id, \*, account_id) -> <a href="./src/cloudflare/types/alerting/v3/destinations/webhook_get_response.py">WebhookGetResponse</a></code>
- <code title="get /accounts/{account_id}/alerting/v3/destinations/webhooks/{webhook_id}">client.alerting.v3.destinations.webhooks.<a href="./src/cloudflare/resources/alerting/v3/destinations/webhooks.py">get</a>(webhook_id, \*, account_id) -> <a href="./src/cloudflare/types/alerting/v3/destinations/aaa_webhooks.py">AaaWebhooks</a></code>
### Histories
Types:
```python
from cloudflare.types.alerting.v3 import HistoryListResponse
from cloudflare.types.alerting.v3 import AaaHistory
```
Methods:
- <code title="get /accounts/{account_id}/alerting/v3/history">client.alerting.v3.histories.<a href="./src/cloudflare/resources/alerting/v3/histories.py">list</a>(\*, account_id, \*\*<a href="src/cloudflare/types/alerting/v3/history_list_params.py">params</a>) -> <a href="./src/cloudflare/types/alerting/v3/history_list_response.py">SyncV4PagePaginationArray[HistoryListResponse]</a></code>
- <code title="get /accounts/{account_id}/alerting/v3/history">client.alerting.v3.histories.<a href="./src/cloudflare/resources/alerting/v3/histories.py">list</a>(\*, account_id, \*\*<a href="src/cloudflare/types/alerting/v3/history_list_params.py">params</a>) -> <a href="./src/cloudflare/types/alerting/v3/aaa_history.py">SyncV4PagePaginationArray[AaaHistory]</a></code>
### Policies
@ -4543,11 +4544,11 @@ Types:
```python
from cloudflare.types.alerting.v3 import (
AaaPolicies,
PolicyCreateResponse,
PolicyUpdateResponse,
PolicyListResponse,
PolicyDeleteResponse,
PolicyGetResponse,
)
```
@ -4557,7 +4558,7 @@ Methods:
- <code title="put /accounts/{account_id}/alerting/v3/policies/{policy_id}">client.alerting.v3.policies.<a href="./src/cloudflare/resources/alerting/v3/policies.py">update</a>(policy_id, \*, account_id, \*\*<a href="src/cloudflare/types/alerting/v3/policy_update_params.py">params</a>) -> <a href="./src/cloudflare/types/alerting/v3/policy_update_response.py">PolicyUpdateResponse</a></code>
- <code title="get /accounts/{account_id}/alerting/v3/policies">client.alerting.v3.policies.<a href="./src/cloudflare/resources/alerting/v3/policies.py">list</a>(\*, account_id) -> <a href="./src/cloudflare/types/alerting/v3/policy_list_response.py">Optional</a></code>
- <code title="delete /accounts/{account_id}/alerting/v3/policies/{policy_id}">client.alerting.v3.policies.<a href="./src/cloudflare/resources/alerting/v3/policies.py">delete</a>(policy_id, \*, account_id) -> <a href="./src/cloudflare/types/alerting/v3/policy_delete_response.py">Optional</a></code>
- <code title="get /accounts/{account_id}/alerting/v3/policies/{policy_id}">client.alerting.v3.policies.<a href="./src/cloudflare/resources/alerting/v3/policies.py">get</a>(policy_id, \*, account_id) -> <a href="./src/cloudflare/types/alerting/v3/policy_get_response.py">PolicyGetResponse</a></code>
- <code title="get /accounts/{account_id}/alerting/v3/policies/{policy_id}">client.alerting.v3.policies.<a href="./src/cloudflare/resources/alerting/v3/policies.py">get</a>(policy_id, \*, account_id) -> <a href="./src/cloudflare/types/alerting/v3/aaa_policies.py">AaaPolicies</a></code>
# D1
@ -5830,6 +5831,25 @@ Methods:
- <code title="delete /accounts/{account_id}/teamnet/virtual_networks/{virtual_network_id}">client.zero_trust.networks.virtual_networks.<a href="./src/cloudflare/resources/zero_trust/networks/virtual_networks.py">delete</a>(virtual_network_id, \*, account_id) -> <a href="./src/cloudflare/types/zero_trust/networks/virtual_network_delete_response.py">VirtualNetworkDeleteResponse</a></code>
- <code title="patch /accounts/{account_id}/teamnet/virtual_networks/{virtual_network_id}">client.zero_trust.networks.virtual_networks.<a href="./src/cloudflare/resources/zero_trust/networks/virtual_networks.py">edit</a>(virtual_network_id, \*, account_id, \*\*<a href="src/cloudflare/types/zero_trust/networks/virtual_network_edit_params.py">params</a>) -> <a href="./src/cloudflare/types/zero_trust/networks/virtual_network_edit_response.py">VirtualNetworkEditResponse</a></code>
# Challenges
## Widgets
Types:
```python
from cloudflare.types.challenges import NcChallengesAdminWidgetDetail, NcChallengesAdminWidgetList
```
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>
# Hyperdrive
## Configs

View file

@ -113,6 +113,7 @@ class Cloudflare(SyncAPIClient):
warp_connector: resources.WARPConnector
workers_for_platforms: resources.WorkersForPlatforms
zero_trust: resources.ZeroTrust
challenges: resources.Challenges
hyperdrive: resources.Hyperdrive
rum: resources.RUM
vectorize: resources.Vectorize
@ -265,6 +266,7 @@ class Cloudflare(SyncAPIClient):
self.warp_connector = resources.WARPConnector(self)
self.workers_for_platforms = resources.WorkersForPlatforms(self)
self.zero_trust = resources.ZeroTrust(self)
self.challenges = resources.Challenges(self)
self.hyperdrive = resources.Hyperdrive(self)
self.rum = resources.RUM(self)
self.vectorize = resources.Vectorize(self)
@ -522,6 +524,7 @@ class AsyncCloudflare(AsyncAPIClient):
warp_connector: resources.AsyncWARPConnector
workers_for_platforms: resources.AsyncWorkersForPlatforms
zero_trust: resources.AsyncZeroTrust
challenges: resources.AsyncChallenges
hyperdrive: resources.AsyncHyperdrive
rum: resources.AsyncRUM
vectorize: resources.AsyncVectorize
@ -674,6 +677,7 @@ class AsyncCloudflare(AsyncAPIClient):
self.warp_connector = resources.AsyncWARPConnector(self)
self.workers_for_platforms = resources.AsyncWorkersForPlatforms(self)
self.zero_trust = resources.AsyncZeroTrust(self)
self.challenges = resources.AsyncChallenges(self)
self.hyperdrive = resources.AsyncHyperdrive(self)
self.rum = resources.AsyncRUM(self)
self.vectorize = resources.AsyncVectorize(self)
@ -932,6 +936,7 @@ class CloudflareWithRawResponse:
self.warp_connector = resources.WARPConnectorWithRawResponse(client.warp_connector)
self.workers_for_platforms = resources.WorkersForPlatformsWithRawResponse(client.workers_for_platforms)
self.zero_trust = resources.ZeroTrustWithRawResponse(client.zero_trust)
self.challenges = resources.ChallengesWithRawResponse(client.challenges)
self.hyperdrive = resources.HyperdriveWithRawResponse(client.hyperdrive)
self.rum = resources.RUMWithRawResponse(client.rum)
self.vectorize = resources.VectorizeWithRawResponse(client.vectorize)
@ -1021,6 +1026,7 @@ class AsyncCloudflareWithRawResponse:
self.warp_connector = resources.AsyncWARPConnectorWithRawResponse(client.warp_connector)
self.workers_for_platforms = resources.AsyncWorkersForPlatformsWithRawResponse(client.workers_for_platforms)
self.zero_trust = resources.AsyncZeroTrustWithRawResponse(client.zero_trust)
self.challenges = resources.AsyncChallengesWithRawResponse(client.challenges)
self.hyperdrive = resources.AsyncHyperdriveWithRawResponse(client.hyperdrive)
self.rum = resources.AsyncRUMWithRawResponse(client.rum)
self.vectorize = resources.AsyncVectorizeWithRawResponse(client.vectorize)
@ -1110,6 +1116,7 @@ class CloudflareWithStreamedResponse:
self.warp_connector = resources.WARPConnectorWithStreamingResponse(client.warp_connector)
self.workers_for_platforms = resources.WorkersForPlatformsWithStreamingResponse(client.workers_for_platforms)
self.zero_trust = resources.ZeroTrustWithStreamingResponse(client.zero_trust)
self.challenges = resources.ChallengesWithStreamingResponse(client.challenges)
self.hyperdrive = resources.HyperdriveWithStreamingResponse(client.hyperdrive)
self.rum = resources.RUMWithStreamingResponse(client.rum)
self.vectorize = resources.VectorizeWithStreamingResponse(client.vectorize)
@ -1205,6 +1212,7 @@ class AsyncCloudflareWithStreamedResponse:
client.workers_for_platforms
)
self.zero_trust = resources.AsyncZeroTrustWithStreamingResponse(client.zero_trust)
self.challenges = resources.AsyncChallengesWithStreamingResponse(client.challenges)
self.hyperdrive = resources.AsyncHyperdriveWithStreamingResponse(client.hyperdrive)
self.rum = resources.AsyncRUMWithStreamingResponse(client.rum)
self.vectorize = resources.AsyncVectorizeWithStreamingResponse(client.vectorize)

View file

@ -336,6 +336,14 @@ from .audit_logs import (
AuditLogsWithStreamingResponse,
AsyncAuditLogsWithStreamingResponse,
)
from .challenges import (
Challenges,
AsyncChallenges,
ChallengesWithRawResponse,
AsyncChallengesWithRawResponse,
ChallengesWithStreamingResponse,
AsyncChallengesWithStreamingResponse,
)
from .hyperdrive import (
Hyperdrive,
AsyncHyperdrive,
@ -1030,6 +1038,12 @@ __all__ = [
"AsyncZeroTrustWithRawResponse",
"ZeroTrustWithStreamingResponse",
"AsyncZeroTrustWithStreamingResponse",
"Challenges",
"AsyncChallenges",
"ChallengesWithRawResponse",
"AsyncChallengesWithRawResponse",
"ChallengesWithStreamingResponse",
"AsyncChallengesWithStreamingResponse",
"Hyperdrive",
"AsyncHyperdrive",
"HyperdriveWithRawResponse",

View file

@ -24,7 +24,7 @@ from ....._base_client import (
make_request_options,
)
from .....types.alerting.v3.destinations import (
WebhookGetResponse,
AaaWebhooks,
WebhookListResponse,
WebhookCreateResponse,
WebhookDeleteResponse,
@ -267,7 +267,7 @@ class Webhooks(SyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> WebhookGetResponse:
) -> AaaWebhooks:
"""
Get details for a single webhooks destination.
@ -297,7 +297,7 @@ class Webhooks(SyncAPIResource):
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[WebhookGetResponse], ResultWrapper[WebhookGetResponse]),
cast_to=cast(Type[AaaWebhooks], ResultWrapper[AaaWebhooks]),
)
@ -532,7 +532,7 @@ class AsyncWebhooks(AsyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> WebhookGetResponse:
) -> AaaWebhooks:
"""
Get details for a single webhooks destination.
@ -562,7 +562,7 @@ class AsyncWebhooks(AsyncAPIResource):
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[WebhookGetResponse], ResultWrapper[WebhookGetResponse]),
cast_to=cast(Type[AaaWebhooks], ResultWrapper[AaaWebhooks]),
)

View file

@ -22,7 +22,7 @@ from ...._base_client import (
AsyncPaginator,
make_request_options,
)
from ....types.alerting.v3 import HistoryListResponse, history_list_params
from ....types.alerting.v3 import AaaHistory, history_list_params
__all__ = ["Histories", "AsyncHistories"]
@ -50,7 +50,7 @@ class Histories(SyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> SyncV4PagePaginationArray[HistoryListResponse]:
) -> SyncV4PagePaginationArray[AaaHistory]:
"""Gets a list of history records for notifications sent to an account.
The records
@ -82,7 +82,7 @@ class Histories(SyncAPIResource):
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}/alerting/v3/history",
page=SyncV4PagePaginationArray[HistoryListResponse],
page=SyncV4PagePaginationArray[AaaHistory],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@ -98,7 +98,7 @@ class Histories(SyncAPIResource):
history_list_params.HistoryListParams,
),
),
model=HistoryListResponse,
model=AaaHistory,
)
@ -125,7 +125,7 @@ class AsyncHistories(AsyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AsyncPaginator[HistoryListResponse, AsyncV4PagePaginationArray[HistoryListResponse]]:
) -> AsyncPaginator[AaaHistory, AsyncV4PagePaginationArray[AaaHistory]]:
"""Gets a list of history records for notifications sent to an account.
The records
@ -157,7 +157,7 @@ class AsyncHistories(AsyncAPIResource):
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}/alerting/v3/history",
page=AsyncV4PagePaginationArray[HistoryListResponse],
page=AsyncV4PagePaginationArray[AaaHistory],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
@ -173,7 +173,7 @@ class AsyncHistories(AsyncAPIResource):
history_list_params.HistoryListParams,
),
),
model=HistoryListResponse,
model=AaaHistory,
)

View file

@ -25,7 +25,7 @@ from ...._base_client import (
make_request_options,
)
from ....types.alerting.v3 import (
PolicyGetResponse,
AaaPolicies,
PolicyListResponse,
PolicyCreateResponse,
PolicyDeleteResponse,
@ -409,7 +409,7 @@ class Policies(SyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> PolicyGetResponse:
) -> AaaPolicies:
"""
Get details for a single policy.
@ -439,7 +439,7 @@ class Policies(SyncAPIResource):
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[PolicyGetResponse], ResultWrapper[PolicyGetResponse]),
cast_to=cast(Type[AaaPolicies], ResultWrapper[AaaPolicies]),
)
@ -815,7 +815,7 @@ class AsyncPolicies(AsyncAPIResource):
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> PolicyGetResponse:
) -> AaaPolicies:
"""
Get details for a single policy.
@ -845,7 +845,7 @@ class AsyncPolicies(AsyncAPIResource):
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[PolicyGetResponse], ResultWrapper[PolicyGetResponse]),
cast_to=cast(Type[AaaPolicies], ResultWrapper[AaaPolicies]),
)

View file

@ -0,0 +1,33 @@
# File generated from our OpenAPI spec by Stainless.
from .widgets import (
Widgets,
AsyncWidgets,
WidgetsWithRawResponse,
AsyncWidgetsWithRawResponse,
WidgetsWithStreamingResponse,
AsyncWidgetsWithStreamingResponse,
)
from .challenges import (
Challenges,
AsyncChallenges,
ChallengesWithRawResponse,
AsyncChallengesWithRawResponse,
ChallengesWithStreamingResponse,
AsyncChallengesWithStreamingResponse,
)
__all__ = [
"Widgets",
"AsyncWidgets",
"WidgetsWithRawResponse",
"AsyncWidgetsWithRawResponse",
"WidgetsWithStreamingResponse",
"AsyncWidgetsWithStreamingResponse",
"Challenges",
"AsyncChallenges",
"ChallengesWithRawResponse",
"AsyncChallengesWithRawResponse",
"ChallengesWithStreamingResponse",
"AsyncChallengesWithStreamingResponse",
]

View file

@ -0,0 +1,80 @@
# File generated from our OpenAPI spec by Stainless.
from __future__ import annotations
from .widgets import (
Widgets,
AsyncWidgets,
WidgetsWithRawResponse,
AsyncWidgetsWithRawResponse,
WidgetsWithStreamingResponse,
AsyncWidgetsWithStreamingResponse,
)
from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
__all__ = ["Challenges", "AsyncChallenges"]
class Challenges(SyncAPIResource):
@cached_property
def widgets(self) -> Widgets:
return Widgets(self._client)
@cached_property
def with_raw_response(self) -> ChallengesWithRawResponse:
return ChallengesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> ChallengesWithStreamingResponse:
return ChallengesWithStreamingResponse(self)
class AsyncChallenges(AsyncAPIResource):
@cached_property
def widgets(self) -> AsyncWidgets:
return AsyncWidgets(self._client)
@cached_property
def with_raw_response(self) -> AsyncChallengesWithRawResponse:
return AsyncChallengesWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncChallengesWithStreamingResponse:
return AsyncChallengesWithStreamingResponse(self)
class ChallengesWithRawResponse:
def __init__(self, challenges: Challenges) -> None:
self._challenges = challenges
@cached_property
def widgets(self) -> WidgetsWithRawResponse:
return WidgetsWithRawResponse(self._challenges.widgets)
class AsyncChallengesWithRawResponse:
def __init__(self, challenges: AsyncChallenges) -> None:
self._challenges = challenges
@cached_property
def widgets(self) -> AsyncWidgetsWithRawResponse:
return AsyncWidgetsWithRawResponse(self._challenges.widgets)
class ChallengesWithStreamingResponse:
def __init__(self, challenges: Challenges) -> None:
self._challenges = challenges
@cached_property
def widgets(self) -> WidgetsWithStreamingResponse:
return WidgetsWithStreamingResponse(self._challenges.widgets)
class AsyncChallengesWithStreamingResponse:
def __init__(self, challenges: AsyncChallenges) -> None:
self._challenges = challenges
@cached_property
def widgets(self) -> AsyncWidgetsWithStreamingResponse:
return AsyncWidgetsWithStreamingResponse(self._challenges.widgets)

View file

@ -0,0 +1,902 @@
# File generated from our OpenAPI spec by Stainless.
from __future__ import annotations
from typing import List, Type, Optional, cast
from typing_extensions import Literal
import httpx
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._utils import (
maybe_transform,
async_maybe_transform,
)
from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import (
to_raw_response_wrapper,
to_streamed_response_wrapper,
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
from ..._wrappers import ResultWrapper
from ...pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
from ..._base_client import (
AsyncPaginator,
make_request_options,
)
from ...types.challenges import (
NcChallengesAdminWidgetList,
NcChallengesAdminWidgetDetail,
widget_list_params,
widget_create_params,
widget_update_params,
widget_rotate_secret_params,
)
__all__ = ["Widgets", "AsyncWidgets"]
class Widgets(SyncAPIResource):
@cached_property
def with_raw_response(self) -> WidgetsWithRawResponse:
return WidgetsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> WidgetsWithStreamingResponse:
return WidgetsWithStreamingResponse(self)
def create(
self,
*,
account_id: str,
domains: List[str],
mode: Literal["non-interactive", "invisible", "managed"],
name: str,
direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
order: Literal["id", "sitekey", "name", "created_on", "modified_on"] | NotGiven = NOT_GIVEN,
page: float | NotGiven = NOT_GIVEN,
per_page: float | NotGiven = NOT_GIVEN,
bot_fight_mode: bool | NotGiven = NOT_GIVEN,
clearance_level: Literal["no_clearance", "jschallenge", "managed", "interactive"] | NotGiven = NOT_GIVEN,
offlabel: bool | NotGiven = NOT_GIVEN,
region: Literal["world"] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
"""
Lists challenge widgets.
Args:
account_id: Identifier
mode: Widget Mode
name: Human readable widget name. Not unique. Cloudflare suggests that you set this to
a meaningful string to make it easier to identify your widget, and where it is
used.
direction: Direction to order widgets.
order: Field to order widgets by.
page: Page number of paginated results.
per_page: Number of items per page.
bot_fight_mode: If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive
challenges in response to malicious bots (ENT only).
clearance_level: If Turnstile is embedded on a Cloudflare site and the widget should grant
challenge clearance, this setting can determine the clearance level to be set
offlabel: Do not show any Cloudflare branding on the widget (ENT only).
region: Region where this widget can be used.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return self._post(
f"/accounts/{account_id}/challenges/widgets",
body=maybe_transform(
{
"domains": domains,
"mode": mode,
"name": name,
"bot_fight_mode": bot_fight_mode,
"clearance_level": clearance_level,
"offlabel": offlabel,
"region": region,
},
widget_create_params.WidgetCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"direction": direction,
"order": order,
"page": page,
"per_page": per_page,
},
widget_create_params.WidgetCreateParams,
),
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
)
def update(
self,
sitekey: str,
*,
account_id: str,
domains: List[str],
mode: Literal["non-interactive", "invisible", "managed"],
name: str,
bot_fight_mode: bool | NotGiven = NOT_GIVEN,
clearance_level: Literal["no_clearance", "jschallenge", "managed", "interactive"] | NotGiven = NOT_GIVEN,
offlabel: bool | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
"""
Update the configuration of a widget.
Args:
account_id: Identifier
sitekey: Widget item identifier tag.
mode: Widget Mode
name: Human readable widget name. Not unique. Cloudflare suggests that you set this to
a meaningful string to make it easier to identify your widget, and where it is
used.
bot_fight_mode: If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive
challenges in response to malicious bots (ENT only).
clearance_level: If Turnstile is embedded on a Cloudflare site and the widget should grant
challenge clearance, this setting can determine the clearance level to be set
offlabel: Do not show any Cloudflare branding on the widget (ENT only).
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not sitekey:
raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}")
return self._put(
f"/accounts/{account_id}/challenges/widgets/{sitekey}",
body=maybe_transform(
{
"domains": domains,
"mode": mode,
"name": name,
"bot_fight_mode": bot_fight_mode,
"clearance_level": clearance_level,
"offlabel": offlabel,
},
widget_update_params.WidgetUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
)
def list(
self,
*,
account_id: str,
direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
order: Literal["id", "sitekey", "name", "created_on", "modified_on"] | NotGiven = NOT_GIVEN,
page: float | NotGiven = NOT_GIVEN,
per_page: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> SyncV4PagePaginationArray[NcChallengesAdminWidgetList]:
"""
Lists all turnstile widgets of an account.
Args:
account_id: Identifier
direction: Direction to order widgets.
order: Field to order widgets by.
page: Page number of paginated results.
per_page: Number of items per page.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
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],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"direction": direction,
"order": order,
"page": page,
"per_page": per_page,
},
widget_list_params.WidgetListParams,
),
),
model=NcChallengesAdminWidgetList,
)
def delete(
self,
sitekey: str,
*,
account_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
"""
Destroy a Turnstile Widget.
Args:
account_id: Identifier
sitekey: Widget item identifier tag.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not sitekey:
raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}")
return self._delete(
f"/accounts/{account_id}/challenges/widgets/{sitekey}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
)
def get(
self,
sitekey: str,
*,
account_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
"""
Show a single challenge widget configuration.
Args:
account_id: Identifier
sitekey: Widget item identifier tag.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not sitekey:
raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}")
return self._get(
f"/accounts/{account_id}/challenges/widgets/{sitekey}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
)
def rotate_secret(
self,
sitekey: str,
*,
account_id: str,
invalidate_immediately: bool | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
"""Generate a new secret key for this widget.
If `invalidate_immediately` is set to
`false`, the previous secret remains valid for 2 hours.
Note that secrets cannot be rotated again during the grace period.
Args:
account_id: Identifier
sitekey: Widget item identifier tag.
invalidate_immediately: If `invalidate_immediately` is set to `false`, the previous secret will remain
valid for two hours. Otherwise, the secret is immediately invalidated, and
requests using it will be rejected.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not sitekey:
raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}")
return self._post(
f"/accounts/{account_id}/challenges/widgets/{sitekey}/rotate_secret",
body=maybe_transform(
{"invalidate_immediately": invalidate_immediately}, widget_rotate_secret_params.WidgetRotateSecretParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
)
class AsyncWidgets(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncWidgetsWithRawResponse:
return AsyncWidgetsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncWidgetsWithStreamingResponse:
return AsyncWidgetsWithStreamingResponse(self)
async def create(
self,
*,
account_id: str,
domains: List[str],
mode: Literal["non-interactive", "invisible", "managed"],
name: str,
direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
order: Literal["id", "sitekey", "name", "created_on", "modified_on"] | NotGiven = NOT_GIVEN,
page: float | NotGiven = NOT_GIVEN,
per_page: float | NotGiven = NOT_GIVEN,
bot_fight_mode: bool | NotGiven = NOT_GIVEN,
clearance_level: Literal["no_clearance", "jschallenge", "managed", "interactive"] | NotGiven = NOT_GIVEN,
offlabel: bool | NotGiven = NOT_GIVEN,
region: Literal["world"] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
"""
Lists challenge widgets.
Args:
account_id: Identifier
mode: Widget Mode
name: Human readable widget name. Not unique. Cloudflare suggests that you set this to
a meaningful string to make it easier to identify your widget, and where it is
used.
direction: Direction to order widgets.
order: Field to order widgets by.
page: Page number of paginated results.
per_page: Number of items per page.
bot_fight_mode: If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive
challenges in response to malicious bots (ENT only).
clearance_level: If Turnstile is embedded on a Cloudflare site and the widget should grant
challenge clearance, this setting can determine the clearance level to be set
offlabel: Do not show any Cloudflare branding on the widget (ENT only).
region: Region where this widget can be used.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return await self._post(
f"/accounts/{account_id}/challenges/widgets",
body=await async_maybe_transform(
{
"domains": domains,
"mode": mode,
"name": name,
"bot_fight_mode": bot_fight_mode,
"clearance_level": clearance_level,
"offlabel": offlabel,
"region": region,
},
widget_create_params.WidgetCreateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=await async_maybe_transform(
{
"direction": direction,
"order": order,
"page": page,
"per_page": per_page,
},
widget_create_params.WidgetCreateParams,
),
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
)
async def update(
self,
sitekey: str,
*,
account_id: str,
domains: List[str],
mode: Literal["non-interactive", "invisible", "managed"],
name: str,
bot_fight_mode: bool | NotGiven = NOT_GIVEN,
clearance_level: Literal["no_clearance", "jschallenge", "managed", "interactive"] | NotGiven = NOT_GIVEN,
offlabel: bool | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
"""
Update the configuration of a widget.
Args:
account_id: Identifier
sitekey: Widget item identifier tag.
mode: Widget Mode
name: Human readable widget name. Not unique. Cloudflare suggests that you set this to
a meaningful string to make it easier to identify your widget, and where it is
used.
bot_fight_mode: If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive
challenges in response to malicious bots (ENT only).
clearance_level: If Turnstile is embedded on a Cloudflare site and the widget should grant
challenge clearance, this setting can determine the clearance level to be set
offlabel: Do not show any Cloudflare branding on the widget (ENT only).
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not sitekey:
raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}")
return await self._put(
f"/accounts/{account_id}/challenges/widgets/{sitekey}",
body=await async_maybe_transform(
{
"domains": domains,
"mode": mode,
"name": name,
"bot_fight_mode": bot_fight_mode,
"clearance_level": clearance_level,
"offlabel": offlabel,
},
widget_update_params.WidgetUpdateParams,
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
)
def list(
self,
*,
account_id: str,
direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
order: Literal["id", "sitekey", "name", "created_on", "modified_on"] | NotGiven = NOT_GIVEN,
page: float | NotGiven = NOT_GIVEN,
per_page: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> AsyncPaginator[NcChallengesAdminWidgetList, AsyncV4PagePaginationArray[NcChallengesAdminWidgetList]]:
"""
Lists all turnstile widgets of an account.
Args:
account_id: Identifier
direction: Direction to order widgets.
order: Field to order widgets by.
page: Page number of paginated results.
per_page: Number of items per page.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
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],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform(
{
"direction": direction,
"order": order,
"page": page,
"per_page": per_page,
},
widget_list_params.WidgetListParams,
),
),
model=NcChallengesAdminWidgetList,
)
async def delete(
self,
sitekey: str,
*,
account_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
"""
Destroy a Turnstile Widget.
Args:
account_id: Identifier
sitekey: Widget item identifier tag.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not sitekey:
raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}")
return await self._delete(
f"/accounts/{account_id}/challenges/widgets/{sitekey}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
)
async def get(
self,
sitekey: str,
*,
account_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
"""
Show a single challenge widget configuration.
Args:
account_id: Identifier
sitekey: Widget item identifier tag.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not sitekey:
raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}")
return await self._get(
f"/accounts/{account_id}/challenges/widgets/{sitekey}",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
)
async def rotate_secret(
self,
sitekey: str,
*,
account_id: str,
invalidate_immediately: bool | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Optional[NcChallengesAdminWidgetDetail]:
"""Generate a new secret key for this widget.
If `invalidate_immediately` is set to
`false`, the previous secret remains valid for 2 hours.
Note that secrets cannot be rotated again during the grace period.
Args:
account_id: Identifier
sitekey: Widget item identifier tag.
invalidate_immediately: If `invalidate_immediately` is set to `false`, the previous secret will remain
valid for two hours. Otherwise, the secret is immediately invalidated, and
requests using it will be rejected.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
if not sitekey:
raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}")
return await self._post(
f"/accounts/{account_id}/challenges/widgets/{sitekey}/rotate_secret",
body=await async_maybe_transform(
{"invalidate_immediately": invalidate_immediately}, widget_rotate_secret_params.WidgetRotateSecretParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Optional[NcChallengesAdminWidgetDetail]], ResultWrapper[NcChallengesAdminWidgetDetail]),
)
class WidgetsWithRawResponse:
def __init__(self, widgets: Widgets) -> None:
self._widgets = widgets
self.create = to_raw_response_wrapper(
widgets.create,
)
self.update = to_raw_response_wrapper(
widgets.update,
)
self.list = to_raw_response_wrapper(
widgets.list,
)
self.delete = to_raw_response_wrapper(
widgets.delete,
)
self.get = to_raw_response_wrapper(
widgets.get,
)
self.rotate_secret = to_raw_response_wrapper(
widgets.rotate_secret,
)
class AsyncWidgetsWithRawResponse:
def __init__(self, widgets: AsyncWidgets) -> None:
self._widgets = widgets
self.create = async_to_raw_response_wrapper(
widgets.create,
)
self.update = async_to_raw_response_wrapper(
widgets.update,
)
self.list = async_to_raw_response_wrapper(
widgets.list,
)
self.delete = async_to_raw_response_wrapper(
widgets.delete,
)
self.get = async_to_raw_response_wrapper(
widgets.get,
)
self.rotate_secret = async_to_raw_response_wrapper(
widgets.rotate_secret,
)
class WidgetsWithStreamingResponse:
def __init__(self, widgets: Widgets) -> None:
self._widgets = widgets
self.create = to_streamed_response_wrapper(
widgets.create,
)
self.update = to_streamed_response_wrapper(
widgets.update,
)
self.list = to_streamed_response_wrapper(
widgets.list,
)
self.delete = to_streamed_response_wrapper(
widgets.delete,
)
self.get = to_streamed_response_wrapper(
widgets.get,
)
self.rotate_secret = to_streamed_response_wrapper(
widgets.rotate_secret,
)
class AsyncWidgetsWithStreamingResponse:
def __init__(self, widgets: AsyncWidgets) -> None:
self._widgets = widgets
self.create = async_to_streamed_response_wrapper(
widgets.create,
)
self.update = async_to_streamed_response_wrapper(
widgets.update,
)
self.list = async_to_streamed_response_wrapper(
widgets.list,
)
self.delete = async_to_streamed_response_wrapper(
widgets.delete,
)
self.get = async_to_streamed_response_wrapper(
widgets.get,
)
self.rotate_secret = async_to_streamed_response_wrapper(
widgets.rotate_secret,
)

View file

@ -2,12 +2,12 @@
from __future__ import annotations
from .aaa_history import AaaHistory as AaaHistory
from .aaa_policies import AaaPolicies as AaaPolicies
from .history_list_params import HistoryListParams as HistoryListParams
from .policy_get_response import PolicyGetResponse as PolicyGetResponse
from .policy_create_params import PolicyCreateParams as PolicyCreateParams
from .policy_list_response import PolicyListResponse as PolicyListResponse
from .policy_update_params import PolicyUpdateParams as PolicyUpdateParams
from .history_list_response import HistoryListResponse as HistoryListResponse
from .policy_create_response import PolicyCreateResponse as PolicyCreateResponse
from .policy_delete_response import PolicyDeleteResponse as PolicyDeleteResponse
from .policy_update_response import PolicyUpdateResponse as PolicyUpdateResponse

View file

@ -6,10 +6,10 @@ from typing_extensions import Literal
from ...._models import BaseModel
__all__ = ["HistoryListResponse"]
__all__ = ["AaaHistory"]
class HistoryListResponse(BaseModel):
class AaaHistory(BaseModel):
id: Optional[str] = None
"""UUID"""

View file

@ -6,7 +6,7 @@ from typing_extensions import Literal
from ...._models import BaseModel
__all__ = ["PolicyGetResponse", "Filters", "Mechanisms"]
__all__ = ["AaaPolicies", "Filters", "Mechanisms"]
class Filters(BaseModel):
@ -145,7 +145,7 @@ class Mechanisms(BaseModel):
"""UUID"""
class PolicyGetResponse(BaseModel):
class AaaPolicies(BaseModel):
id: Optional[str] = None
"""The unique identifier of a notification policy"""

View file

@ -2,7 +2,8 @@
from __future__ import annotations
from .webhook_get_response import WebhookGetResponse as WebhookGetResponse
from .aaa_webhooks import AaaWebhooks as AaaWebhooks
from .aaa_pagerduty import AaaPagerduty as AaaPagerduty
from .eligible_get_response import EligibleGetResponse as EligibleGetResponse
from .webhook_create_params import WebhookCreateParams as WebhookCreateParams
from .webhook_list_response import WebhookListResponse as WebhookListResponse

View file

@ -0,0 +1,15 @@
# File generated from our OpenAPI spec by Stainless.
from typing import Optional
from ....._models import BaseModel
__all__ = ["AaaPagerduty"]
class AaaPagerduty(BaseModel):
id: Optional[str] = None
"""UUID"""
name: Optional[str] = None
"""The name of the pagerduty service."""

View file

@ -6,10 +6,10 @@ from typing_extensions import Literal
from ....._models import BaseModel
__all__ = ["WebhookGetResponse"]
__all__ = ["AaaWebhooks"]
class WebhookGetResponse(BaseModel):
class AaaWebhooks(BaseModel):
id: Optional[str] = None
"""The unique identifier of a webhook"""

View file

@ -1,18 +1,9 @@
# File generated from our OpenAPI spec by Stainless.
from typing import List, Optional
from typing import List
from ....._models import BaseModel
from .aaa_pagerduty import AaaPagerduty
__all__ = ["PagerdutyGetResponse", "PagerdutyGetResponseItem"]
__all__ = ["PagerdutyGetResponse"]
class PagerdutyGetResponseItem(BaseModel):
id: Optional[str] = None
"""UUID"""
name: Optional[str] = None
"""The name of the pagerduty service."""
PagerdutyGetResponse = List[PagerdutyGetResponseItem]
PagerdutyGetResponse = List[AaaPagerduty]

View file

@ -1,52 +1,9 @@
# File generated from our OpenAPI spec by Stainless.
from typing import List, Optional
from datetime import datetime
from typing_extensions import Literal
from typing import List
from ....._models import BaseModel
from .aaa_webhooks import AaaWebhooks
__all__ = ["WebhookListResponse", "WebhookListResponseItem"]
__all__ = ["WebhookListResponse"]
class WebhookListResponseItem(BaseModel):
id: Optional[str] = None
"""The unique identifier of a webhook"""
created_at: Optional[datetime] = None
"""Timestamp of when the webhook destination was created."""
last_failure: Optional[datetime] = None
"""
Timestamp of the last time an attempt to dispatch a notification to this webhook
failed.
"""
last_success: Optional[datetime] = None
"""
Timestamp of the last time Cloudflare was able to successfully dispatch a
notification using this webhook.
"""
name: Optional[str] = None
"""The name of the webhook destination.
This will be included in the request body when you receive a webhook
notification.
"""
secret: Optional[str] = None
"""
Optional secret that will be passed in the `cf-webhook-auth` header when
dispatching generic webhook notifications or formatted for supported
destinations. Secrets are not returned in any API response body.
"""
type: Optional[Literal["slack", "generic", "gchat"]] = None
"""Type of webhook endpoint."""
url: Optional[str] = None
"""The POST endpoint to call when dispatching a notification."""
WebhookListResponse = List[WebhookListResponseItem]
WebhookListResponse = List[AaaWebhooks]

View file

@ -1,249 +1,9 @@
# File generated from our OpenAPI spec by Stainless.
from typing import Dict, List, Union, Optional
from datetime import datetime
from typing_extensions import Literal
from typing import List
from ...._models import BaseModel
from .aaa_policies import AaaPolicies
__all__ = [
"PolicyListResponse",
"PolicyListResponseItem",
"PolicyListResponseItemFilters",
"PolicyListResponseItemMechanisms",
]
__all__ = ["PolicyListResponse"]
class PolicyListResponseItemFilters(BaseModel):
actions: Optional[List[str]] = None
"""Usage depends on specific alert type"""
affected_asns: Optional[List[str]] = None
"""Used for configuring radar_notification"""
affected_components: Optional[List[str]] = None
"""Used for configuring incident_alert.
A list of identifiers for each component to monitor.
"""
affected_locations: Optional[List[str]] = None
"""Used for configuring radar_notification"""
airport_code: Optional[List[str]] = None
"""Used for configuring maintenance_event_notification"""
alert_trigger_preferences: Optional[List[str]] = None
"""Usage depends on specific alert type"""
alert_trigger_preferences_value: Optional[List[Literal["99.0", "98.0", "97.0"]]] = None
"""Used for configuring magic_tunnel_health_check_event"""
enabled: Optional[List[str]] = None
"""Used for configuring load_balancing_pool_enablement_alert"""
environment: Optional[List[str]] = None
"""Used for configuring pages_event_alert"""
event: Optional[List[str]] = None
"""Used for configuring pages_event_alert"""
event_source: Optional[List[str]] = None
"""Used for configuring load_balancing_health_alert"""
event_type: Optional[List[str]] = None
"""Usage depends on specific alert type"""
group_by: Optional[List[str]] = None
"""Usage depends on specific alert type"""
health_check_id: Optional[List[str]] = None
"""Used for configuring health_check_status_notification"""
incident_impact: Optional[
List[
Literal[
"INCIDENT_IMPACT_NONE", "INCIDENT_IMPACT_MINOR", "INCIDENT_IMPACT_MAJOR", "INCIDENT_IMPACT_CRITICAL"
]
]
] = None
"""Used for configuring incident_alert"""
input_id: Optional[List[str]] = None
"""Used for configuring stream_live_notifications"""
limit: Optional[List[str]] = None
"""Used for configuring billing_usage_alert"""
logo_tag: Optional[List[str]] = None
"""Used for configuring logo_match_alert"""
megabits_per_second: Optional[List[str]] = None
"""Used for configuring advanced_ddos_attack_l4_alert"""
new_health: Optional[List[str]] = None
"""Used for configuring load_balancing_health_alert"""
new_status: Optional[List[str]] = None
"""Used for configuring tunnel_health_event"""
packets_per_second: Optional[List[str]] = None
"""Used for configuring advanced_ddos_attack_l4_alert"""
pool_id: Optional[List[str]] = None
"""Usage depends on specific alert type"""
product: Optional[List[str]] = None
"""Used for configuring billing_usage_alert"""
project_id: Optional[List[str]] = None
"""Used for configuring pages_event_alert"""
protocol: Optional[List[str]] = None
"""Used for configuring advanced_ddos_attack_l4_alert"""
query_tag: Optional[List[str]] = None
"""Usage depends on specific alert type"""
requests_per_second: Optional[List[str]] = None
"""Used for configuring advanced_ddos_attack_l7_alert"""
selectors: Optional[List[str]] = None
"""Usage depends on specific alert type"""
services: Optional[List[str]] = None
"""Used for configuring clickhouse_alert_fw_ent_anomaly"""
slo: Optional[List[str]] = None
"""Usage depends on specific alert type"""
status: Optional[List[str]] = None
"""Used for configuring health_check_status_notification"""
target_hostname: Optional[List[str]] = None
"""Used for configuring advanced_ddos_attack_l7_alert"""
target_ip: Optional[List[str]] = None
"""Used for configuring advanced_ddos_attack_l4_alert"""
target_zone_name: Optional[List[str]] = None
"""Used for configuring advanced_ddos_attack_l7_alert"""
traffic_exclusions: Optional[List[Literal["security_events"]]] = None
"""Used for configuring traffic_anomalies_alert"""
tunnel_id: Optional[List[str]] = None
"""Used for configuring tunnel_health_event"""
tunnel_name: Optional[List[str]] = None
"""Used for configuring magic_tunnel_health_check_event"""
where: Optional[List[str]] = None
"""Usage depends on specific alert type"""
zones: Optional[List[str]] = None
"""Usage depends on specific alert type"""
class PolicyListResponseItemMechanisms(BaseModel):
id: Union[str, str, None] = None
"""UUID"""
class PolicyListResponseItem(BaseModel):
id: Optional[str] = None
"""The unique identifier of a notification policy"""
alert_type: Optional[
Literal[
"access_custom_certificate_expiration_type",
"advanced_ddos_attack_l4_alert",
"advanced_ddos_attack_l7_alert",
"advanced_http_alert_error",
"bgp_hijack_notification",
"billing_usage_alert",
"block_notification_block_removed",
"block_notification_new_block",
"block_notification_review_rejected",
"brand_protection_alert",
"brand_protection_digest",
"clickhouse_alert_fw_anomaly",
"clickhouse_alert_fw_ent_anomaly",
"custom_ssl_certificate_event_type",
"dedicated_ssl_certificate_event_type",
"dos_attack_l4",
"dos_attack_l7",
"expiring_service_token_alert",
"failing_logpush_job_disabled_alert",
"fbm_auto_advertisement",
"fbm_dosd_attack",
"fbm_volumetric_attack",
"health_check_status_notification",
"hostname_aop_custom_certificate_expiration_type",
"http_alert_edge_error",
"http_alert_origin_error",
"incident_alert",
"load_balancing_health_alert",
"load_balancing_pool_enablement_alert",
"logo_match_alert",
"magic_tunnel_health_check_event",
"maintenance_event_notification",
"mtls_certificate_store_certificate_expiration_type",
"pages_event_alert",
"radar_notification",
"real_origin_monitoring",
"scriptmonitor_alert_new_code_change_detections",
"scriptmonitor_alert_new_hosts",
"scriptmonitor_alert_new_malicious_hosts",
"scriptmonitor_alert_new_malicious_scripts",
"scriptmonitor_alert_new_malicious_url",
"scriptmonitor_alert_new_max_length_resource_url",
"scriptmonitor_alert_new_resources",
"secondary_dns_all_primaries_failing",
"secondary_dns_primaries_failing",
"secondary_dns_zone_successfully_updated",
"secondary_dns_zone_validation_warning",
"sentinel_alert",
"stream_live_notifications",
"traffic_anomalies_alert",
"tunnel_health_event",
"tunnel_update_event",
"universal_ssl_event_type",
"web_analytics_metrics_update",
"zone_aop_custom_certificate_expiration_type",
]
] = None
"""Refers to which event will trigger a Notification dispatch.
You can use the endpoint to get available alert types which then will give you a
list of possible values.
"""
created: Optional[datetime] = None
description: Optional[str] = None
"""Optional description for the Notification policy."""
enabled: Optional[bool] = None
"""Whether or not the Notification policy is enabled."""
filters: Optional[PolicyListResponseItemFilters] = None
"""
Optional filters that allow you to be alerted only on a subset of events for
that alert type based on some criteria. This is only available for select alert
types. See alert type documentation for more details.
"""
mechanisms: Optional[Dict[str, List[PolicyListResponseItemMechanisms]]] = None
"""List of IDs that will be used when dispatching a notification.
IDs for email type will be the email address.
"""
modified: Optional[datetime] = None
name: Optional[str] = None
"""Name of the policy."""
PolicyListResponse = List[PolicyListResponseItem]
PolicyListResponse = List[AaaPolicies]

View file

@ -1,3 +1,10 @@
# File generated from our OpenAPI spec by Stainless.
from __future__ import annotations
from .widget_list_params import WidgetListParams as WidgetListParams
from .widget_create_params import WidgetCreateParams as WidgetCreateParams
from .widget_update_params import WidgetUpdateParams as WidgetUpdateParams
from .widget_rotate_secret_params import WidgetRotateSecretParams as WidgetRotateSecretParams
from .nc_challenges_admin_widget_list import NcChallengesAdminWidgetList as NcChallengesAdminWidgetList
from .nc_challenges_admin_widget_detail import NcChallengesAdminWidgetDetail as NcChallengesAdminWidgetDetail

View file

@ -0,0 +1,53 @@
# File generated from our OpenAPI spec by Stainless.
from typing import List
from datetime import datetime
from typing_extensions import Literal
from ..._models import BaseModel
__all__ = ["NcChallengesAdminWidgetDetail"]
class NcChallengesAdminWidgetDetail(BaseModel):
bot_fight_mode: bool
"""
If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive
challenges in response to malicious bots (ENT only).
"""
clearance_level: Literal["no_clearance", "jschallenge", "managed", "interactive"]
"""
If Turnstile is embedded on a Cloudflare site and the widget should grant
challenge clearance, this setting can determine the clearance level to be set
"""
created_on: datetime
"""When the widget was created."""
domains: List[str]
mode: Literal["non-interactive", "invisible", "managed"]
"""Widget Mode"""
modified_on: datetime
"""When the widget was modified."""
name: str
"""Human readable widget name.
Not unique. Cloudflare suggests that you set this to a meaningful string to make
it easier to identify your widget, and where it is used.
"""
offlabel: bool
"""Do not show any Cloudflare branding on the widget (ENT only)."""
region: Literal["world"]
"""Region where this widget can be used."""
secret: str
"""Secret key for this widget."""
sitekey: str
"""Widget item identifier tag."""

View file

@ -0,0 +1,50 @@
# File generated from our OpenAPI spec by Stainless.
from typing import List
from datetime import datetime
from typing_extensions import Literal
from ..._models import BaseModel
__all__ = ["NcChallengesAdminWidgetList"]
class NcChallengesAdminWidgetList(BaseModel):
bot_fight_mode: bool
"""
If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive
challenges in response to malicious bots (ENT only).
"""
clearance_level: Literal["no_clearance", "jschallenge", "managed", "interactive"]
"""
If Turnstile is embedded on a Cloudflare site and the widget should grant
challenge clearance, this setting can determine the clearance level to be set
"""
created_on: datetime
"""When the widget was created."""
domains: List[str]
mode: Literal["non-interactive", "invisible", "managed"]
"""Widget Mode"""
modified_on: datetime
"""When the widget was modified."""
name: str
"""Human readable widget name.
Not unique. Cloudflare suggests that you set this to a meaningful string to make
it easier to identify your widget, and where it is used.
"""
offlabel: bool
"""Do not show any Cloudflare branding on the widget (ENT only)."""
region: Literal["world"]
"""Region where this widget can be used."""
sitekey: str
"""Widget item identifier tag."""

View file

@ -0,0 +1,55 @@
# File generated from our OpenAPI spec by Stainless.
from __future__ import annotations
from typing import List
from typing_extensions import Literal, Required, TypedDict
__all__ = ["WidgetCreateParams"]
class WidgetCreateParams(TypedDict, total=False):
account_id: Required[str]
"""Identifier"""
domains: Required[List[str]]
mode: Required[Literal["non-interactive", "invisible", "managed"]]
"""Widget Mode"""
name: Required[str]
"""Human readable widget name.
Not unique. Cloudflare suggests that you set this to a meaningful string to make
it easier to identify your widget, and where it is used.
"""
direction: Literal["asc", "desc"]
"""Direction to order widgets."""
order: Literal["id", "sitekey", "name", "created_on", "modified_on"]
"""Field to order widgets by."""
page: float
"""Page number of paginated results."""
per_page: float
"""Number of items per page."""
bot_fight_mode: bool
"""
If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive
challenges in response to malicious bots (ENT only).
"""
clearance_level: Literal["no_clearance", "jschallenge", "managed", "interactive"]
"""
If Turnstile is embedded on a Cloudflare site and the widget should grant
challenge clearance, this setting can determine the clearance level to be set
"""
offlabel: bool
"""Do not show any Cloudflare branding on the widget (ENT only)."""
region: Literal["world"]
"""Region where this widget can be used."""

View file

@ -0,0 +1,24 @@
# File generated from our OpenAPI spec by Stainless.
from __future__ import annotations
from typing_extensions import Literal, Required, TypedDict
__all__ = ["WidgetListParams"]
class WidgetListParams(TypedDict, total=False):
account_id: Required[str]
"""Identifier"""
direction: Literal["asc", "desc"]
"""Direction to order widgets."""
order: Literal["id", "sitekey", "name", "created_on", "modified_on"]
"""Field to order widgets by."""
page: float
"""Page number of paginated results."""
per_page: float
"""Number of items per page."""

View file

@ -0,0 +1,19 @@
# File generated from our OpenAPI spec by Stainless.
from __future__ import annotations
from typing_extensions import Required, TypedDict
__all__ = ["WidgetRotateSecretParams"]
class WidgetRotateSecretParams(TypedDict, total=False):
account_id: Required[str]
"""Identifier"""
invalidate_immediately: bool
"""
If `invalidate_immediately` is set to `false`, the previous secret will remain
valid for two hours. Otherwise, the secret is immediately invalidated, and
requests using it will be rejected.
"""

View file

@ -0,0 +1,40 @@
# File generated from our OpenAPI spec by Stainless.
from __future__ import annotations
from typing import List
from typing_extensions import Literal, Required, TypedDict
__all__ = ["WidgetUpdateParams"]
class WidgetUpdateParams(TypedDict, total=False):
account_id: Required[str]
"""Identifier"""
domains: Required[List[str]]
mode: Required[Literal["non-interactive", "invisible", "managed"]]
"""Widget Mode"""
name: Required[str]
"""Human readable widget name.
Not unique. Cloudflare suggests that you set this to a meaningful string to make
it easier to identify your widget, and where it is used.
"""
bot_fight_mode: bool
"""
If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive
challenges in response to malicious bots (ENT only).
"""
clearance_level: Literal["no_clearance", "jschallenge", "managed", "interactive"]
"""
If Turnstile is embedded on a Cloudflare site and the widget should grant
challenge clearance, this setting can determine the clearance level to be set
"""
offlabel: bool
"""Do not show any Cloudflare branding on the widget (ENT only)."""

View file

@ -10,7 +10,7 @@ import pytest
from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare.types.alerting.v3.destinations import (
WebhookGetResponse,
AaaWebhooks,
WebhookListResponse,
WebhookCreateResponse,
WebhookDeleteResponse,
@ -259,7 +259,7 @@ class TestWebhooks:
"b115d5ec-15c6-41ee-8b76-92c449b5227b",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(WebhookGetResponse, webhook, path=["response"])
assert_matches_type(AaaWebhooks, webhook, path=["response"])
@pytest.mark.skip()
@parametrize
@ -272,7 +272,7 @@ class TestWebhooks:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
webhook = response.parse()
assert_matches_type(WebhookGetResponse, webhook, path=["response"])
assert_matches_type(AaaWebhooks, webhook, path=["response"])
@pytest.mark.skip()
@parametrize
@ -285,7 +285,7 @@ class TestWebhooks:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
webhook = response.parse()
assert_matches_type(WebhookGetResponse, webhook, path=["response"])
assert_matches_type(AaaWebhooks, webhook, path=["response"])
assert cast(Any, response.is_closed) is True
@ -544,7 +544,7 @@ class TestAsyncWebhooks:
"b115d5ec-15c6-41ee-8b76-92c449b5227b",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(WebhookGetResponse, webhook, path=["response"])
assert_matches_type(AaaWebhooks, webhook, path=["response"])
@pytest.mark.skip()
@parametrize
@ -557,7 +557,7 @@ class TestAsyncWebhooks:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
webhook = await response.parse()
assert_matches_type(WebhookGetResponse, webhook, path=["response"])
assert_matches_type(AaaWebhooks, webhook, path=["response"])
@pytest.mark.skip()
@parametrize
@ -570,7 +570,7 @@ class TestAsyncWebhooks:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
webhook = await response.parse()
assert_matches_type(WebhookGetResponse, webhook, path=["response"])
assert_matches_type(AaaWebhooks, webhook, path=["response"])
assert cast(Any, response.is_closed) is True

View file

@ -11,7 +11,7 @@ from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare._utils import parse_datetime
from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
from cloudflare.types.alerting.v3 import HistoryListResponse
from cloudflare.types.alerting.v3 import AaaHistory
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
@ -25,7 +25,7 @@ class TestHistories:
history = client.alerting.v3.histories.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(SyncV4PagePaginationArray[HistoryListResponse], history, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[AaaHistory], history, path=["response"])
@pytest.mark.skip()
@parametrize
@ -37,7 +37,7 @@ class TestHistories:
per_page=5,
since=parse_datetime("2022-05-19T20:29:58.679897Z"),
)
assert_matches_type(SyncV4PagePaginationArray[HistoryListResponse], history, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[AaaHistory], history, path=["response"])
@pytest.mark.skip()
@parametrize
@ -49,7 +49,7 @@ class TestHistories:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
history = response.parse()
assert_matches_type(SyncV4PagePaginationArray[HistoryListResponse], history, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[AaaHistory], history, path=["response"])
@pytest.mark.skip()
@parametrize
@ -61,7 +61,7 @@ class TestHistories:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
history = response.parse()
assert_matches_type(SyncV4PagePaginationArray[HistoryListResponse], history, path=["response"])
assert_matches_type(SyncV4PagePaginationArray[AaaHistory], history, path=["response"])
assert cast(Any, response.is_closed) is True
@ -83,7 +83,7 @@ class TestAsyncHistories:
history = await async_client.alerting.v3.histories.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(AsyncV4PagePaginationArray[HistoryListResponse], history, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[AaaHistory], history, path=["response"])
@pytest.mark.skip()
@parametrize
@ -95,7 +95,7 @@ class TestAsyncHistories:
per_page=5,
since=parse_datetime("2022-05-19T20:29:58.679897Z"),
)
assert_matches_type(AsyncV4PagePaginationArray[HistoryListResponse], history, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[AaaHistory], history, path=["response"])
@pytest.mark.skip()
@parametrize
@ -107,7 +107,7 @@ class TestAsyncHistories:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
history = await response.parse()
assert_matches_type(AsyncV4PagePaginationArray[HistoryListResponse], history, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[AaaHistory], history, path=["response"])
@pytest.mark.skip()
@parametrize
@ -119,7 +119,7 @@ class TestAsyncHistories:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
history = await response.parse()
assert_matches_type(AsyncV4PagePaginationArray[HistoryListResponse], history, path=["response"])
assert_matches_type(AsyncV4PagePaginationArray[AaaHistory], history, path=["response"])
assert cast(Any, response.is_closed) is True

View file

@ -10,7 +10,7 @@ import pytest
from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare.types.alerting.v3 import (
PolicyGetResponse,
AaaPolicies,
PolicyListResponse,
PolicyCreateResponse,
PolicyDeleteResponse,
@ -369,7 +369,7 @@ class TestPolicies:
"0da2b59e-f118-439d-8097-bdfb215203c9",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(PolicyGetResponse, policy, path=["response"])
assert_matches_type(AaaPolicies, policy, path=["response"])
@pytest.mark.skip()
@parametrize
@ -382,7 +382,7 @@ class TestPolicies:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
policy = response.parse()
assert_matches_type(PolicyGetResponse, policy, path=["response"])
assert_matches_type(AaaPolicies, policy, path=["response"])
@pytest.mark.skip()
@parametrize
@ -395,7 +395,7 @@ class TestPolicies:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
policy = response.parse()
assert_matches_type(PolicyGetResponse, policy, path=["response"])
assert_matches_type(AaaPolicies, policy, path=["response"])
assert cast(Any, response.is_closed) is True
@ -764,7 +764,7 @@ class TestAsyncPolicies:
"0da2b59e-f118-439d-8097-bdfb215203c9",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(PolicyGetResponse, policy, path=["response"])
assert_matches_type(AaaPolicies, policy, path=["response"])
@pytest.mark.skip()
@parametrize
@ -777,7 +777,7 @@ class TestAsyncPolicies:
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
policy = await response.parse()
assert_matches_type(PolicyGetResponse, policy, path=["response"])
assert_matches_type(AaaPolicies, policy, path=["response"])
@pytest.mark.skip()
@parametrize
@ -790,7 +790,7 @@ class TestAsyncPolicies:
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
policy = await response.parse()
assert_matches_type(PolicyGetResponse, policy, path=["response"])
assert_matches_type(AaaPolicies, policy, path=["response"])
assert cast(Any, response.is_closed) is True

View file

@ -0,0 +1,776 @@
# File generated from our OpenAPI spec by Stainless.
from __future__ import annotations
import os
from typing import Any, Optional, cast
import pytest
from cloudflare import Cloudflare, AsyncCloudflare
from tests.utils import assert_matches_type
from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
from cloudflare.types.challenges import (
NcChallengesAdminWidgetList,
NcChallengesAdminWidgetDetail,
)
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
class TestWidgets:
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
@pytest.mark.skip()
@parametrize
def test_method_create(self, client: Cloudflare) -> None:
widget = client.challenges.widgets.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
)
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
def test_method_create_with_all_params(self, client: Cloudflare) -> None:
widget = client.challenges.widgets.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
direction="asc",
order="id",
page=1,
per_page=5,
bot_fight_mode=False,
clearance_level="interactive",
offlabel=False,
region="world",
)
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
def test_raw_response_create(self, client: Cloudflare) -> None:
response = client.challenges.widgets.with_raw_response.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
def test_streaming_response_create(self, client: Cloudflare) -> None:
with client.challenges.widgets.with_streaming_response.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
assert cast(Any, response.is_closed) is True
@pytest.mark.skip()
@parametrize
def test_path_params_create(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
client.challenges.widgets.with_raw_response.create(
account_id="",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
)
@pytest.mark.skip()
@parametrize
def test_method_update(self, client: Cloudflare) -> None:
widget = client.challenges.widgets.update(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
)
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
def test_method_update_with_all_params(self, client: Cloudflare) -> None:
widget = client.challenges.widgets.update(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
bot_fight_mode=False,
clearance_level="interactive",
offlabel=False,
)
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
def test_raw_response_update(self, client: Cloudflare) -> None:
response = client.challenges.widgets.with_raw_response.update(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
def test_streaming_response_update(self, client: Cloudflare) -> None:
with client.challenges.widgets.with_streaming_response.update(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
assert cast(Any, response.is_closed) is True
@pytest.mark.skip()
@parametrize
def test_path_params_update(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
client.challenges.widgets.with_raw_response.update(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `sitekey` but received ''"):
client.challenges.widgets.with_raw_response.update(
"",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
)
@pytest.mark.skip()
@parametrize
def test_method_list(self, client: Cloudflare) -> None:
widget = client.challenges.widgets.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(SyncV4PagePaginationArray[NcChallengesAdminWidgetList], widget, path=["response"])
@pytest.mark.skip()
@parametrize
def test_method_list_with_all_params(self, client: Cloudflare) -> None:
widget = client.challenges.widgets.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
direction="asc",
order="id",
page=1,
per_page=5,
)
assert_matches_type(SyncV4PagePaginationArray[NcChallengesAdminWidgetList], widget, path=["response"])
@pytest.mark.skip()
@parametrize
def test_raw_response_list(self, client: Cloudflare) -> None:
response = client.challenges.widgets.with_raw_response.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = response.parse()
assert_matches_type(SyncV4PagePaginationArray[NcChallengesAdminWidgetList], widget, path=["response"])
@pytest.mark.skip()
@parametrize
def test_streaming_response_list(self, client: Cloudflare) -> None:
with client.challenges.widgets.with_streaming_response.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = response.parse()
assert_matches_type(SyncV4PagePaginationArray[NcChallengesAdminWidgetList], widget, path=["response"])
assert cast(Any, response.is_closed) is True
@pytest.mark.skip()
@parametrize
def test_path_params_list(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
client.challenges.widgets.with_raw_response.list(
account_id="",
)
@pytest.mark.skip()
@parametrize
def test_method_delete(self, client: Cloudflare) -> None:
widget = client.challenges.widgets.delete(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
def test_raw_response_delete(self, client: Cloudflare) -> None:
response = client.challenges.widgets.with_raw_response.delete(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
def test_streaming_response_delete(self, client: Cloudflare) -> None:
with client.challenges.widgets.with_streaming_response.delete(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
assert cast(Any, response.is_closed) is True
@pytest.mark.skip()
@parametrize
def test_path_params_delete(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
client.challenges.widgets.with_raw_response.delete(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `sitekey` but received ''"):
client.challenges.widgets.with_raw_response.delete(
"",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@pytest.mark.skip()
@parametrize
def test_method_get(self, client: Cloudflare) -> None:
widget = client.challenges.widgets.get(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
def test_raw_response_get(self, client: Cloudflare) -> None:
response = client.challenges.widgets.with_raw_response.get(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
def test_streaming_response_get(self, client: Cloudflare) -> None:
with client.challenges.widgets.with_streaming_response.get(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
assert cast(Any, response.is_closed) is True
@pytest.mark.skip()
@parametrize
def test_path_params_get(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
client.challenges.widgets.with_raw_response.get(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `sitekey` but received ''"):
client.challenges.widgets.with_raw_response.get(
"",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@pytest.mark.skip()
@parametrize
def test_method_rotate_secret(self, client: Cloudflare) -> None:
widget = client.challenges.widgets.rotate_secret(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
def test_method_rotate_secret_with_all_params(self, client: Cloudflare) -> None:
widget = client.challenges.widgets.rotate_secret(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
invalidate_immediately=True,
)
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
def test_raw_response_rotate_secret(self, client: Cloudflare) -> None:
response = client.challenges.widgets.with_raw_response.rotate_secret(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
def test_streaming_response_rotate_secret(self, client: Cloudflare) -> None:
with client.challenges.widgets.with_streaming_response.rotate_secret(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
assert cast(Any, response.is_closed) is True
@pytest.mark.skip()
@parametrize
def test_path_params_rotate_secret(self, client: Cloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
client.challenges.widgets.with_raw_response.rotate_secret(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `sitekey` but received ''"):
client.challenges.widgets.with_raw_response.rotate_secret(
"",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
class TestAsyncWidgets:
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
@pytest.mark.skip()
@parametrize
async def test_method_create(self, async_client: AsyncCloudflare) -> None:
widget = await async_client.challenges.widgets.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
)
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None:
widget = await async_client.challenges.widgets.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
direction="asc",
order="id",
page=1,
per_page=5,
bot_fight_mode=False,
clearance_level="interactive",
offlabel=False,
region="world",
)
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
response = await async_client.challenges.widgets.with_raw_response.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = await response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
async with async_client.challenges.widgets.with_streaming_response.create(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = await response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
assert cast(Any, response.is_closed) is True
@pytest.mark.skip()
@parametrize
async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
await async_client.challenges.widgets.with_raw_response.create(
account_id="",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
)
@pytest.mark.skip()
@parametrize
async def test_method_update(self, async_client: AsyncCloudflare) -> None:
widget = await async_client.challenges.widgets.update(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
)
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None:
widget = await async_client.challenges.widgets.update(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
bot_fight_mode=False,
clearance_level="interactive",
offlabel=False,
)
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
response = await async_client.challenges.widgets.with_raw_response.update(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = await response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None:
async with async_client.challenges.widgets.with_streaming_response.update(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = await response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
assert cast(Any, response.is_closed) is True
@pytest.mark.skip()
@parametrize
async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
await async_client.challenges.widgets.with_raw_response.update(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `sitekey` but received ''"):
await async_client.challenges.widgets.with_raw_response.update(
"",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
mode="invisible",
name="blog.cloudflare.com login form",
)
@pytest.mark.skip()
@parametrize
async def test_method_list(self, async_client: AsyncCloudflare) -> None:
widget = await async_client.challenges.widgets.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(AsyncV4PagePaginationArray[NcChallengesAdminWidgetList], widget, path=["response"])
@pytest.mark.skip()
@parametrize
async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None:
widget = await async_client.challenges.widgets.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
direction="asc",
order="id",
page=1,
per_page=5,
)
assert_matches_type(AsyncV4PagePaginationArray[NcChallengesAdminWidgetList], widget, path=["response"])
@pytest.mark.skip()
@parametrize
async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
response = await async_client.challenges.widgets.with_raw_response.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = await response.parse()
assert_matches_type(AsyncV4PagePaginationArray[NcChallengesAdminWidgetList], widget, path=["response"])
@pytest.mark.skip()
@parametrize
async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
async with async_client.challenges.widgets.with_streaming_response.list(
account_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = await response.parse()
assert_matches_type(AsyncV4PagePaginationArray[NcChallengesAdminWidgetList], widget, path=["response"])
assert cast(Any, response.is_closed) is True
@pytest.mark.skip()
@parametrize
async def test_path_params_list(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
await async_client.challenges.widgets.with_raw_response.list(
account_id="",
)
@pytest.mark.skip()
@parametrize
async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
widget = await async_client.challenges.widgets.delete(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
response = await async_client.challenges.widgets.with_raw_response.delete(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = await response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None:
async with async_client.challenges.widgets.with_streaming_response.delete(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = await response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
assert cast(Any, response.is_closed) is True
@pytest.mark.skip()
@parametrize
async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
await async_client.challenges.widgets.with_raw_response.delete(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `sitekey` but received ''"):
await async_client.challenges.widgets.with_raw_response.delete(
"",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@pytest.mark.skip()
@parametrize
async def test_method_get(self, async_client: AsyncCloudflare) -> None:
widget = await async_client.challenges.widgets.get(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
response = await async_client.challenges.widgets.with_raw_response.get(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = await response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
async with async_client.challenges.widgets.with_streaming_response.get(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = await response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
assert cast(Any, response.is_closed) is True
@pytest.mark.skip()
@parametrize
async def test_path_params_get(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
await async_client.challenges.widgets.with_raw_response.get(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `sitekey` but received ''"):
await async_client.challenges.widgets.with_raw_response.get(
"",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
@pytest.mark.skip()
@parametrize
async def test_method_rotate_secret(self, async_client: AsyncCloudflare) -> None:
widget = await async_client.challenges.widgets.rotate_secret(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
async def test_method_rotate_secret_with_all_params(self, async_client: AsyncCloudflare) -> None:
widget = await async_client.challenges.widgets.rotate_secret(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
invalidate_immediately=True,
)
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
async def test_raw_response_rotate_secret(self, async_client: AsyncCloudflare) -> None:
response = await async_client.challenges.widgets.with_raw_response.rotate_secret(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = await response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
@pytest.mark.skip()
@parametrize
async def test_streaming_response_rotate_secret(self, async_client: AsyncCloudflare) -> None:
async with async_client.challenges.widgets.with_streaming_response.rotate_secret(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
widget = await response.parse()
assert_matches_type(Optional[NcChallengesAdminWidgetDetail], widget, path=["response"])
assert cast(Any, response.is_closed) is True
@pytest.mark.skip()
@parametrize
async def test_path_params_rotate_secret(self, async_client: AsyncCloudflare) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
await async_client.challenges.widgets.with_raw_response.rotate_secret(
"0x4AAF00AAAABn0R22HWm-YUc",
account_id="",
)
with pytest.raises(ValueError, match=r"Expected a non-empty value for `sitekey` but received ''"):
await async_client.challenges.widgets.with_raw_response.rotate_secret(
"",
account_id="023e105f4ecef8ad9ca31a8372d0c353",
)