Repository: cloudflare/cloudflare-go
Pull request #1423 (2023-10-19 11:32:50)

Add support for `body_scanning` (Enhanced File Detection) in teams account configuration
Add support for `body_scanning` (Enhanced File Detection) in teams account configuration.

## Description

The teams account configuration APIs support Enhanced File Detection (`body_scanning` in the API), see links below. This PR adds support for this parameter with the Go SDK - with a view to implement the same functionality on the Terraform provider once released.

- Enhanced file detection: [https://developers.cloudflare.com/cloudflare-one/insights/logs/gateway-logs/#enhanced-file-detection](https://developers.cloudflare.com/cloudflare-one/insights/logs/gateway-logs/#enhanced-file-detection)
- API docs: [https://developers.cloudflare.com/api/operations/zero-trust-accounts-get-zero-trust-account-configuration](https://developers.cloudflare.com/api/operations/zero-trust-accounts-get-zero-trust-account-configuration)

No issue raised as this feels like a minor addition. Happy to raise one if requested.

## Has your change been tested?

Unit tests have been updates, and additionally I created a test Go app to confirm the changes work with both get and update functionality, using own Cloudflare account.

## Screenshots (if appropriate):

N/A

## 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.
- [x] 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.

Patch:
diff --git a/.changelog/1423.txt b/.changelog/1423.txt
new file mode 100644
index 000000000..20d7c0afa
--- /dev/null
+++ b/.changelog/1423.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+foo: Add support for body_scanning (Enhanced File Detection) in teams account configuration
+```
diff --git a/teams_accounts.go b/teams_accounts.go
index db63f0538..ece6641ab 100644
--- a/teams_accounts.go
+++ b/teams_accounts.go
@@ -44,6 +44,7 @@ type TeamsAccountSettings struct {
 	BrowserIsolation  *BrowserIsolation       `json:"browser_isolation,omitempty"`
 	FIPS              *TeamsFIPS              `json:"fips,omitempty"`
 	ProtocolDetection *TeamsProtocolDetection `json:"protocol_detection,omitempty"`
+	BodyScanning      *TeamsBodyScanning      `json:"body_scanning,omitempty"`
 }
 
 type BrowserIsolation struct {
@@ -84,6 +85,17 @@ type TeamsBlockPage struct {
 	SuppressFooter  *bool  `json:"suppress_footer,omitempty"`
 }
 
+type TeamsInspectionMode = string
+
+const (
+	TeamsShallowInspectionMode TeamsInspectionMode = "shallow"
+	TeamsDeepInspectionMode    TeamsInspectionMode = "deep"
+)
+
+type TeamsBodyScanning struct {
+	InspectionMode TeamsInspectionMode `json:"inspection_mode,omitempty"`
+}
+
 type TeamsRuleType = string
 
 const (


Test patch:
diff --git a/teams_accounts_test.go b/teams_accounts_test.go
index c1dfe4be4..5b8411384 100644
--- a/teams_accounts_test.go
+++ b/teams_accounts_test.go
@@ -78,6 +78,9 @@ func TestTeamsAccountConfiguration(t *testing.T) {
 						"logo_path": "https://logos.com/a.png",
 						"background_color": "#ff0000",
 						"suppress_footer": true
+					},
+					"body_scanning": {
+						"inspection_mode": "deep"
 					}
 				}
 			}
@@ -96,6 +99,7 @@ func TestTeamsAccountConfiguration(t *testing.T) {
 			TLSDecrypt:        &TeamsTLSDecrypt{Enabled: true},
 			ProtocolDetection: &TeamsProtocolDetection{Enabled: true},
 			FIPS:              &TeamsFIPS{TLS: true},
+			BodyScanning:      &TeamsBodyScanning{InspectionMode: "deep"},
 
 			BlockPage: &TeamsBlockPage{
 				Enabled:         BoolPtr(true),