Hypermedia Design for Machine APIs Web Scale Architecture for the Web of Things Michael J Koster 14 September 2015.

Slides:



Advertisements
Similar presentations
Pierre-Johan CHARTRE Java EE - JAX-RS - Pierre-Johan CHARTRE
Advertisements

Dr. Leo Obrst MITRE Information Semantics Information Discovery & Understanding Command & Control Center February 6, 2014February 6, 2014February 6, 2014.
REST - Representational State Transfer
REST Introduction 吴海生 博克软件(杭州)有限公司.
REST (Representational State Transfer)
Web Service Testing RESTful Web Services Snejina Lazarova Dimo Mitev
OASIS OData Technical Committee. AGENDA Introduction OASIS OData Technical Committee OData Overview Work of the Technical Committee Q&A.
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Web Service Ahmed Gamal Ahmed Nile University Bioinformatics Group
Semantic Web Introduction
Query Verb Proposal Ashok Malhotra, Oracle
LBSC 670 Information Organization. Today The web and automated information services Data, Ontologies and Web-services Protégé work time.
Web Ontology Language for Service (OWL-S). Introduction OWL-S –OWL-based Web service ontology –a core set of markup language constructs for describing.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 3-1 of…
World Wide Web1 Applications World Wide Web. 2 Introduction What is hypertext model? Use of hypertext in World Wide Web (WWW) – HTML. WWW client-server.
WebRatio BPM: a Tool for Design and Deployment of Business Processes on the Web Stefano Butti, Marco Brambilla, Piero Fraternali Web Models Srl, Italy.
Peoplesoft: Building and Consuming Web Services
Web Services Michael Smith Alex Feldman. What is a Web Service? A Web service is a message-oriented software system designed to support inter-operable.
On a Device Information Model for devices in oneM2M
Processing of structured documents Spring 2003, Part 6 Helena Ahonen-Myka.
Service-Oriented Programming
Windows.Net Programming Series Preview. Course Schedule CourseDate Microsoft.Net Fundamentals 01/13/2014 Microsoft Windows/Web Fundamentals 01/20/2014.
Breakout session ESIP Summer Meeting, Chapel Hill, North Carolina Stephen M Richard, organizer.
Aurora: A Conceptual Model for Web-content Adaptation to Support the Universal Accessibility of Web-based Services Anita W. Huang, Neel Sundaresan Presented.
INFORMATION TECHNOLOGY IN BUSINESS AND SOCIETY SESSION 7 – THE WEB SEAN J. TAYLOR.
The Semantic Web Web Science Systems Development Spring 2015.
PUBLISHING ONLINE Chapter 2. Overview Blogs and wikis are two Web 2.0 tools that allow users to publish content online Blogs function as online journals.
Lecture 9: Chapter 9 Architectural Design
Open Data Protocol * Han Wang 11/30/2012 *
Model-Driven Analysis Frameworks for Embedded Systems George Edwards USC Center for Systems and Software Engineering
Nadir Saghar, Tony Pan, Ashish Sharma REST for Data Services.
2007cs Servers on the Web. The World-Wide Web 2007 cs CSS JS HTML Server Browser JS CSS HTML Transfer of resources using HTTP.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
 Structured Data An Introduction to Semantic Web “It is very hard for search engines to understand the structure and semantics of data embedded in an.
Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
RESTful Web Services What is RESTful?
REST By: Vishwanath Vineet.
Web Technologies Lecture 10 Web services. From W3C – A software system designed to support interoperable machine-to-machine interaction over a network.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Chapter 13 설계 개념 Architectural Design 임현승 강원대학교 Revised from the slides by Roger S. Pressman and Bruce R. Maxim for the book “Software Engineering: A Practitioner’s.
Lecture VI: SOAP-based Web Service CS 4593 Cloud-Oriented Big Data and Software Engineering.
RDFa Primer Bridging the Human and Data webs Presented by: Didit ( )
WebApi: What is it? How can I use it? Guy In Front of the Whittaker.
© 2010 IBM Corporation RESTFul Service Modelling in Rational Software Architect April, 2011.
Live. learn. work. play Superior Avenue Suite 310 Cleveland Ohio Tel: Fax:
Representational State Transfer COMP6017 Topics on Web Services Dr Nicholas Gibbins –
REST API Design. Application API API = Application Programming Interface APIs expose functionality of an application or service that exists independently.
National College of Science & Information Technology.
Protocol Bindings Joint oneM2M Call, 31 Aug 2016.
OCF Data Model Michael J Koster.
Overview Blogs and wikis are two Web 2.0 tools that allow users to publish content online Blogs function as online journals Wikis are collections of searchable,
IoT Integration Patterns, REST, and CoAP
Better RESTFul API – Best Practices
Java Beans Sagun Dhakhwa.
Web Ontology Language for Service (OWL-S)
Representational State Transfer
CHAPTER 2 CREATING AN ARCHITECTURAL DESIGN.
Model-Driven Analysis Frameworks for Embedded Systems
Building Self Describing Web APIs
LOD reference architecture
Web Development Using ASP .NET
WebDAV Design Overview
Web API with Angular 2 Front End
WEB SERVICES From Chapter 19, Distributed Systems
W3C WoT Standardization
Chengyu Sun California State University, Los Angeles
REST API Design Borrowed heavily from:
SDMX IT Tools SDMX Registry
Presentation transcript:

Hypermedia Design for Machine APIs Web Scale Architecture for the Web of Things Michael J Koster 14 September 2015

Fielding 4.3 [Fielding2000] Hypothesis I: The design rationale behind the WWW architecture can be described by an architectural style consisting of the set of constraints applied to the elements within the Web architecture. Hypothesis II: Constraints can be added to the WWW architectural style to derive a new hybrid style that better reflects the desired properties of a modern Web architecture. Hypothesis III: Proposals to modify the Web architecture can be compared to the updated WWW architectural style and analyzed for conflicts prior to deployment.

What is REST? Exchange of state information between applications and resources Resource State is part of the application state State is exchanged through representations of the resource Application state is updated by application obtaining a current representation of the resource Resource state is updated by application transmitting a new representation of the resource Application Resource Representations of State Information

What is HATEOAS? Hypermedia As The Engine Of Application State Hypermedia is the descriptive metadata about how to exchange state information between applications and resources An application can read the hypermedia and automatically consume resources Such an interface is machine-understandable Hypermedia defines REST [Fielding 2008]

Hypermedia Controls for HTML Links and Forms embedded in the resource representations of web pages constitute a hypermedia interaction model for HTML Links describe how and where to obtain a resource state representation and how to use it to update application state Forms describe how and where to transmit a representation of the resource to update the resource state

How Links Work Applications update their state by consuming resources indicated by links and incorporating the resource state into the application state The semantics of a link are “{Current Context} has a {Relation Type} Resource at {Target URI} which has {Target Attributes}” Relation Type indicates how the Target Resource is related to the Current Context Target Attributes may include media type

Embedding Links There are outbound links, described above, and embedding links Embedding links enable the embedding of resources within the Current Context Examples are and tags in HTML Linked embedded resources are processed as part of the Current Context

How Forms Work Applications update the state of resources by submitting representations according to the meta data instructions provided by the form The semantics of a form are “To {Relation Type} {Current Context}, perform a {Request Description} to {Target URI} Relation Type indicates the desired action on the Current Context, e.g. Add an article to a blog A form can also be used with GET to create a typed outbound link according to a URL template

The Collection Pattern Very common design pattern [WEBAPIS] Good example of the use of HATEOAS Collection is a resource that contains links to resources, which are items in the collection Application uses links to list items and obtain links to resources in the collection Application uses forms to add items to, or remove items from the collection Adding an item to the collection adds a link to a resource to the collection Removing an item from the collection removes the link to the resource from the collection

Hypermedia Languages HTML – Links and Forms embedded in web pages Microdata – Schema.org; RDFa metadata embedded in web pages CoRE Link Format (RFC 6690) JSON-LD – WoT Thing Description Language (Many others) How is the hypermedia control exposed in the API? How does it drive application state?

Thing Description Language What are Events, Actions, and Properties? – Elements of the WoT Interaction Model – Resource Classes with hypermedia controls Re-use the semantics of HTML Links and Forms but for machine interactions HATEOAS for machine APIs

Hypermedia Controls for Machine APIs Some common attributes and semantic features could be useful for machine APIs Describe media types in Actions and Events Add parameters to Actions and Events Describe Data Types and Data Templates Provide for additional methods, PUT, PATCH Provide a way to process response codes and response metadata from the resource

HATEOAS Design for the WoT Interaction Model Resource Class Hypermedia Controls Actions-Form-like constructs use POST to execute actions based on parameters mapped to resources -POST creates a new Action resource and schedules the action for execution -Action resources are used to track and control ongoing execution of actions Events-Form-like constructs use POST to create and subscribe to Events -Events use the Subscription Resource pattern -Events and Subscriptions are managed in collections Properties-Links and attributes provide a simple hypermedia control for getting and setting property values using GET and PUT -Properties may be of any media type

Lighting Domain Example Professional lighting controls based on a popular control model Actions for on-off control, dimming, and color control for various colorspaces are encapsulated in optional capability modules Various control modes are optionally supported: Change, Step, Move, Toggle Control abstractions allow for controllable timed and smooth transitions between resource states

Control Model for Lighting light onOff level color change toggle newState: {enum:off,on} HS XY temperature change step move targetValue:{units:%} transitionTime rate:{units:%/s} stepSize stop transitionTime:{units:s} change step move targetValue:{units:K, range: } transitionTime rate:{units:K/s} stepSize transitionTime:{units:s} stop light.onOff.change {newState:on} light.color.temperature.change {targetValue:3400, transitionTime:10} light.level.change {targetValue:45, transitionTime:10} thing actuatorsactions parameters application actions {parameters} (colorspace)

Example Hypertext Links to Properties hypertext links at resource context = /light [{ “rel”: “property”, “href”: “ColorTemp/currentValue”, “type”: “observable”, “name”: “ColorTemperature” },{ “rel”: “property”, “href”: “ColorTemp/remTime”, “type”: “observable”, “name”: “TransitionTimeRemaining” }] /light has observable property resources: “ColorTemperature” at the URI /light/ColorTemp/currentValue “TransitionTimeRemaining” at the URI /light/ColorTemp/remTime

Hypertext Link to Actuator hypertext link at resource context = /light { “rel”: “action”, “href”: “ColorTemp”, “type”: “actuator”, “name”: “ColorTemperature” } “/light has an actuator type action resource named ColorTemperature at the URI /light/ColorTemp”

Hypertext Form for Change Action hypertext form at resource context = /light/ColorTemp: { “rel”: “action”, “type”: “action”, “name”: “Change”, “method”: “POST”, “href”: “Actions” “content-format”: “application/tdlactions+json”, “parameters”:[ {“name”: “targetValue”, “dataType”: “float”}, {“name”: “transitionTime”, “dataType”:”float”, “units”: “s”}] “template”: “{ “changeTemp”: “$targetValue”, “transTime”: “$transitionTime” }”, “returns”: [{“responseCode”: “201”, “responseAction”: “success” “parameters”: [{“type”: “header”, “name”: “Location”, “type”: “href” “rel”: “actionInstance” }], ]} To Change the ColorTemperature of /light, POST a template containing targetValue and transition Time parameters to the resource at /light/ColorTemp/Actions. Expect a responseCode of 201 if success and expect to find an actionInstance resource pointed to by the header parameter named “Location”.

Hypertext Form for Step Action hypertext form at resource context = /light/ColorTemp: { “rel”: “action”, “type”: “action”, “name”: “Step”, “method”: “POST”, “href”: “Actions” “content-format”: “application/tdlactions+json”, “parameters”:[ {“name”: “stepSize”, “dataType”: “float”}, {“name”: “transitionTime”, “dataType”:”float”, “units”: “s”}] “template”: “{ “stepSize”: “$stepSize”, “transTime”: “$transitionTime” }”, “returns”: [{“responseCode”: “201”, “responseAction”: “success” “parameters”: [{“type”: “header”, “name”: “Location”, “type”: “href” “rel”: “actionInstance” }], ]} To Step the ColorTemperature of /light, POST a template containing stepSize and transition Time parameters to the resource at /light/ColorTemp/Actions. Expect a responseCode of 201 if success and expect to find an actionInstance resource pointed to by the header parameter named “Location”.

Hypertext Form for Move Action hypertext form at resource context = /light/ColorTemp: { “rel”: “action”, “type”: “action”, “name”: “Move”, “method”: “POST”, “href”: “Actions” “content-format”: “application/tdlactions+json”, “parameters”:[ {“name”: “moveRate”, “dataType”: “float”, “units”: “K/s”}] “template”: “{“rate”: “$moveRate”}”, “returns”: [{“responseCode”: “201”, “responseAction”: “success” “parameters”: [{“type”: “header”, “name”: “Location”, “type”: “href” “rel”: “actionInstance” }], ]} To Move the ColorTemperature of /light, POST a template containing the moveRate parameter to the resource at /light/ColorTemp/Actions. Expect a responseCode of 201 if success and expect to find an actionInstance resource pointed to by the header parameter named “Location”.

Can be discovered by the application as the result of a gradual reveal process guided by an ontology, e.g. ColorTemperature control with ChangeValue control semantics The name can be rendered to the application based on discovered names populated from well known namespaces e.g. Schema.org Actions can be invoked by reusable handlers for well known data and control models Example serialization of an action and invocation using discovered names with values supplied from a scene controller: action= my_light.ColorTemperature.Change(targetValue=2900, TransitionTime=10) The hypermedia control generates this transaction: POST uri=/light/ColorTemp/Actions pl={“changeTemp”: “2900”, “transTime”: “10”} A success response contains the URI of the Action resource in the location header: 201 Created Location: ac3f5774 Execution of the action can be controlled through the Action resource: action.cancel() DELETE uri=/light/ColorTemp/Actions/ac3f5774 Application Interface Mapping

Hypertext Link – CoAP + IPSO Binding hypertext link at resource context = /light { “rel”: “action”, “href”: “3004/0”, “type”: “actuator”, “name”: “ColorTemperature” } “/light has an action resource at the URI /light/3004/0 of type actuator named ColorTemperature”

Hypertext Form – CoAP + IPSO Binding hypertext form for CoAP binding, resource context = /light/3004/0: { “rel”: “action”, “type”: “action”, “name”: “Change”, “method”: “POST”, “href”: “5052” “content-format”: “application/ipso+senml+json”, “parameters”:[ {“name”: “targetValue”, “dataType”: “float”}, {“name”: “transitionTime”, “dataType”:”float”, “units”: “s”}] “template”: “[{“n”: “5059”, “v”: “$targetValue”} {“n”: “5002”, “v”: “$transitionTime”}]”, “returns”: [{“responseCode”: “2.01”, “responseAction”: “success” “parameters”: [{“type”: “header”, “name”: “Location”, “type”: “href” “rel”: “actionInstance” }], ]} To Change the ColorTemperature of /light, POST a template containing targetValue and transition Time parameters to the resource at /light/3004/0/5052. Expect a responseCode of 2.01 if success and expect to find an actionInstance resource pointed to by the header parameter named “Location”

Example serialization of an action and invocation using discovered names with values supplied from a scene controller: action= my_light.ColorTemperature.Change(targetValue=2900, TransitionTime=10) The IPSO + CoAP hypermedia control generates this transaction: POST uri=/light/3004/0/5052 pl=[{“n”:“5059”,“v”:“2900”},{“n”:“5002”,“v”:“10”}] A success response contains the URI of the Action resource in the location header : 2.01 Created Location: 17 Execution of the action can be controlled through the Action resource: action.cancel() DELETE uri=/light/3004/0/5052/17 Uniform Application Interface, Hypermedia Controls for IPSO + CoAP

References [Fielding2000] [Fielding2008] must-be-hypertext-drivenhttp://roy.gbiv.com/untangled/2008/rest-apis- must-be-hypertext-driven [WEBAPIS] Richardson, L. and M. Amundsen, "RESTful Web APIs”, O'Reilly, September 2013.