diff --git a/api.md b/api.md index 96230c4792a..45ee4f73741 100644 --- a/api.md +++ b/api.md @@ -2932,7 +2932,11 @@ Types: ```python from cloudflare.types import ( + BlockRule, + ExecuteRule, + LogRule, Ruleset, + SkipRule, RulesetCreateResponse, RulesetUpdateResponse, RulesetGetResponse, diff --git a/src/cloudflare/resources/rulesets/rules.py b/src/cloudflare/resources/rulesets/rules.py index d8031bc9a4f..826ab6a3b4c 100644 --- a/src/cloudflare/resources/rulesets/rules.py +++ b/src/cloudflare/resources/rulesets/rules.py @@ -55,7 +55,7 @@ def create( zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, action: Literal["block"] | NotGiven = NOT_GIVEN, - action_parameters: rule_create_params.RulesetsBlockRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.BlockRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -115,7 +115,7 @@ def create( zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, action: Literal["execute"] | NotGiven = NOT_GIVEN, - action_parameters: rule_create_params.RulesetsExecuteRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.ExecuteRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -235,7 +235,7 @@ def create( zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, action: Literal["skip"] | NotGiven = NOT_GIVEN, - action_parameters: rule_create_params.RulesetsSkipRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.SkipRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -294,10 +294,10 @@ def create( zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, action: Literal["block"] | Literal["execute"] | Literal["log"] | Literal["skip"] | NotGiven = NOT_GIVEN, - action_parameters: rule_create_params.RulesetsBlockRuleActionParameters - | rule_create_params.RulesetsExecuteRuleActionParameters + action_parameters: rule_create_params.BlockRuleActionParameters + | rule_create_params.ExecuteRuleActionParameters | object - | rule_create_params.RulesetsSkipRuleActionParameters + | rule_create_params.SkipRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, @@ -428,7 +428,7 @@ def edit( zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, action: Literal["block"] | NotGiven = NOT_GIVEN, - action_parameters: rule_edit_params.RulesetsBlockRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.BlockRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -489,7 +489,7 @@ def edit( zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, action: Literal["execute"] | NotGiven = NOT_GIVEN, - action_parameters: rule_edit_params.RulesetsExecuteRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.ExecuteRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -611,7 +611,7 @@ def edit( zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, action: Literal["skip"] | NotGiven = NOT_GIVEN, - action_parameters: rule_edit_params.RulesetsSkipRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.SkipRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -672,10 +672,10 @@ def edit( zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, action: Literal["block"] | Literal["execute"] | Literal["log"] | Literal["skip"] | NotGiven = NOT_GIVEN, - action_parameters: rule_edit_params.RulesetsBlockRuleActionParameters - | rule_edit_params.RulesetsExecuteRuleActionParameters + action_parameters: rule_edit_params.BlockRuleActionParameters + | rule_edit_params.ExecuteRuleActionParameters | object - | rule_edit_params.RulesetsSkipRuleActionParameters + | rule_edit_params.SkipRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, @@ -752,7 +752,7 @@ async def create( zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, action: Literal["block"] | NotGiven = NOT_GIVEN, - action_parameters: rule_create_params.RulesetsBlockRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.BlockRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -812,7 +812,7 @@ async def create( zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, action: Literal["execute"] | NotGiven = NOT_GIVEN, - action_parameters: rule_create_params.RulesetsExecuteRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.ExecuteRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -932,7 +932,7 @@ async def create( zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, action: Literal["skip"] | NotGiven = NOT_GIVEN, - action_parameters: rule_create_params.RulesetsSkipRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.SkipRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -991,10 +991,10 @@ async def create( zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, action: Literal["block"] | Literal["execute"] | Literal["log"] | Literal["skip"] | NotGiven = NOT_GIVEN, - action_parameters: rule_create_params.RulesetsBlockRuleActionParameters - | rule_create_params.RulesetsExecuteRuleActionParameters + action_parameters: rule_create_params.BlockRuleActionParameters + | rule_create_params.ExecuteRuleActionParameters | object - | rule_create_params.RulesetsSkipRuleActionParameters + | rule_create_params.SkipRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, @@ -1125,7 +1125,7 @@ async def edit( zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, action: Literal["block"] | NotGiven = NOT_GIVEN, - action_parameters: rule_edit_params.RulesetsBlockRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.BlockRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -1186,7 +1186,7 @@ async def edit( zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, action: Literal["execute"] | NotGiven = NOT_GIVEN, - action_parameters: rule_edit_params.RulesetsExecuteRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.ExecuteRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -1308,7 +1308,7 @@ async def edit( zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, action: Literal["skip"] | NotGiven = NOT_GIVEN, - action_parameters: rule_edit_params.RulesetsSkipRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.SkipRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -1369,10 +1369,10 @@ async def edit( zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, action: Literal["block"] | Literal["execute"] | Literal["log"] | Literal["skip"] | NotGiven = NOT_GIVEN, - action_parameters: rule_edit_params.RulesetsBlockRuleActionParameters - | rule_edit_params.RulesetsExecuteRuleActionParameters + action_parameters: rule_edit_params.BlockRuleActionParameters + | rule_edit_params.ExecuteRuleActionParameters | object - | rule_edit_params.RulesetsSkipRuleActionParameters + | rule_edit_params.SkipRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, diff --git a/src/cloudflare/types/__init__.py b/src/cloudflare/types/__init__.py index 4df660b2fd5..ec8f1cc5d37 100644 --- a/src/cloudflare/types/__init__.py +++ b/src/cloudflare/types/__init__.py @@ -42,12 +42,15 @@ from .snippet import Snippet as Snippet from .edge_ips import EdgeIPs as EdgeIPs from .hostname import Hostname as Hostname +from .log_rule import LogRule as LogRule from .settings import Settings as Settings from .calls_app import CallsApp as CallsApp from .component import Component as Component from .dns_param import DNSParam as DNSParam from .page_rule import PageRule as PageRule from .rate_plan import RatePlan as RatePlan +from .skip_rule import SkipRule as SkipRule +from .block_rule import BlockRule as BlockRule from .d1_binding import D1Binding as D1Binding from .hyperdrive import Hyperdrive as Hyperdrive from .membership import Membership as Membership @@ -61,6 +64,7 @@ from .route_param import RouteParam as RouteParam from .rules_param import RulesParam as RulesParam from .check_region import CheckRegion as CheckRegion +from .execute_rule import ExecuteRule as ExecuteRule from .header_param import HeaderParam as HeaderParam from .health_check import HealthCheck as HealthCheck from .origin_param import OriginParam as OriginParam @@ -77,6 +81,7 @@ from .hostname_param import HostnameParam as HostnameParam from .ip_list_params import IPListParams as IPListParams from .labeled_region import LabeledRegion as LabeledRegion +from .log_rule_param import LogRuleParam as LogRuleParam from .warp_connector import WARPConnector as WARPConnector from .allowed_origins import AllowedOrigins as AllowedOrigins from .custom_hostname import CustomHostname as CustomHostname @@ -84,7 +89,9 @@ from .origin_steering import OriginSteering as OriginSteering from .random_steering import RandomSteering as RandomSteering from .service_binding import ServiceBinding as ServiceBinding +from .skip_rule_param import SkipRuleParam as SkipRuleParam from .adaptive_routing import AdaptiveRouting as AdaptiveRouting +from .block_rule_param import BlockRuleParam as BlockRuleParam from .geo_restrictions import GeoRestrictions as GeoRestrictions from .ip_list_response import IPListResponse as IPListResponse from .mtls_certificate import MTLSCertificate as MTLSCertificate @@ -109,6 +116,7 @@ from .client_certificate import ClientCertificate as ClientCertificate from .custom_certificate import CustomCertificate as CustomCertificate from .dnssec_edit_params import DNSSECEditParams as DNSSECEditParams +from .execute_rule_param import ExecuteRuleParam as ExecuteRuleParam from .filter_list_params import FilterListParams as FilterListParams from .health_check_param import HealthCheckParam as HealthCheckParam from .http_configuration import HTTPConfiguration as HTTPConfiguration diff --git a/src/cloudflare/types/block_rule.py b/src/cloudflare/types/block_rule.py new file mode 100644 index 00000000000..892d6e2b4f2 --- /dev/null +++ b/src/cloudflare/types/block_rule.py @@ -0,0 +1,61 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c +from .._models import BaseModel + +__all__ = ["BlockRule", "ActionParameters", "ActionParametersResponse"] + + +class ActionParametersResponse(BaseModel): + content: str + """The content to return.""" + + content_type: str + """The type of the content to return.""" + + status_code: int + """The status code to return.""" + + +class ActionParameters(BaseModel): + response: Optional[ActionParametersResponse] = None + """The response to show when the block is applied.""" + + +class BlockRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["block"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[ActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" diff --git a/src/cloudflare/types/block_rule_param.py b/src/cloudflare/types/block_rule_param.py new file mode 100644 index 00000000000..4aeafe363ae --- /dev/null +++ b/src/cloudflare/types/block_rule_param.py @@ -0,0 +1,51 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +from ..types import shared_params + +__all__ = ["BlockRuleParam", "ActionParameters", "ActionParametersResponse"] + + +class ActionParametersResponse(TypedDict, total=False): + content: Required[str] + """The content to return.""" + + content_type: Required[str] + """The type of the content to return.""" + + status_code: Required[int] + """The status code to return.""" + + +class ActionParameters(TypedDict, total=False): + response: ActionParametersResponse + """The response to show when the block is applied.""" + + +class BlockRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["block"] + """The action to perform when the rule matches.""" + + action_parameters: ActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: shared_params.UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" diff --git a/src/cloudflare/types/execute_rule.py b/src/cloudflare/types/execute_rule.py new file mode 100644 index 00000000000..0ef99597a8f --- /dev/null +++ b/src/cloudflare/types/execute_rule.py @@ -0,0 +1,129 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c +from .._models import BaseModel + +__all__ = [ + "ExecuteRule", + "ActionParameters", + "ActionParametersMatchedData", + "ActionParametersOverrides", + "ActionParametersOverridesCategory", + "ActionParametersOverridesRule", +] + + +class ActionParametersMatchedData(BaseModel): + public_key: str + """The public key to encrypt matched data logs with.""" + + +class ActionParametersOverridesCategory(BaseModel): + category: str + """The name of the category to override.""" + + action: Optional[str] = None + """The action to override rules in the category with.""" + + enabled: Optional[bool] = None + """Whether to enable execution of rules in the category.""" + + sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None + """The sensitivity level to use for rules in the category.""" + + +class ActionParametersOverridesRule(BaseModel): + id: str + """The ID of the rule to override.""" + + action: Optional[str] = None + """The action to override the rule with.""" + + enabled: Optional[bool] = None + """Whether to enable execution of the rule.""" + + score_threshold: Optional[int] = None + """The score threshold to use for the rule.""" + + sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None + """The sensitivity level to use for the rule.""" + + +class ActionParametersOverrides(BaseModel): + action: Optional[str] = None + """An action to override all rules with. + + This option has lower precedence than rule and category overrides. + """ + + categories: Optional[List[ActionParametersOverridesCategory]] = None + """A list of category-level overrides. + + This option has the second-highest precedence after rule-level overrides. + """ + + enabled: Optional[bool] = None + """Whether to enable execution of all rules. + + This option has lower precedence than rule and category overrides. + """ + + rules: Optional[List[ActionParametersOverridesRule]] = None + """A list of rule-level overrides. This option has the highest precedence.""" + + sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None + """A sensitivity level to set for all rules. + + This option has lower precedence than rule and category overrides and is only + applicable for DDoS phases. + """ + + +class ActionParameters(BaseModel): + id: str + """The ID of the ruleset to execute.""" + + matched_data: Optional[ActionParametersMatchedData] = None + """The configuration to use for matched data logging.""" + + overrides: Optional[ActionParametersOverrides] = None + """A set of overrides to apply to the target ruleset.""" + + +class ExecuteRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["execute"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[ActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" diff --git a/src/cloudflare/types/execute_rule_param.py b/src/cloudflare/types/execute_rule_param.py new file mode 100644 index 00000000000..fa4d5b253dc --- /dev/null +++ b/src/cloudflare/types/execute_rule_param.py @@ -0,0 +1,120 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Iterable +from typing_extensions import Literal, Required, TypedDict + +from ..types import shared_params + +__all__ = [ + "ExecuteRuleParam", + "ActionParameters", + "ActionParametersMatchedData", + "ActionParametersOverrides", + "ActionParametersOverridesCategory", + "ActionParametersOverridesRule", +] + + +class ActionParametersMatchedData(TypedDict, total=False): + public_key: Required[str] + """The public key to encrypt matched data logs with.""" + + +class ActionParametersOverridesCategory(TypedDict, total=False): + category: Required[str] + """The name of the category to override.""" + + action: str + """The action to override rules in the category with.""" + + enabled: bool + """Whether to enable execution of rules in the category.""" + + sensitivity_level: Literal["default", "medium", "low", "eoff"] + """The sensitivity level to use for rules in the category.""" + + +class ActionParametersOverridesRule(TypedDict, total=False): + id: Required[str] + """The ID of the rule to override.""" + + action: str + """The action to override the rule with.""" + + enabled: bool + """Whether to enable execution of the rule.""" + + score_threshold: int + """The score threshold to use for the rule.""" + + sensitivity_level: Literal["default", "medium", "low", "eoff"] + """The sensitivity level to use for the rule.""" + + +class ActionParametersOverrides(TypedDict, total=False): + action: str + """An action to override all rules with. + + This option has lower precedence than rule and category overrides. + """ + + categories: Iterable[ActionParametersOverridesCategory] + """A list of category-level overrides. + + This option has the second-highest precedence after rule-level overrides. + """ + + enabled: bool + """Whether to enable execution of all rules. + + This option has lower precedence than rule and category overrides. + """ + + rules: Iterable[ActionParametersOverridesRule] + """A list of rule-level overrides. This option has the highest precedence.""" + + sensitivity_level: Literal["default", "medium", "low", "eoff"] + """A sensitivity level to set for all rules. + + This option has lower precedence than rule and category overrides and is only + applicable for DDoS phases. + """ + + +class ActionParameters(TypedDict, total=False): + id: Required[str] + """The ID of the ruleset to execute.""" + + matched_data: ActionParametersMatchedData + """The configuration to use for matched data logging.""" + + overrides: ActionParametersOverrides + """A set of overrides to apply to the target ruleset.""" + + +class ExecuteRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["execute"] + """The action to perform when the rule matches.""" + + action_parameters: ActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: shared_params.UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" diff --git a/src/cloudflare/types/log_rule.py b/src/cloudflare/types/log_rule.py new file mode 100644 index 00000000000..b9a76d3dbba --- /dev/null +++ b/src/cloudflare/types/log_rule.py @@ -0,0 +1,45 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c +from .._models import BaseModel + +__all__ = ["LogRule"] + + +class LogRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["log"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[object] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" diff --git a/src/cloudflare/types/log_rule_param.py b/src/cloudflare/types/log_rule_param.py new file mode 100644 index 00000000000..344e1b35a81 --- /dev/null +++ b/src/cloudflare/types/log_rule_param.py @@ -0,0 +1,35 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, TypedDict + +from ..types import shared_params + +__all__ = ["LogRuleParam"] + + +class LogRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["log"] + """The action to perform when the rule matches.""" + + action_parameters: object + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: shared_params.UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" diff --git a/src/cloudflare/types/ruleset_create_params.py b/src/cloudflare/types/ruleset_create_params.py index cea7f724ade..d839409a395 100644 --- a/src/cloudflare/types/ruleset_create_params.py +++ b/src/cloudflare/types/ruleset_create_params.py @@ -2,27 +2,15 @@ from __future__ import annotations -from typing import Dict, List, Union, Iterable +from typing import Union, Iterable from typing_extensions import Literal, Required, TypedDict -from ..types import shared_params +from .log_rule_param import LogRuleParam +from .skip_rule_param import SkipRuleParam +from .block_rule_param import BlockRuleParam +from .execute_rule_param import ExecuteRuleParam -__all__ = [ - "RulesetCreateParams", - "Rule", - "RuleRulesetsBlockRule", - "RuleRulesetsBlockRuleActionParameters", - "RuleRulesetsBlockRuleActionParametersResponse", - "RuleRulesetsExecuteRule", - "RuleRulesetsExecuteRuleActionParameters", - "RuleRulesetsExecuteRuleActionParametersMatchedData", - "RuleRulesetsExecuteRuleActionParametersOverrides", - "RuleRulesetsExecuteRuleActionParametersOverridesCategory", - "RuleRulesetsExecuteRuleActionParametersOverridesRule", - "RuleRulesetsLogRule", - "RuleRulesetsSkipRule", - "RuleRulesetsSkipRuleActionParameters", -] +__all__ = ["RulesetCreateParams", "Rule"] class RulesetCreateParams(TypedDict, total=False): @@ -74,256 +62,4 @@ class RulesetCreateParams(TypedDict, total=False): """An informative description of the ruleset.""" -class RuleRulesetsBlockRuleActionParametersResponse(TypedDict, total=False): - content: Required[str] - """The content to return.""" - - content_type: Required[str] - """The type of the content to return.""" - - status_code: Required[int] - """The status code to return.""" - - -class RuleRulesetsBlockRuleActionParameters(TypedDict, total=False): - response: RuleRulesetsBlockRuleActionParametersResponse - """The response to show when the block is applied.""" - - -class RuleRulesetsBlockRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["block"] - """The action to perform when the rule matches.""" - - action_parameters: RuleRulesetsBlockRuleActionParameters - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: shared_params.UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsExecuteRuleActionParametersMatchedData(TypedDict, total=False): - public_key: Required[str] - """The public key to encrypt matched data logs with.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesCategory(TypedDict, total=False): - category: Required[str] - """The name of the category to override.""" - - action: str - """The action to override rules in the category with.""" - - enabled: bool - """Whether to enable execution of rules in the category.""" - - sensitivity_level: Literal["default", "medium", "low", "eoff"] - """The sensitivity level to use for rules in the category.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesRule(TypedDict, total=False): - id: Required[str] - """The ID of the rule to override.""" - - action: str - """The action to override the rule with.""" - - enabled: bool - """Whether to enable execution of the rule.""" - - score_threshold: int - """The score threshold to use for the rule.""" - - sensitivity_level: Literal["default", "medium", "low", "eoff"] - """The sensitivity level to use for the rule.""" - - -class RuleRulesetsExecuteRuleActionParametersOverrides(TypedDict, total=False): - action: str - """An action to override all rules with. - - This option has lower precedence than rule and category overrides. - """ - - categories: Iterable[RuleRulesetsExecuteRuleActionParametersOverridesCategory] - """A list of category-level overrides. - - This option has the second-highest precedence after rule-level overrides. - """ - - enabled: bool - """Whether to enable execution of all rules. - - This option has lower precedence than rule and category overrides. - """ - - rules: Iterable[RuleRulesetsExecuteRuleActionParametersOverridesRule] - """A list of rule-level overrides. This option has the highest precedence.""" - - sensitivity_level: Literal["default", "medium", "low", "eoff"] - """A sensitivity level to set for all rules. - - This option has lower precedence than rule and category overrides and is only - applicable for DDoS phases. - """ - - -class RuleRulesetsExecuteRuleActionParameters(TypedDict, total=False): - id: Required[str] - """The ID of the ruleset to execute.""" - - matched_data: RuleRulesetsExecuteRuleActionParametersMatchedData - """The configuration to use for matched data logging.""" - - overrides: RuleRulesetsExecuteRuleActionParametersOverrides - """A set of overrides to apply to the target ruleset.""" - - -class RuleRulesetsExecuteRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["execute"] - """The action to perform when the rule matches.""" - - action_parameters: RuleRulesetsExecuteRuleActionParameters - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: shared_params.UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsLogRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["log"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: shared_params.UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsSkipRuleActionParameters(TypedDict, total=False): - phases: List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] - """A list of phases to skip the execution of. - - This option is incompatible with the ruleset and rulesets options. - """ - - products: List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] - """A list of legacy security products to skip the execution of.""" - - rules: Dict[str, List[str]] - """ - A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - execution of. This option is incompatible with the ruleset option. - """ - - ruleset: Literal["current"] - """A ruleset to skip the execution of. - - This option is incompatible with the rulesets, rules and phases options. - """ - - rulesets: List[str] - """A list of ruleset IDs to skip the execution of. - - This option is incompatible with the ruleset and phases options. - """ - - -class RuleRulesetsSkipRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["skip"] - """The action to perform when the rule matches.""" - - action_parameters: RuleRulesetsSkipRuleActionParameters - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: shared_params.UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -Rule = Union[RuleRulesetsBlockRule, RuleRulesetsExecuteRule, RuleRulesetsLogRule, RuleRulesetsSkipRule] +Rule = Union[BlockRuleParam, ExecuteRuleParam, LogRuleParam, SkipRuleParam] diff --git a/src/cloudflare/types/ruleset_create_response.py b/src/cloudflare/types/ruleset_create_response.py index 45c02ec1b65..720d7af73a9 100644 --- a/src/cloudflare/types/ruleset_create_response.py +++ b/src/cloudflare/types/ruleset_create_response.py @@ -1,323 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Dict, List, Union, Optional +from typing import List, Union, Optional from datetime import datetime from typing_extensions import Literal -from .shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from .._models import BaseModel +from .log_rule import LogRule +from .skip_rule import SkipRule +from .block_rule import BlockRule +from .execute_rule import ExecuteRule -__all__ = [ - "RulesetCreateResponse", - "Rule", - "RuleRulesetsBlockRule", - "RuleRulesetsBlockRuleActionParameters", - "RuleRulesetsBlockRuleActionParametersResponse", - "RuleRulesetsExecuteRule", - "RuleRulesetsExecuteRuleActionParameters", - "RuleRulesetsExecuteRuleActionParametersMatchedData", - "RuleRulesetsExecuteRuleActionParametersOverrides", - "RuleRulesetsExecuteRuleActionParametersOverridesCategory", - "RuleRulesetsExecuteRuleActionParametersOverridesRule", - "RuleRulesetsLogRule", - "RuleRulesetsSkipRule", - "RuleRulesetsSkipRuleActionParameters", -] +__all__ = ["RulesetCreateResponse", "Rule"] - -class RuleRulesetsBlockRuleActionParametersResponse(BaseModel): - content: str - """The content to return.""" - - content_type: str - """The type of the content to return.""" - - status_code: int - """The status code to return.""" - - -class RuleRulesetsBlockRuleActionParameters(BaseModel): - response: Optional[RuleRulesetsBlockRuleActionParametersResponse] = None - """The response to show when the block is applied.""" - - -class RuleRulesetsBlockRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["block"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsBlockRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsExecuteRuleActionParametersMatchedData(BaseModel): - public_key: str - """The public key to encrypt matched data logs with.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesCategory(BaseModel): - category: str - """The name of the category to override.""" - - action: Optional[str] = None - """The action to override rules in the category with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of rules in the category.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for rules in the category.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesRule(BaseModel): - id: str - """The ID of the rule to override.""" - - action: Optional[str] = None - """The action to override the rule with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of the rule.""" - - score_threshold: Optional[int] = None - """The score threshold to use for the rule.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for the rule.""" - - -class RuleRulesetsExecuteRuleActionParametersOverrides(BaseModel): - action: Optional[str] = None - """An action to override all rules with. - - This option has lower precedence than rule and category overrides. - """ - - categories: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesCategory]] = None - """A list of category-level overrides. - - This option has the second-highest precedence after rule-level overrides. - """ - - enabled: Optional[bool] = None - """Whether to enable execution of all rules. - - This option has lower precedence than rule and category overrides. - """ - - rules: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesRule]] = None - """A list of rule-level overrides. This option has the highest precedence.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """A sensitivity level to set for all rules. - - This option has lower precedence than rule and category overrides and is only - applicable for DDoS phases. - """ - - -class RuleRulesetsExecuteRuleActionParameters(BaseModel): - id: str - """The ID of the ruleset to execute.""" - - matched_data: Optional[RuleRulesetsExecuteRuleActionParametersMatchedData] = None - """The configuration to use for matched data logging.""" - - overrides: Optional[RuleRulesetsExecuteRuleActionParametersOverrides] = None - """A set of overrides to apply to the target ruleset.""" - - -class RuleRulesetsExecuteRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["execute"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsExecuteRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsLogRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["log"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsSkipRuleActionParameters(BaseModel): - phases: Optional[ - List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] - ] = None - """A list of phases to skip the execution of. - - This option is incompatible with the ruleset and rulesets options. - """ - - products: Optional[ - List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] - ] = None - """A list of legacy security products to skip the execution of.""" - - rules: Optional[Dict[str, List[str]]] = None - """ - A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - execution of. This option is incompatible with the ruleset option. - """ - - ruleset: Optional[Literal["current"]] = None - """A ruleset to skip the execution of. - - This option is incompatible with the rulesets, rules and phases options. - """ - - rulesets: Optional[List[str]] = None - """A list of ruleset IDs to skip the execution of. - - This option is incompatible with the ruleset and phases options. - """ - - -class RuleRulesetsSkipRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["skip"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsSkipRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -Rule = Union[RuleRulesetsBlockRule, RuleRulesetsExecuteRule, RuleRulesetsLogRule, RuleRulesetsSkipRule] +Rule = Union[BlockRule, ExecuteRule, LogRule, SkipRule] class RulesetCreateResponse(BaseModel): diff --git a/src/cloudflare/types/ruleset_get_response.py b/src/cloudflare/types/ruleset_get_response.py index 8dd2e94525e..993e41ba81e 100644 --- a/src/cloudflare/types/ruleset_get_response.py +++ b/src/cloudflare/types/ruleset_get_response.py @@ -1,323 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Dict, List, Union, Optional +from typing import List, Union, Optional from datetime import datetime from typing_extensions import Literal -from .shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from .._models import BaseModel +from .log_rule import LogRule +from .skip_rule import SkipRule +from .block_rule import BlockRule +from .execute_rule import ExecuteRule -__all__ = [ - "RulesetGetResponse", - "Rule", - "RuleRulesetsBlockRule", - "RuleRulesetsBlockRuleActionParameters", - "RuleRulesetsBlockRuleActionParametersResponse", - "RuleRulesetsExecuteRule", - "RuleRulesetsExecuteRuleActionParameters", - "RuleRulesetsExecuteRuleActionParametersMatchedData", - "RuleRulesetsExecuteRuleActionParametersOverrides", - "RuleRulesetsExecuteRuleActionParametersOverridesCategory", - "RuleRulesetsExecuteRuleActionParametersOverridesRule", - "RuleRulesetsLogRule", - "RuleRulesetsSkipRule", - "RuleRulesetsSkipRuleActionParameters", -] +__all__ = ["RulesetGetResponse", "Rule"] - -class RuleRulesetsBlockRuleActionParametersResponse(BaseModel): - content: str - """The content to return.""" - - content_type: str - """The type of the content to return.""" - - status_code: int - """The status code to return.""" - - -class RuleRulesetsBlockRuleActionParameters(BaseModel): - response: Optional[RuleRulesetsBlockRuleActionParametersResponse] = None - """The response to show when the block is applied.""" - - -class RuleRulesetsBlockRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["block"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsBlockRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsExecuteRuleActionParametersMatchedData(BaseModel): - public_key: str - """The public key to encrypt matched data logs with.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesCategory(BaseModel): - category: str - """The name of the category to override.""" - - action: Optional[str] = None - """The action to override rules in the category with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of rules in the category.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for rules in the category.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesRule(BaseModel): - id: str - """The ID of the rule to override.""" - - action: Optional[str] = None - """The action to override the rule with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of the rule.""" - - score_threshold: Optional[int] = None - """The score threshold to use for the rule.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for the rule.""" - - -class RuleRulesetsExecuteRuleActionParametersOverrides(BaseModel): - action: Optional[str] = None - """An action to override all rules with. - - This option has lower precedence than rule and category overrides. - """ - - categories: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesCategory]] = None - """A list of category-level overrides. - - This option has the second-highest precedence after rule-level overrides. - """ - - enabled: Optional[bool] = None - """Whether to enable execution of all rules. - - This option has lower precedence than rule and category overrides. - """ - - rules: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesRule]] = None - """A list of rule-level overrides. This option has the highest precedence.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """A sensitivity level to set for all rules. - - This option has lower precedence than rule and category overrides and is only - applicable for DDoS phases. - """ - - -class RuleRulesetsExecuteRuleActionParameters(BaseModel): - id: str - """The ID of the ruleset to execute.""" - - matched_data: Optional[RuleRulesetsExecuteRuleActionParametersMatchedData] = None - """The configuration to use for matched data logging.""" - - overrides: Optional[RuleRulesetsExecuteRuleActionParametersOverrides] = None - """A set of overrides to apply to the target ruleset.""" - - -class RuleRulesetsExecuteRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["execute"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsExecuteRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsLogRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["log"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsSkipRuleActionParameters(BaseModel): - phases: Optional[ - List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] - ] = None - """A list of phases to skip the execution of. - - This option is incompatible with the ruleset and rulesets options. - """ - - products: Optional[ - List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] - ] = None - """A list of legacy security products to skip the execution of.""" - - rules: Optional[Dict[str, List[str]]] = None - """ - A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - execution of. This option is incompatible with the ruleset option. - """ - - ruleset: Optional[Literal["current"]] = None - """A ruleset to skip the execution of. - - This option is incompatible with the rulesets, rules and phases options. - """ - - rulesets: Optional[List[str]] = None - """A list of ruleset IDs to skip the execution of. - - This option is incompatible with the ruleset and phases options. - """ - - -class RuleRulesetsSkipRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["skip"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsSkipRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -Rule = Union[RuleRulesetsBlockRule, RuleRulesetsExecuteRule, RuleRulesetsLogRule, RuleRulesetsSkipRule] +Rule = Union[BlockRule, ExecuteRule, LogRule, SkipRule] class RulesetGetResponse(BaseModel): diff --git a/src/cloudflare/types/ruleset_update_params.py b/src/cloudflare/types/ruleset_update_params.py index 5a623bd2b84..904d1a3988f 100644 --- a/src/cloudflare/types/ruleset_update_params.py +++ b/src/cloudflare/types/ruleset_update_params.py @@ -2,27 +2,15 @@ from __future__ import annotations -from typing import Dict, List, Union, Iterable +from typing import Union, Iterable from typing_extensions import Literal, Required, TypedDict -from ..types import shared_params +from .log_rule_param import LogRuleParam +from .skip_rule_param import SkipRuleParam +from .block_rule_param import BlockRuleParam +from .execute_rule_param import ExecuteRuleParam -__all__ = [ - "RulesetUpdateParams", - "Rule", - "RuleRulesetsBlockRule", - "RuleRulesetsBlockRuleActionParameters", - "RuleRulesetsBlockRuleActionParametersResponse", - "RuleRulesetsExecuteRule", - "RuleRulesetsExecuteRuleActionParameters", - "RuleRulesetsExecuteRuleActionParametersMatchedData", - "RuleRulesetsExecuteRuleActionParametersOverrides", - "RuleRulesetsExecuteRuleActionParametersOverridesCategory", - "RuleRulesetsExecuteRuleActionParametersOverridesRule", - "RuleRulesetsLogRule", - "RuleRulesetsSkipRule", - "RuleRulesetsSkipRuleActionParameters", -] +__all__ = ["RulesetUpdateParams", "Rule"] class RulesetUpdateParams(TypedDict, total=False): @@ -72,256 +60,4 @@ class RulesetUpdateParams(TypedDict, total=False): """The phase of the ruleset.""" -class RuleRulesetsBlockRuleActionParametersResponse(TypedDict, total=False): - content: Required[str] - """The content to return.""" - - content_type: Required[str] - """The type of the content to return.""" - - status_code: Required[int] - """The status code to return.""" - - -class RuleRulesetsBlockRuleActionParameters(TypedDict, total=False): - response: RuleRulesetsBlockRuleActionParametersResponse - """The response to show when the block is applied.""" - - -class RuleRulesetsBlockRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["block"] - """The action to perform when the rule matches.""" - - action_parameters: RuleRulesetsBlockRuleActionParameters - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: shared_params.UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsExecuteRuleActionParametersMatchedData(TypedDict, total=False): - public_key: Required[str] - """The public key to encrypt matched data logs with.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesCategory(TypedDict, total=False): - category: Required[str] - """The name of the category to override.""" - - action: str - """The action to override rules in the category with.""" - - enabled: bool - """Whether to enable execution of rules in the category.""" - - sensitivity_level: Literal["default", "medium", "low", "eoff"] - """The sensitivity level to use for rules in the category.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesRule(TypedDict, total=False): - id: Required[str] - """The ID of the rule to override.""" - - action: str - """The action to override the rule with.""" - - enabled: bool - """Whether to enable execution of the rule.""" - - score_threshold: int - """The score threshold to use for the rule.""" - - sensitivity_level: Literal["default", "medium", "low", "eoff"] - """The sensitivity level to use for the rule.""" - - -class RuleRulesetsExecuteRuleActionParametersOverrides(TypedDict, total=False): - action: str - """An action to override all rules with. - - This option has lower precedence than rule and category overrides. - """ - - categories: Iterable[RuleRulesetsExecuteRuleActionParametersOverridesCategory] - """A list of category-level overrides. - - This option has the second-highest precedence after rule-level overrides. - """ - - enabled: bool - """Whether to enable execution of all rules. - - This option has lower precedence than rule and category overrides. - """ - - rules: Iterable[RuleRulesetsExecuteRuleActionParametersOverridesRule] - """A list of rule-level overrides. This option has the highest precedence.""" - - sensitivity_level: Literal["default", "medium", "low", "eoff"] - """A sensitivity level to set for all rules. - - This option has lower precedence than rule and category overrides and is only - applicable for DDoS phases. - """ - - -class RuleRulesetsExecuteRuleActionParameters(TypedDict, total=False): - id: Required[str] - """The ID of the ruleset to execute.""" - - matched_data: RuleRulesetsExecuteRuleActionParametersMatchedData - """The configuration to use for matched data logging.""" - - overrides: RuleRulesetsExecuteRuleActionParametersOverrides - """A set of overrides to apply to the target ruleset.""" - - -class RuleRulesetsExecuteRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["execute"] - """The action to perform when the rule matches.""" - - action_parameters: RuleRulesetsExecuteRuleActionParameters - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: shared_params.UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsLogRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["log"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: shared_params.UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsSkipRuleActionParameters(TypedDict, total=False): - phases: List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] - """A list of phases to skip the execution of. - - This option is incompatible with the ruleset and rulesets options. - """ - - products: List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] - """A list of legacy security products to skip the execution of.""" - - rules: Dict[str, List[str]] - """ - A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - execution of. This option is incompatible with the ruleset option. - """ - - ruleset: Literal["current"] - """A ruleset to skip the execution of. - - This option is incompatible with the rulesets, rules and phases options. - """ - - rulesets: List[str] - """A list of ruleset IDs to skip the execution of. - - This option is incompatible with the ruleset and phases options. - """ - - -class RuleRulesetsSkipRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["skip"] - """The action to perform when the rule matches.""" - - action_parameters: RuleRulesetsSkipRuleActionParameters - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: shared_params.UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -Rule = Union[RuleRulesetsBlockRule, RuleRulesetsExecuteRule, RuleRulesetsLogRule, RuleRulesetsSkipRule] +Rule = Union[BlockRuleParam, ExecuteRuleParam, LogRuleParam, SkipRuleParam] diff --git a/src/cloudflare/types/ruleset_update_response.py b/src/cloudflare/types/ruleset_update_response.py index e81480c5118..8dffbafc4b6 100644 --- a/src/cloudflare/types/ruleset_update_response.py +++ b/src/cloudflare/types/ruleset_update_response.py @@ -1,323 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Dict, List, Union, Optional +from typing import List, Union, Optional from datetime import datetime from typing_extensions import Literal -from .shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from .._models import BaseModel +from .log_rule import LogRule +from .skip_rule import SkipRule +from .block_rule import BlockRule +from .execute_rule import ExecuteRule -__all__ = [ - "RulesetUpdateResponse", - "Rule", - "RuleRulesetsBlockRule", - "RuleRulesetsBlockRuleActionParameters", - "RuleRulesetsBlockRuleActionParametersResponse", - "RuleRulesetsExecuteRule", - "RuleRulesetsExecuteRuleActionParameters", - "RuleRulesetsExecuteRuleActionParametersMatchedData", - "RuleRulesetsExecuteRuleActionParametersOverrides", - "RuleRulesetsExecuteRuleActionParametersOverridesCategory", - "RuleRulesetsExecuteRuleActionParametersOverridesRule", - "RuleRulesetsLogRule", - "RuleRulesetsSkipRule", - "RuleRulesetsSkipRuleActionParameters", -] +__all__ = ["RulesetUpdateResponse", "Rule"] - -class RuleRulesetsBlockRuleActionParametersResponse(BaseModel): - content: str - """The content to return.""" - - content_type: str - """The type of the content to return.""" - - status_code: int - """The status code to return.""" - - -class RuleRulesetsBlockRuleActionParameters(BaseModel): - response: Optional[RuleRulesetsBlockRuleActionParametersResponse] = None - """The response to show when the block is applied.""" - - -class RuleRulesetsBlockRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["block"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsBlockRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsExecuteRuleActionParametersMatchedData(BaseModel): - public_key: str - """The public key to encrypt matched data logs with.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesCategory(BaseModel): - category: str - """The name of the category to override.""" - - action: Optional[str] = None - """The action to override rules in the category with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of rules in the category.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for rules in the category.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesRule(BaseModel): - id: str - """The ID of the rule to override.""" - - action: Optional[str] = None - """The action to override the rule with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of the rule.""" - - score_threshold: Optional[int] = None - """The score threshold to use for the rule.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for the rule.""" - - -class RuleRulesetsExecuteRuleActionParametersOverrides(BaseModel): - action: Optional[str] = None - """An action to override all rules with. - - This option has lower precedence than rule and category overrides. - """ - - categories: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesCategory]] = None - """A list of category-level overrides. - - This option has the second-highest precedence after rule-level overrides. - """ - - enabled: Optional[bool] = None - """Whether to enable execution of all rules. - - This option has lower precedence than rule and category overrides. - """ - - rules: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesRule]] = None - """A list of rule-level overrides. This option has the highest precedence.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """A sensitivity level to set for all rules. - - This option has lower precedence than rule and category overrides and is only - applicable for DDoS phases. - """ - - -class RuleRulesetsExecuteRuleActionParameters(BaseModel): - id: str - """The ID of the ruleset to execute.""" - - matched_data: Optional[RuleRulesetsExecuteRuleActionParametersMatchedData] = None - """The configuration to use for matched data logging.""" - - overrides: Optional[RuleRulesetsExecuteRuleActionParametersOverrides] = None - """A set of overrides to apply to the target ruleset.""" - - -class RuleRulesetsExecuteRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["execute"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsExecuteRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsLogRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["log"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsSkipRuleActionParameters(BaseModel): - phases: Optional[ - List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] - ] = None - """A list of phases to skip the execution of. - - This option is incompatible with the ruleset and rulesets options. - """ - - products: Optional[ - List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] - ] = None - """A list of legacy security products to skip the execution of.""" - - rules: Optional[Dict[str, List[str]]] = None - """ - A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - execution of. This option is incompatible with the ruleset option. - """ - - ruleset: Optional[Literal["current"]] = None - """A ruleset to skip the execution of. - - This option is incompatible with the rulesets, rules and phases options. - """ - - rulesets: Optional[List[str]] = None - """A list of ruleset IDs to skip the execution of. - - This option is incompatible with the ruleset and phases options. - """ - - -class RuleRulesetsSkipRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["skip"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsSkipRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -Rule = Union[RuleRulesetsBlockRule, RuleRulesetsExecuteRule, RuleRulesetsLogRule, RuleRulesetsSkipRule] +Rule = Union[BlockRule, ExecuteRule, LogRule, SkipRule] class RulesetUpdateResponse(BaseModel): diff --git a/src/cloudflare/types/rulesets/phase_get_response.py b/src/cloudflare/types/rulesets/phase_get_response.py index cf88a2b387a..949e29ff8fc 100644 --- a/src/cloudflare/types/rulesets/phase_get_response.py +++ b/src/cloudflare/types/rulesets/phase_get_response.py @@ -1,323 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Dict, List, Union, Optional +from typing import List, Union, Optional from datetime import datetime from typing_extensions import Literal -from ..shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from ..._models import BaseModel +from ..log_rule import LogRule +from ..skip_rule import SkipRule +from ..block_rule import BlockRule +from ..execute_rule import ExecuteRule -__all__ = [ - "PhaseGetResponse", - "Rule", - "RuleRulesetsBlockRule", - "RuleRulesetsBlockRuleActionParameters", - "RuleRulesetsBlockRuleActionParametersResponse", - "RuleRulesetsExecuteRule", - "RuleRulesetsExecuteRuleActionParameters", - "RuleRulesetsExecuteRuleActionParametersMatchedData", - "RuleRulesetsExecuteRuleActionParametersOverrides", - "RuleRulesetsExecuteRuleActionParametersOverridesCategory", - "RuleRulesetsExecuteRuleActionParametersOverridesRule", - "RuleRulesetsLogRule", - "RuleRulesetsSkipRule", - "RuleRulesetsSkipRuleActionParameters", -] +__all__ = ["PhaseGetResponse", "Rule"] - -class RuleRulesetsBlockRuleActionParametersResponse(BaseModel): - content: str - """The content to return.""" - - content_type: str - """The type of the content to return.""" - - status_code: int - """The status code to return.""" - - -class RuleRulesetsBlockRuleActionParameters(BaseModel): - response: Optional[RuleRulesetsBlockRuleActionParametersResponse] = None - """The response to show when the block is applied.""" - - -class RuleRulesetsBlockRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["block"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsBlockRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsExecuteRuleActionParametersMatchedData(BaseModel): - public_key: str - """The public key to encrypt matched data logs with.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesCategory(BaseModel): - category: str - """The name of the category to override.""" - - action: Optional[str] = None - """The action to override rules in the category with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of rules in the category.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for rules in the category.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesRule(BaseModel): - id: str - """The ID of the rule to override.""" - - action: Optional[str] = None - """The action to override the rule with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of the rule.""" - - score_threshold: Optional[int] = None - """The score threshold to use for the rule.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for the rule.""" - - -class RuleRulesetsExecuteRuleActionParametersOverrides(BaseModel): - action: Optional[str] = None - """An action to override all rules with. - - This option has lower precedence than rule and category overrides. - """ - - categories: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesCategory]] = None - """A list of category-level overrides. - - This option has the second-highest precedence after rule-level overrides. - """ - - enabled: Optional[bool] = None - """Whether to enable execution of all rules. - - This option has lower precedence than rule and category overrides. - """ - - rules: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesRule]] = None - """A list of rule-level overrides. This option has the highest precedence.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """A sensitivity level to set for all rules. - - This option has lower precedence than rule and category overrides and is only - applicable for DDoS phases. - """ - - -class RuleRulesetsExecuteRuleActionParameters(BaseModel): - id: str - """The ID of the ruleset to execute.""" - - matched_data: Optional[RuleRulesetsExecuteRuleActionParametersMatchedData] = None - """The configuration to use for matched data logging.""" - - overrides: Optional[RuleRulesetsExecuteRuleActionParametersOverrides] = None - """A set of overrides to apply to the target ruleset.""" - - -class RuleRulesetsExecuteRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["execute"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsExecuteRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsLogRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["log"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsSkipRuleActionParameters(BaseModel): - phases: Optional[ - List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] - ] = None - """A list of phases to skip the execution of. - - This option is incompatible with the ruleset and rulesets options. - """ - - products: Optional[ - List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] - ] = None - """A list of legacy security products to skip the execution of.""" - - rules: Optional[Dict[str, List[str]]] = None - """ - A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - execution of. This option is incompatible with the ruleset option. - """ - - ruleset: Optional[Literal["current"]] = None - """A ruleset to skip the execution of. - - This option is incompatible with the rulesets, rules and phases options. - """ - - rulesets: Optional[List[str]] = None - """A list of ruleset IDs to skip the execution of. - - This option is incompatible with the ruleset and phases options. - """ - - -class RuleRulesetsSkipRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["skip"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsSkipRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -Rule = Union[RuleRulesetsBlockRule, RuleRulesetsExecuteRule, RuleRulesetsLogRule, RuleRulesetsSkipRule] +Rule = Union[BlockRule, ExecuteRule, LogRule, SkipRule] class PhaseGetResponse(BaseModel): diff --git a/src/cloudflare/types/rulesets/phase_update_params.py b/src/cloudflare/types/rulesets/phase_update_params.py index ee0dd31a575..10fed2e85b9 100644 --- a/src/cloudflare/types/rulesets/phase_update_params.py +++ b/src/cloudflare/types/rulesets/phase_update_params.py @@ -2,27 +2,15 @@ from __future__ import annotations -from typing import Dict, List, Union, Iterable +from typing import Union, Iterable from typing_extensions import Literal, Required, TypedDict -from ...types import shared_params +from ..log_rule_param import LogRuleParam +from ..skip_rule_param import SkipRuleParam +from ..block_rule_param import BlockRuleParam +from ..execute_rule_param import ExecuteRuleParam -__all__ = [ - "PhaseUpdateParams", - "Rule", - "RuleRulesetsBlockRule", - "RuleRulesetsBlockRuleActionParameters", - "RuleRulesetsBlockRuleActionParametersResponse", - "RuleRulesetsExecuteRule", - "RuleRulesetsExecuteRuleActionParameters", - "RuleRulesetsExecuteRuleActionParametersMatchedData", - "RuleRulesetsExecuteRuleActionParametersOverrides", - "RuleRulesetsExecuteRuleActionParametersOverridesCategory", - "RuleRulesetsExecuteRuleActionParametersOverridesRule", - "RuleRulesetsLogRule", - "RuleRulesetsSkipRule", - "RuleRulesetsSkipRuleActionParameters", -] +__all__ = ["PhaseUpdateParams", "Rule"] class PhaseUpdateParams(TypedDict, total=False): @@ -72,256 +60,4 @@ class PhaseUpdateParams(TypedDict, total=False): """The phase of the ruleset.""" -class RuleRulesetsBlockRuleActionParametersResponse(TypedDict, total=False): - content: Required[str] - """The content to return.""" - - content_type: Required[str] - """The type of the content to return.""" - - status_code: Required[int] - """The status code to return.""" - - -class RuleRulesetsBlockRuleActionParameters(TypedDict, total=False): - response: RuleRulesetsBlockRuleActionParametersResponse - """The response to show when the block is applied.""" - - -class RuleRulesetsBlockRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["block"] - """The action to perform when the rule matches.""" - - action_parameters: RuleRulesetsBlockRuleActionParameters - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: shared_params.UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsExecuteRuleActionParametersMatchedData(TypedDict, total=False): - public_key: Required[str] - """The public key to encrypt matched data logs with.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesCategory(TypedDict, total=False): - category: Required[str] - """The name of the category to override.""" - - action: str - """The action to override rules in the category with.""" - - enabled: bool - """Whether to enable execution of rules in the category.""" - - sensitivity_level: Literal["default", "medium", "low", "eoff"] - """The sensitivity level to use for rules in the category.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesRule(TypedDict, total=False): - id: Required[str] - """The ID of the rule to override.""" - - action: str - """The action to override the rule with.""" - - enabled: bool - """Whether to enable execution of the rule.""" - - score_threshold: int - """The score threshold to use for the rule.""" - - sensitivity_level: Literal["default", "medium", "low", "eoff"] - """The sensitivity level to use for the rule.""" - - -class RuleRulesetsExecuteRuleActionParametersOverrides(TypedDict, total=False): - action: str - """An action to override all rules with. - - This option has lower precedence than rule and category overrides. - """ - - categories: Iterable[RuleRulesetsExecuteRuleActionParametersOverridesCategory] - """A list of category-level overrides. - - This option has the second-highest precedence after rule-level overrides. - """ - - enabled: bool - """Whether to enable execution of all rules. - - This option has lower precedence than rule and category overrides. - """ - - rules: Iterable[RuleRulesetsExecuteRuleActionParametersOverridesRule] - """A list of rule-level overrides. This option has the highest precedence.""" - - sensitivity_level: Literal["default", "medium", "low", "eoff"] - """A sensitivity level to set for all rules. - - This option has lower precedence than rule and category overrides and is only - applicable for DDoS phases. - """ - - -class RuleRulesetsExecuteRuleActionParameters(TypedDict, total=False): - id: Required[str] - """The ID of the ruleset to execute.""" - - matched_data: RuleRulesetsExecuteRuleActionParametersMatchedData - """The configuration to use for matched data logging.""" - - overrides: RuleRulesetsExecuteRuleActionParametersOverrides - """A set of overrides to apply to the target ruleset.""" - - -class RuleRulesetsExecuteRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["execute"] - """The action to perform when the rule matches.""" - - action_parameters: RuleRulesetsExecuteRuleActionParameters - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: shared_params.UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsLogRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["log"] - """The action to perform when the rule matches.""" - - action_parameters: object - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: shared_params.UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsSkipRuleActionParameters(TypedDict, total=False): - phases: List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] - """A list of phases to skip the execution of. - - This option is incompatible with the ruleset and rulesets options. - """ - - products: List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] - """A list of legacy security products to skip the execution of.""" - - rules: Dict[str, List[str]] - """ - A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - execution of. This option is incompatible with the ruleset option. - """ - - ruleset: Literal["current"] - """A ruleset to skip the execution of. - - This option is incompatible with the rulesets, rules and phases options. - """ - - rulesets: List[str] - """A list of ruleset IDs to skip the execution of. - - This option is incompatible with the ruleset and phases options. - """ - - -class RuleRulesetsSkipRule(TypedDict, total=False): - id: str - """The unique ID of the rule.""" - - action: Literal["skip"] - """The action to perform when the rule matches.""" - - action_parameters: RuleRulesetsSkipRuleActionParameters - """The parameters configuring the rule's action.""" - - description: str - """An informative description of the rule.""" - - enabled: bool - """Whether the rule should be executed.""" - - expression: str - """The expression defining which traffic will match the rule.""" - - logging: shared_params.UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c - """An object configuring the rule's logging behavior.""" - - ref: str - """The reference of the rule (the rule ID by default).""" - - -Rule = Union[RuleRulesetsBlockRule, RuleRulesetsExecuteRule, RuleRulesetsLogRule, RuleRulesetsSkipRule] +Rule = Union[BlockRuleParam, ExecuteRuleParam, LogRuleParam, SkipRuleParam] diff --git a/src/cloudflare/types/rulesets/phase_update_response.py b/src/cloudflare/types/rulesets/phase_update_response.py index dea3c5a4006..71a324579b8 100644 --- a/src/cloudflare/types/rulesets/phase_update_response.py +++ b/src/cloudflare/types/rulesets/phase_update_response.py @@ -1,323 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Dict, List, Union, Optional +from typing import List, Union, Optional from datetime import datetime from typing_extensions import Literal -from ..shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from ..._models import BaseModel +from ..log_rule import LogRule +from ..skip_rule import SkipRule +from ..block_rule import BlockRule +from ..execute_rule import ExecuteRule -__all__ = [ - "PhaseUpdateResponse", - "Rule", - "RuleRulesetsBlockRule", - "RuleRulesetsBlockRuleActionParameters", - "RuleRulesetsBlockRuleActionParametersResponse", - "RuleRulesetsExecuteRule", - "RuleRulesetsExecuteRuleActionParameters", - "RuleRulesetsExecuteRuleActionParametersMatchedData", - "RuleRulesetsExecuteRuleActionParametersOverrides", - "RuleRulesetsExecuteRuleActionParametersOverridesCategory", - "RuleRulesetsExecuteRuleActionParametersOverridesRule", - "RuleRulesetsLogRule", - "RuleRulesetsSkipRule", - "RuleRulesetsSkipRuleActionParameters", -] +__all__ = ["PhaseUpdateResponse", "Rule"] - -class RuleRulesetsBlockRuleActionParametersResponse(BaseModel): - content: str - """The content to return.""" - - content_type: str - """The type of the content to return.""" - - status_code: int - """The status code to return.""" - - -class RuleRulesetsBlockRuleActionParameters(BaseModel): - response: Optional[RuleRulesetsBlockRuleActionParametersResponse] = None - """The response to show when the block is applied.""" - - -class RuleRulesetsBlockRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["block"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsBlockRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsExecuteRuleActionParametersMatchedData(BaseModel): - public_key: str - """The public key to encrypt matched data logs with.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesCategory(BaseModel): - category: str - """The name of the category to override.""" - - action: Optional[str] = None - """The action to override rules in the category with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of rules in the category.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for rules in the category.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesRule(BaseModel): - id: str - """The ID of the rule to override.""" - - action: Optional[str] = None - """The action to override the rule with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of the rule.""" - - score_threshold: Optional[int] = None - """The score threshold to use for the rule.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for the rule.""" - - -class RuleRulesetsExecuteRuleActionParametersOverrides(BaseModel): - action: Optional[str] = None - """An action to override all rules with. - - This option has lower precedence than rule and category overrides. - """ - - categories: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesCategory]] = None - """A list of category-level overrides. - - This option has the second-highest precedence after rule-level overrides. - """ - - enabled: Optional[bool] = None - """Whether to enable execution of all rules. - - This option has lower precedence than rule and category overrides. - """ - - rules: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesRule]] = None - """A list of rule-level overrides. This option has the highest precedence.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """A sensitivity level to set for all rules. - - This option has lower precedence than rule and category overrides and is only - applicable for DDoS phases. - """ - - -class RuleRulesetsExecuteRuleActionParameters(BaseModel): - id: str - """The ID of the ruleset to execute.""" - - matched_data: Optional[RuleRulesetsExecuteRuleActionParametersMatchedData] = None - """The configuration to use for matched data logging.""" - - overrides: Optional[RuleRulesetsExecuteRuleActionParametersOverrides] = None - """A set of overrides to apply to the target ruleset.""" - - -class RuleRulesetsExecuteRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["execute"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsExecuteRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsLogRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["log"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsSkipRuleActionParameters(BaseModel): - phases: Optional[ - List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] - ] = None - """A list of phases to skip the execution of. - - This option is incompatible with the ruleset and rulesets options. - """ - - products: Optional[ - List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] - ] = None - """A list of legacy security products to skip the execution of.""" - - rules: Optional[Dict[str, List[str]]] = None - """ - A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - execution of. This option is incompatible with the ruleset option. - """ - - ruleset: Optional[Literal["current"]] = None - """A ruleset to skip the execution of. - - This option is incompatible with the rulesets, rules and phases options. - """ - - rulesets: Optional[List[str]] = None - """A list of ruleset IDs to skip the execution of. - - This option is incompatible with the ruleset and phases options. - """ - - -class RuleRulesetsSkipRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["skip"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsSkipRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -Rule = Union[RuleRulesetsBlockRule, RuleRulesetsExecuteRule, RuleRulesetsLogRule, RuleRulesetsSkipRule] +Rule = Union[BlockRule, ExecuteRule, LogRule, SkipRule] class PhaseUpdateResponse(BaseModel): diff --git a/src/cloudflare/types/rulesets/phases/version_get_response.py b/src/cloudflare/types/rulesets/phases/version_get_response.py index 55f0d62279f..ea872fae682 100644 --- a/src/cloudflare/types/rulesets/phases/version_get_response.py +++ b/src/cloudflare/types/rulesets/phases/version_get_response.py @@ -1,323 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Dict, List, Union, Optional +from typing import List, Union, Optional from datetime import datetime from typing_extensions import Literal -from ...shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from ...._models import BaseModel +from ...log_rule import LogRule +from ...skip_rule import SkipRule +from ...block_rule import BlockRule +from ...execute_rule import ExecuteRule -__all__ = [ - "VersionGetResponse", - "Rule", - "RuleRulesetsBlockRule", - "RuleRulesetsBlockRuleActionParameters", - "RuleRulesetsBlockRuleActionParametersResponse", - "RuleRulesetsExecuteRule", - "RuleRulesetsExecuteRuleActionParameters", - "RuleRulesetsExecuteRuleActionParametersMatchedData", - "RuleRulesetsExecuteRuleActionParametersOverrides", - "RuleRulesetsExecuteRuleActionParametersOverridesCategory", - "RuleRulesetsExecuteRuleActionParametersOverridesRule", - "RuleRulesetsLogRule", - "RuleRulesetsSkipRule", - "RuleRulesetsSkipRuleActionParameters", -] +__all__ = ["VersionGetResponse", "Rule"] - -class RuleRulesetsBlockRuleActionParametersResponse(BaseModel): - content: str - """The content to return.""" - - content_type: str - """The type of the content to return.""" - - status_code: int - """The status code to return.""" - - -class RuleRulesetsBlockRuleActionParameters(BaseModel): - response: Optional[RuleRulesetsBlockRuleActionParametersResponse] = None - """The response to show when the block is applied.""" - - -class RuleRulesetsBlockRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["block"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsBlockRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsExecuteRuleActionParametersMatchedData(BaseModel): - public_key: str - """The public key to encrypt matched data logs with.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesCategory(BaseModel): - category: str - """The name of the category to override.""" - - action: Optional[str] = None - """The action to override rules in the category with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of rules in the category.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for rules in the category.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesRule(BaseModel): - id: str - """The ID of the rule to override.""" - - action: Optional[str] = None - """The action to override the rule with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of the rule.""" - - score_threshold: Optional[int] = None - """The score threshold to use for the rule.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for the rule.""" - - -class RuleRulesetsExecuteRuleActionParametersOverrides(BaseModel): - action: Optional[str] = None - """An action to override all rules with. - - This option has lower precedence than rule and category overrides. - """ - - categories: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesCategory]] = None - """A list of category-level overrides. - - This option has the second-highest precedence after rule-level overrides. - """ - - enabled: Optional[bool] = None - """Whether to enable execution of all rules. - - This option has lower precedence than rule and category overrides. - """ - - rules: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesRule]] = None - """A list of rule-level overrides. This option has the highest precedence.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """A sensitivity level to set for all rules. - - This option has lower precedence than rule and category overrides and is only - applicable for DDoS phases. - """ - - -class RuleRulesetsExecuteRuleActionParameters(BaseModel): - id: str - """The ID of the ruleset to execute.""" - - matched_data: Optional[RuleRulesetsExecuteRuleActionParametersMatchedData] = None - """The configuration to use for matched data logging.""" - - overrides: Optional[RuleRulesetsExecuteRuleActionParametersOverrides] = None - """A set of overrides to apply to the target ruleset.""" - - -class RuleRulesetsExecuteRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["execute"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsExecuteRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsLogRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["log"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsSkipRuleActionParameters(BaseModel): - phases: Optional[ - List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] - ] = None - """A list of phases to skip the execution of. - - This option is incompatible with the ruleset and rulesets options. - """ - - products: Optional[ - List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] - ] = None - """A list of legacy security products to skip the execution of.""" - - rules: Optional[Dict[str, List[str]]] = None - """ - A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - execution of. This option is incompatible with the ruleset option. - """ - - ruleset: Optional[Literal["current"]] = None - """A ruleset to skip the execution of. - - This option is incompatible with the rulesets, rules and phases options. - """ - - rulesets: Optional[List[str]] = None - """A list of ruleset IDs to skip the execution of. - - This option is incompatible with the ruleset and phases options. - """ - - -class RuleRulesetsSkipRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["skip"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsSkipRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -Rule = Union[RuleRulesetsBlockRule, RuleRulesetsExecuteRule, RuleRulesetsLogRule, RuleRulesetsSkipRule] +Rule = Union[BlockRule, ExecuteRule, LogRule, SkipRule] class VersionGetResponse(BaseModel): diff --git a/src/cloudflare/types/rulesets/rule_create_params.py b/src/cloudflare/types/rulesets/rule_create_params.py index c6fefe04798..f90079b147a 100644 --- a/src/cloudflare/types/rulesets/rule_create_params.py +++ b/src/cloudflare/types/rulesets/rule_create_params.py @@ -9,22 +9,22 @@ __all__ = [ "RuleCreateParams", - "RulesetsBlockRule", - "RulesetsBlockRuleActionParameters", - "RulesetsBlockRuleActionParametersResponse", - "RulesetsExecuteRule", - "RulesetsExecuteRuleActionParameters", - "RulesetsExecuteRuleActionParametersMatchedData", - "RulesetsExecuteRuleActionParametersOverrides", - "RulesetsExecuteRuleActionParametersOverridesCategory", - "RulesetsExecuteRuleActionParametersOverridesRule", - "RulesetsLogRule", - "RulesetsSkipRule", - "RulesetsSkipRuleActionParameters", + "BlockRule", + "BlockRuleActionParameters", + "BlockRuleActionParametersResponse", + "ExecuteRule", + "ExecuteRuleActionParameters", + "ExecuteRuleActionParametersMatchedData", + "ExecuteRuleActionParametersOverrides", + "ExecuteRuleActionParametersOverridesCategory", + "ExecuteRuleActionParametersOverridesRule", + "LogRule", + "SkipRule", + "SkipRuleActionParameters", ] -class RulesetsBlockRule(TypedDict, total=False): +class BlockRule(TypedDict, total=False): account_id: str """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" @@ -37,7 +37,7 @@ class RulesetsBlockRule(TypedDict, total=False): action: Literal["block"] """The action to perform when the rule matches.""" - action_parameters: RulesetsBlockRuleActionParameters + action_parameters: BlockRuleActionParameters """The parameters configuring the rule's action.""" description: str @@ -56,7 +56,7 @@ class RulesetsBlockRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class RulesetsBlockRuleActionParametersResponse(TypedDict, total=False): +class BlockRuleActionParametersResponse(TypedDict, total=False): content: Required[str] """The content to return.""" @@ -67,12 +67,12 @@ class RulesetsBlockRuleActionParametersResponse(TypedDict, total=False): """The status code to return.""" -class RulesetsBlockRuleActionParameters(TypedDict, total=False): - response: RulesetsBlockRuleActionParametersResponse +class BlockRuleActionParameters(TypedDict, total=False): + response: BlockRuleActionParametersResponse """The response to show when the block is applied.""" -class RulesetsExecuteRule(TypedDict, total=False): +class ExecuteRule(TypedDict, total=False): account_id: str """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" @@ -85,7 +85,7 @@ class RulesetsExecuteRule(TypedDict, total=False): action: Literal["execute"] """The action to perform when the rule matches.""" - action_parameters: RulesetsExecuteRuleActionParameters + action_parameters: ExecuteRuleActionParameters """The parameters configuring the rule's action.""" description: str @@ -104,12 +104,12 @@ class RulesetsExecuteRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class RulesetsExecuteRuleActionParametersMatchedData(TypedDict, total=False): +class ExecuteRuleActionParametersMatchedData(TypedDict, total=False): public_key: Required[str] """The public key to encrypt matched data logs with.""" -class RulesetsExecuteRuleActionParametersOverridesCategory(TypedDict, total=False): +class ExecuteRuleActionParametersOverridesCategory(TypedDict, total=False): category: Required[str] """The name of the category to override.""" @@ -123,7 +123,7 @@ class RulesetsExecuteRuleActionParametersOverridesCategory(TypedDict, total=Fals """The sensitivity level to use for rules in the category.""" -class RulesetsExecuteRuleActionParametersOverridesRule(TypedDict, total=False): +class ExecuteRuleActionParametersOverridesRule(TypedDict, total=False): id: Required[str] """The ID of the rule to override.""" @@ -140,14 +140,14 @@ class RulesetsExecuteRuleActionParametersOverridesRule(TypedDict, total=False): """The sensitivity level to use for the rule.""" -class RulesetsExecuteRuleActionParametersOverrides(TypedDict, total=False): +class ExecuteRuleActionParametersOverrides(TypedDict, total=False): action: str """An action to override all rules with. This option has lower precedence than rule and category overrides. """ - categories: Iterable[RulesetsExecuteRuleActionParametersOverridesCategory] + categories: Iterable[ExecuteRuleActionParametersOverridesCategory] """A list of category-level overrides. This option has the second-highest precedence after rule-level overrides. @@ -159,7 +159,7 @@ class RulesetsExecuteRuleActionParametersOverrides(TypedDict, total=False): This option has lower precedence than rule and category overrides. """ - rules: Iterable[RulesetsExecuteRuleActionParametersOverridesRule] + rules: Iterable[ExecuteRuleActionParametersOverridesRule] """A list of rule-level overrides. This option has the highest precedence.""" sensitivity_level: Literal["default", "medium", "low", "eoff"] @@ -170,18 +170,18 @@ class RulesetsExecuteRuleActionParametersOverrides(TypedDict, total=False): """ -class RulesetsExecuteRuleActionParameters(TypedDict, total=False): +class ExecuteRuleActionParameters(TypedDict, total=False): id: Required[str] """The ID of the ruleset to execute.""" - matched_data: RulesetsExecuteRuleActionParametersMatchedData + matched_data: ExecuteRuleActionParametersMatchedData """The configuration to use for matched data logging.""" - overrides: RulesetsExecuteRuleActionParametersOverrides + overrides: ExecuteRuleActionParametersOverrides """A set of overrides to apply to the target ruleset.""" -class RulesetsLogRule(TypedDict, total=False): +class LogRule(TypedDict, total=False): account_id: str """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" @@ -213,7 +213,7 @@ class RulesetsLogRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class RulesetsSkipRule(TypedDict, total=False): +class SkipRule(TypedDict, total=False): account_id: str """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" @@ -226,7 +226,7 @@ class RulesetsSkipRule(TypedDict, total=False): action: Literal["skip"] """The action to perform when the rule matches.""" - action_parameters: RulesetsSkipRuleActionParameters + action_parameters: SkipRuleActionParameters """The parameters configuring the rule's action.""" description: str @@ -245,7 +245,7 @@ class RulesetsSkipRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class RulesetsSkipRuleActionParameters(TypedDict, total=False): +class SkipRuleActionParameters(TypedDict, total=False): phases: List[ Literal[ "ddos_l4", @@ -300,4 +300,4 @@ class RulesetsSkipRuleActionParameters(TypedDict, total=False): """ -RuleCreateParams = Union[RulesetsBlockRule, RulesetsExecuteRule, RulesetsLogRule, RulesetsSkipRule] +RuleCreateParams = Union[BlockRule, ExecuteRule, LogRule, SkipRule] diff --git a/src/cloudflare/types/rulesets/rule_create_response.py b/src/cloudflare/types/rulesets/rule_create_response.py index e4c09492459..a7dfc396232 100644 --- a/src/cloudflare/types/rulesets/rule_create_response.py +++ b/src/cloudflare/types/rulesets/rule_create_response.py @@ -1,323 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Dict, List, Union, Optional +from typing import List, Union, Optional from datetime import datetime from typing_extensions import Literal -from ..shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from ..._models import BaseModel +from ..log_rule import LogRule +from ..skip_rule import SkipRule +from ..block_rule import BlockRule +from ..execute_rule import ExecuteRule -__all__ = [ - "RuleCreateResponse", - "Rule", - "RuleRulesetsBlockRule", - "RuleRulesetsBlockRuleActionParameters", - "RuleRulesetsBlockRuleActionParametersResponse", - "RuleRulesetsExecuteRule", - "RuleRulesetsExecuteRuleActionParameters", - "RuleRulesetsExecuteRuleActionParametersMatchedData", - "RuleRulesetsExecuteRuleActionParametersOverrides", - "RuleRulesetsExecuteRuleActionParametersOverridesCategory", - "RuleRulesetsExecuteRuleActionParametersOverridesRule", - "RuleRulesetsLogRule", - "RuleRulesetsSkipRule", - "RuleRulesetsSkipRuleActionParameters", -] +__all__ = ["RuleCreateResponse", "Rule"] - -class RuleRulesetsBlockRuleActionParametersResponse(BaseModel): - content: str - """The content to return.""" - - content_type: str - """The type of the content to return.""" - - status_code: int - """The status code to return.""" - - -class RuleRulesetsBlockRuleActionParameters(BaseModel): - response: Optional[RuleRulesetsBlockRuleActionParametersResponse] = None - """The response to show when the block is applied.""" - - -class RuleRulesetsBlockRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["block"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsBlockRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsExecuteRuleActionParametersMatchedData(BaseModel): - public_key: str - """The public key to encrypt matched data logs with.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesCategory(BaseModel): - category: str - """The name of the category to override.""" - - action: Optional[str] = None - """The action to override rules in the category with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of rules in the category.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for rules in the category.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesRule(BaseModel): - id: str - """The ID of the rule to override.""" - - action: Optional[str] = None - """The action to override the rule with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of the rule.""" - - score_threshold: Optional[int] = None - """The score threshold to use for the rule.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for the rule.""" - - -class RuleRulesetsExecuteRuleActionParametersOverrides(BaseModel): - action: Optional[str] = None - """An action to override all rules with. - - This option has lower precedence than rule and category overrides. - """ - - categories: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesCategory]] = None - """A list of category-level overrides. - - This option has the second-highest precedence after rule-level overrides. - """ - - enabled: Optional[bool] = None - """Whether to enable execution of all rules. - - This option has lower precedence than rule and category overrides. - """ - - rules: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesRule]] = None - """A list of rule-level overrides. This option has the highest precedence.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """A sensitivity level to set for all rules. - - This option has lower precedence than rule and category overrides and is only - applicable for DDoS phases. - """ - - -class RuleRulesetsExecuteRuleActionParameters(BaseModel): - id: str - """The ID of the ruleset to execute.""" - - matched_data: Optional[RuleRulesetsExecuteRuleActionParametersMatchedData] = None - """The configuration to use for matched data logging.""" - - overrides: Optional[RuleRulesetsExecuteRuleActionParametersOverrides] = None - """A set of overrides to apply to the target ruleset.""" - - -class RuleRulesetsExecuteRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["execute"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsExecuteRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsLogRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["log"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsSkipRuleActionParameters(BaseModel): - phases: Optional[ - List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] - ] = None - """A list of phases to skip the execution of. - - This option is incompatible with the ruleset and rulesets options. - """ - - products: Optional[ - List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] - ] = None - """A list of legacy security products to skip the execution of.""" - - rules: Optional[Dict[str, List[str]]] = None - """ - A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - execution of. This option is incompatible with the ruleset option. - """ - - ruleset: Optional[Literal["current"]] = None - """A ruleset to skip the execution of. - - This option is incompatible with the rulesets, rules and phases options. - """ - - rulesets: Optional[List[str]] = None - """A list of ruleset IDs to skip the execution of. - - This option is incompatible with the ruleset and phases options. - """ - - -class RuleRulesetsSkipRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["skip"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsSkipRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -Rule = Union[RuleRulesetsBlockRule, RuleRulesetsExecuteRule, RuleRulesetsLogRule, RuleRulesetsSkipRule] +Rule = Union[BlockRule, ExecuteRule, LogRule, SkipRule] class RuleCreateResponse(BaseModel): diff --git a/src/cloudflare/types/rulesets/rule_delete_response.py b/src/cloudflare/types/rulesets/rule_delete_response.py index 9e3879da2e4..7cc54b28eff 100644 --- a/src/cloudflare/types/rulesets/rule_delete_response.py +++ b/src/cloudflare/types/rulesets/rule_delete_response.py @@ -1,323 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Dict, List, Union, Optional +from typing import List, Union, Optional from datetime import datetime from typing_extensions import Literal -from ..shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from ..._models import BaseModel +from ..log_rule import LogRule +from ..skip_rule import SkipRule +from ..block_rule import BlockRule +from ..execute_rule import ExecuteRule -__all__ = [ - "RuleDeleteResponse", - "Rule", - "RuleRulesetsBlockRule", - "RuleRulesetsBlockRuleActionParameters", - "RuleRulesetsBlockRuleActionParametersResponse", - "RuleRulesetsExecuteRule", - "RuleRulesetsExecuteRuleActionParameters", - "RuleRulesetsExecuteRuleActionParametersMatchedData", - "RuleRulesetsExecuteRuleActionParametersOverrides", - "RuleRulesetsExecuteRuleActionParametersOverridesCategory", - "RuleRulesetsExecuteRuleActionParametersOverridesRule", - "RuleRulesetsLogRule", - "RuleRulesetsSkipRule", - "RuleRulesetsSkipRuleActionParameters", -] +__all__ = ["RuleDeleteResponse", "Rule"] - -class RuleRulesetsBlockRuleActionParametersResponse(BaseModel): - content: str - """The content to return.""" - - content_type: str - """The type of the content to return.""" - - status_code: int - """The status code to return.""" - - -class RuleRulesetsBlockRuleActionParameters(BaseModel): - response: Optional[RuleRulesetsBlockRuleActionParametersResponse] = None - """The response to show when the block is applied.""" - - -class RuleRulesetsBlockRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["block"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsBlockRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsExecuteRuleActionParametersMatchedData(BaseModel): - public_key: str - """The public key to encrypt matched data logs with.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesCategory(BaseModel): - category: str - """The name of the category to override.""" - - action: Optional[str] = None - """The action to override rules in the category with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of rules in the category.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for rules in the category.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesRule(BaseModel): - id: str - """The ID of the rule to override.""" - - action: Optional[str] = None - """The action to override the rule with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of the rule.""" - - score_threshold: Optional[int] = None - """The score threshold to use for the rule.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for the rule.""" - - -class RuleRulesetsExecuteRuleActionParametersOverrides(BaseModel): - action: Optional[str] = None - """An action to override all rules with. - - This option has lower precedence than rule and category overrides. - """ - - categories: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesCategory]] = None - """A list of category-level overrides. - - This option has the second-highest precedence after rule-level overrides. - """ - - enabled: Optional[bool] = None - """Whether to enable execution of all rules. - - This option has lower precedence than rule and category overrides. - """ - - rules: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesRule]] = None - """A list of rule-level overrides. This option has the highest precedence.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """A sensitivity level to set for all rules. - - This option has lower precedence than rule and category overrides and is only - applicable for DDoS phases. - """ - - -class RuleRulesetsExecuteRuleActionParameters(BaseModel): - id: str - """The ID of the ruleset to execute.""" - - matched_data: Optional[RuleRulesetsExecuteRuleActionParametersMatchedData] = None - """The configuration to use for matched data logging.""" - - overrides: Optional[RuleRulesetsExecuteRuleActionParametersOverrides] = None - """A set of overrides to apply to the target ruleset.""" - - -class RuleRulesetsExecuteRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["execute"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsExecuteRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsLogRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["log"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsSkipRuleActionParameters(BaseModel): - phases: Optional[ - List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] - ] = None - """A list of phases to skip the execution of. - - This option is incompatible with the ruleset and rulesets options. - """ - - products: Optional[ - List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] - ] = None - """A list of legacy security products to skip the execution of.""" - - rules: Optional[Dict[str, List[str]]] = None - """ - A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - execution of. This option is incompatible with the ruleset option. - """ - - ruleset: Optional[Literal["current"]] = None - """A ruleset to skip the execution of. - - This option is incompatible with the rulesets, rules and phases options. - """ - - rulesets: Optional[List[str]] = None - """A list of ruleset IDs to skip the execution of. - - This option is incompatible with the ruleset and phases options. - """ - - -class RuleRulesetsSkipRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["skip"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsSkipRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -Rule = Union[RuleRulesetsBlockRule, RuleRulesetsExecuteRule, RuleRulesetsLogRule, RuleRulesetsSkipRule] +Rule = Union[BlockRule, ExecuteRule, LogRule, SkipRule] class RuleDeleteResponse(BaseModel): diff --git a/src/cloudflare/types/rulesets/rule_edit_params.py b/src/cloudflare/types/rulesets/rule_edit_params.py index 2d951cf7ecf..d8f55fc560d 100644 --- a/src/cloudflare/types/rulesets/rule_edit_params.py +++ b/src/cloudflare/types/rulesets/rule_edit_params.py @@ -9,22 +9,22 @@ __all__ = [ "RuleEditParams", - "RulesetsBlockRule", - "RulesetsBlockRuleActionParameters", - "RulesetsBlockRuleActionParametersResponse", - "RulesetsExecuteRule", - "RulesetsExecuteRuleActionParameters", - "RulesetsExecuteRuleActionParametersMatchedData", - "RulesetsExecuteRuleActionParametersOverrides", - "RulesetsExecuteRuleActionParametersOverridesCategory", - "RulesetsExecuteRuleActionParametersOverridesRule", - "RulesetsLogRule", - "RulesetsSkipRule", - "RulesetsSkipRuleActionParameters", + "BlockRule", + "BlockRuleActionParameters", + "BlockRuleActionParametersResponse", + "ExecuteRule", + "ExecuteRuleActionParameters", + "ExecuteRuleActionParametersMatchedData", + "ExecuteRuleActionParametersOverrides", + "ExecuteRuleActionParametersOverridesCategory", + "ExecuteRuleActionParametersOverridesRule", + "LogRule", + "SkipRule", + "SkipRuleActionParameters", ] -class RulesetsBlockRule(TypedDict, total=False): +class BlockRule(TypedDict, total=False): ruleset_id: Required[str] """The unique ID of the ruleset.""" @@ -40,7 +40,7 @@ class RulesetsBlockRule(TypedDict, total=False): action: Literal["block"] """The action to perform when the rule matches.""" - action_parameters: RulesetsBlockRuleActionParameters + action_parameters: BlockRuleActionParameters """The parameters configuring the rule's action.""" description: str @@ -59,7 +59,7 @@ class RulesetsBlockRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class RulesetsBlockRuleActionParametersResponse(TypedDict, total=False): +class BlockRuleActionParametersResponse(TypedDict, total=False): content: Required[str] """The content to return.""" @@ -70,12 +70,12 @@ class RulesetsBlockRuleActionParametersResponse(TypedDict, total=False): """The status code to return.""" -class RulesetsBlockRuleActionParameters(TypedDict, total=False): - response: RulesetsBlockRuleActionParametersResponse +class BlockRuleActionParameters(TypedDict, total=False): + response: BlockRuleActionParametersResponse """The response to show when the block is applied.""" -class RulesetsExecuteRule(TypedDict, total=False): +class ExecuteRule(TypedDict, total=False): ruleset_id: Required[str] """The unique ID of the ruleset.""" @@ -91,7 +91,7 @@ class RulesetsExecuteRule(TypedDict, total=False): action: Literal["execute"] """The action to perform when the rule matches.""" - action_parameters: RulesetsExecuteRuleActionParameters + action_parameters: ExecuteRuleActionParameters """The parameters configuring the rule's action.""" description: str @@ -110,12 +110,12 @@ class RulesetsExecuteRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class RulesetsExecuteRuleActionParametersMatchedData(TypedDict, total=False): +class ExecuteRuleActionParametersMatchedData(TypedDict, total=False): public_key: Required[str] """The public key to encrypt matched data logs with.""" -class RulesetsExecuteRuleActionParametersOverridesCategory(TypedDict, total=False): +class ExecuteRuleActionParametersOverridesCategory(TypedDict, total=False): category: Required[str] """The name of the category to override.""" @@ -129,7 +129,7 @@ class RulesetsExecuteRuleActionParametersOverridesCategory(TypedDict, total=Fals """The sensitivity level to use for rules in the category.""" -class RulesetsExecuteRuleActionParametersOverridesRule(TypedDict, total=False): +class ExecuteRuleActionParametersOverridesRule(TypedDict, total=False): id: Required[str] """The ID of the rule to override.""" @@ -146,14 +146,14 @@ class RulesetsExecuteRuleActionParametersOverridesRule(TypedDict, total=False): """The sensitivity level to use for the rule.""" -class RulesetsExecuteRuleActionParametersOverrides(TypedDict, total=False): +class ExecuteRuleActionParametersOverrides(TypedDict, total=False): action: str """An action to override all rules with. This option has lower precedence than rule and category overrides. """ - categories: Iterable[RulesetsExecuteRuleActionParametersOverridesCategory] + categories: Iterable[ExecuteRuleActionParametersOverridesCategory] """A list of category-level overrides. This option has the second-highest precedence after rule-level overrides. @@ -165,7 +165,7 @@ class RulesetsExecuteRuleActionParametersOverrides(TypedDict, total=False): This option has lower precedence than rule and category overrides. """ - rules: Iterable[RulesetsExecuteRuleActionParametersOverridesRule] + rules: Iterable[ExecuteRuleActionParametersOverridesRule] """A list of rule-level overrides. This option has the highest precedence.""" sensitivity_level: Literal["default", "medium", "low", "eoff"] @@ -176,18 +176,18 @@ class RulesetsExecuteRuleActionParametersOverrides(TypedDict, total=False): """ -class RulesetsExecuteRuleActionParameters(TypedDict, total=False): +class ExecuteRuleActionParameters(TypedDict, total=False): id: Required[str] """The ID of the ruleset to execute.""" - matched_data: RulesetsExecuteRuleActionParametersMatchedData + matched_data: ExecuteRuleActionParametersMatchedData """The configuration to use for matched data logging.""" - overrides: RulesetsExecuteRuleActionParametersOverrides + overrides: ExecuteRuleActionParametersOverrides """A set of overrides to apply to the target ruleset.""" -class RulesetsLogRule(TypedDict, total=False): +class LogRule(TypedDict, total=False): ruleset_id: Required[str] """The unique ID of the ruleset.""" @@ -222,7 +222,7 @@ class RulesetsLogRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class RulesetsSkipRule(TypedDict, total=False): +class SkipRule(TypedDict, total=False): ruleset_id: Required[str] """The unique ID of the ruleset.""" @@ -238,7 +238,7 @@ class RulesetsSkipRule(TypedDict, total=False): action: Literal["skip"] """The action to perform when the rule matches.""" - action_parameters: RulesetsSkipRuleActionParameters + action_parameters: SkipRuleActionParameters """The parameters configuring the rule's action.""" description: str @@ -257,7 +257,7 @@ class RulesetsSkipRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class RulesetsSkipRuleActionParameters(TypedDict, total=False): +class SkipRuleActionParameters(TypedDict, total=False): phases: List[ Literal[ "ddos_l4", @@ -312,4 +312,4 @@ class RulesetsSkipRuleActionParameters(TypedDict, total=False): """ -RuleEditParams = Union[RulesetsBlockRule, RulesetsExecuteRule, RulesetsLogRule, RulesetsSkipRule] +RuleEditParams = Union[BlockRule, ExecuteRule, LogRule, SkipRule] diff --git a/src/cloudflare/types/rulesets/rule_edit_response.py b/src/cloudflare/types/rulesets/rule_edit_response.py index 79d7e1765f9..3b5c65d9c68 100644 --- a/src/cloudflare/types/rulesets/rule_edit_response.py +++ b/src/cloudflare/types/rulesets/rule_edit_response.py @@ -1,323 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Dict, List, Union, Optional +from typing import List, Union, Optional from datetime import datetime from typing_extensions import Literal -from ..shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from ..._models import BaseModel +from ..log_rule import LogRule +from ..skip_rule import SkipRule +from ..block_rule import BlockRule +from ..execute_rule import ExecuteRule -__all__ = [ - "RuleEditResponse", - "Rule", - "RuleRulesetsBlockRule", - "RuleRulesetsBlockRuleActionParameters", - "RuleRulesetsBlockRuleActionParametersResponse", - "RuleRulesetsExecuteRule", - "RuleRulesetsExecuteRuleActionParameters", - "RuleRulesetsExecuteRuleActionParametersMatchedData", - "RuleRulesetsExecuteRuleActionParametersOverrides", - "RuleRulesetsExecuteRuleActionParametersOverridesCategory", - "RuleRulesetsExecuteRuleActionParametersOverridesRule", - "RuleRulesetsLogRule", - "RuleRulesetsSkipRule", - "RuleRulesetsSkipRuleActionParameters", -] +__all__ = ["RuleEditResponse", "Rule"] - -class RuleRulesetsBlockRuleActionParametersResponse(BaseModel): - content: str - """The content to return.""" - - content_type: str - """The type of the content to return.""" - - status_code: int - """The status code to return.""" - - -class RuleRulesetsBlockRuleActionParameters(BaseModel): - response: Optional[RuleRulesetsBlockRuleActionParametersResponse] = None - """The response to show when the block is applied.""" - - -class RuleRulesetsBlockRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["block"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsBlockRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsExecuteRuleActionParametersMatchedData(BaseModel): - public_key: str - """The public key to encrypt matched data logs with.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesCategory(BaseModel): - category: str - """The name of the category to override.""" - - action: Optional[str] = None - """The action to override rules in the category with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of rules in the category.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for rules in the category.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesRule(BaseModel): - id: str - """The ID of the rule to override.""" - - action: Optional[str] = None - """The action to override the rule with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of the rule.""" - - score_threshold: Optional[int] = None - """The score threshold to use for the rule.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for the rule.""" - - -class RuleRulesetsExecuteRuleActionParametersOverrides(BaseModel): - action: Optional[str] = None - """An action to override all rules with. - - This option has lower precedence than rule and category overrides. - """ - - categories: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesCategory]] = None - """A list of category-level overrides. - - This option has the second-highest precedence after rule-level overrides. - """ - - enabled: Optional[bool] = None - """Whether to enable execution of all rules. - - This option has lower precedence than rule and category overrides. - """ - - rules: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesRule]] = None - """A list of rule-level overrides. This option has the highest precedence.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """A sensitivity level to set for all rules. - - This option has lower precedence than rule and category overrides and is only - applicable for DDoS phases. - """ - - -class RuleRulesetsExecuteRuleActionParameters(BaseModel): - id: str - """The ID of the ruleset to execute.""" - - matched_data: Optional[RuleRulesetsExecuteRuleActionParametersMatchedData] = None - """The configuration to use for matched data logging.""" - - overrides: Optional[RuleRulesetsExecuteRuleActionParametersOverrides] = None - """A set of overrides to apply to the target ruleset.""" - - -class RuleRulesetsExecuteRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["execute"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsExecuteRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsLogRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["log"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsSkipRuleActionParameters(BaseModel): - phases: Optional[ - List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] - ] = None - """A list of phases to skip the execution of. - - This option is incompatible with the ruleset and rulesets options. - """ - - products: Optional[ - List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] - ] = None - """A list of legacy security products to skip the execution of.""" - - rules: Optional[Dict[str, List[str]]] = None - """ - A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - execution of. This option is incompatible with the ruleset option. - """ - - ruleset: Optional[Literal["current"]] = None - """A ruleset to skip the execution of. - - This option is incompatible with the rulesets, rules and phases options. - """ - - rulesets: Optional[List[str]] = None - """A list of ruleset IDs to skip the execution of. - - This option is incompatible with the ruleset and phases options. - """ - - -class RuleRulesetsSkipRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["skip"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsSkipRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -Rule = Union[RuleRulesetsBlockRule, RuleRulesetsExecuteRule, RuleRulesetsLogRule, RuleRulesetsSkipRule] +Rule = Union[BlockRule, ExecuteRule, LogRule, SkipRule] class RuleEditResponse(BaseModel): diff --git a/src/cloudflare/types/rulesets/version_get_response.py b/src/cloudflare/types/rulesets/version_get_response.py index f4001774338..8e83b9cc69d 100644 --- a/src/cloudflare/types/rulesets/version_get_response.py +++ b/src/cloudflare/types/rulesets/version_get_response.py @@ -1,323 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Dict, List, Union, Optional +from typing import List, Union, Optional from datetime import datetime from typing_extensions import Literal -from ..shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from ..._models import BaseModel +from ..log_rule import LogRule +from ..skip_rule import SkipRule +from ..block_rule import BlockRule +from ..execute_rule import ExecuteRule -__all__ = [ - "VersionGetResponse", - "Rule", - "RuleRulesetsBlockRule", - "RuleRulesetsBlockRuleActionParameters", - "RuleRulesetsBlockRuleActionParametersResponse", - "RuleRulesetsExecuteRule", - "RuleRulesetsExecuteRuleActionParameters", - "RuleRulesetsExecuteRuleActionParametersMatchedData", - "RuleRulesetsExecuteRuleActionParametersOverrides", - "RuleRulesetsExecuteRuleActionParametersOverridesCategory", - "RuleRulesetsExecuteRuleActionParametersOverridesRule", - "RuleRulesetsLogRule", - "RuleRulesetsSkipRule", - "RuleRulesetsSkipRuleActionParameters", -] +__all__ = ["VersionGetResponse", "Rule"] - -class RuleRulesetsBlockRuleActionParametersResponse(BaseModel): - content: str - """The content to return.""" - - content_type: str - """The type of the content to return.""" - - status_code: int - """The status code to return.""" - - -class RuleRulesetsBlockRuleActionParameters(BaseModel): - response: Optional[RuleRulesetsBlockRuleActionParametersResponse] = None - """The response to show when the block is applied.""" - - -class RuleRulesetsBlockRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["block"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsBlockRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsExecuteRuleActionParametersMatchedData(BaseModel): - public_key: str - """The public key to encrypt matched data logs with.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesCategory(BaseModel): - category: str - """The name of the category to override.""" - - action: Optional[str] = None - """The action to override rules in the category with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of rules in the category.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for rules in the category.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesRule(BaseModel): - id: str - """The ID of the rule to override.""" - - action: Optional[str] = None - """The action to override the rule with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of the rule.""" - - score_threshold: Optional[int] = None - """The score threshold to use for the rule.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for the rule.""" - - -class RuleRulesetsExecuteRuleActionParametersOverrides(BaseModel): - action: Optional[str] = None - """An action to override all rules with. - - This option has lower precedence than rule and category overrides. - """ - - categories: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesCategory]] = None - """A list of category-level overrides. - - This option has the second-highest precedence after rule-level overrides. - """ - - enabled: Optional[bool] = None - """Whether to enable execution of all rules. - - This option has lower precedence than rule and category overrides. - """ - - rules: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesRule]] = None - """A list of rule-level overrides. This option has the highest precedence.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """A sensitivity level to set for all rules. - - This option has lower precedence than rule and category overrides and is only - applicable for DDoS phases. - """ - - -class RuleRulesetsExecuteRuleActionParameters(BaseModel): - id: str - """The ID of the ruleset to execute.""" - - matched_data: Optional[RuleRulesetsExecuteRuleActionParametersMatchedData] = None - """The configuration to use for matched data logging.""" - - overrides: Optional[RuleRulesetsExecuteRuleActionParametersOverrides] = None - """A set of overrides to apply to the target ruleset.""" - - -class RuleRulesetsExecuteRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["execute"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsExecuteRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsLogRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["log"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsSkipRuleActionParameters(BaseModel): - phases: Optional[ - List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] - ] = None - """A list of phases to skip the execution of. - - This option is incompatible with the ruleset and rulesets options. - """ - - products: Optional[ - List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] - ] = None - """A list of legacy security products to skip the execution of.""" - - rules: Optional[Dict[str, List[str]]] = None - """ - A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - execution of. This option is incompatible with the ruleset option. - """ - - ruleset: Optional[Literal["current"]] = None - """A ruleset to skip the execution of. - - This option is incompatible with the rulesets, rules and phases options. - """ - - rulesets: Optional[List[str]] = None - """A list of ruleset IDs to skip the execution of. - - This option is incompatible with the ruleset and phases options. - """ - - -class RuleRulesetsSkipRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["skip"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsSkipRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -Rule = Union[RuleRulesetsBlockRule, RuleRulesetsExecuteRule, RuleRulesetsLogRule, RuleRulesetsSkipRule] +Rule = Union[BlockRule, ExecuteRule, LogRule, SkipRule] class VersionGetResponse(BaseModel): diff --git a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py index 1e8f04fc00a..fd0d26701d9 100644 --- a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py +++ b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py @@ -1,323 +1,18 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Dict, List, Union, Optional +from typing import List, Union, Optional from datetime import datetime from typing_extensions import Literal -from ...shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from ...._models import BaseModel +from ...log_rule import LogRule +from ...skip_rule import SkipRule +from ...block_rule import BlockRule +from ...execute_rule import ExecuteRule -__all__ = [ - "ByTagGetResponse", - "Rule", - "RuleRulesetsBlockRule", - "RuleRulesetsBlockRuleActionParameters", - "RuleRulesetsBlockRuleActionParametersResponse", - "RuleRulesetsExecuteRule", - "RuleRulesetsExecuteRuleActionParameters", - "RuleRulesetsExecuteRuleActionParametersMatchedData", - "RuleRulesetsExecuteRuleActionParametersOverrides", - "RuleRulesetsExecuteRuleActionParametersOverridesCategory", - "RuleRulesetsExecuteRuleActionParametersOverridesRule", - "RuleRulesetsLogRule", - "RuleRulesetsSkipRule", - "RuleRulesetsSkipRuleActionParameters", -] +__all__ = ["ByTagGetResponse", "Rule"] - -class RuleRulesetsBlockRuleActionParametersResponse(BaseModel): - content: str - """The content to return.""" - - content_type: str - """The type of the content to return.""" - - status_code: int - """The status code to return.""" - - -class RuleRulesetsBlockRuleActionParameters(BaseModel): - response: Optional[RuleRulesetsBlockRuleActionParametersResponse] = None - """The response to show when the block is applied.""" - - -class RuleRulesetsBlockRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["block"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsBlockRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsExecuteRuleActionParametersMatchedData(BaseModel): - public_key: str - """The public key to encrypt matched data logs with.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesCategory(BaseModel): - category: str - """The name of the category to override.""" - - action: Optional[str] = None - """The action to override rules in the category with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of rules in the category.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for rules in the category.""" - - -class RuleRulesetsExecuteRuleActionParametersOverridesRule(BaseModel): - id: str - """The ID of the rule to override.""" - - action: Optional[str] = None - """The action to override the rule with.""" - - enabled: Optional[bool] = None - """Whether to enable execution of the rule.""" - - score_threshold: Optional[int] = None - """The score threshold to use for the rule.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """The sensitivity level to use for the rule.""" - - -class RuleRulesetsExecuteRuleActionParametersOverrides(BaseModel): - action: Optional[str] = None - """An action to override all rules with. - - This option has lower precedence than rule and category overrides. - """ - - categories: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesCategory]] = None - """A list of category-level overrides. - - This option has the second-highest precedence after rule-level overrides. - """ - - enabled: Optional[bool] = None - """Whether to enable execution of all rules. - - This option has lower precedence than rule and category overrides. - """ - - rules: Optional[List[RuleRulesetsExecuteRuleActionParametersOverridesRule]] = None - """A list of rule-level overrides. This option has the highest precedence.""" - - sensitivity_level: Optional[Literal["default", "medium", "low", "eoff"]] = None - """A sensitivity level to set for all rules. - - This option has lower precedence than rule and category overrides and is only - applicable for DDoS phases. - """ - - -class RuleRulesetsExecuteRuleActionParameters(BaseModel): - id: str - """The ID of the ruleset to execute.""" - - matched_data: Optional[RuleRulesetsExecuteRuleActionParametersMatchedData] = None - """The configuration to use for matched data logging.""" - - overrides: Optional[RuleRulesetsExecuteRuleActionParametersOverrides] = None - """A set of overrides to apply to the target ruleset.""" - - -class RuleRulesetsExecuteRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["execute"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsExecuteRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsLogRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["log"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[object] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -class RuleRulesetsSkipRuleActionParameters(BaseModel): - phases: Optional[ - List[ - Literal[ - "ddos_l4", - "ddos_l7", - "http_config_settings", - "http_custom_errors", - "http_log_custom_fields", - "http_ratelimit", - "http_request_cache_settings", - "http_request_dynamic_redirect", - "http_request_firewall_custom", - "http_request_firewall_managed", - "http_request_late_transform", - "http_request_origin", - "http_request_redirect", - "http_request_sanitize", - "http_request_sbfm", - "http_request_select_configuration", - "http_request_transform", - "http_response_compression", - "http_response_firewall_managed", - "http_response_headers_transform", - "magic_transit", - "magic_transit_ids_managed", - "magic_transit_managed", - ] - ] - ] = None - """A list of phases to skip the execution of. - - This option is incompatible with the ruleset and rulesets options. - """ - - products: Optional[ - List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] - ] = None - """A list of legacy security products to skip the execution of.""" - - rules: Optional[Dict[str, List[str]]] = None - """ - A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - execution of. This option is incompatible with the ruleset option. - """ - - ruleset: Optional[Literal["current"]] = None - """A ruleset to skip the execution of. - - This option is incompatible with the rulesets, rules and phases options. - """ - - rulesets: Optional[List[str]] = None - """A list of ruleset IDs to skip the execution of. - - This option is incompatible with the ruleset and phases options. - """ - - -class RuleRulesetsSkipRule(BaseModel): - last_updated: datetime - """The timestamp of when the rule was last modified.""" - - version: str - """The version of the rule.""" - - id: Optional[str] = None - """The unique ID of the rule.""" - - action: Optional[Literal["skip"]] = None - """The action to perform when the rule matches.""" - - action_parameters: Optional[RuleRulesetsSkipRuleActionParameters] = None - """The parameters configuring the rule's action.""" - - categories: Optional[List[str]] = None - """The categories of the rule.""" - - description: Optional[str] = None - """An informative description of the rule.""" - - enabled: Optional[bool] = None - """Whether the rule should be executed.""" - - expression: Optional[str] = None - """The expression defining which traffic will match the rule.""" - - logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None - """An object configuring the rule's logging behavior.""" - - ref: Optional[str] = None - """The reference of the rule (the rule ID by default).""" - - -Rule = Union[RuleRulesetsBlockRule, RuleRulesetsExecuteRule, RuleRulesetsLogRule, RuleRulesetsSkipRule] +Rule = Union[BlockRule, ExecuteRule, LogRule, SkipRule] class ByTagGetResponse(BaseModel): diff --git a/src/cloudflare/types/skip_rule.py b/src/cloudflare/types/skip_rule.py new file mode 100644 index 00000000000..a5992d766e6 --- /dev/null +++ b/src/cloudflare/types/skip_rule.py @@ -0,0 +1,104 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, List, Optional +from datetime import datetime +from typing_extensions import Literal + +from .shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c +from .._models import BaseModel + +__all__ = ["SkipRule", "ActionParameters"] + + +class ActionParameters(BaseModel): + phases: Optional[ + List[ + Literal[ + "ddos_l4", + "ddos_l7", + "http_config_settings", + "http_custom_errors", + "http_log_custom_fields", + "http_ratelimit", + "http_request_cache_settings", + "http_request_dynamic_redirect", + "http_request_firewall_custom", + "http_request_firewall_managed", + "http_request_late_transform", + "http_request_origin", + "http_request_redirect", + "http_request_sanitize", + "http_request_sbfm", + "http_request_select_configuration", + "http_request_transform", + "http_response_compression", + "http_response_firewall_managed", + "http_response_headers_transform", + "magic_transit", + "magic_transit_ids_managed", + "magic_transit_managed", + ] + ] + ] = None + """A list of phases to skip the execution of. + + This option is incompatible with the ruleset and rulesets options. + """ + + products: Optional[ + List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] + ] = None + """A list of legacy security products to skip the execution of.""" + + rules: Optional[Dict[str, List[str]]] = None + """ + A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the + execution of. This option is incompatible with the ruleset option. + """ + + ruleset: Optional[Literal["current"]] = None + """A ruleset to skip the execution of. + + This option is incompatible with the rulesets, rules and phases options. + """ + + rulesets: Optional[List[str]] = None + """A list of ruleset IDs to skip the execution of. + + This option is incompatible with the ruleset and phases options. + """ + + +class SkipRule(BaseModel): + last_updated: datetime + """The timestamp of when the rule was last modified.""" + + version: str + """The version of the rule.""" + + id: Optional[str] = None + """The unique ID of the rule.""" + + action: Optional[Literal["skip"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[ActionParameters] = None + """The parameters configuring the rule's action.""" + + categories: Optional[List[str]] = None + """The categories of the rule.""" + + description: Optional[str] = None + """An informative description of the rule.""" + + enabled: Optional[bool] = None + """Whether the rule should be executed.""" + + expression: Optional[str] = None + """The expression defining which traffic will match the rule.""" + + logging: Optional[UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" diff --git a/src/cloudflare/types/skip_rule_param.py b/src/cloudflare/types/skip_rule_param.py new file mode 100644 index 00000000000..6e470369cfc --- /dev/null +++ b/src/cloudflare/types/skip_rule_param.py @@ -0,0 +1,91 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, List +from typing_extensions import Literal, TypedDict + +from ..types import shared_params + +__all__ = ["SkipRuleParam", "ActionParameters"] + + +class ActionParameters(TypedDict, total=False): + phases: List[ + Literal[ + "ddos_l4", + "ddos_l7", + "http_config_settings", + "http_custom_errors", + "http_log_custom_fields", + "http_ratelimit", + "http_request_cache_settings", + "http_request_dynamic_redirect", + "http_request_firewall_custom", + "http_request_firewall_managed", + "http_request_late_transform", + "http_request_origin", + "http_request_redirect", + "http_request_sanitize", + "http_request_sbfm", + "http_request_select_configuration", + "http_request_transform", + "http_response_compression", + "http_response_firewall_managed", + "http_response_headers_transform", + "magic_transit", + "magic_transit_ids_managed", + "magic_transit_managed", + ] + ] + """A list of phases to skip the execution of. + + This option is incompatible with the ruleset and rulesets options. + """ + + products: List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] + """A list of legacy security products to skip the execution of.""" + + rules: Dict[str, List[str]] + """ + A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the + execution of. This option is incompatible with the ruleset option. + """ + + ruleset: Literal["current"] + """A ruleset to skip the execution of. + + This option is incompatible with the rulesets, rules and phases options. + """ + + rulesets: List[str] + """A list of ruleset IDs to skip the execution of. + + This option is incompatible with the ruleset and phases options. + """ + + +class SkipRuleParam(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["skip"] + """The action to perform when the rule matches.""" + + action_parameters: ActionParameters + """The parameters configuring the rule's action.""" + + description: str + """An informative description of the rule.""" + + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: shared_params.UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default)."""