Skip to content

Commit a7f8722

Browse files
marciocloudflareRebeccaTamachiro
authored andcommitted
[Magic] Updating API paths and use APIRequest (#20704)
* added apirequest * added apirequest comp * Merge remote-tracking branch 'origin/production' into marcio/pcx15975-magic-api * removed api * added apirequest component * corrected fields * removed old api example * added api component removed old * corrected link to API site added apirequest component * added apirequest import * added json fields * corrected json * removed old example * corrected output example * updated api url * added put apirequest schema * removed old code * added response example * corrected link * added component corrected enpoint * deleted old api * indentation
1 parent 65634c0 commit a7f8722

File tree

4 files changed

+155
-115
lines changed

4 files changed

+155
-115
lines changed

src/content/docs/magic-network-monitoring/tutorials/encrypt-network-flow-data.mdx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ head:
99
content: Magic Network Monitoring encrypt network flow data
1010
---
1111

12+
import { APIRequest } from "~/components"
13+
1214
Customers can encrypt the network flow data sent from their router to Cloudflare by [routing](https://www.cloudflare.com/learning/network-layer/what-is-routing/) their network flow traffic through a device running the WARP client. Then, encrypted network flow traffic can be forwarded from the WARP enabled device to Cloudflare's network flow endpoints.
1315

1416
To learn more about the WARP client, and to install the WARP client on Linux, macOS, or Windows, you can visit the [WARP client documentation](/cloudflare-one/connections/connect-devices/warp/).
@@ -28,22 +30,19 @@ The `warp_devices` array at the account level is a list of WARP devices through
2830

2931
For example:
3032

31-
```bash
32-
curl --request PATCH \
33-
"https://api.cloudflare.com/client/v4/accounts/{account_id}/mnm/config" \
34-
--header "X-Auth-Email: <EMAIL>" \
35-
--header "X-Auth-Key: <API_KEY>" \
36-
--header "Content-Type: application/json" \
37-
--data '{
38-
"warp_devices": [
33+
<APIRequest
34+
path="/accounts/{account_id}/mnm/config"
35+
method="PATCH"
36+
json={{
37+
"warp_devices": [
3938
{
40-
"id": "5360368d-b351-4791-abe1-93550dabd351",
41-
"name": "My warp device",
42-
"router_ip": "203.0.113.1"
39+
"id": "<YOUR_WARP_DEVICE_UNIQUE_IDENTIFIER>",
40+
"name": "<NAME_OF_WARP_DEVICE>",
41+
"router_ip": "YOUR_ROUTER_IP"
4342
}
4443
]
45-
}'
46-
```
44+
}}
45+
/>
4746

4847
## 2. Route Magic Network Monitoring traffic through WARP
4948

src/content/docs/magic-transit/how-to/configure-magic-tunnel-alerts.mdx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ head: []
55
description: Use the API to set up and configure Magic Tunnel health alerts
66
---
77

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

1010
<Render
1111
file="magic-tunnel-health-alerts/magic-tunnel-health-alerts"
@@ -36,28 +36,28 @@ Refer to the [documentation for Notifications](/notifications/get-started/) to l
3636

3737
Send a [`POST` request](/api/resources/alerting/subresources/policies/methods/create/) to create a Magic Transit tunnel health alert. You can set tunnel health alerts with any SLO value between `0` and `99.99`.
3838

39-
```bash
40-
curl https://api.cloudflare.com/client/v4/accounts/account_id/alerting/v3/policies \
41-
--header 'Authorization: Bearer <YOUR_TOKEN>' \
42-
--header 'Content-Type: application/json' \
43-
--data '{
44-
"alert_type": "magic_tunnel_health_check_event",
45-
"description": "<DESCRIBE_POLICY>",
46-
"enabled": true,
47-
"filters": {
48-
"slo": [
49-
"99.9"
50-
]
51-
},
52-
"mechanisms": {
53-
"email": [
54-
{
55-
"id": "EMAIL_ADDRESS"
56-
}
57-
],
58-
"name": "<DESCRIBE_ALERT>"
59-
}'
60-
```
39+
<APIRequest
40+
path="/accounts/{account_id}/alerting/v3/policies"
41+
method="POST"
42+
json={{
43+
"alert_type": "magic_tunnel_health_check_event",
44+
"description": "<DESCRIBE_POLICY>",
45+
"enabled": true,
46+
"filters": {
47+
"slo": [
48+
"99.9"
49+
]
50+
},
51+
"mechanisms": {
52+
"email": [
53+
{
54+
"id": "EMAIL_ADDRESS"
55+
}
56+
]},
57+
"name": "<DESCRIBE_ALERT>"
58+
59+
}}
60+
/>
6161

6262
```json output
6363
{

src/content/docs/magic-wan/configuration/common-settings/configure-magic-tunnel-alerts.mdx

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ head: []
55
description: Use the API to set up and configure Magic Tunnel health alerts
66
---
77

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

1010
<Render
1111
file="magic-tunnel-health-alerts/magic-tunnel-health-alerts"
@@ -34,28 +34,27 @@ Refer to the [documentation for Notifications](/notifications/get-started/) to l
3434

3535
Send a [`POST` request](/api/resources/alerting/subresources/policies/methods/create/) to create a Magic WAN tunnel health alert. You can set tunnel health alerts with any SLO value between `0` and `99.99`.
3636

37-
```bash
38-
curl https://api.cloudflare.com/client/v4/accounts/account_id/alerting/v3/policies \
39-
--header 'Authorization: Bearer <YOUR_TOKEN>' \
40-
--header 'Content-Type: application/json' \
41-
--data '{
42-
"alert_type": "magic_wan_tunnel_health",
43-
"description": "<DESCRIBE_POLICY>",
44-
"enabled": true,
45-
"filters": {
46-
"slo": [
47-
"99.9"
48-
]
49-
},
50-
"mechanisms": {
51-
"email": [
52-
{
53-
"id": "EMAIL_ADDRESS"
54-
}
55-
],
56-
"name": "<DESCRIBE_ALERT>"
57-
}'
58-
```
37+
<APIRequest
38+
path="/accounts/{account_id}/alerting/v3/policies"
39+
method="POST"
40+
json={{
41+
"alert_type": "magic_wan_tunnel_health",
42+
"description": "<DESCRIBE_POLICY>",
43+
"enabled": true,
44+
"filters": {
45+
"slo": [
46+
"99.9"
47+
]
48+
},
49+
"mechanisms": {
50+
"email": [
51+
{
52+
"id": "EMAIL_ADDRESS"
53+
}
54+
]},
55+
"name": "<DESCRIBE_ALERT>"
56+
}}
57+
/>
5958

6059
```json output
6160
{

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

Lines changed: 98 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Network segmentation
44
description: Define policies to define if traffic should flow between your LANs without leaving your local premises, or if traffic should be forwarded to Cloudflare for additional security configurations.
55
---
66

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

99
You can define policies in your Connector to either allow traffic to flow between your LANs without it leaving your local premises or to forward it via the Cloudflare network where you can add additional security features. The default behavior is to drop all LAN-to-LAN traffic. These policies can be created for specific subnets, and link two LANs.
1010

@@ -69,17 +69,14 @@ The new policy will ensure that traffic between the specified LANs flows locally
6969

7070
<Render file="connector/account-id-api-key" />
7171

72-
Create a `POST` request [using the API](/api/operations/magic-site-acls-create-acl) to create a network policy.
72+
Create a `POST` request [using the API](/api/resources/magic_transit/subresources/sites/subresources/acls/methods/create/) to create a network policy.
7373

7474
Example:
7575

76-
```bash
77-
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/sites/{site_id}/acls \
78-
--header "X-Auth-Email: <EMAIL>" \
79-
--header "X-Auth-Key: <API_KEY>" \
80-
--header "Content-Type: application/json" \
81-
--data '{
82-
"acl": {
76+
<APIRequest
77+
path="/accounts/{account_id}/magic/sites/{site_id}/acls"
78+
method="POST"
79+
json={{
8380
"description": "<POLICY_DESCRIPTION>",
8481
"forward_locally": true,
8582
"lan_1": {
@@ -106,38 +103,60 @@ curl https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/sites/{sit
106103
"protocols": [
107104
"tcp"
108105
]
109-
}
110-
}'
111-
```
106+
}}
107+
/>
112108

113109
```json output
114110
{
115-
"errors": [],
116-
"messages": [],
117-
"result": {
118-
"acls": [
119-
{
120-
"description": "<POLICY_DESCRIPTION>",
121-
"forward_locally": true,
122-
"id": "023e105f4ecef8ad9ca31a8372d0c353",
123-
"lan_1": {
124-
"lan_id": "<LAN_ID>",
125-
"lan_name": "<LAN_NAME>",
126-
"ports": [1],
127-
"subnets": ["192.0.2.1"]
128-
},
129-
"lan_2": {
130-
"lan_id": "<LAN_ID>",
131-
"lan_name": "<LAN_NAME>",
132-
"ports": [1],
133-
"subnets": ["192.0.2.1"]
134-
},
135-
"name": "<POLICY_NAME>",
136-
"protocols": ["tcp"]
137-
}
138-
]
139-
},
140-
"success": true
111+
"errors": [
112+
{
113+
"code": 1000,
114+
"message": "message"
115+
}
116+
],
117+
"messages": [
118+
{
119+
"code": 1000,
120+
"message": "message"
121+
}
122+
],
123+
"result": {
124+
"id": "023e105f4ecef8ad9ca31a8372d0c353",
125+
"description": "Allows local traffic between PIN pads and cash register.",
126+
"forward_locally": true,
127+
"lan_1": {
128+
"lan_id": "lan_id",
129+
"lan_name": "lan_name",
130+
"port_ranges": [
131+
"8080-9000"
132+
],
133+
"ports": [
134+
1
135+
],
136+
"subnets": [
137+
"192.0.2.1"
138+
]
139+
},
140+
"lan_2": {
141+
"lan_id": "lan_id",
142+
"lan_name": "lan_name",
143+
"port_ranges": [
144+
"8080-9000"
145+
],
146+
"ports": [
147+
1
148+
],
149+
"subnets": [
150+
"192.0.2.1"
151+
]
152+
},
153+
"name": "PIN Pad - Cash Register",
154+
"protocols": [
155+
"tcp"
156+
],
157+
"unidirectional": true
158+
},
159+
"success": true
141160
}
142161
```
143162

@@ -163,18 +182,14 @@ The new policy will ensure that traffic between the specified LANs flows locally
163182

164183
<Render file="connector/account-id-api-key" />
165184

166-
Create a `PUT` request [using the API](/api/operations/magic-site-acls-update-acl) to edit a network policy.
185+
Create a `PUT` request [using the API](/api/resources/magic_transit/subresources/sites/subresources/acls/methods/update/) to edit a network policy.
167186

168187
Example:
169188

170-
```bash
171-
curl --request PUT \
172-
https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id} \
173-
--header "X-Auth-Email: <EMAIL>" \
174-
--header "X-Auth-Key: <API_KEY>" \
175-
--header "Content-Type: application/json" \
176-
--data '{
177-
"acl": {
189+
<APIRequest
190+
path="/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}"
191+
method="PUT"
192+
json={{
178193
"description": "<POLICY_DESCRIPTION>",
179194
"forward_locally": true,
180195
"lan_1": {
@@ -201,8 +216,37 @@ https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/sites/{site_id}
201216
"protocols": [
202217
"tcp"
203218
]
204-
}
205-
}'
219+
}}
220+
/>
221+
222+
```json output
223+
{
224+
"errors": [
225+
{
226+
"code": 1000,
227+
"message": "message"
228+
}
229+
],
230+
"messages": [
231+
{
232+
"code": 1000,
233+
"message": "message"
234+
}
235+
],
236+
"result": {
237+
"id": "023e105f4ecef8ad9ca31a8372d0c353",
238+
"connector_id": "ac60d3d0435248289d446cedd870bcf4",
239+
"description": "description",
240+
"ha_mode": true,
241+
"location": {
242+
"lat": "37.6192",
243+
"lon": "122.3816"
244+
},
245+
"name": "site_1",
246+
"secondary_connector_id": "8d67040d3835dbcf46ce29da440dc482"
247+
},
248+
"success": true
249+
}
206250
```
207251

208252
</TabItem> </Tabs>
@@ -224,15 +268,13 @@ https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/sites/{site_id}
224268

225269
<Render file="connector/account-id-api-key" />
226270

227-
Create a `DELETE` request [using the API](/api/operations/magic-site-acls-delete-acl) to delete a network policy.
271+
Create a `DELETE` request [using the API](/api/resources/magic_transit/subresources/sites/subresources/acls/methods/delete/) to delete a network policy.
228272

229273
Example:
230274

231-
```bash
232-
curl --request DELETE \
233-
https://api.cloudflare.com/client/v4/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_identifier} \
234-
--header "X-Auth-Email: <EMAIL>" \
235-
--header "X-Auth-Key: <API_KEY>"
236-
```
275+
<APIRequest
276+
path="/accounts/{account_id}/magic/sites/{site_id}/acls/{acl_id}"
277+
method="DELETE"
278+
/>
237279

238280
</TabItem> </Tabs>

0 commit comments

Comments
 (0)