nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: cloudflare/cloudflare-go
Pull request #988 (2022-07-12 15:58:28)

Add filtering flag for managed headers API
Adding ability to filter managed headers using new API flag



Patch:
diff --git a/managed_headers.go b/managed_headers.go
index a1d6f3a67..11b2941d5 100644
--- a/managed_headers.go
+++ b/managed_headers.go
@@ -28,15 +28,16 @@ type ManagedHeader struct {
 	ConflictsWith []string `json:"conflicts_with,omitempty"`
 }
 
-type ListManagedHeadersParams struct{}
+type ListManagedHeadersParams struct {
+	Status string `url:"status,omitempty"`
+}
 
 func (api *API) ListZoneManagedHeaders(ctx context.Context, rc *ResourceContainer, params ListManagedHeadersParams) (ManagedHeaders, error) {
 	if rc.Identifier == "" {
 		return ManagedHeaders{}, ErrMissingZoneID
 	}
 
-	uri := fmt.Sprintf("/zones/%s/managed_headers", rc.Identifier)
-
+	uri := buildURI(fmt.Sprintf("/zones/%s/managed_headers", rc.Identifier), params)
 	res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
 	if err != nil {
 		return ManagedHeaders{}, err


Test patch:
diff --git a/managed_headers_test.go b/managed_headers_test.go
index 833dd2622..a1c202ed7 100644
--- a/managed_headers_test.go
+++ b/managed_headers_test.go
@@ -85,6 +85,63 @@ func TestListManagedHeaders(t *testing.T) {
 	}
 }
 
+func TestFilterManagedHeaders(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)
+		assert.Equal(t, r.URL.Query().Get("status"), "enabled")
+		w.Header().Set("content-type", "application/json")
+		fmt.Fprint(w, `{
+      "result": {
+        "managed_request_headers": [
+          {
+            "id": "add_visitor_location_headers",
+            "enabled": true,
+            "has_conflict": false
+          }
+        ],
+        "managed_response_headers": [
+          {
+            "id": "remove_x-powered-by_header",
+            "enabled": true,
+            "has_conflict": false
+          }
+        ]
+      },
+      "success": true,
+      "errors": [],
+      "messages": []
+    }`)
+	}
+	mux.HandleFunc("/zones/"+testZoneID+"/managed_headers", handler)
+
+	want := ManagedHeaders{
+		ManagedRequestHeaders: []ManagedHeader{
+			{
+				ID:         "add_visitor_location_headers",
+				Enabled:    true,
+				HasCoflict: false,
+			},
+		},
+		ManagedResponseHeaders: []ManagedHeader{
+			{
+				ID:         "remove_x-powered-by_header",
+				Enabled:    true,
+				HasCoflict: false,
+			},
+		},
+	}
+
+	zoneActual, err := client.ListZoneManagedHeaders(context.Background(), ZoneIdentifier(testZoneID), ListManagedHeadersParams{
+		Status: "enabled",
+	})
+	if assert.NoError(t, err) {
+		assert.Equal(t, want, zoneActual)
+	}
+}
+
 func TestUpdateManagedHeaders(t *testing.T) {
 	setup()
 	defer teardown()
Repository: cloudflare/cloudflare-go
Pull request #991 (2022-07-13 13:35:38)

Expose Blockpage.{MailtoAddress,MailtoSubject} fields
## Description

Cloudflare documentation for TeamsAccount blockpage settings exposes `created_on` field.
https://api.cloudflare.com/#zero-trust-accounts-update-zero-trust-account-configuration

## Has your change been tested?

No tests exist for blockpage settings.

## 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.
- [ ] 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.

jacobbednarz: can you please add test coverage for these new fields?

Patch:
diff --git a/teams_accounts.go b/teams_accounts.go
index 04ed8df9b..ab7ee7e94 100644
--- a/teams_accounts.go
+++ b/teams_accounts.go
@@ -73,6 +73,8 @@ type TeamsBlockPage struct {
 	LogoPath        string `json:"logo_path,omitempty"`
 	BackgroundColor string `json:"background_color,omitempty"`
 	Name            string `json:"name,omitempty"`
+	MailtoAddress   string `json:"mailto_address,omitempty"`
+	MailtoSubject   string `json:"mailto_subject,omitempty"`
 }
 
 type TeamsRuleType = string


Test patch:
diff --git a/teams_accounts_test.go b/teams_accounts_test.go
index bae38f141..3a59db9a7 100644
--- a/teams_accounts_test.go
+++ b/teams_accounts_test.go
@@ -64,6 +64,16 @@ func TestTeamsAccountConfiguration(t *testing.T) {
 					},
 					"activity_log": {
 						"enabled": true
+					},
+					"block_page": {
+						"enabled": true,
+						"name": "Cloudflare",
+						"footer_text": "--footer--",
+						"header_text": "--header--",
+						"mailto_address": "admin@example.com",
+						"mailto_subject": "Blocked User Inquiry",
+						"logo_path": "https://logos.com/a.png",
+						"background_color": "#ff0000"
 					}
 				}
 			}
@@ -81,6 +91,17 @@ func TestTeamsAccountConfiguration(t *testing.T) {
 			ActivityLog: &TeamsActivityLog{Enabled: true},
 			TLSDecrypt:  &TeamsTLSDecrypt{Enabled: true},
 			FIPS:        &TeamsFIPS{TLS: true},
+
+			BlockPage: &TeamsBlockPage{
+				Enabled:         BoolPtr(true),
+				FooterText:      "--footer--",
+				HeaderText:      "--header--",
+				LogoPath:        "https://logos.com/a.png",
+				BackgroundColor: "#ff0000",
+				Name:            "Cloudflare",
+				MailtoAddress:   "admin@example.com",
+				MailtoSubject:   "Blocked User Inquiry",
+			},
 		})
 	}
 }
Repository: cloudflare/cloudflare-go
Pull request #1060 (2022-08-25 01:42:46)

Fix typo on email API settings endpoint
## Description

The endpoint for enabling Email Routing for a zone is `enable` and not `enabled`

## Has your change been tested?

Updated unit tests and they pass

## Types of changes

What sort of change does your code introduce/modify?

- [X] Bug fix (non-breaking change which fixes an issue)
- [ ] 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.
- [ ] 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.



Patch:
diff --git a/.changelog/1060.txt b/.changelog/1060.txt
new file mode 100644
index 000000000..54ec6e02f
--- /dev/null
+++ b/.changelog/1060.txt
@@ -0,0 +1,3 @@
+```release-note:bug
+email_routing_settings: change enable endpoint from `enabled` to `enable`
+```
diff --git a/email_routing_settings.go b/email_routing_settings.go
index 016605536..9e27c0c21 100644
--- a/email_routing_settings.go
+++ b/email_routing_settings.go
@@ -58,7 +58,7 @@ func (api *API) EnableEmailRouting(ctx context.Context, rc *ResourceContainer) (
 	if rc.Identifier == "" {
 		return EmailRoutingSettings{}, ErrMissingZoneID
 	}
-	uri := fmt.Sprintf("/zones/%s/email/routing/enabled", rc.Identifier)
+	uri := fmt.Sprintf("/zones/%s/email/routing/enable", rc.Identifier)
 	res, err := api.makeRequestContext(ctx, http.MethodPost, uri, nil)
 	if err != nil {
 		return EmailRoutingSettings{}, err


Test patch:
diff --git a/email_routing_settings_test.go b/email_routing_settings_test.go
index 6e937a69c..975e93980 100644
--- a/email_routing_settings_test.go
+++ b/email_routing_settings_test.go
@@ -64,7 +64,7 @@ func TestEmailRouting_Enable(t *testing.T) {
 	setup()
 	defer teardown()
 
-	mux.HandleFunc("/zones/"+testZoneID+"/email/routing/enabled", func(w http.ResponseWriter, r *http.Request) {
+	mux.HandleFunc("/zones/"+testZoneID+"/email/routing/enable", 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.Fprint(w, `{
Repository: cloudflare/cloudflare-go
Pull request #1159 (2022-12-28 21:24:31)

Add user_seat_expiration_inactive_time field to Access org
## Description

Adds the `user_seat_expiration_inactive_time` field to Access organizations. API docs will be updated soon to show this new field as well.


## Types of changes

- [X] New feature (non-breaking change which adds functionality)


Patch:
diff --git a/.changelog/1159.txt b/.changelog/1159.txt
new file mode 100644
index 000000000..5aca5dc5b
--- /dev/null
+++ b/.changelog/1159.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+access_organization: add user_seat_expiration_inactive_time field
+```
diff --git a/access_organization.go b/access_organization.go
index dbebdca7e..35c9e9e37 100644
--- a/access_organization.go
+++ b/access_organization.go
@@ -10,12 +10,13 @@ import (
 
 // AccessOrganization represents an Access organization.
 type AccessOrganization struct {
-	CreatedAt    *time.Time                    `json:"created_at"`
-	UpdatedAt    *time.Time                    `json:"updated_at"`
-	Name         string                        `json:"name"`
-	AuthDomain   string                        `json:"auth_domain"`
-	LoginDesign  AccessOrganizationLoginDesign `json:"login_design"`
-	IsUIReadOnly *bool                         `json:"is_ui_read_only,omitempty"`
+	CreatedAt                      *time.Time                    `json:"created_at"`
+	UpdatedAt                      *time.Time                    `json:"updated_at"`
+	Name                           string                        `json:"name"`
+	AuthDomain                     string                        `json:"auth_domain"`
+	LoginDesign                    AccessOrganizationLoginDesign `json:"login_design"`
+	IsUIReadOnly                   *bool                         `json:"is_ui_read_only,omitempty"`
+	UserSeatExpirationInactiveTime string                        `json:"user_seat_expiration_inactive_time,omitempty"`
 }
 
 // AccessOrganizationLoginDesign represents the login design options.


Test patch:
diff --git a/access_organization_test.go b/access_organization_test.go
index 0e1cede85..f09a0a37e 100644
--- a/access_organization_test.go
+++ b/access_organization_test.go
@@ -27,6 +27,7 @@ func TestAccessOrganization(t *testing.T) {
 				"name": "Widget Corps Internal Applications",
 				"auth_domain": "test.cloudflareaccess.com",
 				"is_ui_read_only": false,
+				"user_seat_expiration_inactive_time": "720h",
 				"login_design": {
 					"background_color": "#c5ed1b",
 					"logo_path": "https://example.com/logo.png",
@@ -54,7 +55,8 @@ func TestAccessOrganization(t *testing.T) {
 			HeaderText:      "Widget Corp",
 			FooterText:      "© Widget Corp",
 		},
-		IsUIReadOnly: BoolPtr(false),
+		IsUIReadOnly:                   BoolPtr(false),
+		UserSeatExpirationInactiveTime: "720h",
 	}
 
 	mux.HandleFunc("/accounts/"+testAccountID+"/access/organizations", handler)
Repository: cloudflare/cloudflare-go
Pull request #1275 (2023-05-04 06:07:33)

rulesets: allow `PreserveQueryString` to be nullable
Updates the `PreserveQueryString` field to be a boolean pointer to be nullable.

github-actions[bot]: changelog detected :white_check_mark:

Patch:
diff --git a/.changelog/1275.txt b/.changelog/1275.txt
new file mode 100644
index 000000000..718b80065
--- /dev/null
+++ b/.changelog/1275.txt
@@ -0,0 +1,3 @@
+```release-note:bug
+rulesets: allow `PreserveQueryString` to be nullable
+```
diff --git a/rulesets.go b/rulesets.go
index 8110d0206..72a7a4f3b 100644
--- a/rulesets.go
+++ b/rulesets.go
@@ -275,7 +275,7 @@ type RulesetRuleActionParametersAutoMinify struct {
 type RulesetRuleActionParametersFromValue struct {
 	StatusCode          uint16                               `json:"status_code,omitempty"`
 	TargetURL           RulesetRuleActionParametersTargetURL `json:"target_url"`
-	PreserveQueryString bool                                 `json:"preserve_query_string,omitempty"`
+	PreserveQueryString *bool                                `json:"preserve_query_string,omitempty"`
 }
 
 type RulesetRuleActionParametersTargetURL struct {


Test patch:
diff --git a/rulesets_test.go b/rulesets_test.go
index c126c7239..52e9ed88c 100644
--- a/rulesets_test.go
+++ b/rulesets_test.go
@@ -523,7 +523,7 @@ func TestGetRuleset_RedirectFromValue(t *testing.T) {
 				TargetURL: RulesetRuleActionParametersTargetURL{
 					Value: "some_host.com",
 				},
-				PreserveQueryString: true,
+				PreserveQueryString: BoolPtr(true),
 			},
 		},
 		Description: "Set dynamic redirect from value",
Repository: cloudflare/cloudflare-go
Pull request #1345 (2023-08-01 14:52:07)

Fix dispatch API path
## Description
As per the [API documentation](https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/get-started/configuration/#2-create-dispatcher), the path should have `/dispatch` when deploying to the namespaced dispatch API.

Otherwise, we had the following error:

```
error uploading worker '123-456-abcdefghi': PUT method not allowed for the api_token authentication scheme (10000)
```

Upon adding `/dispatch` into the URL, we got successful responses.

## Types of changes

What sort of change does your code introduce/modify?

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] 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.
- [ ] I have updated the documentation accordingly.
- [ ] 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/1345.txt b/.changelog/1345.txt
new file mode 100644
index 000000000..4e748a75c
--- /dev/null
+++ b/.changelog/1345.txt
@@ -0,0 +1,3 @@
+```release-note:bug
+workers: Fix namespace dispatch upload API path
+```
diff --git a/workers.go b/workers.go
index 8d4297ce4..b5932f88b 100644
--- a/workers.go
+++ b/workers.go
@@ -277,7 +277,7 @@ func (api *API) UploadWorker(ctx context.Context, rc *ResourceContainer, params
 
 	uri := fmt.Sprintf("/accounts/%s/workers/scripts/%s", rc.Identifier, params.ScriptName)
 	if params.DispatchNamespaceName != nil {
-		uri = fmt.Sprintf("/accounts/%s/workers/namespaces/%s/scripts/%s", rc.Identifier, *params.DispatchNamespaceName, params.ScriptName)
+		uri = fmt.Sprintf("/accounts/%s/workers/dispatch/namespaces/%s/scripts/%s", rc.Identifier, *params.DispatchNamespaceName, params.ScriptName)
 	}
 
 	headers := make(http.Header)


Test patch:
diff --git a/workers_test.go b/workers_test.go
index d116e9384..b0f356c02 100644
--- a/workers_test.go
+++ b/workers_test.go
@@ -1217,7 +1217,7 @@ func TestUploadWorker_ToDispatchNamespace(t *testing.T) {
 		fmt.Fprint(w, workersScriptResponse(t))
 	}
 	mux.HandleFunc(
-		fmt.Sprintf("/accounts/"+testAccountID+"/workers/namespaces/%s/scripts/bar", namespaceName),
+		fmt.Sprintf("/accounts/"+testAccountID+"/workers/dispatch/namespaces/%s/scripts/bar", namespaceName),
 		handler,
 	)