[Hawkular-dev] inventory API: can I get a feed ID from a resource ID?

Lukas Krejci lkrejci at redhat.com
Mon Jul 20 04:02:04 EDT 2015


In Inventory 0.2.0.Alpha1 which I am about to release today if no breakage was 
discovered during my absence:

If you have the resource java object, which I think you have in agent, you 
simply do:

resourceObject.getPath().ids().getFeedId();

Long version:

All inventory entities now store a "canonical path" which is a path going down 
from tenant do the entity in question following the "contains" relationships.

The above call will take the resource object's path analyze it using the 
"ids()" call and will return the feed id, if the resource is contained within 
a feed or null, if the resource lives directly under an environment.

Also if you just store the resource ID, remember that that is only "locally 
unique" within your feed, so to reliably get the correct resource, you only 
can search for it within the feed:

inventory.tenants().getAll("asdf").environments().get("asf").feeds("myfeed")
.resources().get("resource-id");

If you also store the canonical path of the resource, you could do:

inventory.inspect(CanonicalPath.fromString("resource-path"), 
Resources.Single.class);

which would return to you the same access object as the above call.

So when you create your resource, you supply locally unique id, and can use 
the access object returned from the create method to get the newly created 
resource which will contain its full canonical path and all the other details.

On Friday, July 17, 2015 15:11:42 John Mazzitelli wrote:
> To the inventory folks: is there an API that gives me a feed ID if all I
> know is a resource ID? If there is no API, can I get one? :)
> 
> We'll need a way to determine what feed is responsible for managing what
> parts of the inventory. So, given that clients like the UI will only know
> about things like resource ID, that's all they will be able to give the
> kettle - but the server-side components will need to take that resource ID
> and get its associated feed ID so it can pass messages to the feed that is
> managing that resource. _______________________________________________
> hawkular-dev mailing list
> hawkular-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hawkular-dev



More information about the hawkular-dev mailing list