Skip to content

Instantly share code, notes, and snippets.

@cdodd
Last active October 28, 2016 05:09
Show Gist options
  • Save cdodd/8845859 to your computer and use it in GitHub Desktop.
Save cdodd/8845859 to your computer and use it in GitHub Desktop.
Create a CNAME record using the DynECT REST API.
import sys
from dynect.DynectDNS import DynectRest
rest_iface = DynectRest()
# Log in
credentials = {
'customer_name': 'my_cust',
'user_name': 'my_user',
'password': 'my_pass',
}
response = rest_iface.execute('/Session/', 'POST', credentials)
# Verify login status
if response['status'] != 'success':
sys.exit('Incorrect credentials')
# Create a CNAME record
response = rest_iface.execute(
'/CNAMERecord/example.com/myapp.example.com.',
'POST',
{'rdata': {'cname':'example.herokuapp.com.'}},
)
# Output response data
print response['data']
# Destroy session
rest_iface.execute('/Session/', 'DELETE')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment