Skip to content

Commit

Permalink
Merge pull request #4722 from jafowler/jfowler/next-page-rules-on-off…
Browse files Browse the repository at this point in the history
…-actions

page rules on off actions
  • Loading branch information
mgirouard authored Dec 6, 2024
2 parents c2d2c8d + a6c2ad0 commit 7de025c
Show file tree
Hide file tree
Showing 4 changed files with 694 additions and 6 deletions.
73 changes: 67 additions & 6 deletions internal/services/page_rule/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,27 @@ func (m PageRuleModel) marshalTargetsAndActions(b []byte) (data []byte, err erro
}

type PageRuleActionsModel struct {
AutomaticHTTPSRewrites types.String `tfsdk:"automatic_https_rewrites" json:"automatic_https_rewrites,optional"`
AlwaysUseHTTPS types.Bool `tfsdk:"always_use_https" json:"always_use_https,optional"`
DisableApps types.Bool `tfsdk:"disable_apps" json:"disable_apps,optional"`
DisablePerformance types.Bool `tfsdk:"disable_performance" json:"disable_performance,optional"`
DisableSecurity types.Bool `tfsdk:"disable_security" json:"disable_security,optional"`
DisableZaraz types.Bool `tfsdk:"disable_zaraz" json:"disable_zaraz,optional"`
AlwaysUseHTTPS types.Bool `tfsdk:"always_use_https" json:"always_use_https,optional"`
AutomaticHTTPSRewrites types.String `tfsdk:"automatic_https_rewrites" json:"automatic_https_rewrites,optional"`
BrowserCheck types.String `tfsdk:"browser_check" json:"browser_check,optional"`
CacheByDeviceType types.String `tfsdk:"cache_by_device_type" json:"cache_by_device_type,optional"`
CacheDeceptionArmor types.String `tfsdk:"cache_deception_armor" json:"cache_deception_armor,optional"`
DisableApps types.Bool `tfsdk:"disable_apps" json:"disable_apps,optional"`
DisablePerformance types.Bool `tfsdk:"disable_performance" json:"disable_performance,optional"`
DisableSecurity types.Bool `tfsdk:"disable_security" json:"disable_security,optional"`
DisableZaraz types.Bool `tfsdk:"disable_zaraz" json:"disable_zaraz,optional"`
EmailObfuscation types.String `tfsdk:"email_obfuscation" json:"email_obfuscation,optional"`
ExplicitCacheControl types.String `tfsdk:"explicit_cache_control" json:"explicit_cache_control,optional"`
IPGeolocation types.String `tfsdk:"ip_geolocation" json:"ip_geolocation,optional"`
Mirage types.String `tfsdk:"mirage" json:"mirage,optional"`
OpportunisticEncryption types.String `tfsdk:"opportunistic_encryption" json:"opportunistic_encryption,optional"`
OriginErrorPagePassThru types.String `tfsdk:"origin_error_page_pass_thru" json:"origin_error_page_pass_thru,optional"`
RespectStrongEtag types.String `tfsdk:"respect_strong_etag" json:"respect_strong_etag,optional"`
ResponseBuffering types.String `tfsdk:"response_buffering" json:"response_buffering,optional"`
RocketLoader types.String `tfsdk:"rocket_loader" json:"rocket_loader,optional"`
SortQueryStringForCache types.String `tfsdk:"sort_query_string_for_cache" json:"sort_query_string_for_cache,optional"`
TrueClientIPHeader types.String `tfsdk:"true_client_ip_header" json:"true_client_ip_header,optional"`
WAF types.String `tfsdk:"waf" json:"waf,optional"`
}

func (m *PageRuleActionsModel) Encode() (encoded []map[string]any, err error) {
Expand All @@ -80,6 +95,15 @@ func (m *PageRuleActionsModel) Encode() (encoded []map[string]any, err error) {
if !m.AutomaticHTTPSRewrites.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDAutomaticHTTPSRewrites, "value": m.AutomaticHTTPSRewrites.String()})
}
if !m.BrowserCheck.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDBrowserCheck, "value": m.BrowserCheck.ValueString()})
}
if !m.CacheByDeviceType.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDCacheByDeviceType, "value": m.CacheByDeviceType.ValueString()})
}
if !m.CacheDeceptionArmor.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDCacheDeceptionArmor, "value": m.CacheDeceptionArmor.ValueString()})
}
if m.DisableApps.ValueBool() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDDisableApps, "value": m.DisableApps.ValueBool()})
}
Expand All @@ -92,5 +116,42 @@ func (m *PageRuleActionsModel) Encode() (encoded []map[string]any, err error) {
if m.DisableZaraz.ValueBool() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDDisableZaraz})
}
if !m.EmailObfuscation.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDEmailObfuscation, "value": m.EmailObfuscation.ValueString()})
}
if !m.ExplicitCacheControl.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDExplicitCacheControl, "value": m.ExplicitCacheControl.ValueString()})
}
if !m.IPGeolocation.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDIPGeolocation, "value": m.IPGeolocation.ValueString()})
}
if !m.Mirage.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDMirage, "value": m.Mirage.ValueString()})
}
if !m.OpportunisticEncryption.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDOpportunisticEncryption, "value": m.OpportunisticEncryption.ValueString()})
}
if !m.OriginErrorPagePassThru.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDOriginErrorPagePassThru, "value": m.OriginErrorPagePassThru.ValueString()})
}
if !m.RespectStrongEtag.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDRespectStrongEtag, "value": m.RespectStrongEtag.ValueString()})
}
if !m.ResponseBuffering.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDResponseBuffering, "value": m.ResponseBuffering.ValueString()})
}
if !m.RocketLoader.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDRocketLoader, "value": m.RocketLoader.ValueString()})
}
if !m.SortQueryStringForCache.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDSortQueryStringForCache, "value": m.SortQueryStringForCache.ValueString()})
}
if !m.TrueClientIPHeader.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDTrueClientIPHeader, "value": m.TrueClientIPHeader.ValueString()})
}
if !m.WAF.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDWAF, "value": m.WAF.ValueString()})
}

return
}
Loading

0 comments on commit 7de025c

Please sign in to comment.