Skip to content

Instantly share code, notes, and snippets.

@cdodd
Last active October 28, 2016 05:09
Show Gist options
  • Select an option

  • Save cdodd/8845859 to your computer and use it in GitHub Desktop.

Select an option

Save cdodd/8845859 to your computer and use it in GitHub Desktop.

Revisions

  1. Craig Dodd revised this gist Feb 10, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions create_cname.py
    Original file line number Diff line number Diff line change
    @@ -13,9 +13,9 @@

    # Verify login status
    if response['status'] != 'success':
    sys.exit("Incorrect credentials")
    sys.exit('Incorrect credentials')

    # Perform action
    # Create a CNAME record
    response = rest_iface.execute(
    '/CNAMERecord/example.com/myapp.example.com.',
    'POST',
  2. Craig Dodd revised this gist Feb 6, 2014. 1 changed file with 22 additions and 18 deletions.
    40 changes: 22 additions & 18 deletions create_cname.py
    Original file line number Diff line number Diff line change
    @@ -1,25 +1,29 @@
    import sys
    from dynect.DynectDNS import DynectRest

    try:
    import json
    except ImportError:
    try:
    import simplejson as json
    except ImportError:
    sys.exit("Could not find json or simplejson libraries.")
    rest_iface = DynectRest()

    dyn = DynectRest()

    creds = {
    'customer_name': 'yourcustomer',
    'user_name': 'youruser',
    'password': 'yourpass',
    # 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")

    # Perform action
    response = rest_iface.execute(
    '/CNAMERecord/example.com/myapp.example.com.',
    'POST',
    {'rdata': {'cname':'example.herokuapp.com.'}},
    )

    def request_dyn(dyn, uri, method, args):
    response = dyn.execute(uri, method, args)
    if response['status'] != 'success':
    sys.exit('Error executing %s %s %s %s' % (uri, method, json.dumps(args), json.dumps(response)))
    # Output response data
    print response['data']

    request_dyn(dyn, '/CNAMERecord/example.com/myapp.example.com.','POST',{'rdata':{'cname':'example.herokuapp.com.'}})
    # Destroy session
    rest_iface.execute('/Session/', 'DELETE')
  3. Craig Dodd revised this gist Feb 6, 2014. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions create_cname.py
    Original file line number Diff line number Diff line change
    @@ -12,14 +12,14 @@
    dyn = DynectRest()

    creds = {
    'customer_name': 'yourcustomer',
    'user_name': 'youruser',
    'password': 'yourpass',
    'customer_name': 'yourcustomer',
    'user_name': 'youruser',
    'password': 'yourpass',
    }

    def request_dyn(dyn, uri, method, args):
    response = dyn.execute(uri, method, args)
    if response['status'] != 'success':
    sys.exit("Error executing " + uri + " " + method + " " + json.dumps(args) + " " + json.dumps(response))
    sys.exit('Error executing %s %s %s %s' % (uri, method, json.dumps(args), json.dumps(response)))

    request_dyn(dyn, '/CNAMERecord/example.com/myapp.example.com.','POST',{'rdata':{'cname':'example.herokuapp.com.'}})
  4. Craig Dodd revised this gist Feb 6, 2014. 1 changed file with 4 additions and 5 deletions.
    9 changes: 4 additions & 5 deletions create_cname.py
    Original file line number Diff line number Diff line change
    @@ -4,11 +4,10 @@
    try:
    import json
    except ImportError:

    try:
    import simplejson as json
    except ImportError:
    sys.exit("Could not find json or simplejson libraries.")
    try:
    import simplejson as json
    except ImportError:
    sys.exit("Could not find json or simplejson libraries.")

    dyn = DynectRest()

  5. Craig Dodd created this gist Feb 6, 2014.
    26 changes: 26 additions & 0 deletions create_cname.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    import sys
    from dynect.DynectDNS import DynectRest

    try:
    import json
    except ImportError:

    try:
    import simplejson as json
    except ImportError:
    sys.exit("Could not find json or simplejson libraries.")

    dyn = DynectRest()

    creds = {
    'customer_name': 'yourcustomer',
    'user_name': 'youruser',
    'password': 'yourpass',
    }

    def request_dyn(dyn, uri, method, args):
    response = dyn.execute(uri, method, args)
    if response['status'] != 'success':
    sys.exit("Error executing " + uri + " " + method + " " + json.dumps(args) + " " + json.dumps(response))

    request_dyn(dyn, '/CNAMERecord/example.com/myapp.example.com.','POST',{'rdata':{'cname':'example.herokuapp.com.'}})