Repository: cloudflare/cloudflare-go
Pull request #1600 (2024-03-21 21:49:11)

DLP-1723: add ocr_enabled flag to DLP profiles
## Description

Add boolean 'ocr_enabled' flag to reflect newly-added 'ocr_enabled' flag in DLP https://developers.cloudflare.com/api/operations/dlp-profiles-get-custom-profile

## Has your change been tested?

Included examples in unit test, using data based on result of queries against cloudflare API 

## 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.
- [x] My change requires a change to the documentation.
- [x] 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/1600.txt b/.changelog/1600.txt
new file mode 100644
index 000000000..eee34a863
--- /dev/null
+++ b/.changelog/1600.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+dlp: Adds support for ocr_enabled boolean flag
+```
diff --git a/dlp_profile.go b/dlp_profile.go
index 2a0c405da..25e78e9c4 100644
--- a/dlp_profile.go
+++ b/dlp_profile.go
@@ -55,6 +55,7 @@ type DLPProfile struct {
 	Type              string `json:"type,omitempty"`
 	Description       string `json:"description,omitempty"`
 	AllowedMatchCount int    `json:"allowed_match_count"`
+	OCREnabled        *bool  `json:"ocr_enabled,omitempty"`
 
 	ContextAwareness *DLPContextAwareness `json:"context_awareness,omitempty"`
 


Test patch:
diff --git a/dlp_profile_test.go b/dlp_profile_test.go
index 67f014d5a..3345c3dd3 100644
--- a/dlp_profile_test.go
+++ b/dlp_profile_test.go
@@ -51,7 +51,8 @@ func TestDLPProfiles(t *testing.T) {
 						"skip": {
 							"files": true
 						}
-					}
+					},
+					"ocr_enabled": false
 				},
 				{
 					"id": "29678c26-a191-428d-9f63-6e20a4a636a4",
@@ -75,7 +76,8 @@ func TestDLPProfiles(t *testing.T) {
 					"updated_at": "2022-10-18T08:00:57Z",
 					"type": "custom",
 					"description": "just a custom profile example",
-					"allowed_match_count": 1
+					"allowed_match_count": 1,
+					"ocr_enabled": true 
 				}
 			]
 		}
@@ -98,6 +100,7 @@ func TestDLPProfiles(t *testing.T) {
 					Files: BoolPtr(true),
 				},
 			},
+			OCREnabled: BoolPtr(false),
 			Entries: []DLPEntry{
 				{
 					ID:        "111b9d4b-a5c6-40f0-957d-9d53b25dd84a",
@@ -121,6 +124,7 @@ func TestDLPProfiles(t *testing.T) {
 			Description:       "just a custom profile example",
 			AllowedMatchCount: 1,
 			// Omit ContextAwareness to test ContextAwareness optionality
+			OCREnabled: BoolPtr(true),
 			Entries: []DLPEntry{
 				{
 					ID:        "ef79b054-12d4-4067-bb30-b85f6267b91c",
@@ -271,7 +275,8 @@ func TestCreateDLPCustomProfiles(t *testing.T) {
 				"updated_at": "2022-10-18T08:00:57Z",
 				"type": "custom",
 				"description": "`+requestProfile.Description+`",
-				"allowed_match_count": 0
+				"allowed_match_count": 0,
+				"ocr_enabled": true
 			}]
 		}`)
 	}
@@ -303,6 +308,7 @@ func TestCreateDLPCustomProfiles(t *testing.T) {
 			CreatedAt:         &createdAt,
 			UpdatedAt:         &updatedAt,
 			AllowedMatchCount: 0,
+			OCREnabled:        BoolPtr(true),
 		},
 	}