From 3ef5edd03f3fc17c3b3e214e286b8957c60c81b1 Mon Sep 17 00:00:00 2001 From: Mikey Sleevi Date: Sun, 10 Sep 2023 18:27:36 -0600 Subject: [PATCH] Add support for Cache Reserve Configuration in the Rulesets API --- .changelog/1394.txt | 3 +++ rulesets.go | 6 ++++++ rulesets_test.go | 10 +++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 .changelog/1394.txt diff --git a/.changelog/1394.txt b/.changelog/1394.txt new file mode 100644 index 00000000000..c2afb6cf7d7 --- /dev/null +++ b/.changelog/1394.txt @@ -0,0 +1,3 @@ +```release_note:enhancement +rulesets: Add support for Cache Reserve configuration via the Rulesets/Cache Rules API +``` \ No newline at end of file diff --git a/rulesets.go b/rulesets.go index d000ea7bb48..c8a476251a7 100644 --- a/rulesets.go +++ b/rulesets.go @@ -237,6 +237,7 @@ type RulesetRuleActionParameters struct { CacheKey *RulesetRuleActionParametersCacheKey `json:"cache_key,omitempty"` OriginCacheControl *bool `json:"origin_cache_control,omitempty"` OriginErrorPagePassthru *bool `json:"origin_error_page_passthru,omitempty"` + CacheReserve *RulesetRuleActionParametersCacheReserve `json:"cache_reserve,omitempty"` FromList *RulesetRuleActionParametersFromList `json:"from_list,omitempty"` FromValue *RulesetRuleActionParametersFromValue `json:"from_value,omitempty"` AutomaticHTTPSRewrites *bool `json:"automatic_https_rewrites,omitempty"` @@ -316,6 +317,11 @@ type RulesetRuleActionParametersCacheKey struct { CustomKey *RulesetRuleActionParametersCustomKey `json:"custom_key,omitempty"` } +type RulesetRuleActionParametersCacheReserve struct { + Eligible *bool `json:"eligible,omitempty"` + MinimumFileSize *uint `json:"minimum_file_size,omitempty"` +} + type RulesetRuleActionParametersCustomKey struct { Query *RulesetRuleActionParametersCustomKeyQuery `json:"query_string,omitempty"` Header *RulesetRuleActionParametersCustomKeyHeader `json:"header,omitempty"` diff --git a/rulesets_test.go b/rulesets_test.go index 16fafeeddef..91f432529ec 100644 --- a/rulesets_test.go +++ b/rulesets_test.go @@ -244,7 +244,11 @@ func TestGetRuleset_SetCacheSettings(t *testing.T) { "additional_cacheable_ports": [1,2,3,4], "origin_cache_control": true, "read_timeout": 1000, - "origin_error_page_passthru":true + "origin_error_page_passthru":true, + "cache_reserve": { + "eligible": true, + "minimum_file_size": 1000 + } }, "description": "Set all available cache settings in one rule", "last_updated": "2020-12-18T09:28:09.655749Z", @@ -331,6 +335,10 @@ func TestGetRuleset_SetCacheSettings(t *testing.T) { OriginCacheControl: BoolPtr(true), ReadTimeout: UintPtr(1000), OriginErrorPagePassthru: BoolPtr(true), + CacheReserve: &RulesetRuleActionParametersCacheReserve{ + Eligible: BoolPtr(true), + MinimumFileSize: UintPtr(1000), + }, }, Description: "Set all available cache settings in one rule", LastUpdated: &lastUpdated,