[Freeipa-users] JSON-RPC documentation?
Rob Crittenden
rcritten at redhat.com
Tue Jan 15 02:35:53 UTC 2013
Dmitri Pal wrote:
> On 01/14/2013 08:16 PM, Brian Smith wrote:
>> Before I pester the dev list, I was wondering if anyone here could
>> point me to documentation on the JSON-RPC interface to FreeIPA. I'm
>> not doing anything fancy, just adding users and updating passwords, so
>> my requirements are pretty tame. I've gone through the Python code
>> and have somewhat pieced it together myself, but would be more
>> comfortable if there were official docs.
>>
> I do not remember us having documentation about XML-RPC but I will check.
> We are actually debating deprecating XML-RPC over time in favor of JSON.
There is no official documentation on either XML-RPC or JSON. The format
is rather straightforward once you get the hang of things. Each command
is effectively an RPC function (e.g ipa user-add -> user_add). The
arguments consist of positional arguments followed by named arguments
(there is usually only one positional arg).
For XML-RPC it is generally fairly easy to work out what it's doing by
adding -vv option to the command-line to see the raw request and
response. I personally haven't done a lot of raw JSON work.
The final option is to skip all that and use the ipalib to do the work
for you.
For example, to add a user you'd do something like:
from ipalib import api
from ipalib import errors
api.bootstrap(context='cli')
api.finalize()
api.Backend.xmlclient.connect()
try:
api.Command['user_add'](u'newuser',
loginshell=u'/bin/something',
givenname=u'New', sn=u'User')
except errors.DuplicateEntry:
print "user already exists"
else:
print "user added"
More information about the Freeipa-users
mailing list