# Rules ## List Waiting Room Rules `waiting_rooms.rules.get(strwaiting_room_id, RuleGetParams**kwargs) -> SyncSinglePage[WaitingRoomRule]` **get** `/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules` Lists rules for a waiting room. ### Parameters - `zone_id: str` Identifier. - `waiting_room_id: str` ### Returns - `class WaitingRoomRule: …` - `id: Optional[str]` The ID of the rule. - `action: Optional[Literal["bypass_waiting_room"]]` The action to take when the expression matches. - `"bypass_waiting_room"` - `description: Optional[str]` The description of the rule. - `enabled: Optional[bool]` When set to true, the rule is enabled. - `expression: Optional[str]` Criteria defining when there is a match for the current rule. - `last_updated: Optional[datetime]` - `version: Optional[str]` The version of the rule. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.waiting_rooms.rules.get( waiting_room_id="699d98642c564d2e855e9661899b7252", zone_id="023e105f4ecef8ad9ca31a8372d0c353", ) page = page.result[0] print(page.id) ``` #### 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 `waiting_rooms.rules.create(strwaiting_room_id, RuleCreateParams**kwargs) -> SyncSinglePage[WaitingRoomRule]` **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 - `zone_id: str` Identifier. - `waiting_room_id: str` - `rules: Rules` - `action: Literal["bypass_waiting_room"]` The action to take when the expression matches. - `"bypass_waiting_room"` - `expression: str` Criteria defining when there is a match for the current rule. - `description: Optional[str]` The description of the rule. - `enabled: Optional[bool]` When set to true, the rule is enabled. ### Returns - `class WaitingRoomRule: …` - `id: Optional[str]` The ID of the rule. - `action: Optional[Literal["bypass_waiting_room"]]` The action to take when the expression matches. - `"bypass_waiting_room"` - `description: Optional[str]` The description of the rule. - `enabled: Optional[bool]` When set to true, the rule is enabled. - `expression: Optional[str]` Criteria defining when there is a match for the current rule. - `last_updated: Optional[datetime]` - `version: Optional[str]` The version of the rule. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.waiting_rooms.rules.create( waiting_room_id="699d98642c564d2e855e9661899b7252", zone_id="023e105f4ecef8ad9ca31a8372d0c353", rules={ "action": "bypass_waiting_room", "expression": "ip.src in {10.20.30.40}", }, ) page = page.result[0] print(page.id) ``` #### 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 `waiting_rooms.rules.update(strwaiting_room_id, RuleUpdateParams**kwargs) -> SyncSinglePage[WaitingRoomRule]` **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 - `zone_id: str` Identifier. - `waiting_room_id: str` - `rules: Iterable[Rule]` - `action: Literal["bypass_waiting_room"]` The action to take when the expression matches. - `"bypass_waiting_room"` - `expression: str` Criteria defining when there is a match for the current rule. - `description: Optional[str]` The description of the rule. - `enabled: Optional[bool]` When set to true, the rule is enabled. ### Returns - `class WaitingRoomRule: …` - `id: Optional[str]` The ID of the rule. - `action: Optional[Literal["bypass_waiting_room"]]` The action to take when the expression matches. - `"bypass_waiting_room"` - `description: Optional[str]` The description of the rule. - `enabled: Optional[bool]` When set to true, the rule is enabled. - `expression: Optional[str]` Criteria defining when there is a match for the current rule. - `last_updated: Optional[datetime]` - `version: Optional[str]` The version of the rule. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.waiting_rooms.rules.update( waiting_room_id="699d98642c564d2e855e9661899b7252", zone_id="023e105f4ecef8ad9ca31a8372d0c353", rules=[{ "action": "bypass_waiting_room", "expression": "ip.src in {10.20.30.40}", }], ) page = page.result[0] print(page.id) ``` #### 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 `waiting_rooms.rules.edit(strrule_id, RuleEditParams**kwargs) -> SyncSinglePage[WaitingRoomRule]` **patch** `/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules/{rule_id}` Patches a rule for a waiting room. ### Parameters - `zone_id: str` Identifier. - `waiting_room_id: str` - `rule_id: str` The ID of the rule. - `action: Literal["bypass_waiting_room"]` The action to take when the expression matches. - `"bypass_waiting_room"` - `expression: str` Criteria defining when there is a match for the current rule. - `description: Optional[str]` The description of the rule. - `enabled: Optional[bool]` When set to true, the rule is enabled. - `position: Optional[Position]` Reorder the position of a rule - `class PositionIndex: …` - `index: Optional[int]` 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). - `class PositionBefore: …` - `before: Optional[str]` 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. - `class PositionAfter: …` - `after: Optional[str]` 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 - `class WaitingRoomRule: …` - `id: Optional[str]` The ID of the rule. - `action: Optional[Literal["bypass_waiting_room"]]` The action to take when the expression matches. - `"bypass_waiting_room"` - `description: Optional[str]` The description of the rule. - `enabled: Optional[bool]` When set to true, the rule is enabled. - `expression: Optional[str]` Criteria defining when there is a match for the current rule. - `last_updated: Optional[datetime]` - `version: Optional[str]` The version of the rule. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.waiting_rooms.rules.edit( rule_id="25756b2dfe6e378a06b033b670413757", zone_id="023e105f4ecef8ad9ca31a8372d0c353", waiting_room_id="699d98642c564d2e855e9661899b7252", action="bypass_waiting_room", expression="ip.src in {10.20.30.40}", ) page = page.result[0] print(page.id) ``` #### 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 `waiting_rooms.rules.delete(strrule_id, RuleDeleteParams**kwargs) -> SyncSinglePage[WaitingRoomRule]` **delete** `/zones/{zone_id}/waiting_rooms/{waiting_room_id}/rules/{rule_id}` Deletes a rule for a waiting room. ### Parameters - `zone_id: str` Identifier. - `waiting_room_id: str` - `rule_id: str` The ID of the rule. ### Returns - `class WaitingRoomRule: …` - `id: Optional[str]` The ID of the rule. - `action: Optional[Literal["bypass_waiting_room"]]` The action to take when the expression matches. - `"bypass_waiting_room"` - `description: Optional[str]` The description of the rule. - `enabled: Optional[bool]` When set to true, the rule is enabled. - `expression: Optional[str]` Criteria defining when there is a match for the current rule. - `last_updated: Optional[datetime]` - `version: Optional[str]` The version of the rule. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.waiting_rooms.rules.delete( rule_id="25756b2dfe6e378a06b033b670413757", zone_id="023e105f4ecef8ad9ca31a8372d0c353", waiting_room_id="699d98642c564d2e855e9661899b7252", ) page = page.result[0] print(page.id) ``` #### 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 - `class WaitingRoomRule: …` - `id: Optional[str]` The ID of the rule. - `action: Optional[Literal["bypass_waiting_room"]]` The action to take when the expression matches. - `"bypass_waiting_room"` - `description: Optional[str]` The description of the rule. - `enabled: Optional[bool]` When set to true, the rule is enabled. - `expression: Optional[str]` Criteria defining when there is a match for the current rule. - `last_updated: Optional[datetime]` - `version: Optional[str]` The version of the rule.