From db173b7b12320a0ee07de447124ee998721caf21 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:06:24 +0000 Subject: [PATCH] feat(api): OpenAPI spec update via Stainless API (#295) --- src/cloudflare/resources/rulesets/rules.py | 3200 +++++++++- src/cloudflare/types/ruleset_create_params.py | 859 ++- .../types/ruleset_create_response.py | 955 ++- src/cloudflare/types/ruleset_get_response.py | 955 ++- src/cloudflare/types/ruleset_update_params.py | 859 ++- .../types/ruleset_update_response.py | 955 ++- .../types/rulesets/phase_get_response.py | 954 ++- .../types/rulesets/phase_update_params.py | 858 ++- .../types/rulesets/phase_update_response.py | 954 ++- .../rulesets/phases/version_get_response.py | 954 ++- .../types/rulesets/rule_create_params.py | 1012 +++- .../types/rulesets/rule_create_response.py | 954 ++- .../types/rulesets/rule_delete_response.py | 954 ++- .../types/rulesets/rule_edit_params.py | 1045 +++- .../types/rulesets/rule_edit_response.py | 954 ++- .../types/rulesets/version_get_response.py | 954 ++- .../rulesets/versions/by_tag_get_response.py | 954 ++- tests/api_resources/rulesets/test_rules.py | 5164 +++++++++++++++-- 18 files changed, 22787 insertions(+), 707 deletions(-) diff --git a/src/cloudflare/resources/rulesets/rules.py b/src/cloudflare/resources/rulesets/rules.py index 9855957ff1f..7f07952a531 100644 --- a/src/cloudflare/resources/rulesets/rules.py +++ b/src/cloudflare/resources/rulesets/rules.py @@ -106,6 +106,126 @@ def create( """ ... + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["challenge"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["compress_response"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsCompressResponseRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + @overload def create( self, @@ -167,15 +287,2525 @@ def create( ... @overload - def create( + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["js_challenge"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["log"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["managed_challenge"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["redirect"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsRedirectRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["rewrite"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsRewriteRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["route"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsRouteRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["score"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsScoreRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["serve_error"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsServeErrorRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["set_config"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsSetConfigRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + 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, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["set_cache_settings"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsSetCacheSettingsRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["block"] + | Literal["challenge"] + | Literal["compress_response"] + | Literal["execute"] + | Literal["js_challenge"] + | Literal["log"] + | Literal["managed_challenge"] + | Literal["redirect"] + | Literal["rewrite"] + | Literal["route"] + | Literal["score"] + | Literal["serve_error"] + | Literal["set_config"] + | Literal["skip"] + | Literal["set_cache_settings"] + | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.BlockRuleActionParameters + | object + | rule_create_params.RulesetsCompressResponseRuleActionParameters + | rule_create_params.ExecuteRuleActionParameters + | rule_create_params.RulesetsRedirectRuleActionParameters + | rule_create_params.RulesetsRewriteRuleActionParameters + | rule_create_params.RulesetsRouteRuleActionParameters + | rule_create_params.RulesetsScoreRuleActionParameters + | rule_create_params.RulesetsServeErrorRuleActionParameters + | rule_create_params.RulesetsSetConfigRuleActionParameters + | rule_create_params.SkipRuleActionParameters + | rule_create_params.RulesetsSetCacheSettingsRuleActionParameters + | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + if not ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not account_id and not zone_id: + raise ValueError("You must provide either account_id or zone_id") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._post( + f"/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules", + body=maybe_transform( + { + "id": id, + "action": action, + "action_parameters": action_parameters, + "description": description, + "enabled": enabled, + "expression": expression, + "logging": logging, + "ref": ref, + }, + rule_create_params.RuleCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[RuleCreateResponse], ResultWrapper[RuleCreateResponse]), + ) + + def delete( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleDeleteResponse: + """ + Deletes an existing rule from an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if not rule_id: + raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not account_id and not zone_id: + raise ValueError("You must provide either account_id or zone_id") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._delete( + f"/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules/{rule_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[RuleDeleteResponse], ResultWrapper[RuleDeleteResponse]), + ) + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + 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, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["challenge"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["compress_response"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsCompressResponseRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + 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, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["js_challenge"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["log"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["managed_challenge"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["redirect"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsRedirectRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["rewrite"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsRewriteRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["route"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsRouteRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["score"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsScoreRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["serve_error"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsServeErrorRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["set_config"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsSetConfigRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + 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, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["set_cache_settings"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsSetCacheSettingsRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. + + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @required_args( + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ) + def edit( + self, + rule_id: str, + *, + ruleset_id: str, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["block"] + | Literal["challenge"] + | Literal["compress_response"] + | Literal["execute"] + | Literal["js_challenge"] + | Literal["log"] + | Literal["managed_challenge"] + | Literal["redirect"] + | Literal["rewrite"] + | Literal["route"] + | Literal["score"] + | Literal["serve_error"] + | Literal["set_config"] + | Literal["skip"] + | Literal["set_cache_settings"] + | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.BlockRuleActionParameters + | object + | rule_edit_params.RulesetsCompressResponseRuleActionParameters + | rule_edit_params.ExecuteRuleActionParameters + | rule_edit_params.RulesetsRedirectRuleActionParameters + | rule_edit_params.RulesetsRewriteRuleActionParameters + | rule_edit_params.RulesetsRouteRuleActionParameters + | rule_edit_params.RulesetsScoreRuleActionParameters + | rule_edit_params.RulesetsServeErrorRuleActionParameters + | rule_edit_params.RulesetsSetConfigRuleActionParameters + | rule_edit_params.SkipRuleActionParameters + | rule_edit_params.RulesetsSetCacheSettingsRuleActionParameters + | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleEditResponse: + if not ruleset_id: + raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") + if not rule_id: + raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") + if not account_id: + raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") + if not zone_id: + raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") + if not account_id and not zone_id: + raise ValueError("You must provide either account_id or zone_id") + if account_id and zone_id: + raise ValueError("You cannot provide both account_id and zone_id") + + if account_id: + account_or_zone = "accounts" + account_or_zone_id = account_id + else: + account_or_zone = "zones" + account_or_zone_id = zone_id + return self._patch( + f"/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules/{rule_id}", + body=maybe_transform( + { + "id": id, + "action": action, + "action_parameters": action_parameters, + "description": description, + "enabled": enabled, + "expression": expression, + "logging": logging, + "ref": ref, + }, + rule_edit_params.RuleEditParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper._unwrapper, + ), + cast_to=cast(Type[RuleEditResponse], ResultWrapper[RuleEditResponse]), + ) + + +class AsyncRules(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncRulesWithRawResponse: + return AsyncRulesWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncRulesWithStreamingResponse: + return AsyncRulesWithStreamingResponse(self) + + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + 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, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["challenge"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["compress_response"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsCompressResponseRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + 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, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["js_challenge"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["log"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["managed_challenge"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["redirect"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsRedirectRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["rewrite"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsRewriteRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["route"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsRouteRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["score"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsScoreRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( self, ruleset_id: str, *, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, - action: Literal["log"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, + action: Literal["serve_error"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsServeErrorRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -227,7 +2857,67 @@ def create( ... @overload - def create( + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["set_config"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsSetConfigRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def create( self, ruleset_id: str, *, @@ -286,18 +2976,101 @@ def create( """ ... - def create( + @overload + async def create( + self, + ruleset_id: str, + *, + account_id: str | NotGiven = NOT_GIVEN, + zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["set_cache_settings"] | NotGiven = NOT_GIVEN, + action_parameters: rule_create_params.RulesetsSetCacheSettingsRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RuleCreateResponse: + """Adds a new rule to an account or zone ruleset. + + The rule will be added to the end + of the existing list of rules in the ruleset by default. + + Args: + ruleset_id: The unique ID of the ruleset. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + async def create( self, ruleset_id: str, *, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, - action: Literal["block"] | Literal["execute"] | Literal["log"] | Literal["skip"] | NotGiven = NOT_GIVEN, + action: Literal["block"] + | Literal["challenge"] + | Literal["compress_response"] + | Literal["execute"] + | Literal["js_challenge"] + | Literal["log"] + | Literal["managed_challenge"] + | Literal["redirect"] + | Literal["rewrite"] + | Literal["route"] + | Literal["score"] + | Literal["serve_error"] + | Literal["set_config"] + | Literal["skip"] + | Literal["set_cache_settings"] + | NotGiven = NOT_GIVEN, action_parameters: rule_create_params.BlockRuleActionParameters - | rule_create_params.ExecuteRuleActionParameters | object + | rule_create_params.RulesetsCompressResponseRuleActionParameters + | rule_create_params.ExecuteRuleActionParameters + | rule_create_params.RulesetsRedirectRuleActionParameters + | rule_create_params.RulesetsRewriteRuleActionParameters + | rule_create_params.RulesetsRouteRuleActionParameters + | rule_create_params.RulesetsScoreRuleActionParameters + | rule_create_params.RulesetsServeErrorRuleActionParameters + | rule_create_params.RulesetsSetConfigRuleActionParameters | rule_create_params.SkipRuleActionParameters + | rule_create_params.RulesetsSetCacheSettingsRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, @@ -328,9 +3101,9 @@ def create( else: account_or_zone = "zones" account_or_zone_id = zone_id - return self._post( + return await self._post( f"/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules", - body=maybe_transform( + body=await async_maybe_transform( { "id": id, "action": action, @@ -353,7 +3126,7 @@ def create( cast_to=cast(Type[RuleCreateResponse], ResultWrapper[RuleCreateResponse]), ) - def delete( + async def delete( self, rule_id: str, *, @@ -406,7 +3179,7 @@ def delete( else: account_or_zone = "zones" account_or_zone_id = zone_id - return self._delete( + return await self._delete( f"/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules/{rule_id}", options=make_request_options( extra_headers=extra_headers, @@ -419,7 +3192,7 @@ def delete( ) @overload - def edit( + async def edit( self, rule_id: str, *, @@ -480,7 +3253,7 @@ def edit( ... @overload - def edit( + async def edit( self, rule_id: str, *, @@ -488,8 +3261,8 @@ def edit( account_id: str | NotGiven = NOT_GIVEN, 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: Literal["challenge"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -541,7 +3314,7 @@ def edit( ... @overload - def edit( + async def edit( self, rule_id: str, *, @@ -549,8 +3322,8 @@ def edit( account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, - action: Literal["log"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, + action: Literal["compress_response"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsCompressResponseRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -602,7 +3375,7 @@ def edit( ... @overload - def edit( + async def edit( self, rule_id: str, *, @@ -610,8 +3383,8 @@ def edit( account_id: str | NotGiven = NOT_GIVEN, 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: Literal["execute"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.ExecuteRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -662,8 +3435,8 @@ def edit( """ ... - @required_args(["ruleset_id"], ["ruleset_id"], ["ruleset_id"], ["ruleset_id"]) - def edit( + @overload + async def edit( self, rule_id: str, *, @@ -671,12 +3444,8 @@ def edit( account_id: str | NotGiven = NOT_GIVEN, 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 - | object - | rule_edit_params.SkipRuleActionParameters - | NotGiven = NOT_GIVEN, + action: Literal["js_challenge"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -689,70 +3458,55 @@ def edit( extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, ) -> RuleEditResponse: - if not ruleset_id: - raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") - if not rule_id: - raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") + """ + Updates an existing rule in an account or zone ruleset. - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - account_or_zone = "zones" - account_or_zone_id = zone_id - return self._patch( - f"/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules/{rule_id}", - body=maybe_transform( - { - "id": id, - "action": action, - "action_parameters": action_parameters, - "description": description, - "enabled": enabled, - "expression": expression, - "logging": logging, - "ref": ref, - }, - rule_edit_params.RuleEditParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper._unwrapper, - ), - cast_to=cast(Type[RuleEditResponse], ResultWrapper[RuleEditResponse]), - ) + Args: + ruleset_id: The unique ID of the ruleset. + + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + enabled: Whether the rule should be executed. -class AsyncRules(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncRulesWithRawResponse: - return AsyncRulesWithRawResponse(self) + expression: The expression defining which traffic will match the rule. - @cached_property - def with_streaming_response(self) -> AsyncRulesWithStreamingResponse: - return AsyncRulesWithStreamingResponse(self) + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... @overload - async def create( + async def edit( self, - ruleset_id: str, + rule_id: str, *, + ruleset_id: str, account_id: str | NotGiven = NOT_GIVEN, 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: Literal["log"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -764,15 +3518,15 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleCreateResponse: - """Adds a new rule to an account or zone ruleset. - - The rule will be added to the end - of the existing list of rules in the ruleset by default. + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. Args: ruleset_id: The unique ID of the ruleset. + rule_id: The unique ID of the rule. + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. @@ -804,15 +3558,16 @@ async def create( ... @overload - async def create( + async def edit( self, - ruleset_id: str, + rule_id: str, *, + ruleset_id: str, account_id: str | NotGiven = NOT_GIVEN, 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: Literal["managed_challenge"] | NotGiven = NOT_GIVEN, + action_parameters: object | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -824,15 +3579,15 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleCreateResponse: - """Adds a new rule to an account or zone ruleset. - - The rule will be added to the end - of the existing list of rules in the ruleset by default. + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. Args: ruleset_id: The unique ID of the ruleset. + rule_id: The unique ID of the rule. + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. @@ -864,15 +3619,16 @@ async def create( ... @overload - async def create( + async def edit( self, - ruleset_id: str, + rule_id: str, *, + ruleset_id: str, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, - action: Literal["log"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, + action: Literal["redirect"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsRedirectRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -884,15 +3640,15 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleCreateResponse: - """Adds a new rule to an account or zone ruleset. - - The rule will be added to the end - of the existing list of rules in the ruleset by default. + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. Args: ruleset_id: The unique ID of the ruleset. + rule_id: The unique ID of the rule. + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. @@ -924,15 +3680,16 @@ async def create( ... @overload - async def create( + async def edit( self, - ruleset_id: str, + rule_id: str, *, + ruleset_id: str, account_id: str | NotGiven = NOT_GIVEN, 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: Literal["rewrite"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsRewriteRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -944,15 +3701,15 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleCreateResponse: - """Adds a new rule to an account or zone ruleset. - - The rule will be added to the end - of the existing list of rules in the ruleset by default. + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. Args: ruleset_id: The unique ID of the ruleset. + rule_id: The unique ID of the rule. + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. @@ -983,19 +3740,17 @@ async def create( """ ... - async def create( + @overload + async def edit( self, - ruleset_id: str, + rule_id: str, *, + ruleset_id: str, account_id: str | NotGiven = NOT_GIVEN, 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 - | object - | rule_create_params.SkipRuleActionParameters - | NotGiven = NOT_GIVEN, + action: Literal["route"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsRouteRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -1007,65 +3762,70 @@ async def create( extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleCreateResponse: - if not ruleset_id: - raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") + ) -> RuleEditResponse: + """ + Updates an existing rule in an account or zone ruleset. - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._post( - f"/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules", - body=await async_maybe_transform( - { - "id": id, - "action": action, - "action_parameters": action_parameters, - "description": description, - "enabled": enabled, - "expression": expression, - "logging": logging, - "ref": ref, - }, - rule_create_params.RuleCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper._unwrapper, - ), - cast_to=cast(Type[RuleCreateResponse], ResultWrapper[RuleCreateResponse]), - ) + Args: + ruleset_id: The unique ID of the ruleset. - async def delete( + rule_id: The unique ID of the rule. + + account_id: The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + + zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + ... + + @overload + async def edit( self, rule_id: str, *, ruleset_id: str, account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, + id: str | NotGiven = NOT_GIVEN, + action: Literal["score"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsScoreRuleActionParameters | NotGiven = NOT_GIVEN, + description: str | NotGiven = NOT_GIVEN, + enabled: bool | NotGiven = NOT_GIVEN, + expression: str | NotGiven = NOT_GIVEN, + logging: LoggingParam | NotGiven = NOT_GIVEN, + ref: str | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> RuleDeleteResponse: + ) -> RuleEditResponse: """ - Deletes an existing rule from an account or zone ruleset. + Updates an existing rule in an account or zone ruleset. Args: ruleset_id: The unique ID of the ruleset. @@ -1076,6 +3836,22 @@ async def delete( zone_id: The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + id: The unique ID of the rule. + + action: The action to perform when the rule matches. + + action_parameters: The parameters configuring the rule's action. + + description: An informative description of the rule. + + enabled: Whether the rule should be executed. + + expression: The expression defining which traffic will match the rule. + + logging: An object configuring the rule's logging behavior. + + ref: The reference of the rule (the rule ID by default). + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -1084,36 +3860,7 @@ async def delete( timeout: Override the client-level default timeout for this request, in seconds """ - if not ruleset_id: - raise ValueError(f"Expected a non-empty value for `ruleset_id` but received {ruleset_id!r}") - if not rule_id: - raise ValueError(f"Expected a non-empty value for `rule_id` but received {rule_id!r}") - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - if not zone_id: - raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}") - if not account_id and not zone_id: - raise ValueError("You must provide either account_id or zone_id") - if account_id and zone_id: - raise ValueError("You cannot provide both account_id and zone_id") - - if account_id: - account_or_zone = "accounts" - account_or_zone_id = account_id - else: - account_or_zone = "zones" - account_or_zone_id = zone_id - return await self._delete( - f"/{account_or_zone}/{account_or_zone_id}/rulesets/{ruleset_id}/rules/{rule_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper._unwrapper, - ), - cast_to=cast(Type[RuleDeleteResponse], ResultWrapper[RuleDeleteResponse]), - ) + ... @overload async def edit( @@ -1124,8 +3871,8 @@ async def edit( account_id: str | NotGiven = NOT_GIVEN, 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: Literal["serve_error"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsServeErrorRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -1185,8 +3932,8 @@ async def edit( account_id: str | NotGiven = NOT_GIVEN, 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: Literal["set_config"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsSetConfigRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -1246,8 +3993,8 @@ async def edit( account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, - action: Literal["log"] | NotGiven = NOT_GIVEN, - action_parameters: object | NotGiven = NOT_GIVEN, + action: Literal["skip"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.SkipRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -1307,8 +4054,8 @@ async def edit( account_id: str | NotGiven = NOT_GIVEN, 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: Literal["set_cache_settings"] | NotGiven = NOT_GIVEN, + action_parameters: rule_edit_params.RulesetsSetCacheSettingsRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, expression: str | NotGiven = NOT_GIVEN, @@ -1359,7 +4106,23 @@ async def edit( """ ... - @required_args(["ruleset_id"], ["ruleset_id"], ["ruleset_id"], ["ruleset_id"]) + @required_args( + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ["ruleset_id"], + ) async def edit( self, rule_id: str, @@ -1368,11 +4131,34 @@ async def edit( account_id: str | NotGiven = NOT_GIVEN, zone_id: str | NotGiven = NOT_GIVEN, id: str | NotGiven = NOT_GIVEN, - action: Literal["block"] | Literal["execute"] | Literal["log"] | Literal["skip"] | NotGiven = NOT_GIVEN, + action: Literal["block"] + | Literal["challenge"] + | Literal["compress_response"] + | Literal["execute"] + | Literal["js_challenge"] + | Literal["log"] + | Literal["managed_challenge"] + | Literal["redirect"] + | Literal["rewrite"] + | Literal["route"] + | Literal["score"] + | Literal["serve_error"] + | Literal["set_config"] + | Literal["skip"] + | Literal["set_cache_settings"] + | NotGiven = NOT_GIVEN, action_parameters: rule_edit_params.BlockRuleActionParameters - | rule_edit_params.ExecuteRuleActionParameters | object + | rule_edit_params.RulesetsCompressResponseRuleActionParameters + | rule_edit_params.ExecuteRuleActionParameters + | rule_edit_params.RulesetsRedirectRuleActionParameters + | rule_edit_params.RulesetsRewriteRuleActionParameters + | rule_edit_params.RulesetsRouteRuleActionParameters + | rule_edit_params.RulesetsScoreRuleActionParameters + | rule_edit_params.RulesetsServeErrorRuleActionParameters + | rule_edit_params.RulesetsSetConfigRuleActionParameters | rule_edit_params.SkipRuleActionParameters + | rule_edit_params.RulesetsSetCacheSettingsRuleActionParameters | NotGiven = NOT_GIVEN, description: str | NotGiven = NOT_GIVEN, enabled: bool | NotGiven = NOT_GIVEN, diff --git a/src/cloudflare/types/ruleset_create_params.py b/src/cloudflare/types/ruleset_create_params.py index b2f900106ea..230242c5aa6 100644 --- a/src/cloudflare/types/ruleset_create_params.py +++ b/src/cloudflare/types/ruleset_create_params.py @@ -2,12 +2,69 @@ from __future__ import annotations -from typing import Union, Iterable +from typing import Dict, List, Union, Iterable from typing_extensions import Literal, Required, TypedDict -from .rulesets import LogRuleParam, SkipRuleParam, BlockRuleParam, ExecuteRuleParam +from .rulesets import LoggingParam, LogRuleParam, SkipRuleParam, BlockRuleParam, ExecuteRuleParam -__all__ = ["RulesetCreateParams", "Rule"] +__all__ = [ + "RulesetCreateParams", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsCompressResponseRule", + "RuleRulesetsCompressResponseRuleActionParameters", + "RuleRulesetsCompressResponseRuleActionParametersAlgorithm", + "RuleRulesetsJsChallengeRule", + "RuleRulesetsManagedChallengeRule", + "RuleRulesetsRedirectRule", + "RuleRulesetsRedirectRuleActionParameters", + "RuleRulesetsRedirectRuleActionParametersFromList", + "RuleRulesetsRedirectRuleActionParametersFromValue", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURL", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect", + "RuleRulesetsRewriteRule", + "RuleRulesetsRewriteRuleActionParameters", + "RuleRulesetsRewriteRuleActionParametersHeaders", + "RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader", + "RuleRulesetsRewriteRuleActionParametersURI", + "RuleRulesetsRewriteRuleActionParametersURIPath", + "RuleRulesetsRewriteRuleActionParametersURIPathStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue", + "RuleRulesetsRewriteRuleActionParametersURIQuery", + "RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue", + "RuleRulesetsRouteRule", + "RuleRulesetsRouteRuleActionParameters", + "RuleRulesetsRouteRuleActionParametersOrigin", + "RuleRulesetsRouteRuleActionParametersSni", + "RuleRulesetsScoreRule", + "RuleRulesetsScoreRuleActionParameters", + "RuleRulesetsServeErrorRule", + "RuleRulesetsServeErrorRuleActionParameters", + "RuleRulesetsSetConfigRule", + "RuleRulesetsSetConfigRuleActionParameters", + "RuleRulesetsSetConfigRuleActionParametersAutominify", + "RuleRulesetsSetCacheSettingsRule", + "RuleRulesetsSetCacheSettingsRuleActionParameters", + "RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "RuleRulesetsSetCacheSettingsRuleActionParametersServeStale", +] class RulesetCreateParams(TypedDict, total=False): @@ -59,4 +116,798 @@ class RulesetCreateParams(TypedDict, total=False): """An informative description of the ruleset.""" -Rule = Union[BlockRuleParam, ExecuteRuleParam, LogRuleParam, SkipRuleParam] +class RuleRulesetsChallengeRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["challenge"] + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsCompressResponseRuleActionParametersAlgorithm(TypedDict, total=False): + name: Literal["none", "auto", "default", "gzip", "brotli"] + """Name of compression algorithm to enable.""" + + +class RuleRulesetsCompressResponseRuleActionParameters(TypedDict, total=False): + algorithms: Iterable[RuleRulesetsCompressResponseRuleActionParametersAlgorithm] + """Custom order for compression algorithms.""" + + +class RuleRulesetsCompressResponseRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["compress_response"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsCompressResponseRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsJsChallengeRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["js_challenge"] + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsManagedChallengeRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["managed_challenge"] + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRedirectRuleActionParametersFromList(TypedDict, total=False): + key: str + """Expression that evaluates to the list lookup key.""" + + name: str + """The name of the list to match against.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect(TypedDict, total=False): + value: str + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect(TypedDict, total=False): + expression: str + """An expression to evaluate to get the URL to redirect the request to.""" + + +RuleRulesetsRedirectRuleActionParametersFromValueTargetURL = Union[ + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect, + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect, +] + + +class RuleRulesetsRedirectRuleActionParametersFromValue(TypedDict, total=False): + preserve_query_string: bool + """Keep the query string of the original request.""" + + status_code: Literal[301, 302, 303, 307, 308] + """The status code to be used for the redirect.""" + + target_url: RuleRulesetsRedirectRuleActionParametersFromValueTargetURL + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParameters(TypedDict, total=False): + from_list: RuleRulesetsRedirectRuleActionParametersFromList + """Serve a redirect based on a bulk list lookup.""" + + from_value: RuleRulesetsRedirectRuleActionParametersFromValue + """Serve a redirect based on the request properties.""" + + +class RuleRulesetsRedirectRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["redirect"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsRedirectRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader(TypedDict, total=False): + operation: Required[Literal["remove"]] + + +class RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader(TypedDict, total=False): + operation: Required[Literal["set"]] + + value: Required[str] + """Static value for the header.""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader(TypedDict, total=False): + expression: Required[str] + """Expression for the header value.""" + + operation: Required[Literal["set"]] + + +RuleRulesetsRewriteRuleActionParametersHeaders = Union[ + RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader, + RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader, + RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader, +] + + +class RuleRulesetsRewriteRuleActionParametersURIPathStaticValue(TypedDict, total=False): + value: Required[str] + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue(TypedDict, total=False): + expression: Required[str] + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIPath = Union[ + RuleRulesetsRewriteRuleActionParametersURIPathStaticValue, + RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue(TypedDict, total=False): + value: Required[str] + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue(TypedDict, total=False): + expression: Required[str] + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIQuery = Union[ + RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue, + RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURI(TypedDict, total=False): + path: RuleRulesetsRewriteRuleActionParametersURIPath + """Path portion rewrite.""" + + query: RuleRulesetsRewriteRuleActionParametersURIQuery + """Query portion rewrite.""" + + +class RuleRulesetsRewriteRuleActionParameters(TypedDict, total=False): + headers: Dict[str, RuleRulesetsRewriteRuleActionParametersHeaders] + """Map of request headers to modify.""" + + uri: RuleRulesetsRewriteRuleActionParametersURI + """URI to rewrite the request to.""" + + +class RuleRulesetsRewriteRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["rewrite"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsRewriteRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRouteRuleActionParametersOrigin(TypedDict, total=False): + host: str + """Override the resolved hostname.""" + + port: float + """Override the destination port.""" + + +class RuleRulesetsRouteRuleActionParametersSni(TypedDict, total=False): + value: Required[str] + """The SNI override.""" + + +class RuleRulesetsRouteRuleActionParameters(TypedDict, total=False): + host_header: str + """Rewrite the HTTP Host header.""" + + origin: RuleRulesetsRouteRuleActionParametersOrigin + """Override the IP/TCP destination.""" + + sni: RuleRulesetsRouteRuleActionParametersSni + """Override the Server Name Indication (SNI).""" + + +class RuleRulesetsRouteRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["route"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsRouteRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsScoreRuleActionParameters(TypedDict, total=False): + increment: int + """ + Increment contains the delta to change the score and can be either positive or + negative. + """ + + +class RuleRulesetsScoreRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["score"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsScoreRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsServeErrorRuleActionParameters(TypedDict, total=False): + content: str + """Error response content.""" + + content_type: Literal["application/json", "text/xml", "text/plain", "text/html"] + """Content-type header to set with the response.""" + + status_code: float + """The status code to use for the error.""" + + +class RuleRulesetsServeErrorRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["serve_error"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsServeErrorRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetConfigRuleActionParametersAutominify(TypedDict, total=False): + css: bool + """Minify CSS files.""" + + html: bool + """Minify HTML files.""" + + js: bool + """Minify JS files.""" + + +class RuleRulesetsSetConfigRuleActionParameters(TypedDict, total=False): + automatic_https_rewrites: bool + """Turn on or off Automatic HTTPS Rewrites.""" + + autominify: RuleRulesetsSetConfigRuleActionParametersAutominify + """Select which file extensions to minify automatically.""" + + bic: bool + """Turn on or off Browser Integrity Check.""" + + disable_apps: bool + """Turn off all active Cloudflare Apps.""" + + disable_zaraz: bool + """Turn off Zaraz.""" + + email_obfuscation: bool + """Turn on or off Email Obfuscation.""" + + hotlink_protection: bool + """Turn on or off the Hotlink Protection.""" + + mirage: bool + """Turn on or off Mirage.""" + + opportunistic_encryption: bool + """Turn on or off Opportunistic Encryption.""" + + polish: Literal["off", "lossless", "lossy"] + """Configure the Polish level.""" + + rocket_loader: bool + """Turn on or off Rocket Loader""" + + security_level: Literal["off", "essentially_off", "low", "medium", "high", "under_attack"] + """Configure the Security Level.""" + + server_side_excludes: bool + """Turn on or off Server Side Excludes.""" + + ssl: Literal["off", "flexible", "full", "strict", "origin_pull"] + """Configure the SSL level.""" + + sxg: bool + """Turn on or off Signed Exchanges (SXG).""" + + +class RuleRulesetsSetConfigRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_config"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetConfigRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL(TypedDict, total=False): + mode: Required[Literal["respect_origin", "bypass_by_default", "override_origin"]] + """Determines which browser ttl mode to use.""" + + default: int + """The TTL (in seconds) if you choose override_origin mode.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(TypedDict, total=False): + check_presence: List[str] + """Checks for the presence of these cookie names. + + The presence of these cookies is used in building the cache key. + """ + + include: List[str] + """Include these cookies' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(TypedDict, total=False): + check_presence: List[str] + """Checks for the presence of these header names. + + The presence of these headers is used in building the cache key. + """ + + exclude_origin: bool + """Whether or not to include the origin header. + + A value of true will exclude the origin header in the cache key. + """ + + include: List[str] + """Include these headers' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(TypedDict, total=False): + resolved: bool + """Use the resolved host in the cache key. + + A value of true will use the resolved host, while a value or false will use the + original host. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(TypedDict, total=False): + all: bool + """Exclude all query string parameters from use in building the cache key.""" + + list: List[str] + """A list of query string parameters NOT used to build the cache key. + + All parameters present in the request but missing in this list will be used to + build the cache key. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(TypedDict, total=False): + all: bool + """Use all query string parameters in the cache key.""" + + list: List[str] + """A list of query string parameters used to build the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(TypedDict, total=False): + exclude: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude + """ + build the cache key using all query string parameters EXCECPT these excluded + parameters + """ + + include: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude + """ + build the cache key using a list of query string parameters that ARE in the + request. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(TypedDict, total=False): + device_type: bool + """Use the user agent's device type in the cache key.""" + + geo: bool + """Use the user agents's country in the cache key.""" + + lang: bool + """Use the user agent's language in the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey(TypedDict, total=False): + cookie: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie + """The cookies to include in building the cache key.""" + + header: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader + """The header names and values to include in building the cache key.""" + + host: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost + """Whether to use the original host or the resolved host in the cache key.""" + + query_string: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString + """ + Use the presence or absence of parameters in the query string to build the cache + key. + """ + + user: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser + """Characteristics of the request user agent used in building the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey(TypedDict, total=False): + cache_by_device_type: bool + """Separate cached content based on the visitor’s device type""" + + cache_deception_armor: bool + """ + Protect from web cache deception attacks while allowing static assets to be + cached + """ + + custom_key: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey + """ + Customize which components of the request are included or excluded from the + cache key. + """ + + ignore_query_strings_order: bool + """ + Treat requests with the same query parameters the same, regardless of the order + those query parameters are in. A value of true ignores the query strings' order. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve(TypedDict, total=False): + eligible: Required[bool] + """Determines whether cache reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to cache reserve. + """ + + min_file_size: Required[int] + """The minimum file size eligible for store in cache reserve.""" + + +_RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords = TypedDict( + "_RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords", + { + "from": int, + }, + total=False, +) + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange( + _RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords, total=False +): + to: Required[int] + """response status code upper bound""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(TypedDict, total=False): + value: Required[int] + """Time to cache a response (in seconds). + + A value of 0 is equivalent to setting the Cache-Control header with the value + "no-cache". A value of -1 is equivalent to setting Cache-Control header with the + value of "no-store". + """ + + status_code_range: RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + """The range of status codes used to apply the selected mode.""" + + status_code_value: int + """Set the ttl for responses with this specific status code""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL(TypedDict, total=False): + default: Required[int] + """The TTL (in seconds) if you choose override_origin mode.""" + + mode: Required[Literal["respect_origin", "bypass_by_default", "override_origin"]] + """edge ttl options""" + + status_code_ttl: Required[Iterable[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL]] + """List of single status codes, or status code ranges to apply the selected mode""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersServeStale(TypedDict, total=False): + disable_stale_while_updating: Required[bool] + """Defines whether Cloudflare should serve stale content while updating. + + If true, Cloudflare will not serve stale content while getting the latest + content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParameters(TypedDict, total=False): + additional_cacheable_ports: Iterable[int] + """List of additional ports that caching can be enabled on.""" + + browser_ttl: RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL + """Specify how long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: bool + """Mark whether the request’s response from origin is eligible for caching. + + Caching itself will still depend on the cache-control header and your other + caching configurations. + """ + + cache_key: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey + """ + Define which components of the request are included or excluded from the cache + key Cloudflare uses to store the response in cache. + """ + + cache_reserve: RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve + """ + Mark whether the request's response from origin is eligible for Cache Reserve + (requires a Cache Reserve add-on plan). + """ + + edge_ttl: RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL + """ + TTL (Time to Live) specifies the maximum time to cache a resource in the + Cloudflare edge network. + """ + + origin_cache_control: bool + """When enabled, Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: bool + """Generate Cloudflare error pages from issues sent from the origin server. + + When on, error pages will trigger for issues from the origin + """ + + read_timeout: int + """ + Define a timeout value between two successive read operations to your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: bool + """ + Specify whether or not Cloudflare should respect strong ETag (entity tag) + headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: RuleRulesetsSetCacheSettingsRuleActionParametersServeStale + """ + Define if Cloudflare should serve stale content while getting the latest content + from the origin. If on, Cloudflare will not serve stale content while getting + the latest content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_settings"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetCacheSettingsRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +Rule = Union[ + BlockRuleParam, + RuleRulesetsChallengeRule, + RuleRulesetsCompressResponseRule, + ExecuteRuleParam, + RuleRulesetsJsChallengeRule, + LogRuleParam, + RuleRulesetsManagedChallengeRule, + RuleRulesetsRedirectRule, + RuleRulesetsRewriteRule, + RuleRulesetsRouteRule, + RuleRulesetsScoreRule, + RuleRulesetsServeErrorRule, + RuleRulesetsSetConfigRule, + SkipRuleParam, + RuleRulesetsSetCacheSettingsRule, +] diff --git a/src/cloudflare/types/ruleset_create_response.py b/src/cloudflare/types/ruleset_create_response.py index 8af27df5445..983d53a5821 100644 --- a/src/cloudflare/types/ruleset_create_response.py +++ b/src/cloudflare/types/ruleset_create_response.py @@ -1,15 +1,962 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from pydantic import Field as FieldInfo + from .._models import BaseModel -from .rulesets import LogRule, SkipRule, BlockRule, ExecuteRule +from .rulesets import Logging, LogRule, SkipRule, BlockRule, ExecuteRule + +__all__ = [ + "RulesetCreateResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsCompressResponseRule", + "RuleRulesetsCompressResponseRuleActionParameters", + "RuleRulesetsCompressResponseRuleActionParametersAlgorithm", + "RuleRulesetsJsChallengeRule", + "RuleRulesetsManagedChallengeRule", + "RuleRulesetsRedirectRule", + "RuleRulesetsRedirectRuleActionParameters", + "RuleRulesetsRedirectRuleActionParametersFromList", + "RuleRulesetsRedirectRuleActionParametersFromValue", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURL", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect", + "RuleRulesetsRewriteRule", + "RuleRulesetsRewriteRuleActionParameters", + "RuleRulesetsRewriteRuleActionParametersHeaders", + "RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader", + "RuleRulesetsRewriteRuleActionParametersURI", + "RuleRulesetsRewriteRuleActionParametersURIPath", + "RuleRulesetsRewriteRuleActionParametersURIPathStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue", + "RuleRulesetsRewriteRuleActionParametersURIQuery", + "RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue", + "RuleRulesetsRouteRule", + "RuleRulesetsRouteRuleActionParameters", + "RuleRulesetsRouteRuleActionParametersOrigin", + "RuleRulesetsRouteRuleActionParametersSni", + "RuleRulesetsScoreRule", + "RuleRulesetsScoreRuleActionParameters", + "RuleRulesetsServeErrorRule", + "RuleRulesetsServeErrorRuleActionParameters", + "RuleRulesetsSetConfigRule", + "RuleRulesetsSetConfigRuleActionParameters", + "RuleRulesetsSetConfigRuleActionParametersAutominify", + "RuleRulesetsSetCacheSettingsRule", + "RuleRulesetsSetCacheSettingsRuleActionParameters", + "RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "RuleRulesetsSetCacheSettingsRuleActionParametersServeStale", +] + + +class RuleRulesetsChallengeRule(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["challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsCompressResponseRuleActionParametersAlgorithm(BaseModel): + name: Optional[Literal["none", "auto", "default", "gzip", "brotli"]] = None + """Name of compression algorithm to enable.""" + + +class RuleRulesetsCompressResponseRuleActionParameters(BaseModel): + algorithms: Optional[List[RuleRulesetsCompressResponseRuleActionParametersAlgorithm]] = None + """Custom order for compression algorithms.""" + + +class RuleRulesetsCompressResponseRule(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["compress_response"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsCompressResponseRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsJsChallengeRule(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["js_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsManagedChallengeRule(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["managed_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRedirectRuleActionParametersFromList(BaseModel): + key: Optional[str] = None + """Expression that evaluates to the list lookup key.""" + + name: Optional[str] = None + """The name of the list to match against.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect(BaseModel): + value: Optional[str] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect(BaseModel): + expression: Optional[str] = None + """An expression to evaluate to get the URL to redirect the request to.""" + + +RuleRulesetsRedirectRuleActionParametersFromValueTargetURL = Union[ + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect, + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect, +] + + +class RuleRulesetsRedirectRuleActionParametersFromValue(BaseModel): + preserve_query_string: Optional[bool] = None + """Keep the query string of the original request.""" + + status_code: Optional[Literal[301, 302, 303, 307, 308]] = None + """The status code to be used for the redirect.""" + + target_url: Optional[RuleRulesetsRedirectRuleActionParametersFromValueTargetURL] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParameters(BaseModel): + from_list: Optional[RuleRulesetsRedirectRuleActionParametersFromList] = None + """Serve a redirect based on a bulk list lookup.""" + + from_value: Optional[RuleRulesetsRedirectRuleActionParametersFromValue] = None + """Serve a redirect based on the request properties.""" + + +class RuleRulesetsRedirectRule(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["redirect"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRedirectRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader(BaseModel): + operation: Literal["remove"] + + +class RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader(BaseModel): + operation: Literal["set"] + + value: str + """Static value for the header.""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader(BaseModel): + expression: str + """Expression for the header value.""" + + operation: Literal["set"] + + +RuleRulesetsRewriteRuleActionParametersHeaders = Union[ + RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader, + RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader, + RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader, +] + + +class RuleRulesetsRewriteRuleActionParametersURIPathStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIPath = Union[ + RuleRulesetsRewriteRuleActionParametersURIPathStaticValue, + RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIQuery = Union[ + RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue, + RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURI(BaseModel): + path: Optional[RuleRulesetsRewriteRuleActionParametersURIPath] = None + """Path portion rewrite.""" + + query: Optional[RuleRulesetsRewriteRuleActionParametersURIQuery] = None + """Query portion rewrite.""" + + +class RuleRulesetsRewriteRuleActionParameters(BaseModel): + headers: Optional[Dict[str, RuleRulesetsRewriteRuleActionParametersHeaders]] = None + """Map of request headers to modify.""" + + uri: Optional[RuleRulesetsRewriteRuleActionParametersURI] = None + """URI to rewrite the request to.""" + + +class RuleRulesetsRewriteRule(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["rewrite"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRewriteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRouteRuleActionParametersOrigin(BaseModel): + host: Optional[str] = None + """Override the resolved hostname.""" + + port: Optional[float] = None + """Override the destination port.""" + + +class RuleRulesetsRouteRuleActionParametersSni(BaseModel): + value: str + """The SNI override.""" + + +class RuleRulesetsRouteRuleActionParameters(BaseModel): + host_header: Optional[str] = None + """Rewrite the HTTP Host header.""" + + origin: Optional[RuleRulesetsRouteRuleActionParametersOrigin] = None + """Override the IP/TCP destination.""" + + sni: Optional[RuleRulesetsRouteRuleActionParametersSni] = None + """Override the Server Name Indication (SNI).""" + + +class RuleRulesetsRouteRule(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["route"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRouteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsScoreRuleActionParameters(BaseModel): + increment: Optional[int] = None + """ + Increment contains the delta to change the score and can be either positive or + negative. + """ + + +class RuleRulesetsScoreRule(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["score"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsScoreRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsServeErrorRuleActionParameters(BaseModel): + content: Optional[str] = None + """Error response content.""" + + content_type: Optional[Literal["application/json", "text/xml", "text/plain", "text/html"]] = None + """Content-type header to set with the response.""" + + status_code: Optional[float] = None + """The status code to use for the error.""" + + +class RuleRulesetsServeErrorRule(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["serve_error"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsServeErrorRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetConfigRuleActionParametersAutominify(BaseModel): + css: Optional[bool] = None + """Minify CSS files.""" + + html: Optional[bool] = None + """Minify HTML files.""" + + js: Optional[bool] = None + """Minify JS files.""" + + +class RuleRulesetsSetConfigRuleActionParameters(BaseModel): + automatic_https_rewrites: Optional[bool] = None + """Turn on or off Automatic HTTPS Rewrites.""" + + autominify: Optional[RuleRulesetsSetConfigRuleActionParametersAutominify] = None + """Select which file extensions to minify automatically.""" + + bic: Optional[bool] = None + """Turn on or off Browser Integrity Check.""" + + disable_apps: Optional[bool] = None + """Turn off all active Cloudflare Apps.""" + + disable_zaraz: Optional[bool] = None + """Turn off Zaraz.""" + + email_obfuscation: Optional[bool] = None + """Turn on or off Email Obfuscation.""" + + hotlink_protection: Optional[bool] = None + """Turn on or off the Hotlink Protection.""" + + mirage: Optional[bool] = None + """Turn on or off Mirage.""" + + opportunistic_encryption: Optional[bool] = None + """Turn on or off Opportunistic Encryption.""" + + polish: Optional[Literal["off", "lossless", "lossy"]] = None + """Configure the Polish level.""" + + rocket_loader: Optional[bool] = None + """Turn on or off Rocket Loader""" + + security_level: Optional[Literal["off", "essentially_off", "low", "medium", "high", "under_attack"]] = None + """Configure the Security Level.""" + + server_side_excludes: Optional[bool] = None + """Turn on or off Server Side Excludes.""" + + ssl: Optional[Literal["off", "flexible", "full", "strict", "origin_pull"]] = None + """Configure the SSL level.""" + + sxg: Optional[bool] = None + """Turn on or off Signed Exchanges (SXG).""" + + +class RuleRulesetsSetConfigRule(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["set_config"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetConfigRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL(BaseModel): + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """Determines which browser ttl mode to use.""" + + default: Optional[int] = None + """The TTL (in seconds) if you choose override_origin mode.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these cookie names. + + The presence of these cookies is used in building the cache key. + """ + + include: Optional[List[str]] = None + """Include these cookies' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these header names. + + The presence of these headers is used in building the cache key. + """ + + exclude_origin: Optional[bool] = None + """Whether or not to include the origin header. + + A value of true will exclude the origin header in the cache key. + """ + + include: Optional[List[str]] = None + """Include these headers' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(BaseModel): + resolved: Optional[bool] = None + """Use the resolved host in the cache key. + + A value of true will use the resolved host, while a value or false will use the + original host. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(BaseModel): + all: Optional[bool] = None + """Exclude all query string parameters from use in building the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters NOT used to build the cache key. + + All parameters present in the request but missing in this list will be used to + build the cache key. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(BaseModel): + all: Optional[bool] = None + """Use all query string parameters in the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters used to build the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(BaseModel): + exclude: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude] = None + """ + build the cache key using all query string parameters EXCECPT these excluded + parameters + """ + + include: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude] = None + """ + build the cache key using a list of query string parameters that ARE in the + request. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(BaseModel): + device_type: Optional[bool] = None + """Use the user agent's device type in the cache key.""" + + geo: Optional[bool] = None + """Use the user agents's country in the cache key.""" + + lang: Optional[bool] = None + """Use the user agent's language in the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey(BaseModel): + cookie: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie] = None + """The cookies to include in building the cache key.""" + + header: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader] = None + """The header names and values to include in building the cache key.""" + + host: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost] = None + """Whether to use the original host or the resolved host in the cache key.""" + + query_string: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString] = None + """ + Use the presence or absence of parameters in the query string to build the cache + key. + """ + + user: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser] = None + """Characteristics of the request user agent used in building the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey(BaseModel): + cache_by_device_type: Optional[bool] = None + """Separate cached content based on the visitor’s device type""" + + cache_deception_armor: Optional[bool] = None + """ + Protect from web cache deception attacks while allowing static assets to be + cached + """ + + custom_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey] = None + """ + Customize which components of the request are included or excluded from the + cache key. + """ + + ignore_query_strings_order: Optional[bool] = None + """ + Treat requests with the same query parameters the same, regardless of the order + those query parameters are in. A value of true ignores the query strings' order. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve(BaseModel): + eligible: bool + """Determines whether cache reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to cache reserve. + """ + + min_file_size: int + """The minimum file size eligible for store in cache reserve.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange(BaseModel): + from_: int = FieldInfo(alias="from") + """response status code lower bound""" + + to: int + """response status code upper bound""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(BaseModel): + value: int + """Time to cache a response (in seconds). + + A value of 0 is equivalent to setting the Cache-Control header with the value + "no-cache". A value of -1 is equivalent to setting Cache-Control header with the + value of "no-store". + """ + + status_code_range: Optional[ + RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + ] = None + """The range of status codes used to apply the selected mode.""" + + status_code_value: Optional[int] = None + """Set the ttl for responses with this specific status code""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL(BaseModel): + default: int + """The TTL (in seconds) if you choose override_origin mode.""" + + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """edge ttl options""" + + status_code_ttl: List[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL] + """List of single status codes, or status code ranges to apply the selected mode""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersServeStale(BaseModel): + disable_stale_while_updating: bool + """Defines whether Cloudflare should serve stale content while updating. + + If true, Cloudflare will not serve stale content while getting the latest + content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParameters(BaseModel): + additional_cacheable_ports: Optional[List[int]] = None + """List of additional ports that caching can be enabled on.""" + + browser_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL] = None + """Specify how long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: Optional[bool] = None + """Mark whether the request’s response from origin is eligible for caching. + + Caching itself will still depend on the cache-control header and your other + caching configurations. + """ + + cache_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey] = None + """ + Define which components of the request are included or excluded from the cache + key Cloudflare uses to store the response in cache. + """ + + cache_reserve: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve] = None + """ + Mark whether the request's response from origin is eligible for Cache Reserve + (requires a Cache Reserve add-on plan). + """ + + edge_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL] = None + """ + TTL (Time to Live) specifies the maximum time to cache a resource in the + Cloudflare edge network. + """ + + origin_cache_control: Optional[bool] = None + """When enabled, Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: Optional[bool] = None + """Generate Cloudflare error pages from issues sent from the origin server. + + When on, error pages will trigger for issues from the origin + """ + + read_timeout: Optional[int] = None + """ + Define a timeout value between two successive read operations to your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: Optional[bool] = None + """ + Specify whether or not Cloudflare should respect strong ETag (entity tag) + headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersServeStale] = None + """ + Define if Cloudflare should serve stale content while getting the latest content + from the origin. If on, Cloudflare will not serve stale content while getting + the latest content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRule(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["set_cache_settings"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheSettingsRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" -__all__ = ["RulesetCreateResponse", "Rule"] -Rule = Union[BlockRule, ExecuteRule, LogRule, SkipRule] +Rule = Union[ + BlockRule, + RuleRulesetsChallengeRule, + RuleRulesetsCompressResponseRule, + ExecuteRule, + RuleRulesetsJsChallengeRule, + LogRule, + RuleRulesetsManagedChallengeRule, + RuleRulesetsRedirectRule, + RuleRulesetsRewriteRule, + RuleRulesetsRouteRule, + RuleRulesetsScoreRule, + RuleRulesetsServeErrorRule, + RuleRulesetsSetConfigRule, + SkipRule, + RuleRulesetsSetCacheSettingsRule, +] class RulesetCreateResponse(BaseModel): diff --git a/src/cloudflare/types/ruleset_get_response.py b/src/cloudflare/types/ruleset_get_response.py index 3ec45ca675e..7171964af75 100644 --- a/src/cloudflare/types/ruleset_get_response.py +++ b/src/cloudflare/types/ruleset_get_response.py @@ -1,15 +1,962 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from pydantic import Field as FieldInfo + from .._models import BaseModel -from .rulesets import LogRule, SkipRule, BlockRule, ExecuteRule +from .rulesets import Logging, LogRule, SkipRule, BlockRule, ExecuteRule + +__all__ = [ + "RulesetGetResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsCompressResponseRule", + "RuleRulesetsCompressResponseRuleActionParameters", + "RuleRulesetsCompressResponseRuleActionParametersAlgorithm", + "RuleRulesetsJsChallengeRule", + "RuleRulesetsManagedChallengeRule", + "RuleRulesetsRedirectRule", + "RuleRulesetsRedirectRuleActionParameters", + "RuleRulesetsRedirectRuleActionParametersFromList", + "RuleRulesetsRedirectRuleActionParametersFromValue", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURL", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect", + "RuleRulesetsRewriteRule", + "RuleRulesetsRewriteRuleActionParameters", + "RuleRulesetsRewriteRuleActionParametersHeaders", + "RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader", + "RuleRulesetsRewriteRuleActionParametersURI", + "RuleRulesetsRewriteRuleActionParametersURIPath", + "RuleRulesetsRewriteRuleActionParametersURIPathStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue", + "RuleRulesetsRewriteRuleActionParametersURIQuery", + "RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue", + "RuleRulesetsRouteRule", + "RuleRulesetsRouteRuleActionParameters", + "RuleRulesetsRouteRuleActionParametersOrigin", + "RuleRulesetsRouteRuleActionParametersSni", + "RuleRulesetsScoreRule", + "RuleRulesetsScoreRuleActionParameters", + "RuleRulesetsServeErrorRule", + "RuleRulesetsServeErrorRuleActionParameters", + "RuleRulesetsSetConfigRule", + "RuleRulesetsSetConfigRuleActionParameters", + "RuleRulesetsSetConfigRuleActionParametersAutominify", + "RuleRulesetsSetCacheSettingsRule", + "RuleRulesetsSetCacheSettingsRuleActionParameters", + "RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "RuleRulesetsSetCacheSettingsRuleActionParametersServeStale", +] + + +class RuleRulesetsChallengeRule(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["challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsCompressResponseRuleActionParametersAlgorithm(BaseModel): + name: Optional[Literal["none", "auto", "default", "gzip", "brotli"]] = None + """Name of compression algorithm to enable.""" + + +class RuleRulesetsCompressResponseRuleActionParameters(BaseModel): + algorithms: Optional[List[RuleRulesetsCompressResponseRuleActionParametersAlgorithm]] = None + """Custom order for compression algorithms.""" + + +class RuleRulesetsCompressResponseRule(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["compress_response"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsCompressResponseRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsJsChallengeRule(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["js_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsManagedChallengeRule(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["managed_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRedirectRuleActionParametersFromList(BaseModel): + key: Optional[str] = None + """Expression that evaluates to the list lookup key.""" + + name: Optional[str] = None + """The name of the list to match against.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect(BaseModel): + value: Optional[str] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect(BaseModel): + expression: Optional[str] = None + """An expression to evaluate to get the URL to redirect the request to.""" + + +RuleRulesetsRedirectRuleActionParametersFromValueTargetURL = Union[ + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect, + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect, +] + + +class RuleRulesetsRedirectRuleActionParametersFromValue(BaseModel): + preserve_query_string: Optional[bool] = None + """Keep the query string of the original request.""" + + status_code: Optional[Literal[301, 302, 303, 307, 308]] = None + """The status code to be used for the redirect.""" + + target_url: Optional[RuleRulesetsRedirectRuleActionParametersFromValueTargetURL] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParameters(BaseModel): + from_list: Optional[RuleRulesetsRedirectRuleActionParametersFromList] = None + """Serve a redirect based on a bulk list lookup.""" + + from_value: Optional[RuleRulesetsRedirectRuleActionParametersFromValue] = None + """Serve a redirect based on the request properties.""" + + +class RuleRulesetsRedirectRule(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["redirect"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRedirectRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader(BaseModel): + operation: Literal["remove"] + + +class RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader(BaseModel): + operation: Literal["set"] + + value: str + """Static value for the header.""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader(BaseModel): + expression: str + """Expression for the header value.""" + + operation: Literal["set"] + + +RuleRulesetsRewriteRuleActionParametersHeaders = Union[ + RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader, + RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader, + RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader, +] + + +class RuleRulesetsRewriteRuleActionParametersURIPathStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIPath = Union[ + RuleRulesetsRewriteRuleActionParametersURIPathStaticValue, + RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIQuery = Union[ + RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue, + RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURI(BaseModel): + path: Optional[RuleRulesetsRewriteRuleActionParametersURIPath] = None + """Path portion rewrite.""" + + query: Optional[RuleRulesetsRewriteRuleActionParametersURIQuery] = None + """Query portion rewrite.""" + + +class RuleRulesetsRewriteRuleActionParameters(BaseModel): + headers: Optional[Dict[str, RuleRulesetsRewriteRuleActionParametersHeaders]] = None + """Map of request headers to modify.""" + + uri: Optional[RuleRulesetsRewriteRuleActionParametersURI] = None + """URI to rewrite the request to.""" + + +class RuleRulesetsRewriteRule(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["rewrite"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRewriteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRouteRuleActionParametersOrigin(BaseModel): + host: Optional[str] = None + """Override the resolved hostname.""" + + port: Optional[float] = None + """Override the destination port.""" + + +class RuleRulesetsRouteRuleActionParametersSni(BaseModel): + value: str + """The SNI override.""" + + +class RuleRulesetsRouteRuleActionParameters(BaseModel): + host_header: Optional[str] = None + """Rewrite the HTTP Host header.""" + + origin: Optional[RuleRulesetsRouteRuleActionParametersOrigin] = None + """Override the IP/TCP destination.""" + + sni: Optional[RuleRulesetsRouteRuleActionParametersSni] = None + """Override the Server Name Indication (SNI).""" + + +class RuleRulesetsRouteRule(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["route"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRouteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsScoreRuleActionParameters(BaseModel): + increment: Optional[int] = None + """ + Increment contains the delta to change the score and can be either positive or + negative. + """ + + +class RuleRulesetsScoreRule(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["score"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsScoreRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsServeErrorRuleActionParameters(BaseModel): + content: Optional[str] = None + """Error response content.""" + + content_type: Optional[Literal["application/json", "text/xml", "text/plain", "text/html"]] = None + """Content-type header to set with the response.""" + + status_code: Optional[float] = None + """The status code to use for the error.""" + + +class RuleRulesetsServeErrorRule(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["serve_error"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsServeErrorRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetConfigRuleActionParametersAutominify(BaseModel): + css: Optional[bool] = None + """Minify CSS files.""" + + html: Optional[bool] = None + """Minify HTML files.""" + + js: Optional[bool] = None + """Minify JS files.""" + + +class RuleRulesetsSetConfigRuleActionParameters(BaseModel): + automatic_https_rewrites: Optional[bool] = None + """Turn on or off Automatic HTTPS Rewrites.""" + + autominify: Optional[RuleRulesetsSetConfigRuleActionParametersAutominify] = None + """Select which file extensions to minify automatically.""" + + bic: Optional[bool] = None + """Turn on or off Browser Integrity Check.""" + + disable_apps: Optional[bool] = None + """Turn off all active Cloudflare Apps.""" + + disable_zaraz: Optional[bool] = None + """Turn off Zaraz.""" + + email_obfuscation: Optional[bool] = None + """Turn on or off Email Obfuscation.""" + + hotlink_protection: Optional[bool] = None + """Turn on or off the Hotlink Protection.""" + + mirage: Optional[bool] = None + """Turn on or off Mirage.""" + + opportunistic_encryption: Optional[bool] = None + """Turn on or off Opportunistic Encryption.""" + + polish: Optional[Literal["off", "lossless", "lossy"]] = None + """Configure the Polish level.""" + + rocket_loader: Optional[bool] = None + """Turn on or off Rocket Loader""" + + security_level: Optional[Literal["off", "essentially_off", "low", "medium", "high", "under_attack"]] = None + """Configure the Security Level.""" + + server_side_excludes: Optional[bool] = None + """Turn on or off Server Side Excludes.""" + + ssl: Optional[Literal["off", "flexible", "full", "strict", "origin_pull"]] = None + """Configure the SSL level.""" + + sxg: Optional[bool] = None + """Turn on or off Signed Exchanges (SXG).""" + + +class RuleRulesetsSetConfigRule(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["set_config"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetConfigRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL(BaseModel): + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """Determines which browser ttl mode to use.""" + + default: Optional[int] = None + """The TTL (in seconds) if you choose override_origin mode.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these cookie names. + + The presence of these cookies is used in building the cache key. + """ + + include: Optional[List[str]] = None + """Include these cookies' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these header names. + + The presence of these headers is used in building the cache key. + """ + + exclude_origin: Optional[bool] = None + """Whether or not to include the origin header. + + A value of true will exclude the origin header in the cache key. + """ + + include: Optional[List[str]] = None + """Include these headers' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(BaseModel): + resolved: Optional[bool] = None + """Use the resolved host in the cache key. + + A value of true will use the resolved host, while a value or false will use the + original host. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(BaseModel): + all: Optional[bool] = None + """Exclude all query string parameters from use in building the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters NOT used to build the cache key. + + All parameters present in the request but missing in this list will be used to + build the cache key. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(BaseModel): + all: Optional[bool] = None + """Use all query string parameters in the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters used to build the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(BaseModel): + exclude: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude] = None + """ + build the cache key using all query string parameters EXCECPT these excluded + parameters + """ + + include: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude] = None + """ + build the cache key using a list of query string parameters that ARE in the + request. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(BaseModel): + device_type: Optional[bool] = None + """Use the user agent's device type in the cache key.""" + + geo: Optional[bool] = None + """Use the user agents's country in the cache key.""" + + lang: Optional[bool] = None + """Use the user agent's language in the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey(BaseModel): + cookie: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie] = None + """The cookies to include in building the cache key.""" + + header: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader] = None + """The header names and values to include in building the cache key.""" + + host: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost] = None + """Whether to use the original host or the resolved host in the cache key.""" + + query_string: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString] = None + """ + Use the presence or absence of parameters in the query string to build the cache + key. + """ + + user: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser] = None + """Characteristics of the request user agent used in building the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey(BaseModel): + cache_by_device_type: Optional[bool] = None + """Separate cached content based on the visitor’s device type""" + + cache_deception_armor: Optional[bool] = None + """ + Protect from web cache deception attacks while allowing static assets to be + cached + """ + + custom_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey] = None + """ + Customize which components of the request are included or excluded from the + cache key. + """ + + ignore_query_strings_order: Optional[bool] = None + """ + Treat requests with the same query parameters the same, regardless of the order + those query parameters are in. A value of true ignores the query strings' order. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve(BaseModel): + eligible: bool + """Determines whether cache reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to cache reserve. + """ + + min_file_size: int + """The minimum file size eligible for store in cache reserve.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange(BaseModel): + from_: int = FieldInfo(alias="from") + """response status code lower bound""" + + to: int + """response status code upper bound""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(BaseModel): + value: int + """Time to cache a response (in seconds). + + A value of 0 is equivalent to setting the Cache-Control header with the value + "no-cache". A value of -1 is equivalent to setting Cache-Control header with the + value of "no-store". + """ + + status_code_range: Optional[ + RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + ] = None + """The range of status codes used to apply the selected mode.""" + + status_code_value: Optional[int] = None + """Set the ttl for responses with this specific status code""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL(BaseModel): + default: int + """The TTL (in seconds) if you choose override_origin mode.""" + + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """edge ttl options""" + + status_code_ttl: List[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL] + """List of single status codes, or status code ranges to apply the selected mode""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersServeStale(BaseModel): + disable_stale_while_updating: bool + """Defines whether Cloudflare should serve stale content while updating. + + If true, Cloudflare will not serve stale content while getting the latest + content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParameters(BaseModel): + additional_cacheable_ports: Optional[List[int]] = None + """List of additional ports that caching can be enabled on.""" + + browser_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL] = None + """Specify how long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: Optional[bool] = None + """Mark whether the request’s response from origin is eligible for caching. + + Caching itself will still depend on the cache-control header and your other + caching configurations. + """ + + cache_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey] = None + """ + Define which components of the request are included or excluded from the cache + key Cloudflare uses to store the response in cache. + """ + + cache_reserve: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve] = None + """ + Mark whether the request's response from origin is eligible for Cache Reserve + (requires a Cache Reserve add-on plan). + """ + + edge_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL] = None + """ + TTL (Time to Live) specifies the maximum time to cache a resource in the + Cloudflare edge network. + """ + + origin_cache_control: Optional[bool] = None + """When enabled, Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: Optional[bool] = None + """Generate Cloudflare error pages from issues sent from the origin server. + + When on, error pages will trigger for issues from the origin + """ + + read_timeout: Optional[int] = None + """ + Define a timeout value between two successive read operations to your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: Optional[bool] = None + """ + Specify whether or not Cloudflare should respect strong ETag (entity tag) + headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersServeStale] = None + """ + Define if Cloudflare should serve stale content while getting the latest content + from the origin. If on, Cloudflare will not serve stale content while getting + the latest content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRule(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["set_cache_settings"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheSettingsRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" -__all__ = ["RulesetGetResponse", "Rule"] -Rule = Union[BlockRule, ExecuteRule, LogRule, SkipRule] +Rule = Union[ + BlockRule, + RuleRulesetsChallengeRule, + RuleRulesetsCompressResponseRule, + ExecuteRule, + RuleRulesetsJsChallengeRule, + LogRule, + RuleRulesetsManagedChallengeRule, + RuleRulesetsRedirectRule, + RuleRulesetsRewriteRule, + RuleRulesetsRouteRule, + RuleRulesetsScoreRule, + RuleRulesetsServeErrorRule, + RuleRulesetsSetConfigRule, + SkipRule, + RuleRulesetsSetCacheSettingsRule, +] class RulesetGetResponse(BaseModel): diff --git a/src/cloudflare/types/ruleset_update_params.py b/src/cloudflare/types/ruleset_update_params.py index fcb7b5b0298..4de369133c1 100644 --- a/src/cloudflare/types/ruleset_update_params.py +++ b/src/cloudflare/types/ruleset_update_params.py @@ -2,12 +2,69 @@ from __future__ import annotations -from typing import Union, Iterable +from typing import Dict, List, Union, Iterable from typing_extensions import Literal, Required, TypedDict -from .rulesets import LogRuleParam, SkipRuleParam, BlockRuleParam, ExecuteRuleParam +from .rulesets import LoggingParam, LogRuleParam, SkipRuleParam, BlockRuleParam, ExecuteRuleParam -__all__ = ["RulesetUpdateParams", "Rule"] +__all__ = [ + "RulesetUpdateParams", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsCompressResponseRule", + "RuleRulesetsCompressResponseRuleActionParameters", + "RuleRulesetsCompressResponseRuleActionParametersAlgorithm", + "RuleRulesetsJsChallengeRule", + "RuleRulesetsManagedChallengeRule", + "RuleRulesetsRedirectRule", + "RuleRulesetsRedirectRuleActionParameters", + "RuleRulesetsRedirectRuleActionParametersFromList", + "RuleRulesetsRedirectRuleActionParametersFromValue", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURL", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect", + "RuleRulesetsRewriteRule", + "RuleRulesetsRewriteRuleActionParameters", + "RuleRulesetsRewriteRuleActionParametersHeaders", + "RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader", + "RuleRulesetsRewriteRuleActionParametersURI", + "RuleRulesetsRewriteRuleActionParametersURIPath", + "RuleRulesetsRewriteRuleActionParametersURIPathStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue", + "RuleRulesetsRewriteRuleActionParametersURIQuery", + "RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue", + "RuleRulesetsRouteRule", + "RuleRulesetsRouteRuleActionParameters", + "RuleRulesetsRouteRuleActionParametersOrigin", + "RuleRulesetsRouteRuleActionParametersSni", + "RuleRulesetsScoreRule", + "RuleRulesetsScoreRuleActionParameters", + "RuleRulesetsServeErrorRule", + "RuleRulesetsServeErrorRuleActionParameters", + "RuleRulesetsSetConfigRule", + "RuleRulesetsSetConfigRuleActionParameters", + "RuleRulesetsSetConfigRuleActionParametersAutominify", + "RuleRulesetsSetCacheSettingsRule", + "RuleRulesetsSetCacheSettingsRuleActionParameters", + "RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "RuleRulesetsSetCacheSettingsRuleActionParametersServeStale", +] class RulesetUpdateParams(TypedDict, total=False): @@ -57,4 +114,798 @@ class RulesetUpdateParams(TypedDict, total=False): """The phase of the ruleset.""" -Rule = Union[BlockRuleParam, ExecuteRuleParam, LogRuleParam, SkipRuleParam] +class RuleRulesetsChallengeRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["challenge"] + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsCompressResponseRuleActionParametersAlgorithm(TypedDict, total=False): + name: Literal["none", "auto", "default", "gzip", "brotli"] + """Name of compression algorithm to enable.""" + + +class RuleRulesetsCompressResponseRuleActionParameters(TypedDict, total=False): + algorithms: Iterable[RuleRulesetsCompressResponseRuleActionParametersAlgorithm] + """Custom order for compression algorithms.""" + + +class RuleRulesetsCompressResponseRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["compress_response"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsCompressResponseRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsJsChallengeRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["js_challenge"] + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsManagedChallengeRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["managed_challenge"] + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRedirectRuleActionParametersFromList(TypedDict, total=False): + key: str + """Expression that evaluates to the list lookup key.""" + + name: str + """The name of the list to match against.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect(TypedDict, total=False): + value: str + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect(TypedDict, total=False): + expression: str + """An expression to evaluate to get the URL to redirect the request to.""" + + +RuleRulesetsRedirectRuleActionParametersFromValueTargetURL = Union[ + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect, + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect, +] + + +class RuleRulesetsRedirectRuleActionParametersFromValue(TypedDict, total=False): + preserve_query_string: bool + """Keep the query string of the original request.""" + + status_code: Literal[301, 302, 303, 307, 308] + """The status code to be used for the redirect.""" + + target_url: RuleRulesetsRedirectRuleActionParametersFromValueTargetURL + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParameters(TypedDict, total=False): + from_list: RuleRulesetsRedirectRuleActionParametersFromList + """Serve a redirect based on a bulk list lookup.""" + + from_value: RuleRulesetsRedirectRuleActionParametersFromValue + """Serve a redirect based on the request properties.""" + + +class RuleRulesetsRedirectRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["redirect"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsRedirectRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader(TypedDict, total=False): + operation: Required[Literal["remove"]] + + +class RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader(TypedDict, total=False): + operation: Required[Literal["set"]] + + value: Required[str] + """Static value for the header.""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader(TypedDict, total=False): + expression: Required[str] + """Expression for the header value.""" + + operation: Required[Literal["set"]] + + +RuleRulesetsRewriteRuleActionParametersHeaders = Union[ + RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader, + RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader, + RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader, +] + + +class RuleRulesetsRewriteRuleActionParametersURIPathStaticValue(TypedDict, total=False): + value: Required[str] + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue(TypedDict, total=False): + expression: Required[str] + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIPath = Union[ + RuleRulesetsRewriteRuleActionParametersURIPathStaticValue, + RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue(TypedDict, total=False): + value: Required[str] + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue(TypedDict, total=False): + expression: Required[str] + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIQuery = Union[ + RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue, + RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURI(TypedDict, total=False): + path: RuleRulesetsRewriteRuleActionParametersURIPath + """Path portion rewrite.""" + + query: RuleRulesetsRewriteRuleActionParametersURIQuery + """Query portion rewrite.""" + + +class RuleRulesetsRewriteRuleActionParameters(TypedDict, total=False): + headers: Dict[str, RuleRulesetsRewriteRuleActionParametersHeaders] + """Map of request headers to modify.""" + + uri: RuleRulesetsRewriteRuleActionParametersURI + """URI to rewrite the request to.""" + + +class RuleRulesetsRewriteRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["rewrite"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsRewriteRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRouteRuleActionParametersOrigin(TypedDict, total=False): + host: str + """Override the resolved hostname.""" + + port: float + """Override the destination port.""" + + +class RuleRulesetsRouteRuleActionParametersSni(TypedDict, total=False): + value: Required[str] + """The SNI override.""" + + +class RuleRulesetsRouteRuleActionParameters(TypedDict, total=False): + host_header: str + """Rewrite the HTTP Host header.""" + + origin: RuleRulesetsRouteRuleActionParametersOrigin + """Override the IP/TCP destination.""" + + sni: RuleRulesetsRouteRuleActionParametersSni + """Override the Server Name Indication (SNI).""" + + +class RuleRulesetsRouteRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["route"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsRouteRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsScoreRuleActionParameters(TypedDict, total=False): + increment: int + """ + Increment contains the delta to change the score and can be either positive or + negative. + """ + + +class RuleRulesetsScoreRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["score"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsScoreRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsServeErrorRuleActionParameters(TypedDict, total=False): + content: str + """Error response content.""" + + content_type: Literal["application/json", "text/xml", "text/plain", "text/html"] + """Content-type header to set with the response.""" + + status_code: float + """The status code to use for the error.""" + + +class RuleRulesetsServeErrorRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["serve_error"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsServeErrorRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetConfigRuleActionParametersAutominify(TypedDict, total=False): + css: bool + """Minify CSS files.""" + + html: bool + """Minify HTML files.""" + + js: bool + """Minify JS files.""" + + +class RuleRulesetsSetConfigRuleActionParameters(TypedDict, total=False): + automatic_https_rewrites: bool + """Turn on or off Automatic HTTPS Rewrites.""" + + autominify: RuleRulesetsSetConfigRuleActionParametersAutominify + """Select which file extensions to minify automatically.""" + + bic: bool + """Turn on or off Browser Integrity Check.""" + + disable_apps: bool + """Turn off all active Cloudflare Apps.""" + + disable_zaraz: bool + """Turn off Zaraz.""" + + email_obfuscation: bool + """Turn on or off Email Obfuscation.""" + + hotlink_protection: bool + """Turn on or off the Hotlink Protection.""" + + mirage: bool + """Turn on or off Mirage.""" + + opportunistic_encryption: bool + """Turn on or off Opportunistic Encryption.""" + + polish: Literal["off", "lossless", "lossy"] + """Configure the Polish level.""" + + rocket_loader: bool + """Turn on or off Rocket Loader""" + + security_level: Literal["off", "essentially_off", "low", "medium", "high", "under_attack"] + """Configure the Security Level.""" + + server_side_excludes: bool + """Turn on or off Server Side Excludes.""" + + ssl: Literal["off", "flexible", "full", "strict", "origin_pull"] + """Configure the SSL level.""" + + sxg: bool + """Turn on or off Signed Exchanges (SXG).""" + + +class RuleRulesetsSetConfigRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_config"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetConfigRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL(TypedDict, total=False): + mode: Required[Literal["respect_origin", "bypass_by_default", "override_origin"]] + """Determines which browser ttl mode to use.""" + + default: int + """The TTL (in seconds) if you choose override_origin mode.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(TypedDict, total=False): + check_presence: List[str] + """Checks for the presence of these cookie names. + + The presence of these cookies is used in building the cache key. + """ + + include: List[str] + """Include these cookies' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(TypedDict, total=False): + check_presence: List[str] + """Checks for the presence of these header names. + + The presence of these headers is used in building the cache key. + """ + + exclude_origin: bool + """Whether or not to include the origin header. + + A value of true will exclude the origin header in the cache key. + """ + + include: List[str] + """Include these headers' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(TypedDict, total=False): + resolved: bool + """Use the resolved host in the cache key. + + A value of true will use the resolved host, while a value or false will use the + original host. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(TypedDict, total=False): + all: bool + """Exclude all query string parameters from use in building the cache key.""" + + list: List[str] + """A list of query string parameters NOT used to build the cache key. + + All parameters present in the request but missing in this list will be used to + build the cache key. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(TypedDict, total=False): + all: bool + """Use all query string parameters in the cache key.""" + + list: List[str] + """A list of query string parameters used to build the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(TypedDict, total=False): + exclude: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude + """ + build the cache key using all query string parameters EXCECPT these excluded + parameters + """ + + include: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude + """ + build the cache key using a list of query string parameters that ARE in the + request. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(TypedDict, total=False): + device_type: bool + """Use the user agent's device type in the cache key.""" + + geo: bool + """Use the user agents's country in the cache key.""" + + lang: bool + """Use the user agent's language in the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey(TypedDict, total=False): + cookie: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie + """The cookies to include in building the cache key.""" + + header: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader + """The header names and values to include in building the cache key.""" + + host: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost + """Whether to use the original host or the resolved host in the cache key.""" + + query_string: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString + """ + Use the presence or absence of parameters in the query string to build the cache + key. + """ + + user: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser + """Characteristics of the request user agent used in building the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey(TypedDict, total=False): + cache_by_device_type: bool + """Separate cached content based on the visitor’s device type""" + + cache_deception_armor: bool + """ + Protect from web cache deception attacks while allowing static assets to be + cached + """ + + custom_key: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey + """ + Customize which components of the request are included or excluded from the + cache key. + """ + + ignore_query_strings_order: bool + """ + Treat requests with the same query parameters the same, regardless of the order + those query parameters are in. A value of true ignores the query strings' order. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve(TypedDict, total=False): + eligible: Required[bool] + """Determines whether cache reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to cache reserve. + """ + + min_file_size: Required[int] + """The minimum file size eligible for store in cache reserve.""" + + +_RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords = TypedDict( + "_RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords", + { + "from": int, + }, + total=False, +) + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange( + _RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords, total=False +): + to: Required[int] + """response status code upper bound""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(TypedDict, total=False): + value: Required[int] + """Time to cache a response (in seconds). + + A value of 0 is equivalent to setting the Cache-Control header with the value + "no-cache". A value of -1 is equivalent to setting Cache-Control header with the + value of "no-store". + """ + + status_code_range: RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + """The range of status codes used to apply the selected mode.""" + + status_code_value: int + """Set the ttl for responses with this specific status code""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL(TypedDict, total=False): + default: Required[int] + """The TTL (in seconds) if you choose override_origin mode.""" + + mode: Required[Literal["respect_origin", "bypass_by_default", "override_origin"]] + """edge ttl options""" + + status_code_ttl: Required[Iterable[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL]] + """List of single status codes, or status code ranges to apply the selected mode""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersServeStale(TypedDict, total=False): + disable_stale_while_updating: Required[bool] + """Defines whether Cloudflare should serve stale content while updating. + + If true, Cloudflare will not serve stale content while getting the latest + content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParameters(TypedDict, total=False): + additional_cacheable_ports: Iterable[int] + """List of additional ports that caching can be enabled on.""" + + browser_ttl: RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL + """Specify how long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: bool + """Mark whether the request’s response from origin is eligible for caching. + + Caching itself will still depend on the cache-control header and your other + caching configurations. + """ + + cache_key: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey + """ + Define which components of the request are included or excluded from the cache + key Cloudflare uses to store the response in cache. + """ + + cache_reserve: RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve + """ + Mark whether the request's response from origin is eligible for Cache Reserve + (requires a Cache Reserve add-on plan). + """ + + edge_ttl: RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL + """ + TTL (Time to Live) specifies the maximum time to cache a resource in the + Cloudflare edge network. + """ + + origin_cache_control: bool + """When enabled, Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: bool + """Generate Cloudflare error pages from issues sent from the origin server. + + When on, error pages will trigger for issues from the origin + """ + + read_timeout: int + """ + Define a timeout value between two successive read operations to your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: bool + """ + Specify whether or not Cloudflare should respect strong ETag (entity tag) + headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: RuleRulesetsSetCacheSettingsRuleActionParametersServeStale + """ + Define if Cloudflare should serve stale content while getting the latest content + from the origin. If on, Cloudflare will not serve stale content while getting + the latest content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_settings"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetCacheSettingsRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +Rule = Union[ + BlockRuleParam, + RuleRulesetsChallengeRule, + RuleRulesetsCompressResponseRule, + ExecuteRuleParam, + RuleRulesetsJsChallengeRule, + LogRuleParam, + RuleRulesetsManagedChallengeRule, + RuleRulesetsRedirectRule, + RuleRulesetsRewriteRule, + RuleRulesetsRouteRule, + RuleRulesetsScoreRule, + RuleRulesetsServeErrorRule, + RuleRulesetsSetConfigRule, + SkipRuleParam, + RuleRulesetsSetCacheSettingsRule, +] diff --git a/src/cloudflare/types/ruleset_update_response.py b/src/cloudflare/types/ruleset_update_response.py index 691bb31e2fd..8ef688d6149 100644 --- a/src/cloudflare/types/ruleset_update_response.py +++ b/src/cloudflare/types/ruleset_update_response.py @@ -1,15 +1,962 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from pydantic import Field as FieldInfo + from .._models import BaseModel -from .rulesets import LogRule, SkipRule, BlockRule, ExecuteRule +from .rulesets import Logging, LogRule, SkipRule, BlockRule, ExecuteRule + +__all__ = [ + "RulesetUpdateResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsCompressResponseRule", + "RuleRulesetsCompressResponseRuleActionParameters", + "RuleRulesetsCompressResponseRuleActionParametersAlgorithm", + "RuleRulesetsJsChallengeRule", + "RuleRulesetsManagedChallengeRule", + "RuleRulesetsRedirectRule", + "RuleRulesetsRedirectRuleActionParameters", + "RuleRulesetsRedirectRuleActionParametersFromList", + "RuleRulesetsRedirectRuleActionParametersFromValue", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURL", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect", + "RuleRulesetsRewriteRule", + "RuleRulesetsRewriteRuleActionParameters", + "RuleRulesetsRewriteRuleActionParametersHeaders", + "RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader", + "RuleRulesetsRewriteRuleActionParametersURI", + "RuleRulesetsRewriteRuleActionParametersURIPath", + "RuleRulesetsRewriteRuleActionParametersURIPathStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue", + "RuleRulesetsRewriteRuleActionParametersURIQuery", + "RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue", + "RuleRulesetsRouteRule", + "RuleRulesetsRouteRuleActionParameters", + "RuleRulesetsRouteRuleActionParametersOrigin", + "RuleRulesetsRouteRuleActionParametersSni", + "RuleRulesetsScoreRule", + "RuleRulesetsScoreRuleActionParameters", + "RuleRulesetsServeErrorRule", + "RuleRulesetsServeErrorRuleActionParameters", + "RuleRulesetsSetConfigRule", + "RuleRulesetsSetConfigRuleActionParameters", + "RuleRulesetsSetConfigRuleActionParametersAutominify", + "RuleRulesetsSetCacheSettingsRule", + "RuleRulesetsSetCacheSettingsRuleActionParameters", + "RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "RuleRulesetsSetCacheSettingsRuleActionParametersServeStale", +] + + +class RuleRulesetsChallengeRule(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["challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsCompressResponseRuleActionParametersAlgorithm(BaseModel): + name: Optional[Literal["none", "auto", "default", "gzip", "brotli"]] = None + """Name of compression algorithm to enable.""" + + +class RuleRulesetsCompressResponseRuleActionParameters(BaseModel): + algorithms: Optional[List[RuleRulesetsCompressResponseRuleActionParametersAlgorithm]] = None + """Custom order for compression algorithms.""" + + +class RuleRulesetsCompressResponseRule(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["compress_response"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsCompressResponseRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsJsChallengeRule(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["js_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsManagedChallengeRule(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["managed_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRedirectRuleActionParametersFromList(BaseModel): + key: Optional[str] = None + """Expression that evaluates to the list lookup key.""" + + name: Optional[str] = None + """The name of the list to match against.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect(BaseModel): + value: Optional[str] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect(BaseModel): + expression: Optional[str] = None + """An expression to evaluate to get the URL to redirect the request to.""" + + +RuleRulesetsRedirectRuleActionParametersFromValueTargetURL = Union[ + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect, + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect, +] + + +class RuleRulesetsRedirectRuleActionParametersFromValue(BaseModel): + preserve_query_string: Optional[bool] = None + """Keep the query string of the original request.""" + + status_code: Optional[Literal[301, 302, 303, 307, 308]] = None + """The status code to be used for the redirect.""" + + target_url: Optional[RuleRulesetsRedirectRuleActionParametersFromValueTargetURL] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParameters(BaseModel): + from_list: Optional[RuleRulesetsRedirectRuleActionParametersFromList] = None + """Serve a redirect based on a bulk list lookup.""" + + from_value: Optional[RuleRulesetsRedirectRuleActionParametersFromValue] = None + """Serve a redirect based on the request properties.""" + + +class RuleRulesetsRedirectRule(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["redirect"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRedirectRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader(BaseModel): + operation: Literal["remove"] + + +class RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader(BaseModel): + operation: Literal["set"] + + value: str + """Static value for the header.""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader(BaseModel): + expression: str + """Expression for the header value.""" + + operation: Literal["set"] + + +RuleRulesetsRewriteRuleActionParametersHeaders = Union[ + RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader, + RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader, + RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader, +] + + +class RuleRulesetsRewriteRuleActionParametersURIPathStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIPath = Union[ + RuleRulesetsRewriteRuleActionParametersURIPathStaticValue, + RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIQuery = Union[ + RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue, + RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURI(BaseModel): + path: Optional[RuleRulesetsRewriteRuleActionParametersURIPath] = None + """Path portion rewrite.""" + + query: Optional[RuleRulesetsRewriteRuleActionParametersURIQuery] = None + """Query portion rewrite.""" + + +class RuleRulesetsRewriteRuleActionParameters(BaseModel): + headers: Optional[Dict[str, RuleRulesetsRewriteRuleActionParametersHeaders]] = None + """Map of request headers to modify.""" + + uri: Optional[RuleRulesetsRewriteRuleActionParametersURI] = None + """URI to rewrite the request to.""" + + +class RuleRulesetsRewriteRule(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["rewrite"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRewriteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRouteRuleActionParametersOrigin(BaseModel): + host: Optional[str] = None + """Override the resolved hostname.""" + + port: Optional[float] = None + """Override the destination port.""" + + +class RuleRulesetsRouteRuleActionParametersSni(BaseModel): + value: str + """The SNI override.""" + + +class RuleRulesetsRouteRuleActionParameters(BaseModel): + host_header: Optional[str] = None + """Rewrite the HTTP Host header.""" + + origin: Optional[RuleRulesetsRouteRuleActionParametersOrigin] = None + """Override the IP/TCP destination.""" + + sni: Optional[RuleRulesetsRouteRuleActionParametersSni] = None + """Override the Server Name Indication (SNI).""" + + +class RuleRulesetsRouteRule(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["route"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRouteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsScoreRuleActionParameters(BaseModel): + increment: Optional[int] = None + """ + Increment contains the delta to change the score and can be either positive or + negative. + """ + + +class RuleRulesetsScoreRule(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["score"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsScoreRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsServeErrorRuleActionParameters(BaseModel): + content: Optional[str] = None + """Error response content.""" + + content_type: Optional[Literal["application/json", "text/xml", "text/plain", "text/html"]] = None + """Content-type header to set with the response.""" + + status_code: Optional[float] = None + """The status code to use for the error.""" + + +class RuleRulesetsServeErrorRule(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["serve_error"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsServeErrorRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetConfigRuleActionParametersAutominify(BaseModel): + css: Optional[bool] = None + """Minify CSS files.""" + + html: Optional[bool] = None + """Minify HTML files.""" + + js: Optional[bool] = None + """Minify JS files.""" + + +class RuleRulesetsSetConfigRuleActionParameters(BaseModel): + automatic_https_rewrites: Optional[bool] = None + """Turn on or off Automatic HTTPS Rewrites.""" + + autominify: Optional[RuleRulesetsSetConfigRuleActionParametersAutominify] = None + """Select which file extensions to minify automatically.""" + + bic: Optional[bool] = None + """Turn on or off Browser Integrity Check.""" + + disable_apps: Optional[bool] = None + """Turn off all active Cloudflare Apps.""" + + disable_zaraz: Optional[bool] = None + """Turn off Zaraz.""" + + email_obfuscation: Optional[bool] = None + """Turn on or off Email Obfuscation.""" + + hotlink_protection: Optional[bool] = None + """Turn on or off the Hotlink Protection.""" + + mirage: Optional[bool] = None + """Turn on or off Mirage.""" + + opportunistic_encryption: Optional[bool] = None + """Turn on or off Opportunistic Encryption.""" + + polish: Optional[Literal["off", "lossless", "lossy"]] = None + """Configure the Polish level.""" + + rocket_loader: Optional[bool] = None + """Turn on or off Rocket Loader""" + + security_level: Optional[Literal["off", "essentially_off", "low", "medium", "high", "under_attack"]] = None + """Configure the Security Level.""" + + server_side_excludes: Optional[bool] = None + """Turn on or off Server Side Excludes.""" + + ssl: Optional[Literal["off", "flexible", "full", "strict", "origin_pull"]] = None + """Configure the SSL level.""" + + sxg: Optional[bool] = None + """Turn on or off Signed Exchanges (SXG).""" + + +class RuleRulesetsSetConfigRule(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["set_config"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetConfigRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL(BaseModel): + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """Determines which browser ttl mode to use.""" + + default: Optional[int] = None + """The TTL (in seconds) if you choose override_origin mode.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these cookie names. + + The presence of these cookies is used in building the cache key. + """ + + include: Optional[List[str]] = None + """Include these cookies' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these header names. + + The presence of these headers is used in building the cache key. + """ + + exclude_origin: Optional[bool] = None + """Whether or not to include the origin header. + + A value of true will exclude the origin header in the cache key. + """ + + include: Optional[List[str]] = None + """Include these headers' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(BaseModel): + resolved: Optional[bool] = None + """Use the resolved host in the cache key. + + A value of true will use the resolved host, while a value or false will use the + original host. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(BaseModel): + all: Optional[bool] = None + """Exclude all query string parameters from use in building the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters NOT used to build the cache key. + + All parameters present in the request but missing in this list will be used to + build the cache key. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(BaseModel): + all: Optional[bool] = None + """Use all query string parameters in the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters used to build the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(BaseModel): + exclude: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude] = None + """ + build the cache key using all query string parameters EXCECPT these excluded + parameters + """ + + include: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude] = None + """ + build the cache key using a list of query string parameters that ARE in the + request. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(BaseModel): + device_type: Optional[bool] = None + """Use the user agent's device type in the cache key.""" + + geo: Optional[bool] = None + """Use the user agents's country in the cache key.""" + + lang: Optional[bool] = None + """Use the user agent's language in the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey(BaseModel): + cookie: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie] = None + """The cookies to include in building the cache key.""" + + header: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader] = None + """The header names and values to include in building the cache key.""" + + host: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost] = None + """Whether to use the original host or the resolved host in the cache key.""" + + query_string: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString] = None + """ + Use the presence or absence of parameters in the query string to build the cache + key. + """ + + user: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser] = None + """Characteristics of the request user agent used in building the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey(BaseModel): + cache_by_device_type: Optional[bool] = None + """Separate cached content based on the visitor’s device type""" + + cache_deception_armor: Optional[bool] = None + """ + Protect from web cache deception attacks while allowing static assets to be + cached + """ + + custom_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey] = None + """ + Customize which components of the request are included or excluded from the + cache key. + """ + + ignore_query_strings_order: Optional[bool] = None + """ + Treat requests with the same query parameters the same, regardless of the order + those query parameters are in. A value of true ignores the query strings' order. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve(BaseModel): + eligible: bool + """Determines whether cache reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to cache reserve. + """ + + min_file_size: int + """The minimum file size eligible for store in cache reserve.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange(BaseModel): + from_: int = FieldInfo(alias="from") + """response status code lower bound""" + + to: int + """response status code upper bound""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(BaseModel): + value: int + """Time to cache a response (in seconds). + + A value of 0 is equivalent to setting the Cache-Control header with the value + "no-cache". A value of -1 is equivalent to setting Cache-Control header with the + value of "no-store". + """ + + status_code_range: Optional[ + RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + ] = None + """The range of status codes used to apply the selected mode.""" + + status_code_value: Optional[int] = None + """Set the ttl for responses with this specific status code""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL(BaseModel): + default: int + """The TTL (in seconds) if you choose override_origin mode.""" + + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """edge ttl options""" + + status_code_ttl: List[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL] + """List of single status codes, or status code ranges to apply the selected mode""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersServeStale(BaseModel): + disable_stale_while_updating: bool + """Defines whether Cloudflare should serve stale content while updating. + + If true, Cloudflare will not serve stale content while getting the latest + content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParameters(BaseModel): + additional_cacheable_ports: Optional[List[int]] = None + """List of additional ports that caching can be enabled on.""" + + browser_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL] = None + """Specify how long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: Optional[bool] = None + """Mark whether the request’s response from origin is eligible for caching. + + Caching itself will still depend on the cache-control header and your other + caching configurations. + """ + + cache_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey] = None + """ + Define which components of the request are included or excluded from the cache + key Cloudflare uses to store the response in cache. + """ + + cache_reserve: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve] = None + """ + Mark whether the request's response from origin is eligible for Cache Reserve + (requires a Cache Reserve add-on plan). + """ + + edge_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL] = None + """ + TTL (Time to Live) specifies the maximum time to cache a resource in the + Cloudflare edge network. + """ + + origin_cache_control: Optional[bool] = None + """When enabled, Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: Optional[bool] = None + """Generate Cloudflare error pages from issues sent from the origin server. + + When on, error pages will trigger for issues from the origin + """ + + read_timeout: Optional[int] = None + """ + Define a timeout value between two successive read operations to your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: Optional[bool] = None + """ + Specify whether or not Cloudflare should respect strong ETag (entity tag) + headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersServeStale] = None + """ + Define if Cloudflare should serve stale content while getting the latest content + from the origin. If on, Cloudflare will not serve stale content while getting + the latest content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRule(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["set_cache_settings"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheSettingsRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" -__all__ = ["RulesetUpdateResponse", "Rule"] -Rule = Union[BlockRule, ExecuteRule, LogRule, SkipRule] +Rule = Union[ + BlockRule, + RuleRulesetsChallengeRule, + RuleRulesetsCompressResponseRule, + ExecuteRule, + RuleRulesetsJsChallengeRule, + LogRule, + RuleRulesetsManagedChallengeRule, + RuleRulesetsRedirectRule, + RuleRulesetsRewriteRule, + RuleRulesetsRouteRule, + RuleRulesetsScoreRule, + RuleRulesetsServeErrorRule, + RuleRulesetsSetConfigRule, + SkipRule, + RuleRulesetsSetCacheSettingsRule, +] class RulesetUpdateResponse(BaseModel): diff --git a/src/cloudflare/types/rulesets/phase_get_response.py b/src/cloudflare/types/rulesets/phase_get_response.py index e509a7cda57..7a4562b8e16 100644 --- a/src/cloudflare/types/rulesets/phase_get_response.py +++ b/src/cloudflare/types/rulesets/phase_get_response.py @@ -1,18 +1,966 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from pydantic import Field as FieldInfo + +from .logging import Logging from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule from .block_rule import BlockRule from .execute_rule import ExecuteRule -__all__ = ["PhaseGetResponse", "Rule"] +__all__ = [ + "PhaseGetResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsCompressResponseRule", + "RuleRulesetsCompressResponseRuleActionParameters", + "RuleRulesetsCompressResponseRuleActionParametersAlgorithm", + "RuleRulesetsJsChallengeRule", + "RuleRulesetsManagedChallengeRule", + "RuleRulesetsRedirectRule", + "RuleRulesetsRedirectRuleActionParameters", + "RuleRulesetsRedirectRuleActionParametersFromList", + "RuleRulesetsRedirectRuleActionParametersFromValue", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURL", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect", + "RuleRulesetsRewriteRule", + "RuleRulesetsRewriteRuleActionParameters", + "RuleRulesetsRewriteRuleActionParametersHeaders", + "RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader", + "RuleRulesetsRewriteRuleActionParametersURI", + "RuleRulesetsRewriteRuleActionParametersURIPath", + "RuleRulesetsRewriteRuleActionParametersURIPathStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue", + "RuleRulesetsRewriteRuleActionParametersURIQuery", + "RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue", + "RuleRulesetsRouteRule", + "RuleRulesetsRouteRuleActionParameters", + "RuleRulesetsRouteRuleActionParametersOrigin", + "RuleRulesetsRouteRuleActionParametersSni", + "RuleRulesetsScoreRule", + "RuleRulesetsScoreRuleActionParameters", + "RuleRulesetsServeErrorRule", + "RuleRulesetsServeErrorRuleActionParameters", + "RuleRulesetsSetConfigRule", + "RuleRulesetsSetConfigRuleActionParameters", + "RuleRulesetsSetConfigRuleActionParametersAutominify", + "RuleRulesetsSetCacheSettingsRule", + "RuleRulesetsSetCacheSettingsRuleActionParameters", + "RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "RuleRulesetsSetCacheSettingsRuleActionParametersServeStale", +] + + +class RuleRulesetsChallengeRule(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["challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsCompressResponseRuleActionParametersAlgorithm(BaseModel): + name: Optional[Literal["none", "auto", "default", "gzip", "brotli"]] = None + """Name of compression algorithm to enable.""" + + +class RuleRulesetsCompressResponseRuleActionParameters(BaseModel): + algorithms: Optional[List[RuleRulesetsCompressResponseRuleActionParametersAlgorithm]] = None + """Custom order for compression algorithms.""" + + +class RuleRulesetsCompressResponseRule(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["compress_response"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsCompressResponseRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsJsChallengeRule(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["js_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsManagedChallengeRule(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["managed_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRedirectRuleActionParametersFromList(BaseModel): + key: Optional[str] = None + """Expression that evaluates to the list lookup key.""" + + name: Optional[str] = None + """The name of the list to match against.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect(BaseModel): + value: Optional[str] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect(BaseModel): + expression: Optional[str] = None + """An expression to evaluate to get the URL to redirect the request to.""" + + +RuleRulesetsRedirectRuleActionParametersFromValueTargetURL = Union[ + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect, + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect, +] + + +class RuleRulesetsRedirectRuleActionParametersFromValue(BaseModel): + preserve_query_string: Optional[bool] = None + """Keep the query string of the original request.""" + + status_code: Optional[Literal[301, 302, 303, 307, 308]] = None + """The status code to be used for the redirect.""" + + target_url: Optional[RuleRulesetsRedirectRuleActionParametersFromValueTargetURL] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParameters(BaseModel): + from_list: Optional[RuleRulesetsRedirectRuleActionParametersFromList] = None + """Serve a redirect based on a bulk list lookup.""" + + from_value: Optional[RuleRulesetsRedirectRuleActionParametersFromValue] = None + """Serve a redirect based on the request properties.""" + + +class RuleRulesetsRedirectRule(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["redirect"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRedirectRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader(BaseModel): + operation: Literal["remove"] + + +class RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader(BaseModel): + operation: Literal["set"] + + value: str + """Static value for the header.""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader(BaseModel): + expression: str + """Expression for the header value.""" + + operation: Literal["set"] + + +RuleRulesetsRewriteRuleActionParametersHeaders = Union[ + RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader, + RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader, + RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader, +] + + +class RuleRulesetsRewriteRuleActionParametersURIPathStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIPath = Union[ + RuleRulesetsRewriteRuleActionParametersURIPathStaticValue, + RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIQuery = Union[ + RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue, + RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURI(BaseModel): + path: Optional[RuleRulesetsRewriteRuleActionParametersURIPath] = None + """Path portion rewrite.""" + + query: Optional[RuleRulesetsRewriteRuleActionParametersURIQuery] = None + """Query portion rewrite.""" + + +class RuleRulesetsRewriteRuleActionParameters(BaseModel): + headers: Optional[Dict[str, RuleRulesetsRewriteRuleActionParametersHeaders]] = None + """Map of request headers to modify.""" + + uri: Optional[RuleRulesetsRewriteRuleActionParametersURI] = None + """URI to rewrite the request to.""" + + +class RuleRulesetsRewriteRule(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["rewrite"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRewriteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRouteRuleActionParametersOrigin(BaseModel): + host: Optional[str] = None + """Override the resolved hostname.""" + + port: Optional[float] = None + """Override the destination port.""" + + +class RuleRulesetsRouteRuleActionParametersSni(BaseModel): + value: str + """The SNI override.""" + + +class RuleRulesetsRouteRuleActionParameters(BaseModel): + host_header: Optional[str] = None + """Rewrite the HTTP Host header.""" + + origin: Optional[RuleRulesetsRouteRuleActionParametersOrigin] = None + """Override the IP/TCP destination.""" + + sni: Optional[RuleRulesetsRouteRuleActionParametersSni] = None + """Override the Server Name Indication (SNI).""" + + +class RuleRulesetsRouteRule(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["route"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRouteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsScoreRuleActionParameters(BaseModel): + increment: Optional[int] = None + """ + Increment contains the delta to change the score and can be either positive or + negative. + """ + + +class RuleRulesetsScoreRule(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["score"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsScoreRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsServeErrorRuleActionParameters(BaseModel): + content: Optional[str] = None + """Error response content.""" + + content_type: Optional[Literal["application/json", "text/xml", "text/plain", "text/html"]] = None + """Content-type header to set with the response.""" + + status_code: Optional[float] = None + """The status code to use for the error.""" + + +class RuleRulesetsServeErrorRule(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["serve_error"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsServeErrorRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetConfigRuleActionParametersAutominify(BaseModel): + css: Optional[bool] = None + """Minify CSS files.""" + + html: Optional[bool] = None + """Minify HTML files.""" + + js: Optional[bool] = None + """Minify JS files.""" + + +class RuleRulesetsSetConfigRuleActionParameters(BaseModel): + automatic_https_rewrites: Optional[bool] = None + """Turn on or off Automatic HTTPS Rewrites.""" + + autominify: Optional[RuleRulesetsSetConfigRuleActionParametersAutominify] = None + """Select which file extensions to minify automatically.""" + + bic: Optional[bool] = None + """Turn on or off Browser Integrity Check.""" + + disable_apps: Optional[bool] = None + """Turn off all active Cloudflare Apps.""" + + disable_zaraz: Optional[bool] = None + """Turn off Zaraz.""" + + email_obfuscation: Optional[bool] = None + """Turn on or off Email Obfuscation.""" + + hotlink_protection: Optional[bool] = None + """Turn on or off the Hotlink Protection.""" + + mirage: Optional[bool] = None + """Turn on or off Mirage.""" + + opportunistic_encryption: Optional[bool] = None + """Turn on or off Opportunistic Encryption.""" + + polish: Optional[Literal["off", "lossless", "lossy"]] = None + """Configure the Polish level.""" + + rocket_loader: Optional[bool] = None + """Turn on or off Rocket Loader""" + + security_level: Optional[Literal["off", "essentially_off", "low", "medium", "high", "under_attack"]] = None + """Configure the Security Level.""" + + server_side_excludes: Optional[bool] = None + """Turn on or off Server Side Excludes.""" + + ssl: Optional[Literal["off", "flexible", "full", "strict", "origin_pull"]] = None + """Configure the SSL level.""" + + sxg: Optional[bool] = None + """Turn on or off Signed Exchanges (SXG).""" + + +class RuleRulesetsSetConfigRule(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["set_config"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetConfigRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL(BaseModel): + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """Determines which browser ttl mode to use.""" + + default: Optional[int] = None + """The TTL (in seconds) if you choose override_origin mode.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these cookie names. + + The presence of these cookies is used in building the cache key. + """ + + include: Optional[List[str]] = None + """Include these cookies' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these header names. + + The presence of these headers is used in building the cache key. + """ + + exclude_origin: Optional[bool] = None + """Whether or not to include the origin header. + + A value of true will exclude the origin header in the cache key. + """ + + include: Optional[List[str]] = None + """Include these headers' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(BaseModel): + resolved: Optional[bool] = None + """Use the resolved host in the cache key. + + A value of true will use the resolved host, while a value or false will use the + original host. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(BaseModel): + all: Optional[bool] = None + """Exclude all query string parameters from use in building the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters NOT used to build the cache key. + + All parameters present in the request but missing in this list will be used to + build the cache key. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(BaseModel): + all: Optional[bool] = None + """Use all query string parameters in the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters used to build the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(BaseModel): + exclude: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude] = None + """ + build the cache key using all query string parameters EXCECPT these excluded + parameters + """ + + include: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude] = None + """ + build the cache key using a list of query string parameters that ARE in the + request. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(BaseModel): + device_type: Optional[bool] = None + """Use the user agent's device type in the cache key.""" + + geo: Optional[bool] = None + """Use the user agents's country in the cache key.""" + + lang: Optional[bool] = None + """Use the user agent's language in the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey(BaseModel): + cookie: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie] = None + """The cookies to include in building the cache key.""" + + header: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader] = None + """The header names and values to include in building the cache key.""" + + host: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost] = None + """Whether to use the original host or the resolved host in the cache key.""" + + query_string: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString] = None + """ + Use the presence or absence of parameters in the query string to build the cache + key. + """ + + user: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser] = None + """Characteristics of the request user agent used in building the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey(BaseModel): + cache_by_device_type: Optional[bool] = None + """Separate cached content based on the visitor’s device type""" + + cache_deception_armor: Optional[bool] = None + """ + Protect from web cache deception attacks while allowing static assets to be + cached + """ + + custom_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey] = None + """ + Customize which components of the request are included or excluded from the + cache key. + """ + + ignore_query_strings_order: Optional[bool] = None + """ + Treat requests with the same query parameters the same, regardless of the order + those query parameters are in. A value of true ignores the query strings' order. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve(BaseModel): + eligible: bool + """Determines whether cache reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to cache reserve. + """ + + min_file_size: int + """The minimum file size eligible for store in cache reserve.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange(BaseModel): + from_: int = FieldInfo(alias="from") + """response status code lower bound""" + + to: int + """response status code upper bound""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(BaseModel): + value: int + """Time to cache a response (in seconds). + + A value of 0 is equivalent to setting the Cache-Control header with the value + "no-cache". A value of -1 is equivalent to setting Cache-Control header with the + value of "no-store". + """ + + status_code_range: Optional[ + RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + ] = None + """The range of status codes used to apply the selected mode.""" + + status_code_value: Optional[int] = None + """Set the ttl for responses with this specific status code""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL(BaseModel): + default: int + """The TTL (in seconds) if you choose override_origin mode.""" + + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """edge ttl options""" + + status_code_ttl: List[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL] + """List of single status codes, or status code ranges to apply the selected mode""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersServeStale(BaseModel): + disable_stale_while_updating: bool + """Defines whether Cloudflare should serve stale content while updating. + + If true, Cloudflare will not serve stale content while getting the latest + content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParameters(BaseModel): + additional_cacheable_ports: Optional[List[int]] = None + """List of additional ports that caching can be enabled on.""" + + browser_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL] = None + """Specify how long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: Optional[bool] = None + """Mark whether the request’s response from origin is eligible for caching. + + Caching itself will still depend on the cache-control header and your other + caching configurations. + """ + + cache_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey] = None + """ + Define which components of the request are included or excluded from the cache + key Cloudflare uses to store the response in cache. + """ + + cache_reserve: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve] = None + """ + Mark whether the request's response from origin is eligible for Cache Reserve + (requires a Cache Reserve add-on plan). + """ + + edge_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL] = None + """ + TTL (Time to Live) specifies the maximum time to cache a resource in the + Cloudflare edge network. + """ + + origin_cache_control: Optional[bool] = None + """When enabled, Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: Optional[bool] = None + """Generate Cloudflare error pages from issues sent from the origin server. + + When on, error pages will trigger for issues from the origin + """ + + read_timeout: Optional[int] = None + """ + Define a timeout value between two successive read operations to your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: Optional[bool] = None + """ + Specify whether or not Cloudflare should respect strong ETag (entity tag) + headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersServeStale] = None + """ + Define if Cloudflare should serve stale content while getting the latest content + from the origin. If on, Cloudflare will not serve stale content while getting + the latest content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRule(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["set_cache_settings"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheSettingsRuleActionParameters] = 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[Logging] = 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[BlockRule, ExecuteRule, LogRule, SkipRule] +Rule = Union[ + BlockRule, + RuleRulesetsChallengeRule, + RuleRulesetsCompressResponseRule, + ExecuteRule, + RuleRulesetsJsChallengeRule, + LogRule, + RuleRulesetsManagedChallengeRule, + RuleRulesetsRedirectRule, + RuleRulesetsRewriteRule, + RuleRulesetsRouteRule, + RuleRulesetsScoreRule, + RuleRulesetsServeErrorRule, + RuleRulesetsSetConfigRule, + SkipRule, + RuleRulesetsSetCacheSettingsRule, +] class PhaseGetResponse(BaseModel): diff --git a/src/cloudflare/types/rulesets/phase_update_params.py b/src/cloudflare/types/rulesets/phase_update_params.py index d3d9f075311..134d35989ff 100644 --- a/src/cloudflare/types/rulesets/phase_update_params.py +++ b/src/cloudflare/types/rulesets/phase_update_params.py @@ -2,15 +2,73 @@ from __future__ import annotations -from typing import Union, Iterable +from typing import Dict, List, Union, Iterable from typing_extensions import Literal, Required, TypedDict +from .logging_param import LoggingParam from .log_rule_param import LogRuleParam from .skip_rule_param import SkipRuleParam from .block_rule_param import BlockRuleParam from .execute_rule_param import ExecuteRuleParam -__all__ = ["PhaseUpdateParams", "Rule"] +__all__ = [ + "PhaseUpdateParams", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsCompressResponseRule", + "RuleRulesetsCompressResponseRuleActionParameters", + "RuleRulesetsCompressResponseRuleActionParametersAlgorithm", + "RuleRulesetsJsChallengeRule", + "RuleRulesetsManagedChallengeRule", + "RuleRulesetsRedirectRule", + "RuleRulesetsRedirectRuleActionParameters", + "RuleRulesetsRedirectRuleActionParametersFromList", + "RuleRulesetsRedirectRuleActionParametersFromValue", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURL", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect", + "RuleRulesetsRewriteRule", + "RuleRulesetsRewriteRuleActionParameters", + "RuleRulesetsRewriteRuleActionParametersHeaders", + "RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader", + "RuleRulesetsRewriteRuleActionParametersURI", + "RuleRulesetsRewriteRuleActionParametersURIPath", + "RuleRulesetsRewriteRuleActionParametersURIPathStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue", + "RuleRulesetsRewriteRuleActionParametersURIQuery", + "RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue", + "RuleRulesetsRouteRule", + "RuleRulesetsRouteRuleActionParameters", + "RuleRulesetsRouteRuleActionParametersOrigin", + "RuleRulesetsRouteRuleActionParametersSni", + "RuleRulesetsScoreRule", + "RuleRulesetsScoreRuleActionParameters", + "RuleRulesetsServeErrorRule", + "RuleRulesetsServeErrorRuleActionParameters", + "RuleRulesetsSetConfigRule", + "RuleRulesetsSetConfigRuleActionParameters", + "RuleRulesetsSetConfigRuleActionParametersAutominify", + "RuleRulesetsSetCacheSettingsRule", + "RuleRulesetsSetCacheSettingsRuleActionParameters", + "RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "RuleRulesetsSetCacheSettingsRuleActionParametersServeStale", +] class PhaseUpdateParams(TypedDict, total=False): @@ -60,4 +118,798 @@ class PhaseUpdateParams(TypedDict, total=False): """The phase of the ruleset.""" -Rule = Union[BlockRuleParam, ExecuteRuleParam, LogRuleParam, SkipRuleParam] +class RuleRulesetsChallengeRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["challenge"] + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsCompressResponseRuleActionParametersAlgorithm(TypedDict, total=False): + name: Literal["none", "auto", "default", "gzip", "brotli"] + """Name of compression algorithm to enable.""" + + +class RuleRulesetsCompressResponseRuleActionParameters(TypedDict, total=False): + algorithms: Iterable[RuleRulesetsCompressResponseRuleActionParametersAlgorithm] + """Custom order for compression algorithms.""" + + +class RuleRulesetsCompressResponseRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["compress_response"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsCompressResponseRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsJsChallengeRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["js_challenge"] + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsManagedChallengeRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["managed_challenge"] + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRedirectRuleActionParametersFromList(TypedDict, total=False): + key: str + """Expression that evaluates to the list lookup key.""" + + name: str + """The name of the list to match against.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect(TypedDict, total=False): + value: str + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect(TypedDict, total=False): + expression: str + """An expression to evaluate to get the URL to redirect the request to.""" + + +RuleRulesetsRedirectRuleActionParametersFromValueTargetURL = Union[ + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect, + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect, +] + + +class RuleRulesetsRedirectRuleActionParametersFromValue(TypedDict, total=False): + preserve_query_string: bool + """Keep the query string of the original request.""" + + status_code: Literal[301, 302, 303, 307, 308] + """The status code to be used for the redirect.""" + + target_url: RuleRulesetsRedirectRuleActionParametersFromValueTargetURL + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParameters(TypedDict, total=False): + from_list: RuleRulesetsRedirectRuleActionParametersFromList + """Serve a redirect based on a bulk list lookup.""" + + from_value: RuleRulesetsRedirectRuleActionParametersFromValue + """Serve a redirect based on the request properties.""" + + +class RuleRulesetsRedirectRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["redirect"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsRedirectRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader(TypedDict, total=False): + operation: Required[Literal["remove"]] + + +class RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader(TypedDict, total=False): + operation: Required[Literal["set"]] + + value: Required[str] + """Static value for the header.""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader(TypedDict, total=False): + expression: Required[str] + """Expression for the header value.""" + + operation: Required[Literal["set"]] + + +RuleRulesetsRewriteRuleActionParametersHeaders = Union[ + RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader, + RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader, + RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader, +] + + +class RuleRulesetsRewriteRuleActionParametersURIPathStaticValue(TypedDict, total=False): + value: Required[str] + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue(TypedDict, total=False): + expression: Required[str] + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIPath = Union[ + RuleRulesetsRewriteRuleActionParametersURIPathStaticValue, + RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue(TypedDict, total=False): + value: Required[str] + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue(TypedDict, total=False): + expression: Required[str] + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIQuery = Union[ + RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue, + RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURI(TypedDict, total=False): + path: RuleRulesetsRewriteRuleActionParametersURIPath + """Path portion rewrite.""" + + query: RuleRulesetsRewriteRuleActionParametersURIQuery + """Query portion rewrite.""" + + +class RuleRulesetsRewriteRuleActionParameters(TypedDict, total=False): + headers: Dict[str, RuleRulesetsRewriteRuleActionParametersHeaders] + """Map of request headers to modify.""" + + uri: RuleRulesetsRewriteRuleActionParametersURI + """URI to rewrite the request to.""" + + +class RuleRulesetsRewriteRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["rewrite"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsRewriteRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRouteRuleActionParametersOrigin(TypedDict, total=False): + host: str + """Override the resolved hostname.""" + + port: float + """Override the destination port.""" + + +class RuleRulesetsRouteRuleActionParametersSni(TypedDict, total=False): + value: Required[str] + """The SNI override.""" + + +class RuleRulesetsRouteRuleActionParameters(TypedDict, total=False): + host_header: str + """Rewrite the HTTP Host header.""" + + origin: RuleRulesetsRouteRuleActionParametersOrigin + """Override the IP/TCP destination.""" + + sni: RuleRulesetsRouteRuleActionParametersSni + """Override the Server Name Indication (SNI).""" + + +class RuleRulesetsRouteRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["route"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsRouteRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsScoreRuleActionParameters(TypedDict, total=False): + increment: int + """ + Increment contains the delta to change the score and can be either positive or + negative. + """ + + +class RuleRulesetsScoreRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["score"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsScoreRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsServeErrorRuleActionParameters(TypedDict, total=False): + content: str + """Error response content.""" + + content_type: Literal["application/json", "text/xml", "text/plain", "text/html"] + """Content-type header to set with the response.""" + + status_code: float + """The status code to use for the error.""" + + +class RuleRulesetsServeErrorRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["serve_error"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsServeErrorRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetConfigRuleActionParametersAutominify(TypedDict, total=False): + css: bool + """Minify CSS files.""" + + html: bool + """Minify HTML files.""" + + js: bool + """Minify JS files.""" + + +class RuleRulesetsSetConfigRuleActionParameters(TypedDict, total=False): + automatic_https_rewrites: bool + """Turn on or off Automatic HTTPS Rewrites.""" + + autominify: RuleRulesetsSetConfigRuleActionParametersAutominify + """Select which file extensions to minify automatically.""" + + bic: bool + """Turn on or off Browser Integrity Check.""" + + disable_apps: bool + """Turn off all active Cloudflare Apps.""" + + disable_zaraz: bool + """Turn off Zaraz.""" + + email_obfuscation: bool + """Turn on or off Email Obfuscation.""" + + hotlink_protection: bool + """Turn on or off the Hotlink Protection.""" + + mirage: bool + """Turn on or off Mirage.""" + + opportunistic_encryption: bool + """Turn on or off Opportunistic Encryption.""" + + polish: Literal["off", "lossless", "lossy"] + """Configure the Polish level.""" + + rocket_loader: bool + """Turn on or off Rocket Loader""" + + security_level: Literal["off", "essentially_off", "low", "medium", "high", "under_attack"] + """Configure the Security Level.""" + + server_side_excludes: bool + """Turn on or off Server Side Excludes.""" + + ssl: Literal["off", "flexible", "full", "strict", "origin_pull"] + """Configure the SSL level.""" + + sxg: bool + """Turn on or off Signed Exchanges (SXG).""" + + +class RuleRulesetsSetConfigRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_config"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetConfigRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL(TypedDict, total=False): + mode: Required[Literal["respect_origin", "bypass_by_default", "override_origin"]] + """Determines which browser ttl mode to use.""" + + default: int + """The TTL (in seconds) if you choose override_origin mode.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(TypedDict, total=False): + check_presence: List[str] + """Checks for the presence of these cookie names. + + The presence of these cookies is used in building the cache key. + """ + + include: List[str] + """Include these cookies' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(TypedDict, total=False): + check_presence: List[str] + """Checks for the presence of these header names. + + The presence of these headers is used in building the cache key. + """ + + exclude_origin: bool + """Whether or not to include the origin header. + + A value of true will exclude the origin header in the cache key. + """ + + include: List[str] + """Include these headers' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(TypedDict, total=False): + resolved: bool + """Use the resolved host in the cache key. + + A value of true will use the resolved host, while a value or false will use the + original host. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(TypedDict, total=False): + all: bool + """Exclude all query string parameters from use in building the cache key.""" + + list: List[str] + """A list of query string parameters NOT used to build the cache key. + + All parameters present in the request but missing in this list will be used to + build the cache key. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(TypedDict, total=False): + all: bool + """Use all query string parameters in the cache key.""" + + list: List[str] + """A list of query string parameters used to build the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(TypedDict, total=False): + exclude: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude + """ + build the cache key using all query string parameters EXCECPT these excluded + parameters + """ + + include: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude + """ + build the cache key using a list of query string parameters that ARE in the + request. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(TypedDict, total=False): + device_type: bool + """Use the user agent's device type in the cache key.""" + + geo: bool + """Use the user agents's country in the cache key.""" + + lang: bool + """Use the user agent's language in the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey(TypedDict, total=False): + cookie: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie + """The cookies to include in building the cache key.""" + + header: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader + """The header names and values to include in building the cache key.""" + + host: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost + """Whether to use the original host or the resolved host in the cache key.""" + + query_string: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString + """ + Use the presence or absence of parameters in the query string to build the cache + key. + """ + + user: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser + """Characteristics of the request user agent used in building the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey(TypedDict, total=False): + cache_by_device_type: bool + """Separate cached content based on the visitor’s device type""" + + cache_deception_armor: bool + """ + Protect from web cache deception attacks while allowing static assets to be + cached + """ + + custom_key: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey + """ + Customize which components of the request are included or excluded from the + cache key. + """ + + ignore_query_strings_order: bool + """ + Treat requests with the same query parameters the same, regardless of the order + those query parameters are in. A value of true ignores the query strings' order. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve(TypedDict, total=False): + eligible: Required[bool] + """Determines whether cache reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to cache reserve. + """ + + min_file_size: Required[int] + """The minimum file size eligible for store in cache reserve.""" + + +_RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords = TypedDict( + "_RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords", + { + "from": int, + }, + total=False, +) + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange( + _RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords, total=False +): + to: Required[int] + """response status code upper bound""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(TypedDict, total=False): + value: Required[int] + """Time to cache a response (in seconds). + + A value of 0 is equivalent to setting the Cache-Control header with the value + "no-cache". A value of -1 is equivalent to setting Cache-Control header with the + value of "no-store". + """ + + status_code_range: RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + """The range of status codes used to apply the selected mode.""" + + status_code_value: int + """Set the ttl for responses with this specific status code""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL(TypedDict, total=False): + default: Required[int] + """The TTL (in seconds) if you choose override_origin mode.""" + + mode: Required[Literal["respect_origin", "bypass_by_default", "override_origin"]] + """edge ttl options""" + + status_code_ttl: Required[Iterable[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL]] + """List of single status codes, or status code ranges to apply the selected mode""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersServeStale(TypedDict, total=False): + disable_stale_while_updating: Required[bool] + """Defines whether Cloudflare should serve stale content while updating. + + If true, Cloudflare will not serve stale content while getting the latest + content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParameters(TypedDict, total=False): + additional_cacheable_ports: Iterable[int] + """List of additional ports that caching can be enabled on.""" + + browser_ttl: RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL + """Specify how long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: bool + """Mark whether the request’s response from origin is eligible for caching. + + Caching itself will still depend on the cache-control header and your other + caching configurations. + """ + + cache_key: RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey + """ + Define which components of the request are included or excluded from the cache + key Cloudflare uses to store the response in cache. + """ + + cache_reserve: RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve + """ + Mark whether the request's response from origin is eligible for Cache Reserve + (requires a Cache Reserve add-on plan). + """ + + edge_ttl: RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL + """ + TTL (Time to Live) specifies the maximum time to cache a resource in the + Cloudflare edge network. + """ + + origin_cache_control: bool + """When enabled, Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: bool + """Generate Cloudflare error pages from issues sent from the origin server. + + When on, error pages will trigger for issues from the origin + """ + + read_timeout: int + """ + Define a timeout value between two successive read operations to your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: bool + """ + Specify whether or not Cloudflare should respect strong ETag (entity tag) + headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: RuleRulesetsSetCacheSettingsRuleActionParametersServeStale + """ + Define if Cloudflare should serve stale content while getting the latest content + from the origin. If on, Cloudflare will not serve stale content while getting + the latest content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRule(TypedDict, total=False): + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_settings"] + """The action to perform when the rule matches.""" + + action_parameters: RuleRulesetsSetCacheSettingsRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +Rule = Union[ + BlockRuleParam, + RuleRulesetsChallengeRule, + RuleRulesetsCompressResponseRule, + ExecuteRuleParam, + RuleRulesetsJsChallengeRule, + LogRuleParam, + RuleRulesetsManagedChallengeRule, + RuleRulesetsRedirectRule, + RuleRulesetsRewriteRule, + RuleRulesetsRouteRule, + RuleRulesetsScoreRule, + RuleRulesetsServeErrorRule, + RuleRulesetsSetConfigRule, + SkipRuleParam, + RuleRulesetsSetCacheSettingsRule, +] diff --git a/src/cloudflare/types/rulesets/phase_update_response.py b/src/cloudflare/types/rulesets/phase_update_response.py index 0c1cd322a13..5295d28b058 100644 --- a/src/cloudflare/types/rulesets/phase_update_response.py +++ b/src/cloudflare/types/rulesets/phase_update_response.py @@ -1,18 +1,966 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from pydantic import Field as FieldInfo + +from .logging import Logging from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule from .block_rule import BlockRule from .execute_rule import ExecuteRule -__all__ = ["PhaseUpdateResponse", "Rule"] +__all__ = [ + "PhaseUpdateResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsCompressResponseRule", + "RuleRulesetsCompressResponseRuleActionParameters", + "RuleRulesetsCompressResponseRuleActionParametersAlgorithm", + "RuleRulesetsJsChallengeRule", + "RuleRulesetsManagedChallengeRule", + "RuleRulesetsRedirectRule", + "RuleRulesetsRedirectRuleActionParameters", + "RuleRulesetsRedirectRuleActionParametersFromList", + "RuleRulesetsRedirectRuleActionParametersFromValue", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURL", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect", + "RuleRulesetsRewriteRule", + "RuleRulesetsRewriteRuleActionParameters", + "RuleRulesetsRewriteRuleActionParametersHeaders", + "RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader", + "RuleRulesetsRewriteRuleActionParametersURI", + "RuleRulesetsRewriteRuleActionParametersURIPath", + "RuleRulesetsRewriteRuleActionParametersURIPathStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue", + "RuleRulesetsRewriteRuleActionParametersURIQuery", + "RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue", + "RuleRulesetsRouteRule", + "RuleRulesetsRouteRuleActionParameters", + "RuleRulesetsRouteRuleActionParametersOrigin", + "RuleRulesetsRouteRuleActionParametersSni", + "RuleRulesetsScoreRule", + "RuleRulesetsScoreRuleActionParameters", + "RuleRulesetsServeErrorRule", + "RuleRulesetsServeErrorRuleActionParameters", + "RuleRulesetsSetConfigRule", + "RuleRulesetsSetConfigRuleActionParameters", + "RuleRulesetsSetConfigRuleActionParametersAutominify", + "RuleRulesetsSetCacheSettingsRule", + "RuleRulesetsSetCacheSettingsRuleActionParameters", + "RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "RuleRulesetsSetCacheSettingsRuleActionParametersServeStale", +] + + +class RuleRulesetsChallengeRule(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["challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsCompressResponseRuleActionParametersAlgorithm(BaseModel): + name: Optional[Literal["none", "auto", "default", "gzip", "brotli"]] = None + """Name of compression algorithm to enable.""" + + +class RuleRulesetsCompressResponseRuleActionParameters(BaseModel): + algorithms: Optional[List[RuleRulesetsCompressResponseRuleActionParametersAlgorithm]] = None + """Custom order for compression algorithms.""" + + +class RuleRulesetsCompressResponseRule(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["compress_response"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsCompressResponseRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsJsChallengeRule(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["js_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsManagedChallengeRule(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["managed_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRedirectRuleActionParametersFromList(BaseModel): + key: Optional[str] = None + """Expression that evaluates to the list lookup key.""" + + name: Optional[str] = None + """The name of the list to match against.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect(BaseModel): + value: Optional[str] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect(BaseModel): + expression: Optional[str] = None + """An expression to evaluate to get the URL to redirect the request to.""" + + +RuleRulesetsRedirectRuleActionParametersFromValueTargetURL = Union[ + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect, + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect, +] + + +class RuleRulesetsRedirectRuleActionParametersFromValue(BaseModel): + preserve_query_string: Optional[bool] = None + """Keep the query string of the original request.""" + + status_code: Optional[Literal[301, 302, 303, 307, 308]] = None + """The status code to be used for the redirect.""" + + target_url: Optional[RuleRulesetsRedirectRuleActionParametersFromValueTargetURL] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParameters(BaseModel): + from_list: Optional[RuleRulesetsRedirectRuleActionParametersFromList] = None + """Serve a redirect based on a bulk list lookup.""" + + from_value: Optional[RuleRulesetsRedirectRuleActionParametersFromValue] = None + """Serve a redirect based on the request properties.""" + + +class RuleRulesetsRedirectRule(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["redirect"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRedirectRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader(BaseModel): + operation: Literal["remove"] + + +class RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader(BaseModel): + operation: Literal["set"] + + value: str + """Static value for the header.""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader(BaseModel): + expression: str + """Expression for the header value.""" + + operation: Literal["set"] + + +RuleRulesetsRewriteRuleActionParametersHeaders = Union[ + RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader, + RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader, + RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader, +] + + +class RuleRulesetsRewriteRuleActionParametersURIPathStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIPath = Union[ + RuleRulesetsRewriteRuleActionParametersURIPathStaticValue, + RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIQuery = Union[ + RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue, + RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURI(BaseModel): + path: Optional[RuleRulesetsRewriteRuleActionParametersURIPath] = None + """Path portion rewrite.""" + + query: Optional[RuleRulesetsRewriteRuleActionParametersURIQuery] = None + """Query portion rewrite.""" + + +class RuleRulesetsRewriteRuleActionParameters(BaseModel): + headers: Optional[Dict[str, RuleRulesetsRewriteRuleActionParametersHeaders]] = None + """Map of request headers to modify.""" + + uri: Optional[RuleRulesetsRewriteRuleActionParametersURI] = None + """URI to rewrite the request to.""" + + +class RuleRulesetsRewriteRule(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["rewrite"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRewriteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRouteRuleActionParametersOrigin(BaseModel): + host: Optional[str] = None + """Override the resolved hostname.""" + + port: Optional[float] = None + """Override the destination port.""" + + +class RuleRulesetsRouteRuleActionParametersSni(BaseModel): + value: str + """The SNI override.""" + + +class RuleRulesetsRouteRuleActionParameters(BaseModel): + host_header: Optional[str] = None + """Rewrite the HTTP Host header.""" + + origin: Optional[RuleRulesetsRouteRuleActionParametersOrigin] = None + """Override the IP/TCP destination.""" + + sni: Optional[RuleRulesetsRouteRuleActionParametersSni] = None + """Override the Server Name Indication (SNI).""" + + +class RuleRulesetsRouteRule(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["route"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRouteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsScoreRuleActionParameters(BaseModel): + increment: Optional[int] = None + """ + Increment contains the delta to change the score and can be either positive or + negative. + """ + + +class RuleRulesetsScoreRule(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["score"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsScoreRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsServeErrorRuleActionParameters(BaseModel): + content: Optional[str] = None + """Error response content.""" + + content_type: Optional[Literal["application/json", "text/xml", "text/plain", "text/html"]] = None + """Content-type header to set with the response.""" + + status_code: Optional[float] = None + """The status code to use for the error.""" + + +class RuleRulesetsServeErrorRule(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["serve_error"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsServeErrorRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetConfigRuleActionParametersAutominify(BaseModel): + css: Optional[bool] = None + """Minify CSS files.""" + + html: Optional[bool] = None + """Minify HTML files.""" + + js: Optional[bool] = None + """Minify JS files.""" + + +class RuleRulesetsSetConfigRuleActionParameters(BaseModel): + automatic_https_rewrites: Optional[bool] = None + """Turn on or off Automatic HTTPS Rewrites.""" + + autominify: Optional[RuleRulesetsSetConfigRuleActionParametersAutominify] = None + """Select which file extensions to minify automatically.""" + + bic: Optional[bool] = None + """Turn on or off Browser Integrity Check.""" + + disable_apps: Optional[bool] = None + """Turn off all active Cloudflare Apps.""" + + disable_zaraz: Optional[bool] = None + """Turn off Zaraz.""" + + email_obfuscation: Optional[bool] = None + """Turn on or off Email Obfuscation.""" + + hotlink_protection: Optional[bool] = None + """Turn on or off the Hotlink Protection.""" + + mirage: Optional[bool] = None + """Turn on or off Mirage.""" + + opportunistic_encryption: Optional[bool] = None + """Turn on or off Opportunistic Encryption.""" + + polish: Optional[Literal["off", "lossless", "lossy"]] = None + """Configure the Polish level.""" + + rocket_loader: Optional[bool] = None + """Turn on or off Rocket Loader""" + + security_level: Optional[Literal["off", "essentially_off", "low", "medium", "high", "under_attack"]] = None + """Configure the Security Level.""" + + server_side_excludes: Optional[bool] = None + """Turn on or off Server Side Excludes.""" + + ssl: Optional[Literal["off", "flexible", "full", "strict", "origin_pull"]] = None + """Configure the SSL level.""" + + sxg: Optional[bool] = None + """Turn on or off Signed Exchanges (SXG).""" + + +class RuleRulesetsSetConfigRule(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["set_config"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetConfigRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL(BaseModel): + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """Determines which browser ttl mode to use.""" + + default: Optional[int] = None + """The TTL (in seconds) if you choose override_origin mode.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these cookie names. + + The presence of these cookies is used in building the cache key. + """ + + include: Optional[List[str]] = None + """Include these cookies' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these header names. + + The presence of these headers is used in building the cache key. + """ + + exclude_origin: Optional[bool] = None + """Whether or not to include the origin header. + + A value of true will exclude the origin header in the cache key. + """ + + include: Optional[List[str]] = None + """Include these headers' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(BaseModel): + resolved: Optional[bool] = None + """Use the resolved host in the cache key. + + A value of true will use the resolved host, while a value or false will use the + original host. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(BaseModel): + all: Optional[bool] = None + """Exclude all query string parameters from use in building the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters NOT used to build the cache key. + + All parameters present in the request but missing in this list will be used to + build the cache key. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(BaseModel): + all: Optional[bool] = None + """Use all query string parameters in the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters used to build the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(BaseModel): + exclude: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude] = None + """ + build the cache key using all query string parameters EXCECPT these excluded + parameters + """ + + include: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude] = None + """ + build the cache key using a list of query string parameters that ARE in the + request. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(BaseModel): + device_type: Optional[bool] = None + """Use the user agent's device type in the cache key.""" + + geo: Optional[bool] = None + """Use the user agents's country in the cache key.""" + + lang: Optional[bool] = None + """Use the user agent's language in the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey(BaseModel): + cookie: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie] = None + """The cookies to include in building the cache key.""" + + header: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader] = None + """The header names and values to include in building the cache key.""" + + host: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost] = None + """Whether to use the original host or the resolved host in the cache key.""" + + query_string: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString] = None + """ + Use the presence or absence of parameters in the query string to build the cache + key. + """ + + user: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser] = None + """Characteristics of the request user agent used in building the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey(BaseModel): + cache_by_device_type: Optional[bool] = None + """Separate cached content based on the visitor’s device type""" + + cache_deception_armor: Optional[bool] = None + """ + Protect from web cache deception attacks while allowing static assets to be + cached + """ + + custom_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey] = None + """ + Customize which components of the request are included or excluded from the + cache key. + """ + + ignore_query_strings_order: Optional[bool] = None + """ + Treat requests with the same query parameters the same, regardless of the order + those query parameters are in. A value of true ignores the query strings' order. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve(BaseModel): + eligible: bool + """Determines whether cache reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to cache reserve. + """ + + min_file_size: int + """The minimum file size eligible for store in cache reserve.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange(BaseModel): + from_: int = FieldInfo(alias="from") + """response status code lower bound""" + + to: int + """response status code upper bound""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(BaseModel): + value: int + """Time to cache a response (in seconds). + + A value of 0 is equivalent to setting the Cache-Control header with the value + "no-cache". A value of -1 is equivalent to setting Cache-Control header with the + value of "no-store". + """ + + status_code_range: Optional[ + RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + ] = None + """The range of status codes used to apply the selected mode.""" + + status_code_value: Optional[int] = None + """Set the ttl for responses with this specific status code""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL(BaseModel): + default: int + """The TTL (in seconds) if you choose override_origin mode.""" + + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """edge ttl options""" + + status_code_ttl: List[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL] + """List of single status codes, or status code ranges to apply the selected mode""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersServeStale(BaseModel): + disable_stale_while_updating: bool + """Defines whether Cloudflare should serve stale content while updating. + + If true, Cloudflare will not serve stale content while getting the latest + content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParameters(BaseModel): + additional_cacheable_ports: Optional[List[int]] = None + """List of additional ports that caching can be enabled on.""" + + browser_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL] = None + """Specify how long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: Optional[bool] = None + """Mark whether the request’s response from origin is eligible for caching. + + Caching itself will still depend on the cache-control header and your other + caching configurations. + """ + + cache_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey] = None + """ + Define which components of the request are included or excluded from the cache + key Cloudflare uses to store the response in cache. + """ + + cache_reserve: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve] = None + """ + Mark whether the request's response from origin is eligible for Cache Reserve + (requires a Cache Reserve add-on plan). + """ + + edge_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL] = None + """ + TTL (Time to Live) specifies the maximum time to cache a resource in the + Cloudflare edge network. + """ + + origin_cache_control: Optional[bool] = None + """When enabled, Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: Optional[bool] = None + """Generate Cloudflare error pages from issues sent from the origin server. + + When on, error pages will trigger for issues from the origin + """ + + read_timeout: Optional[int] = None + """ + Define a timeout value between two successive read operations to your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: Optional[bool] = None + """ + Specify whether or not Cloudflare should respect strong ETag (entity tag) + headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersServeStale] = None + """ + Define if Cloudflare should serve stale content while getting the latest content + from the origin. If on, Cloudflare will not serve stale content while getting + the latest content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRule(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["set_cache_settings"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheSettingsRuleActionParameters] = 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[Logging] = 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[BlockRule, ExecuteRule, LogRule, SkipRule] +Rule = Union[ + BlockRule, + RuleRulesetsChallengeRule, + RuleRulesetsCompressResponseRule, + ExecuteRule, + RuleRulesetsJsChallengeRule, + LogRule, + RuleRulesetsManagedChallengeRule, + RuleRulesetsRedirectRule, + RuleRulesetsRewriteRule, + RuleRulesetsRouteRule, + RuleRulesetsScoreRule, + RuleRulesetsServeErrorRule, + RuleRulesetsSetConfigRule, + SkipRule, + RuleRulesetsSetCacheSettingsRule, +] class PhaseUpdateResponse(BaseModel): diff --git a/src/cloudflare/types/rulesets/phases/version_get_response.py b/src/cloudflare/types/rulesets/phases/version_get_response.py index e8f1701d4dd..4bb716b1bb9 100644 --- a/src/cloudflare/types/rulesets/phases/version_get_response.py +++ b/src/cloudflare/types/rulesets/phases/version_get_response.py @@ -1,18 +1,966 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from pydantic import Field as FieldInfo + +from ..logging import Logging from ..log_rule import LogRule from ...._models import BaseModel from ..skip_rule import SkipRule from ..block_rule import BlockRule from ..execute_rule import ExecuteRule -__all__ = ["VersionGetResponse", "Rule"] +__all__ = [ + "VersionGetResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsCompressResponseRule", + "RuleRulesetsCompressResponseRuleActionParameters", + "RuleRulesetsCompressResponseRuleActionParametersAlgorithm", + "RuleRulesetsJsChallengeRule", + "RuleRulesetsManagedChallengeRule", + "RuleRulesetsRedirectRule", + "RuleRulesetsRedirectRuleActionParameters", + "RuleRulesetsRedirectRuleActionParametersFromList", + "RuleRulesetsRedirectRuleActionParametersFromValue", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURL", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect", + "RuleRulesetsRewriteRule", + "RuleRulesetsRewriteRuleActionParameters", + "RuleRulesetsRewriteRuleActionParametersHeaders", + "RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader", + "RuleRulesetsRewriteRuleActionParametersURI", + "RuleRulesetsRewriteRuleActionParametersURIPath", + "RuleRulesetsRewriteRuleActionParametersURIPathStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue", + "RuleRulesetsRewriteRuleActionParametersURIQuery", + "RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue", + "RuleRulesetsRouteRule", + "RuleRulesetsRouteRuleActionParameters", + "RuleRulesetsRouteRuleActionParametersOrigin", + "RuleRulesetsRouteRuleActionParametersSni", + "RuleRulesetsScoreRule", + "RuleRulesetsScoreRuleActionParameters", + "RuleRulesetsServeErrorRule", + "RuleRulesetsServeErrorRuleActionParameters", + "RuleRulesetsSetConfigRule", + "RuleRulesetsSetConfigRuleActionParameters", + "RuleRulesetsSetConfigRuleActionParametersAutominify", + "RuleRulesetsSetCacheSettingsRule", + "RuleRulesetsSetCacheSettingsRuleActionParameters", + "RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "RuleRulesetsSetCacheSettingsRuleActionParametersServeStale", +] + + +class RuleRulesetsChallengeRule(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["challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsCompressResponseRuleActionParametersAlgorithm(BaseModel): + name: Optional[Literal["none", "auto", "default", "gzip", "brotli"]] = None + """Name of compression algorithm to enable.""" + + +class RuleRulesetsCompressResponseRuleActionParameters(BaseModel): + algorithms: Optional[List[RuleRulesetsCompressResponseRuleActionParametersAlgorithm]] = None + """Custom order for compression algorithms.""" + + +class RuleRulesetsCompressResponseRule(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["compress_response"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsCompressResponseRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsJsChallengeRule(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["js_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsManagedChallengeRule(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["managed_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRedirectRuleActionParametersFromList(BaseModel): + key: Optional[str] = None + """Expression that evaluates to the list lookup key.""" + + name: Optional[str] = None + """The name of the list to match against.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect(BaseModel): + value: Optional[str] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect(BaseModel): + expression: Optional[str] = None + """An expression to evaluate to get the URL to redirect the request to.""" + + +RuleRulesetsRedirectRuleActionParametersFromValueTargetURL = Union[ + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect, + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect, +] + + +class RuleRulesetsRedirectRuleActionParametersFromValue(BaseModel): + preserve_query_string: Optional[bool] = None + """Keep the query string of the original request.""" + + status_code: Optional[Literal[301, 302, 303, 307, 308]] = None + """The status code to be used for the redirect.""" + + target_url: Optional[RuleRulesetsRedirectRuleActionParametersFromValueTargetURL] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParameters(BaseModel): + from_list: Optional[RuleRulesetsRedirectRuleActionParametersFromList] = None + """Serve a redirect based on a bulk list lookup.""" + + from_value: Optional[RuleRulesetsRedirectRuleActionParametersFromValue] = None + """Serve a redirect based on the request properties.""" + + +class RuleRulesetsRedirectRule(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["redirect"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRedirectRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader(BaseModel): + operation: Literal["remove"] + + +class RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader(BaseModel): + operation: Literal["set"] + + value: str + """Static value for the header.""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader(BaseModel): + expression: str + """Expression for the header value.""" + + operation: Literal["set"] + + +RuleRulesetsRewriteRuleActionParametersHeaders = Union[ + RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader, + RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader, + RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader, +] + + +class RuleRulesetsRewriteRuleActionParametersURIPathStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIPath = Union[ + RuleRulesetsRewriteRuleActionParametersURIPathStaticValue, + RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIQuery = Union[ + RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue, + RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURI(BaseModel): + path: Optional[RuleRulesetsRewriteRuleActionParametersURIPath] = None + """Path portion rewrite.""" + + query: Optional[RuleRulesetsRewriteRuleActionParametersURIQuery] = None + """Query portion rewrite.""" + + +class RuleRulesetsRewriteRuleActionParameters(BaseModel): + headers: Optional[Dict[str, RuleRulesetsRewriteRuleActionParametersHeaders]] = None + """Map of request headers to modify.""" + + uri: Optional[RuleRulesetsRewriteRuleActionParametersURI] = None + """URI to rewrite the request to.""" + + +class RuleRulesetsRewriteRule(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["rewrite"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRewriteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRouteRuleActionParametersOrigin(BaseModel): + host: Optional[str] = None + """Override the resolved hostname.""" + + port: Optional[float] = None + """Override the destination port.""" + + +class RuleRulesetsRouteRuleActionParametersSni(BaseModel): + value: str + """The SNI override.""" + + +class RuleRulesetsRouteRuleActionParameters(BaseModel): + host_header: Optional[str] = None + """Rewrite the HTTP Host header.""" + + origin: Optional[RuleRulesetsRouteRuleActionParametersOrigin] = None + """Override the IP/TCP destination.""" + + sni: Optional[RuleRulesetsRouteRuleActionParametersSni] = None + """Override the Server Name Indication (SNI).""" + + +class RuleRulesetsRouteRule(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["route"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRouteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsScoreRuleActionParameters(BaseModel): + increment: Optional[int] = None + """ + Increment contains the delta to change the score and can be either positive or + negative. + """ + + +class RuleRulesetsScoreRule(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["score"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsScoreRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsServeErrorRuleActionParameters(BaseModel): + content: Optional[str] = None + """Error response content.""" + + content_type: Optional[Literal["application/json", "text/xml", "text/plain", "text/html"]] = None + """Content-type header to set with the response.""" + + status_code: Optional[float] = None + """The status code to use for the error.""" + + +class RuleRulesetsServeErrorRule(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["serve_error"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsServeErrorRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetConfigRuleActionParametersAutominify(BaseModel): + css: Optional[bool] = None + """Minify CSS files.""" + + html: Optional[bool] = None + """Minify HTML files.""" + + js: Optional[bool] = None + """Minify JS files.""" + + +class RuleRulesetsSetConfigRuleActionParameters(BaseModel): + automatic_https_rewrites: Optional[bool] = None + """Turn on or off Automatic HTTPS Rewrites.""" + + autominify: Optional[RuleRulesetsSetConfigRuleActionParametersAutominify] = None + """Select which file extensions to minify automatically.""" + + bic: Optional[bool] = None + """Turn on or off Browser Integrity Check.""" + + disable_apps: Optional[bool] = None + """Turn off all active Cloudflare Apps.""" + + disable_zaraz: Optional[bool] = None + """Turn off Zaraz.""" + + email_obfuscation: Optional[bool] = None + """Turn on or off Email Obfuscation.""" + + hotlink_protection: Optional[bool] = None + """Turn on or off the Hotlink Protection.""" + + mirage: Optional[bool] = None + """Turn on or off Mirage.""" + + opportunistic_encryption: Optional[bool] = None + """Turn on or off Opportunistic Encryption.""" + + polish: Optional[Literal["off", "lossless", "lossy"]] = None + """Configure the Polish level.""" + + rocket_loader: Optional[bool] = None + """Turn on or off Rocket Loader""" + + security_level: Optional[Literal["off", "essentially_off", "low", "medium", "high", "under_attack"]] = None + """Configure the Security Level.""" + + server_side_excludes: Optional[bool] = None + """Turn on or off Server Side Excludes.""" + + ssl: Optional[Literal["off", "flexible", "full", "strict", "origin_pull"]] = None + """Configure the SSL level.""" + + sxg: Optional[bool] = None + """Turn on or off Signed Exchanges (SXG).""" + + +class RuleRulesetsSetConfigRule(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["set_config"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetConfigRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL(BaseModel): + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """Determines which browser ttl mode to use.""" + + default: Optional[int] = None + """The TTL (in seconds) if you choose override_origin mode.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these cookie names. + + The presence of these cookies is used in building the cache key. + """ + + include: Optional[List[str]] = None + """Include these cookies' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these header names. + + The presence of these headers is used in building the cache key. + """ + + exclude_origin: Optional[bool] = None + """Whether or not to include the origin header. + + A value of true will exclude the origin header in the cache key. + """ + + include: Optional[List[str]] = None + """Include these headers' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(BaseModel): + resolved: Optional[bool] = None + """Use the resolved host in the cache key. + + A value of true will use the resolved host, while a value or false will use the + original host. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(BaseModel): + all: Optional[bool] = None + """Exclude all query string parameters from use in building the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters NOT used to build the cache key. + + All parameters present in the request but missing in this list will be used to + build the cache key. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(BaseModel): + all: Optional[bool] = None + """Use all query string parameters in the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters used to build the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(BaseModel): + exclude: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude] = None + """ + build the cache key using all query string parameters EXCECPT these excluded + parameters + """ + + include: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude] = None + """ + build the cache key using a list of query string parameters that ARE in the + request. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(BaseModel): + device_type: Optional[bool] = None + """Use the user agent's device type in the cache key.""" + + geo: Optional[bool] = None + """Use the user agents's country in the cache key.""" + + lang: Optional[bool] = None + """Use the user agent's language in the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey(BaseModel): + cookie: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie] = None + """The cookies to include in building the cache key.""" + + header: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader] = None + """The header names and values to include in building the cache key.""" + + host: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost] = None + """Whether to use the original host or the resolved host in the cache key.""" + + query_string: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString] = None + """ + Use the presence or absence of parameters in the query string to build the cache + key. + """ + + user: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser] = None + """Characteristics of the request user agent used in building the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey(BaseModel): + cache_by_device_type: Optional[bool] = None + """Separate cached content based on the visitor’s device type""" + + cache_deception_armor: Optional[bool] = None + """ + Protect from web cache deception attacks while allowing static assets to be + cached + """ + + custom_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey] = None + """ + Customize which components of the request are included or excluded from the + cache key. + """ + + ignore_query_strings_order: Optional[bool] = None + """ + Treat requests with the same query parameters the same, regardless of the order + those query parameters are in. A value of true ignores the query strings' order. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve(BaseModel): + eligible: bool + """Determines whether cache reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to cache reserve. + """ + + min_file_size: int + """The minimum file size eligible for store in cache reserve.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange(BaseModel): + from_: int = FieldInfo(alias="from") + """response status code lower bound""" + + to: int + """response status code upper bound""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(BaseModel): + value: int + """Time to cache a response (in seconds). + + A value of 0 is equivalent to setting the Cache-Control header with the value + "no-cache". A value of -1 is equivalent to setting Cache-Control header with the + value of "no-store". + """ + + status_code_range: Optional[ + RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + ] = None + """The range of status codes used to apply the selected mode.""" + + status_code_value: Optional[int] = None + """Set the ttl for responses with this specific status code""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL(BaseModel): + default: int + """The TTL (in seconds) if you choose override_origin mode.""" + + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """edge ttl options""" + + status_code_ttl: List[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL] + """List of single status codes, or status code ranges to apply the selected mode""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersServeStale(BaseModel): + disable_stale_while_updating: bool + """Defines whether Cloudflare should serve stale content while updating. + + If true, Cloudflare will not serve stale content while getting the latest + content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParameters(BaseModel): + additional_cacheable_ports: Optional[List[int]] = None + """List of additional ports that caching can be enabled on.""" + + browser_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL] = None + """Specify how long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: Optional[bool] = None + """Mark whether the request’s response from origin is eligible for caching. + + Caching itself will still depend on the cache-control header and your other + caching configurations. + """ + + cache_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey] = None + """ + Define which components of the request are included or excluded from the cache + key Cloudflare uses to store the response in cache. + """ + + cache_reserve: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve] = None + """ + Mark whether the request's response from origin is eligible for Cache Reserve + (requires a Cache Reserve add-on plan). + """ + + edge_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL] = None + """ + TTL (Time to Live) specifies the maximum time to cache a resource in the + Cloudflare edge network. + """ + + origin_cache_control: Optional[bool] = None + """When enabled, Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: Optional[bool] = None + """Generate Cloudflare error pages from issues sent from the origin server. + + When on, error pages will trigger for issues from the origin + """ + + read_timeout: Optional[int] = None + """ + Define a timeout value between two successive read operations to your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: Optional[bool] = None + """ + Specify whether or not Cloudflare should respect strong ETag (entity tag) + headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersServeStale] = None + """ + Define if Cloudflare should serve stale content while getting the latest content + from the origin. If on, Cloudflare will not serve stale content while getting + the latest content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRule(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["set_cache_settings"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheSettingsRuleActionParameters] = 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[Logging] = 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[BlockRule, ExecuteRule, LogRule, SkipRule] +Rule = Union[ + BlockRule, + RuleRulesetsChallengeRule, + RuleRulesetsCompressResponseRule, + ExecuteRule, + RuleRulesetsJsChallengeRule, + LogRule, + RuleRulesetsManagedChallengeRule, + RuleRulesetsRedirectRule, + RuleRulesetsRewriteRule, + RuleRulesetsRouteRule, + RuleRulesetsScoreRule, + RuleRulesetsServeErrorRule, + RuleRulesetsSetConfigRule, + SkipRule, + RuleRulesetsSetCacheSettingsRule, +] class VersionGetResponse(BaseModel): diff --git a/src/cloudflare/types/rulesets/rule_create_params.py b/src/cloudflare/types/rulesets/rule_create_params.py index 4aa8236f744..f6098adb173 100644 --- a/src/cloudflare/types/rulesets/rule_create_params.py +++ b/src/cloudflare/types/rulesets/rule_create_params.py @@ -12,15 +12,69 @@ "BlockRule", "BlockRuleActionParameters", "BlockRuleActionParametersResponse", + "RulesetsChallengeRule", + "RulesetsCompressResponseRule", + "RulesetsCompressResponseRuleActionParameters", + "RulesetsCompressResponseRuleActionParametersAlgorithm", "ExecuteRule", "ExecuteRuleActionParameters", "ExecuteRuleActionParametersMatchedData", "ExecuteRuleActionParametersOverrides", "ExecuteRuleActionParametersOverridesCategory", "ExecuteRuleActionParametersOverridesRule", + "RulesetsJsChallengeRule", "LogRule", + "RulesetsManagedChallengeRule", + "RulesetsRedirectRule", + "RulesetsRedirectRuleActionParameters", + "RulesetsRedirectRuleActionParametersFromList", + "RulesetsRedirectRuleActionParametersFromValue", + "RulesetsRedirectRuleActionParametersFromValueTargetURL", + "RulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect", + "RulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect", + "RulesetsRewriteRule", + "RulesetsRewriteRuleActionParameters", + "RulesetsRewriteRuleActionParametersHeaders", + "RulesetsRewriteRuleActionParametersHeadersRemoveHeader", + "RulesetsRewriteRuleActionParametersHeadersStaticHeader", + "RulesetsRewriteRuleActionParametersHeadersDynamicHeader", + "RulesetsRewriteRuleActionParametersURI", + "RulesetsRewriteRuleActionParametersURIPath", + "RulesetsRewriteRuleActionParametersURIPathStaticValue", + "RulesetsRewriteRuleActionParametersURIPathDynamicValue", + "RulesetsRewriteRuleActionParametersURIQuery", + "RulesetsRewriteRuleActionParametersURIQueryStaticValue", + "RulesetsRewriteRuleActionParametersURIQueryDynamicValue", + "RulesetsRouteRule", + "RulesetsRouteRuleActionParameters", + "RulesetsRouteRuleActionParametersOrigin", + "RulesetsRouteRuleActionParametersSni", + "RulesetsScoreRule", + "RulesetsScoreRuleActionParameters", + "RulesetsServeErrorRule", + "RulesetsServeErrorRuleActionParameters", + "RulesetsSetConfigRule", + "RulesetsSetConfigRuleActionParameters", + "RulesetsSetConfigRuleActionParametersAutominify", "SkipRule", "SkipRuleActionParameters", + "RulesetsSetCacheSettingsRule", + "RulesetsSetCacheSettingsRuleActionParameters", + "RulesetsSetCacheSettingsRuleActionParametersBrowserTTL", + "RulesetsSetCacheSettingsRuleActionParametersCacheKey", + "RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "RulesetsSetCacheSettingsRuleActionParametersCacheReserve", + "RulesetsSetCacheSettingsRuleActionParametersEdgeTTL", + "RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "RulesetsSetCacheSettingsRuleActionParametersServeStale", ] @@ -72,6 +126,80 @@ class BlockRuleActionParameters(TypedDict, total=False): """The response to show when the block is applied.""" +class RulesetsChallengeRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["challenge"] + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsCompressResponseRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["compress_response"] + """The action to perform when the rule matches.""" + + action_parameters: RulesetsCompressResponseRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsCompressResponseRuleActionParametersAlgorithm(TypedDict, total=False): + name: Literal["none", "auto", "default", "gzip", "brotli"] + """Name of compression algorithm to enable.""" + + +class RulesetsCompressResponseRuleActionParameters(TypedDict, total=False): + algorithms: Iterable[RulesetsCompressResponseRuleActionParametersAlgorithm] + """Custom order for compression algorithms.""" + + class ExecuteRule(TypedDict, total=False): account_id: str """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" @@ -181,6 +309,38 @@ class ExecuteRuleActionParameters(TypedDict, total=False): """A set of overrides to apply to the target ruleset.""" +class RulesetsJsChallengeRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["js_challenge"] + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + class LogRule(TypedDict, total=False): account_id: str """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" @@ -213,7 +373,7 @@ class LogRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class SkipRule(TypedDict, total=False): +class RulesetsManagedChallengeRule(TypedDict, total=False): account_id: str """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" @@ -223,10 +383,10 @@ class SkipRule(TypedDict, total=False): id: str """The unique ID of the rule.""" - action: Literal["skip"] + action: Literal["managed_challenge"] """The action to perform when the rule matches.""" - action_parameters: SkipRuleActionParameters + action_parameters: object """The parameters configuring the rule's action.""" description: str @@ -245,59 +405,811 @@ class SkipRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class SkipRuleActionParameters(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. +class RulesetsRedirectRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - This option is incompatible with the ruleset and rulesets options. - """ + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - products: List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] - """A list of legacy security products to skip the execution of.""" + id: str + """The unique ID of the rule.""" - 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. - """ + action: Literal["redirect"] + """The action to perform when the rule matches.""" - ruleset: Literal["current"] - """A ruleset to skip the execution of. + action_parameters: RulesetsRedirectRuleActionParameters + """The parameters configuring the rule's action.""" - This option is incompatible with the rulesets, rules and phases options. - """ + description: str + """An informative description of the rule.""" - rulesets: List[str] - """A list of ruleset IDs to skip the execution of. + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsRedirectRuleActionParametersFromList(TypedDict, total=False): + key: str + """Expression that evaluates to the list lookup key.""" + + name: str + """The name of the list to match against.""" + + +class RulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect(TypedDict, total=False): + value: str + """The URL to redirect the request to.""" + + +class RulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect(TypedDict, total=False): + expression: str + """An expression to evaluate to get the URL to redirect the request to.""" + + +RulesetsRedirectRuleActionParametersFromValueTargetURL = Union[ + RulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect, + RulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect, +] + + +class RulesetsRedirectRuleActionParametersFromValue(TypedDict, total=False): + preserve_query_string: bool + """Keep the query string of the original request.""" + + status_code: Literal[301, 302, 303, 307, 308] + """The status code to be used for the redirect.""" + + target_url: RulesetsRedirectRuleActionParametersFromValueTargetURL + """The URL to redirect the request to.""" + + +class RulesetsRedirectRuleActionParameters(TypedDict, total=False): + from_list: RulesetsRedirectRuleActionParametersFromList + """Serve a redirect based on a bulk list lookup.""" + + from_value: RulesetsRedirectRuleActionParametersFromValue + """Serve a redirect based on the request properties.""" + + +class RulesetsRewriteRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["rewrite"] + """The action to perform when the rule matches.""" + + action_parameters: RulesetsRewriteRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsRewriteRuleActionParametersHeadersRemoveHeader(TypedDict, total=False): + operation: Required[Literal["remove"]] + + +class RulesetsRewriteRuleActionParametersHeadersStaticHeader(TypedDict, total=False): + operation: Required[Literal["set"]] + + value: Required[str] + """Static value for the header.""" + + +class RulesetsRewriteRuleActionParametersHeadersDynamicHeader(TypedDict, total=False): + expression: Required[str] + """Expression for the header value.""" + + operation: Required[Literal["set"]] + + +RulesetsRewriteRuleActionParametersHeaders = Union[ + RulesetsRewriteRuleActionParametersHeadersRemoveHeader, + RulesetsRewriteRuleActionParametersHeadersStaticHeader, + RulesetsRewriteRuleActionParametersHeadersDynamicHeader, +] + + +class RulesetsRewriteRuleActionParametersURIPathStaticValue(TypedDict, total=False): + value: Required[str] + """Predefined replacement value.""" - This option is incompatible with the ruleset and phases options. - """ +class RulesetsRewriteRuleActionParametersURIPathDynamicValue(TypedDict, total=False): + expression: Required[str] + """Expression to evaluate for the replacement value.""" -RuleCreateParams = Union[BlockRule, ExecuteRule, LogRule, SkipRule] + +RulesetsRewriteRuleActionParametersURIPath = Union[ + RulesetsRewriteRuleActionParametersURIPathStaticValue, RulesetsRewriteRuleActionParametersURIPathDynamicValue +] + + +class RulesetsRewriteRuleActionParametersURIQueryStaticValue(TypedDict, total=False): + value: Required[str] + """Predefined replacement value.""" + + +class RulesetsRewriteRuleActionParametersURIQueryDynamicValue(TypedDict, total=False): + expression: Required[str] + """Expression to evaluate for the replacement value.""" + + +RulesetsRewriteRuleActionParametersURIQuery = Union[ + RulesetsRewriteRuleActionParametersURIQueryStaticValue, RulesetsRewriteRuleActionParametersURIQueryDynamicValue +] + + +class RulesetsRewriteRuleActionParametersURI(TypedDict, total=False): + path: RulesetsRewriteRuleActionParametersURIPath + """Path portion rewrite.""" + + query: RulesetsRewriteRuleActionParametersURIQuery + """Query portion rewrite.""" + + +class RulesetsRewriteRuleActionParameters(TypedDict, total=False): + headers: Dict[str, RulesetsRewriteRuleActionParametersHeaders] + """Map of request headers to modify.""" + + uri: RulesetsRewriteRuleActionParametersURI + """URI to rewrite the request to.""" + + +class RulesetsRouteRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["route"] + """The action to perform when the rule matches.""" + + action_parameters: RulesetsRouteRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsRouteRuleActionParametersOrigin(TypedDict, total=False): + host: str + """Override the resolved hostname.""" + + port: float + """Override the destination port.""" + + +class RulesetsRouteRuleActionParametersSni(TypedDict, total=False): + value: Required[str] + """The SNI override.""" + + +class RulesetsRouteRuleActionParameters(TypedDict, total=False): + host_header: str + """Rewrite the HTTP Host header.""" + + origin: RulesetsRouteRuleActionParametersOrigin + """Override the IP/TCP destination.""" + + sni: RulesetsRouteRuleActionParametersSni + """Override the Server Name Indication (SNI).""" + + +class RulesetsScoreRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["score"] + """The action to perform when the rule matches.""" + + action_parameters: RulesetsScoreRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsScoreRuleActionParameters(TypedDict, total=False): + increment: int + """ + Increment contains the delta to change the score and can be either positive or + negative. + """ + + +class RulesetsServeErrorRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["serve_error"] + """The action to perform when the rule matches.""" + + action_parameters: RulesetsServeErrorRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsServeErrorRuleActionParameters(TypedDict, total=False): + content: str + """Error response content.""" + + content_type: Literal["application/json", "text/xml", "text/plain", "text/html"] + """Content-type header to set with the response.""" + + status_code: float + """The status code to use for the error.""" + + +class RulesetsSetConfigRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["set_config"] + """The action to perform when the rule matches.""" + + action_parameters: RulesetsSetConfigRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsSetConfigRuleActionParametersAutominify(TypedDict, total=False): + css: bool + """Minify CSS files.""" + + html: bool + """Minify HTML files.""" + + js: bool + """Minify JS files.""" + + +class RulesetsSetConfigRuleActionParameters(TypedDict, total=False): + automatic_https_rewrites: bool + """Turn on or off Automatic HTTPS Rewrites.""" + + autominify: RulesetsSetConfigRuleActionParametersAutominify + """Select which file extensions to minify automatically.""" + + bic: bool + """Turn on or off Browser Integrity Check.""" + + disable_apps: bool + """Turn off all active Cloudflare Apps.""" + + disable_zaraz: bool + """Turn off Zaraz.""" + + email_obfuscation: bool + """Turn on or off Email Obfuscation.""" + + hotlink_protection: bool + """Turn on or off the Hotlink Protection.""" + + mirage: bool + """Turn on or off Mirage.""" + + opportunistic_encryption: bool + """Turn on or off Opportunistic Encryption.""" + + polish: Literal["off", "lossless", "lossy"] + """Configure the Polish level.""" + + rocket_loader: bool + """Turn on or off Rocket Loader""" + + security_level: Literal["off", "essentially_off", "low", "medium", "high", "under_attack"] + """Configure the Security Level.""" + + server_side_excludes: bool + """Turn on or off Server Side Excludes.""" + + ssl: Literal["off", "flexible", "full", "strict", "origin_pull"] + """Configure the SSL level.""" + + sxg: bool + """Turn on or off Signed Exchanges (SXG).""" + + +class SkipRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["skip"] + """The action to perform when the rule matches.""" + + action_parameters: SkipRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class SkipRuleActionParameters(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 RulesetsSetCacheSettingsRule(TypedDict, total=False): + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_settings"] + """The action to perform when the rule matches.""" + + action_parameters: RulesetsSetCacheSettingsRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsSetCacheSettingsRuleActionParametersBrowserTTL(TypedDict, total=False): + mode: Required[Literal["respect_origin", "bypass_by_default", "override_origin"]] + """Determines which browser ttl mode to use.""" + + default: int + """The TTL (in seconds) if you choose override_origin mode.""" + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(TypedDict, total=False): + check_presence: List[str] + """Checks for the presence of these cookie names. + + The presence of these cookies is used in building the cache key. + """ + + include: List[str] + """Include these cookies' names and their values.""" + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(TypedDict, total=False): + check_presence: List[str] + """Checks for the presence of these header names. + + The presence of these headers is used in building the cache key. + """ + + exclude_origin: bool + """Whether or not to include the origin header. + + A value of true will exclude the origin header in the cache key. + """ + + include: List[str] + """Include these headers' names and their values.""" + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(TypedDict, total=False): + resolved: bool + """Use the resolved host in the cache key. + + A value of true will use the resolved host, while a value or false will use the + original host. + """ + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(TypedDict, total=False): + all: bool + """Exclude all query string parameters from use in building the cache key.""" + + list: List[str] + """A list of query string parameters NOT used to build the cache key. + + All parameters present in the request but missing in this list will be used to + build the cache key. + """ + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(TypedDict, total=False): + all: bool + """Use all query string parameters in the cache key.""" + + list: List[str] + """A list of query string parameters used to build the cache key.""" + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(TypedDict, total=False): + exclude: RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude + """ + build the cache key using all query string parameters EXCECPT these excluded + parameters + """ + + include: RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude + """ + build the cache key using a list of query string parameters that ARE in the + request. + """ + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(TypedDict, total=False): + device_type: bool + """Use the user agent's device type in the cache key.""" + + geo: bool + """Use the user agents's country in the cache key.""" + + lang: bool + """Use the user agent's language in the cache key.""" + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey(TypedDict, total=False): + cookie: RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie + """The cookies to include in building the cache key.""" + + header: RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader + """The header names and values to include in building the cache key.""" + + host: RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost + """Whether to use the original host or the resolved host in the cache key.""" + + query_string: RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString + """ + Use the presence or absence of parameters in the query string to build the cache + key. + """ + + user: RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser + """Characteristics of the request user agent used in building the cache key.""" + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKey(TypedDict, total=False): + cache_by_device_type: bool + """Separate cached content based on the visitor’s device type""" + + cache_deception_armor: bool + """ + Protect from web cache deception attacks while allowing static assets to be + cached + """ + + custom_key: RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey + """ + Customize which components of the request are included or excluded from the + cache key. + """ + + ignore_query_strings_order: bool + """ + Treat requests with the same query parameters the same, regardless of the order + those query parameters are in. A value of true ignores the query strings' order. + """ + + +class RulesetsSetCacheSettingsRuleActionParametersCacheReserve(TypedDict, total=False): + eligible: Required[bool] + """Determines whether cache reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to cache reserve. + """ + + min_file_size: Required[int] + """The minimum file size eligible for store in cache reserve.""" + + +_RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords = TypedDict( + "_RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords", + { + "from": int, + }, + total=False, +) + + +class RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange( + _RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords, total=False +): + to: Required[int] + """response status code upper bound""" + + +class RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(TypedDict, total=False): + value: Required[int] + """Time to cache a response (in seconds). + + A value of 0 is equivalent to setting the Cache-Control header with the value + "no-cache". A value of -1 is equivalent to setting Cache-Control header with the + value of "no-store". + """ + + status_code_range: RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + """The range of status codes used to apply the selected mode.""" + + status_code_value: int + """Set the ttl for responses with this specific status code""" + + +class RulesetsSetCacheSettingsRuleActionParametersEdgeTTL(TypedDict, total=False): + default: Required[int] + """The TTL (in seconds) if you choose override_origin mode.""" + + mode: Required[Literal["respect_origin", "bypass_by_default", "override_origin"]] + """edge ttl options""" + + status_code_ttl: Required[Iterable[RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL]] + """List of single status codes, or status code ranges to apply the selected mode""" + + +class RulesetsSetCacheSettingsRuleActionParametersServeStale(TypedDict, total=False): + disable_stale_while_updating: Required[bool] + """Defines whether Cloudflare should serve stale content while updating. + + If true, Cloudflare will not serve stale content while getting the latest + content from the origin. + """ + + +class RulesetsSetCacheSettingsRuleActionParameters(TypedDict, total=False): + additional_cacheable_ports: Iterable[int] + """List of additional ports that caching can be enabled on.""" + + browser_ttl: RulesetsSetCacheSettingsRuleActionParametersBrowserTTL + """Specify how long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: bool + """Mark whether the request’s response from origin is eligible for caching. + + Caching itself will still depend on the cache-control header and your other + caching configurations. + """ + + cache_key: RulesetsSetCacheSettingsRuleActionParametersCacheKey + """ + Define which components of the request are included or excluded from the cache + key Cloudflare uses to store the response in cache. + """ + + cache_reserve: RulesetsSetCacheSettingsRuleActionParametersCacheReserve + """ + Mark whether the request's response from origin is eligible for Cache Reserve + (requires a Cache Reserve add-on plan). + """ + + edge_ttl: RulesetsSetCacheSettingsRuleActionParametersEdgeTTL + """ + TTL (Time to Live) specifies the maximum time to cache a resource in the + Cloudflare edge network. + """ + + origin_cache_control: bool + """When enabled, Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: bool + """Generate Cloudflare error pages from issues sent from the origin server. + + When on, error pages will trigger for issues from the origin + """ + + read_timeout: int + """ + Define a timeout value between two successive read operations to your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: bool + """ + Specify whether or not Cloudflare should respect strong ETag (entity tag) + headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: RulesetsSetCacheSettingsRuleActionParametersServeStale + """ + Define if Cloudflare should serve stale content while getting the latest content + from the origin. If on, Cloudflare will not serve stale content while getting + the latest content from the origin. + """ + + +RuleCreateParams = Union[ + BlockRule, + RulesetsChallengeRule, + RulesetsCompressResponseRule, + ExecuteRule, + RulesetsJsChallengeRule, + LogRule, + RulesetsManagedChallengeRule, + RulesetsRedirectRule, + RulesetsRewriteRule, + RulesetsRouteRule, + RulesetsScoreRule, + RulesetsServeErrorRule, + RulesetsSetConfigRule, + SkipRule, + RulesetsSetCacheSettingsRule, +] diff --git a/src/cloudflare/types/rulesets/rule_create_response.py b/src/cloudflare/types/rulesets/rule_create_response.py index 3d96e28a3ea..76b96406f5d 100644 --- a/src/cloudflare/types/rulesets/rule_create_response.py +++ b/src/cloudflare/types/rulesets/rule_create_response.py @@ -1,18 +1,966 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from pydantic import Field as FieldInfo + +from .logging import Logging from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule from .block_rule import BlockRule from .execute_rule import ExecuteRule -__all__ = ["RuleCreateResponse", "Rule"] +__all__ = [ + "RuleCreateResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsCompressResponseRule", + "RuleRulesetsCompressResponseRuleActionParameters", + "RuleRulesetsCompressResponseRuleActionParametersAlgorithm", + "RuleRulesetsJsChallengeRule", + "RuleRulesetsManagedChallengeRule", + "RuleRulesetsRedirectRule", + "RuleRulesetsRedirectRuleActionParameters", + "RuleRulesetsRedirectRuleActionParametersFromList", + "RuleRulesetsRedirectRuleActionParametersFromValue", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURL", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect", + "RuleRulesetsRewriteRule", + "RuleRulesetsRewriteRuleActionParameters", + "RuleRulesetsRewriteRuleActionParametersHeaders", + "RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader", + "RuleRulesetsRewriteRuleActionParametersURI", + "RuleRulesetsRewriteRuleActionParametersURIPath", + "RuleRulesetsRewriteRuleActionParametersURIPathStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue", + "RuleRulesetsRewriteRuleActionParametersURIQuery", + "RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue", + "RuleRulesetsRouteRule", + "RuleRulesetsRouteRuleActionParameters", + "RuleRulesetsRouteRuleActionParametersOrigin", + "RuleRulesetsRouteRuleActionParametersSni", + "RuleRulesetsScoreRule", + "RuleRulesetsScoreRuleActionParameters", + "RuleRulesetsServeErrorRule", + "RuleRulesetsServeErrorRuleActionParameters", + "RuleRulesetsSetConfigRule", + "RuleRulesetsSetConfigRuleActionParameters", + "RuleRulesetsSetConfigRuleActionParametersAutominify", + "RuleRulesetsSetCacheSettingsRule", + "RuleRulesetsSetCacheSettingsRuleActionParameters", + "RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "RuleRulesetsSetCacheSettingsRuleActionParametersServeStale", +] + + +class RuleRulesetsChallengeRule(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["challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsCompressResponseRuleActionParametersAlgorithm(BaseModel): + name: Optional[Literal["none", "auto", "default", "gzip", "brotli"]] = None + """Name of compression algorithm to enable.""" + + +class RuleRulesetsCompressResponseRuleActionParameters(BaseModel): + algorithms: Optional[List[RuleRulesetsCompressResponseRuleActionParametersAlgorithm]] = None + """Custom order for compression algorithms.""" + + +class RuleRulesetsCompressResponseRule(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["compress_response"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsCompressResponseRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsJsChallengeRule(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["js_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsManagedChallengeRule(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["managed_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRedirectRuleActionParametersFromList(BaseModel): + key: Optional[str] = None + """Expression that evaluates to the list lookup key.""" + + name: Optional[str] = None + """The name of the list to match against.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect(BaseModel): + value: Optional[str] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect(BaseModel): + expression: Optional[str] = None + """An expression to evaluate to get the URL to redirect the request to.""" + + +RuleRulesetsRedirectRuleActionParametersFromValueTargetURL = Union[ + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect, + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect, +] + + +class RuleRulesetsRedirectRuleActionParametersFromValue(BaseModel): + preserve_query_string: Optional[bool] = None + """Keep the query string of the original request.""" + + status_code: Optional[Literal[301, 302, 303, 307, 308]] = None + """The status code to be used for the redirect.""" + + target_url: Optional[RuleRulesetsRedirectRuleActionParametersFromValueTargetURL] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParameters(BaseModel): + from_list: Optional[RuleRulesetsRedirectRuleActionParametersFromList] = None + """Serve a redirect based on a bulk list lookup.""" + + from_value: Optional[RuleRulesetsRedirectRuleActionParametersFromValue] = None + """Serve a redirect based on the request properties.""" + + +class RuleRulesetsRedirectRule(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["redirect"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRedirectRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader(BaseModel): + operation: Literal["remove"] + + +class RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader(BaseModel): + operation: Literal["set"] + + value: str + """Static value for the header.""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader(BaseModel): + expression: str + """Expression for the header value.""" + + operation: Literal["set"] + + +RuleRulesetsRewriteRuleActionParametersHeaders = Union[ + RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader, + RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader, + RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader, +] + + +class RuleRulesetsRewriteRuleActionParametersURIPathStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIPath = Union[ + RuleRulesetsRewriteRuleActionParametersURIPathStaticValue, + RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIQuery = Union[ + RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue, + RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURI(BaseModel): + path: Optional[RuleRulesetsRewriteRuleActionParametersURIPath] = None + """Path portion rewrite.""" + + query: Optional[RuleRulesetsRewriteRuleActionParametersURIQuery] = None + """Query portion rewrite.""" + + +class RuleRulesetsRewriteRuleActionParameters(BaseModel): + headers: Optional[Dict[str, RuleRulesetsRewriteRuleActionParametersHeaders]] = None + """Map of request headers to modify.""" + + uri: Optional[RuleRulesetsRewriteRuleActionParametersURI] = None + """URI to rewrite the request to.""" + + +class RuleRulesetsRewriteRule(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["rewrite"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRewriteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRouteRuleActionParametersOrigin(BaseModel): + host: Optional[str] = None + """Override the resolved hostname.""" + + port: Optional[float] = None + """Override the destination port.""" + + +class RuleRulesetsRouteRuleActionParametersSni(BaseModel): + value: str + """The SNI override.""" + + +class RuleRulesetsRouteRuleActionParameters(BaseModel): + host_header: Optional[str] = None + """Rewrite the HTTP Host header.""" + + origin: Optional[RuleRulesetsRouteRuleActionParametersOrigin] = None + """Override the IP/TCP destination.""" + + sni: Optional[RuleRulesetsRouteRuleActionParametersSni] = None + """Override the Server Name Indication (SNI).""" + + +class RuleRulesetsRouteRule(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["route"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRouteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsScoreRuleActionParameters(BaseModel): + increment: Optional[int] = None + """ + Increment contains the delta to change the score and can be either positive or + negative. + """ + + +class RuleRulesetsScoreRule(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["score"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsScoreRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsServeErrorRuleActionParameters(BaseModel): + content: Optional[str] = None + """Error response content.""" + + content_type: Optional[Literal["application/json", "text/xml", "text/plain", "text/html"]] = None + """Content-type header to set with the response.""" + + status_code: Optional[float] = None + """The status code to use for the error.""" + + +class RuleRulesetsServeErrorRule(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["serve_error"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsServeErrorRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetConfigRuleActionParametersAutominify(BaseModel): + css: Optional[bool] = None + """Minify CSS files.""" + + html: Optional[bool] = None + """Minify HTML files.""" + + js: Optional[bool] = None + """Minify JS files.""" + + +class RuleRulesetsSetConfigRuleActionParameters(BaseModel): + automatic_https_rewrites: Optional[bool] = None + """Turn on or off Automatic HTTPS Rewrites.""" + + autominify: Optional[RuleRulesetsSetConfigRuleActionParametersAutominify] = None + """Select which file extensions to minify automatically.""" + + bic: Optional[bool] = None + """Turn on or off Browser Integrity Check.""" + + disable_apps: Optional[bool] = None + """Turn off all active Cloudflare Apps.""" + + disable_zaraz: Optional[bool] = None + """Turn off Zaraz.""" + + email_obfuscation: Optional[bool] = None + """Turn on or off Email Obfuscation.""" + + hotlink_protection: Optional[bool] = None + """Turn on or off the Hotlink Protection.""" + + mirage: Optional[bool] = None + """Turn on or off Mirage.""" + + opportunistic_encryption: Optional[bool] = None + """Turn on or off Opportunistic Encryption.""" + + polish: Optional[Literal["off", "lossless", "lossy"]] = None + """Configure the Polish level.""" + + rocket_loader: Optional[bool] = None + """Turn on or off Rocket Loader""" + + security_level: Optional[Literal["off", "essentially_off", "low", "medium", "high", "under_attack"]] = None + """Configure the Security Level.""" + + server_side_excludes: Optional[bool] = None + """Turn on or off Server Side Excludes.""" + + ssl: Optional[Literal["off", "flexible", "full", "strict", "origin_pull"]] = None + """Configure the SSL level.""" + + sxg: Optional[bool] = None + """Turn on or off Signed Exchanges (SXG).""" + + +class RuleRulesetsSetConfigRule(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["set_config"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetConfigRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL(BaseModel): + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """Determines which browser ttl mode to use.""" + + default: Optional[int] = None + """The TTL (in seconds) if you choose override_origin mode.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these cookie names. + + The presence of these cookies is used in building the cache key. + """ + + include: Optional[List[str]] = None + """Include these cookies' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these header names. + + The presence of these headers is used in building the cache key. + """ + + exclude_origin: Optional[bool] = None + """Whether or not to include the origin header. + + A value of true will exclude the origin header in the cache key. + """ + + include: Optional[List[str]] = None + """Include these headers' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(BaseModel): + resolved: Optional[bool] = None + """Use the resolved host in the cache key. + + A value of true will use the resolved host, while a value or false will use the + original host. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(BaseModel): + all: Optional[bool] = None + """Exclude all query string parameters from use in building the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters NOT used to build the cache key. + + All parameters present in the request but missing in this list will be used to + build the cache key. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(BaseModel): + all: Optional[bool] = None + """Use all query string parameters in the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters used to build the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(BaseModel): + exclude: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude] = None + """ + build the cache key using all query string parameters EXCECPT these excluded + parameters + """ + + include: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude] = None + """ + build the cache key using a list of query string parameters that ARE in the + request. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(BaseModel): + device_type: Optional[bool] = None + """Use the user agent's device type in the cache key.""" + + geo: Optional[bool] = None + """Use the user agents's country in the cache key.""" + + lang: Optional[bool] = None + """Use the user agent's language in the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey(BaseModel): + cookie: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie] = None + """The cookies to include in building the cache key.""" + + header: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader] = None + """The header names and values to include in building the cache key.""" + + host: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost] = None + """Whether to use the original host or the resolved host in the cache key.""" + + query_string: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString] = None + """ + Use the presence or absence of parameters in the query string to build the cache + key. + """ + + user: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser] = None + """Characteristics of the request user agent used in building the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey(BaseModel): + cache_by_device_type: Optional[bool] = None + """Separate cached content based on the visitor’s device type""" + + cache_deception_armor: Optional[bool] = None + """ + Protect from web cache deception attacks while allowing static assets to be + cached + """ + + custom_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey] = None + """ + Customize which components of the request are included or excluded from the + cache key. + """ + + ignore_query_strings_order: Optional[bool] = None + """ + Treat requests with the same query parameters the same, regardless of the order + those query parameters are in. A value of true ignores the query strings' order. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve(BaseModel): + eligible: bool + """Determines whether cache reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to cache reserve. + """ + + min_file_size: int + """The minimum file size eligible for store in cache reserve.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange(BaseModel): + from_: int = FieldInfo(alias="from") + """response status code lower bound""" + + to: int + """response status code upper bound""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(BaseModel): + value: int + """Time to cache a response (in seconds). + + A value of 0 is equivalent to setting the Cache-Control header with the value + "no-cache". A value of -1 is equivalent to setting Cache-Control header with the + value of "no-store". + """ + + status_code_range: Optional[ + RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + ] = None + """The range of status codes used to apply the selected mode.""" + + status_code_value: Optional[int] = None + """Set the ttl for responses with this specific status code""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL(BaseModel): + default: int + """The TTL (in seconds) if you choose override_origin mode.""" + + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """edge ttl options""" + + status_code_ttl: List[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL] + """List of single status codes, or status code ranges to apply the selected mode""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersServeStale(BaseModel): + disable_stale_while_updating: bool + """Defines whether Cloudflare should serve stale content while updating. + + If true, Cloudflare will not serve stale content while getting the latest + content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParameters(BaseModel): + additional_cacheable_ports: Optional[List[int]] = None + """List of additional ports that caching can be enabled on.""" + + browser_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL] = None + """Specify how long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: Optional[bool] = None + """Mark whether the request’s response from origin is eligible for caching. + + Caching itself will still depend on the cache-control header and your other + caching configurations. + """ + + cache_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey] = None + """ + Define which components of the request are included or excluded from the cache + key Cloudflare uses to store the response in cache. + """ + + cache_reserve: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve] = None + """ + Mark whether the request's response from origin is eligible for Cache Reserve + (requires a Cache Reserve add-on plan). + """ + + edge_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL] = None + """ + TTL (Time to Live) specifies the maximum time to cache a resource in the + Cloudflare edge network. + """ + + origin_cache_control: Optional[bool] = None + """When enabled, Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: Optional[bool] = None + """Generate Cloudflare error pages from issues sent from the origin server. + + When on, error pages will trigger for issues from the origin + """ + + read_timeout: Optional[int] = None + """ + Define a timeout value between two successive read operations to your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: Optional[bool] = None + """ + Specify whether or not Cloudflare should respect strong ETag (entity tag) + headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersServeStale] = None + """ + Define if Cloudflare should serve stale content while getting the latest content + from the origin. If on, Cloudflare will not serve stale content while getting + the latest content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRule(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["set_cache_settings"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheSettingsRuleActionParameters] = 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[Logging] = 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[BlockRule, ExecuteRule, LogRule, SkipRule] +Rule = Union[ + BlockRule, + RuleRulesetsChallengeRule, + RuleRulesetsCompressResponseRule, + ExecuteRule, + RuleRulesetsJsChallengeRule, + LogRule, + RuleRulesetsManagedChallengeRule, + RuleRulesetsRedirectRule, + RuleRulesetsRewriteRule, + RuleRulesetsRouteRule, + RuleRulesetsScoreRule, + RuleRulesetsServeErrorRule, + RuleRulesetsSetConfigRule, + SkipRule, + RuleRulesetsSetCacheSettingsRule, +] class RuleCreateResponse(BaseModel): diff --git a/src/cloudflare/types/rulesets/rule_delete_response.py b/src/cloudflare/types/rulesets/rule_delete_response.py index 9533a139323..c475e49a89a 100644 --- a/src/cloudflare/types/rulesets/rule_delete_response.py +++ b/src/cloudflare/types/rulesets/rule_delete_response.py @@ -1,18 +1,966 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from pydantic import Field as FieldInfo + +from .logging import Logging from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule from .block_rule import BlockRule from .execute_rule import ExecuteRule -__all__ = ["RuleDeleteResponse", "Rule"] +__all__ = [ + "RuleDeleteResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsCompressResponseRule", + "RuleRulesetsCompressResponseRuleActionParameters", + "RuleRulesetsCompressResponseRuleActionParametersAlgorithm", + "RuleRulesetsJsChallengeRule", + "RuleRulesetsManagedChallengeRule", + "RuleRulesetsRedirectRule", + "RuleRulesetsRedirectRuleActionParameters", + "RuleRulesetsRedirectRuleActionParametersFromList", + "RuleRulesetsRedirectRuleActionParametersFromValue", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURL", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect", + "RuleRulesetsRewriteRule", + "RuleRulesetsRewriteRuleActionParameters", + "RuleRulesetsRewriteRuleActionParametersHeaders", + "RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader", + "RuleRulesetsRewriteRuleActionParametersURI", + "RuleRulesetsRewriteRuleActionParametersURIPath", + "RuleRulesetsRewriteRuleActionParametersURIPathStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue", + "RuleRulesetsRewriteRuleActionParametersURIQuery", + "RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue", + "RuleRulesetsRouteRule", + "RuleRulesetsRouteRuleActionParameters", + "RuleRulesetsRouteRuleActionParametersOrigin", + "RuleRulesetsRouteRuleActionParametersSni", + "RuleRulesetsScoreRule", + "RuleRulesetsScoreRuleActionParameters", + "RuleRulesetsServeErrorRule", + "RuleRulesetsServeErrorRuleActionParameters", + "RuleRulesetsSetConfigRule", + "RuleRulesetsSetConfigRuleActionParameters", + "RuleRulesetsSetConfigRuleActionParametersAutominify", + "RuleRulesetsSetCacheSettingsRule", + "RuleRulesetsSetCacheSettingsRuleActionParameters", + "RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "RuleRulesetsSetCacheSettingsRuleActionParametersServeStale", +] + + +class RuleRulesetsChallengeRule(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["challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsCompressResponseRuleActionParametersAlgorithm(BaseModel): + name: Optional[Literal["none", "auto", "default", "gzip", "brotli"]] = None + """Name of compression algorithm to enable.""" + + +class RuleRulesetsCompressResponseRuleActionParameters(BaseModel): + algorithms: Optional[List[RuleRulesetsCompressResponseRuleActionParametersAlgorithm]] = None + """Custom order for compression algorithms.""" + + +class RuleRulesetsCompressResponseRule(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["compress_response"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsCompressResponseRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsJsChallengeRule(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["js_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsManagedChallengeRule(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["managed_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRedirectRuleActionParametersFromList(BaseModel): + key: Optional[str] = None + """Expression that evaluates to the list lookup key.""" + + name: Optional[str] = None + """The name of the list to match against.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect(BaseModel): + value: Optional[str] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect(BaseModel): + expression: Optional[str] = None + """An expression to evaluate to get the URL to redirect the request to.""" + + +RuleRulesetsRedirectRuleActionParametersFromValueTargetURL = Union[ + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect, + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect, +] + + +class RuleRulesetsRedirectRuleActionParametersFromValue(BaseModel): + preserve_query_string: Optional[bool] = None + """Keep the query string of the original request.""" + + status_code: Optional[Literal[301, 302, 303, 307, 308]] = None + """The status code to be used for the redirect.""" + + target_url: Optional[RuleRulesetsRedirectRuleActionParametersFromValueTargetURL] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParameters(BaseModel): + from_list: Optional[RuleRulesetsRedirectRuleActionParametersFromList] = None + """Serve a redirect based on a bulk list lookup.""" + + from_value: Optional[RuleRulesetsRedirectRuleActionParametersFromValue] = None + """Serve a redirect based on the request properties.""" + + +class RuleRulesetsRedirectRule(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["redirect"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRedirectRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader(BaseModel): + operation: Literal["remove"] + + +class RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader(BaseModel): + operation: Literal["set"] + + value: str + """Static value for the header.""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader(BaseModel): + expression: str + """Expression for the header value.""" + + operation: Literal["set"] + + +RuleRulesetsRewriteRuleActionParametersHeaders = Union[ + RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader, + RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader, + RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader, +] + + +class RuleRulesetsRewriteRuleActionParametersURIPathStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIPath = Union[ + RuleRulesetsRewriteRuleActionParametersURIPathStaticValue, + RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIQuery = Union[ + RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue, + RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURI(BaseModel): + path: Optional[RuleRulesetsRewriteRuleActionParametersURIPath] = None + """Path portion rewrite.""" + + query: Optional[RuleRulesetsRewriteRuleActionParametersURIQuery] = None + """Query portion rewrite.""" + + +class RuleRulesetsRewriteRuleActionParameters(BaseModel): + headers: Optional[Dict[str, RuleRulesetsRewriteRuleActionParametersHeaders]] = None + """Map of request headers to modify.""" + + uri: Optional[RuleRulesetsRewriteRuleActionParametersURI] = None + """URI to rewrite the request to.""" + + +class RuleRulesetsRewriteRule(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["rewrite"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRewriteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRouteRuleActionParametersOrigin(BaseModel): + host: Optional[str] = None + """Override the resolved hostname.""" + + port: Optional[float] = None + """Override the destination port.""" + + +class RuleRulesetsRouteRuleActionParametersSni(BaseModel): + value: str + """The SNI override.""" + + +class RuleRulesetsRouteRuleActionParameters(BaseModel): + host_header: Optional[str] = None + """Rewrite the HTTP Host header.""" + + origin: Optional[RuleRulesetsRouteRuleActionParametersOrigin] = None + """Override the IP/TCP destination.""" + + sni: Optional[RuleRulesetsRouteRuleActionParametersSni] = None + """Override the Server Name Indication (SNI).""" + + +class RuleRulesetsRouteRule(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["route"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRouteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsScoreRuleActionParameters(BaseModel): + increment: Optional[int] = None + """ + Increment contains the delta to change the score and can be either positive or + negative. + """ + + +class RuleRulesetsScoreRule(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["score"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsScoreRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsServeErrorRuleActionParameters(BaseModel): + content: Optional[str] = None + """Error response content.""" + + content_type: Optional[Literal["application/json", "text/xml", "text/plain", "text/html"]] = None + """Content-type header to set with the response.""" + + status_code: Optional[float] = None + """The status code to use for the error.""" + + +class RuleRulesetsServeErrorRule(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["serve_error"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsServeErrorRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetConfigRuleActionParametersAutominify(BaseModel): + css: Optional[bool] = None + """Minify CSS files.""" + + html: Optional[bool] = None + """Minify HTML files.""" + + js: Optional[bool] = None + """Minify JS files.""" + + +class RuleRulesetsSetConfigRuleActionParameters(BaseModel): + automatic_https_rewrites: Optional[bool] = None + """Turn on or off Automatic HTTPS Rewrites.""" + + autominify: Optional[RuleRulesetsSetConfigRuleActionParametersAutominify] = None + """Select which file extensions to minify automatically.""" + + bic: Optional[bool] = None + """Turn on or off Browser Integrity Check.""" + + disable_apps: Optional[bool] = None + """Turn off all active Cloudflare Apps.""" + + disable_zaraz: Optional[bool] = None + """Turn off Zaraz.""" + + email_obfuscation: Optional[bool] = None + """Turn on or off Email Obfuscation.""" + + hotlink_protection: Optional[bool] = None + """Turn on or off the Hotlink Protection.""" + + mirage: Optional[bool] = None + """Turn on or off Mirage.""" + + opportunistic_encryption: Optional[bool] = None + """Turn on or off Opportunistic Encryption.""" + + polish: Optional[Literal["off", "lossless", "lossy"]] = None + """Configure the Polish level.""" + + rocket_loader: Optional[bool] = None + """Turn on or off Rocket Loader""" + + security_level: Optional[Literal["off", "essentially_off", "low", "medium", "high", "under_attack"]] = None + """Configure the Security Level.""" + + server_side_excludes: Optional[bool] = None + """Turn on or off Server Side Excludes.""" + + ssl: Optional[Literal["off", "flexible", "full", "strict", "origin_pull"]] = None + """Configure the SSL level.""" + + sxg: Optional[bool] = None + """Turn on or off Signed Exchanges (SXG).""" + + +class RuleRulesetsSetConfigRule(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["set_config"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetConfigRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL(BaseModel): + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """Determines which browser ttl mode to use.""" + + default: Optional[int] = None + """The TTL (in seconds) if you choose override_origin mode.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these cookie names. + + The presence of these cookies is used in building the cache key. + """ + + include: Optional[List[str]] = None + """Include these cookies' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these header names. + + The presence of these headers is used in building the cache key. + """ + + exclude_origin: Optional[bool] = None + """Whether or not to include the origin header. + + A value of true will exclude the origin header in the cache key. + """ + + include: Optional[List[str]] = None + """Include these headers' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(BaseModel): + resolved: Optional[bool] = None + """Use the resolved host in the cache key. + + A value of true will use the resolved host, while a value or false will use the + original host. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(BaseModel): + all: Optional[bool] = None + """Exclude all query string parameters from use in building the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters NOT used to build the cache key. + + All parameters present in the request but missing in this list will be used to + build the cache key. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(BaseModel): + all: Optional[bool] = None + """Use all query string parameters in the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters used to build the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(BaseModel): + exclude: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude] = None + """ + build the cache key using all query string parameters EXCECPT these excluded + parameters + """ + + include: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude] = None + """ + build the cache key using a list of query string parameters that ARE in the + request. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(BaseModel): + device_type: Optional[bool] = None + """Use the user agent's device type in the cache key.""" + + geo: Optional[bool] = None + """Use the user agents's country in the cache key.""" + + lang: Optional[bool] = None + """Use the user agent's language in the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey(BaseModel): + cookie: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie] = None + """The cookies to include in building the cache key.""" + + header: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader] = None + """The header names and values to include in building the cache key.""" + + host: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost] = None + """Whether to use the original host or the resolved host in the cache key.""" + + query_string: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString] = None + """ + Use the presence or absence of parameters in the query string to build the cache + key. + """ + + user: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser] = None + """Characteristics of the request user agent used in building the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey(BaseModel): + cache_by_device_type: Optional[bool] = None + """Separate cached content based on the visitor’s device type""" + + cache_deception_armor: Optional[bool] = None + """ + Protect from web cache deception attacks while allowing static assets to be + cached + """ + + custom_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey] = None + """ + Customize which components of the request are included or excluded from the + cache key. + """ + + ignore_query_strings_order: Optional[bool] = None + """ + Treat requests with the same query parameters the same, regardless of the order + those query parameters are in. A value of true ignores the query strings' order. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve(BaseModel): + eligible: bool + """Determines whether cache reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to cache reserve. + """ + + min_file_size: int + """The minimum file size eligible for store in cache reserve.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange(BaseModel): + from_: int = FieldInfo(alias="from") + """response status code lower bound""" + + to: int + """response status code upper bound""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(BaseModel): + value: int + """Time to cache a response (in seconds). + + A value of 0 is equivalent to setting the Cache-Control header with the value + "no-cache". A value of -1 is equivalent to setting Cache-Control header with the + value of "no-store". + """ + + status_code_range: Optional[ + RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + ] = None + """The range of status codes used to apply the selected mode.""" + + status_code_value: Optional[int] = None + """Set the ttl for responses with this specific status code""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL(BaseModel): + default: int + """The TTL (in seconds) if you choose override_origin mode.""" + + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """edge ttl options""" + + status_code_ttl: List[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL] + """List of single status codes, or status code ranges to apply the selected mode""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersServeStale(BaseModel): + disable_stale_while_updating: bool + """Defines whether Cloudflare should serve stale content while updating. + + If true, Cloudflare will not serve stale content while getting the latest + content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParameters(BaseModel): + additional_cacheable_ports: Optional[List[int]] = None + """List of additional ports that caching can be enabled on.""" + + browser_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL] = None + """Specify how long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: Optional[bool] = None + """Mark whether the request’s response from origin is eligible for caching. + + Caching itself will still depend on the cache-control header and your other + caching configurations. + """ + + cache_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey] = None + """ + Define which components of the request are included or excluded from the cache + key Cloudflare uses to store the response in cache. + """ + + cache_reserve: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve] = None + """ + Mark whether the request's response from origin is eligible for Cache Reserve + (requires a Cache Reserve add-on plan). + """ + + edge_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL] = None + """ + TTL (Time to Live) specifies the maximum time to cache a resource in the + Cloudflare edge network. + """ + + origin_cache_control: Optional[bool] = None + """When enabled, Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: Optional[bool] = None + """Generate Cloudflare error pages from issues sent from the origin server. + + When on, error pages will trigger for issues from the origin + """ + + read_timeout: Optional[int] = None + """ + Define a timeout value between two successive read operations to your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: Optional[bool] = None + """ + Specify whether or not Cloudflare should respect strong ETag (entity tag) + headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersServeStale] = None + """ + Define if Cloudflare should serve stale content while getting the latest content + from the origin. If on, Cloudflare will not serve stale content while getting + the latest content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRule(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["set_cache_settings"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheSettingsRuleActionParameters] = 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[Logging] = 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[BlockRule, ExecuteRule, LogRule, SkipRule] +Rule = Union[ + BlockRule, + RuleRulesetsChallengeRule, + RuleRulesetsCompressResponseRule, + ExecuteRule, + RuleRulesetsJsChallengeRule, + LogRule, + RuleRulesetsManagedChallengeRule, + RuleRulesetsRedirectRule, + RuleRulesetsRewriteRule, + RuleRulesetsRouteRule, + RuleRulesetsScoreRule, + RuleRulesetsServeErrorRule, + RuleRulesetsSetConfigRule, + SkipRule, + RuleRulesetsSetCacheSettingsRule, +] class RuleDeleteResponse(BaseModel): diff --git a/src/cloudflare/types/rulesets/rule_edit_params.py b/src/cloudflare/types/rulesets/rule_edit_params.py index c682395c92f..00117df9400 100644 --- a/src/cloudflare/types/rulesets/rule_edit_params.py +++ b/src/cloudflare/types/rulesets/rule_edit_params.py @@ -12,15 +12,69 @@ "BlockRule", "BlockRuleActionParameters", "BlockRuleActionParametersResponse", + "RulesetsChallengeRule", + "RulesetsCompressResponseRule", + "RulesetsCompressResponseRuleActionParameters", + "RulesetsCompressResponseRuleActionParametersAlgorithm", "ExecuteRule", "ExecuteRuleActionParameters", "ExecuteRuleActionParametersMatchedData", "ExecuteRuleActionParametersOverrides", "ExecuteRuleActionParametersOverridesCategory", "ExecuteRuleActionParametersOverridesRule", + "RulesetsJsChallengeRule", "LogRule", + "RulesetsManagedChallengeRule", + "RulesetsRedirectRule", + "RulesetsRedirectRuleActionParameters", + "RulesetsRedirectRuleActionParametersFromList", + "RulesetsRedirectRuleActionParametersFromValue", + "RulesetsRedirectRuleActionParametersFromValueTargetURL", + "RulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect", + "RulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect", + "RulesetsRewriteRule", + "RulesetsRewriteRuleActionParameters", + "RulesetsRewriteRuleActionParametersHeaders", + "RulesetsRewriteRuleActionParametersHeadersRemoveHeader", + "RulesetsRewriteRuleActionParametersHeadersStaticHeader", + "RulesetsRewriteRuleActionParametersHeadersDynamicHeader", + "RulesetsRewriteRuleActionParametersURI", + "RulesetsRewriteRuleActionParametersURIPath", + "RulesetsRewriteRuleActionParametersURIPathStaticValue", + "RulesetsRewriteRuleActionParametersURIPathDynamicValue", + "RulesetsRewriteRuleActionParametersURIQuery", + "RulesetsRewriteRuleActionParametersURIQueryStaticValue", + "RulesetsRewriteRuleActionParametersURIQueryDynamicValue", + "RulesetsRouteRule", + "RulesetsRouteRuleActionParameters", + "RulesetsRouteRuleActionParametersOrigin", + "RulesetsRouteRuleActionParametersSni", + "RulesetsScoreRule", + "RulesetsScoreRuleActionParameters", + "RulesetsServeErrorRule", + "RulesetsServeErrorRuleActionParameters", + "RulesetsSetConfigRule", + "RulesetsSetConfigRuleActionParameters", + "RulesetsSetConfigRuleActionParametersAutominify", "SkipRule", "SkipRuleActionParameters", + "RulesetsSetCacheSettingsRule", + "RulesetsSetCacheSettingsRuleActionParameters", + "RulesetsSetCacheSettingsRuleActionParametersBrowserTTL", + "RulesetsSetCacheSettingsRuleActionParametersCacheKey", + "RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "RulesetsSetCacheSettingsRuleActionParametersCacheReserve", + "RulesetsSetCacheSettingsRuleActionParametersEdgeTTL", + "RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "RulesetsSetCacheSettingsRuleActionParametersServeStale", ] @@ -75,6 +129,86 @@ class BlockRuleActionParameters(TypedDict, total=False): """The response to show when the block is applied.""" +class RulesetsChallengeRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["challenge"] + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsCompressResponseRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["compress_response"] + """The action to perform when the rule matches.""" + + action_parameters: RulesetsCompressResponseRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsCompressResponseRuleActionParametersAlgorithm(TypedDict, total=False): + name: Literal["none", "auto", "default", "gzip", "brotli"] + """Name of compression algorithm to enable.""" + + +class RulesetsCompressResponseRuleActionParameters(TypedDict, total=False): + algorithms: Iterable[RulesetsCompressResponseRuleActionParametersAlgorithm] + """Custom order for compression algorithms.""" + + class ExecuteRule(TypedDict, total=False): ruleset_id: Required[str] """The unique ID of the ruleset.""" @@ -187,6 +321,41 @@ class ExecuteRuleActionParameters(TypedDict, total=False): """A set of overrides to apply to the target ruleset.""" +class RulesetsJsChallengeRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["js_challenge"] + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + class LogRule(TypedDict, total=False): ruleset_id: Required[str] """The unique ID of the ruleset.""" @@ -222,7 +391,7 @@ class LogRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class SkipRule(TypedDict, total=False): +class RulesetsManagedChallengeRule(TypedDict, total=False): ruleset_id: Required[str] """The unique ID of the ruleset.""" @@ -235,10 +404,10 @@ class SkipRule(TypedDict, total=False): id: str """The unique ID of the rule.""" - action: Literal["skip"] + action: Literal["managed_challenge"] """The action to perform when the rule matches.""" - action_parameters: SkipRuleActionParameters + action_parameters: object """The parameters configuring the rule's action.""" description: str @@ -257,59 +426,835 @@ class SkipRule(TypedDict, total=False): """The reference of the rule (the rule ID by default).""" -class SkipRuleActionParameters(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. +class RulesetsRedirectRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" - This option is incompatible with the ruleset and rulesets options. - """ + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" - products: List[Literal["bic", "hot", "rateLimit", "securityLevel", "uaBlock", "waf", "zoneLockdown"]] - """A list of legacy security products to skip the execution of.""" + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" - 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. - """ + id: str + """The unique ID of the rule.""" - ruleset: Literal["current"] - """A ruleset to skip the execution of. + action: Literal["redirect"] + """The action to perform when the rule matches.""" - This option is incompatible with the rulesets, rules and phases options. - """ + action_parameters: RulesetsRedirectRuleActionParameters + """The parameters configuring the rule's action.""" - rulesets: List[str] - """A list of ruleset IDs to skip the execution of. + description: str + """An informative description of the rule.""" - This option is incompatible with the ruleset and phases options. - """ + enabled: bool + """Whether the rule should be executed.""" + + expression: str + """The expression defining which traffic will match the rule.""" + + logging: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsRedirectRuleActionParametersFromList(TypedDict, total=False): + key: str + """Expression that evaluates to the list lookup key.""" + + name: str + """The name of the list to match against.""" + + +class RulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect(TypedDict, total=False): + value: str + """The URL to redirect the request to.""" + + +class RulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect(TypedDict, total=False): + expression: str + """An expression to evaluate to get the URL to redirect the request to.""" + + +RulesetsRedirectRuleActionParametersFromValueTargetURL = Union[ + RulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect, + RulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect, +] + + +class RulesetsRedirectRuleActionParametersFromValue(TypedDict, total=False): + preserve_query_string: bool + """Keep the query string of the original request.""" + + status_code: Literal[301, 302, 303, 307, 308] + """The status code to be used for the redirect.""" + + target_url: RulesetsRedirectRuleActionParametersFromValueTargetURL + """The URL to redirect the request to.""" + + +class RulesetsRedirectRuleActionParameters(TypedDict, total=False): + from_list: RulesetsRedirectRuleActionParametersFromList + """Serve a redirect based on a bulk list lookup.""" + + from_value: RulesetsRedirectRuleActionParametersFromValue + """Serve a redirect based on the request properties.""" + + +class RulesetsRewriteRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["rewrite"] + """The action to perform when the rule matches.""" + + action_parameters: RulesetsRewriteRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsRewriteRuleActionParametersHeadersRemoveHeader(TypedDict, total=False): + operation: Required[Literal["remove"]] + + +class RulesetsRewriteRuleActionParametersHeadersStaticHeader(TypedDict, total=False): + operation: Required[Literal["set"]] + + value: Required[str] + """Static value for the header.""" + + +class RulesetsRewriteRuleActionParametersHeadersDynamicHeader(TypedDict, total=False): + expression: Required[str] + """Expression for the header value.""" + + operation: Required[Literal["set"]] + + +RulesetsRewriteRuleActionParametersHeaders = Union[ + RulesetsRewriteRuleActionParametersHeadersRemoveHeader, + RulesetsRewriteRuleActionParametersHeadersStaticHeader, + RulesetsRewriteRuleActionParametersHeadersDynamicHeader, +] + + +class RulesetsRewriteRuleActionParametersURIPathStaticValue(TypedDict, total=False): + value: Required[str] + """Predefined replacement value.""" + + +class RulesetsRewriteRuleActionParametersURIPathDynamicValue(TypedDict, total=False): + expression: Required[str] + """Expression to evaluate for the replacement value.""" + + +RulesetsRewriteRuleActionParametersURIPath = Union[ + RulesetsRewriteRuleActionParametersURIPathStaticValue, RulesetsRewriteRuleActionParametersURIPathDynamicValue +] + + +class RulesetsRewriteRuleActionParametersURIQueryStaticValue(TypedDict, total=False): + value: Required[str] + """Predefined replacement value.""" + + +class RulesetsRewriteRuleActionParametersURIQueryDynamicValue(TypedDict, total=False): + expression: Required[str] + """Expression to evaluate for the replacement value.""" + + +RulesetsRewriteRuleActionParametersURIQuery = Union[ + RulesetsRewriteRuleActionParametersURIQueryStaticValue, RulesetsRewriteRuleActionParametersURIQueryDynamicValue +] + + +class RulesetsRewriteRuleActionParametersURI(TypedDict, total=False): + path: RulesetsRewriteRuleActionParametersURIPath + """Path portion rewrite.""" + + query: RulesetsRewriteRuleActionParametersURIQuery + """Query portion rewrite.""" + + +class RulesetsRewriteRuleActionParameters(TypedDict, total=False): + headers: Dict[str, RulesetsRewriteRuleActionParametersHeaders] + """Map of request headers to modify.""" + + uri: RulesetsRewriteRuleActionParametersURI + """URI to rewrite the request to.""" -RuleEditParams = Union[BlockRule, ExecuteRule, LogRule, SkipRule] +class RulesetsRouteRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["route"] + """The action to perform when the rule matches.""" + + action_parameters: RulesetsRouteRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsRouteRuleActionParametersOrigin(TypedDict, total=False): + host: str + """Override the resolved hostname.""" + + port: float + """Override the destination port.""" + + +class RulesetsRouteRuleActionParametersSni(TypedDict, total=False): + value: Required[str] + """The SNI override.""" + + +class RulesetsRouteRuleActionParameters(TypedDict, total=False): + host_header: str + """Rewrite the HTTP Host header.""" + + origin: RulesetsRouteRuleActionParametersOrigin + """Override the IP/TCP destination.""" + + sni: RulesetsRouteRuleActionParametersSni + """Override the Server Name Indication (SNI).""" + + +class RulesetsScoreRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["score"] + """The action to perform when the rule matches.""" + + action_parameters: RulesetsScoreRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsScoreRuleActionParameters(TypedDict, total=False): + increment: int + """ + Increment contains the delta to change the score and can be either positive or + negative. + """ + + +class RulesetsServeErrorRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["serve_error"] + """The action to perform when the rule matches.""" + + action_parameters: RulesetsServeErrorRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsServeErrorRuleActionParameters(TypedDict, total=False): + content: str + """Error response content.""" + + content_type: Literal["application/json", "text/xml", "text/plain", "text/html"] + """Content-type header to set with the response.""" + + status_code: float + """The status code to use for the error.""" + + +class RulesetsSetConfigRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["set_config"] + """The action to perform when the rule matches.""" + + action_parameters: RulesetsSetConfigRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsSetConfigRuleActionParametersAutominify(TypedDict, total=False): + css: bool + """Minify CSS files.""" + + html: bool + """Minify HTML files.""" + + js: bool + """Minify JS files.""" + + +class RulesetsSetConfigRuleActionParameters(TypedDict, total=False): + automatic_https_rewrites: bool + """Turn on or off Automatic HTTPS Rewrites.""" + + autominify: RulesetsSetConfigRuleActionParametersAutominify + """Select which file extensions to minify automatically.""" + + bic: bool + """Turn on or off Browser Integrity Check.""" + + disable_apps: bool + """Turn off all active Cloudflare Apps.""" + + disable_zaraz: bool + """Turn off Zaraz.""" + + email_obfuscation: bool + """Turn on or off Email Obfuscation.""" + + hotlink_protection: bool + """Turn on or off the Hotlink Protection.""" + + mirage: bool + """Turn on or off Mirage.""" + + opportunistic_encryption: bool + """Turn on or off Opportunistic Encryption.""" + + polish: Literal["off", "lossless", "lossy"] + """Configure the Polish level.""" + + rocket_loader: bool + """Turn on or off Rocket Loader""" + + security_level: Literal["off", "essentially_off", "low", "medium", "high", "under_attack"] + """Configure the Security Level.""" + + server_side_excludes: bool + """Turn on or off Server Side Excludes.""" + + ssl: Literal["off", "flexible", "full", "strict", "origin_pull"] + """Configure the SSL level.""" + + sxg: bool + """Turn on or off Signed Exchanges (SXG).""" + + +class SkipRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["skip"] + """The action to perform when the rule matches.""" + + action_parameters: SkipRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class SkipRuleActionParameters(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 RulesetsSetCacheSettingsRule(TypedDict, total=False): + ruleset_id: Required[str] + """The unique ID of the ruleset.""" + + account_id: str + """The Account ID to use for this endpoint. Mutually exclusive with the Zone ID.""" + + zone_id: str + """The Zone ID to use for this endpoint. Mutually exclusive with the Account ID.""" + + id: str + """The unique ID of the rule.""" + + action: Literal["set_cache_settings"] + """The action to perform when the rule matches.""" + + action_parameters: RulesetsSetCacheSettingsRuleActionParameters + """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: LoggingParam + """An object configuring the rule's logging behavior.""" + + ref: str + """The reference of the rule (the rule ID by default).""" + + +class RulesetsSetCacheSettingsRuleActionParametersBrowserTTL(TypedDict, total=False): + mode: Required[Literal["respect_origin", "bypass_by_default", "override_origin"]] + """Determines which browser ttl mode to use.""" + + default: int + """The TTL (in seconds) if you choose override_origin mode.""" + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(TypedDict, total=False): + check_presence: List[str] + """Checks for the presence of these cookie names. + + The presence of these cookies is used in building the cache key. + """ + + include: List[str] + """Include these cookies' names and their values.""" + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(TypedDict, total=False): + check_presence: List[str] + """Checks for the presence of these header names. + + The presence of these headers is used in building the cache key. + """ + + exclude_origin: bool + """Whether or not to include the origin header. + + A value of true will exclude the origin header in the cache key. + """ + + include: List[str] + """Include these headers' names and their values.""" + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(TypedDict, total=False): + resolved: bool + """Use the resolved host in the cache key. + + A value of true will use the resolved host, while a value or false will use the + original host. + """ + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(TypedDict, total=False): + all: bool + """Exclude all query string parameters from use in building the cache key.""" + + list: List[str] + """A list of query string parameters NOT used to build the cache key. + + All parameters present in the request but missing in this list will be used to + build the cache key. + """ + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(TypedDict, total=False): + all: bool + """Use all query string parameters in the cache key.""" + + list: List[str] + """A list of query string parameters used to build the cache key.""" + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(TypedDict, total=False): + exclude: RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude + """ + build the cache key using all query string parameters EXCECPT these excluded + parameters + """ + + include: RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude + """ + build the cache key using a list of query string parameters that ARE in the + request. + """ + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(TypedDict, total=False): + device_type: bool + """Use the user agent's device type in the cache key.""" + + geo: bool + """Use the user agents's country in the cache key.""" + + lang: bool + """Use the user agent's language in the cache key.""" + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey(TypedDict, total=False): + cookie: RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie + """The cookies to include in building the cache key.""" + + header: RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader + """The header names and values to include in building the cache key.""" + + host: RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost + """Whether to use the original host or the resolved host in the cache key.""" + + query_string: RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString + """ + Use the presence or absence of parameters in the query string to build the cache + key. + """ + + user: RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser + """Characteristics of the request user agent used in building the cache key.""" + + +class RulesetsSetCacheSettingsRuleActionParametersCacheKey(TypedDict, total=False): + cache_by_device_type: bool + """Separate cached content based on the visitor’s device type""" + + cache_deception_armor: bool + """ + Protect from web cache deception attacks while allowing static assets to be + cached + """ + + custom_key: RulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey + """ + Customize which components of the request are included or excluded from the + cache key. + """ + + ignore_query_strings_order: bool + """ + Treat requests with the same query parameters the same, regardless of the order + those query parameters are in. A value of true ignores the query strings' order. + """ + + +class RulesetsSetCacheSettingsRuleActionParametersCacheReserve(TypedDict, total=False): + eligible: Required[bool] + """Determines whether cache reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to cache reserve. + """ + + min_file_size: Required[int] + """The minimum file size eligible for store in cache reserve.""" + + +_RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords = TypedDict( + "_RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords", + { + "from": int, + }, + total=False, +) + + +class RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange( + _RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeReservedKeywords, total=False +): + to: Required[int] + """response status code upper bound""" + + +class RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(TypedDict, total=False): + value: Required[int] + """Time to cache a response (in seconds). + + A value of 0 is equivalent to setting the Cache-Control header with the value + "no-cache". A value of -1 is equivalent to setting Cache-Control header with the + value of "no-store". + """ + + status_code_range: RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + """The range of status codes used to apply the selected mode.""" + + status_code_value: int + """Set the ttl for responses with this specific status code""" + + +class RulesetsSetCacheSettingsRuleActionParametersEdgeTTL(TypedDict, total=False): + default: Required[int] + """The TTL (in seconds) if you choose override_origin mode.""" + + mode: Required[Literal["respect_origin", "bypass_by_default", "override_origin"]] + """edge ttl options""" + + status_code_ttl: Required[Iterable[RulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL]] + """List of single status codes, or status code ranges to apply the selected mode""" + + +class RulesetsSetCacheSettingsRuleActionParametersServeStale(TypedDict, total=False): + disable_stale_while_updating: Required[bool] + """Defines whether Cloudflare should serve stale content while updating. + + If true, Cloudflare will not serve stale content while getting the latest + content from the origin. + """ + + +class RulesetsSetCacheSettingsRuleActionParameters(TypedDict, total=False): + additional_cacheable_ports: Iterable[int] + """List of additional ports that caching can be enabled on.""" + + browser_ttl: RulesetsSetCacheSettingsRuleActionParametersBrowserTTL + """Specify how long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: bool + """Mark whether the request’s response from origin is eligible for caching. + + Caching itself will still depend on the cache-control header and your other + caching configurations. + """ + + cache_key: RulesetsSetCacheSettingsRuleActionParametersCacheKey + """ + Define which components of the request are included or excluded from the cache + key Cloudflare uses to store the response in cache. + """ + + cache_reserve: RulesetsSetCacheSettingsRuleActionParametersCacheReserve + """ + Mark whether the request's response from origin is eligible for Cache Reserve + (requires a Cache Reserve add-on plan). + """ + + edge_ttl: RulesetsSetCacheSettingsRuleActionParametersEdgeTTL + """ + TTL (Time to Live) specifies the maximum time to cache a resource in the + Cloudflare edge network. + """ + + origin_cache_control: bool + """When enabled, Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: bool + """Generate Cloudflare error pages from issues sent from the origin server. + + When on, error pages will trigger for issues from the origin + """ + + read_timeout: int + """ + Define a timeout value between two successive read operations to your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: bool + """ + Specify whether or not Cloudflare should respect strong ETag (entity tag) + headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: RulesetsSetCacheSettingsRuleActionParametersServeStale + """ + Define if Cloudflare should serve stale content while getting the latest content + from the origin. If on, Cloudflare will not serve stale content while getting + the latest content from the origin. + """ + + +RuleEditParams = Union[ + BlockRule, + RulesetsChallengeRule, + RulesetsCompressResponseRule, + ExecuteRule, + RulesetsJsChallengeRule, + LogRule, + RulesetsManagedChallengeRule, + RulesetsRedirectRule, + RulesetsRewriteRule, + RulesetsRouteRule, + RulesetsScoreRule, + RulesetsServeErrorRule, + RulesetsSetConfigRule, + SkipRule, + RulesetsSetCacheSettingsRule, +] diff --git a/src/cloudflare/types/rulesets/rule_edit_response.py b/src/cloudflare/types/rulesets/rule_edit_response.py index d13e37c8643..75a7e050b54 100644 --- a/src/cloudflare/types/rulesets/rule_edit_response.py +++ b/src/cloudflare/types/rulesets/rule_edit_response.py @@ -1,18 +1,966 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from pydantic import Field as FieldInfo + +from .logging import Logging from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule from .block_rule import BlockRule from .execute_rule import ExecuteRule -__all__ = ["RuleEditResponse", "Rule"] +__all__ = [ + "RuleEditResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsCompressResponseRule", + "RuleRulesetsCompressResponseRuleActionParameters", + "RuleRulesetsCompressResponseRuleActionParametersAlgorithm", + "RuleRulesetsJsChallengeRule", + "RuleRulesetsManagedChallengeRule", + "RuleRulesetsRedirectRule", + "RuleRulesetsRedirectRuleActionParameters", + "RuleRulesetsRedirectRuleActionParametersFromList", + "RuleRulesetsRedirectRuleActionParametersFromValue", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURL", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect", + "RuleRulesetsRewriteRule", + "RuleRulesetsRewriteRuleActionParameters", + "RuleRulesetsRewriteRuleActionParametersHeaders", + "RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader", + "RuleRulesetsRewriteRuleActionParametersURI", + "RuleRulesetsRewriteRuleActionParametersURIPath", + "RuleRulesetsRewriteRuleActionParametersURIPathStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue", + "RuleRulesetsRewriteRuleActionParametersURIQuery", + "RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue", + "RuleRulesetsRouteRule", + "RuleRulesetsRouteRuleActionParameters", + "RuleRulesetsRouteRuleActionParametersOrigin", + "RuleRulesetsRouteRuleActionParametersSni", + "RuleRulesetsScoreRule", + "RuleRulesetsScoreRuleActionParameters", + "RuleRulesetsServeErrorRule", + "RuleRulesetsServeErrorRuleActionParameters", + "RuleRulesetsSetConfigRule", + "RuleRulesetsSetConfigRuleActionParameters", + "RuleRulesetsSetConfigRuleActionParametersAutominify", + "RuleRulesetsSetCacheSettingsRule", + "RuleRulesetsSetCacheSettingsRuleActionParameters", + "RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "RuleRulesetsSetCacheSettingsRuleActionParametersServeStale", +] + + +class RuleRulesetsChallengeRule(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["challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsCompressResponseRuleActionParametersAlgorithm(BaseModel): + name: Optional[Literal["none", "auto", "default", "gzip", "brotli"]] = None + """Name of compression algorithm to enable.""" + + +class RuleRulesetsCompressResponseRuleActionParameters(BaseModel): + algorithms: Optional[List[RuleRulesetsCompressResponseRuleActionParametersAlgorithm]] = None + """Custom order for compression algorithms.""" + + +class RuleRulesetsCompressResponseRule(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["compress_response"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsCompressResponseRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsJsChallengeRule(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["js_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsManagedChallengeRule(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["managed_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRedirectRuleActionParametersFromList(BaseModel): + key: Optional[str] = None + """Expression that evaluates to the list lookup key.""" + + name: Optional[str] = None + """The name of the list to match against.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect(BaseModel): + value: Optional[str] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect(BaseModel): + expression: Optional[str] = None + """An expression to evaluate to get the URL to redirect the request to.""" + + +RuleRulesetsRedirectRuleActionParametersFromValueTargetURL = Union[ + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect, + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect, +] + + +class RuleRulesetsRedirectRuleActionParametersFromValue(BaseModel): + preserve_query_string: Optional[bool] = None + """Keep the query string of the original request.""" + + status_code: Optional[Literal[301, 302, 303, 307, 308]] = None + """The status code to be used for the redirect.""" + + target_url: Optional[RuleRulesetsRedirectRuleActionParametersFromValueTargetURL] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParameters(BaseModel): + from_list: Optional[RuleRulesetsRedirectRuleActionParametersFromList] = None + """Serve a redirect based on a bulk list lookup.""" + + from_value: Optional[RuleRulesetsRedirectRuleActionParametersFromValue] = None + """Serve a redirect based on the request properties.""" + + +class RuleRulesetsRedirectRule(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["redirect"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRedirectRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader(BaseModel): + operation: Literal["remove"] + + +class RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader(BaseModel): + operation: Literal["set"] + + value: str + """Static value for the header.""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader(BaseModel): + expression: str + """Expression for the header value.""" + + operation: Literal["set"] + + +RuleRulesetsRewriteRuleActionParametersHeaders = Union[ + RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader, + RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader, + RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader, +] + + +class RuleRulesetsRewriteRuleActionParametersURIPathStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIPath = Union[ + RuleRulesetsRewriteRuleActionParametersURIPathStaticValue, + RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIQuery = Union[ + RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue, + RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURI(BaseModel): + path: Optional[RuleRulesetsRewriteRuleActionParametersURIPath] = None + """Path portion rewrite.""" + + query: Optional[RuleRulesetsRewriteRuleActionParametersURIQuery] = None + """Query portion rewrite.""" + + +class RuleRulesetsRewriteRuleActionParameters(BaseModel): + headers: Optional[Dict[str, RuleRulesetsRewriteRuleActionParametersHeaders]] = None + """Map of request headers to modify.""" + + uri: Optional[RuleRulesetsRewriteRuleActionParametersURI] = None + """URI to rewrite the request to.""" + + +class RuleRulesetsRewriteRule(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["rewrite"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRewriteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRouteRuleActionParametersOrigin(BaseModel): + host: Optional[str] = None + """Override the resolved hostname.""" + + port: Optional[float] = None + """Override the destination port.""" + + +class RuleRulesetsRouteRuleActionParametersSni(BaseModel): + value: str + """The SNI override.""" + + +class RuleRulesetsRouteRuleActionParameters(BaseModel): + host_header: Optional[str] = None + """Rewrite the HTTP Host header.""" + + origin: Optional[RuleRulesetsRouteRuleActionParametersOrigin] = None + """Override the IP/TCP destination.""" + + sni: Optional[RuleRulesetsRouteRuleActionParametersSni] = None + """Override the Server Name Indication (SNI).""" + + +class RuleRulesetsRouteRule(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["route"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRouteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsScoreRuleActionParameters(BaseModel): + increment: Optional[int] = None + """ + Increment contains the delta to change the score and can be either positive or + negative. + """ + + +class RuleRulesetsScoreRule(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["score"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsScoreRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsServeErrorRuleActionParameters(BaseModel): + content: Optional[str] = None + """Error response content.""" + + content_type: Optional[Literal["application/json", "text/xml", "text/plain", "text/html"]] = None + """Content-type header to set with the response.""" + + status_code: Optional[float] = None + """The status code to use for the error.""" + + +class RuleRulesetsServeErrorRule(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["serve_error"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsServeErrorRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetConfigRuleActionParametersAutominify(BaseModel): + css: Optional[bool] = None + """Minify CSS files.""" + + html: Optional[bool] = None + """Minify HTML files.""" + + js: Optional[bool] = None + """Minify JS files.""" + + +class RuleRulesetsSetConfigRuleActionParameters(BaseModel): + automatic_https_rewrites: Optional[bool] = None + """Turn on or off Automatic HTTPS Rewrites.""" + + autominify: Optional[RuleRulesetsSetConfigRuleActionParametersAutominify] = None + """Select which file extensions to minify automatically.""" + + bic: Optional[bool] = None + """Turn on or off Browser Integrity Check.""" + + disable_apps: Optional[bool] = None + """Turn off all active Cloudflare Apps.""" + + disable_zaraz: Optional[bool] = None + """Turn off Zaraz.""" + + email_obfuscation: Optional[bool] = None + """Turn on or off Email Obfuscation.""" + + hotlink_protection: Optional[bool] = None + """Turn on or off the Hotlink Protection.""" + + mirage: Optional[bool] = None + """Turn on or off Mirage.""" + + opportunistic_encryption: Optional[bool] = None + """Turn on or off Opportunistic Encryption.""" + + polish: Optional[Literal["off", "lossless", "lossy"]] = None + """Configure the Polish level.""" + + rocket_loader: Optional[bool] = None + """Turn on or off Rocket Loader""" + + security_level: Optional[Literal["off", "essentially_off", "low", "medium", "high", "under_attack"]] = None + """Configure the Security Level.""" + + server_side_excludes: Optional[bool] = None + """Turn on or off Server Side Excludes.""" + + ssl: Optional[Literal["off", "flexible", "full", "strict", "origin_pull"]] = None + """Configure the SSL level.""" + + sxg: Optional[bool] = None + """Turn on or off Signed Exchanges (SXG).""" + + +class RuleRulesetsSetConfigRule(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["set_config"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetConfigRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL(BaseModel): + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """Determines which browser ttl mode to use.""" + + default: Optional[int] = None + """The TTL (in seconds) if you choose override_origin mode.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these cookie names. + + The presence of these cookies is used in building the cache key. + """ + + include: Optional[List[str]] = None + """Include these cookies' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these header names. + + The presence of these headers is used in building the cache key. + """ + + exclude_origin: Optional[bool] = None + """Whether or not to include the origin header. + + A value of true will exclude the origin header in the cache key. + """ + + include: Optional[List[str]] = None + """Include these headers' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(BaseModel): + resolved: Optional[bool] = None + """Use the resolved host in the cache key. + + A value of true will use the resolved host, while a value or false will use the + original host. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(BaseModel): + all: Optional[bool] = None + """Exclude all query string parameters from use in building the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters NOT used to build the cache key. + + All parameters present in the request but missing in this list will be used to + build the cache key. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(BaseModel): + all: Optional[bool] = None + """Use all query string parameters in the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters used to build the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(BaseModel): + exclude: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude] = None + """ + build the cache key using all query string parameters EXCECPT these excluded + parameters + """ + + include: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude] = None + """ + build the cache key using a list of query string parameters that ARE in the + request. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(BaseModel): + device_type: Optional[bool] = None + """Use the user agent's device type in the cache key.""" + + geo: Optional[bool] = None + """Use the user agents's country in the cache key.""" + + lang: Optional[bool] = None + """Use the user agent's language in the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey(BaseModel): + cookie: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie] = None + """The cookies to include in building the cache key.""" + + header: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader] = None + """The header names and values to include in building the cache key.""" + + host: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost] = None + """Whether to use the original host or the resolved host in the cache key.""" + + query_string: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString] = None + """ + Use the presence or absence of parameters in the query string to build the cache + key. + """ + + user: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser] = None + """Characteristics of the request user agent used in building the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey(BaseModel): + cache_by_device_type: Optional[bool] = None + """Separate cached content based on the visitor’s device type""" + + cache_deception_armor: Optional[bool] = None + """ + Protect from web cache deception attacks while allowing static assets to be + cached + """ + + custom_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey] = None + """ + Customize which components of the request are included or excluded from the + cache key. + """ + + ignore_query_strings_order: Optional[bool] = None + """ + Treat requests with the same query parameters the same, regardless of the order + those query parameters are in. A value of true ignores the query strings' order. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve(BaseModel): + eligible: bool + """Determines whether cache reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to cache reserve. + """ + + min_file_size: int + """The minimum file size eligible for store in cache reserve.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange(BaseModel): + from_: int = FieldInfo(alias="from") + """response status code lower bound""" + + to: int + """response status code upper bound""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(BaseModel): + value: int + """Time to cache a response (in seconds). + + A value of 0 is equivalent to setting the Cache-Control header with the value + "no-cache". A value of -1 is equivalent to setting Cache-Control header with the + value of "no-store". + """ + + status_code_range: Optional[ + RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + ] = None + """The range of status codes used to apply the selected mode.""" + + status_code_value: Optional[int] = None + """Set the ttl for responses with this specific status code""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL(BaseModel): + default: int + """The TTL (in seconds) if you choose override_origin mode.""" + + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """edge ttl options""" + + status_code_ttl: List[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL] + """List of single status codes, or status code ranges to apply the selected mode""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersServeStale(BaseModel): + disable_stale_while_updating: bool + """Defines whether Cloudflare should serve stale content while updating. + + If true, Cloudflare will not serve stale content while getting the latest + content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParameters(BaseModel): + additional_cacheable_ports: Optional[List[int]] = None + """List of additional ports that caching can be enabled on.""" + + browser_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL] = None + """Specify how long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: Optional[bool] = None + """Mark whether the request’s response from origin is eligible for caching. + + Caching itself will still depend on the cache-control header and your other + caching configurations. + """ + + cache_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey] = None + """ + Define which components of the request are included or excluded from the cache + key Cloudflare uses to store the response in cache. + """ + + cache_reserve: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve] = None + """ + Mark whether the request's response from origin is eligible for Cache Reserve + (requires a Cache Reserve add-on plan). + """ + + edge_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL] = None + """ + TTL (Time to Live) specifies the maximum time to cache a resource in the + Cloudflare edge network. + """ + + origin_cache_control: Optional[bool] = None + """When enabled, Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: Optional[bool] = None + """Generate Cloudflare error pages from issues sent from the origin server. + + When on, error pages will trigger for issues from the origin + """ + + read_timeout: Optional[int] = None + """ + Define a timeout value between two successive read operations to your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: Optional[bool] = None + """ + Specify whether or not Cloudflare should respect strong ETag (entity tag) + headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersServeStale] = None + """ + Define if Cloudflare should serve stale content while getting the latest content + from the origin. If on, Cloudflare will not serve stale content while getting + the latest content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRule(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["set_cache_settings"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheSettingsRuleActionParameters] = 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[Logging] = 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[BlockRule, ExecuteRule, LogRule, SkipRule] +Rule = Union[ + BlockRule, + RuleRulesetsChallengeRule, + RuleRulesetsCompressResponseRule, + ExecuteRule, + RuleRulesetsJsChallengeRule, + LogRule, + RuleRulesetsManagedChallengeRule, + RuleRulesetsRedirectRule, + RuleRulesetsRewriteRule, + RuleRulesetsRouteRule, + RuleRulesetsScoreRule, + RuleRulesetsServeErrorRule, + RuleRulesetsSetConfigRule, + SkipRule, + RuleRulesetsSetCacheSettingsRule, +] class RuleEditResponse(BaseModel): diff --git a/src/cloudflare/types/rulesets/version_get_response.py b/src/cloudflare/types/rulesets/version_get_response.py index fdd1e094340..4098d8c4fcf 100644 --- a/src/cloudflare/types/rulesets/version_get_response.py +++ b/src/cloudflare/types/rulesets/version_get_response.py @@ -1,18 +1,966 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from pydantic import Field as FieldInfo + +from .logging import Logging from .log_rule import LogRule from ..._models import BaseModel from .skip_rule import SkipRule from .block_rule import BlockRule from .execute_rule import ExecuteRule -__all__ = ["VersionGetResponse", "Rule"] +__all__ = [ + "VersionGetResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsCompressResponseRule", + "RuleRulesetsCompressResponseRuleActionParameters", + "RuleRulesetsCompressResponseRuleActionParametersAlgorithm", + "RuleRulesetsJsChallengeRule", + "RuleRulesetsManagedChallengeRule", + "RuleRulesetsRedirectRule", + "RuleRulesetsRedirectRuleActionParameters", + "RuleRulesetsRedirectRuleActionParametersFromList", + "RuleRulesetsRedirectRuleActionParametersFromValue", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURL", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect", + "RuleRulesetsRewriteRule", + "RuleRulesetsRewriteRuleActionParameters", + "RuleRulesetsRewriteRuleActionParametersHeaders", + "RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader", + "RuleRulesetsRewriteRuleActionParametersURI", + "RuleRulesetsRewriteRuleActionParametersURIPath", + "RuleRulesetsRewriteRuleActionParametersURIPathStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue", + "RuleRulesetsRewriteRuleActionParametersURIQuery", + "RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue", + "RuleRulesetsRouteRule", + "RuleRulesetsRouteRuleActionParameters", + "RuleRulesetsRouteRuleActionParametersOrigin", + "RuleRulesetsRouteRuleActionParametersSni", + "RuleRulesetsScoreRule", + "RuleRulesetsScoreRuleActionParameters", + "RuleRulesetsServeErrorRule", + "RuleRulesetsServeErrorRuleActionParameters", + "RuleRulesetsSetConfigRule", + "RuleRulesetsSetConfigRuleActionParameters", + "RuleRulesetsSetConfigRuleActionParametersAutominify", + "RuleRulesetsSetCacheSettingsRule", + "RuleRulesetsSetCacheSettingsRuleActionParameters", + "RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "RuleRulesetsSetCacheSettingsRuleActionParametersServeStale", +] + + +class RuleRulesetsChallengeRule(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["challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsCompressResponseRuleActionParametersAlgorithm(BaseModel): + name: Optional[Literal["none", "auto", "default", "gzip", "brotli"]] = None + """Name of compression algorithm to enable.""" + + +class RuleRulesetsCompressResponseRuleActionParameters(BaseModel): + algorithms: Optional[List[RuleRulesetsCompressResponseRuleActionParametersAlgorithm]] = None + """Custom order for compression algorithms.""" + + +class RuleRulesetsCompressResponseRule(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["compress_response"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsCompressResponseRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsJsChallengeRule(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["js_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsManagedChallengeRule(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["managed_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRedirectRuleActionParametersFromList(BaseModel): + key: Optional[str] = None + """Expression that evaluates to the list lookup key.""" + + name: Optional[str] = None + """The name of the list to match against.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect(BaseModel): + value: Optional[str] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect(BaseModel): + expression: Optional[str] = None + """An expression to evaluate to get the URL to redirect the request to.""" + + +RuleRulesetsRedirectRuleActionParametersFromValueTargetURL = Union[ + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect, + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect, +] + + +class RuleRulesetsRedirectRuleActionParametersFromValue(BaseModel): + preserve_query_string: Optional[bool] = None + """Keep the query string of the original request.""" + + status_code: Optional[Literal[301, 302, 303, 307, 308]] = None + """The status code to be used for the redirect.""" + + target_url: Optional[RuleRulesetsRedirectRuleActionParametersFromValueTargetURL] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParameters(BaseModel): + from_list: Optional[RuleRulesetsRedirectRuleActionParametersFromList] = None + """Serve a redirect based on a bulk list lookup.""" + + from_value: Optional[RuleRulesetsRedirectRuleActionParametersFromValue] = None + """Serve a redirect based on the request properties.""" + + +class RuleRulesetsRedirectRule(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["redirect"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRedirectRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader(BaseModel): + operation: Literal["remove"] + + +class RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader(BaseModel): + operation: Literal["set"] + + value: str + """Static value for the header.""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader(BaseModel): + expression: str + """Expression for the header value.""" + + operation: Literal["set"] + + +RuleRulesetsRewriteRuleActionParametersHeaders = Union[ + RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader, + RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader, + RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader, +] + + +class RuleRulesetsRewriteRuleActionParametersURIPathStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIPath = Union[ + RuleRulesetsRewriteRuleActionParametersURIPathStaticValue, + RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIQuery = Union[ + RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue, + RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURI(BaseModel): + path: Optional[RuleRulesetsRewriteRuleActionParametersURIPath] = None + """Path portion rewrite.""" + + query: Optional[RuleRulesetsRewriteRuleActionParametersURIQuery] = None + """Query portion rewrite.""" + + +class RuleRulesetsRewriteRuleActionParameters(BaseModel): + headers: Optional[Dict[str, RuleRulesetsRewriteRuleActionParametersHeaders]] = None + """Map of request headers to modify.""" + + uri: Optional[RuleRulesetsRewriteRuleActionParametersURI] = None + """URI to rewrite the request to.""" + + +class RuleRulesetsRewriteRule(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["rewrite"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRewriteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRouteRuleActionParametersOrigin(BaseModel): + host: Optional[str] = None + """Override the resolved hostname.""" + + port: Optional[float] = None + """Override the destination port.""" + + +class RuleRulesetsRouteRuleActionParametersSni(BaseModel): + value: str + """The SNI override.""" + + +class RuleRulesetsRouteRuleActionParameters(BaseModel): + host_header: Optional[str] = None + """Rewrite the HTTP Host header.""" + + origin: Optional[RuleRulesetsRouteRuleActionParametersOrigin] = None + """Override the IP/TCP destination.""" + + sni: Optional[RuleRulesetsRouteRuleActionParametersSni] = None + """Override the Server Name Indication (SNI).""" + + +class RuleRulesetsRouteRule(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["route"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRouteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsScoreRuleActionParameters(BaseModel): + increment: Optional[int] = None + """ + Increment contains the delta to change the score and can be either positive or + negative. + """ + + +class RuleRulesetsScoreRule(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["score"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsScoreRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsServeErrorRuleActionParameters(BaseModel): + content: Optional[str] = None + """Error response content.""" + + content_type: Optional[Literal["application/json", "text/xml", "text/plain", "text/html"]] = None + """Content-type header to set with the response.""" + + status_code: Optional[float] = None + """The status code to use for the error.""" + + +class RuleRulesetsServeErrorRule(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["serve_error"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsServeErrorRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetConfigRuleActionParametersAutominify(BaseModel): + css: Optional[bool] = None + """Minify CSS files.""" + + html: Optional[bool] = None + """Minify HTML files.""" + + js: Optional[bool] = None + """Minify JS files.""" + + +class RuleRulesetsSetConfigRuleActionParameters(BaseModel): + automatic_https_rewrites: Optional[bool] = None + """Turn on or off Automatic HTTPS Rewrites.""" + + autominify: Optional[RuleRulesetsSetConfigRuleActionParametersAutominify] = None + """Select which file extensions to minify automatically.""" + + bic: Optional[bool] = None + """Turn on or off Browser Integrity Check.""" + + disable_apps: Optional[bool] = None + """Turn off all active Cloudflare Apps.""" + + disable_zaraz: Optional[bool] = None + """Turn off Zaraz.""" + + email_obfuscation: Optional[bool] = None + """Turn on or off Email Obfuscation.""" + + hotlink_protection: Optional[bool] = None + """Turn on or off the Hotlink Protection.""" + + mirage: Optional[bool] = None + """Turn on or off Mirage.""" + + opportunistic_encryption: Optional[bool] = None + """Turn on or off Opportunistic Encryption.""" + + polish: Optional[Literal["off", "lossless", "lossy"]] = None + """Configure the Polish level.""" + + rocket_loader: Optional[bool] = None + """Turn on or off Rocket Loader""" + + security_level: Optional[Literal["off", "essentially_off", "low", "medium", "high", "under_attack"]] = None + """Configure the Security Level.""" + + server_side_excludes: Optional[bool] = None + """Turn on or off Server Side Excludes.""" + + ssl: Optional[Literal["off", "flexible", "full", "strict", "origin_pull"]] = None + """Configure the SSL level.""" + + sxg: Optional[bool] = None + """Turn on or off Signed Exchanges (SXG).""" + + +class RuleRulesetsSetConfigRule(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["set_config"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetConfigRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL(BaseModel): + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """Determines which browser ttl mode to use.""" + + default: Optional[int] = None + """The TTL (in seconds) if you choose override_origin mode.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these cookie names. + + The presence of these cookies is used in building the cache key. + """ + + include: Optional[List[str]] = None + """Include these cookies' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these header names. + + The presence of these headers is used in building the cache key. + """ + + exclude_origin: Optional[bool] = None + """Whether or not to include the origin header. + + A value of true will exclude the origin header in the cache key. + """ + + include: Optional[List[str]] = None + """Include these headers' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(BaseModel): + resolved: Optional[bool] = None + """Use the resolved host in the cache key. + + A value of true will use the resolved host, while a value or false will use the + original host. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(BaseModel): + all: Optional[bool] = None + """Exclude all query string parameters from use in building the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters NOT used to build the cache key. + + All parameters present in the request but missing in this list will be used to + build the cache key. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(BaseModel): + all: Optional[bool] = None + """Use all query string parameters in the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters used to build the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(BaseModel): + exclude: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude] = None + """ + build the cache key using all query string parameters EXCECPT these excluded + parameters + """ + + include: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude] = None + """ + build the cache key using a list of query string parameters that ARE in the + request. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(BaseModel): + device_type: Optional[bool] = None + """Use the user agent's device type in the cache key.""" + + geo: Optional[bool] = None + """Use the user agents's country in the cache key.""" + + lang: Optional[bool] = None + """Use the user agent's language in the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey(BaseModel): + cookie: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie] = None + """The cookies to include in building the cache key.""" + + header: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader] = None + """The header names and values to include in building the cache key.""" + + host: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost] = None + """Whether to use the original host or the resolved host in the cache key.""" + + query_string: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString] = None + """ + Use the presence or absence of parameters in the query string to build the cache + key. + """ + + user: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser] = None + """Characteristics of the request user agent used in building the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey(BaseModel): + cache_by_device_type: Optional[bool] = None + """Separate cached content based on the visitor’s device type""" + + cache_deception_armor: Optional[bool] = None + """ + Protect from web cache deception attacks while allowing static assets to be + cached + """ + + custom_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey] = None + """ + Customize which components of the request are included or excluded from the + cache key. + """ + + ignore_query_strings_order: Optional[bool] = None + """ + Treat requests with the same query parameters the same, regardless of the order + those query parameters are in. A value of true ignores the query strings' order. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve(BaseModel): + eligible: bool + """Determines whether cache reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to cache reserve. + """ + + min_file_size: int + """The minimum file size eligible for store in cache reserve.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange(BaseModel): + from_: int = FieldInfo(alias="from") + """response status code lower bound""" + + to: int + """response status code upper bound""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(BaseModel): + value: int + """Time to cache a response (in seconds). + + A value of 0 is equivalent to setting the Cache-Control header with the value + "no-cache". A value of -1 is equivalent to setting Cache-Control header with the + value of "no-store". + """ + + status_code_range: Optional[ + RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + ] = None + """The range of status codes used to apply the selected mode.""" + + status_code_value: Optional[int] = None + """Set the ttl for responses with this specific status code""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL(BaseModel): + default: int + """The TTL (in seconds) if you choose override_origin mode.""" + + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """edge ttl options""" + + status_code_ttl: List[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL] + """List of single status codes, or status code ranges to apply the selected mode""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersServeStale(BaseModel): + disable_stale_while_updating: bool + """Defines whether Cloudflare should serve stale content while updating. + + If true, Cloudflare will not serve stale content while getting the latest + content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParameters(BaseModel): + additional_cacheable_ports: Optional[List[int]] = None + """List of additional ports that caching can be enabled on.""" + + browser_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL] = None + """Specify how long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: Optional[bool] = None + """Mark whether the request’s response from origin is eligible for caching. + + Caching itself will still depend on the cache-control header and your other + caching configurations. + """ + + cache_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey] = None + """ + Define which components of the request are included or excluded from the cache + key Cloudflare uses to store the response in cache. + """ + + cache_reserve: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve] = None + """ + Mark whether the request's response from origin is eligible for Cache Reserve + (requires a Cache Reserve add-on plan). + """ + + edge_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL] = None + """ + TTL (Time to Live) specifies the maximum time to cache a resource in the + Cloudflare edge network. + """ + + origin_cache_control: Optional[bool] = None + """When enabled, Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: Optional[bool] = None + """Generate Cloudflare error pages from issues sent from the origin server. + + When on, error pages will trigger for issues from the origin + """ + + read_timeout: Optional[int] = None + """ + Define a timeout value between two successive read operations to your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: Optional[bool] = None + """ + Specify whether or not Cloudflare should respect strong ETag (entity tag) + headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersServeStale] = None + """ + Define if Cloudflare should serve stale content while getting the latest content + from the origin. If on, Cloudflare will not serve stale content while getting + the latest content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRule(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["set_cache_settings"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheSettingsRuleActionParameters] = 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[Logging] = 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[BlockRule, ExecuteRule, LogRule, SkipRule] +Rule = Union[ + BlockRule, + RuleRulesetsChallengeRule, + RuleRulesetsCompressResponseRule, + ExecuteRule, + RuleRulesetsJsChallengeRule, + LogRule, + RuleRulesetsManagedChallengeRule, + RuleRulesetsRedirectRule, + RuleRulesetsRewriteRule, + RuleRulesetsRouteRule, + RuleRulesetsScoreRule, + RuleRulesetsServeErrorRule, + RuleRulesetsSetConfigRule, + SkipRule, + RuleRulesetsSetCacheSettingsRule, +] class VersionGetResponse(BaseModel): diff --git a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py index e5d1f322f3a..3b4be3afa64 100644 --- a/src/cloudflare/types/rulesets/versions/by_tag_get_response.py +++ b/src/cloudflare/types/rulesets/versions/by_tag_get_response.py @@ -1,18 +1,966 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union, Optional +from typing import Dict, List, Union, Optional from datetime import datetime from typing_extensions import Literal +from pydantic import Field as FieldInfo + +from ..logging import Logging from ..log_rule import LogRule from ...._models import BaseModel from ..skip_rule import SkipRule from ..block_rule import BlockRule from ..execute_rule import ExecuteRule -__all__ = ["ByTagGetResponse", "Rule"] +__all__ = [ + "ByTagGetResponse", + "Rule", + "RuleRulesetsChallengeRule", + "RuleRulesetsCompressResponseRule", + "RuleRulesetsCompressResponseRuleActionParameters", + "RuleRulesetsCompressResponseRuleActionParametersAlgorithm", + "RuleRulesetsJsChallengeRule", + "RuleRulesetsManagedChallengeRule", + "RuleRulesetsRedirectRule", + "RuleRulesetsRedirectRuleActionParameters", + "RuleRulesetsRedirectRuleActionParametersFromList", + "RuleRulesetsRedirectRuleActionParametersFromValue", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURL", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect", + "RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect", + "RuleRulesetsRewriteRule", + "RuleRulesetsRewriteRuleActionParameters", + "RuleRulesetsRewriteRuleActionParametersHeaders", + "RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader", + "RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader", + "RuleRulesetsRewriteRuleActionParametersURI", + "RuleRulesetsRewriteRuleActionParametersURIPath", + "RuleRulesetsRewriteRuleActionParametersURIPathStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue", + "RuleRulesetsRewriteRuleActionParametersURIQuery", + "RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue", + "RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue", + "RuleRulesetsRouteRule", + "RuleRulesetsRouteRuleActionParameters", + "RuleRulesetsRouteRuleActionParametersOrigin", + "RuleRulesetsRouteRuleActionParametersSni", + "RuleRulesetsScoreRule", + "RuleRulesetsScoreRuleActionParameters", + "RuleRulesetsServeErrorRule", + "RuleRulesetsServeErrorRuleActionParameters", + "RuleRulesetsSetConfigRule", + "RuleRulesetsSetConfigRuleActionParameters", + "RuleRulesetsSetConfigRuleActionParametersAutominify", + "RuleRulesetsSetCacheSettingsRule", + "RuleRulesetsSetCacheSettingsRuleActionParameters", + "RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser", + "RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL", + "RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange", + "RuleRulesetsSetCacheSettingsRuleActionParametersServeStale", +] + + +class RuleRulesetsChallengeRule(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["challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsCompressResponseRuleActionParametersAlgorithm(BaseModel): + name: Optional[Literal["none", "auto", "default", "gzip", "brotli"]] = None + """Name of compression algorithm to enable.""" + + +class RuleRulesetsCompressResponseRuleActionParameters(BaseModel): + algorithms: Optional[List[RuleRulesetsCompressResponseRuleActionParametersAlgorithm]] = None + """Custom order for compression algorithms.""" + + +class RuleRulesetsCompressResponseRule(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["compress_response"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsCompressResponseRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsJsChallengeRule(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["js_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsManagedChallengeRule(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["managed_challenge"]] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRedirectRuleActionParametersFromList(BaseModel): + key: Optional[str] = None + """Expression that evaluates to the list lookup key.""" + + name: Optional[str] = None + """The name of the list to match against.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect(BaseModel): + value: Optional[str] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect(BaseModel): + expression: Optional[str] = None + """An expression to evaluate to get the URL to redirect the request to.""" + + +RuleRulesetsRedirectRuleActionParametersFromValueTargetURL = Union[ + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLStaticURLRedirect, + RuleRulesetsRedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect, +] + + +class RuleRulesetsRedirectRuleActionParametersFromValue(BaseModel): + preserve_query_string: Optional[bool] = None + """Keep the query string of the original request.""" + + status_code: Optional[Literal[301, 302, 303, 307, 308]] = None + """The status code to be used for the redirect.""" + + target_url: Optional[RuleRulesetsRedirectRuleActionParametersFromValueTargetURL] = None + """The URL to redirect the request to.""" + + +class RuleRulesetsRedirectRuleActionParameters(BaseModel): + from_list: Optional[RuleRulesetsRedirectRuleActionParametersFromList] = None + """Serve a redirect based on a bulk list lookup.""" + + from_value: Optional[RuleRulesetsRedirectRuleActionParametersFromValue] = None + """Serve a redirect based on the request properties.""" + + +class RuleRulesetsRedirectRule(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["redirect"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRedirectRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader(BaseModel): + operation: Literal["remove"] + + +class RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader(BaseModel): + operation: Literal["set"] + + value: str + """Static value for the header.""" + + +class RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader(BaseModel): + expression: str + """Expression for the header value.""" + + operation: Literal["set"] + + +RuleRulesetsRewriteRuleActionParametersHeaders = Union[ + RuleRulesetsRewriteRuleActionParametersHeadersRemoveHeader, + RuleRulesetsRewriteRuleActionParametersHeadersStaticHeader, + RuleRulesetsRewriteRuleActionParametersHeadersDynamicHeader, +] + + +class RuleRulesetsRewriteRuleActionParametersURIPathStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIPath = Union[ + RuleRulesetsRewriteRuleActionParametersURIPathStaticValue, + RuleRulesetsRewriteRuleActionParametersURIPathDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue(BaseModel): + value: str + """Predefined replacement value.""" + + +class RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue(BaseModel): + expression: str + """Expression to evaluate for the replacement value.""" + + +RuleRulesetsRewriteRuleActionParametersURIQuery = Union[ + RuleRulesetsRewriteRuleActionParametersURIQueryStaticValue, + RuleRulesetsRewriteRuleActionParametersURIQueryDynamicValue, +] + + +class RuleRulesetsRewriteRuleActionParametersURI(BaseModel): + path: Optional[RuleRulesetsRewriteRuleActionParametersURIPath] = None + """Path portion rewrite.""" + + query: Optional[RuleRulesetsRewriteRuleActionParametersURIQuery] = None + """Query portion rewrite.""" + + +class RuleRulesetsRewriteRuleActionParameters(BaseModel): + headers: Optional[Dict[str, RuleRulesetsRewriteRuleActionParametersHeaders]] = None + """Map of request headers to modify.""" + + uri: Optional[RuleRulesetsRewriteRuleActionParametersURI] = None + """URI to rewrite the request to.""" + + +class RuleRulesetsRewriteRule(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["rewrite"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRewriteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsRouteRuleActionParametersOrigin(BaseModel): + host: Optional[str] = None + """Override the resolved hostname.""" + + port: Optional[float] = None + """Override the destination port.""" + + +class RuleRulesetsRouteRuleActionParametersSni(BaseModel): + value: str + """The SNI override.""" + + +class RuleRulesetsRouteRuleActionParameters(BaseModel): + host_header: Optional[str] = None + """Rewrite the HTTP Host header.""" + + origin: Optional[RuleRulesetsRouteRuleActionParametersOrigin] = None + """Override the IP/TCP destination.""" + + sni: Optional[RuleRulesetsRouteRuleActionParametersSni] = None + """Override the Server Name Indication (SNI).""" + + +class RuleRulesetsRouteRule(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["route"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsRouteRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsScoreRuleActionParameters(BaseModel): + increment: Optional[int] = None + """ + Increment contains the delta to change the score and can be either positive or + negative. + """ + + +class RuleRulesetsScoreRule(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["score"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsScoreRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsServeErrorRuleActionParameters(BaseModel): + content: Optional[str] = None + """Error response content.""" + + content_type: Optional[Literal["application/json", "text/xml", "text/plain", "text/html"]] = None + """Content-type header to set with the response.""" + + status_code: Optional[float] = None + """The status code to use for the error.""" + + +class RuleRulesetsServeErrorRule(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["serve_error"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsServeErrorRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetConfigRuleActionParametersAutominify(BaseModel): + css: Optional[bool] = None + """Minify CSS files.""" + + html: Optional[bool] = None + """Minify HTML files.""" + + js: Optional[bool] = None + """Minify JS files.""" + + +class RuleRulesetsSetConfigRuleActionParameters(BaseModel): + automatic_https_rewrites: Optional[bool] = None + """Turn on or off Automatic HTTPS Rewrites.""" + + autominify: Optional[RuleRulesetsSetConfigRuleActionParametersAutominify] = None + """Select which file extensions to minify automatically.""" + + bic: Optional[bool] = None + """Turn on or off Browser Integrity Check.""" + + disable_apps: Optional[bool] = None + """Turn off all active Cloudflare Apps.""" + + disable_zaraz: Optional[bool] = None + """Turn off Zaraz.""" + + email_obfuscation: Optional[bool] = None + """Turn on or off Email Obfuscation.""" + + hotlink_protection: Optional[bool] = None + """Turn on or off the Hotlink Protection.""" + + mirage: Optional[bool] = None + """Turn on or off Mirage.""" + + opportunistic_encryption: Optional[bool] = None + """Turn on or off Opportunistic Encryption.""" + + polish: Optional[Literal["off", "lossless", "lossy"]] = None + """Configure the Polish level.""" + + rocket_loader: Optional[bool] = None + """Turn on or off Rocket Loader""" + + security_level: Optional[Literal["off", "essentially_off", "low", "medium", "high", "under_attack"]] = None + """Configure the Security Level.""" + + server_side_excludes: Optional[bool] = None + """Turn on or off Server Side Excludes.""" + + ssl: Optional[Literal["off", "flexible", "full", "strict", "origin_pull"]] = None + """Configure the SSL level.""" + + sxg: Optional[bool] = None + """Turn on or off Signed Exchanges (SXG).""" + + +class RuleRulesetsSetConfigRule(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["set_config"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetConfigRuleActionParameters] = 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[Logging] = None + """An object configuring the rule's logging behavior.""" + + ref: Optional[str] = None + """The reference of the rule (the rule ID by default).""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL(BaseModel): + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """Determines which browser ttl mode to use.""" + + default: Optional[int] = None + """The TTL (in seconds) if you choose override_origin mode.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these cookie names. + + The presence of these cookies is used in building the cache key. + """ + + include: Optional[List[str]] = None + """Include these cookies' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader(BaseModel): + check_presence: Optional[List[str]] = None + """Checks for the presence of these header names. + + The presence of these headers is used in building the cache key. + """ + + exclude_origin: Optional[bool] = None + """Whether or not to include the origin header. + + A value of true will exclude the origin header in the cache key. + """ + + include: Optional[List[str]] = None + """Include these headers' names and their values.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost(BaseModel): + resolved: Optional[bool] = None + """Use the resolved host in the cache key. + + A value of true will use the resolved host, while a value or false will use the + original host. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude(BaseModel): + all: Optional[bool] = None + """Exclude all query string parameters from use in building the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters NOT used to build the cache key. + + All parameters present in the request but missing in this list will be used to + build the cache key. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude(BaseModel): + all: Optional[bool] = None + """Use all query string parameters in the cache key.""" + + rule_list: Optional[List[str]] = FieldInfo(alias="list", default=None) + """A list of query string parameters used to build the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString(BaseModel): + exclude: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude] = None + """ + build the cache key using all query string parameters EXCECPT these excluded + parameters + """ + + include: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude] = None + """ + build the cache key using a list of query string parameters that ARE in the + request. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser(BaseModel): + device_type: Optional[bool] = None + """Use the user agent's device type in the cache key.""" + + geo: Optional[bool] = None + """Use the user agents's country in the cache key.""" + + lang: Optional[bool] = None + """Use the user agent's language in the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey(BaseModel): + cookie: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie] = None + """The cookies to include in building the cache key.""" + + header: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader] = None + """The header names and values to include in building the cache key.""" + + host: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost] = None + """Whether to use the original host or the resolved host in the cache key.""" + + query_string: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString] = None + """ + Use the presence or absence of parameters in the query string to build the cache + key. + """ + + user: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser] = None + """Characteristics of the request user agent used in building the cache key.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey(BaseModel): + cache_by_device_type: Optional[bool] = None + """Separate cached content based on the visitor’s device type""" + + cache_deception_armor: Optional[bool] = None + """ + Protect from web cache deception attacks while allowing static assets to be + cached + """ + + custom_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKeyCustomKey] = None + """ + Customize which components of the request are included or excluded from the + cache key. + """ + + ignore_query_strings_order: Optional[bool] = None + """ + Treat requests with the same query parameters the same, regardless of the order + those query parameters are in. A value of true ignores the query strings' order. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve(BaseModel): + eligible: bool + """Determines whether cache reserve is enabled. + + If this is true and a request meets eligibility criteria, Cloudflare will write + the resource to cache reserve. + """ + + min_file_size: int + """The minimum file size eligible for store in cache reserve.""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange(BaseModel): + from_: int = FieldInfo(alias="from") + """response status code lower bound""" + + to: int + """response status code upper bound""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL(BaseModel): + value: int + """Time to cache a response (in seconds). + + A value of 0 is equivalent to setting the Cache-Control header with the value + "no-cache". A value of -1 is equivalent to setting Cache-Control header with the + value of "no-store". + """ + + status_code_range: Optional[ + RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange + ] = None + """The range of status codes used to apply the selected mode.""" + + status_code_value: Optional[int] = None + """Set the ttl for responses with this specific status code""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL(BaseModel): + default: int + """The TTL (in seconds) if you choose override_origin mode.""" + + mode: Literal["respect_origin", "bypass_by_default", "override_origin"] + """edge ttl options""" + + status_code_ttl: List[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL] + """List of single status codes, or status code ranges to apply the selected mode""" + + +class RuleRulesetsSetCacheSettingsRuleActionParametersServeStale(BaseModel): + disable_stale_while_updating: bool + """Defines whether Cloudflare should serve stale content while updating. + + If true, Cloudflare will not serve stale content while getting the latest + content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRuleActionParameters(BaseModel): + additional_cacheable_ports: Optional[List[int]] = None + """List of additional ports that caching can be enabled on.""" + + browser_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersBrowserTTL] = None + """Specify how long client browsers should cache the response. + + Cloudflare cache purge will not purge content cached on client browsers, so high + browser TTLs may lead to stale content. + """ + + cache: Optional[bool] = None + """Mark whether the request’s response from origin is eligible for caching. + + Caching itself will still depend on the cache-control header and your other + caching configurations. + """ + + cache_key: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheKey] = None + """ + Define which components of the request are included or excluded from the cache + key Cloudflare uses to store the response in cache. + """ + + cache_reserve: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersCacheReserve] = None + """ + Mark whether the request's response from origin is eligible for Cache Reserve + (requires a Cache Reserve add-on plan). + """ + + edge_ttl: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersEdgeTTL] = None + """ + TTL (Time to Live) specifies the maximum time to cache a resource in the + Cloudflare edge network. + """ + + origin_cache_control: Optional[bool] = None + """When enabled, Cloudflare will aim to strictly adhere to RFC 7234.""" + + origin_error_page_passthru: Optional[bool] = None + """Generate Cloudflare error pages from issues sent from the origin server. + + When on, error pages will trigger for issues from the origin + """ + + read_timeout: Optional[int] = None + """ + Define a timeout value between two successive read operations to your origin + server. Historically, the timeout value between two read options from Cloudflare + to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + errors because of timeouts from an origin server, try increasing this timeout + value. + """ + + respect_strong_etags: Optional[bool] = None + """ + Specify whether or not Cloudflare should respect strong ETag (entity tag) + headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + """ + + serve_stale: Optional[RuleRulesetsSetCacheSettingsRuleActionParametersServeStale] = None + """ + Define if Cloudflare should serve stale content while getting the latest content + from the origin. If on, Cloudflare will not serve stale content while getting + the latest content from the origin. + """ + + +class RuleRulesetsSetCacheSettingsRule(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["set_cache_settings"]] = None + """The action to perform when the rule matches.""" + + action_parameters: Optional[RuleRulesetsSetCacheSettingsRuleActionParameters] = 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[Logging] = 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[BlockRule, ExecuteRule, LogRule, SkipRule] +Rule = Union[ + BlockRule, + RuleRulesetsChallengeRule, + RuleRulesetsCompressResponseRule, + ExecuteRule, + RuleRulesetsJsChallengeRule, + LogRule, + RuleRulesetsManagedChallengeRule, + RuleRulesetsRedirectRule, + RuleRulesetsRewriteRule, + RuleRulesetsRouteRule, + RuleRulesetsScoreRule, + RuleRulesetsServeErrorRule, + RuleRulesetsSetConfigRule, + SkipRule, + RuleRulesetsSetCacheSettingsRule, +] class ByTagGetResponse(BaseModel): diff --git a/tests/api_resources/rulesets/test_rules.py b/tests/api_resources/rulesets/test_rules.py index 2bc480b2c7b..bfa711e3da1 100644 --- a/tests/api_resources/rulesets/test_rules.py +++ b/tests/api_resources/rulesets/test_rules.py @@ -122,6 +122,170 @@ def test_method_create_overload_2(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize def test_method_create_with_all_params_overload_2(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="challenge", + action_parameters={}, + description="Issue an Interactive Challenge if the visitor had not solved an Interactive Challenge prior to the request when the address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_create_overload_3(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_create_with_all_params_overload_3(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="compress_response", + action_parameters={"algorithms": [{"name": "none"}]}, + description="Disable compression when address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create_overload_3(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create_overload_3(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create_overload_3(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_create_overload_4(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_create_with_all_params_overload_4(self, client: Cloudflare) -> None: rule = client.rulesets.rules.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -164,7 +328,7 @@ def test_method_create_with_all_params_overload_2(self, client: Cloudflare) -> N @pytest.mark.skip() @parametrize - def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: + def test_raw_response_create_overload_4(self, client: Cloudflare) -> None: response = client.rulesets.rules.with_raw_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -178,7 +342,7 @@ def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize - def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: + def test_streaming_response_create_overload_4(self, client: Cloudflare) -> None: with client.rulesets.rules.with_streaming_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -194,7 +358,7 @@ def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize - def test_path_params_create_overload_2(self, client: Cloudflare) -> None: + def test_path_params_create_overload_4(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): client.rulesets.rules.with_raw_response.create( "", @@ -218,7 +382,7 @@ def test_path_params_create_overload_2(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize - def test_method_create_overload_3(self, client: Cloudflare) -> None: + def test_method_create_overload_5(self, client: Cloudflare) -> None: rule = client.rulesets.rules.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -228,15 +392,15 @@ def test_method_create_overload_3(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize - def test_method_create_with_all_params_overload_3(self, client: Cloudflare) -> None: + def test_method_create_with_all_params_overload_5(self, client: Cloudflare) -> None: rule = client.rulesets.rules.create( "2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", id="3a03d665bac047339bb530ecb439a90d", - action="log", + action="js_challenge", action_parameters={}, - description="Log when the IP address is not 1.1.1.1", + description="Issue a non-interactive Javascript Challenge if the visitor had not solved a Interactive Challenge, Managed Challenge, or Javascript Challenge prior to the request when the address is not 1.1.1.1", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -246,7 +410,7 @@ def test_method_create_with_all_params_overload_3(self, client: Cloudflare) -> N @pytest.mark.skip() @parametrize - def test_raw_response_create_overload_3(self, client: Cloudflare) -> None: + def test_raw_response_create_overload_5(self, client: Cloudflare) -> None: response = client.rulesets.rules.with_raw_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -260,7 +424,7 @@ def test_raw_response_create_overload_3(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize - def test_streaming_response_create_overload_3(self, client: Cloudflare) -> None: + def test_streaming_response_create_overload_5(self, client: Cloudflare) -> None: with client.rulesets.rules.with_streaming_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -276,7 +440,7 @@ def test_streaming_response_create_overload_3(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize - def test_path_params_create_overload_3(self, client: Cloudflare) -> None: + def test_path_params_create_overload_5(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): client.rulesets.rules.with_raw_response.create( "", @@ -300,7 +464,7 @@ def test_path_params_create_overload_3(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize - def test_method_create_overload_4(self, client: Cloudflare) -> None: + def test_method_create_overload_6(self, client: Cloudflare) -> None: rule = client.rulesets.rules.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -310,21 +474,15 @@ def test_method_create_overload_4(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize - def test_method_create_with_all_params_overload_4(self, client: Cloudflare) -> None: + def test_method_create_with_all_params_overload_6(self, client: Cloudflare) -> None: rule = client.rulesets.rules.create( "2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", id="3a03d665bac047339bb530ecb439a90d", - action="skip", - action_parameters={ - "phases": ["http_request_firewall_custom"], - "products": ["bic"], - "rules": {"4814384a9e5d4991b9815dcfc25d2f1f": ["8ac8bc2a661e475d940980f9317f28e1"]}, - "ruleset": "current", - "rulesets": ["4814384a9e5d4991b9815dcfc25d2f1f"], - }, - description="Skip the current ruleset when the IP address is not 1.1.1.1", + action="log", + action_parameters={}, + description="Log when the IP address is not 1.1.1.1", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -334,7 +492,7 @@ def test_method_create_with_all_params_overload_4(self, client: Cloudflare) -> N @pytest.mark.skip() @parametrize - def test_raw_response_create_overload_4(self, client: Cloudflare) -> None: + def test_raw_response_create_overload_6(self, client: Cloudflare) -> None: response = client.rulesets.rules.with_raw_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -348,7 +506,7 @@ def test_raw_response_create_overload_4(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize - def test_streaming_response_create_overload_4(self, client: Cloudflare) -> None: + def test_streaming_response_create_overload_6(self, client: Cloudflare) -> None: with client.rulesets.rules.with_streaming_response.create( "2f2feab2026849078ba485f918791bdc", account_id="string", @@ -364,7 +522,7 @@ def test_streaming_response_create_overload_4(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize - def test_path_params_create_overload_4(self, client: Cloudflare) -> None: + def test_path_params_create_overload_6(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): client.rulesets.rules.with_raw_response.create( "", @@ -388,32 +546,37 @@ def test_path_params_create_overload_4(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.delete( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", + def test_method_create_overload_7(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) - assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - def test_method_delete_with_all_params(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.delete( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", + def test_method_create_with_all_params_overload_7(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="managed_challenge", + action_parameters={}, + description="Issue a Managed Challenge if the visitor had not solved a Managed Challenge or Interactive Challenge prior to the request when the address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", ) - assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.rulesets.rules.with_raw_response.delete( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", + def test_raw_response_create_overload_7(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) @@ -421,14 +584,13 @@ def test_raw_response_delete(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = response.parse() - assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.rulesets.rules.with_streaming_response.delete( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", + def test_streaming_response_create_overload_7(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) as response: @@ -436,60 +598,4042 @@ def test_streaming_response_delete(self, client: Cloudflare) -> None: assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = response.parse() - assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip() @parametrize - def test_path_params_delete(self, client: Cloudflare) -> None: + def test_path_params_create_overload_7(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - client.rulesets.rules.with_raw_response.delete( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="", - account_id="string", - zone_id="string", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - client.rulesets.rules.with_raw_response.delete( + client.rulesets.rules.with_raw_response.create( "", - ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.rulesets.rules.with_raw_response.delete( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", account_id="", zone_id="string", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rulesets.rules.with_raw_response.delete( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="", ) @pytest.mark.skip() @parametrize - def test_method_edit_overload_1(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.edit( - "3a03d665bac047339bb530ecb439a90d", - ruleset_id="2f2feab2026849078ba485f918791bdc", + def test_method_create_overload_8(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) - assert_matches_type(RuleEditResponse, rule, path=["response"]) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_create_with_all_params_overload_8(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="redirect", + action_parameters={ + "from_list": { + "key": "http.request.full_uri", + "name": "list1", + }, + "from_value": { + "preserve_query_string": True, + "status_code": 301, + "target_url": {"value": "x"}, + }, + }, + description="Redirect when IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create_overload_8(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create_overload_8(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create_overload_8(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_create_overload_9(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_create_with_all_params_overload_9(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="rewrite", + action_parameters={ + "headers": { + "client-http-version": { + "expression": "http.request.version", + "operation": "set", + } + }, + "uri": { + "path": {"expression": 'regex_replace(http.request.uri.path, "/bar$", "/baz")'}, + "query": {"expression": 'regex_replace(http.request.uri.query, "foo=bar", "")'}, + }, + }, + description="Add a header when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create_overload_9(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create_overload_9(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create_overload_9(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_create_overload_10(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_create_with_all_params_overload_10(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="route", + action_parameters={ + "host_header": "static.example.com", + "origin": { + "host": "static.example.com", + "port": 1, + }, + "sni": {"value": "static.example.com"}, + }, + description="Select origin server when IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create_overload_10(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create_overload_10(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create_overload_10(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_create_overload_11(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_create_with_all_params_overload_11(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="score", + action_parameters={"increment": 3}, + description="Increment score when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create_overload_11(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create_overload_11(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create_overload_11(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_create_overload_12(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_create_with_all_params_overload_12(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="serve_error", + action_parameters={ + "content": '{"error": "1xxx error occurred"}\n', + "content_type": "application/json", + "status_code": 500, + }, + description="Serve a JSON response to api users on error", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create_overload_12(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create_overload_12(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create_overload_12(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_create_overload_13(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_create_with_all_params_overload_13(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="set_config", + action_parameters={ + "automatic_https_rewrites": True, + "autominify": { + "css": True, + "html": True, + "js": True, + }, + "bic": True, + "disable_apps": True, + "disable_zaraz": True, + "email_obfuscation": True, + "hotlink_protection": True, + "mirage": True, + "opportunistic_encryption": True, + "polish": "off", + "rocket_loader": True, + "security_level": "off", + "server_side_excludes": True, + "ssl": "off", + "sxg": True, + }, + description="Disable Zaraz when IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create_overload_13(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create_overload_13(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create_overload_13(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_create_overload_14(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_create_with_all_params_overload_14(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="skip", + action_parameters={ + "phases": ["http_request_firewall_custom"], + "products": ["bic"], + "rules": {"4814384a9e5d4991b9815dcfc25d2f1f": ["8ac8bc2a661e475d940980f9317f28e1"]}, + "ruleset": "current", + "rulesets": ["4814384a9e5d4991b9815dcfc25d2f1f"], + }, + description="Skip the current ruleset when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create_overload_14(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create_overload_14(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create_overload_14(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_create_overload_15(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_create_with_all_params_overload_15(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_settings", + action_parameters={ + "additional_cacheable_ports": [0, 0, 0], + "browser_ttl": { + "default": 0, + "mode": "respect_origin", + }, + "cache": True, + "cache_key": { + "cache_by_device_type": True, + "cache_deception_armor": True, + "custom_key": { + "cookie": { + "check_presence": ["string", "string", "string"], + "include": ["string", "string", "string"], + }, + "header": { + "check_presence": ["string", "string", "string"], + "exclude_origin": True, + "include": ["string", "string", "string"], + }, + "host": {"resolved": True}, + "query_string": { + "exclude": { + "all": True, + "list": ["string", "string", "string"], + }, + "include": { + "all": True, + "list": ["string", "string", "string"], + }, + }, + "user": { + "device_type": True, + "geo": True, + "lang": True, + }, + }, + "ignore_query_strings_order": True, + }, + "cache_reserve": { + "eligible": True, + "min_file_size": 0, + }, + "edge_ttl": { + "default": 1, + "mode": "respect_origin", + "status_code_ttl": [ + { + "status_code_range": { + "from": 0, + "to": 0, + }, + "status_code_value": 0, + "value": 0, + }, + { + "status_code_range": { + "from": 0, + "to": 0, + }, + "status_code_value": 0, + "value": 0, + }, + { + "status_code_range": { + "from": 0, + "to": 0, + }, + "status_code_value": 0, + "value": 0, + }, + ], + }, + "origin_cache_control": True, + "origin_error_page_passthru": True, + "read_timeout": 900, + "respect_strong_etags": True, + "serve_stale": {"disable_stale_while_updating": True}, + }, + description="Set cache settings when the hostname address is not example.com", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_create_overload_15(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_create_overload_15(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_create_overload_15(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.delete( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_delete_with_all_params(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.delete( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.delete( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.delete( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.delete( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.delete( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.delete( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.delete( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_edit_overload_1(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_edit_with_all_params_overload_1(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="block", + action_parameters={ + "response": { + "content": '{\n "success": false,\n "error": "you have been blocked"\n}', + "content_type": "application/json", + "status_code": 400, + } + }, + description="Block when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_edit_overload_1(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_edit_overload_1(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_edit_overload_1(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_edit_overload_2(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_edit_with_all_params_overload_2(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="challenge", + action_parameters={}, + description="Issue an Interactive Challenge if the visitor had not solved an Interactive Challenge prior to the request when the address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_edit_overload_2(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_edit_overload_2(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_edit_overload_2(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_edit_overload_3(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_edit_with_all_params_overload_3(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="compress_response", + action_parameters={"algorithms": [{"name": "none"}]}, + description="Disable compression when address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_edit_overload_3(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_edit_overload_3(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_edit_overload_3(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_edit_overload_4(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_edit_with_all_params_overload_4(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="execute", + action_parameters={ + "id": "4814384a9e5d4991b9815dcfc25d2f1f", + "matched_data": {"public_key": "iGqBmyIUxuWt1rvxoAharN9FUXneUBxA/Y19PyyrEG0="}, + "overrides": { + "action": "log", + "categories": [ + { + "action": "log", + "category": "directory-traversal", + "enabled": True, + "sensitivity_level": "default", + } + ], + "enabled": True, + "rules": [ + { + "action": "log", + "enabled": True, + "id": "8ac8bc2a661e475d940980f9317f28e1", + "score_threshold": 0, + "sensitivity_level": "default", + } + ], + "sensitivity_level": "default", + }, + }, + description="Execute the OWASP ruleset when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_edit_overload_4(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_edit_overload_4(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_edit_overload_4(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_edit_overload_5(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_edit_with_all_params_overload_5(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="js_challenge", + action_parameters={}, + description="Issue a non-interactive Javascript Challenge if the visitor had not solved a Interactive Challenge, Managed Challenge, or Javascript Challenge prior to the request when the address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_edit_overload_5(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_edit_overload_5(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_edit_overload_5(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_edit_overload_6(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_edit_with_all_params_overload_6(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="log", + action_parameters={}, + description="Log when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_edit_overload_6(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_edit_overload_6(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_edit_overload_6(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_edit_overload_7(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_edit_with_all_params_overload_7(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="managed_challenge", + action_parameters={}, + description="Issue a Managed Challenge if the visitor had not solved a Managed Challenge or Interactive Challenge prior to the request when the address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_edit_overload_7(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_edit_overload_7(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_edit_overload_7(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_edit_overload_8(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_edit_with_all_params_overload_8(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="redirect", + action_parameters={ + "from_list": { + "key": "http.request.full_uri", + "name": "list1", + }, + "from_value": { + "preserve_query_string": True, + "status_code": 301, + "target_url": {"value": "x"}, + }, + }, + description="Redirect when IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_edit_overload_8(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_edit_overload_8(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_edit_overload_8(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_edit_overload_9(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_edit_with_all_params_overload_9(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="rewrite", + action_parameters={ + "headers": { + "client-http-version": { + "expression": "http.request.version", + "operation": "set", + } + }, + "uri": { + "path": {"expression": 'regex_replace(http.request.uri.path, "/bar$", "/baz")'}, + "query": {"expression": 'regex_replace(http.request.uri.query, "foo=bar", "")'}, + }, + }, + description="Add a header when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_edit_overload_9(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_edit_overload_9(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_edit_overload_9(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_edit_overload_10(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_edit_with_all_params_overload_10(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="route", + action_parameters={ + "host_header": "static.example.com", + "origin": { + "host": "static.example.com", + "port": 1, + }, + "sni": {"value": "static.example.com"}, + }, + description="Select origin server when IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_edit_overload_10(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_edit_overload_10(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_edit_overload_10(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_edit_overload_11(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_edit_with_all_params_overload_11(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="score", + action_parameters={"increment": 3}, + description="Increment score when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_edit_overload_11(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_edit_overload_11(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_edit_overload_11(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_edit_overload_12(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_edit_with_all_params_overload_12(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="serve_error", + action_parameters={ + "content": '{"error": "1xxx error occurred"}\n', + "content_type": "application/json", + "status_code": 500, + }, + description="Serve a JSON response to api users on error", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_edit_overload_12(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_edit_overload_12(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_edit_overload_12(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_edit_overload_13(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_edit_with_all_params_overload_13(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="set_config", + action_parameters={ + "automatic_https_rewrites": True, + "autominify": { + "css": True, + "html": True, + "js": True, + }, + "bic": True, + "disable_apps": True, + "disable_zaraz": True, + "email_obfuscation": True, + "hotlink_protection": True, + "mirage": True, + "opportunistic_encryption": True, + "polish": "off", + "rocket_loader": True, + "security_level": "off", + "server_side_excludes": True, + "ssl": "off", + "sxg": True, + }, + description="Disable Zaraz when IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_edit_overload_13(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_edit_overload_13(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_edit_overload_13(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_edit_overload_14(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_edit_with_all_params_overload_14(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="skip", + action_parameters={ + "phases": ["http_request_firewall_custom"], + "products": ["bic"], + "rules": {"4814384a9e5d4991b9815dcfc25d2f1f": ["8ac8bc2a661e475d940980f9317f28e1"]}, + "ruleset": "current", + "rulesets": ["4814384a9e5d4991b9815dcfc25d2f1f"], + }, + description="Skip the current ruleset when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_edit_overload_14(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_edit_overload_14(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_edit_overload_14(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + def test_method_edit_overload_15(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_edit_with_all_params_overload_15(self, client: Cloudflare) -> None: + rule = client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_settings", + action_parameters={ + "additional_cacheable_ports": [0, 0, 0], + "browser_ttl": { + "default": 0, + "mode": "respect_origin", + }, + "cache": True, + "cache_key": { + "cache_by_device_type": True, + "cache_deception_armor": True, + "custom_key": { + "cookie": { + "check_presence": ["string", "string", "string"], + "include": ["string", "string", "string"], + }, + "header": { + "check_presence": ["string", "string", "string"], + "exclude_origin": True, + "include": ["string", "string", "string"], + }, + "host": {"resolved": True}, + "query_string": { + "exclude": { + "all": True, + "list": ["string", "string", "string"], + }, + "include": { + "all": True, + "list": ["string", "string", "string"], + }, + }, + "user": { + "device_type": True, + "geo": True, + "lang": True, + }, + }, + "ignore_query_strings_order": True, + }, + "cache_reserve": { + "eligible": True, + "min_file_size": 0, + }, + "edge_ttl": { + "default": 1, + "mode": "respect_origin", + "status_code_ttl": [ + { + "status_code_range": { + "from": 0, + "to": 0, + }, + "status_code_value": 0, + "value": 0, + }, + { + "status_code_range": { + "from": 0, + "to": 0, + }, + "status_code_value": 0, + "value": 0, + }, + { + "status_code_range": { + "from": 0, + "to": 0, + }, + "status_code_value": 0, + "value": 0, + }, + ], + }, + "origin_cache_control": True, + "origin_error_page_passthru": True, + "read_timeout": 900, + "respect_strong_etags": True, + "serve_stale": {"disable_stale_while_updating": True}, + }, + description="Set cache settings when the hostname address is not example.com", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_edit_overload_15(self, client: Cloudflare) -> None: + response = client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_edit_overload_15(self, client: Cloudflare) -> None: + with client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_edit_overload_15(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + +class TestAsyncRules: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="block", + action_parameters={ + "response": { + "content": '{\n "success": false,\n "error": "you have been blocked"\n}', + "content_type": "application/json", + "status_code": 400, + } + }, + description="Block when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="challenge", + action_parameters={}, + description="Issue an Interactive Challenge if the visitor had not solved an Interactive Challenge prior to the request when the address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_create_overload_3(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params_overload_3(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="compress_response", + action_parameters={"algorithms": [{"name": "none"}]}, + description="Disable compression when address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create_overload_3(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create_overload_3(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create_overload_3(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_create_overload_4(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params_overload_4(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="execute", + action_parameters={ + "id": "4814384a9e5d4991b9815dcfc25d2f1f", + "matched_data": {"public_key": "iGqBmyIUxuWt1rvxoAharN9FUXneUBxA/Y19PyyrEG0="}, + "overrides": { + "action": "log", + "categories": [ + { + "action": "log", + "category": "directory-traversal", + "enabled": True, + "sensitivity_level": "default", + } + ], + "enabled": True, + "rules": [ + { + "action": "log", + "enabled": True, + "id": "8ac8bc2a661e475d940980f9317f28e1", + "score_threshold": 0, + "sensitivity_level": "default", + } + ], + "sensitivity_level": "default", + }, + }, + description="Execute the OWASP ruleset when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create_overload_4(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create_overload_4(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create_overload_4(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_create_overload_5(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params_overload_5(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="js_challenge", + action_parameters={}, + description="Issue a non-interactive Javascript Challenge if the visitor had not solved a Interactive Challenge, Managed Challenge, or Javascript Challenge prior to the request when the address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create_overload_5(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create_overload_5(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create_overload_5(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_create_overload_6(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params_overload_6(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="log", + action_parameters={}, + description="Log when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create_overload_6(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create_overload_6(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create_overload_6(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_create_overload_7(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params_overload_7(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="managed_challenge", + action_parameters={}, + description="Issue a Managed Challenge if the visitor had not solved a Managed Challenge or Interactive Challenge prior to the request when the address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create_overload_7(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create_overload_7(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create_overload_7(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_create_overload_8(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params_overload_8(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="redirect", + action_parameters={ + "from_list": { + "key": "http.request.full_uri", + "name": "list1", + }, + "from_value": { + "preserve_query_string": True, + "status_code": 301, + "target_url": {"value": "x"}, + }, + }, + description="Redirect when IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create_overload_8(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create_overload_8(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create_overload_8(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_create_overload_9(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params_overload_9(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="rewrite", + action_parameters={ + "headers": { + "client-http-version": { + "expression": "http.request.version", + "operation": "set", + } + }, + "uri": { + "path": {"expression": 'regex_replace(http.request.uri.path, "/bar$", "/baz")'}, + "query": {"expression": 'regex_replace(http.request.uri.query, "foo=bar", "")'}, + }, + }, + description="Add a header when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create_overload_9(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create_overload_9(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create_overload_9(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_create_overload_10(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params_overload_10(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="route", + action_parameters={ + "host_header": "static.example.com", + "origin": { + "host": "static.example.com", + "port": 1, + }, + "sni": {"value": "static.example.com"}, + }, + description="Select origin server when IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create_overload_10(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create_overload_10(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create_overload_10(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_create_overload_11(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params_overload_11(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="score", + action_parameters={"increment": 3}, + description="Increment score when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create_overload_11(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create_overload_11(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create_overload_11(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_create_overload_12(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params_overload_12(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="serve_error", + action_parameters={ + "content": '{"error": "1xxx error occurred"}\n', + "content_type": "application/json", + "status_code": 500, + }, + description="Serve a JSON response to api users on error", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create_overload_12(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create_overload_12(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create_overload_12(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_create_overload_13(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params_overload_13(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="set_config", + action_parameters={ + "automatic_https_rewrites": True, + "autominify": { + "css": True, + "html": True, + "js": True, + }, + "bic": True, + "disable_apps": True, + "disable_zaraz": True, + "email_obfuscation": True, + "hotlink_protection": True, + "mirage": True, + "opportunistic_encryption": True, + "polish": "off", + "rocket_loader": True, + "security_level": "off", + "server_side_excludes": True, + "ssl": "off", + "sxg": True, + }, + description="Disable Zaraz when IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create_overload_13(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create_overload_13(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create_overload_13(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_create_overload_14(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params_overload_14(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="skip", + action_parameters={ + "phases": ["http_request_firewall_custom"], + "products": ["bic"], + "rules": {"4814384a9e5d4991b9815dcfc25d2f1f": ["8ac8bc2a661e475d940980f9317f28e1"]}, + "ruleset": "current", + "rulesets": ["4814384a9e5d4991b9815dcfc25d2f1f"], + }, + description="Skip the current ruleset when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create_overload_14(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create_overload_14(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create_overload_14(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_create_overload_15(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_create_with_all_params_overload_15(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="set_cache_settings", + action_parameters={ + "additional_cacheable_ports": [0, 0, 0], + "browser_ttl": { + "default": 0, + "mode": "respect_origin", + }, + "cache": True, + "cache_key": { + "cache_by_device_type": True, + "cache_deception_armor": True, + "custom_key": { + "cookie": { + "check_presence": ["string", "string", "string"], + "include": ["string", "string", "string"], + }, + "header": { + "check_presence": ["string", "string", "string"], + "exclude_origin": True, + "include": ["string", "string", "string"], + }, + "host": {"resolved": True}, + "query_string": { + "exclude": { + "all": True, + "list": ["string", "string", "string"], + }, + "include": { + "all": True, + "list": ["string", "string", "string"], + }, + }, + "user": { + "device_type": True, + "geo": True, + "lang": True, + }, + }, + "ignore_query_strings_order": True, + }, + "cache_reserve": { + "eligible": True, + "min_file_size": 0, + }, + "edge_ttl": { + "default": 1, + "mode": "respect_origin", + "status_code_ttl": [ + { + "status_code_range": { + "from": 0, + "to": 0, + }, + "status_code_value": 0, + "value": 0, + }, + { + "status_code_range": { + "from": 0, + "to": 0, + }, + "status_code_value": 0, + "value": 0, + }, + { + "status_code_range": { + "from": 0, + "to": 0, + }, + "status_code_value": 0, + "value": 0, + }, + ], + }, + "origin_cache_control": True, + "origin_error_page_passthru": True, + "read_timeout": 900, + "respect_strong_etags": True, + "serve_stale": {"disable_stale_while_updating": True}, + }, + description="Set cache settings when the hostname address is not example.com", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_create_overload_15(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleCreateResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_create_overload_15(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.create( + "2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.delete( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.delete( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.delete( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleDeleteResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - def test_method_edit_with_all_params_overload_1(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.edit( + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.delete( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.delete( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.delete( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.delete( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.delete( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_edit_overload_1(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_edit_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -513,8 +4657,202 @@ def test_method_edit_with_all_params_overload_1(self, client: Cloudflare) -> Non @pytest.mark.skip() @parametrize - def test_raw_response_edit_overload_1(self, client: Cloudflare) -> None: - response = client.rulesets.rules.with_raw_response.edit( + async def test_raw_response_edit_overload_1(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_edit_overload_1(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_edit_overload_1(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_edit_overload_2(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_edit_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="challenge", + action_parameters={}, + description="Issue an Interactive Challenge if the visitor had not solved an Interactive Challenge prior to the request when the address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_edit_overload_2(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_edit_overload_2(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + rule = await response.parse() + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_edit_overload_2(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_edit_overload_3(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_edit_with_all_params_overload_3(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", + account_id="string", + zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="compress_response", + action_parameters={"algorithms": [{"name": "none"}]}, + description="Disable compression when address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", + ) + assert_matches_type(RuleEditResponse, rule, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_edit_overload_3(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -523,13 +4861,13 @@ def test_raw_response_edit_overload_1(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() + rule = await response.parse() assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - def test_streaming_response_edit_overload_1(self, client: Cloudflare) -> None: - with client.rulesets.rules.with_streaming_response.edit( + async def test_streaming_response_edit_overload_3(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -538,16 +4876,16 @@ def test_streaming_response_edit_overload_1(self, client: Cloudflare) -> None: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() + rule = await response.parse() assert_matches_type(RuleEditResponse, rule, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip() @parametrize - def test_path_params_edit_overload_1(self, client: Cloudflare) -> None: + async def test_path_params_edit_overload_3(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( + await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="", account_id="string", @@ -555,7 +4893,7 @@ def test_path_params_edit_overload_1(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( + await async_client.rulesets.rules.with_raw_response.edit( "", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -563,7 +4901,7 @@ def test_path_params_edit_overload_1(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( + await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="", @@ -571,7 +4909,7 @@ def test_path_params_edit_overload_1(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( + await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -580,8 +4918,8 @@ def test_path_params_edit_overload_1(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize - def test_method_edit_overload_2(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.edit( + async def test_method_edit_overload_4(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -591,8 +4929,8 @@ def test_method_edit_overload_2(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize - def test_method_edit_with_all_params_overload_2(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.edit( + async def test_method_edit_with_all_params_overload_4(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -635,8 +4973,8 @@ def test_method_edit_with_all_params_overload_2(self, client: Cloudflare) -> Non @pytest.mark.skip() @parametrize - def test_raw_response_edit_overload_2(self, client: Cloudflare) -> None: - response = client.rulesets.rules.with_raw_response.edit( + async def test_raw_response_edit_overload_4(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -645,13 +4983,13 @@ def test_raw_response_edit_overload_2(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() + rule = await response.parse() assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - def test_streaming_response_edit_overload_2(self, client: Cloudflare) -> None: - with client.rulesets.rules.with_streaming_response.edit( + async def test_streaming_response_edit_overload_4(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -660,16 +4998,16 @@ def test_streaming_response_edit_overload_2(self, client: Cloudflare) -> None: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() + rule = await response.parse() assert_matches_type(RuleEditResponse, rule, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip() @parametrize - def test_path_params_edit_overload_2(self, client: Cloudflare) -> None: + async def test_path_params_edit_overload_4(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( + await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="", account_id="string", @@ -677,7 +5015,7 @@ def test_path_params_edit_overload_2(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( + await async_client.rulesets.rules.with_raw_response.edit( "", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -685,7 +5023,7 @@ def test_path_params_edit_overload_2(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( + await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="", @@ -693,7 +5031,7 @@ def test_path_params_edit_overload_2(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( + await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -702,8 +5040,8 @@ def test_path_params_edit_overload_2(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize - def test_method_edit_overload_3(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.edit( + async def test_method_edit_overload_5(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -713,16 +5051,16 @@ def test_method_edit_overload_3(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize - def test_method_edit_with_all_params_overload_3(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.edit( + async def test_method_edit_with_all_params_overload_5(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", id="3a03d665bac047339bb530ecb439a90d", - action="log", + action="js_challenge", action_parameters={}, - description="Log when the IP address is not 1.1.1.1", + description="Issue a non-interactive Javascript Challenge if the visitor had not solved a Interactive Challenge, Managed Challenge, or Javascript Challenge prior to the request when the address is not 1.1.1.1", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -732,8 +5070,8 @@ def test_method_edit_with_all_params_overload_3(self, client: Cloudflare) -> Non @pytest.mark.skip() @parametrize - def test_raw_response_edit_overload_3(self, client: Cloudflare) -> None: - response = client.rulesets.rules.with_raw_response.edit( + async def test_raw_response_edit_overload_5(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -742,13 +5080,13 @@ def test_raw_response_edit_overload_3(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() + rule = await response.parse() assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - def test_streaming_response_edit_overload_3(self, client: Cloudflare) -> None: - with client.rulesets.rules.with_streaming_response.edit( + async def test_streaming_response_edit_overload_5(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -757,16 +5095,16 @@ def test_streaming_response_edit_overload_3(self, client: Cloudflare) -> None: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() + rule = await response.parse() assert_matches_type(RuleEditResponse, rule, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip() @parametrize - def test_path_params_edit_overload_3(self, client: Cloudflare) -> None: + async def test_path_params_edit_overload_5(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( + await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="", account_id="string", @@ -774,7 +5112,7 @@ def test_path_params_edit_overload_3(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( + await async_client.rulesets.rules.with_raw_response.edit( "", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -782,7 +5120,7 @@ def test_path_params_edit_overload_3(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( + await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="", @@ -790,7 +5128,7 @@ def test_path_params_edit_overload_3(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( + await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -799,8 +5137,8 @@ def test_path_params_edit_overload_3(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize - def test_method_edit_overload_4(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.edit( + async def test_method_edit_overload_6(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -810,22 +5148,16 @@ def test_method_edit_overload_4(self, client: Cloudflare) -> None: @pytest.mark.skip() @parametrize - def test_method_edit_with_all_params_overload_4(self, client: Cloudflare) -> None: - rule = client.rulesets.rules.edit( + async def test_method_edit_with_all_params_overload_6(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", id="3a03d665bac047339bb530ecb439a90d", - action="skip", - action_parameters={ - "phases": ["http_request_firewall_custom"], - "products": ["bic"], - "rules": {"4814384a9e5d4991b9815dcfc25d2f1f": ["8ac8bc2a661e475d940980f9317f28e1"]}, - "ruleset": "current", - "rulesets": ["4814384a9e5d4991b9815dcfc25d2f1f"], - }, - description="Skip the current ruleset when the IP address is not 1.1.1.1", + action="log", + action_parameters={}, + description="Log when the IP address is not 1.1.1.1", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -835,8 +5167,8 @@ def test_method_edit_with_all_params_overload_4(self, client: Cloudflare) -> Non @pytest.mark.skip() @parametrize - def test_raw_response_edit_overload_4(self, client: Cloudflare) -> None: - response = client.rulesets.rules.with_raw_response.edit( + async def test_raw_response_edit_overload_6(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -845,13 +5177,13 @@ def test_raw_response_edit_overload_4(self, client: Cloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() + rule = await response.parse() assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - def test_streaming_response_edit_overload_4(self, client: Cloudflare) -> None: - with client.rulesets.rules.with_streaming_response.edit( + async def test_streaming_response_edit_overload_6(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -860,16 +5192,16 @@ def test_streaming_response_edit_overload_4(self, client: Cloudflare) -> None: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" - rule = response.parse() + rule = await response.parse() assert_matches_type(RuleEditResponse, rule, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip() @parametrize - def test_path_params_edit_overload_4(self, client: Cloudflare) -> None: + async def test_path_params_edit_overload_6(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( + await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="", account_id="string", @@ -877,7 +5209,7 @@ def test_path_params_edit_overload_4(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( + await async_client.rulesets.rules.with_raw_response.edit( "", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -885,7 +5217,7 @@ def test_path_params_edit_overload_4(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( + await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="", @@ -893,56 +5225,49 @@ def test_path_params_edit_overload_4(self, client: Cloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - client.rulesets.rules.with_raw_response.edit( + await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="", ) - -class TestAsyncRules: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip() @parametrize - async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", + async def test_method_edit_overload_7(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - async def test_method_create_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", + async def test_method_edit_with_all_params_overload_7(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", id="3a03d665bac047339bb530ecb439a90d", - action="block", - action_parameters={ - "response": { - "content": '{\n "success": false,\n "error": "you have been blocked"\n}', - "content_type": "application/json", - "status_code": 400, - } - }, - description="Block when the IP address is not 1.1.1.1", + action="managed_challenge", + action_parameters={}, + description="Issue a Managed Challenge if the visitor had not solved a Managed Challenge or Interactive Challenge prior to the request when the address is not 1.1.1.1", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, ref="my_ref", ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: - response = await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", + async def test_raw_response_edit_overload_7(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) @@ -950,13 +5275,14 @@ async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: - async with async_client.rulesets.rules.with_streaming_response.create( - "2f2feab2026849078ba485f918791bdc", + async def test_streaming_response_edit_overload_7(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) as response: @@ -964,92 +5290,91 @@ async def test_streaming_response_create_overload_1(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip() @parametrize - async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_edit_overload_7(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( "", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="", zone_id="string", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="", ) @pytest.mark.skip() @parametrize - async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", + async def test_method_edit_overload_8(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - async def test_method_create_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", + async def test_method_edit_with_all_params_overload_8(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", id="3a03d665bac047339bb530ecb439a90d", - action="execute", + action="redirect", action_parameters={ - "id": "4814384a9e5d4991b9815dcfc25d2f1f", - "matched_data": {"public_key": "iGqBmyIUxuWt1rvxoAharN9FUXneUBxA/Y19PyyrEG0="}, - "overrides": { - "action": "log", - "categories": [ - { - "action": "log", - "category": "directory-traversal", - "enabled": True, - "sensitivity_level": "default", - } - ], - "enabled": True, - "rules": [ - { - "action": "log", - "enabled": True, - "id": "8ac8bc2a661e475d940980f9317f28e1", - "score_threshold": 0, - "sensitivity_level": "default", - } - ], - "sensitivity_level": "default", + "from_list": { + "key": "http.request.full_uri", + "name": "list1", + }, + "from_value": { + "preserve_query_string": True, + "status_code": 301, + "target_url": {"value": "x"}, }, }, - description="Execute the OWASP ruleset when the IP address is not 1.1.1.1", + description="Redirect when IP address is not 1.1.1.1", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, ref="my_ref", ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: - response = await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", + async def test_raw_response_edit_overload_8(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) @@ -1057,13 +5382,14 @@ async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: - async with async_client.rulesets.rules.with_streaming_response.create( - "2f2feab2026849078ba485f918791bdc", + async def test_streaming_response_edit_overload_8(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) as response: @@ -1071,67 +5397,92 @@ async def test_streaming_response_create_overload_2(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) assert cast(Any, response.is_closed) is True - @pytest.mark.skip() - @parametrize - async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( + @pytest.mark.skip() + @parametrize + async def test_path_params_edit_overload_8(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( "", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="", zone_id="string", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="", ) @pytest.mark.skip() @parametrize - async def test_method_create_overload_3(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", + async def test_method_edit_overload_9(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - async def test_method_create_with_all_params_overload_3(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", + async def test_method_edit_with_all_params_overload_9(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", id="3a03d665bac047339bb530ecb439a90d", - action="log", - action_parameters={}, - description="Log when the IP address is not 1.1.1.1", + action="rewrite", + action_parameters={ + "headers": { + "client-http-version": { + "expression": "http.request.version", + "operation": "set", + } + }, + "uri": { + "path": {"expression": 'regex_replace(http.request.uri.path, "/bar$", "/baz")'}, + "query": {"expression": 'regex_replace(http.request.uri.query, "foo=bar", "")'}, + }, + }, + description="Add a header when the IP address is not 1.1.1.1", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, ref="my_ref", ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - async def test_raw_response_create_overload_3(self, async_client: AsyncCloudflare) -> None: - response = await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", + async def test_raw_response_edit_overload_9(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) @@ -1139,13 +5490,14 @@ async def test_raw_response_create_overload_3(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - async def test_streaming_response_create_overload_3(self, async_client: AsyncCloudflare) -> None: - async with async_client.rulesets.rules.with_streaming_response.create( - "2f2feab2026849078ba485f918791bdc", + async def test_streaming_response_edit_overload_9(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) as response: @@ -1153,73 +5505,88 @@ async def test_streaming_response_create_overload_3(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip() @parametrize - async def test_path_params_create_overload_3(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_edit_overload_9(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( "", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="", zone_id="string", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="", ) @pytest.mark.skip() @parametrize - async def test_method_create_overload_4(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", + async def test_method_edit_overload_10(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - async def test_method_create_with_all_params_overload_4(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.create( - "2f2feab2026849078ba485f918791bdc", + async def test_method_edit_with_all_params_overload_10(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", id="3a03d665bac047339bb530ecb439a90d", - action="skip", + action="route", action_parameters={ - "phases": ["http_request_firewall_custom"], - "products": ["bic"], - "rules": {"4814384a9e5d4991b9815dcfc25d2f1f": ["8ac8bc2a661e475d940980f9317f28e1"]}, - "ruleset": "current", - "rulesets": ["4814384a9e5d4991b9815dcfc25d2f1f"], + "host_header": "static.example.com", + "origin": { + "host": "static.example.com", + "port": 1, + }, + "sni": {"value": "static.example.com"}, }, - description="Skip the current ruleset when the IP address is not 1.1.1.1", + description="Select origin server when IP address is not 1.1.1.1", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, ref="my_ref", ) - assert_matches_type(RuleCreateResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - async def test_raw_response_create_overload_4(self, async_client: AsyncCloudflare) -> None: - response = await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", + async def test_raw_response_edit_overload_10(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) @@ -1227,13 +5594,14 @@ async def test_raw_response_create_overload_4(self, async_client: AsyncCloudflar assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - async def test_streaming_response_create_overload_4(self, async_client: AsyncCloudflare) -> None: - async with async_client.rulesets.rules.with_streaming_response.create( - "2f2feab2026849078ba485f918791bdc", + async def test_streaming_response_edit_overload_10(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) as response: @@ -1241,60 +5609,79 @@ async def test_streaming_response_create_overload_4(self, async_client: AsyncClo assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(RuleCreateResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip() @parametrize - async def test_path_params_create_overload_4(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_edit_overload_10(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="", + account_id="string", + zone_id="string", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): + await async_client.rulesets.rules.with_raw_response.edit( "", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="", zone_id="string", ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.create( - "2f2feab2026849078ba485f918791bdc", + await async_client.rulesets.rules.with_raw_response.edit( + "3a03d665bac047339bb530ecb439a90d", + ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="", ) @pytest.mark.skip() @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.delete( + async def test_method_edit_overload_11(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", ) - assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - async def test_method_delete_with_all_params(self, async_client: AsyncCloudflare) -> None: - rule = await async_client.rulesets.rules.delete( + async def test_method_edit_with_all_params_overload_11(self, async_client: AsyncCloudflare) -> None: + rule = await async_client.rulesets.rules.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", + id="3a03d665bac047339bb530ecb439a90d", + action="score", + action_parameters={"increment": 3}, + description="Increment score when the IP address is not 1.1.1.1", + enabled=True, + expression="ip.src ne 1.1.1.1", + logging={"enabled": True}, + ref="my_ref", ) - assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.rulesets.rules.with_raw_response.delete( + async def test_raw_response_edit_overload_11(self, async_client: AsyncCloudflare) -> None: + response = await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -1304,12 +5691,12 @@ async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) @pytest.mark.skip() @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.rulesets.rules.with_streaming_response.delete( + async def test_streaming_response_edit_overload_11(self, async_client: AsyncCloudflare) -> None: + async with async_client.rulesets.rules.with_streaming_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -1319,15 +5706,15 @@ async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> assert response.http_request.headers.get("X-Stainless-Lang") == "python" rule = await response.parse() - assert_matches_type(RuleDeleteResponse, rule, path=["response"]) + assert_matches_type(RuleEditResponse, rule, path=["response"]) assert cast(Any, response.is_closed) is True @pytest.mark.skip() @parametrize - async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_edit_overload_11(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.delete( + await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="", account_id="string", @@ -1335,7 +5722,7 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `rule_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.delete( + await async_client.rulesets.rules.with_raw_response.edit( "", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -1343,7 +5730,7 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.delete( + await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="", @@ -1351,7 +5738,7 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: ) with pytest.raises(ValueError, match=r"Expected a non-empty value for `zone_id` but received ''"): - await async_client.rulesets.rules.with_raw_response.delete( + await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", @@ -1360,7 +5747,7 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: @pytest.mark.skip() @parametrize - async def test_method_edit_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_method_edit_overload_12(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -1371,22 +5758,20 @@ async def test_method_edit_overload_1(self, async_client: AsyncCloudflare) -> No @pytest.mark.skip() @parametrize - async def test_method_edit_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_method_edit_with_all_params_overload_12(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", id="3a03d665bac047339bb530ecb439a90d", - action="block", + action="serve_error", action_parameters={ - "response": { - "content": '{\n "success": false,\n "error": "you have been blocked"\n}', - "content_type": "application/json", - "status_code": 400, - } + "content": '{"error": "1xxx error occurred"}\n', + "content_type": "application/json", + "status_code": 500, }, - description="Block when the IP address is not 1.1.1.1", + description="Serve a JSON response to api users on error", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -1396,7 +5781,7 @@ async def test_method_edit_with_all_params_overload_1(self, async_client: AsyncC @pytest.mark.skip() @parametrize - async def test_raw_response_edit_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_edit_overload_12(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -1411,7 +5796,7 @@ async def test_raw_response_edit_overload_1(self, async_client: AsyncCloudflare) @pytest.mark.skip() @parametrize - async def test_streaming_response_edit_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_edit_overload_12(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -1428,7 +5813,7 @@ async def test_streaming_response_edit_overload_1(self, async_client: AsyncCloud @pytest.mark.skip() @parametrize - async def test_path_params_edit_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_edit_overload_12(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", @@ -1463,7 +5848,7 @@ async def test_path_params_edit_overload_1(self, async_client: AsyncCloudflare) @pytest.mark.skip() @parametrize - async def test_method_edit_overload_2(self, async_client: AsyncCloudflare) -> None: + async def test_method_edit_overload_13(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -1474,41 +5859,36 @@ async def test_method_edit_overload_2(self, async_client: AsyncCloudflare) -> No @pytest.mark.skip() @parametrize - async def test_method_edit_with_all_params_overload_2(self, async_client: AsyncCloudflare) -> None: + async def test_method_edit_with_all_params_overload_13(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", id="3a03d665bac047339bb530ecb439a90d", - action="execute", + action="set_config", action_parameters={ - "id": "4814384a9e5d4991b9815dcfc25d2f1f", - "matched_data": {"public_key": "iGqBmyIUxuWt1rvxoAharN9FUXneUBxA/Y19PyyrEG0="}, - "overrides": { - "action": "log", - "categories": [ - { - "action": "log", - "category": "directory-traversal", - "enabled": True, - "sensitivity_level": "default", - } - ], - "enabled": True, - "rules": [ - { - "action": "log", - "enabled": True, - "id": "8ac8bc2a661e475d940980f9317f28e1", - "score_threshold": 0, - "sensitivity_level": "default", - } - ], - "sensitivity_level": "default", + "automatic_https_rewrites": True, + "autominify": { + "css": True, + "html": True, + "js": True, }, + "bic": True, + "disable_apps": True, + "disable_zaraz": True, + "email_obfuscation": True, + "hotlink_protection": True, + "mirage": True, + "opportunistic_encryption": True, + "polish": "off", + "rocket_loader": True, + "security_level": "off", + "server_side_excludes": True, + "ssl": "off", + "sxg": True, }, - description="Execute the OWASP ruleset when the IP address is not 1.1.1.1", + description="Disable Zaraz when IP address is not 1.1.1.1", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -1518,7 +5898,7 @@ async def test_method_edit_with_all_params_overload_2(self, async_client: AsyncC @pytest.mark.skip() @parametrize - async def test_raw_response_edit_overload_2(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_edit_overload_13(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -1533,7 +5913,7 @@ async def test_raw_response_edit_overload_2(self, async_client: AsyncCloudflare) @pytest.mark.skip() @parametrize - async def test_streaming_response_edit_overload_2(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_edit_overload_13(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -1550,7 +5930,7 @@ async def test_streaming_response_edit_overload_2(self, async_client: AsyncCloud @pytest.mark.skip() @parametrize - async def test_path_params_edit_overload_2(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_edit_overload_13(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", @@ -1585,7 +5965,7 @@ async def test_path_params_edit_overload_2(self, async_client: AsyncCloudflare) @pytest.mark.skip() @parametrize - async def test_method_edit_overload_3(self, async_client: AsyncCloudflare) -> None: + async def test_method_edit_overload_14(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -1596,16 +5976,22 @@ async def test_method_edit_overload_3(self, async_client: AsyncCloudflare) -> No @pytest.mark.skip() @parametrize - async def test_method_edit_with_all_params_overload_3(self, async_client: AsyncCloudflare) -> None: + async def test_method_edit_with_all_params_overload_14(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", id="3a03d665bac047339bb530ecb439a90d", - action="log", - action_parameters={}, - description="Log when the IP address is not 1.1.1.1", + action="skip", + action_parameters={ + "phases": ["http_request_firewall_custom"], + "products": ["bic"], + "rules": {"4814384a9e5d4991b9815dcfc25d2f1f": ["8ac8bc2a661e475d940980f9317f28e1"]}, + "ruleset": "current", + "rulesets": ["4814384a9e5d4991b9815dcfc25d2f1f"], + }, + description="Skip the current ruleset when the IP address is not 1.1.1.1", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -1615,7 +6001,7 @@ async def test_method_edit_with_all_params_overload_3(self, async_client: AsyncC @pytest.mark.skip() @parametrize - async def test_raw_response_edit_overload_3(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_edit_overload_14(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -1630,7 +6016,7 @@ async def test_raw_response_edit_overload_3(self, async_client: AsyncCloudflare) @pytest.mark.skip() @parametrize - async def test_streaming_response_edit_overload_3(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_edit_overload_14(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -1647,7 +6033,7 @@ async def test_streaming_response_edit_overload_3(self, async_client: AsyncCloud @pytest.mark.skip() @parametrize - async def test_path_params_edit_overload_3(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_edit_overload_14(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", @@ -1682,7 +6068,7 @@ async def test_path_params_edit_overload_3(self, async_client: AsyncCloudflare) @pytest.mark.skip() @parametrize - async def test_method_edit_overload_4(self, async_client: AsyncCloudflare) -> None: + async def test_method_edit_overload_15(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -1693,22 +6079,94 @@ async def test_method_edit_overload_4(self, async_client: AsyncCloudflare) -> No @pytest.mark.skip() @parametrize - async def test_method_edit_with_all_params_overload_4(self, async_client: AsyncCloudflare) -> None: + async def test_method_edit_with_all_params_overload_15(self, async_client: AsyncCloudflare) -> None: rule = await async_client.rulesets.rules.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", account_id="string", zone_id="string", id="3a03d665bac047339bb530ecb439a90d", - action="skip", + action="set_cache_settings", action_parameters={ - "phases": ["http_request_firewall_custom"], - "products": ["bic"], - "rules": {"4814384a9e5d4991b9815dcfc25d2f1f": ["8ac8bc2a661e475d940980f9317f28e1"]}, - "ruleset": "current", - "rulesets": ["4814384a9e5d4991b9815dcfc25d2f1f"], + "additional_cacheable_ports": [0, 0, 0], + "browser_ttl": { + "default": 0, + "mode": "respect_origin", + }, + "cache": True, + "cache_key": { + "cache_by_device_type": True, + "cache_deception_armor": True, + "custom_key": { + "cookie": { + "check_presence": ["string", "string", "string"], + "include": ["string", "string", "string"], + }, + "header": { + "check_presence": ["string", "string", "string"], + "exclude_origin": True, + "include": ["string", "string", "string"], + }, + "host": {"resolved": True}, + "query_string": { + "exclude": { + "all": True, + "list": ["string", "string", "string"], + }, + "include": { + "all": True, + "list": ["string", "string", "string"], + }, + }, + "user": { + "device_type": True, + "geo": True, + "lang": True, + }, + }, + "ignore_query_strings_order": True, + }, + "cache_reserve": { + "eligible": True, + "min_file_size": 0, + }, + "edge_ttl": { + "default": 1, + "mode": "respect_origin", + "status_code_ttl": [ + { + "status_code_range": { + "from": 0, + "to": 0, + }, + "status_code_value": 0, + "value": 0, + }, + { + "status_code_range": { + "from": 0, + "to": 0, + }, + "status_code_value": 0, + "value": 0, + }, + { + "status_code_range": { + "from": 0, + "to": 0, + }, + "status_code_value": 0, + "value": 0, + }, + ], + }, + "origin_cache_control": True, + "origin_error_page_passthru": True, + "read_timeout": 900, + "respect_strong_etags": True, + "serve_stale": {"disable_stale_while_updating": True}, }, - description="Skip the current ruleset when the IP address is not 1.1.1.1", + description="Set cache settings when the hostname address is not example.com", enabled=True, expression="ip.src ne 1.1.1.1", logging={"enabled": True}, @@ -1718,7 +6176,7 @@ async def test_method_edit_with_all_params_overload_4(self, async_client: AsyncC @pytest.mark.skip() @parametrize - async def test_raw_response_edit_overload_4(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_edit_overload_15(self, async_client: AsyncCloudflare) -> None: response = await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -1733,7 +6191,7 @@ async def test_raw_response_edit_overload_4(self, async_client: AsyncCloudflare) @pytest.mark.skip() @parametrize - async def test_streaming_response_edit_overload_4(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_edit_overload_15(self, async_client: AsyncCloudflare) -> None: async with async_client.rulesets.rules.with_streaming_response.edit( "3a03d665bac047339bb530ecb439a90d", ruleset_id="2f2feab2026849078ba485f918791bdc", @@ -1750,7 +6208,7 @@ async def test_streaming_response_edit_overload_4(self, async_client: AsyncCloud @pytest.mark.skip() @parametrize - async def test_path_params_edit_overload_4(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_edit_overload_15(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ruleset_id` but received ''"): await async_client.rulesets.rules.with_raw_response.edit( "3a03d665bac047339bb530ecb439a90d",