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 Proxy Read Timeout field in the Rulesets API #2755

Merged
merged 4 commits into from
Sep 15, 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/2755.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/cloudflare_ruleset: Add support for the use of Proxy Read Timeout field in Rulesets API
```
1 change: 1 addition & 0 deletions internal/framework/service/rulesets/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type ActionParametersModel struct {
Phases types.Set `tfsdk:"phases"`
Polish types.String `tfsdk:"polish"`
Products types.Set `tfsdk:"products"`
ReadTimeout types.Int64 `tfsdk:"read_timeout"`
RequestFields types.Set `tfsdk:"request_fields"`
RespectStrongEtags types.Bool `tfsdk:"respect_strong_etags"`
Response []*ActionParameterResponseModel `tfsdk:"response"`
Expand Down
5 changes: 5 additions & 0 deletions internal/framework/service/rulesets/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ func toRulesetResourceModel(ctx context.Context, zoneID, accountID basetypes.Str
OriginCacheControl: flatteners.Bool(ruleResponse.ActionParameters.OriginCacheControl),
OriginErrorPagePassthru: flatteners.Bool(ruleResponse.ActionParameters.OriginErrorPagePassthru),
RespectStrongEtags: flatteners.Bool(ruleResponse.ActionParameters.RespectStrongETags),
ReadTimeout: flatteners.Int64(int64(cloudflare.Uint(ruleResponse.ActionParameters.ReadTimeout))),
Version: flatteners.String(cloudflare.String(ruleResponse.ActionParameters.Version)),
})

Expand Down Expand Up @@ -901,6 +902,10 @@ func (r *RulesModel) toRulesetRule(ctx context.Context) cloudflare.RulesetRule {
rr.ActionParameters.SXG = cloudflare.BoolPtr(ap.SXG.ValueBool())
}

if !ap.ReadTimeout.IsNull() {
rr.ActionParameters.ReadTimeout = cloudflare.UintPtr(uint(ap.ReadTimeout.ValueInt64()))
}

if !ap.Polish.IsNull() {
polish, _ := cloudflare.PolishFromString(ap.Polish.ValueString())
rr.ActionParameters.Polish = polish
Expand Down
2 changes: 2 additions & 0 deletions internal/framework/service/rulesets/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1815,6 +1815,7 @@ func TestAccCloudflareRuleset_CacheSettingsAllEnabled(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "rules.0.action_parameters.0.edge_ttl.0.status_code_ttl.1.status_code_range.0.to", "300"),
resource.TestCheckResourceAttr(resourceName, "rules.0.action_parameters.0.browser_ttl.0.mode", "respect_origin"),
resource.TestCheckResourceAttr(resourceName, "rules.0.action_parameters.0.serve_stale.0.disable_stale_while_updating", "true"),
resource.TestCheckResourceAttr(resourceName, "rules.0.action_parameters.0.read_timeout", "2000"),
resource.TestCheckResourceAttr(resourceName, "rules.0.action_parameters.0.respect_strong_etags", "true"),
resource.TestCheckResourceAttr(resourceName, "rules.0.action_parameters.0.cache_key.0.ignore_query_strings_order", "false"),
resource.TestCheckResourceAttr(resourceName, "rules.0.action_parameters.0.cache_key.0.cache_deception_armor", "true"),
Expand Down Expand Up @@ -3938,6 +3939,7 @@ func testAccCloudflareRulesetCacheSettingsAllEnabled(rnd, accountID, zoneID stri
disable_stale_while_updating = true
}
respect_strong_etags = true
read_timeout = 2000
cache_key {
ignore_query_strings_order = false
cache_deception_armor = true
Expand Down
4 changes: 4 additions & 0 deletions internal/framework/service/rulesets/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ func (r *RulesetResource) Schema(ctx context.Context, req resource.SchemaRequest
Optional: true,
MarkdownDescription: fmt.Sprintf("Products to target with the actions. %s.", utils.RenderAvailableDocumentationValuesStringSlice(cloudflare.RulesetActionParameterProductValues())),
},
"read_timeout": schema.Int64Attribute{
Optional: true,
MarkdownDescription: "Specifies a maximum timeout for reading content from an origin server.",
},
"request_fields": schema.SetAttribute{
ElementType: types.StringType,
Optional: true,
Expand Down
5 changes: 5 additions & 0 deletions internal/sdkv2provider/data_source_rulesets.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,11 @@ func resourceCloudflareRulesetSchema() map[string]*schema.Schema {
},
},
},
"read_timeout": {
Type: schema.TypeInt,
Optional: true,
Description: "Sets the timeout value for reading content from an origin server.",
},
"respect_strong_etags": {
Type: schema.TypeBool,
Optional: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ var resourceCloudflareZoneSettingsSchema = map[string]*schema.Schema{
Computed: true,
},

"proxy_read_timeout": {
"read_timeout": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Expand Down