[Hawkular-dev] Serialization format for inventory relations

Jiri Kremser jkremser at redhat.com
Thu Apr 23 07:19:23 EDT 2015


Hello devs,
  currently, the inventory REST API can't answer requests like 'give me all related entities to this entity' or similar. I am working on exposing the relationships. Although, it's not probably the use case the REST was designed for (relations are not resources), I would like to stick with standards as much as possible.

I suggest using the JSON-LD[1] standard as the underlying serialization format. 
pros:
 * w3c standard
 * can be converted into RDF, RDFa, Turtle, etc. and stored in arbitrary triplestore (might be useful for some offline analysis, querying with SPARQL, etc)
 * HATEOASS ready, because the ids are URIs

cons:
 * not as concise as plain JSON

Here is an example of 1 relation/edge:

{
  "@context": {
    "inv": "http://hawkular.org/inventory/0.0.1",
    "baseUrl": "http://127.0.0.1:8080/hawkular/inventory/"
  },
  "@id": "baseUrl:relationships/1337",
  "inv:shortId": "2",
  "@type": "inv:Relationship",
  "inv:source": {
    "@id": "baseUrl:tenants/acme",
    "@type": "inv:Tenant",
    "inv:shortId": "acme"
  },
  "inv:label": "contains",
  "inv:target": {
    "@id": "baseUrl:acme/resourceTypes/URL",
    "@type": "inv:ResourceType",
    "inv:shortId": "URL"
  },
  "inv:properties": {
    "created": "2000-01-01",
    "strength": 0.8
  }
}

(inv:properties can be omitted)

The work is almost done in here[2]

[1]: http://www.w3.org/TR/json-ld/
[2]: https://github.com/hawkular/hawkular-inventory/pull/55

wdyt?


More information about the hawkular-dev mailing list