Skip to content

Commit c07a179

Browse files
feat(api): api update
1 parent 8c98391 commit c07a179

File tree

7 files changed

+98
-26
lines changed

7 files changed

+98
-26
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 1741
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-21830db1e58667bb5491a9df74ec360aaf783d7185c216a2c897ec41657d4c80.yml
3-
openapi_spec_hash: ee3e7fffcac2e3aef9121af57fc1b56e
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-79b0883c50661fe0956591bd1f7067d5cebf7db5b45d7b5971554e5aad570699.yml
3+
openapi_spec_hash: 08e5d3e41fee4265e778fd22ed3ea93e
44
config_hash: d72c4fd125f1a13d55b0929439ad8189

src/cloudflare/resources/firewall/lockdowns.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ def create(
5555
zone_id: str,
5656
configurations: ConfigurationParam,
5757
urls: List[OverrideURL],
58+
description: str | NotGiven = NOT_GIVEN,
59+
paused: bool | NotGiven = NOT_GIVEN,
60+
priority: float | NotGiven = NOT_GIVEN,
5861
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5962
# The extra values given here take precedence over values defined on the client or passed to this method.
6063
extra_headers: Headers | None = None,
@@ -76,6 +79,15 @@ def create(
7679
entered URL will be escaped before use, which means you can only use simple
7780
wildcard patterns.
7881
82+
description: An informative summary of the rate limit. This value is sanitized and any tags
83+
will be removed.
84+
85+
paused: When true, indicates that the rule is currently paused.
86+
87+
priority: The priority of the rule to control the processing order. A lower number
88+
indicates higher priority. If not provided, any rules with a configured priority
89+
will be processed before rules without a priority.
90+
7991
extra_headers: Send extra headers
8092
8193
extra_query: Add additional query parameters to the request
@@ -92,6 +104,9 @@ def create(
92104
{
93105
"configurations": configurations,
94106
"urls": urls,
107+
"description": description,
108+
"paused": paused,
109+
"priority": priority,
95110
},
96111
lockdown_create_params.LockdownCreateParams,
97112
),
@@ -374,6 +389,9 @@ async def create(
374389
zone_id: str,
375390
configurations: ConfigurationParam,
376391
urls: List[OverrideURL],
392+
description: str | NotGiven = NOT_GIVEN,
393+
paused: bool | NotGiven = NOT_GIVEN,
394+
priority: float | NotGiven = NOT_GIVEN,
377395
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
378396
# The extra values given here take precedence over values defined on the client or passed to this method.
379397
extra_headers: Headers | None = None,
@@ -395,6 +413,15 @@ async def create(
395413
entered URL will be escaped before use, which means you can only use simple
396414
wildcard patterns.
397415
416+
description: An informative summary of the rate limit. This value is sanitized and any tags
417+
will be removed.
418+
419+
paused: When true, indicates that the rule is currently paused.
420+
421+
priority: The priority of the rule to control the processing order. A lower number
422+
indicates higher priority. If not provided, any rules with a configured priority
423+
will be processed before rules without a priority.
424+
398425
extra_headers: Send extra headers
399426
400427
extra_query: Add additional query parameters to the request
@@ -411,6 +438,9 @@ async def create(
411438
{
412439
"configurations": configurations,
413440
"urls": urls,
441+
"description": description,
442+
"paused": paused,
443+
"priority": priority,
414444
},
415445
lockdown_create_params.LockdownCreateParams,
416446
),

src/cloudflare/resources/firewall/ua_rules.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ def create(
6969
Args:
7070
zone_id: Defines an identifier.
7171
72-
configuration: The rule configuration.
73-
7472
mode: The action to apply to a matched request.
7573
7674
extra_headers: Send extra headers
@@ -369,8 +367,6 @@ async def create(
369367
Args:
370368
zone_id: Defines an identifier.
371369
372-
configuration: The rule configuration.
373-
374370
mode: The action to apply to a matched request.
375371
376372
extra_headers: Send extra headers

src/cloudflare/types/firewall/lockdown_create_params.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,19 @@ class LockdownCreateParams(TypedDict, total=False):
2828
You can use wildcards. Each entered URL will be escaped before use, which means
2929
you can only use simple wildcard patterns.
3030
"""
31+
32+
description: str
33+
"""An informative summary of the rate limit.
34+
35+
This value is sanitized and any tags will be removed.
36+
"""
37+
38+
paused: bool
39+
"""When true, indicates that the rule is currently paused."""
40+
41+
priority: float
42+
"""The priority of the rule to control the processing order.
43+
44+
A lower number indicates higher priority. If not provided, any rules with a
45+
configured priority will be processed before rules without a priority.
46+
"""

src/cloudflare/types/firewall/ua_rule_create_params.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Union
6-
from typing_extensions import Literal, Required, TypeAlias, TypedDict
7-
8-
from .asn_configuration_param import ASNConfigurationParam
9-
from .ipv6_configuration_param import IPV6ConfigurationParam
10-
from .country_configuration_param import CountryConfigurationParam
11-
from .access_rule_ip_configuration_param import AccessRuleIPConfigurationParam
12-
from .access_rule_cidr_configuration_param import AccessRuleCIDRConfigurationParam
5+
from typing_extensions import Literal, Required, TypedDict
136

147
__all__ = ["UARuleCreateParams", "Configuration"]
158

@@ -19,16 +12,17 @@ class UARuleCreateParams(TypedDict, total=False):
1912
"""Defines an identifier."""
2013

2114
configuration: Required[Configuration]
22-
"""The rule configuration."""
2315

2416
mode: Required[Literal["block", "challenge", "whitelist", "js_challenge", "managed_challenge"]]
2517
"""The action to apply to a matched request."""
2618

2719

28-
Configuration: TypeAlias = Union[
29-
AccessRuleIPConfigurationParam,
30-
IPV6ConfigurationParam,
31-
AccessRuleCIDRConfigurationParam,
32-
ASNConfigurationParam,
33-
CountryConfigurationParam,
34-
]
20+
class Configuration(TypedDict, total=False):
21+
target: Literal["ua"]
22+
"""The configuration target.
23+
24+
You must set the target to `ua` when specifying a user agent in the rule.
25+
"""
26+
27+
value: str
28+
"""the user agent to exactly match"""

tests/api_resources/firewall/test_lockdowns.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ def test_method_create(self, client: Cloudflare) -> None:
3232
)
3333
assert_matches_type(Lockdown, lockdown, path=["response"])
3434

35+
@pytest.mark.skip(reason="TODO: investigate broken test")
36+
@parametrize
37+
def test_method_create_with_all_params(self, client: Cloudflare) -> None:
38+
lockdown = client.firewall.lockdowns.create(
39+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
40+
configurations=[
41+
{
42+
"target": "ip",
43+
"value": "198.51.100.4",
44+
}
45+
],
46+
urls=["shop.example.com/*"],
47+
description="Prevent multiple login failures to mitigate brute force attacks",
48+
paused=False,
49+
priority=5,
50+
)
51+
assert_matches_type(Lockdown, lockdown, path=["response"])
52+
3553
@pytest.mark.skip(reason="TODO: investigate broken test")
3654
@parametrize
3755
def test_raw_response_create(self, client: Cloudflare) -> None:
@@ -300,6 +318,24 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None:
300318
)
301319
assert_matches_type(Lockdown, lockdown, path=["response"])
302320

321+
@pytest.mark.skip(reason="TODO: investigate broken test")
322+
@parametrize
323+
async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None:
324+
lockdown = await async_client.firewall.lockdowns.create(
325+
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
326+
configurations=[
327+
{
328+
"target": "ip",
329+
"value": "198.51.100.4",
330+
}
331+
],
332+
urls=["shop.example.com/*"],
333+
description="Prevent multiple login failures to mitigate brute force attacks",
334+
paused=False,
335+
priority=5,
336+
)
337+
assert_matches_type(Lockdown, lockdown, path=["response"])
338+
303339
@pytest.mark.skip(reason="TODO: investigate broken test")
304340
@parametrize
305341
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:

tests/api_resources/firewall/test_ua_rules.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None:
4040
ua_rule = client.firewall.ua_rules.create(
4141
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
4242
configuration={
43-
"target": "ip",
44-
"value": "198.51.100.4",
43+
"target": "ua",
44+
"value": "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)",
4545
},
4646
mode="challenge",
4747
)
@@ -329,8 +329,8 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare
329329
ua_rule = await async_client.firewall.ua_rules.create(
330330
zone_id="023e105f4ecef8ad9ca31a8372d0c353",
331331
configuration={
332-
"target": "ip",
333-
"value": "198.51.100.4",
332+
"target": "ua",
333+
"value": "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)",
334334
},
335335
mode="challenge",
336336
)

0 commit comments

Comments
 (0)