Repository: cloudflare/cloudflare-go
Pull request #1463 (2023-12-14 04:31:39)

feat: added gateway rule notification settings
New notification settings are added to the gateway rules as optional settings. This PR adds support for them in the library.

API DOC change at https://developers.cloudflare.com/api/operations/zero-trust-gateway-rules-create-zero-trust-gateway-rule


## 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.
jacobbednarz: once the lint failures are fixed here, lgtm 🚢 

Patch:
diff --git a/.changelog/1463.txt b/.changelog/1463.txt
new file mode 100644
index 000000000..a6b8e2e2d
--- /dev/null
+++ b/.changelog/1463.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+teams_rules: Added support for notification settings in a gateway rule
+```
\ No newline at end of file
diff --git a/.changelog/1464.txt b/.changelog/1464.txt
deleted file mode 100644
index d2bb00b15..000000000
--- a/.changelog/1464.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-```release-note:enhancement
-device_posture_rules: add support for Access client fields in device posture integrations
-```
\ No newline at end of file
diff --git a/.changelog/1466.txt b/.changelog/1466.txt
deleted file mode 100644
index c7e1d56aa..000000000
--- a/.changelog/1466.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-```release-note:dependency
-deps: bumps golang.org/x/crypto from 0.14.0 to 0.17.0
-```
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4e9ecdfe2..695b8dc08 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,14 +3,12 @@
 ENHANCEMENTS:
 
 * access_group: Add support for email lists ([#1445](https://github.com/cloudflare/cloudflare-go/issues/1445))
-* device_posture_rules: add support for Access client fields in device posture integrations ([#1464](https://github.com/cloudflare/cloudflare-go/issues/1464))
 * page_shield: added support for page shield ([#1459](https://github.com/cloudflare/cloudflare-go/issues/1459))
 
 DEPENDENCIES:
 
 * deps: bumps actions/setup-go from 4 to 5 ([#1460](https://github.com/cloudflare/cloudflare-go/issues/1460))
 * deps: bumps github/codeql-action from 2 to 3 ([#1462](https://github.com/cloudflare/cloudflare-go/issues/1462))
-* deps: bumps golang.org/x/crypto from 0.14.0 to 0.17.0 ([#1466](https://github.com/cloudflare/cloudflare-go/issues/1466))
 
 ## 0.83.0 (December 6th, 2023)
 
diff --git a/device_posture_rule.go b/device_posture_rule.go
index 02c0cfe46..664d5241f 100644
--- a/device_posture_rule.go
+++ b/device_posture_rule.go
@@ -11,14 +11,12 @@ import (
 // DevicePostureIntegrationConfig contains authentication information
 // for a device posture integration.
 type DevicePostureIntegrationConfig struct {
-	ClientID           string `json:"client_id,omitempty"`
-	ClientSecret       string `json:"client_secret,omitempty"`
-	AuthUrl            string `json:"auth_url,omitempty"`
-	ApiUrl             string `json:"api_url,omitempty"`
-	ClientKey          string `json:"client_key,omitempty"`
-	CustomerID         string `json:"customer_id,omitempty"`
-	AccessClientID     string `json:"access_client_id,omitempty"`
-	AccessClientSecret string `json:"access_client_secret,omitempty"`
+	ClientID     string `json:"client_id,omitempty"`
+	ClientSecret string `json:"client_secret,omitempty"`
+	AuthUrl      string `json:"auth_url,omitempty"`
+	ApiUrl       string `json:"api_url,omitempty"`
+	ClientKey    string `json:"client_key,omitempty"`
+	CustomerID   string `json:"customer_id,omitempty"`
 }
 
 // DevicePostureIntegration represents a device posture integration.
diff --git a/internal/tools/go.mod b/internal/tools/go.mod
index 35abdb7fd..b0c02ca79 100644
--- a/internal/tools/go.mod
+++ b/internal/tools/go.mod
@@ -219,13 +219,13 @@ require (
 	go.uber.org/multierr v1.6.0 // indirect
 	go.uber.org/zap v1.17.0 // indirect
 	golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4 // indirect
-	golang.org/x/crypto v0.17.0 // indirect
+	golang.org/x/crypto v0.14.0 // indirect
 	golang.org/x/exp/typeparams v0.0.0-20220722155223-a9213eeb770e // indirect
 	golang.org/x/mod v0.8.0 // indirect
 	golang.org/x/net v0.17.0 // indirect
 	golang.org/x/sync v0.1.0 // indirect
-	golang.org/x/sys v0.15.0 // indirect
-	golang.org/x/text v0.14.0 // indirect
+	golang.org/x/sys v0.13.0 // indirect
+	golang.org/x/text v0.13.0 // indirect
 	golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect
 	golang.org/x/tools v0.6.0 // indirect
 	golang.org/x/vuln v0.0.0-20220725105440-4151a5aca1df // indirect
diff --git a/internal/tools/go.sum b/internal/tools/go.sum
index 8230c4ed3..766cd8d67 100644
--- a/internal/tools/go.sum
+++ b/internal/tools/go.sum
@@ -917,8 +917,8 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm
 golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
-golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
-golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
+golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
+golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
 golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
 golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
 golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -1104,10 +1104,10 @@ golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBc
 golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
-golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
+golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
-golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
+golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -1117,8 +1117,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
-golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
+golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
+golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
 golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
diff --git a/teams_rules.go b/teams_rules.go
index f179e81c6..880c55ca8 100644
--- a/teams_rules.go
+++ b/teams_rules.go
@@ -63,6 +63,8 @@ type TeamsRuleSettings struct {
 
 	// Resolver policy settings.
 	DnsResolverSettings *TeamsDnsResolverSettings `json:"dns_resolvers,omitempty"`
+
+	NotificationSettings *TeamsNotificationSettings `json:"notification_settings"`
 }
 
 type TeamsGatewayUntrustedCertAction string
@@ -77,6 +79,12 @@ type UntrustedCertSettings struct {
 	Action TeamsGatewayUntrustedCertAction `json:"action"`
 }
 
+type TeamsNotificationSettings struct {
+	Enabled    *bool  `json:"enabled,omitempty"`
+	Message    string `json:"msg"`
+	SupportURL string `json:"support_url"`
+}
+
 type AuditSSHRuleSettings struct {
 	CommandLogging bool `json:"command_logging"`
 }


Test patch:
diff --git a/device_posture_rule_test.go b/device_posture_rule_test.go
index b9b72b2b8..79ce77c51 100644
--- a/device_posture_rule_test.go
+++ b/device_posture_rule_test.go
@@ -228,55 +228,6 @@ func TestDevicePostureIntegrationCreate(t *testing.T) {
 	}
 }
 
-func TestDevicePostureIntegrationTaniumCreate(t *testing.T) {
-	setup()
-	defer teardown()
-
-	id := "480f4f69-1a28-4fdd-9240-1ed29f0ac1db"
-	handler := func(w http.ResponseWriter, r *http.Request) {
-		assert.Equal(t, http.MethodPost, r.Method, "Expected method 'POST', got %s", r.Method)
-		w.Header().Set("content-type", "application/json")
-		fmt.Fprintf(w, `{
-			"success": true,
-			"errors": [],
-			"messages": [],
-			"result": {
-				"id": "%s",
-				"interval": "1h",
-				"type": "tanium_s2s",
-				"name": "My Tanium integration",
-				"config": {
-					"api_url":              "https://api_url.example.com",
-					"client_secret":        "test_client_secret",
-					"access_client_id":     "test_access_client_id",
-					"access_client_secret": "test_access_client_secret"
-				}
-			}
-		}`, id)
-	}
-
-	want := DevicePostureIntegration{
-		IntegrationID: id,
-		Name:          "My Tanium integration",
-		Type:          "tanium_s2s",
-		Interval:      "1h",
-		Config: DevicePostureIntegrationConfig{
-			ApiUrl:             "https://api_url.example.com",
-			ClientSecret:       "test_client_secret",
-			AccessClientID:     "test_access_client_id",
-			AccessClientSecret: "test_access_client_secret",
-		},
-	}
-
-	mux.HandleFunc("/accounts/"+testAccountID+"/devices/posture/integration", handler)
-
-	actual, err := client.CreateDevicePostureIntegration(context.Background(), testAccountID, want)
-
-	if assert.NoError(t, err) {
-		assert.Equal(t, want, actual)
-	}
-}
-
 func TestDevicePostureIntegrationDelete(t *testing.T) {
 	setup()
 	defer teardown()
diff --git a/teams_rules_test.go b/teams_rules_test.go
index 5fe9ac6c5..8bc93b989 100644
--- a/teams_rules_test.go
+++ b/teams_rules_test.go
@@ -66,6 +66,11 @@ func TestTeamsRules(t *testing.T) {
 						"ipv6": [
 							{"ip": "2460::1"}
 						]
+					},
+					"notification_settings": {
+						"enabled": true,
+						"msg": "message",
+						"support_url": "https://hello.com"
 					}
 				  }
 				},
@@ -161,6 +166,11 @@ func TestTeamsRules(t *testing.T) {
 					},
 				},
 			},
+			NotificationSettings: &TeamsNotificationSettings{
+				Enabled:    BoolPtr(true),
+				Message:    "message",
+				SupportURL: "https://hello.com",
+			},
 		},
 		CreatedAt: &createdAt,
 		UpdatedAt: &updatedAt,