Skip to content

Instantly share code, notes, and snippets.

@aliafshar
Created May 27, 2014 16:34
Show Gist options
  • Select an option

  • Save aliafshar/aa6825f6ebaa52bc1179 to your computer and use it in GitHub Desktop.

Select an option

Save aliafshar/aa6825f6ebaa52bc1179 to your computer and use it in GitHub Desktop.
from apiclient import errors
# ...
# XXX Auth
# XXX Build a service
##
# Addition of records
#
BODY = {
'additions' : [{
'name' : 'example.com.',
'type' : 'A',
'ttl' : '3600',
'rrdatas' : [
'1.2.3.4'
]
}]
}
try:
response = service.changes().create(project=PROJECT_NAME,
managedZone=ZONE_NAME,
body=BODY).execute()
except errors.HttpError, error:
print 'An error occurred: %s' % error
##
# Deletion and addition of records in the same request:
#
BODY = {
'additions' : [{
'name' : 'example.com.',
'type' : 'A',
'ttl' : '3600',
'rrdatas' : [
'2.3.4.5'
]
}],
'deletions' : [{
'name' : 'example.com.',
'type' : 'A',
'ttl' : '3600',
'rrdatas' : [
'1.2.3.4'
]
}]
}
try:
response = service.changes().create(project=PROJECT_NAME,
managedZone=ZONE_NAME,
body=BODY).execute()
except errors.HttpError, error:
print 'An error occurred: %s' % error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment