Repository: cloudflare/cloudflare-go
Pull request #3764 (2024-12-27 18:53:20)

feat: add waiting room turnstile integration fields
This PR adds two new fields to waiting room and waiting room events to configure the integration between WR and Turnstile.

## 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 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/3764.txt b/.changelog/3764.txt
new file mode 100644
index 000000000..a61bbf8bc
--- /dev/null
+++ b/.changelog/3764.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+waiting_room: add waiting room turnstile integration fields
+```
\ No newline at end of file
diff --git a/waiting_room.go b/waiting_room.go
index c765bd057..48e8338fd 100644
--- a/waiting_room.go
+++ b/waiting_room.go
@@ -41,6 +41,8 @@ type WaitingRoom struct {
 	QueueingStatusCode         int                          `json:"queueing_status_code"`
 	EnabledOriginCommands      []string                     `json:"enabled_origin_commands,omitempty"`
 	CookieAttributes           *WaitingRoomCookieAttributes `json:"cookie_attributes,omitempty"`
+	TurnstileMode              string                       `json:"turnstile_mode,omitempty"`
+	TurnstileAction            string                       `json:"turnstile_action,omitempty"`
 }
 
 // WaitingRoomStatus describes the status of a waiting room.
@@ -70,6 +72,8 @@ type WaitingRoomEvent struct {
 	DisableSessionRenewal *bool      `json:"disable_session_renewal,omitempty"`
 	Suspended             bool       `json:"suspended"`
 	ShuffleAtEventStart   bool       `json:"shuffle_at_event_start"`
+	TurnstileMode         string     `json:"turnstile_mode,omitempty"`
+	TurnstileAction       string     `json:"turnstile_action,omitempty"`
 }
 
 type WaitingRoomRule struct {


Test patch:
diff --git a/waiting_room_test.go b/waiting_room_test.go
index 26f729af7..3e3717d47 100644
--- a/waiting_room_test.go
+++ b/waiting_room_test.go
@@ -43,7 +43,9 @@ var waitingRoomJSON = fmt.Sprintf(`
       "cookie_suffix": "example_shop",
       "additional_routes": [{"host": "shop2.example.com", "path": "/shop/checkout"}],
       "queueing_status_code": 200,
-      "enabled_origin_commands": ["revoke"]
+      "enabled_origin_commands": ["revoke"],
+      "turnstile_mode": "invisible",
+      "turnstile_action": "log"
     }
    `, waitingRoomID, testTimestampWaitingRoom.Format(time.RFC3339Nano), testTimestampWaitingRoom.Format(time.RFC3339Nano),
 	testTimestampWaitingRoomEventStart.Format(time.RFC3339Nano))
@@ -65,7 +67,9 @@ var waitingRoomEventJSON = fmt.Sprintf(`
       "session_duration": null,
       "disable_session_renewal": null,
       "queueing_method": "random",
-      "custom_page_html": "{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Event is prequeueing / Queue all enabled {{/waitTimeKnown}}"
+      "custom_page_html": "{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Event is prequeueing / Queue all enabled {{/waitTimeKnown}}",
+      "turnstile_mode": "invisible",
+      "turnstile_action": "log"
     }
    `, waitingRoomEventID, testTimestampWaitingRoomEvent.Format(time.RFC3339Nano),
 	testTimestampWaitingRoomEvent.Format(time.RFC3339Nano),
@@ -131,6 +135,8 @@ var waitingRoom = WaitingRoom{
 	AdditionalRoutes:           []*WaitingRoomRoute{{Host: "shop2.example.com", Path: "/shop/checkout"}},
 	QueueingStatusCode:         200,
 	EnabledOriginCommands:      []string{"revoke"},
+	TurnstileMode:              "invisible",
+	TurnstileAction:            "log",
 }
 
 var waitingRoomEvent = WaitingRoomEvent{
@@ -150,6 +156,8 @@ var waitingRoomEvent = WaitingRoomEvent{
 	DisableSessionRenewal: nil,
 	QueueingMethod:        "random",
 	CustomPageHTML:        "{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Event is prequeueing / Queue all enabled {{/waitTimeKnown}}",
+	TurnstileMode:         "invisible",
+	TurnstileAction:       "log",
 }
 
 var waitingRoomStatus = WaitingRoomStatus{