Skip to content

Commit

Permalink
Merge pull request #1394 from iveelsm/mikey/cache-reserve-cache-rule
Browse files Browse the repository at this point in the history
Add support for Cache Reserve Configuration in the Rulesets API
  • Loading branch information
jacobbednarz authored Sep 11, 2023
2 parents 4298a09 + 3ef5edd commit e1a7432
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/1394.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release_note:enhancement
rulesets: Add support for Cache Reserve configuration via the Rulesets/Cache Rules API
```
6 changes: 6 additions & 0 deletions rulesets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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"`
Expand Down
10 changes: 9 additions & 1 deletion rulesets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e1a7432

Please sign in to comment.