[Freeipa-users] JSON interface (Was: IPA DNS command line tools and ~)
Petr Viktorin
pviktori at redhat.com
Fri Mar 7 15:57:29 UTC 2014
On 03/07/2014 04:34 PM, Rich Megginson wrote:
[...]
> The ipa command line tools use RPC, but they use XML. If you run ipa
> -vv dnsrecord-add ... you can see the XML sent and received. There is a
> bit of work converting from XML to JSON. e.g.
> <array><data><value><string>testdomain.com.</string></value><value><string>testdomain.com</string></value></data></array> is
["testdomain.com.", "testdomain.com."]
[...]
Note that FreeIPA 4.0 (current git master) will use JSON-RPC by default,
so you'll no longer need to convert from XML.
It seems the -vv option is quickly becoming very useful for API users.
Currently the logging is very low-level; in current master I get:
$ ipa -vv ping
ipa: INFO: trying https://vm-244.idm.lab.eng.brq.redhat.com/ipa/session/json
ipa: INFO: Forwarding 'ping' to json server
'https://vm-244.idm.lab.eng.brq.redhat.com/ipa/session/json'
send: u'POST /ipa/session/json HTTP/1.1\r\nHost:
vm-244.idm.lab.eng.brq.redhat.com\r\nAccept-Encoding:
gzip\r\nAccept-Language: en-us\r\nReferer:
https://vm-244.idm.lab.eng.brq.redhat.com/ipa/xml\r\nCookie:
ipa_session=da66695e0c3a772a3fe649c3e1d11612;\r\nUser-Agent:
xmlrpclib.py/1.0.1 (by www.pythonware.com)\r\nContent-Type:
application/json\r\nContent-Length: 64\r\n\r\n{"params": [[],
{"version": "2.77"}], "method": "ping", "id": 0}'
reply: 'HTTP/1.1 200 Success\r\n'
header: Date: Fri, 07 Mar 2014 15:48:31 GMT
header: Server: Apache/2.4.6 (Fedora) mod_auth_kerb/5.4 mod_nss/2.4.6
NSS/3.15.3 Basic ECC mod_wsgi/3.4 Python/2.7.5
header: Set-Cookie: ipa_session=da66695e0c3a772a3fe649c3e1d11612;
Domain=vm-244.idm.lab.eng.brq.redhat.com; Path=/ipa; Expires=Fri, 07 Mar
2014 16:08:31 GMT; Secure; HttpOnly
header: Vary: Accept-Encoding
header: Content-Encoding: gzip
header: Content-Length: 176
header: Content-Type: application/json; charset=utf-8
body: '{\n "error": null, \n "id": 0, \n "principal":
"admin at IDM.LAB.ENG.BRQ.REDHAT.COM", \n "result": {\n
"summary": "IPA server version 3.3.90GITcb4dcd8. API version 2.77"\n
}, \n "version": "3.3.90GITcb4dcd8"\n}'
-----------------------------------------------------
IPA server version 3.3.90GITcb4dcd8. API version 2.77
-----------------------------------------------------
Would it be useful to also log pretty-printed JSON with `-vvv`, so
adventurous API explorers can just copy and paste?
--
Petr³
More information about the Freeipa-users
mailing list