# Rules ## List Waiting Room Rules `client.WaitingRooms.Rules.Get(ctx, waitingRoomID, query) (*SinglePage[WaitingRoomRule], error)` **get** `/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules` Lists rules for a waiting room. ### Parameters - `waitingRoomID string` - `query RuleGetParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type WaitingRoomRule struct{…}` - `ID string` The ID of the rule. - `Action WaitingRoomRuleAction` The action to take when the expression matches. - `const WaitingRoomRuleActionBypassWaitingRoom WaitingRoomRuleAction = "bypass_waiting_room"` - `Description string` The description of the rule. - `Enabled bool` When set to true, the rule is enabled. - `Expression string` Criteria defining when there is a match for the current rule. - `LastUpdated Time` - `Version string` The version of the rule. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/waiting_rooms" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.WaitingRooms.Rules.Get( context.TODO(), "699d98642c564d2e855e9661899b7252", waiting_rooms.RuleGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "id": "25756b2dfe6e378a06b033b670413757", "action": "bypass_waiting_room", "description": "allow all traffic from 10.20.30.40", "enabled": true, "expression": "ip.src in {10.20.30.40}", "last_updated": "2014-01-01T05:20:00.12345Z", "version": "1" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Create Waiting Room Rule `client.WaitingRooms.Rules.New(ctx, waitingRoomID, params) (*SinglePage[WaitingRoomRule], error)` **post** `/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules` Only available for the Waiting Room Advanced subscription. Creates a rule for a waiting room. ### Parameters - `waitingRoomID string` - `params RuleNewParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Rules param.Field[RuleNewParamsRules]` Body param - `Action RuleNewParamsRulesAction` The action to take when the expression matches. - `const RuleNewParamsRulesActionBypassWaitingRoom RuleNewParamsRulesAction = "bypass_waiting_room"` - `Expression string` Criteria defining when there is a match for the current rule. - `Description string` The description of the rule. - `Enabled bool` When set to true, the rule is enabled. ### Returns - `type WaitingRoomRule struct{…}` - `ID string` The ID of the rule. - `Action WaitingRoomRuleAction` The action to take when the expression matches. - `const WaitingRoomRuleActionBypassWaitingRoom WaitingRoomRuleAction = "bypass_waiting_room"` - `Description string` The description of the rule. - `Enabled bool` When set to true, the rule is enabled. - `Expression string` Criteria defining when there is a match for the current rule. - `LastUpdated Time` - `Version string` The version of the rule. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/waiting_rooms" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.WaitingRooms.Rules.New( context.TODO(), "699d98642c564d2e855e9661899b7252", waiting_rooms.RuleNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Rules: waiting_rooms.RuleNewParamsRules{ Action: cloudflare.F(waiting_rooms.RuleNewParamsRulesActionBypassWaitingRoom), Expression: cloudflare.F("ip.src in {10.20.30.40}"), }, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "id": "25756b2dfe6e378a06b033b670413757", "action": "bypass_waiting_room", "description": "allow all traffic from 10.20.30.40", "enabled": true, "expression": "ip.src in {10.20.30.40}", "last_updated": "2014-01-01T05:20:00.12345Z", "version": "1" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Replace Waiting Room Rules `client.WaitingRooms.Rules.Update(ctx, waitingRoomID, params) (*SinglePage[WaitingRoomRule], error)` **put** `/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules` Only available for the Waiting Room Advanced subscription. Replaces all rules for a waiting room. ### Parameters - `waitingRoomID string` - `params RuleUpdateParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Rules param.Field[[]RuleUpdateParamsRule]` Body param - `Action RuleUpdateParamsRulesAction` The action to take when the expression matches. - `const RuleUpdateParamsRulesActionBypassWaitingRoom RuleUpdateParamsRulesAction = "bypass_waiting_room"` - `Expression string` Criteria defining when there is a match for the current rule. - `Description string` The description of the rule. - `Enabled bool` When set to true, the rule is enabled. ### Returns - `type WaitingRoomRule struct{…}` - `ID string` The ID of the rule. - `Action WaitingRoomRuleAction` The action to take when the expression matches. - `const WaitingRoomRuleActionBypassWaitingRoom WaitingRoomRuleAction = "bypass_waiting_room"` - `Description string` The description of the rule. - `Enabled bool` When set to true, the rule is enabled. - `Expression string` Criteria defining when there is a match for the current rule. - `LastUpdated Time` - `Version string` The version of the rule. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/waiting_rooms" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.WaitingRooms.Rules.Update( context.TODO(), "699d98642c564d2e855e9661899b7252", waiting_rooms.RuleUpdateParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Rules: []waiting_rooms.RuleUpdateParamsRule{waiting_rooms.RuleUpdateParamsRule{ Action: cloudflare.F(waiting_rooms.RuleUpdateParamsRulesActionBypassWaitingRoom), Expression: cloudflare.F("ip.src in {10.20.30.40}"), }}, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "id": "25756b2dfe6e378a06b033b670413757", "action": "bypass_waiting_room", "description": "allow all traffic from 10.20.30.40", "enabled": true, "expression": "ip.src in {10.20.30.40}", "last_updated": "2014-01-01T05:20:00.12345Z", "version": "1" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Patch Waiting Room Rule `client.WaitingRooms.Rules.Edit(ctx, waitingRoomID, ruleID, params) (*SinglePage[WaitingRoomRule], error)` **patch** `/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules/{rule_id}` Patches a rule for a waiting room. ### Parameters - `waitingRoomID string` - `ruleID string` The ID of the rule. - `params RuleEditParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Action param.Field[RuleEditParamsAction]` Body param: The action to take when the expression matches. - `const RuleEditParamsActionBypassWaitingRoom RuleEditParamsAction = "bypass_waiting_room"` - `Expression param.Field[string]` Body param: Criteria defining when there is a match for the current rule. - `Description param.Field[string]` Body param: The description of the rule. - `Enabled param.Field[bool]` Body param: When set to true, the rule is enabled. - `Position param.Field[RuleEditParamsPosition]` Body param: Reorder the position of a rule - `type RuleEditParamsPositionIndex struct{…}` - `Index int64` Places the rule in the exact position specified by the integer number . Position numbers start with 1. Existing rules in the ruleset from the specified position number onward are shifted one position (no rule is overwritten). - `type RuleEditParamsPositionBefore struct{…}` - `Before string` Places the rule before rule . Use this argument with an empty rule ID value ("") to set the rule as the first rule in the ruleset. - `type RuleEditParamsPositionAfter struct{…}` - `After string` Places the rule after rule . Use this argument with an empty rule ID value ("") to set the rule as the last rule in the ruleset. ### Returns - `type WaitingRoomRule struct{…}` - `ID string` The ID of the rule. - `Action WaitingRoomRuleAction` The action to take when the expression matches. - `const WaitingRoomRuleActionBypassWaitingRoom WaitingRoomRuleAction = "bypass_waiting_room"` - `Description string` The description of the rule. - `Enabled bool` When set to true, the rule is enabled. - `Expression string` Criteria defining when there is a match for the current rule. - `LastUpdated Time` - `Version string` The version of the rule. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/waiting_rooms" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.WaitingRooms.Rules.Edit( context.TODO(), "699d98642c564d2e855e9661899b7252", "25756b2dfe6e378a06b033b670413757", waiting_rooms.RuleEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Action: cloudflare.F(waiting_rooms.RuleEditParamsActionBypassWaitingRoom), Expression: cloudflare.F("ip.src in {10.20.30.40}"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "id": "25756b2dfe6e378a06b033b670413757", "action": "bypass_waiting_room", "description": "allow all traffic from 10.20.30.40", "enabled": true, "expression": "ip.src in {10.20.30.40}", "last_updated": "2014-01-01T05:20:00.12345Z", "version": "1" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Delete Waiting Room Rule `client.WaitingRooms.Rules.Delete(ctx, waitingRoomID, ruleID, body) (*SinglePage[WaitingRoomRule], error)` **delete** `/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules/{rule_id}` Deletes a rule for a waiting room. ### Parameters - `waitingRoomID string` - `ruleID string` The ID of the rule. - `body RuleDeleteParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type WaitingRoomRule struct{…}` - `ID string` The ID of the rule. - `Action WaitingRoomRuleAction` The action to take when the expression matches. - `const WaitingRoomRuleActionBypassWaitingRoom WaitingRoomRuleAction = "bypass_waiting_room"` - `Description string` The description of the rule. - `Enabled bool` When set to true, the rule is enabled. - `Expression string` Criteria defining when there is a match for the current rule. - `LastUpdated Time` - `Version string` The version of the rule. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/waiting_rooms" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.WaitingRooms.Rules.Delete( context.TODO(), "699d98642c564d2e855e9661899b7252", "25756b2dfe6e378a06b033b670413757", waiting_rooms.RuleDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "id": "25756b2dfe6e378a06b033b670413757", "action": "bypass_waiting_room", "description": "allow all traffic from 10.20.30.40", "enabled": true, "expression": "ip.src in {10.20.30.40}", "last_updated": "2014-01-01T05:20:00.12345Z", "version": "1" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Domain Types ### Waiting Room Rule - `type WaitingRoomRule struct{…}` - `ID string` The ID of the rule. - `Action WaitingRoomRuleAction` The action to take when the expression matches. - `const WaitingRoomRuleActionBypassWaitingRoom WaitingRoomRuleAction = "bypass_waiting_room"` - `Description string` The description of the rule. - `Enabled bool` When set to true, the rule is enabled. - `Expression string` Criteria defining when there is a match for the current rule. - `LastUpdated Time` - `Version string` The version of the rule.