Overview of HATEOAS Approaches
W3C WoT IG / IRTF T2TRG Joint Meeting, Nice, France, 2016 Matthias Kovatsch (kovatsch@inf.ethz.ch)
1
Overview of HATEOAS Approaches W3C WoT IG / IRTF T2TRG Joint - - PowerPoint PPT Presentation
Overview of HATEOAS Approaches W3C WoT IG / IRTF T2TRG Joint Meeting, Nice, France, 2016 Matthias Kovatsch (kovatsch@inf.ethz.ch) 1 Web Mashups through Open APIs Internal microservice APIs 2 Often Break 3 Human Web Interaction 4
W3C WoT IG / IRTF T2TRG Joint Meeting, Nice, France, 2016 Matthias Kovatsch (kovatsch@inf.ethz.ch)
1
2
Internal microservice APIs
3
4
Thing B Thing A Follow links
Client
Auth-Server Dynamically extend process flow Resource Directory Entry URI Submit forms Action Result
5
Thing C Thing D Choice & redundancy
6
7
8
Still control old things Also control future things
Control alternative things
Add new things
Individual drafts by Klaus Hartke hartke@tzi.org
9
https://tools.ietf.org/html/draft-hartke-core-apps-02
10
11
12
Lightbulb
Client
Bulletin Board
application/bulletin-board+json
Controller
application/thing-description+json
Config Lighting State
application/lighting-config+json application/lighting+json
Power Consumption
13
Bulletin Board Lightbulb Controller
Discovery as client and submit form
14
Client
Bulletin Board Bulletin Board Bulletin Board Bulletin Board Bulletin Board Bulletin Board
15
Extensions by Matthias Kovatsch and Yassin Hassan kovatsch@inf.ethz.ch
16
17
{ "value": {"r":255, "g":0, "b":0}, "mode": "rgb", "_links": { "same-as": { "href": "/brightness", "type": "application/x.lighting-state+json" } }, "_forms": { "edit": { "method": "PUT", "href": "/light", "accepts": "application/x.lighting-state+json" } }, "_self":"/light" }
Application Data Links Forms
18
Client Resource Directory Thing A Auth-Server Thing B Thing C Follow links Submit forms Dynamically extend process flow Entry URI Action Result Thing C Choice & redundancy
19
20
21
Entry Point Light Resource State Resource ep = new HypermediaClient("coap://home.local"); // entry point light = ep.followLink("light"); // link relation type state = light.followLink("state"); // link relation type light state
22
Entry Point Light Resource State Resource ep = new HypermediaClient("coap://home.local"); light = ep.followLink("light"); state = light.followLink("state"); data = state.get(); light state
23
Entry Point Light Resource State Resource ep = new HypermediaClient("coap://home.local"); light = ep.followLink("light"); state = light.followLink("state"); data = state.get(); // Max-Age expires ... data = state.get(); light state
to recover from unavailable/replaced devices
24
Entry Point Light Resource State Resource // thing is replaced, address and resource path changes data = state.get(); light state
25
public class LightingStateFuture extends CoREHalResourceFuture<LightingState> { public void setRGB(int r, int g, int b) { LightingState lightingState = new LightingState(); lightingState.setValue(new RGBValue(r,g,b)); submitForm("edit", lightingState); } }
will be released publicly soon, announcement on T2TRG mailing list (https://www.irtf.org/mailman/listinfo/t2trg)
26
Approach by Michael Koster michael.koster@smartthings.com
27
28
CoAP HTTP MQTT WS CCML
(IP) Send/Rcv (PHY) Send/Rcv URI Topic, Payload (IP) Send/Rcv (PHY) (IP) Pub/Sub (PHY) (IP) Trx (PHY) URI URI REST REST Payload REST REST REST Need CCML/REST shim layer
(item composition; embed, link)
29
Link Item Link Item Link Link Link (self) (sub) Link Collection Link Item Link Link Link Item Link Item Sub Resource Collection Collection Link Link Collection Link
Base Schema Resource Model Application Logic Thing Object Model
(Deferred Interface)
30
Domain Schema Resources Hypermedia Controls Discovery Domain Model Hypermedia Client Resource Logic (Physical I/O) Networks Client Server Public Resource Tools
Base Schema Resource Model Application Logic Thing Object Model
(Deferred Interface)
31
Domain Schema Resources Hypermedia Controls Discovery Domain Model Hypermedia Client Resource Logic (Physical I/O) Server Client
Base Schema Resource Model Application Logic Thing Object Model
(Deferred Interface)
32
Domain Schema Resources Hypermedia Controls Discovery Domain Model Hypermedia Client Resource Logic (Physical I/O) Server Client
Base Schema Resource Model Application Logic Thing Object Model
(Deferred Interface)
33
Domain Schema Resources Hypermedia Controls Discovery Domain Model Hypermedia Client Resource Logic (Physical I/O)
34
Common Server Common Client Pluggable Protocols Application Logic Common CRUD Requests MQTT Common CRUD Responses Resource Model Resources Resource Model Thing Object Model HTTP CoAP Resource Logic WS “Scripting” “Scripting”
35