Skip to content

Commit b38c072

Browse files
pedrosousapatriciasantaana
authored andcommitted
[WAF, Ruleset Engine] Update code blocks (#17127)
1 parent 3f67a3d commit b38c072

25 files changed

+832
-1074
lines changed

src/content/docs/ruleset-engine/basic-operations/add-rule-phase-rulesets.mdx

Lines changed: 73 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ type: overview
44
title: Add rules to phase entry point rulesets
55
sidebar:
66
order: 3
7-
87
---
98

10-
import { Details } from "~/components"
9+
import { Details } from "~/components";
1110

1211
A [phase entry point ruleset](/ruleset-engine/about/rulesets/#entry-point-ruleset) contains an ordered list of rules that run in that phase. A rule in an entry point ruleset can execute a different ruleset. You can have entry point rulesets for each phase at the account level and at the zone level.
1312

@@ -16,19 +15,14 @@ To add one or more rules to a phase entry point ruleset, use one of the [ruleset
1615
If you are adding a **single** rule to a ruleset, consider using one of the [rule creation operations](/ruleset-engine/rulesets-api/add-rule/) instead. In this case, the request will only include the definition of the new rule.
1716

1817
:::note[Creating an entry point ruleset]
19-
20-
2118
Instead of relying on the automatic creation of an entry point ruleset, you can also create this ruleset explicitly using one of the [ruleset creation operations](/ruleset-engine/rulesets-api/create/).
22-
23-
2419
:::
2520

26-
2721
<Details header="Example: Set the rules of a phase entry point ruleset at the zone level">
2822

2923
The following example sets the rules of a phase entry point ruleset at the zone level for the `http_request_firewall_managed` phase using the [Update a zone ruleset](/api/operations/updateZoneRuleset) operation.
3024

31-
```bash title="Request"
25+
```bash
3226
curl --request PUT \
3327
https://api.cloudflare.com/client/v4/zones/{zone_id}/phases/http_request_firewall_managed/entrypoint \
3428
--header "Authorization: Bearer <API_TOKEN>" \
@@ -53,54 +47,52 @@ https://api.cloudflare.com/client/v4/zones/{zone_id}/phases/http_request_firewal
5347
}'
5448
```
5549

56-
```json title="Response"
50+
```json output
5751
{
58-
"result": {
59-
"id": "<RULESET_ID>",
60-
"name": "Default",
61-
"description": "",
62-
"kind": "zone",
63-
"version": "1",
64-
"rules": [
65-
{
66-
"id": "<RULE_ID_1>",
67-
"version": "1",
68-
"action": "execute",
69-
"expression": "true",
70-
"action_parameters": {
71-
"id": "<MANAGED_RULESET_ID_1>"
72-
},
73-
"last_updated": "2021-06-17T15:42:37.917815Z"
74-
},
75-
{
76-
"id": "<RULE_ID_2>",
77-
"version": "1",
78-
"action": "execute",
79-
"expression": "true",
80-
"action_parameters": {
81-
"id": "<MANAGED_RULESET_ID_2>"
82-
},
83-
"last_updated": "2021-06-17T15:42:37.917815Z"
84-
}
85-
],
86-
"last_updated": "2021-06-17T15:42:37.917815Z",
87-
"phase": "http_request_firewall_managed"
88-
},
89-
"success": true,
90-
"errors": [],
91-
"messages": []
52+
"result": {
53+
"id": "<RULESET_ID>",
54+
"name": "Default",
55+
"description": "",
56+
"kind": "zone",
57+
"version": "1",
58+
"rules": [
59+
{
60+
"id": "<RULE_ID_1>",
61+
"version": "1",
62+
"action": "execute",
63+
"expression": "true",
64+
"action_parameters": {
65+
"id": "<MANAGED_RULESET_ID_1>"
66+
},
67+
"last_updated": "2021-06-17T15:42:37.917815Z"
68+
},
69+
{
70+
"id": "<RULE_ID_2>",
71+
"version": "1",
72+
"action": "execute",
73+
"expression": "true",
74+
"action_parameters": {
75+
"id": "<MANAGED_RULESET_ID_2>"
76+
},
77+
"last_updated": "2021-06-17T15:42:37.917815Z"
78+
}
79+
],
80+
"last_updated": "2021-06-17T15:42:37.917815Z",
81+
"phase": "http_request_firewall_managed"
82+
},
83+
"success": true,
84+
"errors": [],
85+
"messages": []
9286
}
9387
```
9488

95-
9689
</Details>
9790

98-
9991
<Details header="Example: Add a single rule to a phase entry point ruleset at the zone level">
10092

10193
The following example adds a single rule to a phase entry point ruleset (with ID `{ruleset_id}`) at the zone level using the [Create a zone ruleset rule](/api/operations/createZoneRulesetRule) operation.
10294

103-
```bash title="Request"
95+
```bash
10496
curl https://api.cloudflare.com/client/v4/zone/{zone_id}/rulesets/{ruleset_id}/rules \
10597
--header "Authorization: Bearer <API_TOKEN>" \
10698
--header "Content-Type: application/json" \
@@ -113,44 +105,43 @@ curl https://api.cloudflare.com/client/v4/zone/{zone_id}/rulesets/{ruleset_id}/r
113105
}'
114106
```
115107

116-
```json title="Response"
108+
```json output
117109
{
118-
"result": {
119-
"id": "<RULESET_ID>",
120-
"name": "Zone-level phase entry point ruleset",
121-
"description": "",
122-
"kind": "root",
123-
"version": "2",
124-
"rules": [
125-
{
126-
"id": "<EXISTING_RULE_ID>",
127-
"version": "1",
128-
"action": "execute",
129-
"expression": "true",
130-
"action_parameters": {
131-
"id": "<ANOTHER_MANAGED_RULESET_ID>"
132-
},
133-
"last_updated": "2021-03-17T15:42:37.917815Z"
134-
},
135-
{
136-
"id": "<NEW_RULE_ID>",
137-
"version": "1",
138-
"action": "execute",
139-
"expression": "true",
140-
"action_parameters": {
141-
"id": "<MANAGED_RULESET_ID>"
142-
},
143-
"last_updated": "2021-06-30T15:42:37.917815Z"
144-
}
145-
],
146-
"last_updated": "2021-06-30T15:42:37.917815Z",
147-
"phase": "http_request_firewall_managed"
148-
},
149-
"success": true,
150-
"errors": [],
151-
"messages": []
110+
"result": {
111+
"id": "<RULESET_ID>",
112+
"name": "Zone-level phase entry point ruleset",
113+
"description": "",
114+
"kind": "root",
115+
"version": "2",
116+
"rules": [
117+
{
118+
"id": "<EXISTING_RULE_ID>",
119+
"version": "1",
120+
"action": "execute",
121+
"expression": "true",
122+
"action_parameters": {
123+
"id": "<ANOTHER_MANAGED_RULESET_ID>"
124+
},
125+
"last_updated": "2021-03-17T15:42:37.917815Z"
126+
},
127+
{
128+
"id": "<NEW_RULE_ID>",
129+
"version": "1",
130+
"action": "execute",
131+
"expression": "true",
132+
"action_parameters": {
133+
"id": "<MANAGED_RULESET_ID>"
134+
},
135+
"last_updated": "2021-06-30T15:42:37.917815Z"
136+
}
137+
],
138+
"last_updated": "2021-06-30T15:42:37.917815Z",
139+
"phase": "http_request_firewall_managed"
140+
},
141+
"success": true,
142+
"errors": [],
143+
"messages": []
152144
}
153145
```
154146

155-
156147
</Details>

src/content/docs/ruleset-engine/basic-operations/deploy-rulesets.mdx

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,27 @@ type: overview
44
title: Deploy rulesets
55
sidebar:
66
order: 4
7-
87
---
98

109
Use the [Rulesets API](/ruleset-engine/rulesets-api/) to deploy a ruleset. To deploy a ruleset, add a rule with `"action": "execute"` to a phase entry point ruleset, specifying the ruleset ID to execute as an action parameter. Use a separate rule for each ruleset you want to deploy.
1110

1211
A rule that executes a ruleset consists of:
1312

14-
* The **ID of the ruleset** you want to execute.
15-
* An **expression**.
16-
* An **action**, set to `execute`.
13+
- The **ID of the ruleset** you want to execute.
14+
- An **expression**.
15+
- An **action**, set to `execute`.
1716

1817
The rules in the ruleset execute when a request satisfies the expression.
1918

2019
:::note
21-
22-
2320
To apply a rule to every request in a phase at the **zone** level, set the rule expression to `true`.
24-
25-
2621
:::
2722

2823
## Example
2924

3025
The following example deploys a managed ruleset to the `http_request_firewall_managed` phase of a given zone (`{zone_id}`) by adding a rule that executes the managed ruleset.
3126

32-
```bash title="Request"
27+
```bash
3328
curl --request PUT \
3429
https://api.cloudflare.com/client/v4/zones/{zone_id}/rulesets/phases/http_request_firewall_managed/entrypoint \
3530
--header "Authorization: Bearer <API_TOKEN>" \
@@ -48,36 +43,36 @@ https://api.cloudflare.com/client/v4/zones/{zone_id}/rulesets/phases/http_reques
4843
}'
4944
```
5045

51-
```json title="Response"
46+
```json output
5247
{
53-
"result": {
54-
"id": "<ZONE_PHASE_RULESET_ID>",
55-
"name": "Zone-level Ruleset 1",
56-
"description": "",
57-
"kind": "zone",
58-
"version": "latest",
59-
"rules": [
60-
{
61-
"id": "<RULE_ID>",
62-
"version": "1",
63-
"action": "execute",
64-
"action_parameters": {
65-
"id": "<CLOUDFLARE_MANAGED_RULESET_ID>",
66-
"version": "3"
67-
},
68-
"expression": "true",
69-
"description": "Execute Cloudflare Managed Ruleset on my zone ruleset",
70-
"last_updated": "2021-03-18T18:08:14.003361Z",
71-
"ref": "<RULE_REF>",
72-
"enabled": true
73-
}
74-
],
75-
"last_updated": "2021-03-18T18:08:14.003361Z",
76-
"phase": "http_request_firewall_managed"
77-
},
78-
"success": true,
79-
"errors": [],
80-
"messages": []
48+
"result": {
49+
"id": "<ZONE_PHASE_RULESET_ID>",
50+
"name": "Zone-level Ruleset 1",
51+
"description": "",
52+
"kind": "zone",
53+
"version": "latest",
54+
"rules": [
55+
{
56+
"id": "<RULE_ID>",
57+
"version": "1",
58+
"action": "execute",
59+
"action_parameters": {
60+
"id": "<CLOUDFLARE_MANAGED_RULESET_ID>",
61+
"version": "3"
62+
},
63+
"expression": "true",
64+
"description": "Execute Cloudflare Managed Ruleset on my zone ruleset",
65+
"last_updated": "2021-03-18T18:08:14.003361Z",
66+
"ref": "<RULE_REF>",
67+
"enabled": true
68+
}
69+
],
70+
"last_updated": "2021-03-18T18:08:14.003361Z",
71+
"phase": "http_request_firewall_managed"
72+
},
73+
"success": true,
74+
"errors": [],
75+
"messages": []
8176
}
8277
```
8378

0 commit comments

Comments
 (0)