Repository: cloudflare/cloudflare-go
Pull request #1212 (2023-02-21 18:58:26)

DLP-809: Add support for DLP payload logging rule/account settings
## Description

DLP recently added support for partial payload logging, which will log a portion region of matching requests and encrypt it using a user-provided public key. This PR adds support for setting that public key and enabling payload logging for individual rules.

## Has your change been tested?

The change includes unit tests to cover the new functions. These tests match the actual responses given/URLs used by the public API.

## 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 (api.cloudflare.com or developers.cloudflare.com) and 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: thanks! a couple of small nitpicks but overall looking good!
OrionNebula: I think I've addressed your comments, if you want to take another look

Patch:
diff --git a/.changelog/1212.txt b/.changelog/1212.txt
new file mode 100644
index 000000000..8656a47b4
--- /dev/null
+++ b/.changelog/1212.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+dlp: Adds support for partial payload logging
+```
diff --git a/.changelog/1213.txt b/.changelog/1213.txt
deleted file mode 100644
index 124db5e91..000000000
--- a/.changelog/1213.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-```release-note:bug
-dex_test: use dex test types and json struct mappings instead of managed networks
-```
diff --git a/.changelog/1215.txt b/.changelog/1215.txt
deleted file mode 100644
index 44307cf98..000000000
--- a/.changelog/1215.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-```release-note:dependency
-deps: bumps golang.org/x/text from 0.3.7 to 0.3.8
-```
diff --git a/.changelog/1216.txt b/.changelog/1216.txt
deleted file mode 100644
index 44307cf98..000000000
--- a/.changelog/1216.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-```release-note:dependency
-deps: bumps golang.org/x/text from 0.3.7 to 0.3.8
-```
diff --git a/.changelog/1217.txt b/.changelog/1217.txt
deleted file mode 100644
index 0fc959900..000000000
--- a/.changelog/1217.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-```release-note:dependency
-deps: bumps golang.org/x/time from 0.0.0-20220224211638-0e9765cccd65 to 0.3.0
-```
diff --git a/.changelog/1218.txt b/.changelog/1218.txt
deleted file mode 100644
index 148e60cca..000000000
--- a/.changelog/1218.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-```release-note:dependency
-deps: bumps golang.org/x/net from 0.0.0-20220722155237-a158d28d115b to 0.7.0
-```
diff --git a/.changelog/1219.txt b/.changelog/1219.txt
deleted file mode 100644
index 148e60cca..000000000
--- a/.changelog/1219.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-```release-note:dependency
-deps: bumps golang.org/x/net from 0.0.0-20220722155237-a158d28d115b to 0.7.0
-```
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b17822996..792686e24 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,18 +6,9 @@ ENHANCEMENTS:
 * teams_accounts: Add new root_certificate_installation_enabled field ([#1208](https://github.com/cloudflare/cloudflare-go/issues/1208))
 * tunnels: automatically paginate `ListTunnels` ([#1206](https://github.com/cloudflare/cloudflare-go/issues/1206))
 
-BUG FIXES:
-
-* dex_test: use dex test types and json struct mappings instead of managed networks ([#1213](https://github.com/cloudflare/cloudflare-go/issues/1213))
-
 DEPENDENCIES:
 
 * deps: bumps github.com/urfave/cli/v2 from 2.24.3 to 2.24.4 ([#1210](https://github.com/cloudflare/cloudflare-go/issues/1210))
-* deps: bumps golang.org/x/net from 0.0.0-20220722155237-a158d28d115b to 0.7.0 ([#1218](https://github.com/cloudflare/cloudflare-go/issues/1218))
-* deps: bumps golang.org/x/net from 0.0.0-20220722155237-a158d28d115b to 0.7.0 ([#1219](https://github.com/cloudflare/cloudflare-go/issues/1219))
-* deps: bumps golang.org/x/text from 0.3.7 to 0.3.8 ([#1215](https://github.com/cloudflare/cloudflare-go/issues/1215))
-* deps: bumps golang.org/x/text from 0.3.7 to 0.3.8 ([#1216](https://github.com/cloudflare/cloudflare-go/issues/1216))
-* deps: bumps golang.org/x/time from 0.0.0-20220224211638-0e9765cccd65 to 0.3.0 ([#1217](https://github.com/cloudflare/cloudflare-go/issues/1217))
 
 ## 0.61.0 (15th February, 2023)
 
diff --git a/devices_dex.go b/devices_dex.go
index f95cb9b5c..d04a84028 100644
--- a/devices_dex.go
+++ b/devices_dex.go
@@ -38,7 +38,7 @@ type DeviceDexTestListResponse struct {
 type ListDeviceDexTestParams struct{}
 
 type CreateDeviceDexTestParams struct {
-	TestID      string             `json:"test_id,omitempty"`
+	TestID      string             `json:"network_id,omitempty"`
 	Name        string             `json:"name"`
 	Description string             `json:"description,omitempty"`
 	Interval    string             `json:"interval"`
@@ -47,7 +47,7 @@ type CreateDeviceDexTestParams struct {
 }
 
 type UpdateDeviceDexTestParams struct {
-	TestID      string             `json:"test_id,omitempty"`
+	TestID      string             `json:"network_id,omitempty"`
 	Name        string             `json:"name"`
 	Description string             `json:"description,omitempty"`
 	Interval    string             `json:"interval"`
@@ -105,25 +105,25 @@ func (api *API) CreateDeviceDexTest(ctx context.Context, rc *ResourceContainer,
 // UpdateDeviceDexTest Updates a Device Dex Test.
 //
 // API reference: https://developers.cloudflare.com/api/operations/device-dex-test-update-device-dex-test
-func (api *API) UpdateDeviceDexTest(ctx context.Context, rc *ResourceContainer, params UpdateDeviceDexTestParams) (DeviceDexTest, error) {
+func (api *API) UpdateDeviceDexTest(ctx context.Context, rc *ResourceContainer, params UpdateDeviceDexTestParams) (DeviceManagedNetwork, error) {
 	if rc.Level != AccountRouteLevel {
-		return DeviceDexTest{}, ErrRequiredAccountLevelResourceContainer
+		return DeviceManagedNetwork{}, ErrRequiredAccountLevelResourceContainer
 	}
 
 	uri := fmt.Sprintf("/%s/%s/devices/dex_tests/%s", rc.Level, rc.Identifier, params.TestID)
 
 	res, err := api.makeRequestContext(ctx, http.MethodPut, uri, params)
 	if err != nil {
-		return DeviceDexTest{}, err
+		return DeviceManagedNetwork{}, err
 	}
 
-	var deviceDexTestsResponse DeviceDexTestResponse
+	var deviceManagedNetworksResponse DeviceManagedNetworkResponse
 
-	if err := json.Unmarshal(res, &deviceDexTestsResponse); err != nil {
-		return DeviceDexTest{}, fmt.Errorf("%s: %w", errUnmarshalError, err)
+	if err := json.Unmarshal(res, &deviceManagedNetworksResponse); err != nil {
+		return DeviceManagedNetwork{}, fmt.Errorf("%s: %w", errUnmarshalError, err)
 	}
 
-	return deviceDexTestsResponse.Result, err
+	return deviceManagedNetworksResponse.Result, err
 }
 
 // GetDeviceDexTest gets a single Device Dex Test.
diff --git a/dlp_payload_log.go b/dlp_payload_log.go
new file mode 100644
index 000000000..34f37ca8c
--- /dev/null
+++ b/dlp_payload_log.go
@@ -0,0 +1,71 @@
+package cloudflare
+
+import (
+	"context"
+	"encoding/json"
+	"fmt"
+	"net/http"
+	"time"
+)
+
+type DLPPayloadLogSettings struct {
+	PublicKey string `json:"public_key,omitempty"`
+
+	// Only present in responses
+	UpdatedAt *time.Time `json:"updated_at,omitempty"`
+}
+
+type GetDLPPayloadLogSettingsParams struct{}
+
+type DLPPayloadLogSettingsResponse struct {
+	Response
+	Result DLPPayloadLogSettings `json:"result"`
+}
+
+// GetDLPPayloadLogSettings gets the current DLP payload logging settings.
+//
+// API reference: https://api.cloudflare.com/#dlp-payload-log-settings-get-settings
+func (api *API) GetDLPPayloadLogSettings(ctx context.Context, rc *ResourceContainer, params GetDLPPayloadLogSettingsParams) (DLPPayloadLogSettings, error) {
+	if rc.Identifier == "" {
+		return DLPPayloadLogSettings{}, ErrMissingResourceIdentifier
+	}
+
+	uri := buildURI(fmt.Sprintf("/%s/%s/dlp/payload_log", rc.Level, rc.Identifier), nil)
+
+	res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
+	if err != nil {
+		return DLPPayloadLogSettings{}, err
+	}
+
+	var dlpPayloadLogSettingsResponse DLPPayloadLogSettingsResponse
+	err = json.Unmarshal(res, &dlpPayloadLogSettingsResponse)
+	if err != nil {
+		return DLPPayloadLogSettings{}, fmt.Errorf("%s: %w", errUnmarshalError, err)
+	}
+
+	return dlpPayloadLogSettingsResponse.Result, nil
+}
+
+// UpdateDLPPayloadLogSettings sets the current DLP payload logging settings to new values.
+//
+// API reference: https://api.cloudflare.com/#dlp-payload-log-settings-update-settings
+func (api *API) UpdateDLPPayloadLogSettings(ctx context.Context, rc *ResourceContainer, settings DLPPayloadLogSettings) (DLPPayloadLogSettings, error) {
+	if rc.Identifier == "" {
+		return DLPPayloadLogSettings{}, ErrMissingResourceIdentifier
+	}
+
+	uri := buildURI(fmt.Sprintf("/%s/%s/dlp/payload_log", rc.Level, rc.Identifier), nil)
+
+	res, err := api.makeRequestContext(ctx, http.MethodPut, uri, settings)
+	if err != nil {
+		return DLPPayloadLogSettings{}, err
+	}
+
+	var dlpPayloadLogSettingsResponse DLPPayloadLogSettingsResponse
+	err = json.Unmarshal(res, &dlpPayloadLogSettingsResponse)
+	if err != nil {
+		return DLPPayloadLogSettings{}, fmt.Errorf("%s: %w", errUnmarshalError, err)
+	}
+
+	return dlpPayloadLogSettingsResponse.Result, nil
+}
diff --git a/go.mod b/go.mod
index cb534c4cb..4731b3bea 100644
--- a/go.mod
+++ b/go.mod
@@ -8,8 +8,8 @@ require (
 	github.com/olekukonko/tablewriter v0.0.5
 	github.com/stretchr/testify v1.8.1
 	github.com/urfave/cli/v2 v2.24.4
-	golang.org/x/net v0.7.0
-	golang.org/x/time v0.3.0
+	golang.org/x/net v0.0.0-20220722155237-a158d28d115b
+	golang.org/x/time v0.0.0-20220224211638-0e9765cccd65
 )
 
 require gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
@@ -30,6 +30,7 @@ require (
 	github.com/rogpeppe/go-internal v1.8.1 // indirect
 	github.com/russross/blackfriday/v2 v2.1.0 // indirect
 	github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
-	golang.org/x/text v0.7.0 // indirect
+	golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
+	golang.org/x/text v0.3.7 // indirect
 	gopkg.in/yaml.v3 v3.0.1 // indirect
 )
diff --git a/go.sum b/go.sum
index 2cf3d4094..dd22cce7c 100644
--- a/go.sum
+++ b/go.sum
@@ -64,44 +64,24 @@ github.com/urfave/cli/v2 v2.24.4 h1:0gyJJEBYtCV87zI/x2nZCPyDxD51K6xM8SkwjHFCNEU=
 github.com/urfave/cli/v2 v2.24.4/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
 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=
-github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
-golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
-golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
-golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
-golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
 golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
-golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
-golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
-golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
 golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
-golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
-golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
 golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
-golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
-golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
-golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 h1:M73Iuj3xbbb9Uk1DYhzydthsj6oOd6l9bpuFcNoUvTs=
+golang.org/x/time v0.0.0-20220224211638-0e9765cccd65/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
-golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/internal/tools/go.mod b/internal/tools/go.mod
index eb343b706..1dfd729e8 100644
--- a/internal/tools/go.mod
+++ b/internal/tools/go.mod
@@ -222,10 +222,10 @@ require (
 	golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
 	golang.org/x/exp/typeparams v0.0.0-20220722155223-a9213eeb770e // indirect
 	golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
-	golang.org/x/net v0.7.0 // indirect
+	golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
 	golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
-	golang.org/x/sys v0.5.0 // indirect
-	golang.org/x/text v0.7.0 // indirect
+	golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41 // indirect
+	golang.org/x/text v0.3.7 // indirect
 	golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect
 	golang.org/x/tools v0.1.13-0.20220812184215-3f9b119300de // indirect
 	golang.org/x/vuln v0.0.0-20220725105440-4151a5aca1df // indirect
diff --git a/internal/tools/go.sum b/internal/tools/go.sum
index aeb2689f0..f5841ad10 100644
--- a/internal/tools/go.sum
+++ b/internal/tools/go.sum
@@ -1005,8 +1005,8 @@ golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5o
 golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
 golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
 golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
-golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
-golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
+golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
+golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
 golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -1103,10 +1103,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.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
-golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41 h1:ohgcoMbSofXygzo6AD2I1kz3BFmW1QArPYTtwEM3UXc=
+golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
-golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
+golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
 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=
@@ -1115,9 +1115,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 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 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
 golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
-golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
 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 16c5134e2..6fdf7cbcd 100644
--- a/teams_rules.go
+++ b/teams_rules.go
@@ -37,6 +37,9 @@ type TeamsRuleSettings struct {
 	InsecureDisableDNSSECValidation bool `json:"insecure_disable_dnssec_validation"`
 
 	EgressSettings *EgressSettings `json:"egress"`
+
+	// DLP payload logging configuration
+	PayloadLog *TeamsDlpPayloadLogSettings `json:"payload_log"`
 }
 
 type EgressSettings struct {
@@ -64,6 +67,10 @@ type TeamsCheckSessionSettings struct {
 	Duration Duration `json:"duration"`
 }
 
+type TeamsDlpPayloadLogSettings struct {
+	Enabled bool `json:"enabled"`
+}
+
 type TeamsFilterType string
 
 type TeamsGatewayAction string


Test patch:
diff --git a/devices_dex_test.go b/devices_dex_test.go
index f5901f791..0db33d442 100644
--- a/devices_dex_test.go
+++ b/devices_dex_test.go
@@ -189,69 +189,6 @@ func TestCreateDeviceDexTest(t *testing.T) {
 	}
 }
 
-func TestUpdateDeviceDexTest(t *testing.T) {
-	setup()
-	defer teardown()
-
-	handler := func(w http.ResponseWriter, r *http.Request) {
-		assert.Equal(t, http.MethodPut, r.Method, "Expected method 'PUT', got %s", r.Method)
-		w.Header().Set("content-type", "application/json")
-		fmt.Fprintf(w, `{
-			"success": true,
-			"errors": [],
-			"messages": [],
-			"result": {
-				"test_id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
-				"name": "http test dash",
-				"description": "dex test description",
-				"interval": "0h30m0s",
-				"enabled": true,
-				"data": {
-				"host": "https://dash.cloudflare.com",
-				"kind": "http",
-				"method": "GET"
-				},
-				"updated": "2023-01-30T19:59:44.401278Z",
-				"created": "2023-01-30T19:59:44.401278Z"
-			}
-		  }`)
-	}
-
-	want := DeviceDexTest{
-		TestID:      testID,
-		Name:        "http test dash",
-		Description: "dex test description",
-		Interval:    "0h30m0s",
-		Enabled:     true,
-		Data: &DeviceDexTestData{
-			"kind":   "http",
-			"method": "GET",
-			"host":   "https://dash.cloudflare.com",
-		},
-		Updated: dexTimestamp,
-		Created: dexTimestamp,
-	}
-
-	mux.HandleFunc("/accounts/"+testAccountID+"/devices/dex_tests/"+testID, handler)
-
-	actual, err := client.UpdateDeviceDexTest(context.Background(), AccountIdentifier(testAccountID), UpdateDeviceDexTestParams{
-		TestID:      testID,
-		Name:        "http test dash",
-		Description: "dex test description",
-		Interval:    "0h30m0s",
-		Enabled:     true,
-		Data: &DeviceDexTestData{
-			"kind":   "http",
-			"method": "GET",
-			"host":   "https://dash.cloudflare.com",
-		},
-	})
-
-	if assert.NoError(t, err) {
-		assert.Equal(t, want, actual)
-	}
-}
-
 func TestDeleteDeviceDexTest(t *testing.T) {
 	setup()
 	defer teardown()
diff --git a/dlp_payload_log_test.go b/dlp_payload_log_test.go
new file mode 100644
index 000000000..4ef505da4
--- /dev/null
+++ b/dlp_payload_log_test.go
@@ -0,0 +1,84 @@
+package cloudflare
+
+import (
+	"context"
+	"encoding/json"
+	"fmt"
+	"net/http"
+	"testing"
+	"time"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/require"
+)
+
+func TestGetDLPPayloadLogSettings(t *testing.T) {
+	setup()
+	defer teardown()
+
+	handler := func(w http.ResponseWriter, r *http.Request) {
+		assert.Equal(t, http.MethodGet, r.Method, "Expected method 'GET', got %s", r.Method)
+		w.Header().Set("content-type", "application/json")
+		fmt.Fprintf(w, `{
+			"success": true,
+			"errors": [],
+			"messages": [],
+			"result": {
+				"public_key": "3NP5MGKjzBLLceVxNZrF+LyithbWX+AVFBMRAA0Xl2A=",
+				"updated_at": "2022-12-22T21:02:39Z"
+			}
+		}`)
+	}
+
+	updatedAt, _ := time.Parse(time.RFC3339, "2022-12-22T21:02:39Z")
+
+	want := DLPPayloadLogSettings{
+		PublicKey: "3NP5MGKjzBLLceVxNZrF+LyithbWX+AVFBMRAA0Xl2A=",
+		UpdatedAt: &updatedAt,
+	}
+
+	mux.HandleFunc("/accounts/"+testAccountID+"/dlp/payload_log", handler)
+
+	actual, err := client.GetDLPPayloadLogSettings(context.Background(), AccountIdentifier(testAccountID), GetDLPPayloadLogSettingsParams{})
+	require.NoError(t, err)
+	require.Equal(t, want, actual)
+}
+
+func TestPutDLPPayloadLogSettings(t *testing.T) {
+	setup()
+	defer teardown()
+
+	handler := func(w http.ResponseWriter, r *http.Request) {
+		assert.Equal(t, http.MethodPut, r.Method, "Expected method 'PUT', got %s", r.Method)
+		w.Header().Set("content-type", "application/json")
+
+		var requestSettings DLPPayloadLogSettings
+		err := json.NewDecoder(r.Body).Decode(&requestSettings)
+		require.Nil(t, err)
+
+		fmt.Fprintf(w, `{
+			"success": true,
+			"errors": [],
+			"messages": [],
+			"result": {
+				"public_key": "`+requestSettings.PublicKey+`",
+				"updated_at": "2022-12-22T21:02:39Z"
+			}
+		}`)
+	}
+
+	updatedAt, _ := time.Parse(time.RFC3339, "2022-12-22T21:02:39Z")
+
+	want := DLPPayloadLogSettings{
+		PublicKey: "3NP5MGKjzBLLceVxNZrF+LyithbWX+AVFBMRAA0Xl2A=",
+		UpdatedAt: &updatedAt,
+	}
+
+	mux.HandleFunc("/accounts/"+testAccountID+"/dlp/payload_log", handler)
+
+	actual, err := client.UpdateDLPPayloadLogSettings(context.Background(), AccountIdentifier(testAccountID), DLPPayloadLogSettings{
+		PublicKey: "3NP5MGKjzBLLceVxNZrF+LyithbWX+AVFBMRAA0Xl2A=",
+	})
+	require.NoError(t, err)
+	require.Equal(t, want, actual)
+}