Initial commit
authorNIIBE Yutaka <gniibe@fsij.org>
Sat, 10 May 2014 10:44:46 +0000 (19:44 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Sat, 10 May 2014 10:44:46 +0000 (19:44 +0900)
.gitignore [new file with mode: 0644]
api-key-info.asc [new file with mode: 0644]
gandi_tool.py [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..0d20b64
--- /dev/null
@@ -0,0 +1 @@
+*.pyc
diff --git a/api-key-info.asc b/api-key-info.asc
new file mode 100644 (file)
index 0000000..cf8d5d6
--- /dev/null
@@ -0,0 +1,14 @@
+-----BEGIN PGP MESSAGE-----
+Version: GnuPG v1.4.12 (GNU/Linux)
+
+hQEMA3mnkJMIQjnPAQf9F4hWbz6mCGL6PST67UMTuvyloHgorb4KWW/ZGtfvhIUz
+dCteANQvWtMNjGfWHYwakD9YOIHHdOguSHwmWIrVrUhzKiQwUA/rE81ML1Shd9E5
+QgizSrD3ghCHv7qHnn+7T88j2Tx33yNkDTiFfmgI68RIi8DVD+MtcIIxGQdjZQfG
+RUiGR+SGVuWcfDfbJW1AeiAXrGjXwJIwJt8s+SUptduvreoLjQzLOdJwtmJ9mXKO
+02MbmjcSPoiLjt5vTsIQQpSI40TViynjLvLkET2N+USTb+TrHzv+1Jo128/r/iji
+lA4KGmcAURx+8KjWoJeom//Teiht4xQq4y9rogIcjtJ+Ae92d0F8Lf1tvLNDLorq
+EZDrWV9MBIcjydMRXUQxYcNTLNqZEZtDbrGAxBSguAJ61eBzsLn4g/5E39R+ttqd
+AfOj09Li/eERFwWuXuxIpHjGvUnZyD0G8JHj1fnLM1ZNltvq1l8R6G7A4EtiM3UX
+jCOVXkpOVMa+KMIJsDpw
+=u34s
+-----END PGP MESSAGE-----
diff --git a/gandi_tool.py b/gandi_tool.py
new file mode 100644 (file)
index 0000000..594dd0a
--- /dev/null
@@ -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