Created
July 9, 2013 13:51
-
-
Save eviljim/5957495 to your computer and use it in GitHub Desktop.
Basic python class to talk to an Interworx webhosting control panel (nodeworx or siteworx) API using python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xmlrpclib | |
class InterworxRpc(object): | |
def __init__(self, server_url, key_file): | |
with open(key_file, 'r') as f: | |
self.key = f.read() | |
self.server = xmlrpclib.Server('https://%s:2443/xmlrpc' % server_url) | |
def Query(self, path, cmd, params=None): | |
params = params or {} | |
return self.server.iworx.route( | |
self.key, path, cmd, params) | |
# The demo code below is just an example use of the above. | |
SERVER_URL = 'hazelgrace.amusive.com' | |
# You will need to create a file with this name that contains your API key. | |
# Make sure this file does not have read permissions granted to any other users! | |
KEY_FILE = '.interworx.key' | |
rpc = InterworxRpc(SERVER_URL, KEY_FILE) | |
# Issue a command to get a list of all zones for this server. | |
res = rpc.Query('/nodeworx/dns/zone', 'listZones') | |
for dom in res['payload']: | |
print dom['domain'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment