Skip to content

Commit 29bafe6

Browse files
marciocloudflareelithrar
authored andcommitted
[Magic] APIRequest updates (#20758)
* added apirequest * deleted old example * added apirequest * removed old example * added api request * deleted old example * added apirequest * deleted old example * added apirequest * added apirequest * deleted old example * added example response * change to single route * updated example
1 parent 549d6a8 commit 29bafe6

File tree

4 files changed

+169
-79
lines changed

4 files changed

+169
-79
lines changed

src/content/docs/magic-wan/configuration/connector/network-options/dhcp/dhcp-relay.mdx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pcx_content_type: how-to
33
title: DHCP relay
44
---
55

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

88
DHCP Relay provides a way for DHCP clients to communicate with DHCP servers that are not available on the same local subnet/broadcast domain. When you enable DHCP Relay, Magic WAN Connector forwards DHCP discover messages to a predefined DHCP server, and routes the responses back to the original device that sent the discover message.
99

@@ -48,14 +48,11 @@ Create a [`PUT` request](/api/resources/magic_transit/subresources/sites/subreso
4848

4949
Example:
5050

51-
```bash
52-
curl --request PUT \
53-
https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id} \
54-
--header "X-Auth-Email: <EMAIL>" \
55-
--header "X-Auth-Key: <API_KEY>" \
56-
--header "Content-Type: application/json" \
57-
--data '{
58-
"lan": {
51+
<APIRequest
52+
path="/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}"
53+
method="PUT"
54+
json={{
55+
"lan": {
5956
"static_addressing": {
6057
"dhcp_relay": {
6158
"server_addresses": [
@@ -64,7 +61,7 @@ https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/sites/{site_id}
6461
}
6562
}
6663
}
67-
}'
68-
```
64+
}}
65+
/>
6966

7067
</TabItem> </Tabs>

src/content/docs/magic-wan/configuration/connector/network-options/dhcp/dhcp-server.mdx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pcx_content_type: how-to
33
title: DHCP server
44
---
55

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

88
When you use a static IP address, Magic WAN Connector can also act as a DHCP server in your network. To enable this feature:
99

@@ -37,14 +37,11 @@ Create a [`PUT` request](/api/resources/magic_transit/subresources/sites/subreso
3737

3838
Example:
3939

40-
```bash
41-
curl --request PUT \
42-
https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id} \
43-
--header "X-Auth-Email: <EMAIL>" \
44-
--header "X-Auth-Key: <API_KEY>" \
45-
--header "Content-Type: application/json" \
46-
--data '{
47-
"lan": {
40+
<APIRequest
41+
path="/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}"
42+
method="PUT"
43+
json={{
44+
"lan": {
4845
"static_addressing": {
4946
"dhcp_server": {
5047
"dhcp_pool_end": "<IP_ADDRESS>",
@@ -53,7 +50,7 @@ https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/sites/{site_id}
5350
}
5451
}
5552
}
56-
}'
57-
```
53+
}}
54+
/>
5855

5956
</TabItem> </Tabs>

src/content/docs/magic-wan/configuration/connector/network-options/dhcp/dhcp-static-address-reservation.mdx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pcx_content_type: how-to
33
title: DHCP static address reservation
44
---
55

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

88
If you configure your Connector to be a DHCP server, you can also assign IP addresses to specific devices on your network. To reserve IP addresses:
99

@@ -23,14 +23,11 @@ Create a [`PUT` request](/api/resources/magic_transit/subresources/sites/subreso
2323

2424
Example:
2525

26-
```bash
27-
curl --request PUT \
28-
https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id} \
29-
--header "X-Auth-Email: <EMAIL>" \
30-
--header "X-Auth-Key: <API_KEY>" \
31-
--header "Content-Type: application/json" \
32-
--data '{
33-
"lan": {
26+
<APIRequest
27+
path="/accounts/{account_id}/magic/sites/{site_id}/lans/{lan_id}"
28+
method="PUT"
29+
json={{
30+
"lan": {
3431
"static_addressing": {
3532
"dhcp_server": {
3633
"reservations": {
@@ -40,7 +37,7 @@ https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/sites/{site_id}
4037
}
4138
}
4239
}
43-
}'
44-
```
40+
}}
41+
/>
4542

4643
</TabItem> </Tabs>

src/content/partials/magic-transit/static-routes.mdx

Lines changed: 145 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ params:
1010
- tunnelEndpoints
1111
---
1212

13-
import { Aside, GlossaryTooltip, Markdown, AnchorHeading, Render, TabItem, Tabs } from "~/components";
13+
import { APIRequest, Aside, GlossaryTooltip, Markdown, AnchorHeading, Render, TabItem, Tabs } from "~/components";
1414

1515
:::note
1616
If you are connecting to Cloudflare via a [Direct CNI connection](/network-interconnect/express-cni/), refer to <a href={props.BGPpath}>BGP peering</a> to learn how to take advantage of this [routing](https://www.cloudflare.com/learning/network-layer/what-is-routing/) protocol. If not, continue reading.
@@ -190,30 +190,63 @@ Create a `POST` request [using the API](/api/resources/magic_transit/subresource
190190

191191
Example:
192192

193-
```bash
194-
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/routes \
195-
--header "X-Auth-Email: <EMAIL>" \
196-
--header "X-Auth-Key: <API_KEY>" \
197-
--header "Content-Type: application/json" \
198-
--data '{
199-
"routes": [
193+
<APIRequest
194+
path="/accounts/{account_id}/magic/routes"
195+
method="POST"
196+
json={{
197+
"nexthop": "<IP_NEXT_HOP>",
198+
"prefix": "<YOUR_IP_PREFIX>",
199+
"priority": 0,
200+
"id": "023e105f4ecef8ad9ca31a8372d0c353",
201+
"description": "<ROUTE_DESCRIPTION>",
202+
"scope": {
203+
"colo_names": [
204+
"den01"
205+
],
206+
"colo_regions": [
207+
"APAC"
208+
]
209+
},
210+
"weight": 0
211+
}}
212+
/>
213+
214+
```json output
215+
{
216+
"errors": [
200217
{
201-
"description": "New route for new prefix",
202-
"prefix": "<YOUR_IP_PREFIX>",
203-
"nexthop": "<IP_NEXT_HOP>",
204-
"priority": <PRIORITY>,
205-
"scope": {
206-
"colo_names": [
207-
"<NAME_OF_CLOUDFLARE_SERVER>"
208-
],
209-
"colo_regions": [
210-
"<NAME_OF_REGION>"
211-
]
212-
},
213-
"weight": <WEIGHT>
218+
"code": 1000,
219+
"message": "message"
214220
}
215-
]
216-
}'
221+
],
222+
"messages": [
223+
{
224+
"code": 1000,
225+
"message": "message"
226+
}
227+
],
228+
"result": {
229+
"routes": [
230+
{
231+
"nexthop": "203.0.113.1",
232+
"prefix": "192.0.2.0/24",
233+
"priority": 0,
234+
"id": "023e105f4ecef8ad9ca31a8372d0c353",
235+
"description": "New route for new prefix 203.0.113.1",
236+
"scope": {
237+
"colo_names": [
238+
"den01"
239+
],
240+
"colo_regions": [
241+
"APAC"
242+
]
243+
},
244+
"weight": 0
245+
}
246+
]
247+
},
248+
"success": true
249+
}
217250
```
218251

219252
</TabItem> </Tabs>
@@ -231,35 +264,66 @@ curl https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/routes \
231264

232265
<Render file="connector/account-id-api-key" product="magic-wan" />
233266

234-
Create a `PUT` request [using the API](/api/resources/magic_transit/subresources/routes/methods/bulk_update/) to update one or more static routes.
267+
Create a `PUT` request [using the API](/api/resources/magic_transit/subresources/routes/methods/update/) to update one or more static routes.
235268

236269
Example:
237270

238-
```bash
239-
curl --request PUT \
240-
https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/routes \
241-
--header "X-Auth-Email: <EMAIL>" \
242-
--header "X-Auth-Key: <API_KEY>" \
243-
--header "Content-Type: application/json" \
244-
--data '{
245-
"routes": [
271+
<APIRequest
272+
path="/accounts/{account_id}/magic/routes/{route_id}"
273+
method="PUT"
274+
json={{
275+
"nexthop": "<IP_NEXT_HOP>",
276+
"prefix": "<YOUR_IP_PREFIX>",
277+
"priority": 0,
278+
"id": "023e105f4ecef8ad9ca31a8372d0c353",
279+
"description": "<ROUTE_DESCRIPTION>",
280+
"scope": {
281+
"colo_names": [
282+
"den01"
283+
],
284+
"colo_regions": [
285+
"APAC"
286+
]
287+
},
288+
"weight": 0
289+
}}
290+
/>
291+
292+
```json output
293+
{
294+
"errors": [
295+
{
296+
"code": 1000,
297+
"message": "message"
298+
}
299+
],
300+
"messages": [
246301
{
247-
"description": "New route for new prefix",
248-
"nexthop": "<IP_NEXT_HOP>",
249-
"prefix": "<YOUR_IP_PREFIX>",
250-
"priority": <PRIORITY>,
302+
"code": 1000,
303+
"message": "message"
304+
}
305+
],
306+
"result": {
307+
"modified": true,
308+
"modified_route": {
309+
"nexthop": "203.0.113.1",
310+
"prefix": "192.0.2.0/24",
311+
"priority": 0,
312+
"id": "023e105f4ecef8ad9ca31a8372d0c353",
313+
"description": "New route for new prefix 203.0.113.1",
251314
"scope": {
252315
"colo_names": [
253-
"<NAME_OF_CLOUDFLARE_SERVER>"
316+
"den01"
254317
],
255318
"colo_regions": [
256-
"<NAME_OF_REGION>"
319+
"APAC"
257320
]
258321
},
259-
"weight": <WEIGHT>
322+
"weight": 0
260323
}
261-
]
262-
}'
324+
},
325+
"success": true
326+
}
263327
```
264328

265329
</TabItem> </Tabs>
@@ -279,11 +343,46 @@ Create a `DELETE` request [using the API](/api/resources/magic_transit/subresour
279343

280344
Example:
281345

282-
```bash
283-
curl --request DELETE \
284-
https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/routes/{route_id} \
285-
--header "X-Auth-Email: <EMAIL>" \
286-
--header "X-Auth-Key: <API_KEY>"
346+
<APIRequest
347+
path="/accounts/{account_id}/magic/routes/{route_id}"
348+
method="DELETE"
349+
/>
350+
351+
```json output
352+
{
353+
"errors": [
354+
{
355+
"code": 1000,
356+
"message": "message"
357+
}
358+
],
359+
"messages": [
360+
{
361+
"code": 1000,
362+
"message": "message"
363+
}
364+
],
365+
"result": {
366+
"deleted": true,
367+
"deleted_route": {
368+
"nexthop": "203.0.113.1",
369+
"prefix": "192.0.2.0/24",
370+
"priority": 0,
371+
"id": "023e105f4ecef8ad9ca31a8372d0c353",
372+
"description": "New route for new prefix 203.0.113.1",
373+
"scope": {
374+
"colo_names": [
375+
"den01"
376+
],
377+
"colo_regions": [
378+
"APAC"
379+
]
380+
},
381+
"weight": 0
382+
}
383+
},
384+
"success": true
385+
}
287386
```
288387

289388
</TabItem> </Tabs>

0 commit comments

Comments
 (0)