Skip to content

Commit 8df59e2

Browse files
[Various] APIRequest component (#24264)
* apirequest component * fix spacing
1 parent bfe9710 commit 8df59e2

File tree

4 files changed

+66
-59
lines changed

4 files changed

+66
-59
lines changed

src/content/docs/api-shield/security/schema-validation/api.mdx

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ head:
99
content: Configure Schema Validation
1010
---
1111

12-
import { GlossaryTooltip, Steps } from "~/components"
12+
import { GlossaryTooltip, Steps, APIRequest } from "~/components"
1313

1414
Schema Validation 2.0 allows all corresponding configuration calls to be made via API. This validation centers more around individual <GlossaryTooltip term="API endpoint">endpoints</GlossaryTooltip> and lets you set mitigation actions for each endpoint individually. Additionally, you can use Cloudflare-provided learned schemas that we [learn automatically](/api-shield/management-and-monitoring/#endpoint-schema-learning) from your traffic for individual endpoints.
1515

@@ -49,13 +49,18 @@ Endpoints must be listed in Endpoint Management for Schema Validation to match r
4949

5050
Upload a schema via the v4 API using `POST`. This example requires a `example_schema.yaml` schema file in the current folder.
5151

52-
```bash title="cURL command"
53-
curl --request POST "https://api.cloudflare.com/client/v4/zones/{zone_id}/api_gateway/user_schemas" \
54-
--header "Authorization: Bearer <API_TOKEN>" \
55-
--form file=@example_schema.yaml --form kind=openapi_v3 --form name=example_schema --form validation_enabled=false
56-
```
57-
58-
```json title="Result"
52+
<APIRequest
53+
path="/zones/{zone_id}/schema_validation/schemas"
54+
method="POST"
55+
json={{
56+
kind: "openapi_v3",
57+
name: "example_schema",
58+
source: "<SOURCE>",
59+
validation_enabled: true
60+
}}
61+
/>
62+
63+
```json output
5964
{
6065
"result":
6166
{
@@ -80,16 +85,15 @@ By default, Schema Validation is disabled for an uploaded schema so that you can
8085

8186
Use a `PATCH` request to activate a schema after inspection.
8287

83-
```bash title="cURL command"
84-
curl --request PATCH "https://api.cloudflare.com/client/v4/zones/{zone_id}/api_gateway/user_schemas/{schema_id}" \
85-
--header "Authorization: Bearer <API_TOKEN>" \
86-
--header 'Content-Type: application/json' \
87-
--data '{
88-
"validation_enabled": true
89-
}'
90-
```
88+
<APIRequest
89+
path="/zones/{zone_id}/api_gateway/user_schemas/{schema_id}"
90+
method="PATCH"
91+
json={{
92+
validation_enabled: true,
93+
}}
94+
/>
9195

92-
```json title="Result"
96+
```json output
9397
{
9498
"result":
9599
{
@@ -119,7 +123,7 @@ curl --request GET "https://api.cloudflare.com/client/v4/zones/{zone_id}/api_gat
119123
--header 'Content-Type: application/json'
120124
```
121125

122-
```json title="Result"
126+
```json output
123127
{
124128
"result":
125129
[
@@ -158,7 +162,7 @@ curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/api_gateway/operation
158162
]'
159163
```
160164

161-
```json title="Result"
165+
```json output
162166
{
163167
"result": [
164168
{
@@ -202,7 +206,7 @@ curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/api_gateway/settings/
202206
--header "Authorization: Bearer <API_TOKEN>"
203207
```
204208

205-
```json title="Result"
209+
```json output
206210
{
207211
"result": {
208212
"validation_default_mitigation_action": "none",
@@ -227,7 +231,7 @@ curl --request PUT "https://api.cloudflare.com/client/v4/zones/{zone_id}/api_gat
227231
}'
228232
```
229233

230-
```json title="Result"
234+
```json output
231235
{
232236
"result": {
233237
"validation_default_mitigation_action": "block",
@@ -249,7 +253,7 @@ curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/api_gateway/operation
249253
--header "Authorization: Bearer <API_TOKEN>"
250254
```
251255

252-
```json title="Result"
256+
```json output
253257
{
254258
"result": {
255259
"mitigation_action": "null"
@@ -276,7 +280,7 @@ curl --request PUT "https://api.cloudflare.com/client/v4/zones/{zone_id}/api_gat
276280
}'
277281
```
278282

279-
```json title="Result"
283+
```json output
280284
{
281285
"result": {
282286
"mitigation_action": "block"
@@ -295,12 +299,12 @@ You can get an overview of the schemas currently active on a zone using `GET`.
295299

296300
`validation_enabled=true` is an optional parameter.
297301

298-
```bash title="cURL command"
299-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/api_gateway/user_schemas?omit_source=true" \
300-
--header "Authorization: Bearer <API_TOKEN>"
301-
```
302+
<APIRequest
303+
path="/zones/{zone_id}/schema_validation/schemas"
304+
method="GET"
305+
/>
302306

303-
```json title="Result"
307+
```json output
304308
{
305309
"result": [
306310
{
@@ -329,12 +333,12 @@ We recommend using the query parameter `omit_source=true` to only display active
329333

330334
You can delete a schema using `DELETE`.
331335

332-
```bash title="cURL command"
333-
curl --request DELETE "https://api.cloudflare.com/client/v4/zones/{zone_id}/api_gateway/user_schemas/{schema_id}" \
334-
--header "Authorization: Bearer <API_TOKEN>"
335-
```
336+
<APIRequest
337+
path="/zones/{zone_id}/schema_validation/schemas/{schema_id}"
338+
method="DELETE"
339+
/>
336340

337-
```json title="Result"
341+
```json output
338342
{
339343
"result": null,
340344
"success": true,
@@ -354,7 +358,7 @@ curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/api_gateway/operation
354358
--header "Authorization: Bearer <API_TOKEN>"
355359
```
356360

357-
```json title="Result"
361+
```json output
358362
{
359363
"result":
360364
{
@@ -404,7 +408,7 @@ curl --request PUT "https://api.cloudflare.com/client/v4/zones/{zone_id}/api_gat
404408
--header "Authorization: Bearer <API_TOKEN>"
405409
```
406410

407-
```json title="Result"
411+
```json output
408412
{
409413
"result": null,
410414
"success": true,
@@ -434,7 +438,7 @@ curl --request PATCH "https://api.cloudflare.com/client/v4/zones/{zone_id}/api_g
434438
}'
435439
```
436440

437-
```json title="Result"
441+
```json output
438442
{
439443
"result": {
440444
"validation_default_mitigation_action": "block",

src/content/docs/api-shield/security/volumetric-abuse-detection.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sidebar:
77

88
---
99

10-
import { GlossaryTooltip, Steps, Render } from "~/components"
10+
import { GlossaryTooltip, Steps, Render, APIRequest } from "~/components"
1111

1212
Cloudflare Volumetric Abuse Detection helps you set up a system of adaptive rate limiting.
1313

@@ -60,6 +60,11 @@ Refer to the [Rules documentation](https://developers.cloudflare.com/waf/rate-li
6060

6161
[Rate limit recommendations are available via the API](/api/resources/api_gateway/subresources/operations/methods/get/) if you would like to dynamically update rate limits over time.
6262

63+
<APIRequest
64+
path="/zones/{zone_id}/api_gateway/operations/{operation_id}"
65+
method="GET"
66+
/>
67+
6368
## Special cases
6469

6570
<Render file="rate-limit-user" />

src/content/docs/bots/frequently-asked-questions.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sidebar:
66
order: 11
77
---
88

9-
import { Render, RuleID } from "~/components";
9+
import { Render, RuleID, APIRequest } from "~/components";
1010

1111
## Bots
1212

@@ -171,19 +171,19 @@ This is a known issue the Bots team is working to resolve in the near future. In
171171

172172
1. List the existing Rulesets at the zone level.
173173

174-
```bash
175-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/rulesets" \
176-
--header "Authorization: Bearer <API_TOKEN>"
177-
```
174+
<APIRequest
175+
path="/zones/{zone_id}/rulesets"
176+
method="GET"
177+
/>
178178

179179
2. From the output in step 1, find the ruleset ID that is associated with the zone's SBFM configuration. You should be able to see `"kind": "zone"` and `"phase": "http_request_sbfm"` for that ruleset.
180180

181181
3. Use the ruleset ID you found to delete the SBFM ruleset.
182182

183-
```bash
184-
curl --request DELETE "https://api.cloudflare.com/client/v4/zones/{zone_id}/rulesets/{ruleset_id}" \
185-
--header "Authorization: Bearer <API_TOKEN>"
186-
```
183+
<APIRequest
184+
path="/zones/{zone_id}/rulesets/{ruleset_id}"
185+
method="DELETE"
186+
/>
187187

188188
Note that you need to replace `<API_TOKEN>` with your own [API token](/fundamentals/api/get-started/create-token/).
189189

src/content/docs/ddos-protection/botnet-threat-feed.mdx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ learning_center:
1111
link: https://www.cloudflare.com/learning/ddos/what-is-a-ddos-botnet/
1212

1313
---
14-
import { Steps } from "~/components"
14+
import { Steps, APIRequest } from "~/components"
1515

1616
The Cloudflare DDoS Botnet Threat Feed is a threat intelligence feed for service providers (SPs) such as hosting providers and Internet service providers (ISPs) that provides information about their own IP addresses that have participated in HTTP DDoS attacks as observed from Cloudflare's global network. The feed aims to help service providers stop the abuse and reduce DDoS attacks originating from within their networks.
1717

@@ -96,13 +96,12 @@ Retrieves all the data in the botnet tracking database for a given ASN (currentl
9696

9797
The provided `{asn}` must be affiliated with your account.
9898

99-
```bash title="Example request"
100-
curl "https://api.cloudflare.com/client/v4/accounts/{account_id}/botnet_feed/asn/{asn}/full_report" \
101-
--header "Content-Type: application/json" \
102-
--header "Authorization: Bearer <API_TOKEN>"
103-
```
99+
<APIRequest
100+
path="/accounts/{account_id}/botnet_feed/asn/{asn_id}/full_report"
101+
method="GET"
102+
/>
104103

105-
```json title="Example response"
104+
```json output
106105
{
107106
"result": [
108107
{
@@ -129,13 +128,12 @@ The provided `{asn}` must be affiliated with your account.
129128

130129
`{date}` must be an ISO 8601-formatted date: `YYYY-MM-DD`. If no date is specified, the API responds with the data from the day before.
131130

132-
```bash title="Example request"
133-
curl "https://api.cloudflare.com/client/v4/accounts/{account_id}/botnet_feed/asn/{asn}/day_report?date=2024-05-05" \
134-
--header "Content-Type: application/json" \
135-
--header "Authorization: Bearer <API_TOKEN>"
136-
```
131+
<APIRequest
132+
path="/accounts/{account_id}/botnet_feed/asn/{asn_id}/day_report"
133+
method="GET"
134+
/>
137135

138-
```json title="Example response"
136+
```json output
139137
{
140138
"result": [
141139
{

0 commit comments

Comments
 (0)