Skip to content

Commit b990ead

Browse files
angelampcostasdnts
authored andcommitted
Adds APIRequest component to LB docs (cloudflare#23554)
1 parent ac1c583 commit b990ead

File tree

5 files changed

+133
-139
lines changed

5 files changed

+133
-139
lines changed

src/content/docs/load-balancing/private-network/tunnels-setup.mdx

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 2
66
---
77

8-
import { Render, TabItem, Tabs } from "~/components";
8+
import { Render, TabItem, Tabs, APIRequest } from "~/components";
99

1010
Consider the following steps to learn how to configure Private Network Load Balancing solution, using [Cloudflare Tunnel](/cloudflare-one/connections/connect-networks/) as the off-ramp to securely connect to your private or internal services.
1111

@@ -86,23 +86,21 @@ All origins with private IPs must have `virtual_network_id` specified.
8686

8787
:::
8888

89-
```bash
90-
curl --request PATCH \
91-
https://api.cloudflare.com/client/v4/accounts/{account_id}/load_balancers/pools/{pool_id} \
92-
--header "Authorization: Bearer <API_TOKEN>" \
93-
--header "Content-Type: application/json" \
94-
--data '{
95-
"origins": [
96-
{
97-
"name": "origin-1",
98-
"address": "10.0.0.1",
99-
"enabled": true,
100-
"weight": 1,
101-
"virtual_network_id": "a5624d4e-044a-4ff0-b3e1-e2465353d4b4"
102-
}
103-
]
104-
}'
105-
```
89+
<APIRequest
90+
path="/accounts/{account_id}/load_balancers/pools/{pool_id}"
91+
method="PATCH"
92+
json={{
93+
origins: [
94+
{
95+
name: "origin-1",
96+
address: "10.0.0.1",
97+
enabled: true,
98+
weight: 1,
99+
virtual_network_id: "a5624d4e-044a-4ff0-b3e1-e2465353d4b4"
100+
}
101+
]
102+
}}
103+
/>
106104

107105
</TabItem>
108106
</Tabs>

src/content/docs/load-balancing/reference/migration-guides/health-monitor-notifications.mdx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sidebar:
66

77
---
88

9-
import { Details } from "~/components"
9+
import { Details, APIRequest } from "~/components"
1010

1111
Cloudflare is migrating the notifications used by load balancing [health monitors](/load-balancing/monitors/) to use Cloudflare's centralized [Notifications Service](/notifications/).
1212

@@ -113,15 +113,13 @@ Though you can perform these steps in the dashboard, Cloudflare recommends you u
113113

114114
If using the Cloudflare API, we recently added a [`PATCH`](/api/resources/load_balancers/subresources/pools/methods/bulk_edit/) endpoint so you can easily remove email notifications from multiple pools at the same time.
115115

116-
```bash title="Request"
117-
curl --request PATCH \
118-
"https://api.cloudflare.com/client/v4/accounts/{account_id}/load_balancers/pools" \
119-
--header "Authorization: Bearer <API_TOKEN>" \
120-
--header "Content-Type: application/json" \
121-
--data '{
122-
"notification_email": ""
123-
}'
124-
```
116+
<APIRequest
117+
path="/accounts/{account_id}/load_balancers/pools"
118+
method="PATCH"
119+
json={{
120+
notification_email: ""
121+
}}
122+
/>
125123

126124
This API call supports the standard pagination query parameters, either `limit/offset` or `per_page/page`, so by default it only updates the first 25 pools listed. To make sure you update all your pools, you may want to adjust your API call so it loops through various pages or includes a larger number of pools with each request.
127125

src/content/partials/load-balancing/load-balancer-create-api.mdx

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
---
55

6+
import { APIRequest } from "~/components";
7+
68
For a full list of properties, refer to [Create Load Balancer](/api/resources/load_balancers/methods/create/). If you need help with API authentication, refer to [Cloudflare API documentation](/fundamentals/api/).
79

810
:::note
@@ -13,47 +15,46 @@ Since load balancers only exist on a zone — and not an account — you may nee
1315

1416
:::
1517

16-
```bash title="Request"
17-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/load_balancers" \
18-
--header "Authorization: Bearer <API_TOKEN>" \
19-
--header "Content-Type: application/json" \
20-
--data '{
21-
"description": "Load Balancer for lb.example.com",
22-
"name": "lb.example.com",
23-
"enabled": true,
24-
"ttl": 30,
25-
"fallback_pool": "17b5962d775c646f3f9725cbc7a53df4",
26-
"default_pools": [
27-
"17b5962d775c646f3f9725cbc7a53df4",
28-
"9290f38c5d07c2e2f4df57b1f61d4196",
29-
"00920f38ce07c2e2f4df50b1f61d4194"
30-
],
31-
"proxied": true,
32-
"steering_policy": "random_steering",
33-
"session_affinity": "cookie",
34-
"session_affinity_attributes": {
35-
"samesite": "Auto",
36-
"secure": "Auto",
37-
"drain_duration": 100,
38-
"zero_downtime_failover": "sticky"
39-
},
40-
"session_affinity_ttl": 5000,
41-
"adaptive_routing": {
42-
"failover_across_pools": true
43-
},
44-
"location_strategy": {
45-
"prefer_ecs": "always",
46-
"mode": "resolver_ip"
47-
},
48-
"random_steering": {
49-
"pool_weights": {
50-
"de90f38ced07c2e2f4df50b1f61d4194": 0.3,
51-
"9290f38c5d07c2e2f4df57b1f61d4196": 0.5
18+
<APIRequest
19+
path="/zones/{zone_id}/load_balancers"
20+
method="POST"
21+
json={{
22+
description: "Load Balancer for lb.example.com",
23+
name: "lb.example.com",
24+
enabled: true,
25+
ttl: 30,
26+
fallback_pool: "17b5962d775c646f3f9725cbc7a53df4",
27+
default_pools: [
28+
"17b5962d775c646f3f9725cbc7a53df4",
29+
"9290f38c5d07c2e2f4df57b1f61d4196",
30+
"00920f38ce07c2e2f4df50b1f61d4194"
31+
],
32+
proxied: true,
33+
steering_policy: "random_steering",
34+
session_affinity: "cookie",
35+
session_affinity_attributes: {
36+
samesite: "Auto",
37+
secure: "Auto",
38+
drain_duration: 100,
39+
zero_downtime_failover: "sticky"
5240
},
53-
"default_weight": 0.2
54-
}
55-
}'
56-
```
41+
session_affinity_ttl: 5000,
42+
adaptive_routing: {
43+
failover_across_pools: true
44+
},
45+
location_strategy: {
46+
prefer_ecs: "always",
47+
mode: "resolver_ip"
48+
},
49+
random_steering: {
50+
pool_weights: {
51+
"de90f38ced07c2e2f4df50b1f61d4194": 0.3,
52+
"9290f38c5d07c2e2f4df57b1f61d4196": 0.5
53+
},
54+
default_weight: 0.2
55+
}
56+
}}
57+
/>
5758

5859
The response contains the complete definition of the new load balancer.
5960

src/content/partials/load-balancing/monitor-create-api.mdx

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,35 @@
33

44
---
55

6+
import { APIRequest } from "~/components";
7+
68
For a full list of monitor properties, refer to [Create Monitor](/api/resources/load_balancers/subresources/monitors/methods/create/). If you need help with API authentication, refer to [Cloudflare API documentation](/fundamentals/api/).
79

8-
```bash title="Request"
9-
curl "https://api.cloudflare.com/client/v4/accounts/{account_id}/load_balancers/monitors" \
10-
--header "Authorization: Bearer <API_TOKEN>" \
11-
--header "Content-Type: application/json" \
12-
--data '{
13-
"type": "https",
14-
"description": "Login page monitor",
15-
"method": "GET",
16-
"path": "/health",
17-
"header": {
18-
"Host": ["example.com"],
19-
"X-App-ID": ["abc123"]
20-
},
21-
"port": 8080,
22-
"timeout": 3,
23-
"retries": 0,
24-
"interval": 90,
25-
"expected_body": "alive",
26-
"expected_codes": "2xx",
27-
"follow_redirects": true,
28-
"allow_insecure": true,
29-
"consecutive_up": 3,
30-
"consecutive_down": 2,
31-
"probe_zone": "example.com"
32-
}'
33-
```
10+
<APIRequest
11+
path="/accounts/{account_id}/load_balancers/monitors"
12+
method="POST"
13+
json={{
14+
type: "https",
15+
description: "Login page monitor",
16+
method: "GET",
17+
path: "/health",
18+
header: {
19+
Host: ["example.com"],
20+
"X-App-ID": ["abc123"]
21+
},
22+
port: 8080,
23+
timeout: 3,
24+
retries: 0,
25+
interval: 90,
26+
expected_body: "alive",
27+
expected_codes: "2xx",
28+
follow_redirects: true,
29+
allow_insecure: true,
30+
consecutive_up: 3,
31+
consecutive_down: 2,
32+
probe_zone: "example.com"
33+
}}
34+
/>
3435

3536
The response contains the complete definition of the new monitor.
3637

src/content/partials/load-balancing/pool-create-api.mdx

Lines changed: 41 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,52 @@
33

44
---
55

6+
import { APIRequest } from "~/components";
7+
68
For a full list of properties, refer to [Create Pool](/api/resources/load_balancers/subresources/pools/methods/create/). If you need help with API authentication, refer to [Cloudflare API documentation](/fundamentals/api/).
79

8-
```bash title="Request"
9-
curl "https://api.cloudflare.com/client/v4/accounts/{account_id}/load_balancers/pools" \
10-
--header "Authorization: Bearer <API_TOKEN>" \
11-
--header "Content-Type: application/json" \
12-
--data '{
13-
"description": "Primary data center - Provider XYZ",
14-
"name": "primary-dc-1",
15-
"enabled": false,
16-
"load_shedding": {
17-
"default_percent": 0,
18-
"default_policy": "random",
19-
"session_percent": 0,
20-
"session_policy": "hash"
21-
},
22-
"minimum_origins": 2,
23-
"monitor": "f1aba936b94213e5b8dca0c0dbf1f9cc",
24-
"check_regions": [
25-
"WEU",
26-
"ENAM"
27-
],
28-
"origins": [
29-
{
30-
"name": "app-server-1",
31-
"address": "0.0.0.0",
32-
"enabled": true,
33-
"weight": 0.56,
34-
"header": {
35-
"Host": [
36-
"example.com"
37-
]
10+
<APIRequest
11+
path="/accounts/{account_id}/load_balancers/pools"
12+
method="POST"
13+
json={{
14+
description: "Primary data center - Provider XYZ",
15+
name: "primary-dc-1",
16+
enabled: false,
17+
load_shedding: {
18+
default_percent: 0,
19+
default_policy: "random",
20+
session_percent: 0,
21+
session_policy: "hash"
22+
},
23+
minimum_origins: 2,
24+
monitor: "f1aba936b94213e5b8dca0c0dbf1f9cc",
25+
check_regions: ["WEU", "ENAM"],
26+
origins: [
27+
{
28+
name: "app-server-1",
29+
address: "0.0.0.0",
30+
enabled: true,
31+
weight: 0.56,
32+
header: {
33+
Host: ["example.com"]
34+
}
3835
}
39-
}
40-
],
41-
"origin_steering": {
42-
"policy": "random"
43-
},
44-
"notification_filter": {
45-
"origin": {
46-
"disable": false,
47-
"healthy": null
36+
],
37+
origin_steering: {
38+
policy: "random"
4839
},
49-
"pool": {
50-
"disable": false,
51-
"healthy": null
40+
notification_filter: {
41+
origin: {
42+
disable: false,
43+
healthy: null
44+
},
45+
pool: {
46+
disable: false,
47+
healthy: null
48+
}
5249
}
53-
}
54-
}'
55-
```
50+
}}
51+
/>
5652

5753
The response contains the complete definition of the new pool.
5854

0 commit comments

Comments
 (0)