author | NIIBE Yutaka <gniibe@fsij.org> | 2014年05月10日 19:44:46 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2014年05月10日 19:44:46 +0900 |
commit | 8fb81ae3c99c7a1bf438d0482d442cb4371bbe4e (patch) | |
tree | a6ad18b27cf40d07b33690fce22e1e7e4e074cb8 /gandi_tool.py |
-rw-r--r-- | gandi_tool.py | 31 |
diff --git a/gandi_tool.py b/gandi_tool.py new file mode 100644 index 0000000..594dd0a --- /dev/null +++ b/gandi_tool.py @@ -0,0 +1,31 @@ +url='https://rpc.gandi.net/xmlrpc/' + +import xmlrpclib +api = xmlrpclib.ServerProxy(url) + +import subprocess +command=['gpg', '--decrypt', '-o', '-', 'api-key-info.asc' ] +p = subprocess.Popen(command, stdout=subprocess.PIPE) +keydata_string = p.communicate()[0] + +import json +keydata = json.loads(keydata_string) +apikey = keydata['key'] +# validation check: is it 24-char? + +version = api.version.info(apikey) +print("API Version: %s", version) +print(api.domain.info(apikey, 'fsij.org')) + +print(api.domain.forward.count(apikey, 'fsij.org')) +print(api.domain.forward.list(apikey, 'fsij.org')) + +# >>> api.domain.forward.create(apikey, 'mydomain.net', 'admin', +# ... {'destinations': ['stephanie@example.com']}) +# {'destinations': ['stephanie@example.com'], 'source': 'admin'} +# +# >>> api.domain.forward.update(apikey, 'mydomain.net', 'admin', ... {'destinations': ['stephanie@example.com', 'steph@example.com']}) +# {'destinations': ['stephanie@example.com', 'steph@example.com'], 'source': 'admin'} +# +# >>> api.domain.forward.delete(apikey, 'mydomain.net', 'admin') +# True |