Creating Groups via REST API


#1

Setting up new tenants is getting to be a really tedious chore, and I’d love to be able to automate it by setting up as much of the necessary CloudForms bits as possible programatically … like groups & role mappings.

I can find documentation for creating roles, and even tenants, in the REST API docs, but nothing about groups, and when I try some stab-in-the-dark approaches I get knocked back with an error that suggests the POST method is unsupported on the /api/groups collection.

It seems odd that roles can be created but not groups. Is this by design, or am I doing something wrong and just haven’t found the right documentary guidance yet?


#2

I just pulled the latest and it appears groups is in the Rest api.

{"href":"https://172.16.23.187/api/groups/6","id":6,"guid":"1cff1dac-7e41-11e5-b305-000c29ee68e2","description":"EvmGroup-approver","group_type":"system","sequence":5,"created_on":"2015-10-29T13:29:42Z","updated_on":"2015-10-29T13:29:42Z","miq_user_role_id":3,"tenant_id":1,"actions":[{"name":"edit","method":"post","href":"https://172.16.23.187/api/groups/6"},{"name":"delete","method":"post","href":"https://172.16.23.187/api/groups/6"},{"name":"delete","method":"delete","href":"https://172.16.23.187/api/groups/6"}]}


#3

Unfortunately, since the MIQ EVM was originally engineered before the days of “APIs first” architecture, the APIs that are available are created as needed. I recently had a need for creating roles programmatically and, consequently, submitted a patch and pull request to have this added :slightly_smiling: As for groups, while it appears that the REST API should allow for POSTing new groups, it seems that the underlying implementation is not yet complete (no specific API controller exists to handle the POST operation… thus your error during your creation attempts).

In any case, I may have found my next API to contribute… unless, of course, you’d like to try your hand at it?


#4

Hi Josh

That looks better than what I have at the moment. Is this the nightly build?

Also, I notice there isn’t a “create” action, yet.


#5

Yeah, I’d like to try but I’m still too n00b at this ruby on rails stuff :slight_smile: Getting there …


#6

Users and Group CRUD was merged in early December with PRs https://github.com/ManageIQ/manageiq/pull/5611 and https://github.com/ManageIQ/manageiq/pull/5674 for Darga release, so v2.2.0-pre of API. sorry no doc update yet for those in https://github.com/ManageIQ/manageiq_docs (v.2.1.0). So with these 2 PRs merge, you now have CRUD on users, groups and roles.