From b578250796fffc743e56807b383a7fa3bd301b8c Mon Sep 17 00:00:00 2001 From: Brad Date: Tue, 28 Jun 2022 10:14:49 -0500 Subject: [PATCH] add waiting_room queueing_method --- .changelog/1759.txt | 3 +++ docs/resources/ruleset.md | 4 ++-- docs/resources/waiting_room.md | 1 + internal/provider/resource_cloudflare_waiting_room.go | 2 ++ .../provider/resource_cloudflare_waiting_room_test.go | 2 ++ internal/provider/schema_cloudflare_waiting_room.go | 8 ++++++++ 6 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .changelog/1759.txt diff --git a/.changelog/1759.txt b/.changelog/1759.txt new file mode 100644 index 0000000000..05726e64e2 --- /dev/null +++ b/.changelog/1759.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/cloudflare_waiting_room: Add queueing_method field. +``` \ No newline at end of file diff --git a/docs/resources/ruleset.md b/docs/resources/ruleset.md index e11bdbcc94..5e9bb4ee41 100644 --- a/docs/resources/ruleset.md +++ b/docs/resources/ruleset.md @@ -362,7 +362,7 @@ resource "cloudflare_ruleset" "redirect_from_list_example" { - `kind` (String) Type of Ruleset to create. Available values: `custom`, `managed`, `root`, `schema`, `zone`. - `name` (String) Name of the ruleset. -- `phase` (String) Point in the request/response lifecycle where the ruleset will be created. Available values: `ddos_l4`, `ddos_l7`, `http_log_custom_fields`, `http_request_cache_settings`, `http_request_firewall_custom`, `http_request_firewall_managed`, `http_request_late_transform`, `http_request_late_transform_managed`, `http_request_main`, `http_request_origin`, `http_request_redirect`, `http_request_sanitize`, `http_request_transform`, `http_response_firewall_managed`, `http_response_headers_transform`, `magic_transit`, `http_ratelimit`, `http_request_sbfm`. +- `phase` (String) Point in the request/response lifecycle where the ruleset will be created. Available values: `ddos_l4`, `ddos_l7`, `http_log_custom_fields`, `http_request_cache_settings`, `http_request_firewall_custom`, `http_request_firewall_managed`, `http_request_late_transform`, `http_request_late_transform_managed`, `http_request_main`, `http_request_origin`, `http_request_redirect`, `http_request_sanitize`, `http_request_transform`, `http_response_firewall_managed`, `http_response_headers_transform`, `http_response_headers_transform_managed`, `magic_transit`, `http_ratelimit`, `http_request_sbfm`. ### Optional @@ -418,7 +418,7 @@ Optional: - `origin` (Block List, Max: 1) List of properties to change request origin. (see [below for nested schema](#nestedblock--rules--action_parameters--origin)) - `origin_error_page_passthru` (Boolean) Pass-through error page for origin. - `overrides` (Block List, Max: 1) List of override configurations to apply to the ruleset. (see [below for nested schema](#nestedblock--rules--action_parameters--overrides)) -- `phases` (Set of String) Point in the request/response lifecycle where the ruleset will be created. Available values: `ddos_l4`, `ddos_l7`, `http_log_custom_fields`, `http_request_cache_settings`, `http_request_firewall_custom`, `http_request_firewall_managed`, `http_request_late_transform`, `http_request_late_transform_managed`, `http_request_main`, `http_request_origin`, `http_request_redirect`, `http_request_sanitize`, `http_request_transform`, `http_response_firewall_managed`, `http_response_headers_transform`, `magic_transit`, `http_ratelimit`, `http_request_sbfm`. +- `phases` (Set of String) Point in the request/response lifecycle where the ruleset will be created. Available values: `ddos_l4`, `ddos_l7`, `http_log_custom_fields`, `http_request_cache_settings`, `http_request_firewall_custom`, `http_request_firewall_managed`, `http_request_late_transform`, `http_request_late_transform_managed`, `http_request_main`, `http_request_origin`, `http_request_redirect`, `http_request_sanitize`, `http_request_transform`, `http_response_firewall_managed`, `http_response_headers_transform`, `http_response_headers_transform_managed`, `magic_transit`, `http_ratelimit`, `http_request_sbfm`. - `products` (Set of String) Products to target with the actions. Available values: `bic`, `hot`, `ratelimit`, `securityLevel`, `uablock`, `waf`, `zonelockdown`. - `request_fields` (Set of String) List of request headers to include as part of custom fields logging, in lowercase. - `respect_strong_etags` (Boolean) Respect strong ETags. diff --git a/docs/resources/waiting_room.md b/docs/resources/waiting_room.md index a70e124f0d..641c5a86ee 100644 --- a/docs/resources/waiting_room.md +++ b/docs/resources/waiting_room.md @@ -42,6 +42,7 @@ resource "cloudflare_waiting_room" "example" { - `json_response_enabled` (Boolean) If true, requests to the waiting room with the header `Accept: application/json` will receive a JSON response object. - `path` (String) The path within the host to enable the waiting room on. - `queue_all` (Boolean) If queue_all is true, then all traffic will be sent to the waiting room. +- `queueing_method` (String) The queueing method used by the waiting room. Available values: `fifo`, `random`, `passthrough`, `reject`. Defaults to `fifo`. - `session_duration` (Number) Lifetime of a cookie (in minutes) set by Cloudflare for users who get access to the origin. - `suspended` (Boolean) Suspends the waiting room. - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) diff --git a/internal/provider/resource_cloudflare_waiting_room.go b/internal/provider/resource_cloudflare_waiting_room.go index b8a519ec98..3e8d7d8597 100644 --- a/internal/provider/resource_cloudflare_waiting_room.go +++ b/internal/provider/resource_cloudflare_waiting_room.go @@ -41,6 +41,7 @@ func buildWaitingRoom(d *schema.ResourceData) cloudflare.WaitingRoom { TotalActiveUsers: d.Get("total_active_users").(int), NewUsersPerMinute: d.Get("new_users_per_minute").(int), CustomPageHTML: d.Get("custom_page_html").(string), + QueueingMethod: d.Get("queueing_method").(string), DefaultTemplateLanguage: d.Get("default_template_language").(string), SessionDuration: d.Get("session_duration").(int), JsonResponseEnabled: d.Get("json_response_enabled").(bool), @@ -93,6 +94,7 @@ func resourceCloudflareWaitingRoomRead(ctx context.Context, d *schema.ResourceDa d.Set("total_active_users", waitingRoom.TotalActiveUsers) d.Set("session_duration", waitingRoom.SessionDuration) d.Set("disable_session_renewal", waitingRoom.DisableSessionRenewal) + d.Set("queueing_method", waitingRoom.QueueingMethod) d.Set("custom_page_html", waitingRoom.CustomPageHTML) d.Set("default_template_language", waitingRoom.DefaultTemplateLanguage) d.Set("json_response_enabled", waitingRoom.JsonResponseEnabled) diff --git a/internal/provider/resource_cloudflare_waiting_room_test.go b/internal/provider/resource_cloudflare_waiting_room_test.go index 66346b1ae6..32ed7fd60b 100644 --- a/internal/provider/resource_cloudflare_waiting_room_test.go +++ b/internal/provider/resource_cloudflare_waiting_room_test.go @@ -30,6 +30,7 @@ func TestAccCloudflareWaitingRoom_Create(t *testing.T) { resource.TestCheckResourceAttr(name, "zone_id", zoneID), resource.TestCheckResourceAttr(name, "name", waitingRoomName), resource.TestCheckResourceAttr(name, "description", "my desc"), + resource.TestCheckResourceAttr(name, "queueing_method", "fifo"), resource.TestCheckResourceAttr(name, "custom_page_html", "foobar"), resource.TestCheckResourceAttr(name, "default_template_language", "en-US"), resource.TestCheckResourceAttr(name, "disable_session_renewal", "true"), @@ -72,6 +73,7 @@ resource "cloudflare_waiting_room" "%[1]s" { total_active_users = 405 path = "%[5]s" session_duration = 10 + queueing_method = "fifo" custom_page_html = "foobar" default_template_language = "en-US" description = "my desc" diff --git a/internal/provider/schema_cloudflare_waiting_room.go b/internal/provider/schema_cloudflare_waiting_room.go index 905aaf0b9a..c1da6896f0 100644 --- a/internal/provider/schema_cloudflare_waiting_room.go +++ b/internal/provider/schema_cloudflare_waiting_room.go @@ -84,6 +84,14 @@ func resourceCloudflareWaitingRoomSchema() map[string]*schema.Schema { Optional: true, }, + "queueing_method": { + Description: fmt.Sprintf("The queueing method used by the waiting room. %s", renderAvailableDocumentationValuesStringSlice(waitingRoomQueueingMethod)), + Type: schema.TypeString, + Default: "fifo", + Optional: true, + ValidateFunc: validation.StringInSlice(waitingRoomQueueingMethod, false), + }, + "default_template_language": { Description: fmt.Sprintf("The language to use for the default waiting room page. %s", renderAvailableDocumentationValuesStringSlice(defaultTemplateLanguages)), Type: schema.TypeString,