Wednesday, January 16, 2013

AlertDefinitions in the RHQ REST-Api


I have in the last few days added the support for alert definitions to the REST-Api in RHQ master.
Although this will make it into RHQ 4.6 , it is not the final state of affairs.

On top of the API implementation I have also written 27 tests (for the alert part; at the time of writing this posting) that use Rest Assured to test the api.

Please try the API, give feedback and report errors; if possible as Rest Assured tests, to increase the
test coverage and as an easy way to reproduce your issues.

I think it would also be very cool if someone could write a script in whatever language that exports definitions and applies them to a resource hierarchy on a different server (e.g from test to production)

5 comments:

Kurt Stam said...

Hi Heiko,

Do you have documentation on the REST-API?

Thx,

--Kurt

Heiko Rupp said...

Hey Kurt,

of course a REST-api is by definition totally discoverable and self-explanatory, so this question is totally void.

:-)

Of course I am totally joking here, which is why I have created the documentation generator (see http://pilhuhn.blogspot.de/2012/10/restjax-rs-documentation-generation.html ), where the output is available for JON on the documentation pages and for RHQ on the download page for the release, which is for the current 4.6 release at https://sourceforge.net/projects/rhq/files/rhq/rhq-4.6.0/

Another good source of documentation are the integration tests which currently reside at http://git.fedorahosted.org/cgit/rhq/rhq.git/tree/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi and especially http://git.fedorahosted.org/cgit/rhq/rhq.git/tree/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/AlertTest.java for alerts and alert definitions.

Vlad said...

Hello,

I started to study how to export/import definitions with the REST-API and I got an issue.

The REST-API doesn't export any information about the resource the definition is applied on and this is a showstopper because when importing in the target server I need to get the resource somehow (which means by name, IDs being obviously different).

Can the REST-API be enhanced by adding the name&type of the resource in the exported data ? I think that should be easy as AlertDefinition class has the field Resource in it.


Another thing I tried is to use the CLI for implementing this feature, but it lacks the "create" definition method. Is this on purpose or you plan to add it ? It looks like CLI would be much better to use as it is more powerful.


Best regards,
Vlad Craciunoiu

Heiko Rupp said...

Vlad,
thanks for the comment -can you please open a BZ for this?

Wrt CLI - someone "just" needs to do it (iirc) there is an open BZ for that. Patches are welcome :)

Heiko

Vlad said...

Speaking of import/export, I have implemented it as a server plugin, maybe it worth to have a look here:

https://bugzilla.redhat.com/show_bug.cgi?id=535829#c6

Best regards,
Vlad