diff --git a/.stats.yml b/.stats.yml
index c1b84218a52..fdf1e9f7f3b 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -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
diff --git a/api.md b/api.md
index 1ecb3510f5f..0fcdd96ea84 100644
--- a/api.md
+++ b/api.md
@@ -3122,24 +3122,29 @@ from cloudflare.types.page_shield import Setting, PageShieldUpdateResponse
Methods:
-- client.page_shield.update(\*, zone_id, \*\*params) -> PageShieldUpdateResponse
-- client.page_shield.get(\*, zone_id) -> Setting
+- client.page_shield.update(\*, zone_id, \*\*params) -> Optional
+- client.page_shield.get(\*, zone_id) -> Optional
## Policies
Types:
```python
-from cloudflare.types.page_shield import Policy
+from cloudflare.types.page_shield import (
+ PolicyCreateResponse,
+ PolicyUpdateResponse,
+ PolicyListResponse,
+ PolicyGetResponse,
+)
```
Methods:
-- client.page_shield.policies.create(\*, zone_id, \*\*params) -> Policy
-- client.page_shield.policies.update(policy_id, \*, zone_id, \*\*params) -> Policy
-- client.page_shield.policies.list(\*, zone_id) -> SyncSinglePage[Policy]
+- client.page_shield.policies.create(\*, zone_id, \*\*params) -> Optional
+- client.page_shield.policies.update(policy_id, \*, zone_id, \*\*params) -> Optional
+- client.page_shield.policies.list(\*, zone_id) -> SyncSinglePage[PolicyListResponse]
- client.page_shield.policies.delete(policy_id, \*, zone_id) -> None
-- client.page_shield.policies.get(policy_id, \*, zone_id) -> Policy
+- client.page_shield.policies.get(policy_id, \*, zone_id) -> Optional
## Connections
@@ -3152,7 +3157,7 @@ from cloudflare.types.page_shield import Connection
Methods:
- client.page_shield.connections.list(\*, zone_id, \*\*params) -> SyncSinglePage[Connection]
-- client.page_shield.connections.get(connection_id, \*, zone_id) -> Connection
+- client.page_shield.connections.get(connection_id, \*, zone_id) -> Optional
## Scripts
@@ -3165,7 +3170,7 @@ from cloudflare.types.page_shield import Script, ScriptGetResponse
Methods:
- client.page_shield.scripts.list(\*, zone_id, \*\*params) -> SyncSinglePage[Script]
-- client.page_shield.scripts.get(script_id, \*, zone_id) -> ScriptGetResponse
+- client.page_shield.scripts.get(script_id, \*, zone_id) -> Optional
# Rulesets
diff --git a/src/cloudflare/resources/page_shield/connections.py b/src/cloudflare/resources/page_shield/connections.py
index c9d5a5c7c71..e961e1e4bc6 100644
--- a/src/cloudflare/resources/page_shield/connections.py
+++ b/src/cloudflare/resources/page_shield/connections.py
@@ -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 @@
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 @@ def get(
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 @@ def get(
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 @@ async def get(
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 @@ async def get(
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]),
)
diff --git a/src/cloudflare/resources/page_shield/page_shield.py b/src/cloudflare/resources/page_shield/page_shield.py
index ef88a6b37e0..655f3b4c4fd 100644
--- a/src/cloudflare/resources/page_shield/page_shield.py
+++ b/src/cloudflare/resources/page_shield/page_shield.py
@@ -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 @@ def update(
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 @@ def update(
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 @@ def get(
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 @@ def get(
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 @@ async def update(
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 @@ async def update(
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 @@ async def get(
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 @@ async def get(
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]),
)
diff --git a/src/cloudflare/resources/page_shield/policies.py b/src/cloudflare/resources/page_shield/policies.py
index 2a0ecdd591b..de2822019e7 100644
--- a/src/cloudflare/resources/page_shield/policies.py
+++ b/src/cloudflare/resources/page_shield/policies.py
@@ -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 @@
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 @@ def create(
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 @@ def create(
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 @@ def update(
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 @@ def update(
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 @@ def list(
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 @@ def list(
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 @@ def delete(
Args:
zone_id: Identifier
- policy_id: The ID of the policy.
+ policy_id: Identifier
extra_headers: Send extra headers
@@ -254,14 +267,14 @@ def get(
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 @@ def get(
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 @@ async def create(
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 @@ async def create(
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 @@ async def update(
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 @@ async def update(
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 @@ def list(
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 @@ def list(
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 @@ async def delete(
Args:
zone_id: Identifier
- policy_id: The ID of the policy.
+ policy_id: Identifier
extra_headers: Send extra headers
@@ -508,14 +533,14 @@ async def get(
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 @@ async def get(
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]),
)
diff --git a/src/cloudflare/resources/page_shield/scripts.py b/src/cloudflare/resources/page_shield/scripts.py
index 147bef3320b..2a3e556f7cc 100644
--- a/src/cloudflare/resources/page_shield/scripts.py
+++ b/src/cloudflare/resources/page_shield/scripts.py
@@ -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 @@
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 @@ def get(
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 @@ def get(
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 @@ async def get(
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 @@ async def get(
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]),
)
diff --git a/src/cloudflare/types/page_shield/__init__.py b/src/cloudflare/types/page_shield/__init__.py
index 6f07ca60629..1442bda6660 100644
--- a/src/cloudflare/types/page_shield/__init__.py
+++ b/src/cloudflare/types/page_shield/__init__.py
@@ -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
diff --git a/src/cloudflare/types/page_shield/connection.py b/src/cloudflare/types/page_shield/connection.py
index e89e575b52a..252091a2c85 100644
--- a/src/cloudflare/types/page_shield/connection.py
+++ b/src/cloudflare/types/page_shield/connection.py
@@ -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 @@
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
-
- host: Optional[str] = None
+ malicious_domain_categories: Optional[List[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
diff --git a/src/cloudflare/types/page_shield/page_shield_update_response.py b/src/cloudflare/types/page_shield/page_shield_update_response.py
index d0410913b2d..ad2852df732 100644
--- a/src/cloudflare/types/page_shield/page_shield_update_response.py
+++ b/src/cloudflare/types/page_shield/page_shield_update_response.py
@@ -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 @@
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."""
diff --git a/src/cloudflare/types/page_shield/policy_create_params.py b/src/cloudflare/types/page_shield/policy_create_params.py
index 724923121d7..6578a38230b 100644
--- a/src/cloudflare/types/page_shield/policy_create_params.py
+++ b/src/cloudflare/types/page_shield/policy_create_params.py
@@ -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"""
diff --git a/src/cloudflare/types/page_shield/policy.py b/src/cloudflare/types/page_shield/policy_create_response.py
similarity index 59%
rename from src/cloudflare/types/page_shield/policy.py
rename to src/cloudflare/types/page_shield/policy_create_response.py
index 3f838d934c7..483d2835764 100644
--- a/src/cloudflare/types/page_shield/policy.py
+++ b/src/cloudflare/types/page_shield/policy_create_response.py
@@ -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"""
diff --git a/src/cloudflare/types/page_shield/policy_get_response.py b/src/cloudflare/types/page_shield/policy_get_response.py
new file mode 100644
index 00000000000..3b28c295122
--- /dev/null
+++ b/src/cloudflare/types/page_shield/policy_get_response.py
@@ -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"""
diff --git a/src/cloudflare/types/page_shield/policy_list_response.py b/src/cloudflare/types/page_shield/policy_list_response.py
new file mode 100644
index 00000000000..5ce2180de2f
--- /dev/null
+++ b/src/cloudflare/types/page_shield/policy_list_response.py
@@ -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"""
diff --git a/src/cloudflare/types/page_shield/policy_update_response.py b/src/cloudflare/types/page_shield/policy_update_response.py
new file mode 100644
index 00000000000..dcc40a8c6cb
--- /dev/null
+++ b/src/cloudflare/types/page_shield/policy_update_response.py
@@ -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"""
diff --git a/src/cloudflare/types/page_shield/script.py b/src/cloudflare/types/page_shield/script.py
index 60d4a295f50..2db2c549968 100644
--- a/src/cloudflare/types/page_shield/script.py
+++ b/src/cloudflare/types/page_shield/script.py
@@ -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 @@
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
diff --git a/src/cloudflare/types/page_shield/script_get_response.py b/src/cloudflare/types/page_shield/script_get_response.py
index 171d5e24c6b..56d60bc2164 100644
--- a/src/cloudflare/types/page_shield/script_get_response.py
+++ b/src/cloudflare/types/page_shield/script_get_response.py
@@ -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
diff --git a/src/cloudflare/types/page_shield/setting.py b/src/cloudflare/types/page_shield/setting.py
index fee7e5dc567..46e4fd6da65 100644
--- a/src/cloudflare/types/page_shield/setting.py
+++ b/src/cloudflare/types/page_shield/setting.py
@@ -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 @@
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."""
diff --git a/tests/api_resources/page_shield/test_connections.py b/tests/api_resources/page_shield/test_connections.py
index f0a138460d7..74e8e45713e 100644
--- a/tests/api_resources/page_shield/test_connections.py
+++ b/tests/api_resources/page_shield/test_connections.py
@@ -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 @@ def test_path_params_list(self, client: Cloudflare) -> None:
@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 @@ def test_streaming_response_get(self, client: Cloudflare) -> None:
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 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None:
@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 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No
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="",
)
diff --git a/tests/api_resources/page_shield/test_policies.py b/tests/api_resources/page_shield/test_policies.py
index 500d4d23d0e..d2ff101721c 100644
--- a/tests/api_resources/page_shield/test_policies.py
+++ b/tests/api_resources/page_shield/test_policies.py
@@ -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")
@@ -20,13 +25,6 @@ class TestPolicies:
@parametrize
def test_method_create(self, client: Cloudflare) -> None:
- policy = client.page_shield.policies.create(
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- )
- assert_matches_type(Policy, policy, path=["response"])
-
- @parametrize
- def test_method_create_with_all_params(self, client: Cloudflare) -> None:
policy = client.page_shield.policies.create(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
action="allow",
@@ -35,29 +33,39 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None:
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_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",
+ enabled=True,
+ expression='ends_with(http.request.uri.path, "/checkout")',
+ value="script-src 'none';",
)
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 @@ def test_path_params_create(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.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 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None:
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 @@ def test_streaming_response_update(self, client: Cloudflare) -> None:
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 @@ def test_method_list(self, client: Cloudflare) -> None:
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 @@ def test_raw_response_list(self, client: Cloudflare) -> None:
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 @@ def test_streaming_response_list(self, client: Cloudflare) -> None:
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 @@ def test_path_params_list(self, client: Cloudflare) -> None:
@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 @@ def test_method_delete(self, client: Cloudflare) -> None:
@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 @@ def test_raw_response_delete(self, client: Cloudflare) -> None:
@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 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None:
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 @@ def test_path_params_delete(self, client: Cloudflare) -> None:
@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 @@ def test_streaming_response_get(self, client: Cloudflare) -> None:
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="",
)
@@ -269,13 +282,6 @@ class TestAsyncPolicies:
@parametrize
async def test_method_create(self, async_client: AsyncCloudflare) -> None:
- policy = await async_client.page_shield.policies.create(
- zone_id="023e105f4ecef8ad9ca31a8372d0c353",
- )
- assert_matches_type(Policy, 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(
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
action="allow",
@@ -284,29 +290,39 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare
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_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",
+ enabled=True,
+ expression='ends_with(http.request.uri.path, "/checkout")',
+ value="script-src 'none';",
)
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 @@ async def test_path_params_create(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.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 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare
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 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) ->
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 @@ async def test_method_list(self, async_client: AsyncCloudflare) -> None:
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 @@ async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None:
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 @@ async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> N
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 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None:
@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 @@ async def test_method_delete(self, async_client: AsyncCloudflare) -> None:
@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 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None:
@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 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) ->
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 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None:
@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 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No
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="",
)
diff --git a/tests/api_resources/page_shield/test_scripts.py b/tests/api_resources/page_shield/test_scripts.py
index a93e18c8b85..c874f315be8 100644
--- a/tests/api_resources/page_shield/test_scripts.py
+++ b/tests/api_resources/page_shield/test_scripts.py
@@ -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 @@ def test_path_params_list(self, client: Cloudflare) -> None:
@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 @@ def test_streaming_response_get(self, client: Cloudflare) -> None:
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 @@ async def test_path_params_list(self, async_client: AsyncCloudflare) -> None:
@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 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No
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="",
)
diff --git a/tests/api_resources/test_page_shield.py b/tests/api_resources/test_page_shield.py
index 9e7112a8b9c..2511ba986b2 100644
--- a/tests/api_resources/test_page_shield.py
+++ b/tests/api_resources/test_page_shield.py
@@ -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 @@ def test_method_update(self, client: Cloudflare) -> None:
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 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None:
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 @@ def test_raw_response_update(self, client: Cloudflare) -> None:
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 @@ def test_streaming_response_update(self, client: Cloudflare) -> None:
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 @@ def test_method_get(self, client: Cloudflare) -> None:
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 @@ def test_raw_response_get(self, client: Cloudflare) -> None:
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 @@ def test_streaming_response_get(self, client: Cloudflare) -> None:
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 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None:
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 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare
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 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
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 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) ->
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 @@ async def test_method_get(self, async_client: AsyncCloudflare) -> None:
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 @@ async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None:
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 @@ async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> No
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