Skip to content

Commit 771c7e4

Browse files
committed
chore(fraud): update generated types and methods
1 parent 878e3d4 commit 771c7e4

4 files changed

Lines changed: 189 additions & 2 deletions

File tree

src/cloudflare/resources/fraud/fraud.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def update(
4949
self,
5050
*,
5151
zone_id: str,
52+
authentication_settings: fraud_update_params.AuthenticationSettings | Omit = omit,
5253
user_profiles: Literal["enabled", "disabled"] | Omit = omit,
5354
username_expressions: SequenceNotStr[str] | Omit = omit,
5455
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -69,6 +70,14 @@ def update(
6970
Args:
7071
zone_id: Identifier.
7172
73+
authentication_settings: Configuration for classifying login authentication outcomes based on the origin
74+
response. Requires `user_profiles` to be enabled.
75+
76+
- Success and failure criteria are independently updatable — sending only
77+
`success_criteria` leaves failure codes untouched, and vice versa.
78+
- Omit `authentication_settings` entirely to leave both unchanged.
79+
- Status codes must not overlap between success and failure criteria.
80+
7281
user_profiles: Whether Fraud User Profiles is enabled for the zone.
7382
7483
username_expressions: List of expressions to detect usernames in write HTTP requests.
@@ -93,6 +102,7 @@ def update(
93102
path_template("/zones/{zone_id}/fraud_detection/settings", zone_id=zone_id),
94103
body=maybe_transform(
95104
{
105+
"authentication_settings": authentication_settings,
96106
"user_profiles": user_profiles,
97107
"username_expressions": username_expressions,
98108
},
@@ -172,6 +182,7 @@ async def update(
172182
self,
173183
*,
174184
zone_id: str,
185+
authentication_settings: fraud_update_params.AuthenticationSettings | Omit = omit,
175186
user_profiles: Literal["enabled", "disabled"] | Omit = omit,
176187
username_expressions: SequenceNotStr[str] | Omit = omit,
177188
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -192,6 +203,14 @@ async def update(
192203
Args:
193204
zone_id: Identifier.
194205
206+
authentication_settings: Configuration for classifying login authentication outcomes based on the origin
207+
response. Requires `user_profiles` to be enabled.
208+
209+
- Success and failure criteria are independently updatable — sending only
210+
`success_criteria` leaves failure codes untouched, and vice versa.
211+
- Omit `authentication_settings` entirely to leave both unchanged.
212+
- Status codes must not overlap between success and failure criteria.
213+
195214
user_profiles: Whether Fraud User Profiles is enabled for the zone.
196215
197216
username_expressions: List of expressions to detect usernames in write HTTP requests.
@@ -216,6 +235,7 @@ async def update(
216235
path_template("/zones/{zone_id}/fraud_detection/settings", zone_id=zone_id),
217236
body=await async_maybe_transform(
218237
{
238+
"authentication_settings": authentication_settings,
219239
"user_profiles": user_profiles,
220240
"username_expressions": username_expressions,
221241
},

src/cloudflare/types/fraud/fraud_settings.py

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,78 @@
55

66
from ..._models import BaseModel
77

8-
__all__ = ["FraudSettings"]
8+
__all__ = [
9+
"FraudSettings",
10+
"AuthenticationSettings",
11+
"AuthenticationSettingsFailureCriteria",
12+
"AuthenticationSettingsSuccessCriteria",
13+
]
14+
15+
16+
class AuthenticationSettingsFailureCriteria(BaseModel):
17+
"""Criterion for identifying failed login responses."""
18+
19+
kind: Literal["status_code"]
20+
"""The type of criterion. Currently only `status_code` is supported."""
21+
22+
status_codes: Optional[List[int]] = None
23+
"""HTTP status codes to match against the origin response.
24+
25+
- Maximum of 10 codes per criterion.
26+
- Each code must be a valid HTTP status code (100-599).
27+
- Codes are deduplicated and sorted on save.
28+
- Omit to leave unchanged on update.
29+
- Provide an empty array `[]` to clear codes on update.
30+
"""
31+
32+
33+
class AuthenticationSettingsSuccessCriteria(BaseModel):
34+
"""Criterion for identifying successful login responses."""
35+
36+
kind: Literal["status_code"]
37+
"""The type of criterion. Currently only `status_code` is supported."""
38+
39+
status_codes: Optional[List[int]] = None
40+
"""HTTP status codes to match against the origin response.
41+
42+
- Maximum of 10 codes per criterion.
43+
- Each code must be a valid HTTP status code (100-599).
44+
- Codes are deduplicated and sorted on save.
45+
- Omit to leave unchanged on update.
46+
- Provide an empty array `[]` to clear codes on update.
47+
"""
48+
49+
50+
class AuthenticationSettings(BaseModel):
51+
"""
52+
Configuration for classifying login authentication outcomes based on the origin response.
53+
Requires `user_profiles` to be enabled.
54+
55+
- Success and failure criteria are independently updatable — sending only `success_criteria`
56+
leaves failure codes untouched, and vice versa.
57+
- Omit `authentication_settings` entirely to leave both unchanged.
58+
- Status codes must not overlap between success and failure criteria.
59+
"""
60+
61+
failure_criteria: Optional[AuthenticationSettingsFailureCriteria] = None
62+
"""Criterion for identifying failed login responses."""
63+
64+
success_criteria: Optional[AuthenticationSettingsSuccessCriteria] = None
65+
"""Criterion for identifying successful login responses."""
966

1067

1168
class FraudSettings(BaseModel):
69+
authentication_settings: Optional[AuthenticationSettings] = None
70+
"""
71+
Configuration for classifying login authentication outcomes based on the origin
72+
response. Requires `user_profiles` to be enabled.
73+
74+
- Success and failure criteria are independently updatable — sending only
75+
`success_criteria` leaves failure codes untouched, and vice versa.
76+
- Omit `authentication_settings` entirely to leave both unchanged.
77+
- Status codes must not overlap between success and failure criteria.
78+
"""
79+
1280
user_profiles: Optional[Literal["enabled", "disabled"]] = None
1381
"""Whether Fraud User Profiles is enabled for the zone."""
1482

src/cloudflare/types/fraud/fraud_update_params.py

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,34 @@
22

33
from __future__ import annotations
44

5+
from typing import Iterable
56
from typing_extensions import Literal, Required, TypedDict
67

78
from ..._types import SequenceNotStr
89

9-
__all__ = ["FraudUpdateParams"]
10+
__all__ = [
11+
"FraudUpdateParams",
12+
"AuthenticationSettings",
13+
"AuthenticationSettingsFailureCriteria",
14+
"AuthenticationSettingsSuccessCriteria",
15+
]
1016

1117

1218
class FraudUpdateParams(TypedDict, total=False):
1319
zone_id: Required[str]
1420
"""Identifier."""
1521

22+
authentication_settings: AuthenticationSettings
23+
"""
24+
Configuration for classifying login authentication outcomes based on the origin
25+
response. Requires `user_profiles` to be enabled.
26+
27+
- Success and failure criteria are independently updatable — sending only
28+
`success_criteria` leaves failure codes untouched, and vice versa.
29+
- Omit `authentication_settings` entirely to leave both unchanged.
30+
- Status codes must not overlap between success and failure criteria.
31+
"""
32+
1633
user_profiles: Literal["enabled", "disabled"]
1734
"""Whether Fraud User Profiles is enabled for the zone."""
1835

@@ -25,3 +42,55 @@ class FraudUpdateParams(TypedDict, total=False):
2542
- Invalid expressions will result in a 10400 Bad Request with details in the
2643
`messages` array.
2744
"""
45+
46+
47+
class AuthenticationSettingsFailureCriteria(TypedDict, total=False):
48+
"""Criterion for identifying failed login responses."""
49+
50+
kind: Required[Literal["status_code"]]
51+
"""The type of criterion. Currently only `status_code` is supported."""
52+
53+
status_codes: Iterable[int]
54+
"""HTTP status codes to match against the origin response.
55+
56+
- Maximum of 10 codes per criterion.
57+
- Each code must be a valid HTTP status code (100-599).
58+
- Codes are deduplicated and sorted on save.
59+
- Omit to leave unchanged on update.
60+
- Provide an empty array `[]` to clear codes on update.
61+
"""
62+
63+
64+
class AuthenticationSettingsSuccessCriteria(TypedDict, total=False):
65+
"""Criterion for identifying successful login responses."""
66+
67+
kind: Required[Literal["status_code"]]
68+
"""The type of criterion. Currently only `status_code` is supported."""
69+
70+
status_codes: Iterable[int]
71+
"""HTTP status codes to match against the origin response.
72+
73+
- Maximum of 10 codes per criterion.
74+
- Each code must be a valid HTTP status code (100-599).
75+
- Codes are deduplicated and sorted on save.
76+
- Omit to leave unchanged on update.
77+
- Provide an empty array `[]` to clear codes on update.
78+
"""
79+
80+
81+
class AuthenticationSettings(TypedDict, total=False):
82+
"""
83+
Configuration for classifying login authentication outcomes based on the origin response.
84+
Requires `user_profiles` to be enabled.
85+
86+
- Success and failure criteria are independently updatable — sending only `success_criteria`
87+
leaves failure codes untouched, and vice versa.
88+
- Omit `authentication_settings` entirely to leave both unchanged.
89+
- Status codes must not overlap between success and failure criteria.
90+
"""
91+
92+
failure_criteria: AuthenticationSettingsFailureCriteria
93+
"""Criterion for identifying failed login responses."""
94+
95+
success_criteria: AuthenticationSettingsSuccessCriteria
96+
"""Criterion for identifying successful login responses."""

tests/api_resources/test_fraud.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,35 @@
1717
class TestFraud:
1818
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
1919

20+
@pytest.mark.skip(reason="HTTP 422 error from prism")
2021
@parametrize
2122
def test_method_update(self, client: Cloudflare) -> None:
2223
fraud = client.fraud.update(
2324
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
2425
)
2526
assert_matches_type(Optional[FraudSettings], fraud, path=["response"])
2627

28+
@pytest.mark.skip(reason="HTTP 422 error from prism")
2729
@parametrize
2830
def test_method_update_with_all_params(self, client: Cloudflare) -> None:
2931
fraud = client.fraud.update(
3032
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
33+
authentication_settings={
34+
"failure_criteria": {
35+
"kind": "status_code",
36+
"status_codes": [200, 201],
37+
},
38+
"success_criteria": {
39+
"kind": "status_code",
40+
"status_codes": [200, 201],
41+
},
42+
},
3143
user_profiles="disabled",
3244
username_expressions=["string"],
3345
)
3446
assert_matches_type(Optional[FraudSettings], fraud, path=["response"])
3547

48+
@pytest.mark.skip(reason="HTTP 422 error from prism")
3649
@parametrize
3750
def test_raw_response_update(self, client: Cloudflare) -> None:
3851
response = client.fraud.with_raw_response.update(
@@ -44,6 +57,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None:
4457
fraud = response.parse()
4558
assert_matches_type(Optional[FraudSettings], fraud, path=["response"])
4659

60+
@pytest.mark.skip(reason="HTTP 422 error from prism")
4761
@parametrize
4862
def test_streaming_response_update(self, client: Cloudflare) -> None:
4963
with client.fraud.with_streaming_response.update(
@@ -57,6 +71,7 @@ def test_streaming_response_update(self, client: Cloudflare) -> None:
5771

5872
assert cast(Any, response.is_closed) is True
5973

74+
@pytest.mark.skip(reason="HTTP 422 error from prism")
6075
@parametrize
6176
def test_path_params_update(self, client: Cloudflare) -> None:
6277
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):
@@ -108,22 +123,35 @@ class TestAsyncFraud:
108123
"async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"]
109124
)
110125

126+
@pytest.mark.skip(reason="HTTP 422 error from prism")
111127
@parametrize
112128
async def test_method_update(self, async_client: AsyncCloudflare) -> None:
113129
fraud = await async_client.fraud.update(
114130
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
115131
)
116132
assert_matches_type(Optional[FraudSettings], fraud, path=["response"])
117133

134+
@pytest.mark.skip(reason="HTTP 422 error from prism")
118135
@parametrize
119136
async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None:
120137
fraud = await async_client.fraud.update(
121138
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
139+
authentication_settings={
140+
"failure_criteria": {
141+
"kind": "status_code",
142+
"status_codes": [200, 201],
143+
},
144+
"success_criteria": {
145+
"kind": "status_code",
146+
"status_codes": [200, 201],
147+
},
148+
},
122149
user_profiles="disabled",
123150
username_expressions=["string"],
124151
)
125152
assert_matches_type(Optional[FraudSettings], fraud, path=["response"])
126153

154+
@pytest.mark.skip(reason="HTTP 422 error from prism")
127155
@parametrize
128156
async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
129157
response = await async_client.fraud.with_raw_response.update(
@@ -135,6 +163,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
135163
fraud = await response.parse()
136164
assert_matches_type(Optional[FraudSettings], fraud, path=["response"])
137165

166+
@pytest.mark.skip(reason="HTTP 422 error from prism")
138167
@parametrize
139168
async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None:
140169
async with async_client.fraud.with_streaming_response.update(
@@ -148,6 +177,7 @@ async def test_streaming_response_update(self, async_client: AsyncCloudflare) ->
148177

149178
assert cast(Any, response.is_closed) is True
150179

180+
@pytest.mark.skip(reason="HTTP 422 error from prism")
151181
@parametrize
152182
async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
153183
with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"):

0 commit comments

Comments
 (0)