From 4002758021f382fc8f5fba50d4c4e230b4b91d11 Mon Sep 17 00:00:00 2001 From: Aji Mufti <39007244+mftzk@users.noreply.github.com> Date: Tue, 30 Jul 2024 13:55:17 +0700 Subject: [PATCH] Update record.py zone id get from os environment variable --- examples/dns/record.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/dns/record.py b/examples/dns/record.py index 5b271b85c0e..05ee42c60f8 100644 --- a/examples/dns/record.py +++ b/examples/dns/record.py @@ -1,24 +1,27 @@ +import os from cloudflare import Cloudflare +zone_id = os.getenv("CLOUDFLARE_ZONE_ID") +if zone_id is None: + sys.exit("CLOUDFLARE_ZONE_ID is not defined") -cloudflare_token = "your-cloudflare-token" -cloudflare_zone_id = "zone" alias_name = "www.mydns.com" cannonical_name = "cname.example.com" -client = Cloudflare() +client = Cloudflare() # create dns using defined driver record = client.dns.records.create( - zone_id=cloudflare_zone_id, + zone_id=zone_id, type='CNAME', name=alias_name, content=cannonical_name, proxied=False ) + # print output -print(record) \ No newline at end of file +print(record)