Repository: cloudflare/cloudflare-go
Pull request #1294 (2023-05-25 15:55:20)

Add description to device non default settings policy
Provide a general summary of your changes in the title above. You should
remove this overview, any sections and any section descriptions you
don't need below before submitting. There isn't a strict requirement to
use this template if you can structure your description and still cover
these points.

## Description

Describe your changes in detail through motivation and context. Why is
this change required? What problem does it solve? If it fixes an open
issue, link to the issue using GitHub's closing issues keywords[1].

## Has your change been tested?

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.
- [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/



Patch:
diff --git a/.changelog/1294.txt b/.changelog/1294.txt
new file mode 100644
index 000000000..fa9244192
--- /dev/null
+++ b/.changelog/1294.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+devices_policy: Add missing description field to policy
+```
diff --git a/devices_policy.go b/devices_policy.go
index 2664a260c..3b7dbcddf 100644
--- a/devices_policy.go
+++ b/devices_policy.go
@@ -53,6 +53,7 @@ type DeviceSettingsPolicy struct {
 	Precedence          *int              `json:"precedence"`
 	Default             bool              `json:"default"`
 	ExcludeOfficeIps    *bool             `json:"exclude_office_ips"`
+	Description         *string           `json:"description"`
 }
 
 type DeviceSettingsPolicyResponse struct {
@@ -80,6 +81,7 @@ type DeviceSettingsPolicyRequest struct {
 	Match               *string        `json:"match,omitempty"`
 	Enabled             *bool          `json:"enabled,omitempty"`
 	ExcludeOfficeIps    *bool          `json:"exclude_office_ips"`
+	Description         *string        `json:"description,omitempty"`
 }
 
 // UpdateDeviceClientCertificates controls the zero trust zone used to provision client certificates.


Test patch:
diff --git a/devices_policy_test.go b/devices_policy_test.go
index ac03a752c..de29cc0a6 100644
--- a/devices_policy_test.go
+++ b/devices_policy_test.go
@@ -42,6 +42,7 @@ var (
 		Precedence:       nil,
 		Default:          true,
 		ExcludeOfficeIps: BoolPtr(false),
+		Description:      nil,
 	}
 
 	nonDefaultDeviceSettingsPolicy = DeviceSettingsPolicy{
@@ -72,6 +73,7 @@ var (
 		Precedence:       &deviceSettingsPolicyPrecedence,
 		Default:          false,
 		ExcludeOfficeIps: BoolPtr(true),
+		Description:      StringPtr("Test Description"),
 	}
 
 	defaultDeviceSettingsPolicyJson = `{
@@ -143,7 +145,8 @@ var (
 		"match": %#v,
 		"precedence": 10,
 		"default": false,
-		"exclude_office_ips":true
+		"exclude_office_ips":true,
+		"description":"Test Description"
 	}`, deviceSettingsPolicyID, deviceSettingsPolicyMatch)
 )
 
@@ -240,9 +243,10 @@ func TestCreateDeviceSettingsPolicy(t *testing.T) {
 	mux.HandleFunc("/accounts/"+testAccountID+"/devices/policy", handler)
 
 	actual, err := client.CreateDeviceSettingsPolicy(context.Background(), testAccountID, DeviceSettingsPolicyRequest{
-		Precedence: IntPtr(10),
-		Match:      &deviceSettingsPolicyMatch,
-		Name:       StringPtr("test"),
+		Precedence:  IntPtr(10),
+		Match:       &deviceSettingsPolicyMatch,
+		Name:        StringPtr("test"),
+		Description: StringPtr("Test Description"),
 	})
 
 	if assert.NoError(t, err) {