On 23.5.2014 14:02, Bret Wortman wrote:
Is the Python API documented anywhere? I've looked around without success.

Not yet.

For now, you can use IPA CLI for inspection:

CLI commands are basically API commands, where `_` is replaced by `-`.

List objects:
  `ipa help topics`

List object commands:
  `ipa help $object`, e.g., `ipa help user`

List command CLI options and parameters:
  `ipa $command --help`, e.g., `ipa user-mod --help`

Map command params and options names to API option names:
  `ipa show-mappings $command`, e.g., `ipa show-mappings user-add`

More can be read from code or by observing Web UI communication in browser developer tools - network tab.

Then the python syntax is ~
 args = ['arg1', 'arg2']
 options = dict(option1="foo", option2="bar")
 api.Command['command_name'](*args, **options)


On 05/23/2014 07:54 AM, Martin Kosek wrote:
On 05/23/2014 06:42 AM, Sanju A wrote:
Dear All,

Is there any command to export the user and host list to a csv or
text format
There is no such command out of the shelf, I would personally just
write a
short Python script to export the hosts (or anything else) in a format
I need.

Example for host:


from ipalib import api
api.bootstrap(context='exporter', debug=False)

hosts = api.Command['host_find']()['result']

for host in hosts:
    print host['fqdn'][0]

This will print one host for each new line.


Petr Vobornik

Freeipa-users mailing list

Reply via email to