Some nice progress!
We now have routes wired up for all the major things you'd want to do
with things.
https://github.com/ansible/ansible-commander/blob/master/commander.py
https://github.com/ansible/ansible-commander/blob/master/tests.py
To learn about what resources are offered, just curl the API url once
starting the Flask app. It is just "/api"
The collections you can now GET are:
/api/users/
/api/groups/
/api/hosts/
Trailing slashes are important.
And the "/api" URL will tell you all about the fields that are
available. (It tells you about hidden variable names that you can't
edit too, which I should trim out, but it's not hurting anything --
the API will deny you access). Anyway, it's a self documenting API,
sort of.
Once you want to create something POST to one of the collections.
When you POST, you'll get back the resource and there will be an
'href' attribute that will tell you where it is. It's always
predictable though.
Example:
href = /api/groups/webservers
From there, you can PUT to the resource to edit any of the editable
fields, or DELETE the resource.
(Renames are not /yet/ supported, but I plan to add this -- until
then, just POST a new object and then DELETE the old).
There are also two "secret" URLs I'm going to be using for writing the
external inventory script tomorrow. They really aren't part of the
API, they just keep the inventory script from having to access the
database. The idea here, once again, is you could maintain a central
inventory on an ansible-commander server and still have multiple
ansible machines pointing at it.
/api/inventory/index
/api/inventory/hosts/<name>
These return what the external inventory script wants to consume.
With this in place, you can (if you are crazy in such ways) use the
REST API to manage your inventory even before the API exists.
Since the REST API is mostly standardized, this allows working with
the UI for a while. There's still code in need of cleanup, and
config files or whatever probably need to be addressed -- but it's
functional.
From a checkout of ansible-commander just do "make test" to run all the tests.
Note -- I also have some outstanding notes to make the admin user
'special', as right now, if you have a user account, you can edit
other user accounts and make new ones. For this reason, this is still
a development project which you shouldn't use in production just yet
(hopefully should be obvious).
Anyway, very good stuff, I think -- and it means start on the UI --
which I find plenty exciting -- can start in the next day or so.
The inventory script is going to be crazy simple to write, so it won't
take long.
--Michael