Skip to content

Commit b06c6b4

Browse files
committed
Use patch API method for preserving desired proxy state #8
1 parent 13c075d commit b06c6b4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

cloudflareddns/cloudflareddns.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import logging as log # for verbose output
99
import os
1010
import socket # to get default hostname
11-
import sys
1211

1312
import CloudFlare
1413
import requests
@@ -141,7 +140,7 @@ def update(hostname, ip, ttl=None):
141140

142141
if ipAddressType != oldIpType:
143142
# only update the correct address type (A or AAAA)
144-
# we don't see this becuase of the search params above
143+
# we don't see this because of the search params above
145144
log.debug('IGNORED: %s %s ; wrong address family' % (hostname, oldIp))
146145
continue
147146

@@ -154,14 +153,14 @@ def update(hostname, ip, ttl=None):
154153
dnsRecordId = dnsRecord['id']
155154

156155
try:
157-
cf.zones.dns_records.put(zone_id, dnsRecordId, data=desiredRecordData)
156+
cf.zones.dns_records.patch(zone_id, dnsRecordId, data=desiredRecordData)
158157
except CloudFlare.exceptions.CloudFlareAPIError as e:
159158
log.error('/zones.dns_records.put %s - %d %s - api call failed' % (hostname, e, e))
160159
return '911'
161160
log.info('UPDATED: %s %s -> %s' % (hostname, oldIp, ip))
162161
return 'good'
163162

164-
# no exsiting dns record to update - so create dns record
163+
# no existing dns record to update - so create dns record
165164
try:
166165
cf.zones.dns_records.post(zone_id, data=desiredRecordData)
167166
log.info('CREATED: %s %s' % (hostname, ip))

0 commit comments

Comments
 (0)