mirror of
https://github.com/cloudflare/cloudflare-python.git
synced 2026-01-16 23:01:03 +00:00
feat(api): OpenAPI spec update via Stainless API (#970)
This commit is contained in:
parent
71e97aa998
commit
9ced3bb626
21 changed files with 457 additions and 256 deletions
|
|
@ -1,2 +1,2 @@
|
|||
configured_endpoints: 1343
|
||||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-f5082157bb70165b34f3a552faa44b9693adacaa9613d4b887b251cd744d076f.yml
|
||||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-fea5e994c4346dfa223df3833cf88a978ab7df816a2a4e5718ec2ce40cd98ac0.yml
|
||||
|
|
|
|||
23
api.md
23
api.md
|
|
@ -3122,24 +3122,29 @@ from cloudflare.types.page_shield import Setting, PageShieldUpdateResponse
|
|||
|
||||
Methods:
|
||||
|
||||
- <code title="put /zones/{zone_id}/page_shield">client.page_shield.<a href="./src/cloudflare/resources/page_shield/page_shield.py">update</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/page_shield/page_shield_update_params.py">params</a>) -> <a href="./src/cloudflare/types/page_shield/page_shield_update_response.py">PageShieldUpdateResponse</a></code>
|
||||
- <code title="get /zones/{zone_id}/page_shield">client.page_shield.<a href="./src/cloudflare/resources/page_shield/page_shield.py">get</a>(\*, zone_id) -> <a href="./src/cloudflare/types/page_shield/setting.py">Setting</a></code>
|
||||
- <code title="put /zones/{zone_id}/page_shield">client.page_shield.<a href="./src/cloudflare/resources/page_shield/page_shield.py">update</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/page_shield/page_shield_update_params.py">params</a>) -> <a href="./src/cloudflare/types/page_shield/page_shield_update_response.py">Optional</a></code>
|
||||
- <code title="get /zones/{zone_id}/page_shield">client.page_shield.<a href="./src/cloudflare/resources/page_shield/page_shield.py">get</a>(\*, zone_id) -> <a href="./src/cloudflare/types/page_shield/setting.py">Optional</a></code>
|
||||
|
||||
## Policies
|
||||
|
||||
Types:
|
||||
|
||||
```python
|
||||
from cloudflare.types.page_shield import Policy
|
||||
from cloudflare.types.page_shield import (
|
||||
PolicyCreateResponse,
|
||||
PolicyUpdateResponse,
|
||||
PolicyListResponse,
|
||||
PolicyGetResponse,
|
||||
)
|
||||
```
|
||||
|
||||
Methods:
|
||||
|
||||
- <code title="post /zones/{zone_id}/page_shield/policies">client.page_shield.policies.<a href="./src/cloudflare/resources/page_shield/policies.py">create</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/page_shield/policy_create_params.py">params</a>) -> <a href="./src/cloudflare/types/page_shield/policy.py">Policy</a></code>
|
||||
- <code title="put /zones/{zone_id}/page_shield/policies/{policy_id}">client.page_shield.policies.<a href="./src/cloudflare/resources/page_shield/policies.py">update</a>(policy_id, \*, zone_id, \*\*<a href="src/cloudflare/types/page_shield/policy_update_params.py">params</a>) -> <a href="./src/cloudflare/types/page_shield/policy.py">Policy</a></code>
|
||||
- <code title="get /zones/{zone_id}/page_shield/policies">client.page_shield.policies.<a href="./src/cloudflare/resources/page_shield/policies.py">list</a>(\*, zone_id) -> <a href="./src/cloudflare/types/page_shield/policy.py">SyncSinglePage[Policy]</a></code>
|
||||
- <code title="post /zones/{zone_id}/page_shield/policies">client.page_shield.policies.<a href="./src/cloudflare/resources/page_shield/policies.py">create</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/page_shield/policy_create_params.py">params</a>) -> <a href="./src/cloudflare/types/page_shield/policy_create_response.py">Optional</a></code>
|
||||
- <code title="put /zones/{zone_id}/page_shield/policies/{policy_id}">client.page_shield.policies.<a href="./src/cloudflare/resources/page_shield/policies.py">update</a>(policy_id, \*, zone_id, \*\*<a href="src/cloudflare/types/page_shield/policy_update_params.py">params</a>) -> <a href="./src/cloudflare/types/page_shield/policy_update_response.py">Optional</a></code>
|
||||
- <code title="get /zones/{zone_id}/page_shield/policies">client.page_shield.policies.<a href="./src/cloudflare/resources/page_shield/policies.py">list</a>(\*, zone_id) -> <a href="./src/cloudflare/types/page_shield/policy_list_response.py">SyncSinglePage[PolicyListResponse]</a></code>
|
||||
- <code title="delete /zones/{zone_id}/page_shield/policies/{policy_id}">client.page_shield.policies.<a href="./src/cloudflare/resources/page_shield/policies.py">delete</a>(policy_id, \*, zone_id) -> None</code>
|
||||
- <code title="get /zones/{zone_id}/page_shield/policies/{policy_id}">client.page_shield.policies.<a href="./src/cloudflare/resources/page_shield/policies.py">get</a>(policy_id, \*, zone_id) -> <a href="./src/cloudflare/types/page_shield/policy.py">Policy</a></code>
|
||||
- <code title="get /zones/{zone_id}/page_shield/policies/{policy_id}">client.page_shield.policies.<a href="./src/cloudflare/resources/page_shield/policies.py">get</a>(policy_id, \*, zone_id) -> <a href="./src/cloudflare/types/page_shield/policy_get_response.py">Optional</a></code>
|
||||
|
||||
## Connections
|
||||
|
||||
|
|
@ -3152,7 +3157,7 @@ from cloudflare.types.page_shield import Connection
|
|||
Methods:
|
||||
|
||||
- <code title="get /zones/{zone_id}/page_shield/connections">client.page_shield.connections.<a href="./src/cloudflare/resources/page_shield/connections.py">list</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/page_shield/connection_list_params.py">params</a>) -> <a href="./src/cloudflare/types/page_shield/connection.py">SyncSinglePage[Connection]</a></code>
|
||||
- <code title="get /zones/{zone_id}/page_shield/connections/{connection_id}">client.page_shield.connections.<a href="./src/cloudflare/resources/page_shield/connections.py">get</a>(connection_id, \*, zone_id) -> <a href="./src/cloudflare/types/page_shield/connection.py">Connection</a></code>
|
||||
- <code title="get /zones/{zone_id}/page_shield/connections/{connection_id}">client.page_shield.connections.<a href="./src/cloudflare/resources/page_shield/connections.py">get</a>(connection_id, \*, zone_id) -> <a href="./src/cloudflare/types/page_shield/connection.py">Optional</a></code>
|
||||
|
||||
## Scripts
|
||||
|
||||
|
|
@ -3165,7 +3170,7 @@ from cloudflare.types.page_shield import Script, ScriptGetResponse
|
|||
Methods:
|
||||
|
||||
- <code title="get /zones/{zone_id}/page_shield/scripts">client.page_shield.scripts.<a href="./src/cloudflare/resources/page_shield/scripts.py">list</a>(\*, zone_id, \*\*<a href="src/cloudflare/types/page_shield/script_list_params.py">params</a>) -> <a href="./src/cloudflare/types/page_shield/script.py">SyncSinglePage[Script]</a></code>
|
||||
- <code title="get /zones/{zone_id}/page_shield/scripts/{script_id}">client.page_shield.scripts.<a href="./src/cloudflare/resources/page_shield/scripts.py">get</a>(script_id, \*, zone_id) -> <a href="./src/cloudflare/types/page_shield/script_get_response.py">ScriptGetResponse</a></code>
|
||||
- <code title="get /zones/{zone_id}/page_shield/scripts/{script_id}">client.page_shield.scripts.<a href="./src/cloudflare/resources/page_shield/scripts.py">get</a>(script_id, \*, zone_id) -> <a href="./src/cloudflare/types/page_shield/script_get_response.py">Optional</a></code>
|
||||
|
||||
# Rulesets
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Type, Optional, cast
|
||||
from typing_extensions import Literal
|
||||
|
||||
import httpx
|
||||
|
|
@ -16,6 +17,7 @@ from ..._response import (
|
|||
async_to_raw_response_wrapper,
|
||||
async_to_streamed_response_wrapper,
|
||||
)
|
||||
from ..._wrappers import ResultWrapper
|
||||
from ...pagination import SyncSinglePage, AsyncSinglePage
|
||||
from ..._base_client import (
|
||||
AsyncPaginator,
|
||||
|
|
@ -161,14 +163,14 @@ class ConnectionsResource(SyncAPIResource):
|
|||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
||||
) -> Connection:
|
||||
) -> Optional[Connection]:
|
||||
"""
|
||||
Fetches a connection detected by Page Shield by connection ID.
|
||||
|
||||
Args:
|
||||
zone_id: Identifier
|
||||
|
||||
connection_id: The ID of the resource.
|
||||
connection_id: Identifier
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
|
|
@ -185,9 +187,13 @@ class ConnectionsResource(SyncAPIResource):
|
|||
return self._get(
|
||||
f"/zones/{zone_id}/page_shield/connections/{connection_id}",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[Connection]]._unwrapper,
|
||||
),
|
||||
cast_to=Connection,
|
||||
cast_to=cast(Type[Optional[Connection]], ResultWrapper[Connection]),
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -325,14 +331,14 @@ class AsyncConnectionsResource(AsyncAPIResource):
|
|||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
||||
) -> Connection:
|
||||
) -> Optional[Connection]:
|
||||
"""
|
||||
Fetches a connection detected by Page Shield by connection ID.
|
||||
|
||||
Args:
|
||||
zone_id: Identifier
|
||||
|
||||
connection_id: The ID of the resource.
|
||||
connection_id: Identifier
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
|
|
@ -349,9 +355,13 @@ class AsyncConnectionsResource(AsyncAPIResource):
|
|||
return await self._get(
|
||||
f"/zones/{zone_id}/page_shield/connections/{connection_id}",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[Connection]]._unwrapper,
|
||||
),
|
||||
cast_to=Connection,
|
||||
cast_to=cast(Type[Optional[Connection]], ResultWrapper[Connection]),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Type, cast
|
||||
from typing import Type, Optional, cast
|
||||
|
||||
import httpx
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ class PageShieldResource(SyncAPIResource):
|
|||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
||||
) -> PageShieldUpdateResponse:
|
||||
) -> Optional[PageShieldUpdateResponse]:
|
||||
"""
|
||||
Updates Page Shield settings.
|
||||
|
||||
|
|
@ -127,9 +127,9 @@ class PageShieldResource(SyncAPIResource):
|
|||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[PageShieldUpdateResponse]._unwrapper,
|
||||
post_parser=ResultWrapper[Optional[PageShieldUpdateResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[PageShieldUpdateResponse], ResultWrapper[PageShieldUpdateResponse]),
|
||||
cast_to=cast(Type[Optional[PageShieldUpdateResponse]], ResultWrapper[PageShieldUpdateResponse]),
|
||||
)
|
||||
|
||||
def get(
|
||||
|
|
@ -142,7 +142,7 @@ class PageShieldResource(SyncAPIResource):
|
|||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
||||
) -> Setting:
|
||||
) -> Optional[Setting]:
|
||||
"""
|
||||
Fetches the Page Shield settings.
|
||||
|
||||
|
|
@ -166,9 +166,9 @@ class PageShieldResource(SyncAPIResource):
|
|||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Setting]._unwrapper,
|
||||
post_parser=ResultWrapper[Optional[Setting]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[Setting], ResultWrapper[Setting]),
|
||||
cast_to=cast(Type[Optional[Setting]], ResultWrapper[Setting]),
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ class AsyncPageShieldResource(AsyncAPIResource):
|
|||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
||||
) -> PageShieldUpdateResponse:
|
||||
) -> Optional[PageShieldUpdateResponse]:
|
||||
"""
|
||||
Updates Page Shield settings.
|
||||
|
||||
|
|
@ -245,9 +245,9 @@ class AsyncPageShieldResource(AsyncAPIResource):
|
|||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[PageShieldUpdateResponse]._unwrapper,
|
||||
post_parser=ResultWrapper[Optional[PageShieldUpdateResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[PageShieldUpdateResponse], ResultWrapper[PageShieldUpdateResponse]),
|
||||
cast_to=cast(Type[Optional[PageShieldUpdateResponse]], ResultWrapper[PageShieldUpdateResponse]),
|
||||
)
|
||||
|
||||
async def get(
|
||||
|
|
@ -260,7 +260,7 @@ class AsyncPageShieldResource(AsyncAPIResource):
|
|||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
||||
) -> Setting:
|
||||
) -> Optional[Setting]:
|
||||
"""
|
||||
Fetches the Page Shield settings.
|
||||
|
||||
|
|
@ -284,9 +284,9 @@ class AsyncPageShieldResource(AsyncAPIResource):
|
|||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Setting]._unwrapper,
|
||||
post_parser=ResultWrapper[Optional[Setting]]._unwrapper,
|
||||
),
|
||||
cast_to=cast(Type[Setting], ResultWrapper[Setting]),
|
||||
cast_to=cast(Type[Optional[Setting]], ResultWrapper[Setting]),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Type, Optional, cast
|
||||
from typing_extensions import Literal
|
||||
|
||||
import httpx
|
||||
|
|
@ -19,13 +20,17 @@ from ..._response import (
|
|||
async_to_raw_response_wrapper,
|
||||
async_to_streamed_response_wrapper,
|
||||
)
|
||||
from ..._wrappers import ResultWrapper
|
||||
from ...pagination import SyncSinglePage, AsyncSinglePage
|
||||
from ..._base_client import (
|
||||
AsyncPaginator,
|
||||
make_request_options,
|
||||
)
|
||||
from ...types.page_shield import policy_create_params, policy_update_params
|
||||
from ...types.page_shield.policy import Policy
|
||||
from ...types.page_shield.policy_get_response import PolicyGetResponse
|
||||
from ...types.page_shield.policy_list_response import PolicyListResponse
|
||||
from ...types.page_shield.policy_create_response import PolicyCreateResponse
|
||||
from ...types.page_shield.policy_update_response import PolicyUpdateResponse
|
||||
|
||||
__all__ = ["PoliciesResource", "AsyncPoliciesResource"]
|
||||
|
||||
|
|
@ -43,18 +48,18 @@ class PoliciesResource(SyncAPIResource):
|
|||
self,
|
||||
*,
|
||||
zone_id: str,
|
||||
action: Literal["allow", "log"] | NotGiven = NOT_GIVEN,
|
||||
description: str | NotGiven = NOT_GIVEN,
|
||||
enabled: bool | NotGiven = NOT_GIVEN,
|
||||
expression: str | NotGiven = NOT_GIVEN,
|
||||
value: str | NotGiven = NOT_GIVEN,
|
||||
action: Literal["allow", "log"],
|
||||
description: str,
|
||||
enabled: bool,
|
||||
expression: str,
|
||||
value: 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,
|
||||
) -> Policy:
|
||||
) -> Optional[PolicyCreateResponse]:
|
||||
"""
|
||||
Create a Page Shield policy.
|
||||
|
||||
|
|
@ -95,9 +100,13 @@ class PoliciesResource(SyncAPIResource):
|
|||
policy_create_params.PolicyCreateParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[PolicyCreateResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=Policy,
|
||||
cast_to=cast(Type[Optional[PolicyCreateResponse]], ResultWrapper[PolicyCreateResponse]),
|
||||
)
|
||||
|
||||
def update(
|
||||
|
|
@ -116,14 +125,14 @@ class PoliciesResource(SyncAPIResource):
|
|||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
||||
) -> Policy:
|
||||
) -> Optional[PolicyUpdateResponse]:
|
||||
"""
|
||||
Update a Page Shield policy by ID.
|
||||
|
||||
Args:
|
||||
zone_id: Identifier
|
||||
|
||||
policy_id: The ID of the policy.
|
||||
policy_id: Identifier
|
||||
|
||||
action: The action to take if the expression matches
|
||||
|
||||
|
|
@ -161,9 +170,13 @@ class PoliciesResource(SyncAPIResource):
|
|||
policy_update_params.PolicyUpdateParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[PolicyUpdateResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=Policy,
|
||||
cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]),
|
||||
)
|
||||
|
||||
def list(
|
||||
|
|
@ -176,7 +189,7 @@ class PoliciesResource(SyncAPIResource):
|
|||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
||||
) -> SyncSinglePage[Policy]:
|
||||
) -> SyncSinglePage[PolicyListResponse]:
|
||||
"""
|
||||
Lists all Page Shield policies.
|
||||
|
||||
|
|
@ -195,11 +208,11 @@ class PoliciesResource(SyncAPIResource):
|
|||
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
|
||||
return self._get_api_list(
|
||||
f"/zones/{zone_id}/page_shield/policies",
|
||||
page=SyncSinglePage[Policy],
|
||||
page=SyncSinglePage[PolicyListResponse],
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
model=Policy,
|
||||
model=PolicyListResponse,
|
||||
)
|
||||
|
||||
def delete(
|
||||
|
|
@ -220,7 +233,7 @@ class PoliciesResource(SyncAPIResource):
|
|||
Args:
|
||||
zone_id: Identifier
|
||||
|
||||
policy_id: The ID of the policy.
|
||||
policy_id: Identifier
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
|
|
@ -254,14 +267,14 @@ class PoliciesResource(SyncAPIResource):
|
|||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
||||
) -> Policy:
|
||||
) -> Optional[PolicyGetResponse]:
|
||||
"""
|
||||
Fetches a Page Shield policy by ID.
|
||||
|
||||
Args:
|
||||
zone_id: Identifier
|
||||
|
||||
policy_id: The ID of the policy.
|
||||
policy_id: Identifier
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
|
|
@ -278,9 +291,13 @@ class PoliciesResource(SyncAPIResource):
|
|||
return self._get(
|
||||
f"/zones/{zone_id}/page_shield/policies/{policy_id}",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[PolicyGetResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=Policy,
|
||||
cast_to=cast(Type[Optional[PolicyGetResponse]], ResultWrapper[PolicyGetResponse]),
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -297,18 +314,18 @@ class AsyncPoliciesResource(AsyncAPIResource):
|
|||
self,
|
||||
*,
|
||||
zone_id: str,
|
||||
action: Literal["allow", "log"] | NotGiven = NOT_GIVEN,
|
||||
description: str | NotGiven = NOT_GIVEN,
|
||||
enabled: bool | NotGiven = NOT_GIVEN,
|
||||
expression: str | NotGiven = NOT_GIVEN,
|
||||
value: str | NotGiven = NOT_GIVEN,
|
||||
action: Literal["allow", "log"],
|
||||
description: str,
|
||||
enabled: bool,
|
||||
expression: str,
|
||||
value: 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,
|
||||
) -> Policy:
|
||||
) -> Optional[PolicyCreateResponse]:
|
||||
"""
|
||||
Create a Page Shield policy.
|
||||
|
||||
|
|
@ -349,9 +366,13 @@ class AsyncPoliciesResource(AsyncAPIResource):
|
|||
policy_create_params.PolicyCreateParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[PolicyCreateResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=Policy,
|
||||
cast_to=cast(Type[Optional[PolicyCreateResponse]], ResultWrapper[PolicyCreateResponse]),
|
||||
)
|
||||
|
||||
async def update(
|
||||
|
|
@ -370,14 +391,14 @@ class AsyncPoliciesResource(AsyncAPIResource):
|
|||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
||||
) -> Policy:
|
||||
) -> Optional[PolicyUpdateResponse]:
|
||||
"""
|
||||
Update a Page Shield policy by ID.
|
||||
|
||||
Args:
|
||||
zone_id: Identifier
|
||||
|
||||
policy_id: The ID of the policy.
|
||||
policy_id: Identifier
|
||||
|
||||
action: The action to take if the expression matches
|
||||
|
||||
|
|
@ -415,9 +436,13 @@ class AsyncPoliciesResource(AsyncAPIResource):
|
|||
policy_update_params.PolicyUpdateParams,
|
||||
),
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[PolicyUpdateResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=Policy,
|
||||
cast_to=cast(Type[Optional[PolicyUpdateResponse]], ResultWrapper[PolicyUpdateResponse]),
|
||||
)
|
||||
|
||||
def list(
|
||||
|
|
@ -430,7 +455,7 @@ class AsyncPoliciesResource(AsyncAPIResource):
|
|||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
||||
) -> AsyncPaginator[Policy, AsyncSinglePage[Policy]]:
|
||||
) -> AsyncPaginator[PolicyListResponse, AsyncSinglePage[PolicyListResponse]]:
|
||||
"""
|
||||
Lists all Page Shield policies.
|
||||
|
||||
|
|
@ -449,11 +474,11 @@ class AsyncPoliciesResource(AsyncAPIResource):
|
|||
raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
|
||||
return self._get_api_list(
|
||||
f"/zones/{zone_id}/page_shield/policies",
|
||||
page=AsyncSinglePage[Policy],
|
||||
page=AsyncSinglePage[PolicyListResponse],
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
),
|
||||
model=Policy,
|
||||
model=PolicyListResponse,
|
||||
)
|
||||
|
||||
async def delete(
|
||||
|
|
@ -474,7 +499,7 @@ class AsyncPoliciesResource(AsyncAPIResource):
|
|||
Args:
|
||||
zone_id: Identifier
|
||||
|
||||
policy_id: The ID of the policy.
|
||||
policy_id: Identifier
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
|
|
@ -508,14 +533,14 @@ class AsyncPoliciesResource(AsyncAPIResource):
|
|||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
||||
) -> Policy:
|
||||
) -> Optional[PolicyGetResponse]:
|
||||
"""
|
||||
Fetches a Page Shield policy by ID.
|
||||
|
||||
Args:
|
||||
zone_id: Identifier
|
||||
|
||||
policy_id: The ID of the policy.
|
||||
policy_id: Identifier
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
|
|
@ -532,9 +557,13 @@ class AsyncPoliciesResource(AsyncAPIResource):
|
|||
return await self._get(
|
||||
f"/zones/{zone_id}/page_shield/policies/{policy_id}",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[PolicyGetResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=Policy,
|
||||
cast_to=cast(Type[Optional[PolicyGetResponse]], ResultWrapper[PolicyGetResponse]),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Type, Optional, cast
|
||||
from typing_extensions import Literal
|
||||
|
||||
import httpx
|
||||
|
|
@ -16,6 +17,7 @@ from ..._response import (
|
|||
async_to_raw_response_wrapper,
|
||||
async_to_streamed_response_wrapper,
|
||||
)
|
||||
from ..._wrappers import ResultWrapper
|
||||
from ...pagination import SyncSinglePage, AsyncSinglePage
|
||||
from ..._base_client import (
|
||||
AsyncPaginator,
|
||||
|
|
@ -169,14 +171,14 @@ class ScriptsResource(SyncAPIResource):
|
|||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
||||
) -> ScriptGetResponse:
|
||||
) -> Optional[ScriptGetResponse]:
|
||||
"""
|
||||
Fetches a script detected by Page Shield by script ID.
|
||||
|
||||
Args:
|
||||
zone_id: Identifier
|
||||
|
||||
script_id: The ID of the resource.
|
||||
script_id: Identifier
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
|
|
@ -193,9 +195,13 @@ class ScriptsResource(SyncAPIResource):
|
|||
return self._get(
|
||||
f"/zones/{zone_id}/page_shield/scripts/{script_id}",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[ScriptGetResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=ScriptGetResponse,
|
||||
cast_to=cast(Type[Optional[ScriptGetResponse]], ResultWrapper[ScriptGetResponse]),
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -340,14 +346,14 @@ class AsyncScriptsResource(AsyncAPIResource):
|
|||
extra_query: Query | None = None,
|
||||
extra_body: Body | None = None,
|
||||
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
|
||||
) -> ScriptGetResponse:
|
||||
) -> Optional[ScriptGetResponse]:
|
||||
"""
|
||||
Fetches a script detected by Page Shield by script ID.
|
||||
|
||||
Args:
|
||||
zone_id: Identifier
|
||||
|
||||
script_id: The ID of the resource.
|
||||
script_id: Identifier
|
||||
|
||||
extra_headers: Send extra headers
|
||||
|
||||
|
|
@ -364,9 +370,13 @@ class AsyncScriptsResource(AsyncAPIResource):
|
|||
return await self._get(
|
||||
f"/zones/{zone_id}/page_shield/scripts/{script_id}",
|
||||
options=make_request_options(
|
||||
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
||||
extra_headers=extra_headers,
|
||||
extra_query=extra_query,
|
||||
extra_body=extra_body,
|
||||
timeout=timeout,
|
||||
post_parser=ResultWrapper[Optional[ScriptGetResponse]]._unwrapper,
|
||||
),
|
||||
cast_to=ScriptGetResponse,
|
||||
cast_to=cast(Type[Optional[ScriptGetResponse]], ResultWrapper[ScriptGetResponse]),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,14 +2,17 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
from .policy import Policy as Policy
|
||||
from .script import Script as Script
|
||||
from .setting import Setting as Setting
|
||||
from .connection import Connection as Connection
|
||||
from .script_list_params import ScriptListParams as ScriptListParams
|
||||
from .policy_get_response import PolicyGetResponse as PolicyGetResponse
|
||||
from .script_get_response import ScriptGetResponse as ScriptGetResponse
|
||||
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 .connection_list_params import ConnectionListParams as ConnectionListParams
|
||||
from .policy_create_response import PolicyCreateResponse as PolicyCreateResponse
|
||||
from .policy_update_response import PolicyUpdateResponse as PolicyUpdateResponse
|
||||
from .page_shield_update_params import PageShieldUpdateParams as PageShieldUpdateParams
|
||||
from .page_shield_update_response import PageShieldUpdateResponse as PageShieldUpdateResponse
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing import List, Optional
|
||||
from datetime import datetime
|
||||
|
||||
from ..._models import BaseModel
|
||||
|
||||
|
|
@ -8,22 +9,29 @@ __all__ = ["Connection"]
|
|||
|
||||
|
||||
class Connection(BaseModel):
|
||||
id: Optional[str] = None
|
||||
id: str
|
||||
"""Identifier"""
|
||||
|
||||
added_at: Optional[str] = None
|
||||
added_at: datetime
|
||||
|
||||
first_seen_at: datetime
|
||||
|
||||
host: str
|
||||
|
||||
last_seen_at: datetime
|
||||
|
||||
url: str
|
||||
|
||||
url_contains_cdn_cgi_path: bool
|
||||
|
||||
domain_reported_malicious: Optional[bool] = None
|
||||
|
||||
first_page_url: Optional[str] = None
|
||||
|
||||
first_seen_at: Optional[str] = None
|
||||
malicious_domain_categories: Optional[List[str]] = None
|
||||
|
||||
host: Optional[str] = None
|
||||
|
||||
last_seen_at: Optional[str] = None
|
||||
malicious_url_categories: Optional[List[str]] = None
|
||||
|
||||
page_urls: Optional[List[str]] = None
|
||||
|
||||
url: Optional[str] = None
|
||||
|
||||
url_contains_cdn_cgi_path: Optional[bool] = None
|
||||
url_reported_malicious: Optional[bool] = None
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing import Optional
|
||||
|
||||
|
||||
from ..._models import BaseModel
|
||||
|
||||
|
|
@ -8,17 +8,17 @@ __all__ = ["PageShieldUpdateResponse"]
|
|||
|
||||
|
||||
class PageShieldUpdateResponse(BaseModel):
|
||||
enabled: Optional[bool] = None
|
||||
enabled: bool
|
||||
"""When true, indicates that Page Shield is enabled."""
|
||||
|
||||
updated_at: Optional[str] = None
|
||||
updated_at: str
|
||||
"""The timestamp of when Page Shield was last updated."""
|
||||
|
||||
use_cloudflare_reporting_endpoint: Optional[bool] = None
|
||||
use_cloudflare_reporting_endpoint: bool
|
||||
"""
|
||||
When true, CSP reports will be sent to
|
||||
https://csp-reporting.cloudflare.com/cdn-cgi/script_monitor/report
|
||||
"""
|
||||
|
||||
use_connection_url_path: Optional[bool] = None
|
||||
use_connection_url_path: bool
|
||||
"""When true, the paths associated with connections URLs will also be analyzed."""
|
||||
|
|
|
|||
|
|
@ -11,20 +11,20 @@ class PolicyCreateParams(TypedDict, total=False):
|
|||
zone_id: Required[str]
|
||||
"""Identifier"""
|
||||
|
||||
action: Literal["allow", "log"]
|
||||
action: Required[Literal["allow", "log"]]
|
||||
"""The action to take if the expression matches"""
|
||||
|
||||
description: str
|
||||
description: Required[str]
|
||||
"""A description for the policy"""
|
||||
|
||||
enabled: bool
|
||||
enabled: Required[bool]
|
||||
"""Whether the policy is enabled"""
|
||||
|
||||
expression: str
|
||||
expression: Required[str]
|
||||
"""
|
||||
The expression which must match for the policy to be applied, using the
|
||||
Cloudflare Firewall rule expression syntax
|
||||
"""
|
||||
|
||||
value: str
|
||||
value: Required[str]
|
||||
"""The policy which will be applied"""
|
||||
|
|
|
|||
|
|
@ -1,31 +1,30 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing import Optional
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ..._models import BaseModel
|
||||
|
||||
__all__ = ["Policy"]
|
||||
__all__ = ["PolicyCreateResponse"]
|
||||
|
||||
|
||||
class Policy(BaseModel):
|
||||
id: Optional[str] = None
|
||||
"""The ID of the policy"""
|
||||
class PolicyCreateResponse(BaseModel):
|
||||
id: str
|
||||
"""Identifier"""
|
||||
|
||||
action: Optional[Literal["allow", "log"]] = None
|
||||
action: Literal["allow", "log"]
|
||||
"""The action to take if the expression matches"""
|
||||
|
||||
description: Optional[str] = None
|
||||
description: str
|
||||
"""A description for the policy"""
|
||||
|
||||
enabled: Optional[bool] = None
|
||||
enabled: bool
|
||||
"""Whether the policy is enabled"""
|
||||
|
||||
expression: Optional[str] = None
|
||||
expression: str
|
||||
"""
|
||||
The expression which must match for the policy to be applied, using the
|
||||
Cloudflare Firewall rule expression syntax
|
||||
"""
|
||||
|
||||
value: Optional[str] = None
|
||||
value: str
|
||||
"""The policy which will be applied"""
|
||||
30
src/cloudflare/types/page_shield/policy_get_response.py
Normal file
30
src/cloudflare/types/page_shield/policy_get_response.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ..._models import BaseModel
|
||||
|
||||
__all__ = ["PolicyGetResponse"]
|
||||
|
||||
|
||||
class PolicyGetResponse(BaseModel):
|
||||
id: str
|
||||
"""Identifier"""
|
||||
|
||||
action: Literal["allow", "log"]
|
||||
"""The action to take if the expression matches"""
|
||||
|
||||
description: str
|
||||
"""A description for the policy"""
|
||||
|
||||
enabled: bool
|
||||
"""Whether the policy is enabled"""
|
||||
|
||||
expression: str
|
||||
"""
|
||||
The expression which must match for the policy to be applied, using the
|
||||
Cloudflare Firewall rule expression syntax
|
||||
"""
|
||||
|
||||
value: str
|
||||
"""The policy which will be applied"""
|
||||
30
src/cloudflare/types/page_shield/policy_list_response.py
Normal file
30
src/cloudflare/types/page_shield/policy_list_response.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ..._models import BaseModel
|
||||
|
||||
__all__ = ["PolicyListResponse"]
|
||||
|
||||
|
||||
class PolicyListResponse(BaseModel):
|
||||
id: str
|
||||
"""Identifier"""
|
||||
|
||||
action: Literal["allow", "log"]
|
||||
"""The action to take if the expression matches"""
|
||||
|
||||
description: str
|
||||
"""A description for the policy"""
|
||||
|
||||
enabled: bool
|
||||
"""Whether the policy is enabled"""
|
||||
|
||||
expression: str
|
||||
"""
|
||||
The expression which must match for the policy to be applied, using the
|
||||
Cloudflare Firewall rule expression syntax
|
||||
"""
|
||||
|
||||
value: str
|
||||
"""The policy which will be applied"""
|
||||
30
src/cloudflare/types/page_shield/policy_update_response.py
Normal file
30
src/cloudflare/types/page_shield/policy_update_response.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ..._models import BaseModel
|
||||
|
||||
__all__ = ["PolicyUpdateResponse"]
|
||||
|
||||
|
||||
class PolicyUpdateResponse(BaseModel):
|
||||
id: str
|
||||
"""Identifier"""
|
||||
|
||||
action: Literal["allow", "log"]
|
||||
"""The action to take if the expression matches"""
|
||||
|
||||
description: str
|
||||
"""A description for the policy"""
|
||||
|
||||
enabled: bool
|
||||
"""Whether the policy is enabled"""
|
||||
|
||||
expression: str
|
||||
"""
|
||||
The expression which must match for the policy to be applied, using the
|
||||
Cloudflare Firewall rule expression syntax
|
||||
"""
|
||||
|
||||
value: str
|
||||
"""The policy which will be applied"""
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing import List, Optional
|
||||
from datetime import datetime
|
||||
|
||||
from ..._models import BaseModel
|
||||
|
||||
|
|
@ -8,32 +9,44 @@ __all__ = ["Script"]
|
|||
|
||||
|
||||
class Script(BaseModel):
|
||||
id: Optional[str] = None
|
||||
id: str
|
||||
"""Identifier"""
|
||||
|
||||
added_at: Optional[str] = None
|
||||
added_at: datetime
|
||||
|
||||
dataflow_score: Optional[float] = None
|
||||
first_seen_at: datetime
|
||||
|
||||
host: str
|
||||
|
||||
last_seen_at: datetime
|
||||
|
||||
url: str
|
||||
|
||||
url_contains_cdn_cgi_path: bool
|
||||
|
||||
dataflow_score: Optional[int] = None
|
||||
"""The dataflow score of the JavaScript content."""
|
||||
|
||||
domain_reported_malicious: Optional[bool] = None
|
||||
|
||||
fetched_at: Optional[str] = None
|
||||
"""The timestamp of when the script was last fetched."""
|
||||
|
||||
first_page_url: Optional[str] = None
|
||||
|
||||
first_seen_at: Optional[str] = None
|
||||
|
||||
hash: Optional[str] = None
|
||||
"""The computed hash of the analyzed script."""
|
||||
|
||||
host: Optional[str] = None
|
||||
js_integrity_score: Optional[int] = None
|
||||
"""The integrity score of the JavaScript content."""
|
||||
|
||||
js_integrity_score: Optional[float] = None
|
||||
malicious_domain_categories: Optional[List[str]] = None
|
||||
|
||||
last_seen_at: Optional[str] = None
|
||||
malicious_url_categories: Optional[List[str]] = None
|
||||
|
||||
obfuscation_score: Optional[float] = None
|
||||
obfuscation_score: Optional[int] = None
|
||||
"""The obfuscation score of the JavaScript content."""
|
||||
|
||||
page_urls: Optional[List[str]] = None
|
||||
|
||||
url: Optional[str] = None
|
||||
|
||||
url_contains_cdn_cgi_path: Optional[bool] = None
|
||||
url_reported_malicious: Optional[bool] = None
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing import List, Optional
|
||||
from datetime import datetime
|
||||
|
||||
from ..._models import BaseModel
|
||||
|
||||
|
|
@ -25,34 +26,46 @@ class Version(BaseModel):
|
|||
|
||||
|
||||
class ScriptGetResponse(BaseModel):
|
||||
id: Optional[str] = None
|
||||
id: str
|
||||
"""Identifier"""
|
||||
|
||||
added_at: Optional[str] = None
|
||||
added_at: datetime
|
||||
|
||||
dataflow_score: Optional[float] = None
|
||||
first_seen_at: datetime
|
||||
|
||||
host: str
|
||||
|
||||
last_seen_at: datetime
|
||||
|
||||
url: str
|
||||
|
||||
url_contains_cdn_cgi_path: bool
|
||||
|
||||
dataflow_score: Optional[int] = None
|
||||
"""The dataflow score of the JavaScript content."""
|
||||
|
||||
domain_reported_malicious: Optional[bool] = None
|
||||
|
||||
fetched_at: Optional[str] = None
|
||||
"""The timestamp of when the script was last fetched."""
|
||||
|
||||
first_page_url: Optional[str] = None
|
||||
|
||||
first_seen_at: Optional[str] = None
|
||||
|
||||
hash: Optional[str] = None
|
||||
"""The computed hash of the analyzed script."""
|
||||
|
||||
host: Optional[str] = None
|
||||
js_integrity_score: Optional[int] = None
|
||||
"""The integrity score of the JavaScript content."""
|
||||
|
||||
js_integrity_score: Optional[float] = None
|
||||
malicious_domain_categories: Optional[List[str]] = None
|
||||
|
||||
last_seen_at: Optional[str] = None
|
||||
malicious_url_categories: Optional[List[str]] = None
|
||||
|
||||
obfuscation_score: Optional[float] = None
|
||||
obfuscation_score: Optional[int] = None
|
||||
"""The obfuscation score of the JavaScript content."""
|
||||
|
||||
page_urls: Optional[List[str]] = None
|
||||
|
||||
url: Optional[str] = None
|
||||
|
||||
url_contains_cdn_cgi_path: Optional[bool] = None
|
||||
url_reported_malicious: Optional[bool] = None
|
||||
|
||||
versions: Optional[List[Version]] = None
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
||||
|
||||
from typing import Optional
|
||||
|
||||
|
||||
from ..._models import BaseModel
|
||||
|
||||
|
|
@ -8,17 +8,17 @@ __all__ = ["Setting"]
|
|||
|
||||
|
||||
class Setting(BaseModel):
|
||||
enabled: Optional[bool] = None
|
||||
enabled: bool
|
||||
"""When true, indicates that Page Shield is enabled."""
|
||||
|
||||
updated_at: Optional[str] = None
|
||||
updated_at: str
|
||||
"""The timestamp of when Page Shield was last updated."""
|
||||
|
||||
use_cloudflare_reporting_endpoint: Optional[bool] = None
|
||||
use_cloudflare_reporting_endpoint: bool
|
||||
"""
|
||||
When true, CSP reports will be sent to
|
||||
https://csp-reporting.cloudflare.com/cdn-cgi/script_monitor/report
|
||||
"""
|
||||
|
||||
use_connection_url_path: Optional[bool] = None
|
||||
use_connection_url_path: bool
|
||||
"""When true, the paths associated with connections URLs will also be analyzed."""
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import Any, cast
|
||||
from typing import Any, Optional, cast
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
@ -78,34 +78,34 @@ class TestConnections:
|
|||
@parametrize
|
||||
def test_method_get(self, client: Cloudflare) -> None:
|
||||
connection = client.page_shield.connections.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Connection, connection, path=["response"])
|
||||
assert_matches_type(Optional[Connection], connection, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_raw_response_get(self, client: Cloudflare) -> None:
|
||||
response = client.page_shield.connections.with_raw_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
connection = response.parse()
|
||||
assert_matches_type(Connection, connection, path=["response"])
|
||||
assert_matches_type(Optional[Connection], connection, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_streaming_response_get(self, client: Cloudflare) -> None:
|
||||
with client.page_shield.connections.with_streaming_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
connection = response.parse()
|
||||
assert_matches_type(Connection, connection, path=["response"])
|
||||
assert_matches_type(Optional[Connection], connection, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ class TestConnections:
|
|||
def test_path_params_get(self, client: Cloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
|
||||
client.page_shield.connections.with_raw_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="",
|
||||
)
|
||||
|
||||
|
|
@ -187,34 +187,34 @@ class TestAsyncConnections:
|
|||
@parametrize
|
||||
async def test_method_get(self, async_client: AsyncCloudflare) -> None:
|
||||
connection = await async_client.page_shield.connections.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Connection, connection, path=["response"])
|
||||
assert_matches_type(Optional[Connection], connection, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
|
||||
response = await async_client.page_shield.connections.with_raw_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
connection = await response.parse()
|
||||
assert_matches_type(Connection, connection, path=["response"])
|
||||
assert_matches_type(Optional[Connection], connection, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
|
||||
async with async_client.page_shield.connections.with_streaming_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
connection = await response.parse()
|
||||
assert_matches_type(Connection, connection, path=["response"])
|
||||
assert_matches_type(Optional[Connection], connection, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
@ -222,7 +222,7 @@ class TestAsyncConnections:
|
|||
async def test_path_params_get(self, async_client: AsyncCloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
|
||||
await async_client.page_shield.connections.with_raw_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="",
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,14 +3,19 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import Any, cast
|
||||
from typing import Any, Optional, cast
|
||||
|
||||
import pytest
|
||||
|
||||
from cloudflare import Cloudflare, AsyncCloudflare
|
||||
from tests.utils import assert_matches_type
|
||||
from cloudflare.pagination import SyncSinglePage, AsyncSinglePage
|
||||
from cloudflare.types.page_shield import Policy
|
||||
from cloudflare.types.page_shield import (
|
||||
PolicyGetResponse,
|
||||
PolicyListResponse,
|
||||
PolicyCreateResponse,
|
||||
PolicyUpdateResponse,
|
||||
)
|
||||
|
||||
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
|
||||
|
||||
|
|
@ -22,12 +27,17 @@ class TestPolicies:
|
|||
def test_method_create(self, client: Cloudflare) -> None:
|
||||
policy = client.page_shield.policies.create(
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
action="allow",
|
||||
description="Checkout page CSP policy",
|
||||
enabled=True,
|
||||
expression='ends_with(http.request.uri.path, "/checkout")',
|
||||
value="script-src 'none';",
|
||||
)
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_method_create_with_all_params(self, client: Cloudflare) -> None:
|
||||
policy = client.page_shield.policies.create(
|
||||
def test_raw_response_create(self, client: Cloudflare) -> None:
|
||||
response = client.page_shield.policies.with_raw_response.create(
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
action="allow",
|
||||
description="Checkout page CSP policy",
|
||||
|
|
@ -35,29 +45,27 @@ class TestPolicies:
|
|||
expression='ends_with(http.request.uri.path, "/checkout")',
|
||||
value="script-src 'none';",
|
||||
)
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_raw_response_create(self, client: Cloudflare) -> None:
|
||||
response = client.page_shield.policies.with_raw_response.create(
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
policy = response.parse()
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_streaming_response_create(self, client: Cloudflare) -> None:
|
||||
with client.page_shield.policies.with_streaming_response.create(
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
action="allow",
|
||||
description="Checkout page CSP policy",
|
||||
enabled=True,
|
||||
expression='ends_with(http.request.uri.path, "/checkout")',
|
||||
value="script-src 'none';",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
policy = response.parse()
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
@ -66,20 +74,25 @@ class TestPolicies:
|
|||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
|
||||
client.page_shield.policies.with_raw_response.create(
|
||||
zone_id="",
|
||||
action="allow",
|
||||
description="Checkout page CSP policy",
|
||||
enabled=True,
|
||||
expression='ends_with(http.request.uri.path, "/checkout")',
|
||||
value="script-src 'none';",
|
||||
)
|
||||
|
||||
@parametrize
|
||||
def test_method_update(self, client: Cloudflare) -> None:
|
||||
policy = client.page_shield.policies.update(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_method_update_with_all_params(self, client: Cloudflare) -> None:
|
||||
policy = client.page_shield.policies.update(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
action="allow",
|
||||
description="Checkout page CSP policy",
|
||||
|
|
@ -87,31 +100,31 @@ class TestPolicies:
|
|||
expression='ends_with(http.request.uri.path, "/checkout")',
|
||||
value="script-src 'none';",
|
||||
)
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_raw_response_update(self, client: Cloudflare) -> None:
|
||||
response = client.page_shield.policies.with_raw_response.update(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
policy = response.parse()
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_streaming_response_update(self, client: Cloudflare) -> None:
|
||||
with client.page_shield.policies.with_streaming_response.update(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
policy = response.parse()
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
@ -119,7 +132,7 @@ class TestPolicies:
|
|||
def test_path_params_update(self, client: Cloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
|
||||
client.page_shield.policies.with_raw_response.update(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="",
|
||||
)
|
||||
|
||||
|
|
@ -134,7 +147,7 @@ class TestPolicies:
|
|||
policy = client.page_shield.policies.list(
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(SyncSinglePage[Policy], policy, path=["response"])
|
||||
assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_raw_response_list(self, client: Cloudflare) -> None:
|
||||
|
|
@ -145,7 +158,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(SyncSinglePage[Policy], policy, path=["response"])
|
||||
assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_streaming_response_list(self, client: Cloudflare) -> None:
|
||||
|
|
@ -156,7 +169,7 @@ class TestPolicies:
|
|||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
policy = response.parse()
|
||||
assert_matches_type(SyncSinglePage[Policy], policy, path=["response"])
|
||||
assert_matches_type(SyncSinglePage[PolicyListResponse], policy, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
@ -170,7 +183,7 @@ class TestPolicies:
|
|||
@parametrize
|
||||
def test_method_delete(self, client: Cloudflare) -> None:
|
||||
policy = client.page_shield.policies.delete(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert policy is None
|
||||
|
|
@ -178,7 +191,7 @@ class TestPolicies:
|
|||
@parametrize
|
||||
def test_raw_response_delete(self, client: Cloudflare) -> None:
|
||||
response = client.page_shield.policies.with_raw_response.delete(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
|
|
@ -190,7 +203,7 @@ class TestPolicies:
|
|||
@parametrize
|
||||
def test_streaming_response_delete(self, client: Cloudflare) -> None:
|
||||
with client.page_shield.policies.with_streaming_response.delete(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
|
|
@ -205,7 +218,7 @@ class TestPolicies:
|
|||
def test_path_params_delete(self, client: Cloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
|
||||
client.page_shield.policies.with_raw_response.delete(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="",
|
||||
)
|
||||
|
||||
|
|
@ -218,34 +231,34 @@ class TestPolicies:
|
|||
@parametrize
|
||||
def test_method_get(self, client: Cloudflare) -> None:
|
||||
policy = client.page_shield.policies.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_raw_response_get(self, client: Cloudflare) -> None:
|
||||
response = client.page_shield.policies.with_raw_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
policy = response.parse()
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_streaming_response_get(self, client: Cloudflare) -> None:
|
||||
with client.page_shield.policies.with_streaming_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
policy = response.parse()
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
@ -253,7 +266,7 @@ class TestPolicies:
|
|||
def test_path_params_get(self, client: Cloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
|
||||
client.page_shield.policies.with_raw_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="",
|
||||
)
|
||||
|
||||
|
|
@ -271,12 +284,17 @@ class TestAsyncPolicies:
|
|||
async def test_method_create(self, async_client: AsyncCloudflare) -> None:
|
||||
policy = await async_client.page_shield.policies.create(
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
action="allow",
|
||||
description="Checkout page CSP policy",
|
||||
enabled=True,
|
||||
expression='ends_with(http.request.uri.path, "/checkout")',
|
||||
value="script-src 'none';",
|
||||
)
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None:
|
||||
policy = await async_client.page_shield.policies.create(
|
||||
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
|
||||
response = await async_client.page_shield.policies.with_raw_response.create(
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
action="allow",
|
||||
description="Checkout page CSP policy",
|
||||
|
|
@ -284,29 +302,27 @@ class TestAsyncPolicies:
|
|||
expression='ends_with(http.request.uri.path, "/checkout")',
|
||||
value="script-src 'none';",
|
||||
)
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
|
||||
response = await async_client.page_shield.policies.with_raw_response.create(
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
policy = await response.parse()
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
|
||||
async with async_client.page_shield.policies.with_streaming_response.create(
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
action="allow",
|
||||
description="Checkout page CSP policy",
|
||||
enabled=True,
|
||||
expression='ends_with(http.request.uri.path, "/checkout")',
|
||||
value="script-src 'none';",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
policy = await response.parse()
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyCreateResponse], policy, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
@ -315,20 +331,25 @@ class TestAsyncPolicies:
|
|||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
|
||||
await async_client.page_shield.policies.with_raw_response.create(
|
||||
zone_id="",
|
||||
action="allow",
|
||||
description="Checkout page CSP policy",
|
||||
enabled=True,
|
||||
expression='ends_with(http.request.uri.path, "/checkout")',
|
||||
value="script-src 'none';",
|
||||
)
|
||||
|
||||
@parametrize
|
||||
async def test_method_update(self, async_client: AsyncCloudflare) -> None:
|
||||
policy = await async_client.page_shield.policies.update(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None:
|
||||
policy = await async_client.page_shield.policies.update(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
action="allow",
|
||||
description="Checkout page CSP policy",
|
||||
|
|
@ -336,31 +357,31 @@ class TestAsyncPolicies:
|
|||
expression='ends_with(http.request.uri.path, "/checkout")',
|
||||
value="script-src 'none';",
|
||||
)
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
|
||||
response = await async_client.page_shield.policies.with_raw_response.update(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
policy = await response.parse()
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None:
|
||||
async with async_client.page_shield.policies.with_streaming_response.update(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
policy = await response.parse()
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyUpdateResponse], policy, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
@ -368,7 +389,7 @@ class TestAsyncPolicies:
|
|||
async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
|
||||
await async_client.page_shield.policies.with_raw_response.update(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="",
|
||||
)
|
||||
|
||||
|
|
@ -383,7 +404,7 @@ class TestAsyncPolicies:
|
|||
policy = await async_client.page_shield.policies.list(
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(AsyncSinglePage[Policy], policy, path=["response"])
|
||||
assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
|
||||
|
|
@ -394,7 +415,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(AsyncSinglePage[Policy], policy, path=["response"])
|
||||
assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None:
|
||||
|
|
@ -405,7 +426,7 @@ class TestAsyncPolicies:
|
|||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
policy = await response.parse()
|
||||
assert_matches_type(AsyncSinglePage[Policy], policy, path=["response"])
|
||||
assert_matches_type(AsyncSinglePage[PolicyListResponse], policy, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
@ -419,7 +440,7 @@ class TestAsyncPolicies:
|
|||
@parametrize
|
||||
async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
|
||||
policy = await async_client.page_shield.policies.delete(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert policy is None
|
||||
|
|
@ -427,7 +448,7 @@ class TestAsyncPolicies:
|
|||
@parametrize
|
||||
async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
|
||||
response = await async_client.page_shield.policies.with_raw_response.delete(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
|
|
@ -439,7 +460,7 @@ class TestAsyncPolicies:
|
|||
@parametrize
|
||||
async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None:
|
||||
async with async_client.page_shield.policies.with_streaming_response.delete(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
|
|
@ -454,7 +475,7 @@ class TestAsyncPolicies:
|
|||
async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
|
||||
await async_client.page_shield.policies.with_raw_response.delete(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="",
|
||||
)
|
||||
|
||||
|
|
@ -467,34 +488,34 @@ class TestAsyncPolicies:
|
|||
@parametrize
|
||||
async def test_method_get(self, async_client: AsyncCloudflare) -> None:
|
||||
policy = await async_client.page_shield.policies.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
|
||||
response = await async_client.page_shield.policies.with_raw_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
policy = await response.parse()
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
|
||||
async with async_client.page_shield.policies.with_streaming_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
policy = await response.parse()
|
||||
assert_matches_type(Policy, policy, path=["response"])
|
||||
assert_matches_type(Optional[PolicyGetResponse], policy, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
@ -502,7 +523,7 @@ class TestAsyncPolicies:
|
|||
async def test_path_params_get(self, async_client: AsyncCloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
|
||||
await async_client.page_shield.policies.with_raw_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="",
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import Any, cast
|
||||
from typing import Any, Optional, cast
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
@ -79,34 +79,34 @@ class TestScripts:
|
|||
@parametrize
|
||||
def test_method_get(self, client: Cloudflare) -> None:
|
||||
script = client.page_shield.scripts.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(ScriptGetResponse, script, path=["response"])
|
||||
assert_matches_type(Optional[ScriptGetResponse], script, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_raw_response_get(self, client: Cloudflare) -> None:
|
||||
response = client.page_shield.scripts.with_raw_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
script = response.parse()
|
||||
assert_matches_type(ScriptGetResponse, script, path=["response"])
|
||||
assert_matches_type(Optional[ScriptGetResponse], script, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_streaming_response_get(self, client: Cloudflare) -> None:
|
||||
with client.page_shield.scripts.with_streaming_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
script = response.parse()
|
||||
assert_matches_type(ScriptGetResponse, script, path=["response"])
|
||||
assert_matches_type(Optional[ScriptGetResponse], script, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ class TestScripts:
|
|||
def test_path_params_get(self, client: Cloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
|
||||
client.page_shield.scripts.with_raw_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="",
|
||||
)
|
||||
|
||||
|
|
@ -189,34 +189,34 @@ class TestAsyncScripts:
|
|||
@parametrize
|
||||
async def test_method_get(self, async_client: AsyncCloudflare) -> None:
|
||||
script = await async_client.page_shield.scripts.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(ScriptGetResponse, script, path=["response"])
|
||||
assert_matches_type(Optional[ScriptGetResponse], script, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
|
||||
response = await async_client.page_shield.scripts.with_raw_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
|
||||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
script = await response.parse()
|
||||
assert_matches_type(ScriptGetResponse, script, path=["response"])
|
||||
assert_matches_type(Optional[ScriptGetResponse], script, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
|
||||
async with async_client.page_shield.scripts.with_streaming_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
) as response:
|
||||
assert not response.is_closed
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
script = await response.parse()
|
||||
assert_matches_type(ScriptGetResponse, script, path=["response"])
|
||||
assert_matches_type(Optional[ScriptGetResponse], script, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
@ -224,7 +224,7 @@ class TestAsyncScripts:
|
|||
async def test_path_params_get(self, async_client: AsyncCloudflare) -> None:
|
||||
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
|
||||
await async_client.page_shield.scripts.with_raw_response.get(
|
||||
"c9ef84a6bf5e47138c75d95e2f933e8f",
|
||||
"023e105f4ecef8ad9ca31a8372d0c353",
|
||||
zone_id="",
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import Any, cast
|
||||
from typing import Any, Optional, cast
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ class TestPageShield:
|
|||
page_shield = client.page_shield.update(
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(PageShieldUpdateResponse, page_shield, path=["response"])
|
||||
assert_matches_type(Optional[PageShieldUpdateResponse], page_shield, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_method_update_with_all_params(self, client: Cloudflare) -> None:
|
||||
|
|
@ -32,7 +32,7 @@ class TestPageShield:
|
|||
use_cloudflare_reporting_endpoint=True,
|
||||
use_connection_url_path=True,
|
||||
)
|
||||
assert_matches_type(PageShieldUpdateResponse, page_shield, path=["response"])
|
||||
assert_matches_type(Optional[PageShieldUpdateResponse], page_shield, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_raw_response_update(self, client: Cloudflare) -> None:
|
||||
|
|
@ -43,7 +43,7 @@ class TestPageShield:
|
|||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
page_shield = response.parse()
|
||||
assert_matches_type(PageShieldUpdateResponse, page_shield, path=["response"])
|
||||
assert_matches_type(Optional[PageShieldUpdateResponse], page_shield, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_streaming_response_update(self, client: Cloudflare) -> None:
|
||||
|
|
@ -54,7 +54,7 @@ class TestPageShield:
|
|||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
page_shield = response.parse()
|
||||
assert_matches_type(PageShieldUpdateResponse, page_shield, path=["response"])
|
||||
assert_matches_type(Optional[PageShieldUpdateResponse], page_shield, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ class TestPageShield:
|
|||
page_shield = client.page_shield.get(
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Setting, page_shield, path=["response"])
|
||||
assert_matches_type(Optional[Setting], page_shield, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_raw_response_get(self, client: Cloudflare) -> None:
|
||||
|
|
@ -81,7 +81,7 @@ class TestPageShield:
|
|||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
page_shield = response.parse()
|
||||
assert_matches_type(Setting, page_shield, path=["response"])
|
||||
assert_matches_type(Optional[Setting], page_shield, path=["response"])
|
||||
|
||||
@parametrize
|
||||
def test_streaming_response_get(self, client: Cloudflare) -> None:
|
||||
|
|
@ -92,7 +92,7 @@ class TestPageShield:
|
|||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
page_shield = response.parse()
|
||||
assert_matches_type(Setting, page_shield, path=["response"])
|
||||
assert_matches_type(Optional[Setting], page_shield, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ class TestAsyncPageShield:
|
|||
page_shield = await async_client.page_shield.update(
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(PageShieldUpdateResponse, page_shield, path=["response"])
|
||||
assert_matches_type(Optional[PageShieldUpdateResponse], page_shield, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None:
|
||||
|
|
@ -122,7 +122,7 @@ class TestAsyncPageShield:
|
|||
use_cloudflare_reporting_endpoint=True,
|
||||
use_connection_url_path=True,
|
||||
)
|
||||
assert_matches_type(PageShieldUpdateResponse, page_shield, path=["response"])
|
||||
assert_matches_type(Optional[PageShieldUpdateResponse], page_shield, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
|
||||
|
|
@ -133,7 +133,7 @@ class TestAsyncPageShield:
|
|||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
page_shield = await response.parse()
|
||||
assert_matches_type(PageShieldUpdateResponse, page_shield, path=["response"])
|
||||
assert_matches_type(Optional[PageShieldUpdateResponse], page_shield, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None:
|
||||
|
|
@ -144,7 +144,7 @@ class TestAsyncPageShield:
|
|||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
page_shield = await response.parse()
|
||||
assert_matches_type(PageShieldUpdateResponse, page_shield, path=["response"])
|
||||
assert_matches_type(Optional[PageShieldUpdateResponse], page_shield, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ class TestAsyncPageShield:
|
|||
page_shield = await async_client.page_shield.get(
|
||||
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
|
||||
)
|
||||
assert_matches_type(Setting, page_shield, path=["response"])
|
||||
assert_matches_type(Optional[Setting], page_shield, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
|
||||
|
|
@ -171,7 +171,7 @@ class TestAsyncPageShield:
|
|||
assert response.is_closed is True
|
||||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
page_shield = await response.parse()
|
||||
assert_matches_type(Setting, page_shield, path=["response"])
|
||||
assert_matches_type(Optional[Setting], page_shield, path=["response"])
|
||||
|
||||
@parametrize
|
||||
async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None:
|
||||
|
|
@ -182,7 +182,7 @@ class TestAsyncPageShield:
|
|||
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
||||
|
||||
page_shield = await response.parse()
|
||||
assert_matches_type(Setting, page_shield, path=["response"])
|
||||
assert_matches_type(Optional[Setting], page_shield, path=["response"])
|
||||
|
||||
assert cast(Any, response.is_closed) is True
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue