Skip to content

Commit c025f8c

Browse files
[Secrets Store, DNS] Replace examples with APIRequest (#23451)
* Replace create secrets examples with APIRequest version * Replace Delete a secrete example * Replace API examples in dns/dnssec pages * Replace API examples in dns-record-types * Replace examples in add-mx-records partial
1 parent 3be82e6 commit c025f8c

File tree

6 files changed

+136
-148
lines changed

6 files changed

+136
-148
lines changed

src/content/docs/dns/dnssec/dnssec-active-migration.mdx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,21 @@ The provider you are migrating from must allow you to add DNSKEY records on the
6060

6161
You can do this [on the dashboard](/dns/manage-dns-records/how-to/create-dns-records/#create-dns-records) or through the [Create DNS Record endpoint](/api/resources/dns/subresources/records/methods/create/), as in the following example.
6262

63-
```bash
64-
curl https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records \
65-
--header "X-Auth-Email: <EMAIL>" \
66-
--header "X-Auth-Key: <API_KEY>" \
67-
--header "Content-Type: application/json" \
68-
--data '{
69-
"type": "DNSKEY",
70-
"name": "<ZONE_NAME>",
71-
"data": {
72-
"flags": 256,
73-
"protocol": 3,
74-
"algorithm": 13,
75-
"public_key": "<PUBLIC_KEY>"
76-
},
77-
"ttl":3600
78-
}'
79-
```
63+
<APIRequest
64+
path="/zones/{zone_id}/dns_records"
65+
method="POST"
66+
json={{
67+
"type": "DNSKEY",
68+
"name": "<ZONE_NAME>",
69+
"data": {
70+
"flags": 256,
71+
"protocol": 3,
72+
"algorithm": 13,
73+
"public_key": "<PUBLIC_KEY>"
74+
},
75+
"ttl": 3600
76+
}}
77+
/>
8078

8179
2. Get Cloudflare's ZSK using either the API or a query from one of the assigned Cloudflare nameservers.
8280

src/content/docs/dns/dnssec/multi-signer-dnssec/setup.mdx

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,10 @@ For the purpose of this tutorial, you will update your registrar with the DS rec
5555

5656
2. Add the ZSK(s) of your external provider(s) to Cloudflare by creating a DNSKEY record on your zone.
5757

58-
```bash
59-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records" \
60-
--header "X-Auth-Email: <EMAIL>" \
61-
--header "X-Auth-Key: <API_KEY>" \
62-
--header "Content-Type: application/json" \
63-
--data '{
58+
<APIRequest
59+
path="/zones/{zone_id}/dns_records"
60+
method="POST"
61+
json={{
6462
"type": "DNSKEY",
6563
"name": "<ZONE_NAME>",
6664
"data": {
@@ -70,23 +68,21 @@ curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records" \
7068
"public_key": "<PUBLIC_KEY>"
7169
},
7270
"ttl": 3600
73-
}'
74-
```
71+
}}
72+
/>
7573

7674
3. Add your external provider(s) nameservers as NS records on your zone apex.
7775

78-
```bash
79-
curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records" \
80-
--header "X-Auth-Email: <EMAIL>" \
81-
--header "X-Auth-Key: <API_KEY>" \
82-
--header "Content-Type: application/json" \
83-
--data '{
76+
<APIRequest
77+
path="/zones/{zone_id}/dns_records"
78+
method="POST"
79+
json={{
8480
"type": "NS",
8581
"name": "<ZONE_NAME>",
8682
"content": "<NS_DOMAIN>",
8783
"ttl": 86400
88-
}'
89-
```
84+
}}
85+
/>
9086

9187
4. Enable the usage of the nameservers you added in the previous step by using the API request below.
9288

src/content/docs/dns/manage-dns-records/reference/dns-record-types.mdx

Lines changed: 44 additions & 44 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
This page provides information about some of the different types of DNS records that you can manage on Cloudflare. For guidance on how to add, edit, or delete DNS records, refer to [Manage DNS records](/dns/manage-dns-records/how-to/create-dns-records/).
1212

@@ -49,19 +49,20 @@ When creating A or AAAA records [using the API](/dns/manage-dns-records/how-to/c
4949

5050
<Render file="api-field-definitions" />
5151

52-
```bash title="Request" {8,10}
53-
curl "https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/dns_records" \
54-
--header "X-Auth-Email: <EMAIL>" \
55-
--header "X-Auth-Key: <API_KEY>" \
56-
--header "Content-Type: application/json" \
57-
--data '{
58-
"type": "A",
59-
"name": "www.example.com",
60-
"content": "192.0.2.1",
61-
"ttl": 3600,
62-
"proxied": false
63-
}'
64-
```
52+
<APIRequest
53+
path="/zones/{zone_id}/dns_records"
54+
method="POST"
55+
json={{
56+
"type": "A",
57+
"name": "www.example.com",
58+
"content": "192.0.2.1",
59+
"ttl": 3600,
60+
"proxied": false
61+
}}
62+
code={{
63+
mark: [8, 10],
64+
}}
65+
/>
6566

6667
```json title="Response"
6768
{
@@ -119,23 +120,24 @@ Specific CNAME record values with traffic proxied through Cloudflare will enable
119120
When creating CNAME records [using the API](/dns/manage-dns-records/how-to/create-dns-records/#create-dns-records):
120121

121122
* The `content` of the records is a [fully qualified domain name](https://en.wikipedia.org/wiki/Fully_qualified_domain_name).
122-
* The `proxied` field affects the record's [proxy status](/dns/proxy-status/)
123+
* The `proxied` field affects the record's [proxy status](/dns/proxy-status/).
123124

124125
<Render file="api-field-definitions" />
125126

126-
```bash title="Request" {8,10}
127-
curl "https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/dns_records" \
128-
--header "X-Auth-Email: <EMAIL>" \
129-
--header "X-Auth-Key: <API_KEY>" \
130-
--header "Content-Type: application/json" \
131-
--data '{
132-
"type": "CNAME",
133-
"name": "www.example.com",
134-
"content": "www.another-example.com",
135-
"ttl": 3600,
136-
"proxied": false
137-
}'
138-
```
127+
<APIRequest
128+
path="/zones/{zone_id}/dns_records"
129+
method="POST"
130+
json={{
131+
"type": "CNAME",
132+
"name": "www.example.com",
133+
"content": "www.another-example.com",
134+
"ttl": 3600,
135+
"proxied": false
136+
}}
137+
code={{
138+
mark: [8, 10],
139+
}}
140+
/>
139141

140142
```json title="Response"
141143
{
@@ -242,22 +244,20 @@ A [service record (SRV)](https://www.cloudflare.com/learning/dns/dns-records/dns
242244

243245
<Render file="api-field-definitions" />
244246

245-
```bash title="Request"
246-
curl "https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/dns_records" \
247-
--header "X-Auth-Email: <EMAIL>" \
248-
--header "X-Auth-Key: <API_KEY>" \
249-
--header "Content-Type: application/json" \
250-
--data '{
251-
"type": "SRV",
252-
"name": "_xmpp._tcp.example.com",
253-
"data": {
254-
"priority": 10,
255-
"weight": 5,
256-
"port": 5223,
257-
"target": "server.example.com"
258-
}
259-
}'
260-
```
247+
<APIRequest
248+
path="/zones/{zone_id}/dns_records"
249+
method="POST"
250+
json={{
251+
"type": "SRV",
252+
"name": "_xmpp._tcp.example.com",
253+
"data": {
254+
"priority": 10,
255+
"weight": 5,
256+
"port": 5223,
257+
"target": "server.example.com"
258+
}
259+
}}
260+
/>
261261

262262
```json title="Response"
263263
{

src/content/docs/secrets-store/integrations/workers.mdx

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sidebar:
66
label: Use with Workers
77
---
88

9-
import { WranglerConfig, Tabs, TabItem } from "~/components";
9+
import { WranglerConfig, Tabs, TabItem, APIRequest } from "~/components";
1010

1111
[Cloudflare Secrets Store](/secrets-store/) is a secure, centralized location in which account-level secrets are stored and managed. The secrets are securely encrypted and stored across all Cloudflare data centers.
1212

@@ -68,25 +68,24 @@ You can find and copy the store ID from the [Secrets Store tab](https://dash.clo
6868

6969
Refer to [Secrets Store API](/api/resources/secrets_store/) for the full API documentation.
7070

71-
```bash
72-
curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/secrets_store/stores/$STORE_ID/secrets \
73-
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
74-
--header "Content-Type: application/json" \
75-
--data '[
76-
{
77-
"name":"<MY_SECRET_NAME>",
78-
"value":"<SECRET_VALUE>",
79-
"scopes":["workers"],
80-
"comment":""
81-
},
82-
{
83-
"name":"<MY_SECRET_NAME_2>",
84-
"value":"<SECRET_VALUE>",
85-
"scopes":["workers"],
86-
"comment":""
87-
}
88-
]'
89-
```
71+
<APIRequest
72+
path="/accounts/{account_id}/secrets_store/stores/{store_id}/secrets"
73+
method="POST"
74+
json={[
75+
{
76+
"name":"<MY_SECRET_NAME>",
77+
"value":"<SECRET_VALUE>",
78+
"scopes":["workers"],
79+
"comment":""
80+
},
81+
{
82+
"name":"<MY_SECRET_NAME_2>",
83+
"value":"<SECRET_VALUE>",
84+
"scopes":["workers"],
85+
"comment":""
86+
}
87+
]}
88+
/>
9089

9190
</TabItem> </Tabs>
9291

src/content/docs/secrets-store/manage-secrets/how-to.mdx

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

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

1010
Refer to the sections below to learn about common actions you might want to take when managing your data in Secrets Store.
1111

@@ -31,25 +31,24 @@ You must have a [Super Administrator or Secrets Store Admin role](/secrets-store
3131
A secret `name` cannot contain spaces. Refer to [Secrets Store API](/api/resources/secrets_store/) for the full API documentation.
3232
:::
3333

34-
```bash
35-
curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/secrets_store/stores/$STORE_ID/secrets \
36-
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
37-
--header "Content-Type: application/json" \
38-
--data '[
39-
{
40-
"name":"<MY_SECRET_NAME>",
41-
"value":"<SECRET_VALUE>",
42-
"scopes":["workers"],
43-
"comment":""
44-
},
45-
{
46-
"name":"<MY_SECRET_NAME_2>",
47-
"value":"<SECRET_VALUE>",
48-
"scopes":["workers"],
49-
"comment":""
50-
}
51-
]'
52-
```
34+
<APIRequest
35+
path="/accounts/{account_id}/secrets_store/stores/{store_id}/secrets"
36+
method="POST"
37+
json={[
38+
{
39+
"name":"<MY_SECRET_NAME>",
40+
"value":"<SECRET_VALUE>",
41+
"scopes":["workers"],
42+
"comment":""
43+
},
44+
{
45+
"name":"<MY_SECRET_NAME_2>",
46+
"value":"<SECRET_VALUE>",
47+
"scopes":["workers"],
48+
"comment":""
49+
}
50+
]}
51+
/>
5352

5453
</TabItem> </Tabs>
5554

@@ -139,10 +138,9 @@ Before deleting a secret, make sure it is not deployed. Secrets Store secrets in
139138

140139
Refer to [Secrets Store API](/api/resources/secrets_store/) for the full API documentation.
141140

142-
```bash
143-
curl --request DELETE \
144-
https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/secrets_store/stores/$STORE_ID/secrets/$SECRET_ID \
145-
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
146-
```
141+
<APIRequest
142+
path="/accounts/{account_id}/secrets_store/stores/{store_id}/secrets/{secret_id}"
143+
method="DELETE"
144+
/>
147145

148146
</TabItem> </Tabs>

src/content/partials/dns/add-mx-records.mdx

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
22
{}
3-
43
---
54

5+
import { APIRequest } from "~/components";
6+
67
## Receive email
78

89
If you only need to **receive** emails, Cloudflare offers [Email Routing](/email-routing/) for free email forwarding to custom email addresses.
@@ -23,19 +24,17 @@ To **send and receive** emails from your domain, you need an SMTP provider. Then
2324
<summary>API example</summary>
2425
<div>
2526

26-
```bash title="Request"
27-
curl "https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/dns_records" \
28-
--header "x-auth-email: <EMAIL>" \
29-
--header "x-auth-key: <API_KEY>" \
30-
--header "Content-Type: application/json" \
31-
--data '{
32-
"type":"A",
33-
"name":"www.example.com",
34-
"content":"192.0.2.1",
35-
"ttl":3600,
36-
"proxied":false
37-
}'
38-
```
27+
<APIRequest
28+
path="/zones/{zone_id}/dns_records"
29+
method="POST"
30+
json={{
31+
"type":"A",
32+
"name":"www.example.com",
33+
"content":"192.0.2.1",
34+
"ttl":3600,
35+
"proxied":false
36+
}}
37+
/>
3938

4039
```json title="Response"
4140
{
@@ -77,18 +76,16 @@ To **send and receive** emails from your domain, you need an SMTP provider. Then
7776
<summary>API example</summary>
7877
<div>
7978

80-
```bash title="Request"
81-
curl "https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/dns_records" \
82-
--header "x-auth-email: <EMAIL>" \
83-
--header "x-auth-key: <API_KEY>" \
84-
--header "Content-Type: application/json" \
85-
--data '{
86-
"type":"MX",
87-
"name":"example.com",
88-
"content":"mail.example.com",
89-
"ttl":3600
90-
}'
91-
```
79+
<APIRequest
80+
path="/zones/{zone_id}/dns_records"
81+
method="POST"
82+
json={{
83+
"type":"MX",
84+
"name":"example.com",
85+
"content":"mail.example.com",
86+
"ttl":3600
87+
}}
88+
/>
9289

9390
```json title="Response"
9491
{

0 commit comments

Comments
 (0)