Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f7a03e2

Browse files
committedFeb 25, 2025·
feat(api): api update (#2474)
1 parent 277d4ee commit f7a03e2

File tree

7 files changed

+68
-71
lines changed

7 files changed

+68
-71
lines changed
 

‎.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 1542
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2f8a0617b1fa22b1c401d2276be0fd66dd2eee35c9005a9ea2d2deea7ee55637.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1b7e8a8d202a9d07964ed940d0213d0a0b90fbe9580df0f4586579f526c11eca.yml

‎src/cloudflare/resources/magic_network_monitoring/rules/rules.py

+13-24
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
from typing import List, Type, Optional, cast
6+
from typing_extensions import Literal
67

78
import httpx
89

@@ -64,7 +65,7 @@ def create(
6465
self,
6566
*,
6667
account_id: str,
67-
duration: str,
68+
duration: Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"],
6869
name: str,
6970
automatic_advertisement: Optional[bool] | NotGiven = NOT_GIVEN,
7071
bandwidth: float | NotGiven = NOT_GIVEN,
@@ -85,9 +86,7 @@ def create(
8586
Args:
8687
duration: The amount of time that the rule threshold must be exceeded to send an alert
8788
notification. The final value must be equivalent to one of the following 8
88-
values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is
89-
AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at
90-
least one unit must be provided.
89+
values ["1m","5m","10m","15m","20m","30m","45m","60m"].
9190
9291
name: The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9,
9392
underscore (\\__), dash (-), period (.), and tilde (~). You can’t have a space in
@@ -140,7 +139,7 @@ def update(
140139
self,
141140
*,
142141
account_id: str,
143-
duration: str,
142+
duration: Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"],
144143
name: str,
145144
id: str | NotGiven = NOT_GIVEN,
146145
automatic_advertisement: Optional[bool] | NotGiven = NOT_GIVEN,
@@ -160,9 +159,7 @@ def update(
160159
Args:
161160
duration: The amount of time that the rule threshold must be exceeded to send an alert
162161
notification. The final value must be equivalent to one of the following 8
163-
values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is
164-
AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at
165-
least one unit must be provided.
162+
values ["1m","5m","10m","15m","20m","30m","45m","60m"].
166163
167164
name: The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9,
168165
underscore (\\__), dash (-), period (.), and tilde (~). You can’t have a space in
@@ -297,7 +294,7 @@ def edit(
297294
account_id: str,
298295
automatic_advertisement: Optional[bool] | NotGiven = NOT_GIVEN,
299296
bandwidth: float | NotGiven = NOT_GIVEN,
300-
duration: str | NotGiven = NOT_GIVEN,
297+
duration: Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"] | NotGiven = NOT_GIVEN,
301298
name: str | NotGiven = NOT_GIVEN,
302299
packet_threshold: float | NotGiven = NOT_GIVEN,
303300
prefixes: List[str] | NotGiven = NOT_GIVEN,
@@ -323,9 +320,7 @@ def edit(
323320
324321
duration: The amount of time that the rule threshold must be exceeded to send an alert
325322
notification. The final value must be equivalent to one of the following 8
326-
values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is
327-
AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at
328-
least one unit must be provided.
323+
values ["1m","5m","10m","15m","20m","30m","45m","60m"].
329324
330325
name: The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9,
331326
underscore (\\__), dash (-), period (.), and tilde (~). You can’t have a space in
@@ -440,7 +435,7 @@ async def create(
440435
self,
441436
*,
442437
account_id: str,
443-
duration: str,
438+
duration: Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"],
444439
name: str,
445440
automatic_advertisement: Optional[bool] | NotGiven = NOT_GIVEN,
446441
bandwidth: float | NotGiven = NOT_GIVEN,
@@ -461,9 +456,7 @@ async def create(
461456
Args:
462457
duration: The amount of time that the rule threshold must be exceeded to send an alert
463458
notification. The final value must be equivalent to one of the following 8
464-
values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is
465-
AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at
466-
least one unit must be provided.
459+
values ["1m","5m","10m","15m","20m","30m","45m","60m"].
467460
468461
name: The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9,
469462
underscore (\\__), dash (-), period (.), and tilde (~). You can’t have a space in
@@ -516,7 +509,7 @@ async def update(
516509
self,
517510
*,
518511
account_id: str,
519-
duration: str,
512+
duration: Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"],
520513
name: str,
521514
id: str | NotGiven = NOT_GIVEN,
522515
automatic_advertisement: Optional[bool] | NotGiven = NOT_GIVEN,
@@ -536,9 +529,7 @@ async def update(
536529
Args:
537530
duration: The amount of time that the rule threshold must be exceeded to send an alert
538531
notification. The final value must be equivalent to one of the following 8
539-
values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is
540-
AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at
541-
least one unit must be provided.
532+
values ["1m","5m","10m","15m","20m","30m","45m","60m"].
542533
543534
name: The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9,
544535
underscore (\\__), dash (-), period (.), and tilde (~). You can’t have a space in
@@ -673,7 +664,7 @@ async def edit(
673664
account_id: str,
674665
automatic_advertisement: Optional[bool] | NotGiven = NOT_GIVEN,
675666
bandwidth: float | NotGiven = NOT_GIVEN,
676-
duration: str | NotGiven = NOT_GIVEN,
667+
duration: Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"] | NotGiven = NOT_GIVEN,
677668
name: str | NotGiven = NOT_GIVEN,
678669
packet_threshold: float | NotGiven = NOT_GIVEN,
679670
prefixes: List[str] | NotGiven = NOT_GIVEN,
@@ -699,9 +690,7 @@ async def edit(
699690
700691
duration: The amount of time that the rule threshold must be exceeded to send an alert
701692
notification. The final value must be equivalent to one of the following 8
702-
values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is
703-
AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at
704-
least one unit must be provided.
693+
values ["1m","5m","10m","15m","20m","30m","45m","60m"].
705694
706695
name: The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9,
707696
underscore (\\__), dash (-), period (.), and tilde (~). You can’t have a space in

‎src/cloudflare/types/magic_network_monitoring/magic_network_monitoring_rule.py

+23-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
from typing import List, Optional
4+
from typing_extensions import Literal
45

56
from ..._models import BaseModel
67

@@ -15,15 +16,6 @@ class MagicNetworkMonitoringRule(BaseModel):
1516
available for users of Magic Transit.
1617
"""
1718

18-
duration: str
19-
"""
20-
The amount of time that the rule threshold must be exceeded to send an alert
21-
notification. The final value must be equivalent to one of the following 8
22-
values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is
23-
AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at
24-
least one unit must be provided.
25-
"""
26-
2719
name: str
2820
"""The name of the rule.
2921
@@ -34,6 +26,9 @@ class MagicNetworkMonitoringRule(BaseModel):
3426

3527
prefixes: List[str]
3628

29+
type: Literal["threshold", "zscore", "advanced_ddos"]
30+
"""MNM rule type."""
31+
3732
id: Optional[str] = None
3833
"""The id of the rule. Must be unique."""
3934

@@ -44,9 +39,28 @@ class MagicNetworkMonitoringRule(BaseModel):
4439
Minimum of 1 and no maximum.
4540
"""
4641

42+
duration: Optional[Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"]] = None
43+
"""
44+
The amount of time that the rule threshold must be exceeded to send an alert
45+
notification. The final value must be equivalent to one of the following 8
46+
values ["1m","5m","10m","15m","20m","30m","45m","60m"].
47+
"""
48+
4749
packet_threshold: Optional[float] = None
4850
"""The number of packets per second for the rule.
4951
5052
When this value is exceeded for the set duration, an alert notification is sent.
5153
Minimum of 1 and no maximum.
5254
"""
55+
56+
prefix_match: Optional[Literal["exact", "subnet", "supernet"]] = None
57+
"""
58+
Prefix match type to be applied for a prefix auto advertisement when using an
59+
advanced_ddos rule.
60+
"""
61+
62+
zscore_sensitivity: Optional[Literal["low", "medium", "high"]] = None
63+
"""Level of sensitivity set for zscore rules."""
64+
65+
zscore_target: Optional[Literal["bits", "packets"]] = None
66+
"""Target of the zscore rule analysis."""

‎src/cloudflare/types/magic_network_monitoring/rule_create_params.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,19 @@
33
from __future__ import annotations
44

55
from typing import List, Optional
6-
from typing_extensions import Required, TypedDict
6+
from typing_extensions import Literal, Required, TypedDict
77

88
__all__ = ["RuleCreateParams"]
99

1010

1111
class RuleCreateParams(TypedDict, total=False):
1212
account_id: Required[str]
1313

14-
duration: Required[str]
14+
duration: Required[Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"]]
1515
"""
1616
The amount of time that the rule threshold must be exceeded to send an alert
1717
notification. The final value must be equivalent to one of the following 8
18-
values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is
19-
AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at
20-
least one unit must be provided.
18+
values ["1m","5m","10m","15m","20m","30m","45m","60m"].
2119
"""
2220

2321
name: Required[str]

‎src/cloudflare/types/magic_network_monitoring/rule_edit_params.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from typing import List, Optional
6-
from typing_extensions import Required, TypedDict
6+
from typing_extensions import Literal, Required, TypedDict
77

88
__all__ = ["RuleEditParams"]
99

@@ -25,13 +25,11 @@ class RuleEditParams(TypedDict, total=False):
2525
Minimum of 1 and no maximum.
2626
"""
2727

28-
duration: str
28+
duration: Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"]
2929
"""
3030
The amount of time that the rule threshold must be exceeded to send an alert
3131
notification. The final value must be equivalent to one of the following 8
32-
values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is
33-
AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at
34-
least one unit must be provided.
32+
values ["1m","5m","10m","15m","20m","30m","45m","60m"].
3533
"""
3634

3735
name: str

‎src/cloudflare/types/magic_network_monitoring/rule_update_params.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,19 @@
33
from __future__ import annotations
44

55
from typing import List, Optional
6-
from typing_extensions import Required, TypedDict
6+
from typing_extensions import Literal, Required, TypedDict
77

88
__all__ = ["RuleUpdateParams"]
99

1010

1111
class RuleUpdateParams(TypedDict, total=False):
1212
account_id: Required[str]
1313

14-
duration: Required[str]
14+
duration: Required[Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"]]
1515
"""
1616
The amount of time that the rule threshold must be exceeded to send an alert
1717
notification. The final value must be equivalent to one of the following 8
18-
values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is
19-
AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at
20-
least one unit must be provided.
18+
values ["1m","5m","10m","15m","20m","30m","45m","60m"].
2119
"""
2220

2321
name: Required[str]

‎tests/api_resources/magic_network_monitoring/test_rules.py

+22-22
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class TestRules:
2424
def test_method_create(self, client: Cloudflare) -> None:
2525
rule = client.magic_network_monitoring.rules.create(
2626
account_id="6f91088a406011ed95aed352566e8d4c",
27-
duration="300s",
27+
duration="1m",
2828
name="my_rule_1",
2929
)
3030
assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"])
@@ -33,7 +33,7 @@ def test_method_create(self, client: Cloudflare) -> None:
3333
def test_method_create_with_all_params(self, client: Cloudflare) -> None:
3434
rule = client.magic_network_monitoring.rules.create(
3535
account_id="6f91088a406011ed95aed352566e8d4c",
36-
duration="300s",
36+
duration="1m",
3737
name="my_rule_1",
3838
automatic_advertisement=True,
3939
bandwidth=1000,
@@ -46,7 +46,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None:
4646
def test_raw_response_create(self, client: Cloudflare) -> None:
4747
response = client.magic_network_monitoring.rules.with_raw_response.create(
4848
account_id="6f91088a406011ed95aed352566e8d4c",
49-
duration="300s",
49+
duration="1m",
5050
name="my_rule_1",
5151
)
5252

@@ -59,7 +59,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None:
5959
def test_streaming_response_create(self, client: Cloudflare) -> None:
6060
with client.magic_network_monitoring.rules.with_streaming_response.create(
6161
account_id="6f91088a406011ed95aed352566e8d4c",
62-
duration="300s",
62+
duration="1m",
6363
name="my_rule_1",
6464
) as response:
6565
assert not response.is_closed
@@ -75,7 +75,7 @@ def test_path_params_create(self, client: Cloudflare) -> None:
7575
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
7676
client.magic_network_monitoring.rules.with_raw_response.create(
7777
account_id="",
78-
duration="300s",
78+
duration="1m",
7979
name="my_rule_1",
8080
)
8181

@@ -84,7 +84,7 @@ def test_path_params_create(self, client: Cloudflare) -> None:
8484
def test_method_update(self, client: Cloudflare) -> None:
8585
rule = client.magic_network_monitoring.rules.update(
8686
account_id="6f91088a406011ed95aed352566e8d4c",
87-
duration="300s",
87+
duration="1m",
8888
name="my_rule_1",
8989
)
9090
assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"])
@@ -94,7 +94,7 @@ def test_method_update(self, client: Cloudflare) -> None:
9494
def test_method_update_with_all_params(self, client: Cloudflare) -> None:
9595
rule = client.magic_network_monitoring.rules.update(
9696
account_id="6f91088a406011ed95aed352566e8d4c",
97-
duration="300s",
97+
duration="1m",
9898
name="my_rule_1",
9999
id="2890e6fa406311ed9b5a23f70f6fb8cf",
100100
automatic_advertisement=True,
@@ -109,7 +109,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None:
109109
def test_raw_response_update(self, client: Cloudflare) -> None:
110110
response = client.magic_network_monitoring.rules.with_raw_response.update(
111111
account_id="6f91088a406011ed95aed352566e8d4c",
112-
duration="300s",
112+
duration="1m",
113113
name="my_rule_1",
114114
)
115115

@@ -123,7 +123,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None:
123123
def test_streaming_response_update(self, client: Cloudflare) -> None:
124124
with client.magic_network_monitoring.rules.with_streaming_response.update(
125125
account_id="6f91088a406011ed95aed352566e8d4c",
126-
duration="300s",
126+
duration="1m",
127127
name="my_rule_1",
128128
) as response:
129129
assert not response.is_closed
@@ -140,7 +140,7 @@ def test_path_params_update(self, client: Cloudflare) -> None:
140140
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
141141
client.magic_network_monitoring.rules.with_raw_response.update(
142142
account_id="",
143-
duration="300s",
143+
duration="1m",
144144
name="my_rule_1",
145145
)
146146

@@ -245,7 +245,7 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None:
245245
account_id="6f91088a406011ed95aed352566e8d4c",
246246
automatic_advertisement=True,
247247
bandwidth=1000,
248-
duration="300s",
248+
duration="1m",
249249
name="my_rule_1",
250250
packet_threshold=10000,
251251
prefixes=["203.0.113.1/32"],
@@ -348,7 +348,7 @@ class TestAsyncRules:
348348
async def test_method_create(self, async_client: AsyncCloudflare) -> None:
349349
rule = await async_client.magic_network_monitoring.rules.create(
350350
account_id="6f91088a406011ed95aed352566e8d4c",
351-
duration="300s",
351+
duration="1m",
352352
name="my_rule_1",
353353
)
354354
assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"])
@@ -357,7 +357,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None:
357357
async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None:
358358
rule = await async_client.magic_network_monitoring.rules.create(
359359
account_id="6f91088a406011ed95aed352566e8d4c",
360-
duration="300s",
360+
duration="1m",
361361
name="my_rule_1",
362362
automatic_advertisement=True,
363363
bandwidth=1000,
@@ -370,7 +370,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare
370370
async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
371371
response = await async_client.magic_network_monitoring.rules.with_raw_response.create(
372372
account_id="6f91088a406011ed95aed352566e8d4c",
373-
duration="300s",
373+
duration="1m",
374374
name="my_rule_1",
375375
)
376376

@@ -383,7 +383,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None:
383383
async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None:
384384
async with async_client.magic_network_monitoring.rules.with_streaming_response.create(
385385
account_id="6f91088a406011ed95aed352566e8d4c",
386-
duration="300s",
386+
duration="1m",
387387
name="my_rule_1",
388388
) as response:
389389
assert not response.is_closed
@@ -399,7 +399,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
399399
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
400400
await async_client.magic_network_monitoring.rules.with_raw_response.create(
401401
account_id="",
402-
duration="300s",
402+
duration="1m",
403403
name="my_rule_1",
404404
)
405405

@@ -408,7 +408,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None:
408408
async def test_method_update(self, async_client: AsyncCloudflare) -> None:
409409
rule = await async_client.magic_network_monitoring.rules.update(
410410
account_id="6f91088a406011ed95aed352566e8d4c",
411-
duration="300s",
411+
duration="1m",
412412
name="my_rule_1",
413413
)
414414
assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"])
@@ -418,7 +418,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None:
418418
async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None:
419419
rule = await async_client.magic_network_monitoring.rules.update(
420420
account_id="6f91088a406011ed95aed352566e8d4c",
421-
duration="300s",
421+
duration="1m",
422422
name="my_rule_1",
423423
id="2890e6fa406311ed9b5a23f70f6fb8cf",
424424
automatic_advertisement=True,
@@ -433,7 +433,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare
433433
async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
434434
response = await async_client.magic_network_monitoring.rules.with_raw_response.update(
435435
account_id="6f91088a406011ed95aed352566e8d4c",
436-
duration="300s",
436+
duration="1m",
437437
name="my_rule_1",
438438
)
439439

@@ -447,7 +447,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None:
447447
async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None:
448448
async with async_client.magic_network_monitoring.rules.with_streaming_response.update(
449449
account_id="6f91088a406011ed95aed352566e8d4c",
450-
duration="300s",
450+
duration="1m",
451451
name="my_rule_1",
452452
) as response:
453453
assert not response.is_closed
@@ -464,7 +464,7 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None:
464464
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
465465
await async_client.magic_network_monitoring.rules.with_raw_response.update(
466466
account_id="",
467-
duration="300s",
467+
duration="1m",
468468
name="my_rule_1",
469469
)
470470

@@ -569,7 +569,7 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare)
569569
account_id="6f91088a406011ed95aed352566e8d4c",
570570
automatic_advertisement=True,
571571
bandwidth=1000,
572-
duration="300s",
572+
duration="1m",
573573
name="my_rule_1",
574574
packet_threshold=10000,
575575
prefixes=["203.0.113.1/32"],

0 commit comments

Comments
 (0)
Please sign in to comment.