Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add examples to create dns record #1231

Merged
merged 11 commits into from
Jul 31, 2024
26 changes: 26 additions & 0 deletions examples/dns/record.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from cloudflare import Cloudflare


# define your variable here
mftzk marked this conversation as resolved.
Show resolved Hide resolved

cloudflare_token = "your-cloudflare-token"
cloudflare_zone_id = "zone"
alias_name = "www.mydns.com"
cannonical_name = "cname.example.com"
mftzk marked this conversation as resolved.
Show resolved Hide resolved

# build cloudflare driver here
mftzk marked this conversation as resolved.
Show resolved Hide resolved
client = Cloudflare(api_token=cloudflare_token)
mftzk marked this conversation as resolved.
Show resolved Hide resolved



# create dns using defined driver
dns = client.dns.records.create(
zone_id=cloudflare_zone_id,
type='CNAME',
name=alias_name,
content=cannonical_name,
proxied=False
)

# print output
print(dns)
mftzk marked this conversation as resolved.
Show resolved Hide resolved