Skip to content

Commit 647c03c

Browse files
committed
Use partials for repeated API steps
1 parent dcc8b70 commit 647c03c

File tree

10 files changed

+129
-20
lines changed

10 files changed

+129
-20
lines changed

src/content/docs/waf/account/custom-rulesets/create-api.mdx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ head:
99
content: Create a WAF custom ruleset using the API
1010
---
1111

12+
import { Render } from "~/components";
13+
1214
:::note
1315
This feature requires an Enterprise plan with a paid add-on.
1416
:::
@@ -53,7 +55,10 @@ Save the ruleset ID in the response for the next step.
5355

5456
To deploy the custom ruleset, add a rule with `"action": "execute"` to the `http_request_firewall_custom` phase entry point ruleset at the account level.
5557

56-
1. Invoke the [Get an account entry point ruleset](/api/operations/getAccountEntrypointRuleset) operation to obtain the definition of the entry point ruleset for the `http_request_firewall_custom` phase. You will need the [account ID](/fundamentals/setup/find-account-and-zone-ids/) for this task.
58+
1. <Render
59+
file="rulesets/api-account/step1-get-entrypoint"
60+
params={{ phaseName: "http_request_firewall_custom" }}
61+
/>
5762

5863
```bash
5964
curl "https://api.cloudflare.com/client/v4/accounts/{account_id}/rulesets/phases/http_request_firewall_custom/entrypoint" \
@@ -80,7 +85,12 @@ To deploy the custom ruleset, add a rule with `"action": "execute"` to the `http
8085
}
8186
```
8287

83-
2. If the entry point ruleset already exists (that is, if you received a `200 OK` status code and the ruleset definition), take note of the ruleset ID in the response. Then, invoke the [Create an account ruleset rule](/api/operations/createAccountRulesetRule) operation to add an `execute` rule to the existing ruleset deploying the custom ruleset. By default, the rule will be added at the end of the list of rules already in the ruleset.
88+
2. <Render
89+
file="rulesets/api-account/step2-create-rule"
90+
params={{
91+
deploymentItem: "custom ruleset",
92+
}}
93+
/>
8494

8595
The following request creates a rule that executes the custom ruleset with ID `<CUSTOM_RULESET_ID>` for all Enterprise zones in the account:
8696

@@ -103,7 +113,13 @@ To deploy the custom ruleset, add a rule with `"action": "execute"` to the `http
103113
You can only apply custom rulesets to incoming traffic of zones on an Enterprise plan. To enforce this requirement, you must include `cf.zone.plan eq "ENT"` in the expression of the `execute` rule deploying the custom ruleset.
104114
:::
105115

106-
3. If the entry point ruleset does not exist (that is, if you received a `404 Not Found` status code in step 1), create it using the [Create an account ruleset](/api/operations/createAccountRuleset) operation. Include a single rule in the `rules` array that executes the custom ruleset.
116+
3. <Render
117+
file="rulesets/api-account/step3-create-ruleset"
118+
params={{
119+
deploymentItem: "custom ruleset",
120+
scope: "all incoming requests of Enterprise zones in your account",
121+
}}
122+
/>
107123

108124
```bash
109125
curl "https://api.cloudflare.com/client/v4/accounts/{account_id}/rulesets" \

src/content/docs/waf/account/rate-limiting-rulesets/create-api.mdx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ Save the ruleset ID in the response for the next step.
7272

7373
To deploy the rate limiting ruleset, add a rule with `"action": "execute"` to the `http_ratelimit` phase entry point ruleset at the account level.
7474

75-
1. Invoke the [Get an account entry point ruleset](/api/operations/getAccountEntrypointRuleset) operation to obtain the definition of the entry point ruleset for the `http_ratelimit` phase. You will need the [account ID](/fundamentals/setup/find-account-and-zone-ids/) for this task.
75+
1. <Render
76+
file="rulesets/api-account/step1-get-entrypoint"
77+
params={{ phaseName: "http_ratelimit" }}
78+
/>
7679

7780
```bash
7881
curl "https://api.cloudflare.com/client/v4/accounts/{account_id}/rulesets/phases/http_ratelimit/entrypoint" \
@@ -100,7 +103,12 @@ To deploy the rate limiting ruleset, add a rule with `"action": "execute"` to th
100103
}
101104
```
102105

103-
2. If the entry point ruleset already exists (that is, if you received a `200 OK` status code and the ruleset definition), take note of the ruleset ID in the response. Then, invoke the [Create an account ruleset rule](/api/operations/createAccountRulesetRule) operation to add an `execute` rule to the existing ruleset deploying the rate limiting ruleset. By default, the rule will be added at the end of the list of rules already in the ruleset.
106+
2. <Render
107+
file="rulesets/api-account/step2-create-rule"
108+
params={{
109+
deploymentItem: "rate limiting ruleset",
110+
}}
111+
/>
104112

105113
The following request creates a rule that executes the rate limiting ruleset with ID `<RATE_LIMITING_RULESET_ID>` for all Enterprise zones in the account:
106114

@@ -121,7 +129,13 @@ To deploy the rate limiting ruleset, add a rule with `"action": "execute"` to th
121129

122130
<Render file="account-enterprise-zones-only-api" />
123131

124-
3. If the entry point ruleset does not exist (that is, if you received a `404 Not Found` status code in step 1), create it using the [Create an account ruleset](/api/operations/createAccountRuleset) operation. Include a single rule in the `rules` array that executes the rate limiting ruleset.
132+
3. <Render
133+
file="rulesets/api-account/step3-create-ruleset"
134+
params={{
135+
deploymentItem: "rate limiting ruleset",
136+
scope: "all incoming requests of Enterprise zones in your account",
137+
}}
138+
/>
125139

126140
```bash
127141
curl "https://api.cloudflare.com/client/v4/accounts/{account_id}/rulesets" \

src/content/partials/waf/managed-rulesets/api-account-example.mdx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
{}
33
---
44

5-
import { RuleID } from "~/components";
5+
import { Render, RuleID } from "~/components";
66

77
The following example deploys a [WAF managed ruleset](/waf/managed-rules/#managed-rulesets) to the `http_request_firewall_managed` phase of a given account (`{account_id}`) by creating a rule that executes the managed ruleset. The rules in the managed ruleset are executed when the zone name matches one of `example.com` or `anotherexample.com`.
88

9-
1. Invoke the [Get an account entry point ruleset](/api/operations/getAccountEntrypointRuleset) operation to obtain the definition of the entry point ruleset for the `http_request_firewall_managed` phase. You will need the [account ID](/fundamentals/setup/find-account-and-zone-ids/) for this task.
9+
1. <Render
10+
file="rulesets/api-account/step1-get-entrypoint"
11+
params={{ phaseName: "http_request_firewall_managed" }}
12+
/>
1013

1114
```bash
1215
curl "https://api.cloudflare.com/client/v4/accounts/{account_id}/rulesets/phases/http_request_firewall_managed/entrypoint" \
@@ -34,7 +37,13 @@ The following example deploys a [WAF managed ruleset](/waf/managed-rules/#manage
3437
}
3538
```
3639

37-
2. If the entry point ruleset already exists (that is, if you received a `200 OK` status code and the ruleset definition), take note of the ruleset ID in the response. Then, invoke the [Create an account ruleset rule](/api/operations/createAccountRulesetRule) operation to add an `execute` rule to the existing ruleset deploying the [Cloudflare Managed Ruleset](/waf/managed-rules/reference/cloudflare-managed-ruleset/) (with ID <RuleID id="efb7b8c949ac4650a09736fc376e9aee" />). By default, the rule will be added at the end of the list of rules already in the ruleset.
40+
2. <Render
41+
file="rulesets/api-account/step2-create-rule"
42+
params={{
43+
deploymentItem:
44+
"[Cloudflare Managed Ruleset](/waf/managed-rules/reference/cloudflare-managed-ruleset/) (with ID `efb7b8c949ac4650a09736fc376e9aee`)",
45+
}}
46+
/>
3847

3948
```bash
4049
curl "https://api.cloudflare.com/client/v4/accounts/{account_id}/rulesets/{ruleset_id}/rules" \
@@ -88,7 +97,15 @@ The following example deploys a [WAF managed ruleset](/waf/managed-rules/#manage
8897
Managed rulesets deployed at the account level will only apply to incoming traffic of zones on an Enterprise plan. The expression of your `execute` rule must end with `and cf.zone.plan eq "ENT"` or else the API operation will fail.
8998
:::
9099

91-
3. If the entry point ruleset does not exist (that is, if you received a `404 Not Found` status code in step 1), create the ruleset using the [Create an account ruleset](/api/operations/createAccountRuleset) operation. Include a single rule in the `rules` array that executes the Cloudflare Managed Ruleset (with ID <RuleID id="efb7b8c949ac4650a09736fc376e9aee" />) for all incoming requests where the zone name matches one of `example.com` or `anotherexample.com`.
100+
3. <Render
101+
file="rulesets/api-account/step3-create-ruleset"
102+
params={{
103+
deploymentItem:
104+
"Cloudflare Managed Ruleset (with ID `efb7b8c949ac4650a09736fc376e9aee`)",
105+
scope:
106+
"all incoming requests where the zone name matches one of `example.com` or `anotherexample.com`",
107+
}}
108+
/>
92109

93110
```bash
94111
curl "https://api.cloudflare.com/client/v4/accounts/{account_id}/rulesets" \

src/content/partials/waf/managed-rulesets/api-zone-example.mdx

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
{}
33
---
44

5-
import { RuleID } from "~/components";
5+
import { Render, RuleID } from "~/components";
66

77
The following example deploys a [WAF managed ruleset](/waf/managed-rules/#managed-rulesets) to the `http_request_firewall_managed` phase of a given zone (`{zone_id}`) by creating a rule that executes the managed ruleset.
88

9-
1. Invoke the [Get a zone entry point ruleset](/api/operations/getZoneEntrypointRuleset) operation to obtain the definition of the entry point ruleset for the `http_request_firewall_managed` phase. You will need the [zone ID](/fundamentals/setup/find-account-and-zone-ids/) for this task.
9+
1. <Render
10+
file="rulesets/api-zone/step1-get-entrypoint"
11+
params={{ phaseName: "http_request_firewall_managed" }}
12+
/>
1013

1114
```bash
1215
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/rulesets/phases/http_request_firewall_managed/entrypoint" \
@@ -34,19 +37,25 @@ The following example deploys a [WAF managed ruleset](/waf/managed-rules/#manage
3437
}
3538
```
3639

37-
2. If the entry point ruleset already exists (that is, if you received a `200 OK` status code and the ruleset definition), take note of the ruleset ID in the response. Then, invoke the [Create a zone ruleset rule](/api/operations/createZoneRulesetRule) operation to add an `execute` rule to the existing ruleset deploying the [Cloudflare Managed Ruleset](/waf/managed-rules/reference/cloudflare-managed-ruleset/) (with ID <RuleID id="efb7b8c949ac4650a09736fc376e9aee" />). By default, the rule will be added at the end of the list of rules already in the ruleset.
40+
2. <Render
41+
file="rulesets/api-zone/step2-create-rule"
42+
params={{
43+
deploymentItem:
44+
"Cloudflare Managed Ruleset (with ID `efb7b8c949ac4650a09736fc376e9aee`)",
45+
}}
46+
/>
3847

3948
```bash
4049
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/rulesets/{ruleset_id}/rules" \
4150
--header "Authorization: Bearer <API_TOKEN>" \
4251
--header "Content-Type: application/json" \
4352
--data '{
44-
"action": "execute",
45-
"action_parameters": {
46-
"id": "efb7b8c949ac4650a09736fc376e9aee"
47-
},
48-
"expression": "true",
49-
"description": "Execute the Cloudflare Managed Ruleset"
53+
"action": "execute",
54+
"action_parameters": {
55+
"id": "efb7b8c949ac4650a09736fc376e9aee"
56+
},
57+
"expression": "true",
58+
"description": "Execute the Cloudflare Managed Ruleset"
5059
}'
5160
```
5261

@@ -84,7 +93,14 @@ The following example deploys a [WAF managed ruleset](/waf/managed-rules/#manage
8493
}
8594
```
8695

87-
3. If the entry point ruleset does not exist (that is, if you received a `404 Not Found` status code in step 1), create it using the [Create a zone ruleset](/api/operations/createZoneRuleset) operation. Include a single rule in the `rules` array that executes the [Cloudflare Managed Ruleset](/waf/managed-rules/reference/cloudflare-managed-ruleset/) (with ID <RuleID id="efb7b8c949ac4650a09736fc376e9aee" />) for all incoming requests in the zone.
96+
3. <Render
97+
file="rulesets/api-zone/step3-create-ruleset"
98+
params={{
99+
deploymentItem:
100+
"Cloudflare Managed Ruleset (with ID `efb7b8c949ac4650a09736fc376e9aee`)",
101+
scope: "all incoming requests in the zone",
102+
}}
103+
/>
88104

89105
```bash
90106
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/rulesets" \
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
params:
3+
- phaseName
4+
---
5+
6+
Invoke the [Get an account entry point ruleset](/api/operations/getAccountEntrypointRuleset) operation to obtain the definition of the entry point ruleset for the <code>{props.phaseName}</code> phase. You will need the [account ID](/fundamentals/setup/find-account-and-zone-ids/) for this task.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
params:
3+
- deploymentItem
4+
---
5+
6+
import { Markdown } from "~/components";
7+
8+
If the entry point ruleset already exists (that is, if you received a `200 OK` status code and the ruleset definition), take note of the ruleset ID in the response. Then, invoke the [Create an account ruleset rule](/api/operations/createAccountRulesetRule) operation to add an `execute` rule to the existing ruleset deploying the <Markdown text={props.deploymentItem} />. By default, the rule will be added at the end of the list of rules already in the ruleset.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
params:
3+
- deploymentItem
4+
- scope
5+
---
6+
7+
import { Markdown } from "~/components";
8+
9+
If the entry point ruleset does not exist (that is, if you received a `404 Not Found` status code in step 1), create it using the [Create an account ruleset](/api/operations/createAccountRuleset) operation. Include a single rule in the `rules` array that executes the <Markdown text={props.deploymentItem} /> for <Markdown text={props.scope} />.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
params:
3+
- phaseName
4+
---
5+
6+
Invoke the [Get a zone entry point ruleset](/api/operations/getZoneEntrypointRuleset) operation to obtain the definition of the entry point ruleset for the <code>{props.phaseName}</code> phase. You will need the [zone ID](/fundamentals/setup/find-account-and-zone-ids/) for this task.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
params:
3+
- deploymentItem
4+
---
5+
6+
import { Markdown } from "~/components";
7+
8+
If the entry point ruleset already exists (that is, if you received a `200 OK` status code and the ruleset definition), take note of the ruleset ID in the response. Then, invoke the [Create a zone ruleset rule](/api/operations/createZoneRulesetRule) operation to add an `execute` rule to the existing ruleset deploying the <Markdown text={props.deploymentItem} />. By default, the rule will be added at the end of the list of rules already in the ruleset.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
params:
3+
- deploymentItem
4+
- scope
5+
---
6+
7+
import { Markdown } from "~/components";
8+
9+
If the entry point ruleset does not exist (that is, if you received a `404 Not Found` status code in step 1), create it using the [Create a zone ruleset](/api/operations/createZoneRuleset) operation. Include a single rule in the `rules` array that executes the <Markdown text={props.deploymentItem} /> for <Markdown text={props.scope} />.

0 commit comments

Comments
 (0)