From 94d5c2d25fdb7977c30235803fe5a6447d1063ae Mon Sep 17 00:00:00 2001 From: mahtin Date: Wed, 4 May 2016 08:39:12 -0700 Subject: [PATCH] Added proxed flag to show how to adjust DNS entries after creation --- examples/example-create-zone-and-populate.py | 22 ++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/examples/example-create-zone-and-populate.py b/examples/example-create-zone-and-populate.py index 4da56a1..debfc00 100755 --- a/examples/example-create-zone-and-populate.py +++ b/examples/example-create-zone-and-populate.py @@ -33,6 +33,7 @@ def main(): # DNS records to create dns_records = [ + {'name':'ding', 'type':'A', 'content':'216.58.194.206'}, {'name':'foo', 'type':'AAAA', 'content':'2001:d8b::1'}, {'name':'foo', 'type':'A', 'content':'192.168.0.1'}, {'name':'duh', 'type':'A', 'content':'10.0.0.1', 'ttl':120}, @@ -49,7 +50,24 @@ def main(): exit('/zones.dns_records.post %s %s - %d %s' % (zone_name, record['name'], e, e)) # Print respose info - they should be the same dns_record = r - print '\t%s %30s %6d %-5s %s' % (dns_record['id'], dns_record['name'], dns_record['ttl'], dns_record['type'], dns_record['content']) + print '\t%s %30s %6d %-5s %s ; proxied=%s proxiable=%s' % (dns_record['id'], dns_record['name'], dns_record['ttl'], dns_record['type'], dns_record['content'], dns_record['proxied'], dns_record['proxiable']) + + # set proxied flag to false - for example + dns_record_id = dns_record['id'] + + new_dns_record = { + # Must have type/name/content (even if they don't change) + 'type':dns_record['type'], + 'name':dns_record['name'], + 'content':dns_record['content'], + # now add new values you want to change + 'proxied':False + } + + try: + dns_record = cf.zones.dns_records.put(zone_id, dns_record_id, data=new_dns_record) + except CloudFlare.CloudFlareAPIError as e: + exit('/zones/dns_records.put %d %s - api call failed' % (e, e)) print '' @@ -61,7 +79,7 @@ def main(): exit('/zones.dns_records.get %s - %d %s' % (zone_name, e, e)) for dns_record in sorted(dns_records, key=lambda v: v['name']): - print '\t%s %30s %6d %-5s %s' % (dns_record['id'], dns_record['name'], dns_record['ttl'], dns_record['type'], dns_record['content']) + print '\t%s %30s %6d %-5s %s ; proxied=%s proxiable=%s' % (dns_record['id'], dns_record['name'], dns_record['ttl'], dns_record['type'], dns_record['content'], dns_record['proxied'], dns_record['proxiable']) print ''