From 04f7e9d1ac6b696fe5042f5c2554dbd4e8d4b0ae Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 23:52:21 +0000 Subject: [PATCH] feat(api): update via SDK Studio (#254) --- api.md | 5 - .../resources/rulesets/phases/phases.py | 5 +- src/cloudflare/resources/rulesets/rules.py | 48 +-- src/cloudflare/resources/rulesets/rulesets.py | 9 +- src/cloudflare/types/__init__.py | 10 - src/cloudflare/types/block_rule.py | 61 ---- src/cloudflare/types/block_rule_param.py | 51 --- src/cloudflare/types/execute_rule.py | 129 ------- src/cloudflare/types/execute_rule_param.py | 120 ------- src/cloudflare/types/log_rule.py | 45 --- src/cloudflare/types/log_rule_param.py | 35 -- src/cloudflare/types/request_rule.py | 12 - src/cloudflare/types/request_rule_param.py | 14 - src/cloudflare/types/ruleset_create_params.py | 278 ++++++++++++++- .../types/ruleset_create_response.py | 318 +++++++++++++++++- src/cloudflare/types/ruleset_get_response.py | 318 +++++++++++++++++- src/cloudflare/types/ruleset_update_params.py | 278 ++++++++++++++- .../types/ruleset_update_response.py | 318 +++++++++++++++++- .../types/rulesets/phase_get_response.py | 318 +++++++++++++++++- .../types/rulesets/phase_update_params.py | 278 ++++++++++++++- .../types/rulesets/phase_update_response.py | 318 +++++++++++++++++- .../rulesets/phases/version_get_response.py | 318 +++++++++++++++++- .../types/rulesets/rule_create_params.py | 66 ++-- .../types/rulesets/rule_create_response.py | 318 +++++++++++++++++- .../types/rulesets/rule_delete_response.py | 318 +++++++++++++++++- .../types/rulesets/rule_edit_params.py | 66 ++-- .../types/rulesets/rule_edit_response.py | 318 +++++++++++++++++- .../types/rulesets/version_get_response.py | 318 +++++++++++++++++- .../rulesets/versions/by_tag_get_response.py | 318 +++++++++++++++++- src/cloudflare/types/skip_rule.py | 104 ------ src/cloudflare/types/skip_rule_param.py | 91 ----- 31 files changed, 4372 insertions(+), 831 deletions(-) delete mode 100644 src/cloudflare/types/block_rule.py delete mode 100644 src/cloudflare/types/block_rule_param.py delete mode 100644 src/cloudflare/types/execute_rule.py delete mode 100644 src/cloudflare/types/execute_rule_param.py delete mode 100644 src/cloudflare/types/log_rule.py delete mode 100644 src/cloudflare/types/log_rule_param.py delete mode 100644 src/cloudflare/types/request_rule.py delete mode 100644 src/cloudflare/types/request_rule_param.py delete mode 100644 src/cloudflare/types/skip_rule.py delete mode 100644 src/cloudflare/types/skip_rule_param.py diff --git a/api.md b/api.md index 5e5bebd996b..96230c4792a 100644 --- a/api.md +++ b/api.md @@ -2932,12 +2932,7 @@ Types: ```python from cloudflare.types import ( - BlockRule, - ExecuteRule, - LogRule, - RequestRule, Ruleset, - SkipRule, RulesetCreateResponse, RulesetUpdateResponse, RulesetGetResponse, diff --git a/src/cloudflare/resources/rulesets/phases/phases.py b/src/cloudflare/resources/rulesets/phases/phases.py index 0900e523671..cc59c4d3d6f 100644 --- a/src/cloudflare/resources/rulesets/phases/phases.py +++ b/src/cloudflare/resources/rulesets/phases/phases.py @@ -7,7 +7,6 @@ import httpx -from ....types import RequestRuleParam from .versions import ( Versions, AsyncVersions, @@ -79,7 +78,7 @@ def update( "magic_transit_managed", ], *, - rules: Iterable[RequestRuleParam], + rules: Iterable[phase_update_params.Rule], account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, @@ -312,7 +311,7 @@ async def update( "magic_transit_managed", ], *, - rules: Iterable[RequestRuleParam], + rules: Iterable[phase_update_params.Rule], account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, diff --git a/src/cloudflare/resources/rulesets/rules.py b/src/cloudflare/resources/rulesets/rules.py index 826ab6a3b4c..d8031bc9a4f 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.BlockRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsBlockRuleActionParameters | 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.ExecuteRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsExecuteRuleActionParameters | 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.SkipRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsSkipRuleActionParameters | 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.BlockRuleActionParameters - | rule_create_params.ExecuteRuleActionParameters + action_parameters: rule_create_params.RulesetsBlockRuleActionParameters + | rule_create_params.RulesetsExecuteRuleActionParameters | object - | rule_create_params.SkipRuleActionParameters + | rule_create_params.RulesetsSkipRuleActionParameters | 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.BlockRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsBlockRuleActionParameters | 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.ExecuteRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsExecuteRuleActionParameters | 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.SkipRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsSkipRuleActionParameters | 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.BlockRuleActionParameters - | rule_edit_params.ExecuteRuleActionParameters + action_parameters: rule_edit_params.RulesetsBlockRuleActionParameters + | rule_edit_params.RulesetsExecuteRuleActionParameters | object - | rule_edit_params.SkipRuleActionParameters + | rule_edit_params.RulesetsSkipRuleActionParameters | 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.BlockRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsBlockRuleActionParameters | 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.ExecuteRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsExecuteRuleActionParameters | 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.SkipRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsSkipRuleActionParameters | 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.BlockRuleActionParameters - | rule_create_params.ExecuteRuleActionParameters + action_parameters: rule_create_params.RulesetsBlockRuleActionParameters + | rule_create_params.RulesetsExecuteRuleActionParameters | object - | rule_create_params.SkipRuleActionParameters + | rule_create_params.RulesetsSkipRuleActionParameters | 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.BlockRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsBlockRuleActionParameters | 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.ExecuteRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsExecuteRuleActionParameters | 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.SkipRuleActionParameters | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsSkipRuleActionParameters | 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.BlockRuleActionParameters - | rule_edit_params.ExecuteRuleActionParameters + action_parameters: rule_edit_params.RulesetsBlockRuleActionParameters + | rule_edit_params.RulesetsExecuteRuleActionParameters | object - | rule_edit_params.SkipRuleActionParameters + | rule_edit_params.RulesetsSkipRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, diff --git a/src/cloudflare/resources/rulesets/rulesets.py b/src/cloudflare/resources/rulesets/rulesets.py index 3fcb3c271fd..e88c1e2317a 100644 --- a/src/cloudflare/resources/rulesets/rulesets.py +++ b/src/cloudflare/resources/rulesets/rulesets.py @@ -25,7 +25,6 @@ ) from ...types import ( Ruleset, - RequestRuleParam, RulesetGetResponse, RulesetCreateResponse, RulesetUpdateResponse, @@ -116,7 +115,7 @@ def create( "magic_transit_ids_managed", "magic_transit_managed", ], - rules: Iterable[RequestRuleParam], + rules: Iterable[ruleset_create_params.Rule], account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, @@ -194,7 +193,7 @@ def update( self, ruleset_id: str, *, - rules: Iterable[RequestRuleParam], + rules: Iterable[ruleset_update_params.Rule], account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, @@ -521,7 +520,7 @@ async def create( "magic_transit_ids_managed", "magic_transit_managed", ], - rules: Iterable[RequestRuleParam], + rules: Iterable[ruleset_create_params.Rule], account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, @@ -599,7 +598,7 @@ async def update( self, ruleset_id: str, *, - rules: Iterable[RequestRuleParam], + rules: Iterable[ruleset_update_params.Rule], account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, diff --git a/src/cloudflare/types/__init__.py b/src/cloudflare/types/__init__.py index fd5dc24b9cc..4df660b2fd5 100644 --- a/src/cloudflare/types/__init__.py +++ b/src/cloudflare/types/__init__.py @@ -42,15 +42,12 @@ 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 @@ -64,11 +61,9 @@ 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 -from .request_rule import RequestRule as RequestRule from .targes_param import TargesParam as TargesParam from .tunnel_param import TunnelParam as TunnelParam from .waiting_room import WaitingRoom as WaitingRoom @@ -82,7 +77,6 @@ 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 @@ -90,9 +84,7 @@ 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 @@ -117,14 +109,12 @@ 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 from .pcap_create_params import PCAPCreateParams as PCAPCreateParams from .pcap_list_response import PCAPListResponse as PCAPListResponse from .queue_get_response import QueueGetResponse as QueueGetResponse -from .request_rule_param import RequestRuleParam as RequestRuleParam from .stream_list_params import StreamListParams as StreamListParams from .zone_create_params import ZoneCreateParams as ZoneCreateParams from .account_list_params import AccountListParams as AccountListParams diff --git a/src/cloudflare/types/block_rule.py b/src/cloudflare/types/block_rule.py deleted file mode 100644 index 892d6e2b4f2..00000000000 --- a/src/cloudflare/types/block_rule.py +++ /dev/null @@ -1,61 +0,0 @@ -# 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 deleted file mode 100644 index 4aeafe363ae..00000000000 --- a/src/cloudflare/types/block_rule_param.py +++ /dev/null @@ -1,51 +0,0 @@ -# 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 deleted file mode 100644 index 0ef99597a8f..00000000000 --- a/src/cloudflare/types/execute_rule.py +++ /dev/null @@ -1,129 +0,0 @@ -# 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 deleted file mode 100644 index fa4d5b253dc..00000000000 --- a/src/cloudflare/types/execute_rule_param.py +++ /dev/null @@ -1,120 +0,0 @@ -# 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 deleted file mode 100644 index b9a76d3dbba..00000000000 --- a/src/cloudflare/types/log_rule.py +++ /dev/null @@ -1,45 +0,0 @@ -# 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 deleted file mode 100644 index 344e1b35a81..00000000000 --- a/src/cloudflare/types/log_rule_param.py +++ /dev/null @@ -1,35 +0,0 @@ -# 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/request_rule.py b/src/cloudflare/types/request_rule.py deleted file mode 100644 index a71cd7d6034..00000000000 --- a/src/cloudflare/types/request_rule.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Union - -from .log_rule import LogRule -from .skip_rule import SkipRule -from .block_rule import BlockRule -from .execute_rule import ExecuteRule - -__all__ = ["RequestRule"] - -RequestRule = Union[BlockRule, ExecuteRule, LogRule, SkipRule] diff --git a/src/cloudflare/types/request_rule_param.py b/src/cloudflare/types/request_rule_param.py deleted file mode 100644 index 709767e34b6..00000000000 --- a/src/cloudflare/types/request_rule_param.py +++ /dev/null @@ -1,14 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Union - -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__ = ["RequestRuleParam"] - -RequestRuleParam = Union[BlockRuleParam, ExecuteRuleParam, LogRuleParam, SkipRuleParam] diff --git a/src/cloudflare/types/ruleset_create_params.py b/src/cloudflare/types/ruleset_create_params.py index 27128c076da..cea7f724ade 100644 --- a/src/cloudflare/types/ruleset_create_params.py +++ b/src/cloudflare/types/ruleset_create_params.py @@ -2,12 +2,27 @@ from __future__ import annotations -from typing import Iterable +from typing import Dict, List, Union, Iterable from typing_extensions import Literal, Required, TypedDict -from .request_rule_param import RequestRuleParam +from ..types import shared_params -__all__ = ["RulesetCreateParams"] +__all__ = [ + "RulesetCreateParams", + "Rule", + "RuleRulesetsBlockRule", + "RuleRulesetsBlockRuleActionParameters", + "RuleRulesetsBlockRuleActionParametersResponse", + "RuleRulesetsExecuteRule", + "RuleRulesetsExecuteRuleActionParameters", + "RuleRulesetsExecuteRuleActionParametersMatchedData", + "RuleRulesetsExecuteRuleActionParametersOverrides", + "RuleRulesetsExecuteRuleActionParametersOverridesCategory", + "RuleRulesetsExecuteRuleActionParametersOverridesRule", + "RuleRulesetsLogRule", + "RuleRulesetsSkipRule", + "RuleRulesetsSkipRuleActionParameters", +] class RulesetCreateParams(TypedDict, total=False): @@ -46,7 +61,7 @@ class RulesetCreateParams(TypedDict, total=False): ] """The phase of the ruleset.""" - rules: Required[Iterable[RequestRuleParam]] + rules: Required[Iterable[Rule]] """The list of rules in the ruleset.""" account_id: str @@ -57,3 +72,258 @@ class RulesetCreateParams(TypedDict, total=False): description: str """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] diff --git a/src/cloudflare/types/ruleset_create_response.py b/src/cloudflare/types/ruleset_create_response.py index ec9b42b31f6..45c02ec1b65 100644 --- a/src/cloudflare/types/ruleset_create_response.py +++ b/src/cloudflare/types/ruleset_create_response.py @@ -1,13 +1,323 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from .shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from .._models import BaseModel -from .request_rule import RequestRule -__all__ = ["RulesetCreateResponse"] +__all__ = [ + "RulesetCreateResponse", + "Rule", + "RuleRulesetsBlockRule", + "RuleRulesetsBlockRuleActionParameters", + "RuleRulesetsBlockRuleActionParametersResponse", + "RuleRulesetsExecuteRule", + "RuleRulesetsExecuteRuleActionParameters", + "RuleRulesetsExecuteRuleActionParametersMatchedData", + "RuleRulesetsExecuteRuleActionParametersOverrides", + "RuleRulesetsExecuteRuleActionParametersOverridesCategory", + "RuleRulesetsExecuteRuleActionParametersOverridesRule", + "RuleRulesetsLogRule", + "RuleRulesetsSkipRule", + "RuleRulesetsSkipRuleActionParameters", +] + + +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] class RulesetCreateResponse(BaseModel): @@ -50,7 +360,7 @@ class RulesetCreateResponse(BaseModel): ] """The phase of the ruleset.""" - rules: List[RequestRule] + rules: List[Rule] """The list of rules in the ruleset.""" version: str diff --git a/src/cloudflare/types/ruleset_get_response.py b/src/cloudflare/types/ruleset_get_response.py index da086d15e8b..8dd2e94525e 100644 --- a/src/cloudflare/types/ruleset_get_response.py +++ b/src/cloudflare/types/ruleset_get_response.py @@ -1,13 +1,323 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from .shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from .._models import BaseModel -from .request_rule import RequestRule -__all__ = ["RulesetGetResponse"] +__all__ = [ + "RulesetGetResponse", + "Rule", + "RuleRulesetsBlockRule", + "RuleRulesetsBlockRuleActionParameters", + "RuleRulesetsBlockRuleActionParametersResponse", + "RuleRulesetsExecuteRule", + "RuleRulesetsExecuteRuleActionParameters", + "RuleRulesetsExecuteRuleActionParametersMatchedData", + "RuleRulesetsExecuteRuleActionParametersOverrides", + "RuleRulesetsExecuteRuleActionParametersOverridesCategory", + "RuleRulesetsExecuteRuleActionParametersOverridesRule", + "RuleRulesetsLogRule", + "RuleRulesetsSkipRule", + "RuleRulesetsSkipRuleActionParameters", +] + + +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] class RulesetGetResponse(BaseModel): @@ -50,7 +360,7 @@ class RulesetGetResponse(BaseModel): ] """The phase of the ruleset.""" - rules: List[RequestRule] + rules: List[Rule] """The list of rules in the ruleset.""" version: str diff --git a/src/cloudflare/types/ruleset_update_params.py b/src/cloudflare/types/ruleset_update_params.py index 1c0d34cd3e2..5a623bd2b84 100644 --- a/src/cloudflare/types/ruleset_update_params.py +++ b/src/cloudflare/types/ruleset_update_params.py @@ -2,16 +2,31 @@ from __future__ import annotations -from typing import Iterable +from typing import Dict, List, Union, Iterable from typing_extensions import Literal, Required, TypedDict -from .request_rule_param import RequestRuleParam +from ..types import shared_params -__all__ = ["RulesetUpdateParams"] +__all__ = [ + "RulesetUpdateParams", + "Rule", + "RuleRulesetsBlockRule", + "RuleRulesetsBlockRuleActionParameters", + "RuleRulesetsBlockRuleActionParametersResponse", + "RuleRulesetsExecuteRule", + "RuleRulesetsExecuteRuleActionParameters", + "RuleRulesetsExecuteRuleActionParametersMatchedData", + "RuleRulesetsExecuteRuleActionParametersOverrides", + "RuleRulesetsExecuteRuleActionParametersOverridesCategory", + "RuleRulesetsExecuteRuleActionParametersOverridesRule", + "RuleRulesetsLogRule", + "RuleRulesetsSkipRule", + "RuleRulesetsSkipRuleActionParameters", +] class RulesetUpdateParams(TypedDict, total=False): - rules: Required[Iterable[RequestRuleParam]] + rules: Required[Iterable[Rule]] """The list of rules in the ruleset.""" account_id: str @@ -55,3 +70,258 @@ class RulesetUpdateParams(TypedDict, total=False): "magic_transit_managed", ] """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] diff --git a/src/cloudflare/types/ruleset_update_response.py b/src/cloudflare/types/ruleset_update_response.py index 3ea7e8ca5a2..e81480c5118 100644 --- a/src/cloudflare/types/ruleset_update_response.py +++ b/src/cloudflare/types/ruleset_update_response.py @@ -1,13 +1,323 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from .shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from .._models import BaseModel -from .request_rule import RequestRule -__all__ = ["RulesetUpdateResponse"] +__all__ = [ + "RulesetUpdateResponse", + "Rule", + "RuleRulesetsBlockRule", + "RuleRulesetsBlockRuleActionParameters", + "RuleRulesetsBlockRuleActionParametersResponse", + "RuleRulesetsExecuteRule", + "RuleRulesetsExecuteRuleActionParameters", + "RuleRulesetsExecuteRuleActionParametersMatchedData", + "RuleRulesetsExecuteRuleActionParametersOverrides", + "RuleRulesetsExecuteRuleActionParametersOverridesCategory", + "RuleRulesetsExecuteRuleActionParametersOverridesRule", + "RuleRulesetsLogRule", + "RuleRulesetsSkipRule", + "RuleRulesetsSkipRuleActionParameters", +] + + +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] class RulesetUpdateResponse(BaseModel): @@ -50,7 +360,7 @@ class RulesetUpdateResponse(BaseModel): ] """The phase of the ruleset.""" - rules: List[RequestRule] + rules: List[Rule] """The list of rules in the ruleset.""" version: str diff --git a/src/cloudflare/types/rulesets/phase_get_response.py b/src/cloudflare/types/rulesets/phase_get_response.py index b738b3189b0..cf88a2b387a 100644 --- a/src/cloudflare/types/rulesets/phase_get_response.py +++ b/src/cloudflare/types/rulesets/phase_get_response.py @@ -1,13 +1,323 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from ..shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from ..._models import BaseModel -from ..request_rule import RequestRule -__all__ = ["PhaseGetResponse"] +__all__ = [ + "PhaseGetResponse", + "Rule", + "RuleRulesetsBlockRule", + "RuleRulesetsBlockRuleActionParameters", + "RuleRulesetsBlockRuleActionParametersResponse", + "RuleRulesetsExecuteRule", + "RuleRulesetsExecuteRuleActionParameters", + "RuleRulesetsExecuteRuleActionParametersMatchedData", + "RuleRulesetsExecuteRuleActionParametersOverrides", + "RuleRulesetsExecuteRuleActionParametersOverridesCategory", + "RuleRulesetsExecuteRuleActionParametersOverridesRule", + "RuleRulesetsLogRule", + "RuleRulesetsSkipRule", + "RuleRulesetsSkipRuleActionParameters", +] + + +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] class PhaseGetResponse(BaseModel): @@ -50,7 +360,7 @@ class PhaseGetResponse(BaseModel): ] """The phase of the ruleset.""" - rules: List[RequestRule] + rules: List[Rule] """The list of rules in the ruleset.""" version: str diff --git a/src/cloudflare/types/rulesets/phase_update_params.py b/src/cloudflare/types/rulesets/phase_update_params.py index 6358187dc13..ee0dd31a575 100644 --- a/src/cloudflare/types/rulesets/phase_update_params.py +++ b/src/cloudflare/types/rulesets/phase_update_params.py @@ -2,16 +2,31 @@ from __future__ import annotations -from typing import Iterable +from typing import Dict, List, Union, Iterable from typing_extensions import Literal, Required, TypedDict -from ..request_rule_param import RequestRuleParam +from ...types import shared_params -__all__ = ["PhaseUpdateParams"] +__all__ = [ + "PhaseUpdateParams", + "Rule", + "RuleRulesetsBlockRule", + "RuleRulesetsBlockRuleActionParameters", + "RuleRulesetsBlockRuleActionParametersResponse", + "RuleRulesetsExecuteRule", + "RuleRulesetsExecuteRuleActionParameters", + "RuleRulesetsExecuteRuleActionParametersMatchedData", + "RuleRulesetsExecuteRuleActionParametersOverrides", + "RuleRulesetsExecuteRuleActionParametersOverridesCategory", + "RuleRulesetsExecuteRuleActionParametersOverridesRule", + "RuleRulesetsLogRule", + "RuleRulesetsSkipRule", + "RuleRulesetsSkipRuleActionParameters", +] class PhaseUpdateParams(TypedDict, total=False): - rules: Required[Iterable[RequestRuleParam]] + rules: Required[Iterable[Rule]] """The list of rules in the ruleset.""" account_id: str @@ -55,3 +70,258 @@ class PhaseUpdateParams(TypedDict, total=False): "magic_transit_managed", ] """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] diff --git a/src/cloudflare/types/rulesets/phase_update_response.py b/src/cloudflare/types/rulesets/phase_update_response.py index 24fc312459c..dea3c5a4006 100644 --- a/src/cloudflare/types/rulesets/phase_update_response.py +++ b/src/cloudflare/types/rulesets/phase_update_response.py @@ -1,13 +1,323 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from ..shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from ..._models import BaseModel -from ..request_rule import RequestRule -__all__ = ["PhaseUpdateResponse"] +__all__ = [ + "PhaseUpdateResponse", + "Rule", + "RuleRulesetsBlockRule", + "RuleRulesetsBlockRuleActionParameters", + "RuleRulesetsBlockRuleActionParametersResponse", + "RuleRulesetsExecuteRule", + "RuleRulesetsExecuteRuleActionParameters", + "RuleRulesetsExecuteRuleActionParametersMatchedData", + "RuleRulesetsExecuteRuleActionParametersOverrides", + "RuleRulesetsExecuteRuleActionParametersOverridesCategory", + "RuleRulesetsExecuteRuleActionParametersOverridesRule", + "RuleRulesetsLogRule", + "RuleRulesetsSkipRule", + "RuleRulesetsSkipRuleActionParameters", +] + + +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] class PhaseUpdateResponse(BaseModel): @@ -50,7 +360,7 @@ class PhaseUpdateResponse(BaseModel): ] """The phase of the ruleset.""" - rules: List[RequestRule] + rules: List[Rule] """The list of rules in the ruleset.""" version: str diff --git a/src/cloudflare/types/rulesets/phases/version_get_response.py b/src/cloudflare/types/rulesets/phases/version_get_response.py index 050f070a592..55f0d62279f 100644 --- a/src/cloudflare/types/rulesets/phases/version_get_response.py +++ b/src/cloudflare/types/rulesets/phases/version_get_response.py @@ -1,13 +1,323 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from ...shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from ...._models import BaseModel -from ...request_rule import RequestRule -__all__ = ["VersionGetResponse"] +__all__ = [ + "VersionGetResponse", + "Rule", + "RuleRulesetsBlockRule", + "RuleRulesetsBlockRuleActionParameters", + "RuleRulesetsBlockRuleActionParametersResponse", + "RuleRulesetsExecuteRule", + "RuleRulesetsExecuteRuleActionParameters", + "RuleRulesetsExecuteRuleActionParametersMatchedData", + "RuleRulesetsExecuteRuleActionParametersOverrides", + "RuleRulesetsExecuteRuleActionParametersOverridesCategory", + "RuleRulesetsExecuteRuleActionParametersOverridesRule", + "RuleRulesetsLogRule", + "RuleRulesetsSkipRule", + "RuleRulesetsSkipRuleActionParameters", +] + + +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] class VersionGetResponse(BaseModel): @@ -50,7 +360,7 @@ class VersionGetResponse(BaseModel): ] """The phase of the ruleset.""" - rules: List[RequestRule] + rules: List[Rule] """The list of rules in the ruleset.""" version: str diff --git a/src/cloudflare/types/rulesets/rule_create_params.py b/src/cloudflare/types/rulesets/rule_create_params.py index f90079b147a..c6fefe04798 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", - "BlockRule", - "BlockRuleActionParameters", - "BlockRuleActionParametersResponse", - "ExecuteRule", - "ExecuteRuleActionParameters", - "ExecuteRuleActionParametersMatchedData", - "ExecuteRuleActionParametersOverrides", - "ExecuteRuleActionParametersOverridesCategory", - "ExecuteRuleActionParametersOverridesRule", - "LogRule", - "SkipRule", - "SkipRuleActionParameters", + "RulesetsBlockRule", + "RulesetsBlockRuleActionParameters", + "RulesetsBlockRuleActionParametersResponse", + "RulesetsExecuteRule", + "RulesetsExecuteRuleActionParameters", + "RulesetsExecuteRuleActionParametersMatchedData", + "RulesetsExecuteRuleActionParametersOverrides", + "RulesetsExecuteRuleActionParametersOverridesCategory", + "RulesetsExecuteRuleActionParametersOverridesRule", + "RulesetsLogRule", + "RulesetsSkipRule", + "RulesetsSkipRuleActionParameters", ] -class BlockRule(TypedDict, total=False): +class RulesetsBlockRule(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 BlockRule(TypedDict, total=False): action: Literal["block"] """The action to perform when the rule matches.""" - action_parameters: BlockRuleActionParameters + action_parameters: RulesetsBlockRuleActionParameters """The parameters configuring the rule's action.""" description: str @@ -56,7 +56,7 @@ class BlockRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class BlockRuleActionParametersResponse(TypedDict, total=False): +class RulesetsBlockRuleActionParametersResponse(TypedDict, total=False): content: Required[str] """The content to return.""" @@ -67,12 +67,12 @@ class BlockRuleActionParametersResponse(TypedDict, total=False): """The status code to return.""" -class BlockRuleActionParameters(TypedDict, total=False): - response: BlockRuleActionParametersResponse +class RulesetsBlockRuleActionParameters(TypedDict, total=False): + response: RulesetsBlockRuleActionParametersResponse """The response to show when the block is applied.""" -class ExecuteRule(TypedDict, total=False): +class RulesetsExecuteRule(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 ExecuteRule(TypedDict, total=False): action: Literal["execute"] """The action to perform when the rule matches.""" - action_parameters: ExecuteRuleActionParameters + action_parameters: RulesetsExecuteRuleActionParameters """The parameters configuring the rule's action.""" description: str @@ -104,12 +104,12 @@ class ExecuteRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class ExecuteRuleActionParametersMatchedData(TypedDict, total=False): +class RulesetsExecuteRuleActionParametersMatchedData(TypedDict, total=False): public_key: Required[str] """The public key to encrypt matched data logs with.""" -class ExecuteRuleActionParametersOverridesCategory(TypedDict, total=False): +class RulesetsExecuteRuleActionParametersOverridesCategory(TypedDict, total=False): category: Required[str] """The name of the category to override.""" @@ -123,7 +123,7 @@ class ExecuteRuleActionParametersOverridesCategory(TypedDict, total=False): """The sensitivity level to use for rules in the category.""" -class ExecuteRuleActionParametersOverridesRule(TypedDict, total=False): +class RulesetsExecuteRuleActionParametersOverridesRule(TypedDict, total=False): id: Required[str] """The ID of the rule to override.""" @@ -140,14 +140,14 @@ class ExecuteRuleActionParametersOverridesRule(TypedDict, total=False): """The sensitivity level to use for the rule.""" -class ExecuteRuleActionParametersOverrides(TypedDict, total=False): +class RulesetsExecuteRuleActionParametersOverrides(TypedDict, total=False): action: str """An action to override all rules with. This option has lower precedence than rule and category overrides. """ - categories: Iterable[ExecuteRuleActionParametersOverridesCategory] + categories: Iterable[RulesetsExecuteRuleActionParametersOverridesCategory] """A list of category-level overrides. This option has the second-highest precedence after rule-level overrides. @@ -159,7 +159,7 @@ class ExecuteRuleActionParametersOverrides(TypedDict, total=False): This option has lower precedence than rule and category overrides. """ - rules: Iterable[ExecuteRuleActionParametersOverridesRule] + rules: Iterable[RulesetsExecuteRuleActionParametersOverridesRule] """A list of rule-level overrides. This option has the highest precedence.""" sensitivity_level: Literal["default", "medium", "low", "eoff"] @@ -170,18 +170,18 @@ class ExecuteRuleActionParametersOverrides(TypedDict, total=False): """ -class ExecuteRuleActionParameters(TypedDict, total=False): +class RulesetsExecuteRuleActionParameters(TypedDict, total=False): id: Required[str] """The ID of the ruleset to execute.""" - matched_data: ExecuteRuleActionParametersMatchedData + matched_data: RulesetsExecuteRuleActionParametersMatchedData """The configuration to use for matched data logging.""" - overrides: ExecuteRuleActionParametersOverrides + overrides: RulesetsExecuteRuleActionParametersOverrides """A set of overrides to apply to the target ruleset.""" -class LogRule(TypedDict, total=False): +class RulesetsLogRule(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 LogRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class SkipRule(TypedDict, total=False): +class RulesetsSkipRule(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 SkipRule(TypedDict, total=False): action: Literal["skip"] """The action to perform when the rule matches.""" - action_parameters: SkipRuleActionParameters + action_parameters: RulesetsSkipRuleActionParameters """The parameters configuring the rule's action.""" description: str @@ -245,7 +245,7 @@ class SkipRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class SkipRuleActionParameters(TypedDict, total=False): +class RulesetsSkipRuleActionParameters(TypedDict, total=False): phases: List[ Literal[ "ddos_l4", @@ -300,4 +300,4 @@ class SkipRuleActionParameters(TypedDict, total=False): """ -RuleCreateParams = Union[BlockRule, ExecuteRule, LogRule, SkipRule] +RuleCreateParams = Union[RulesetsBlockRule, RulesetsExecuteRule, RulesetsLogRule, RulesetsSkipRule] diff --git a/src/cloudflare/types/rulesets/rule_create_response.py b/src/cloudflare/types/rulesets/rule_create_response.py index b554755248f..e4c09492459 100644 --- a/src/cloudflare/types/rulesets/rule_create_response.py +++ b/src/cloudflare/types/rulesets/rule_create_response.py @@ -1,13 +1,323 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from ..shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from ..._models import BaseModel -from ..request_rule import RequestRule -__all__ = ["RuleCreateResponse"] +__all__ = [ + "RuleCreateResponse", + "Rule", + "RuleRulesetsBlockRule", + "RuleRulesetsBlockRuleActionParameters", + "RuleRulesetsBlockRuleActionParametersResponse", + "RuleRulesetsExecuteRule", + "RuleRulesetsExecuteRuleActionParameters", + "RuleRulesetsExecuteRuleActionParametersMatchedData", + "RuleRulesetsExecuteRuleActionParametersOverrides", + "RuleRulesetsExecuteRuleActionParametersOverridesCategory", + "RuleRulesetsExecuteRuleActionParametersOverridesRule", + "RuleRulesetsLogRule", + "RuleRulesetsSkipRule", + "RuleRulesetsSkipRuleActionParameters", +] + + +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] class RuleCreateResponse(BaseModel): @@ -50,7 +360,7 @@ class RuleCreateResponse(BaseModel): ] """The phase of the ruleset.""" - rules: List[RequestRule] + rules: List[Rule] """The list of rules in the ruleset.""" version: str diff --git a/src/cloudflare/types/rulesets/rule_delete_response.py b/src/cloudflare/types/rulesets/rule_delete_response.py index 3e1cd2ab850..9e3879da2e4 100644 --- a/src/cloudflare/types/rulesets/rule_delete_response.py +++ b/src/cloudflare/types/rulesets/rule_delete_response.py @@ -1,13 +1,323 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from ..shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from ..._models import BaseModel -from ..request_rule import RequestRule -__all__ = ["RuleDeleteResponse"] +__all__ = [ + "RuleDeleteResponse", + "Rule", + "RuleRulesetsBlockRule", + "RuleRulesetsBlockRuleActionParameters", + "RuleRulesetsBlockRuleActionParametersResponse", + "RuleRulesetsExecuteRule", + "RuleRulesetsExecuteRuleActionParameters", + "RuleRulesetsExecuteRuleActionParametersMatchedData", + "RuleRulesetsExecuteRuleActionParametersOverrides", + "RuleRulesetsExecuteRuleActionParametersOverridesCategory", + "RuleRulesetsExecuteRuleActionParametersOverridesRule", + "RuleRulesetsLogRule", + "RuleRulesetsSkipRule", + "RuleRulesetsSkipRuleActionParameters", +] + + +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] class RuleDeleteResponse(BaseModel): @@ -50,7 +360,7 @@ class RuleDeleteResponse(BaseModel): ] """The phase of the ruleset.""" - rules: List[RequestRule] + rules: List[Rule] """The list of rules in the ruleset.""" version: str diff --git a/src/cloudflare/types/rulesets/rule_edit_params.py b/src/cloudflare/types/rulesets/rule_edit_params.py index d8f55fc560d..2d951cf7ecf 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", - "BlockRule", - "BlockRuleActionParameters", - "BlockRuleActionParametersResponse", - "ExecuteRule", - "ExecuteRuleActionParameters", - "ExecuteRuleActionParametersMatchedData", - "ExecuteRuleActionParametersOverrides", - "ExecuteRuleActionParametersOverridesCategory", - "ExecuteRuleActionParametersOverridesRule", - "LogRule", - "SkipRule", - "SkipRuleActionParameters", + "RulesetsBlockRule", + "RulesetsBlockRuleActionParameters", + "RulesetsBlockRuleActionParametersResponse", + "RulesetsExecuteRule", + "RulesetsExecuteRuleActionParameters", + "RulesetsExecuteRuleActionParametersMatchedData", + "RulesetsExecuteRuleActionParametersOverrides", + "RulesetsExecuteRuleActionParametersOverridesCategory", + "RulesetsExecuteRuleActionParametersOverridesRule", + "RulesetsLogRule", + "RulesetsSkipRule", + "RulesetsSkipRuleActionParameters", ] -class BlockRule(TypedDict, total=False): +class RulesetsBlockRule(TypedDict, total=False): ruleset_id: Required[str] """The unique ID of the ruleset.""" @@ -40,7 +40,7 @@ class BlockRule(TypedDict, total=False): action: Literal["block"] """The action to perform when the rule matches.""" - action_parameters: BlockRuleActionParameters + action_parameters: RulesetsBlockRuleActionParameters """The parameters configuring the rule's action.""" description: str @@ -59,7 +59,7 @@ class BlockRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class BlockRuleActionParametersResponse(TypedDict, total=False): +class RulesetsBlockRuleActionParametersResponse(TypedDict, total=False): content: Required[str] """The content to return.""" @@ -70,12 +70,12 @@ class BlockRuleActionParametersResponse(TypedDict, total=False): """The status code to return.""" -class BlockRuleActionParameters(TypedDict, total=False): - response: BlockRuleActionParametersResponse +class RulesetsBlockRuleActionParameters(TypedDict, total=False): + response: RulesetsBlockRuleActionParametersResponse """The response to show when the block is applied.""" -class ExecuteRule(TypedDict, total=False): +class RulesetsExecuteRule(TypedDict, total=False): ruleset_id: Required[str] """The unique ID of the ruleset.""" @@ -91,7 +91,7 @@ class ExecuteRule(TypedDict, total=False): action: Literal["execute"] """The action to perform when the rule matches.""" - action_parameters: ExecuteRuleActionParameters + action_parameters: RulesetsExecuteRuleActionParameters """The parameters configuring the rule's action.""" description: str @@ -110,12 +110,12 @@ class ExecuteRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class ExecuteRuleActionParametersMatchedData(TypedDict, total=False): +class RulesetsExecuteRuleActionParametersMatchedData(TypedDict, total=False): public_key: Required[str] """The public key to encrypt matched data logs with.""" -class ExecuteRuleActionParametersOverridesCategory(TypedDict, total=False): +class RulesetsExecuteRuleActionParametersOverridesCategory(TypedDict, total=False): category: Required[str] """The name of the category to override.""" @@ -129,7 +129,7 @@ class ExecuteRuleActionParametersOverridesCategory(TypedDict, total=False): """The sensitivity level to use for rules in the category.""" -class ExecuteRuleActionParametersOverridesRule(TypedDict, total=False): +class RulesetsExecuteRuleActionParametersOverridesRule(TypedDict, total=False): id: Required[str] """The ID of the rule to override.""" @@ -146,14 +146,14 @@ class ExecuteRuleActionParametersOverridesRule(TypedDict, total=False): """The sensitivity level to use for the rule.""" -class ExecuteRuleActionParametersOverrides(TypedDict, total=False): +class RulesetsExecuteRuleActionParametersOverrides(TypedDict, total=False): action: str """An action to override all rules with. This option has lower precedence than rule and category overrides. """ - categories: Iterable[ExecuteRuleActionParametersOverridesCategory] + categories: Iterable[RulesetsExecuteRuleActionParametersOverridesCategory] """A list of category-level overrides. This option has the second-highest precedence after rule-level overrides. @@ -165,7 +165,7 @@ class ExecuteRuleActionParametersOverrides(TypedDict, total=False): This option has lower precedence than rule and category overrides. """ - rules: Iterable[ExecuteRuleActionParametersOverridesRule] + rules: Iterable[RulesetsExecuteRuleActionParametersOverridesRule] """A list of rule-level overrides. This option has the highest precedence.""" sensitivity_level: Literal["default", "medium", "low", "eoff"] @@ -176,18 +176,18 @@ class ExecuteRuleActionParametersOverrides(TypedDict, total=False): """ -class ExecuteRuleActionParameters(TypedDict, total=False): +class RulesetsExecuteRuleActionParameters(TypedDict, total=False): id: Required[str] """The ID of the ruleset to execute.""" - matched_data: ExecuteRuleActionParametersMatchedData + matched_data: RulesetsExecuteRuleActionParametersMatchedData """The configuration to use for matched data logging.""" - overrides: ExecuteRuleActionParametersOverrides + overrides: RulesetsExecuteRuleActionParametersOverrides """A set of overrides to apply to the target ruleset.""" -class LogRule(TypedDict, total=False): +class RulesetsLogRule(TypedDict, total=False): ruleset_id: Required[str] """The unique ID of the ruleset.""" @@ -222,7 +222,7 @@ class LogRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class SkipRule(TypedDict, total=False): +class RulesetsSkipRule(TypedDict, total=False): ruleset_id: Required[str] """The unique ID of the ruleset.""" @@ -238,7 +238,7 @@ class SkipRule(TypedDict, total=False): action: Literal["skip"] """The action to perform when the rule matches.""" - action_parameters: SkipRuleActionParameters + action_parameters: RulesetsSkipRuleActionParameters """The parameters configuring the rule's action.""" description: str @@ -257,7 +257,7 @@ class SkipRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class SkipRuleActionParameters(TypedDict, total=False): +class RulesetsSkipRuleActionParameters(TypedDict, total=False): phases: List[ Literal[ "ddos_l4", @@ -312,4 +312,4 @@ class SkipRuleActionParameters(TypedDict, total=False): """ -RuleEditParams = Union[BlockRule, ExecuteRule, LogRule, SkipRule] +RuleEditParams = Union[RulesetsBlockRule, RulesetsExecuteRule, RulesetsLogRule, RulesetsSkipRule] diff --git a/src/cloudflare/types/rulesets/rule_edit_response.py b/src/cloudflare/types/rulesets/rule_edit_response.py index a53cec82198..79d7e1765f9 100644 --- a/src/cloudflare/types/rulesets/rule_edit_response.py +++ b/src/cloudflare/types/rulesets/rule_edit_response.py @@ -1,13 +1,323 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from ..shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from ..._models import BaseModel -from ..request_rule import RequestRule -__all__ = ["RuleEditResponse"] +__all__ = [ + "RuleEditResponse", + "Rule", + "RuleRulesetsBlockRule", + "RuleRulesetsBlockRuleActionParameters", + "RuleRulesetsBlockRuleActionParametersResponse", + "RuleRulesetsExecuteRule", + "RuleRulesetsExecuteRuleActionParameters", + "RuleRulesetsExecuteRuleActionParametersMatchedData", + "RuleRulesetsExecuteRuleActionParametersOverrides", + "RuleRulesetsExecuteRuleActionParametersOverridesCategory", + "RuleRulesetsExecuteRuleActionParametersOverridesRule", + "RuleRulesetsLogRule", + "RuleRulesetsSkipRule", + "RuleRulesetsSkipRuleActionParameters", +] + + +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] class RuleEditResponse(BaseModel): @@ -50,7 +360,7 @@ class RuleEditResponse(BaseModel): ] """The phase of the ruleset.""" - rules: List[RequestRule] + rules: List[Rule] """The list of rules in the ruleset.""" version: str diff --git a/src/cloudflare/types/rulesets/version_get_response.py b/src/cloudflare/types/rulesets/version_get_response.py index 7761a6fff22..f4001774338 100644 --- a/src/cloudflare/types/rulesets/version_get_response.py +++ b/src/cloudflare/types/rulesets/version_get_response.py @@ -1,13 +1,323 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from ..shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from ..._models import BaseModel -from ..request_rule import RequestRule -__all__ = ["VersionGetResponse"] +__all__ = [ + "VersionGetResponse", + "Rule", + "RuleRulesetsBlockRule", + "RuleRulesetsBlockRuleActionParameters", + "RuleRulesetsBlockRuleActionParametersResponse", + "RuleRulesetsExecuteRule", + "RuleRulesetsExecuteRuleActionParameters", + "RuleRulesetsExecuteRuleActionParametersMatchedData", + "RuleRulesetsExecuteRuleActionParametersOverrides", + "RuleRulesetsExecuteRuleActionParametersOverridesCategory", + "RuleRulesetsExecuteRuleActionParametersOverridesRule", + "RuleRulesetsLogRule", + "RuleRulesetsSkipRule", + "RuleRulesetsSkipRuleActionParameters", +] + + +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] class VersionGetResponse(BaseModel): @@ -50,7 +360,7 @@ class VersionGetResponse(BaseModel): ] """The phase of the ruleset.""" - rules: List[RequestRule] + rules: List[Rule] """The list of rules in the ruleset.""" version: str 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 dbe66c2305e..1e8f04fc00a 100644 --- a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py +++ b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py @@ -1,13 +1,323 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from ...shared import UnnamedSchemaRef70f2c6ccd8a405358ac7ef8fc3d6751c from ...._models import BaseModel -from ...request_rule import RequestRule -__all__ = ["ByTagGetResponse"] +__all__ = [ + "ByTagGetResponse", + "Rule", + "RuleRulesetsBlockRule", + "RuleRulesetsBlockRuleActionParameters", + "RuleRulesetsBlockRuleActionParametersResponse", + "RuleRulesetsExecuteRule", + "RuleRulesetsExecuteRuleActionParameters", + "RuleRulesetsExecuteRuleActionParametersMatchedData", + "RuleRulesetsExecuteRuleActionParametersOverrides", + "RuleRulesetsExecuteRuleActionParametersOverridesCategory", + "RuleRulesetsExecuteRuleActionParametersOverridesRule", + "RuleRulesetsLogRule", + "RuleRulesetsSkipRule", + "RuleRulesetsSkipRuleActionParameters", +] + + +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] class ByTagGetResponse(BaseModel): @@ -50,7 +360,7 @@ class ByTagGetResponse(BaseModel): ] """The phase of the ruleset.""" - rules: List[RequestRule] + rules: List[Rule] """The list of rules in the ruleset.""" version: str diff --git a/src/cloudflare/types/skip_rule.py b/src/cloudflare/types/skip_rule.py deleted file mode 100644 index a5992d766e6..00000000000 --- a/src/cloudflare/types/skip_rule.py +++ /dev/null @@ -1,104 +0,0 @@ -# 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 deleted file mode 100644 index 6e470369cfc..00000000000 --- a/src/cloudflare/types/skip_rule_param.py +++ /dev/null @@ -1,91 +0,0 @@ -# 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)."""