Skip to content

Commit 513a0ce

Browse files
committed
Adds APIRequest component
1 parent 83eb40f commit 513a0ce

File tree

4 files changed

+94
-49
lines changed

4 files changed

+94
-49
lines changed

src/content/docs/spectrum/about/static-ip.mdx

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ weight: 0
55

66
---
77

8+
import { APIRequest } from "~/components"
9+
810
When you create a Spectrum application, you are assigned an IP. These IPs are normally dynamic, meaning that they will change over time. But, for instance, if you want to set up WAF custom rules for specific IPs, you may want to use static IPs. A static IP, like a physical street address can tell other computers or servers on the Internet where a specific computer is located or connected. This makes the device easier to find on the network, since the IP will not change.
911

1012
With static IPs, Cloudflare commits to never changing the IP address of a client's domain resolved at the Cloudflare global network. For example, `www.example.com` will always resolve and accept traffic sent to `198.51.100.10`. No other customer will be hosted on that IP.
@@ -17,27 +19,26 @@ Once you get your static IP from Cloudflare, you can use it via API, just like [
1719

1820
When creating a Spectrum application through the API, specify the static IPs that you have been provided. See, for instance, the API example below that creates an application routing traffic through Cloudflare’s HTTP pipeline.
1921

20-
```bash
21-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/spectrum/apps" \
22-
--header "Authorization: Bearer <API_TOKEN>" \
23-
--header "Content-Type: application/json" \
24-
--data '{
25-
"protocol": "tcp/80",
26-
"dns": {
27-
"type": "ADDRESS",
28-
"name": "www.example.com"
29-
},
30-
"origin_direct": [
31-
"tcp://192.0.2.1:80"
32-
],
33-
"tls": "off",
34-
"traffic_type": "http",
35-
"edge_ips": {
36-
"type": "static",
37-
"ips": [
38-
"198.51.100.10",
39-
"2001:DB8::1"
40-
]
41-
}
42-
}'
43-
```
22+
<APIRequest
23+
path="/zones/{zone_id}/spectrum/apps"
24+
method="POST"
25+
json={{
26+
protocol: "tcp/80",
27+
dns: {
28+
type: "ADDRESS",
29+
name: "www.example.com"
30+
},
31+
origin_direct: [
32+
"tcp://192.0.2.1:80"
33+
],
34+
tls: "off",
35+
traffic_type: "http",
36+
edge_ips: {
37+
type: "static",
38+
ips: [
39+
"198.51.100.10",
40+
"2001:DB8::1"
41+
]
42+
}
43+
}}
44+
/>

src/content/docs/spectrum/get-started.mdx

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

77
---
88

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

1111
Spectrum is available on all paid plans. Pro and Business support selected protocols only, whereas Enterprise supports all TCP and UDP based traffic. Refer to [Configuration options](/spectrum/reference/configuration-options/) for more configuration details.
1212

@@ -41,12 +41,29 @@ Below is a curl example and the associated data being posted to the API.
4141

4242
**API example:**
4343

44-
```bash
45-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/spectrum/apps" \
46-
--header "Authorization: Bearer <API_TOKEN>" \
47-
--header "Content-Type: application/json" \
48-
--data '{"protocol":"tcp/22","dns":{"type":"CNAME","name":"ssh.example.com"},"origin_direct":["tcp://192.0.2.1:22"],"proxy_protocol":"off","ip_firewall":true,"tls":"full","edge_ips":{"type":"dynamic","connectivity":"all"},"traffic_type":"direct","argo_smart_routing":true}'
49-
```
44+
<APIRequest
45+
path="/zones/{zone_id}/spectrum/apps"
46+
method="POST"
47+
json={{
48+
protocol: "tcp/22",
49+
dns: {
50+
type: "CNAME",
51+
name: "ssh.example.com"
52+
},
53+
origin_direct: [
54+
"tcp://192.0.2.1:22"
55+
],
56+
proxy_protocol: "off",
57+
ip_firewall: true,
58+
tls: "full",
59+
edge_ips: {
60+
type: "dynamic",
61+
connectivity: "all"
62+
},
63+
traffic_type: "direct",
64+
argo_smart_routing: true
65+
}}
66+
/>
5067

5168
**Example data:**
5269

@@ -109,12 +126,25 @@ Below is a curl example and the associated data being posted to the API.
109126

110127
**API example:**
111128

112-
```bash
113-
curl 'https://api.cloudflare.com/client/v4/zones/{zone_id}/spectrum/apps' \
114-
--header "Authorization: Bearer <API_TOKEN>" \
115-
--header "Content-Type: application/json" \
116-
--data '{"dns":{"type":"CNAME","name":"spectrum-cname.example.com"},"ip_firewall":false,"protocol":"tcp/22","proxy_protocol":"off","tls":"off","origin_dns": {"name": "cname-to-origin.example.com", "ttl": 1200}, "origin_port": 22}'
117-
```
129+
<APIRequest
130+
path="/zones/{zone_id}/spectrum/apps"
131+
method="POST"
132+
json={{
133+
dns: {
134+
type: "CNAME",
135+
name: "spectrum-cname.example.com"
136+
},
137+
ip_firewall: false,
138+
protocol: "tcp/22",
139+
proxy_protocol: "off",
140+
tls: "off",
141+
origin_dns: {
142+
name: "cname-to-origin.example.com",
143+
ttl: 1200
144+
},
145+
origin_port: 22
146+
}}
147+
/>
118148

119149
**Example data:**
120150

src/content/docs/spectrum/reference/analytics.mdx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ weight: 0
55

66
---
77

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

1010
Cloudflare measures the following metrics for every connection.
1111

@@ -81,10 +81,9 @@ Use the operators below to filter data.
8181

8282
## Analytics query example
8383

84-
```bash
85-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/spectrum/analytics/events/summary?metrics=count&dimensions=event,appID&since=2018-01-01T16:57:00Z" \
86-
--header "X-Auth-Email: <EMAIL>" \
87-
--header "X-Auth-Key: <API_KEY>"
88-
```
84+
<APIRequest
85+
path="/zones/{zone_id}/spectrum/analytics/events/summary"
86+
method="GET"
87+
/>
8988

9089
Refer to the [Spectrum API documentation](/api/resources/spectrum/subresources/analytics/subresources/aggregates/subresources/currents/methods/get/) for more examples of API requests.

src/content/partials/spectrum/spectrum-with-load-balancer-api.mdx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,31 @@
33

44
---
55

6+
import { APIRequest } from "~/components"
7+
68
Below is a curl example and the associated data being posted to the API.
79

810
**API example:**
911

10-
```bash
11-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/spectrum/apps" \
12-
--header "Authorization: Bearer <API_TOKEN>" \
13-
--header "Content-Type: application/json" \
14-
--data '{"dns":{"type":"CNAME","name":"spectrum-cname.example.com"},"ip_firewall":false,"protocol":"tcp/22","proxy_protocol":"off","tls":"off","origin_dns": {"name": "cname-to-origin.example.com", "ttl": 1200}, "origin_port": 22}'
15-
```
12+
<APIRequest
13+
path="/zones/{zone_id}/spectrum/apps"
14+
method="POST"
15+
json={{
16+
dns: {
17+
type: "CNAME",
18+
name: "spectrum-cname.example.com"
19+
},
20+
ip_firewall: false,
21+
protocol: "tcp/22",
22+
proxy_protocol: "off",
23+
tls: "off",
24+
origin_dns: {
25+
name: "cname-to-origin.example.com",
26+
ttl: 1200
27+
},
28+
origin_port: 22
29+
}}
30+
/>
1631

1732
**Example data:**
1833

0 commit comments

Comments
 (0)