From ad13becb9bd2578b8fdd58b528e5cf481b5bc92c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 25 Feb 2025 18:34:28 +0000 Subject: [PATCH] feat(api): api update --- .stats.yml | 2 +- .../magic_network_monitoring/rules/rules.py | 37 ++++++---------- .../magic_network_monitoring_rule.py | 32 ++++++++++---- .../rule_create_params.py | 8 ++-- .../rule_edit_params.py | 8 ++-- .../rule_update_params.py | 8 ++-- .../magic_network_monitoring/test_rules.py | 44 +++++++++---------- 7 files changed, 68 insertions(+), 71 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7f4f9426c58..e8483f182fc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1542 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2f8a0617b1fa22b1c401d2276be0fd66dd2eee35c9005a9ea2d2deea7ee55637.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1b7e8a8d202a9d07964ed940d0213d0a0b90fbe9580df0f4586579f526c11eca.yml diff --git a/src/cloudflare/resources/magic_network_monitoring/rules/rules.py b/src/cloudflare/resources/magic_network_monitoring/rules/rules.py index 9427a504bc7..c7c9f26cce1 100644 --- a/src/cloudflare/resources/magic_network_monitoring/rules/rules.py +++ b/src/cloudflare/resources/magic_network_monitoring/rules/rules.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import List, Type, Optional, cast +from typing_extensions import Literal import httpx @@ -64,7 +65,7 @@ def create( self, *, account_id: str, - duration: str, + duration: Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"], name: str, automatic_advertisement: Optional[bool] | NotGiven = NOT_GIVEN, bandwidth: float | NotGiven = NOT_GIVEN, @@ -85,9 +86,7 @@ def create( Args: duration: The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 - values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is - AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at - least one unit must be provided. + values ["1m","5m","10m","15m","20m","30m","45m","60m"]. name: The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (\\__), dash (-), period (.), and tilde (~). You can’t have a space in @@ -140,7 +139,7 @@ def update( self, *, account_id: str, - duration: str, + duration: Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"], name: str, id: str | NotGiven = NOT_GIVEN, automatic_advertisement: Optional[bool] | NotGiven = NOT_GIVEN, @@ -160,9 +159,7 @@ def update( Args: duration: The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 - values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is - AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at - least one unit must be provided. + values ["1m","5m","10m","15m","20m","30m","45m","60m"]. name: The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (\\__), dash (-), period (.), and tilde (~). You can’t have a space in @@ -297,7 +294,7 @@ def edit( account_id: str, automatic_advertisement: Optional[bool] | NotGiven = NOT_GIVEN, bandwidth: float | NotGiven = NOT_GIVEN, - duration: str | NotGiven = NOT_GIVEN, + duration: Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"] | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, packet_threshold: float | NotGiven = NOT_GIVEN, prefixes: List[str] | NotGiven = NOT_GIVEN, @@ -323,9 +320,7 @@ def edit( duration: The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 - values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is - AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at - least one unit must be provided. + values ["1m","5m","10m","15m","20m","30m","45m","60m"]. name: The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (\\__), dash (-), period (.), and tilde (~). You can’t have a space in @@ -440,7 +435,7 @@ async def create( self, *, account_id: str, - duration: str, + duration: Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"], name: str, automatic_advertisement: Optional[bool] | NotGiven = NOT_GIVEN, bandwidth: float | NotGiven = NOT_GIVEN, @@ -461,9 +456,7 @@ async def create( Args: duration: The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 - values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is - AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at - least one unit must be provided. + values ["1m","5m","10m","15m","20m","30m","45m","60m"]. name: The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (\\__), dash (-), period (.), and tilde (~). You can’t have a space in @@ -516,7 +509,7 @@ async def update( self, *, account_id: str, - duration: str, + duration: Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"], name: str, id: str | NotGiven = NOT_GIVEN, automatic_advertisement: Optional[bool] | NotGiven = NOT_GIVEN, @@ -536,9 +529,7 @@ async def update( Args: duration: The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 - values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is - AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at - least one unit must be provided. + values ["1m","5m","10m","15m","20m","30m","45m","60m"]. name: The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (\\__), dash (-), period (.), and tilde (~). You can’t have a space in @@ -673,7 +664,7 @@ async def edit( account_id: str, automatic_advertisement: Optional[bool] | NotGiven = NOT_GIVEN, bandwidth: float | NotGiven = NOT_GIVEN, - duration: str | NotGiven = NOT_GIVEN, + duration: Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"] | NotGiven = NOT_GIVEN, name: str | NotGiven = NOT_GIVEN, packet_threshold: float | NotGiven = NOT_GIVEN, prefixes: List[str] | NotGiven = NOT_GIVEN, @@ -699,9 +690,7 @@ async def edit( duration: The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 - values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is - AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at - least one unit must be provided. + values ["1m","5m","10m","15m","20m","30m","45m","60m"]. name: The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (\\__), dash (-), period (.), and tilde (~). You can’t have a space in diff --git a/src/cloudflare/types/magic_network_monitoring/magic_network_monitoring_rule.py b/src/cloudflare/types/magic_network_monitoring/magic_network_monitoring_rule.py index 3dbb9d85afa..b9e8c6d7023 100644 --- a/src/cloudflare/types/magic_network_monitoring/magic_network_monitoring_rule.py +++ b/src/cloudflare/types/magic_network_monitoring/magic_network_monitoring_rule.py @@ -1,6 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from typing import List, Optional +from typing_extensions import Literal from ..._models import BaseModel @@ -15,15 +16,6 @@ class MagicNetworkMonitoringRule(BaseModel): available for users of Magic Transit. """ - duration: str - """ - The amount of time that the rule threshold must be exceeded to send an alert - notification. The final value must be equivalent to one of the following 8 - values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is - AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at - least one unit must be provided. - """ - name: str """The name of the rule. @@ -34,6 +26,9 @@ class MagicNetworkMonitoringRule(BaseModel): prefixes: List[str] + type: Literal["threshold", "zscore", "advanced_ddos"] + """MNM rule type.""" + id: Optional[str] = None """The id of the rule. Must be unique.""" @@ -44,9 +39,28 @@ class MagicNetworkMonitoringRule(BaseModel): Minimum of 1 and no maximum. """ + duration: Optional[Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"]] = None + """ + The amount of time that the rule threshold must be exceeded to send an alert + notification. The final value must be equivalent to one of the following 8 + values ["1m","5m","10m","15m","20m","30m","45m","60m"]. + """ + packet_threshold: Optional[float] = None """The number of packets per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. """ + + prefix_match: Optional[Literal["exact", "subnet", "supernet"]] = None + """ + Prefix match type to be applied for a prefix auto advertisement when using an + advanced_ddos rule. + """ + + zscore_sensitivity: Optional[Literal["low", "medium", "high"]] = None + """Level of sensitivity set for zscore rules.""" + + zscore_target: Optional[Literal["bits", "packets"]] = None + """Target of the zscore rule analysis.""" diff --git a/src/cloudflare/types/magic_network_monitoring/rule_create_params.py b/src/cloudflare/types/magic_network_monitoring/rule_create_params.py index 353c41693f0..b077e3efa43 100644 --- a/src/cloudflare/types/magic_network_monitoring/rule_create_params.py +++ b/src/cloudflare/types/magic_network_monitoring/rule_create_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import List, Optional -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict __all__ = ["RuleCreateParams"] @@ -11,13 +11,11 @@ class RuleCreateParams(TypedDict, total=False): account_id: Required[str] - duration: Required[str] + duration: Required[Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"]] """ The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 - values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is - AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at - least one unit must be provided. + values ["1m","5m","10m","15m","20m","30m","45m","60m"]. """ name: Required[str] diff --git a/src/cloudflare/types/magic_network_monitoring/rule_edit_params.py b/src/cloudflare/types/magic_network_monitoring/rule_edit_params.py index c11aaa9e787..d5757763a2e 100644 --- a/src/cloudflare/types/magic_network_monitoring/rule_edit_params.py +++ b/src/cloudflare/types/magic_network_monitoring/rule_edit_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import List, Optional -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict __all__ = ["RuleEditParams"] @@ -25,13 +25,11 @@ class RuleEditParams(TypedDict, total=False): Minimum of 1 and no maximum. """ - duration: str + duration: Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"] """ The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 - values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is - AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at - least one unit must be provided. + values ["1m","5m","10m","15m","20m","30m","45m","60m"]. """ name: str diff --git a/src/cloudflare/types/magic_network_monitoring/rule_update_params.py b/src/cloudflare/types/magic_network_monitoring/rule_update_params.py index 4c5920c7b6c..741b6f78ef5 100644 --- a/src/cloudflare/types/magic_network_monitoring/rule_update_params.py +++ b/src/cloudflare/types/magic_network_monitoring/rule_update_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import List, Optional -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict __all__ = ["RuleUpdateParams"] @@ -11,13 +11,11 @@ class RuleUpdateParams(TypedDict, total=False): account_id: Required[str] - duration: Required[str] + duration: Required[Literal["1m", "5m", "10m", "15m", "20m", "30m", "45m", "60m"]] """ The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 - values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is - AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at - least one unit must be provided. + values ["1m","5m","10m","15m","20m","30m","45m","60m"]. """ name: Required[str] diff --git a/tests/api_resources/magic_network_monitoring/test_rules.py b/tests/api_resources/magic_network_monitoring/test_rules.py index 7a95401cd0c..1f5cbdf0ea3 100644 --- a/tests/api_resources/magic_network_monitoring/test_rules.py +++ b/tests/api_resources/magic_network_monitoring/test_rules.py @@ -24,7 +24,7 @@ class TestRules: def test_method_create(self, client: Cloudflare) -> None: rule = client.magic_network_monitoring.rules.create( account_id="6f91088a406011ed95aed352566e8d4c", - duration="300s", + duration="1m", name="my_rule_1", ) assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) @@ -33,7 +33,7 @@ def test_method_create(self, client: Cloudflare) -> None: def test_method_create_with_all_params(self, client: Cloudflare) -> None: rule = client.magic_network_monitoring.rules.create( account_id="6f91088a406011ed95aed352566e8d4c", - duration="300s", + duration="1m", name="my_rule_1", automatic_advertisement=True, bandwidth=1000, @@ -46,7 +46,7 @@ def test_method_create_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_create(self, client: Cloudflare) -> None: response = client.magic_network_monitoring.rules.with_raw_response.create( account_id="6f91088a406011ed95aed352566e8d4c", - duration="300s", + duration="1m", name="my_rule_1", ) @@ -59,7 +59,7 @@ def test_raw_response_create(self, client: Cloudflare) -> None: def test_streaming_response_create(self, client: Cloudflare) -> None: with client.magic_network_monitoring.rules.with_streaming_response.create( account_id="6f91088a406011ed95aed352566e8d4c", - duration="300s", + duration="1m", name="my_rule_1", ) as response: assert not response.is_closed @@ -75,7 +75,7 @@ def test_path_params_create(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.magic_network_monitoring.rules.with_raw_response.create( account_id="", - duration="300s", + duration="1m", name="my_rule_1", ) @@ -84,7 +84,7 @@ def test_path_params_create(self, client: Cloudflare) -> None: def test_method_update(self, client: Cloudflare) -> None: rule = client.magic_network_monitoring.rules.update( account_id="6f91088a406011ed95aed352566e8d4c", - duration="300s", + duration="1m", name="my_rule_1", ) assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) @@ -94,7 +94,7 @@ def test_method_update(self, client: Cloudflare) -> None: def test_method_update_with_all_params(self, client: Cloudflare) -> None: rule = client.magic_network_monitoring.rules.update( account_id="6f91088a406011ed95aed352566e8d4c", - duration="300s", + duration="1m", name="my_rule_1", id="2890e6fa406311ed9b5a23f70f6fb8cf", automatic_advertisement=True, @@ -109,7 +109,7 @@ def test_method_update_with_all_params(self, client: Cloudflare) -> None: def test_raw_response_update(self, client: Cloudflare) -> None: response = client.magic_network_monitoring.rules.with_raw_response.update( account_id="6f91088a406011ed95aed352566e8d4c", - duration="300s", + duration="1m", name="my_rule_1", ) @@ -123,7 +123,7 @@ def test_raw_response_update(self, client: Cloudflare) -> None: def test_streaming_response_update(self, client: Cloudflare) -> None: with client.magic_network_monitoring.rules.with_streaming_response.update( account_id="6f91088a406011ed95aed352566e8d4c", - duration="300s", + duration="1m", name="my_rule_1", ) as response: assert not response.is_closed @@ -140,7 +140,7 @@ def test_path_params_update(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.magic_network_monitoring.rules.with_raw_response.update( account_id="", - duration="300s", + duration="1m", name="my_rule_1", ) @@ -245,7 +245,7 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: account_id="6f91088a406011ed95aed352566e8d4c", automatic_advertisement=True, bandwidth=1000, - duration="300s", + duration="1m", name="my_rule_1", packet_threshold=10000, prefixes=["203.0.113.1/32"], @@ -348,7 +348,7 @@ class TestAsyncRules: async def test_method_create(self, async_client: AsyncCloudflare) -> None: rule = await async_client.magic_network_monitoring.rules.create( account_id="6f91088a406011ed95aed352566e8d4c", - duration="300s", + duration="1m", name="my_rule_1", ) assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) @@ -357,7 +357,7 @@ async def test_method_create(self, async_client: AsyncCloudflare) -> None: async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: rule = await async_client.magic_network_monitoring.rules.create( account_id="6f91088a406011ed95aed352566e8d4c", - duration="300s", + duration="1m", name="my_rule_1", automatic_advertisement=True, bandwidth=1000, @@ -370,7 +370,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncCloudflare async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_network_monitoring.rules.with_raw_response.create( account_id="6f91088a406011ed95aed352566e8d4c", - duration="300s", + duration="1m", name="my_rule_1", ) @@ -383,7 +383,7 @@ async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_network_monitoring.rules.with_streaming_response.create( account_id="6f91088a406011ed95aed352566e8d4c", - duration="300s", + duration="1m", name="my_rule_1", ) as response: assert not response.is_closed @@ -399,7 +399,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.magic_network_monitoring.rules.with_raw_response.create( account_id="", - duration="300s", + duration="1m", name="my_rule_1", ) @@ -408,7 +408,7 @@ async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: async def test_method_update(self, async_client: AsyncCloudflare) -> None: rule = await async_client.magic_network_monitoring.rules.update( account_id="6f91088a406011ed95aed352566e8d4c", - duration="300s", + duration="1m", name="my_rule_1", ) assert_matches_type(Optional[MagicNetworkMonitoringRule], rule, path=["response"]) @@ -418,7 +418,7 @@ async def test_method_update(self, async_client: AsyncCloudflare) -> None: async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: rule = await async_client.magic_network_monitoring.rules.update( account_id="6f91088a406011ed95aed352566e8d4c", - duration="300s", + duration="1m", name="my_rule_1", id="2890e6fa406311ed9b5a23f70f6fb8cf", automatic_advertisement=True, @@ -433,7 +433,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncCloudflare async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: response = await async_client.magic_network_monitoring.rules.with_raw_response.update( account_id="6f91088a406011ed95aed352566e8d4c", - duration="300s", + duration="1m", name="my_rule_1", ) @@ -447,7 +447,7 @@ async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: async with async_client.magic_network_monitoring.rules.with_streaming_response.update( account_id="6f91088a406011ed95aed352566e8d4c", - duration="300s", + duration="1m", name="my_rule_1", ) as response: assert not response.is_closed @@ -464,7 +464,7 @@ async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.magic_network_monitoring.rules.with_raw_response.update( account_id="", - duration="300s", + duration="1m", name="my_rule_1", ) @@ -569,7 +569,7 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) account_id="6f91088a406011ed95aed352566e8d4c", automatic_advertisement=True, bandwidth=1000, - duration="300s", + duration="1m", name="my_rule_1", packet_threshold=10000, prefixes=["203.0.113.1/32"],