Repository: cloudflare/cloudflare-go
Pull request #1454 (2023-12-01 23:37:56)

Add support for Opt-In Split Tunnel Overlapping IPs
## Description
Add two new fields to the device settings policy. This is to add API support for the Opt-In Split Tunnel Overlapping IPs feature:
1. `lan_allow_minutes` (uint) used to set the amount of time a user can access a LAN subnet.
2. `lan_allow_subnet_size` (uint) the allowed subnet size for the lan 

## Has your change been tested?
Added to existing device settings policy tests.

## Types of changes
- [ ] 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/1454.txt b/.changelog/1454.txt
new file mode 100644
index 000000000..b0d74dbef
--- /dev/null
+++ b/.changelog/1454.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+devices_policy: add fields for Opt-In Split Tunnel Overlapping IPs feature.
+```
diff --git a/.changelog/1456.txt b/.changelog/1456.txt
deleted file mode 100644
index d8198fe44..000000000
--- a/.changelog/1456.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-```release-note:dependency
-deps: bumps github.com/urfave/cli/v2 from 2.25.7 to 2.26.0
-```
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c0bf55f45..97641bc9e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,7 +8,6 @@ ENHANCEMENTS:
 
 DEPENDENCIES:
 
-* deps: bumps github.com/urfave/cli/v2 from 2.25.7 to 2.26.0 ([#1456](https://github.com/cloudflare/cloudflare-go/issues/1456))
 * deps: bumps golang.org/x/net from 0.18.0 to 0.19.0 ([#1452](https://github.com/cloudflare/cloudflare-go/issues/1452))
 * deps: bumps golang.org/x/time from 0.4.0 to 0.5.0 ([#1449](https://github.com/cloudflare/cloudflare-go/issues/1449))
 
diff --git a/devices_policy.go b/devices_policy.go
index c662ecb42..1a8b03b9d 100644
--- a/devices_policy.go
+++ b/devices_policy.go
@@ -57,6 +57,8 @@ type DeviceSettingsPolicy struct {
 	Default             bool              `json:"default"`
 	ExcludeOfficeIps    *bool             `json:"exclude_office_ips"`
 	Description         *string           `json:"description"`
+	LANAllowMinutes     *uint             `json:"lan_allow_minutes"`
+	LANAllowSubnetSize  *uint             `json:"lan_allow_subnet_size"`
 }
 
 type DeviceSettingsPolicyResponse struct {
@@ -85,6 +87,8 @@ type CreateDeviceSettingsPolicyParams struct {
 	Enabled             *bool          `json:"enabled,omitempty"`
 	ExcludeOfficeIps    *bool          `json:"exclude_office_ips"`
 	Description         *string        `json:"description,omitempty"`
+	LANAllowMinutes     *uint          `json:"lan_allow_minutes,omitempty"`
+	LANAllowSubnetSize  *uint          `json:"lan_allow_subnet_size,omitempty"`
 }
 
 type UpdateDefaultDeviceSettingsPolicyParams struct {
@@ -103,6 +107,8 @@ type UpdateDefaultDeviceSettingsPolicyParams struct {
 	Enabled             *bool          `json:"enabled,omitempty"`
 	ExcludeOfficeIps    *bool          `json:"exclude_office_ips"`
 	Description         *string        `json:"description,omitempty"`
+	LANAllowMinutes     *uint          `json:"lan_allow_minutes,omitempty"`
+	LANAllowSubnetSize  *uint          `json:"lan_allow_subnet_size,omitempty"`
 }
 
 type UpdateDeviceSettingsPolicyParams struct {
@@ -122,6 +128,8 @@ type UpdateDeviceSettingsPolicyParams struct {
 	Enabled             *bool          `json:"enabled,omitempty"`
 	ExcludeOfficeIps    *bool          `json:"exclude_office_ips"`
 	Description         *string        `json:"description,omitempty"`
+	LANAllowMinutes     *uint          `json:"lan_allow_minutes,omitempty"`
+	LANAllowSubnetSize  *uint          `json:"lan_allow_subnet_size,omitempty"`
 }
 
 type ListDeviceSettingsPoliciesResponse struct {
diff --git a/go.mod b/go.mod
index e94c4af01..987233b04 100644
--- a/go.mod
+++ b/go.mod
@@ -8,7 +8,7 @@ require (
 	github.com/hashicorp/go-retryablehttp v0.7.5
 	github.com/olekukonko/tablewriter v0.0.5
 	github.com/stretchr/testify v1.8.4
-	github.com/urfave/cli/v2 v2.26.0
+	github.com/urfave/cli/v2 v2.25.7
 	golang.org/x/net v0.19.0
 	golang.org/x/time v0.5.0
 )
diff --git a/go.sum b/go.sum
index 6d8761c4e..c18455fb1 100644
--- a/go.sum
+++ b/go.sum
@@ -55,8 +55,8 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
 github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
 github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
-github.com/urfave/cli/v2 v2.26.0 h1:3f3AMg3HpThFNT4I++TKOejZO8yU55t3JnnSr4S4QEI=
-github.com/urfave/cli/v2 v2.26.0/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
+github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
+github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
 github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
 github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
 golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=


Test patch:
diff --git a/devices_policy_test.go b/devices_policy_test.go
index b08e45226..c78a13838 100644
--- a/devices_policy_test.go
+++ b/devices_policy_test.go
@@ -27,22 +27,24 @@ var (
 			{Address: "10.0.0.0/8"},
 			{Address: "100.64.0.0/10"},
 		},
-		GatewayUniqueID:  StringPtr("t1235"),
-		SupportURL:       StringPtr(""),
-		CaptivePortal:    IntPtr(180),
-		AllowModeSwitch:  BoolPtr(false),
-		SwitchLocked:     BoolPtr(false),
-		AllowUpdates:     BoolPtr(false),
-		AutoConnect:      IntPtr(0),
-		AllowedToLeave:   BoolPtr(true),
-		Enabled:          BoolPtr(true),
-		PolicyID:         nil,
-		Name:             nil,
-		Match:            nil,
-		Precedence:       nil,
-		Default:          true,
-		ExcludeOfficeIps: BoolPtr(false),
-		Description:      nil,
+		GatewayUniqueID:    StringPtr("t1235"),
+		SupportURL:         StringPtr(""),
+		CaptivePortal:      IntPtr(180),
+		AllowModeSwitch:    BoolPtr(false),
+		SwitchLocked:       BoolPtr(false),
+		AllowUpdates:       BoolPtr(false),
+		AutoConnect:        IntPtr(0),
+		AllowedToLeave:     BoolPtr(true),
+		Enabled:            BoolPtr(true),
+		PolicyID:           nil,
+		Name:               nil,
+		Match:              nil,
+		Precedence:         nil,
+		Default:            true,
+		ExcludeOfficeIps:   BoolPtr(false),
+		Description:        nil,
+		LANAllowMinutes:    nil,
+		LANAllowSubnetSize: nil,
 	}
 
 	nonDefaultDeviceSettingsPolicy = DeviceSettingsPolicy{
@@ -58,22 +60,24 @@ var (
 			{Address: "10.0.0.0/8"},
 			{Address: "100.64.0.0/10"},
 		},
-		GatewayUniqueID:  StringPtr("t1235"),
-		SupportURL:       StringPtr(""),
-		CaptivePortal:    IntPtr(180),
-		AllowModeSwitch:  BoolPtr(false),
-		SwitchLocked:     BoolPtr(false),
-		AllowUpdates:     BoolPtr(false),
-		AutoConnect:      IntPtr(0),
-		AllowedToLeave:   BoolPtr(true),
-		PolicyID:         &deviceSettingsPolicyID,
-		Enabled:          BoolPtr(true),
-		Name:             StringPtr("test"),
-		Match:            &deviceSettingsPolicyMatch,
-		Precedence:       &deviceSettingsPolicyPrecedence,
-		Default:          false,
-		ExcludeOfficeIps: BoolPtr(true),
-		Description:      StringPtr("Test Description"),
+		GatewayUniqueID:    StringPtr("t1235"),
+		SupportURL:         StringPtr(""),
+		CaptivePortal:      IntPtr(180),
+		AllowModeSwitch:    BoolPtr(false),
+		SwitchLocked:       BoolPtr(false),
+		AllowUpdates:       BoolPtr(false),
+		AutoConnect:        IntPtr(0),
+		AllowedToLeave:     BoolPtr(true),
+		PolicyID:           &deviceSettingsPolicyID,
+		Enabled:            BoolPtr(true),
+		Name:               StringPtr("test"),
+		Match:              &deviceSettingsPolicyMatch,
+		Precedence:         &deviceSettingsPolicyPrecedence,
+		Default:            false,
+		ExcludeOfficeIps:   BoolPtr(true),
+		Description:        StringPtr("Test Description"),
+		LANAllowMinutes:    UintPtr(120),
+		LANAllowSubnetSize: UintPtr(31),
 	}
 
 	defaultDeviceSettingsPolicyJson = `{
@@ -146,7 +150,9 @@ var (
 		"precedence": 10,
 		"default": false,
 		"exclude_office_ips":true,
-		"description":"Test Description"
+		"description":"Test Description",
+		"lan_allow_minutes": 120,
+		"lan_allow_subnet_size": 31
 	}`, deviceSettingsPolicyID, deviceSettingsPolicyMatch)
 )
 
@@ -234,10 +240,12 @@ func TestCreateDeviceSettingsPolicy(t *testing.T) {
 	mux.HandleFunc("/accounts/"+testAccountID+"/devices/policy", handler)
 
 	actual, err := client.CreateDeviceSettingsPolicy(context.Background(), AccountIdentifier(testAccountID), CreateDeviceSettingsPolicyParams{
-		Precedence:  IntPtr(10),
-		Match:       &deviceSettingsPolicyMatch,
-		Name:        StringPtr("test"),
-		Description: StringPtr("Test Description"),
+		Precedence:         IntPtr(10),
+		Match:              &deviceSettingsPolicyMatch,
+		Name:               StringPtr("test"),
+		Description:        StringPtr("Test Description"),
+		LANAllowMinutes:    UintPtr(120),
+		LANAllowSubnetSize: UintPtr(31),
 	})
 
 	if assert.NoError(t, err) {