Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for additional cacheable ports in the Rulesets API #1375

Merged
merged 3 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this is whitespace formatting, this is the only new field

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
Loading