mirror of
https://github.com/cloudflare/cloudflare-python.git
synced 2026-01-16 23:01:03 +00:00
feat: OpenAPI spec update via Stainless API (#121)
This commit is contained in:
parent
9b343e897c
commit
cae2868592
15 changed files with 1 additions and 2075 deletions
|
|
@ -1 +1 @@
|
|||
configured_endpoints: 1288
|
||||
configured_endpoints: 1282
|
||||
|
|
|
|||
19
api.md
19
api.md
|
|
@ -5830,25 +5830,6 @@ 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_identifier}/challenges/widgets">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">create</a>(account_identifier, \*\*<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_identifier}/challenges/widgets/{sitekey}">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">update</a>(sitekey, \*, account_identifier, \*\*<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_identifier}/challenges/widgets">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">list</a>(account_identifier, \*\*<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_identifier}/challenges/widgets/{sitekey}">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">delete</a>(sitekey, \*, account_identifier) -> <a href="./src/cloudflare/types/challenges/nc_challenges_admin_widget_detail.py">Optional</a></code>
|
||||
- <code title="get /accounts/{account_identifier}/challenges/widgets/{sitekey}">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">get</a>(sitekey, \*, account_identifier) -> <a href="./src/cloudflare/types/challenges/nc_challenges_admin_widget_detail.py">Optional</a></code>
|
||||
- <code title="post /accounts/{account_identifier}/challenges/widgets/{sitekey}/rotate_secret">client.challenges.widgets.<a href="./src/cloudflare/resources/challenges/widgets.py">rotate_secret</a>(sitekey, \*, account_identifier, \*\*<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
|
||||
|
|
|
|||
|
|
@ -113,7 +113,6 @@ 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
|
||||
|
|
@ -266,7 +265,6 @@ 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)
|
||||
|
|
@ -524,7 +522,6 @@ 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
|
||||
|
|
@ -677,7 +674,6 @@ 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)
|
||||
|
|
@ -936,7 +932,6 @@ 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)
|
||||
|
|
@ -1026,7 +1021,6 @@ 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)
|
||||
|
|
@ -1116,7 +1110,6 @@ 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)
|
||||
|
|
@ -1212,7 +1205,6 @@ 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)
|
||||
|
|
|
|||
|
|
@ -336,14 +336,6 @@ from .audit_logs import (
|
|||
AuditLogsWithStreamingResponse,
|
||||
AsyncAuditLogsWithStreamingResponse,
|
||||
)
|
||||
from .challenges import (
|
||||
Challenges,
|
||||
AsyncChallenges,
|
||||
ChallengesWithRawResponse,
|
||||
AsyncChallengesWithRawResponse,
|
||||
ChallengesWithStreamingResponse,
|
||||
AsyncChallengesWithStreamingResponse,
|
||||
)
|
||||
from .hyperdrive import (
|
||||
Hyperdrive,
|
||||
AsyncHyperdrive,
|
||||
|
|
@ -1038,12 +1030,6 @@ __all__ = [
|
|||
"AsyncZeroTrustWithRawResponse",
|
||||
"ZeroTrustWithStreamingResponse",
|
||||
"AsyncZeroTrustWithStreamingResponse",
|
||||
"Challenges",
|
||||
"AsyncChallenges",
|
||||
"ChallengesWithRawResponse",
|
||||
"AsyncChallengesWithRawResponse",
|
||||
"ChallengesWithStreamingResponse",
|
||||
"AsyncChallengesWithStreamingResponse",
|
||||
"Hyperdrive",
|
||||
"AsyncHyperdrive",
|
||||
"HyperdriveWithRawResponse",
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
# 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",
|
||||
]
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
# 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)
|
||||
|
|
@ -1,902 +0,0 @@
|
|||
# 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_identifier: 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_identifier: 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_identifier:
|
||||
raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}")
|
||||
return self._post(
|
||||
f"/accounts/{account_identifier}/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_identifier: 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_identifier: 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_identifier:
|
||||
raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}")
|
||||
if not sitekey:
|
||||
raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}")
|
||||
return self._put(
|
||||
f"/accounts/{account_identifier}/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_identifier: 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_identifier: 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_identifier:
|
||||
raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}")
|
||||
return self._get_api_list(
|
||||
f"/accounts/{account_identifier}/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_identifier: 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_identifier: 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_identifier:
|
||||
raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}")
|
||||
if not sitekey:
|
||||
raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}")
|
||||
return self._delete(
|
||||
f"/accounts/{account_identifier}/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_identifier: 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_identifier: 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_identifier:
|
||||
raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}")
|
||||
if not sitekey:
|
||||
raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}")
|
||||
return self._get(
|
||||
f"/accounts/{account_identifier}/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_identifier: 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_identifier: 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_identifier:
|
||||
raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}")
|
||||
if not sitekey:
|
||||
raise ValueError(f"Expected a non-empty value for `sitekey` but received {sitekey!r}")
|
||||
return self._post(
|
||||
f"/accounts/{account_identifier}/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_identifier: 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_identifier: 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_identifier:
|
||||
raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}")
|
||||
return await self._post(
|
||||
f"/accounts/{account_identifier}/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_identifier: 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_identifier: 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_identifier:
|
||||
raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!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_identifier}/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_identifier: 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_identifier: 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_identifier:
|
||||
raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}")
|
||||
return self._get_api_list(
|
||||
f"/accounts/{account_identifier}/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_identifier: 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_identifier: 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_identifier:
|
||||
raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!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_identifier}/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_identifier: 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_identifier: 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_identifier:
|
||||
raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!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_identifier}/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_identifier: 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_identifier: 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_identifier:
|
||||
raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!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_identifier}/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,
|
||||
)
|
||||
|
|
@ -1,10 +1,3 @@
|
|||
# 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
|
||||
|
|
|
|||
|
|
@ -1,53 +0,0 @@
|
|||
# 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."""
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
# 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."""
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
# 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):
|
||||
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."""
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
# File generated from our OpenAPI spec by Stainless.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing_extensions import Literal, TypedDict
|
||||
|
||||
__all__ = ["WidgetListParams"]
|
||||
|
||||
|
||||
class WidgetListParams(TypedDict, total=False):
|
||||
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."""
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# 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_identifier: 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.
|
||||
"""
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
# 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_identifier: 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)."""
|
||||
|
|
@ -1,776 +0,0 @@
|
|||
# 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(
|
||||
"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(
|
||||
"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=True,
|
||||
clearance_level="interactive",
|
||||
offlabel=True,
|
||||
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(
|
||||
"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(
|
||||
"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_identifier` but received ''"):
|
||||
client.challenges.widgets.with_raw_response.create(
|
||||
"",
|
||||
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_identifier="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_identifier="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
|
||||
mode="invisible",
|
||||
name="blog.cloudflare.com login form",
|
||||
bot_fight_mode=True,
|
||||
clearance_level="interactive",
|
||||
offlabel=True,
|
||||
)
|
||||
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_identifier="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_identifier="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_identifier` but received ''"):
|
||||
client.challenges.widgets.with_raw_response.update(
|
||||
"0x4AAF00AAAABn0R22HWm-YUc",
|
||||
account_identifier="",
|
||||
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_identifier="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(
|
||||
"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(
|
||||
"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(
|
||||
"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(
|
||||
"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_identifier` but received ''"):
|
||||
client.challenges.widgets.with_raw_response.list(
|
||||
"",
|
||||
)
|
||||
|
||||
@pytest.mark.skip()
|
||||
@parametrize
|
||||
def test_method_delete(self, client: Cloudflare) -> None:
|
||||
widget = client.challenges.widgets.delete(
|
||||
"0x4AAF00AAAABn0R22HWm-YUc",
|
||||
account_identifier="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_identifier="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_identifier="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_identifier` but received ''"):
|
||||
client.challenges.widgets.with_raw_response.delete(
|
||||
"0x4AAF00AAAABn0R22HWm-YUc",
|
||||
account_identifier="",
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `sitekey` but received ''"):
|
||||
client.challenges.widgets.with_raw_response.delete(
|
||||
"",
|
||||
account_identifier="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
@pytest.mark.skip()
|
||||
@parametrize
|
||||
def test_method_get(self, client: Cloudflare) -> None:
|
||||
widget = client.challenges.widgets.get(
|
||||
"0x4AAF00AAAABn0R22HWm-YUc",
|
||||
account_identifier="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_identifier="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_identifier="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_identifier` but received ''"):
|
||||
client.challenges.widgets.with_raw_response.get(
|
||||
"0x4AAF00AAAABn0R22HWm-YUc",
|
||||
account_identifier="",
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `sitekey` but received ''"):
|
||||
client.challenges.widgets.with_raw_response.get(
|
||||
"",
|
||||
account_identifier="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
@pytest.mark.skip()
|
||||
@parametrize
|
||||
def test_method_rotate_secret(self, client: Cloudflare) -> None:
|
||||
widget = client.challenges.widgets.rotate_secret(
|
||||
"0x4AAF00AAAABn0R22HWm-YUc",
|
||||
account_identifier="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_identifier="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_identifier="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_identifier="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_identifier` but received ''"):
|
||||
client.challenges.widgets.with_raw_response.rotate_secret(
|
||||
"0x4AAF00AAAABn0R22HWm-YUc",
|
||||
account_identifier="",
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `sitekey` but received ''"):
|
||||
client.challenges.widgets.with_raw_response.rotate_secret(
|
||||
"",
|
||||
account_identifier="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(
|
||||
"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(
|
||||
"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=True,
|
||||
clearance_level="interactive",
|
||||
offlabel=True,
|
||||
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(
|
||||
"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(
|
||||
"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_identifier` but received ''"):
|
||||
await async_client.challenges.widgets.with_raw_response.create(
|
||||
"",
|
||||
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_identifier="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_identifier="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
domains=["203.0.113.1", "cloudflare.com", "blog.example.com"],
|
||||
mode="invisible",
|
||||
name="blog.cloudflare.com login form",
|
||||
bot_fight_mode=True,
|
||||
clearance_level="interactive",
|
||||
offlabel=True,
|
||||
)
|
||||
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_identifier="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_identifier="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_identifier` but received ''"):
|
||||
await async_client.challenges.widgets.with_raw_response.update(
|
||||
"0x4AAF00AAAABn0R22HWm-YUc",
|
||||
account_identifier="",
|
||||
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_identifier="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(
|
||||
"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(
|
||||
"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(
|
||||
"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(
|
||||
"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_identifier` but received ''"):
|
||||
await async_client.challenges.widgets.with_raw_response.list(
|
||||
"",
|
||||
)
|
||||
|
||||
@pytest.mark.skip()
|
||||
@parametrize
|
||||
async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
|
||||
widget = await async_client.challenges.widgets.delete(
|
||||
"0x4AAF00AAAABn0R22HWm-YUc",
|
||||
account_identifier="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_identifier="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_identifier="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_identifier` but received ''"):
|
||||
await async_client.challenges.widgets.with_raw_response.delete(
|
||||
"0x4AAF00AAAABn0R22HWm-YUc",
|
||||
account_identifier="",
|
||||
)
|
||||
|
||||
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_identifier="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_identifier="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_identifier="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_identifier="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_identifier` but received ''"):
|
||||
await async_client.challenges.widgets.with_raw_response.get(
|
||||
"0x4AAF00AAAABn0R22HWm-YUc",
|
||||
account_identifier="",
|
||||
)
|
||||
|
||||
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_identifier="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_identifier="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_identifier="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_identifier="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_identifier="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_identifier` but received ''"):
|
||||
await async_client.challenges.widgets.with_raw_response.rotate_secret(
|
||||
"0x4AAF00AAAABn0R22HWm-YUc",
|
||||
account_identifier="",
|
||||
)
|
||||
|
||||
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_identifier="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
Loading…
Add table
Reference in a new issue