Repository: cloudflare/cloudflare-go
Pull request #1374 (2023-08-25 16:34:37)

Add support for Read Timeout in Rulesets API
## Description

Adds support for the usage of the `read_timeout` field which has been added to the rulesets API. This controls the Proxy Read Timeout for connections to the origin to allow for longer wait times before closing the connection.

## Has your change been tested?

The API has been tested thoroughly. Unit tests have been modified to include validation of the API response. Additional testing may be required.

<!--
Explain how the change has been tested and what you ran to confirm your
change affects other parts of the code. Automated tests are generally
expected and changes without tests should explain why they aren't
required.
-->

## Screenshots (if appropriate):

## Types of changes

What sort of change does your code introduce/modify?

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Checklist:

- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
- [ ] This change is using publicly documented in [cloudflare/api-schemas](https://github.com/cloudflare/api-schemas) 
      and relies on stable APIs.

[1]: https://help.github.com/articles/closing-issues-using-keywords/


github-actions[bot]: Oops! It looks like no changelog entry is attached to this PR. Please include a release note as described in https://github.com/cloudflare/cloudflare-go/blob/master/docs/changelog-process.md.

Example: 

~~~
```release-note:TYPE
Release note
```
~~~

If you do not require a release note to be included, please add the `workflow/skip-changelog-entry` label.
iveelsm: @jacobbednarz copy is currently being made for this on the API side and support for the UI is still in design. This is part of a series of PRs I will be opening both here and in the Terraform repo.

Patch:
diff --git a/.changelog/1374.txt b/.changelog/1374.txt
new file mode 100644
index 000000000..07bc895bb
--- /dev/null
+++ b/.changelog/1374.txt
@@ -0,0 +1,3 @@
+```release_note:enhancement
+rulesets: Add support for Proxy Read Timeout configuration via the Rulesets/Cache Rules API
+```
\ No newline at end of file
diff --git a/rulesets.go b/rulesets.go
index 206a5e17c..92cc252da 100644
--- a/rulesets.go
+++ b/rulesets.go
@@ -247,6 +247,7 @@ type RulesetRuleActionParameters struct {
 	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"`


Test patch:
diff --git a/rulesets_test.go b/rulesets_test.go
index d2d654a1f..18cdd9648 100644
--- a/rulesets_test.go
+++ b/rulesets_test.go
@@ -241,6 +241,7 @@ func TestGetRuleset_SetCacheSettings(t *testing.T) {
 						}
 					}
 				},
+				"read_timeout": 1000,
 				"origin_error_page_passthru":true
 			},
 			"description": "Set all available cache settings in one rule",
@@ -324,6 +325,7 @@ func TestGetRuleset_SetCacheSettings(t *testing.T) {
 					},
 				},
 			},
+			ReadTimeout:             UintPtr(1000),
 			OriginErrorPagePassthru: BoolPtr(true),
 		},
 		Description: "Set all available cache settings in one rule",