Skip to content

Commit

Permalink
Merge pull request #1375 from iveelsm/mikey/additional-cacheable
Browse files Browse the repository at this point in the history
Add support for additional cacheable ports in the Rulesets API
  • Loading branch information
jacobbednarz authored Aug 28, 2023
2 parents 8f47cb0 + 994158b commit ac0c135
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 53 deletions.
3 changes: 3 additions & 0 deletions .changelog/1375.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release_note:enhancement
rulesets: Add support for Additional Cacheable Ports configuration via the Rulesets/Cache Rules API
```
101 changes: 51 additions & 50 deletions rulesets.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,56 +206,57 @@ type RulesetActionParametersLogCustomField struct {
// RulesetRuleActionParameters specifies the action parameters for a Ruleset
// rule.
type RulesetRuleActionParameters struct {
ID string `json:"id,omitempty"`
Ruleset string `json:"ruleset,omitempty"`
Rulesets []string `json:"rulesets,omitempty"`
Rules map[string][]string `json:"rules,omitempty"`
Increment int `json:"increment,omitempty"`
URI *RulesetRuleActionParametersURI `json:"uri,omitempty"`
Headers map[string]RulesetRuleActionParametersHTTPHeader `json:"headers,omitempty"`
Products []string `json:"products,omitempty"`
Phases []string `json:"phases,omitempty"`
Overrides *RulesetRuleActionParametersOverrides `json:"overrides,omitempty"`
MatchedData *RulesetRuleActionParametersMatchedData `json:"matched_data,omitempty"`
Version *string `json:"version,omitempty"`
Response *RulesetRuleActionParametersBlockResponse `json:"response,omitempty"`
HostHeader string `json:"host_header,omitempty"`
Origin *RulesetRuleActionParametersOrigin `json:"origin,omitempty"`
SNI *RulesetRuleActionParametersSni `json:"sni,omitempty"`
RequestFields []RulesetActionParametersLogCustomField `json:"request_fields,omitempty"`
ResponseFields []RulesetActionParametersLogCustomField `json:"response_fields,omitempty"`
CookieFields []RulesetActionParametersLogCustomField `json:"cookie_fields,omitempty"`
Cache *bool `json:"cache,omitempty"`
EdgeTTL *RulesetRuleActionParametersEdgeTTL `json:"edge_ttl,omitempty"`
BrowserTTL *RulesetRuleActionParametersBrowserTTL `json:"browser_ttl,omitempty"`
ServeStale *RulesetRuleActionParametersServeStale `json:"serve_stale,omitempty"`
Content string `json:"content,omitempty"`
ContentType string `json:"content_type,omitempty"`
StatusCode uint16 `json:"status_code,omitempty"`
RespectStrongETags *bool `json:"respect_strong_etags,omitempty"`
CacheKey *RulesetRuleActionParametersCacheKey `json:"cache_key,omitempty"`
OriginCacheControl *bool `json:"origin_cache_control,omitempty"`
OriginErrorPagePassthru *bool `json:"origin_error_page_passthru,omitempty"`
FromList *RulesetRuleActionParametersFromList `json:"from_list,omitempty"`
FromValue *RulesetRuleActionParametersFromValue `json:"from_value,omitempty"`
AutomaticHTTPSRewrites *bool `json:"automatic_https_rewrites,omitempty"`
AutoMinify *RulesetRuleActionParametersAutoMinify `json:"autominify,omitempty"`
BrowserIntegrityCheck *bool `json:"bic,omitempty"`
DisableApps *bool `json:"disable_apps,omitempty"`
DisableZaraz *bool `json:"disable_zaraz,omitempty"`
DisableRailgun *bool `json:"disable_railgun,omitempty"`
EmailObfuscation *bool `json:"email_obfuscation,omitempty"`
Mirage *bool `json:"mirage,omitempty"`
OpportunisticEncryption *bool `json:"opportunistic_encryption,omitempty"`
Polish *Polish `json:"polish,omitempty"`
ReadTimeout *uint `json:"read_timeout,omitempty"`
RocketLoader *bool `json:"rocket_loader,omitempty"`
SecurityLevel *SecurityLevel `json:"security_level,omitempty"`
ServerSideExcludes *bool `json:"server_side_excludes,omitempty"`
SSL *SSL `json:"ssl,omitempty"`
SXG *bool `json:"sxg,omitempty"`
HotLinkProtection *bool `json:"hotlink_protection,omitempty"`
Algorithms []RulesetRuleActionParametersCompressionAlgorithm `json:"algorithms,omitempty"`
ID string `json:"id,omitempty"`
Ruleset string `json:"ruleset,omitempty"`
Rulesets []string `json:"rulesets,omitempty"`
Rules map[string][]string `json:"rules,omitempty"`
Increment int `json:"increment,omitempty"`
URI *RulesetRuleActionParametersURI `json:"uri,omitempty"`
Headers map[string]RulesetRuleActionParametersHTTPHeader `json:"headers,omitempty"`
Products []string `json:"products,omitempty"`
Phases []string `json:"phases,omitempty"`
Overrides *RulesetRuleActionParametersOverrides `json:"overrides,omitempty"`
MatchedData *RulesetRuleActionParametersMatchedData `json:"matched_data,omitempty"`
Version *string `json:"version,omitempty"`
Response *RulesetRuleActionParametersBlockResponse `json:"response,omitempty"`
HostHeader string `json:"host_header,omitempty"`
Origin *RulesetRuleActionParametersOrigin `json:"origin,omitempty"`
SNI *RulesetRuleActionParametersSni `json:"sni,omitempty"`
RequestFields []RulesetActionParametersLogCustomField `json:"request_fields,omitempty"`
ResponseFields []RulesetActionParametersLogCustomField `json:"response_fields,omitempty"`
CookieFields []RulesetActionParametersLogCustomField `json:"cookie_fields,omitempty"`
Cache *bool `json:"cache,omitempty"`
AdditionalCacheablePorts []int `json:"additional_cacheable_ports,omitempty"`
EdgeTTL *RulesetRuleActionParametersEdgeTTL `json:"edge_ttl,omitempty"`
BrowserTTL *RulesetRuleActionParametersBrowserTTL `json:"browser_ttl,omitempty"`
ServeStale *RulesetRuleActionParametersServeStale `json:"serve_stale,omitempty"`
Content string `json:"content,omitempty"`
ContentType string `json:"content_type,omitempty"`
StatusCode uint16 `json:"status_code,omitempty"`
RespectStrongETags *bool `json:"respect_strong_etags,omitempty"`
CacheKey *RulesetRuleActionParametersCacheKey `json:"cache_key,omitempty"`
OriginCacheControl *bool `json:"origin_cache_control,omitempty"`
OriginErrorPagePassthru *bool `json:"origin_error_page_passthru,omitempty"`
FromList *RulesetRuleActionParametersFromList `json:"from_list,omitempty"`
FromValue *RulesetRuleActionParametersFromValue `json:"from_value,omitempty"`
AutomaticHTTPSRewrites *bool `json:"automatic_https_rewrites,omitempty"`
AutoMinify *RulesetRuleActionParametersAutoMinify `json:"autominify,omitempty"`
BrowserIntegrityCheck *bool `json:"bic,omitempty"`
DisableApps *bool `json:"disable_apps,omitempty"`
DisableZaraz *bool `json:"disable_zaraz,omitempty"`
DisableRailgun *bool `json:"disable_railgun,omitempty"`
EmailObfuscation *bool `json:"email_obfuscation,omitempty"`
Mirage *bool `json:"mirage,omitempty"`
OpportunisticEncryption *bool `json:"opportunistic_encryption,omitempty"`
Polish *Polish `json:"polish,omitempty"`
ReadTimeout *uint `json:"read_timeout,omitempty"`
RocketLoader *bool `json:"rocket_loader,omitempty"`
SecurityLevel *SecurityLevel `json:"security_level,omitempty"`
ServerSideExcludes *bool `json:"server_side_excludes,omitempty"`
SSL *SSL `json:"ssl,omitempty"`
SXG *bool `json:"sxg,omitempty"`
HotLinkProtection *bool `json:"hotlink_protection,omitempty"`
Algorithms []RulesetRuleActionParametersCompressionAlgorithm `json:"algorithms,omitempty"`
}

// RulesetRuleActionParametersFromList holds the FromList struct for
Expand Down
8 changes: 5 additions & 3 deletions rulesets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ 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
Expand Down Expand Up @@ -326,9 +327,10 @@ func TestGetRuleset_SetCacheSettings(t *testing.T) {
},
},
},
OriginCacheControl: BoolPtr(true),
ReadTimeout: UintPtr(1000),
OriginErrorPagePassthru: BoolPtr(true),
AdditionalCacheablePorts: []int{1, 2, 3, 4},
OriginCacheControl: BoolPtr(true),
ReadTimeout: UintPtr(1000),
OriginErrorPagePassthru: BoolPtr(true),
},
Description: "Set all available cache settings in one rule",
LastUpdated: &lastUpdated,
Expand Down

0 comments on commit ac0c135

Please sign in to comment.