More Related Content Similar to Importance of APIs in the Internet of Things (20) More from Nordic APIs (20) Importance of APIs in the Internet of Things1. Importance of APIs in the Internet of Things
From Network APIs to the next big thing
Jacob Ideskog, Solution Architect
@jacobideskog
Copyright © 2013 Twobo Technologies AB. All rights reserved
2. Agenda
History – this has happened before…
The network industry
REST
Devices – services or APIs?
Copyright © 2013 Twobo Technologies AB. All rights reserved.
4. The Web, networking and the Internet of things
Copyright © 2013 Twobo Technologies AB
Free
Web APIs
The
Networking
Industry
Device APIs
rpc/rmi
5. The Networking Idustry
From SNMP to NETCONF
Copyright © 2013 Twobo Technologies AB
Free
Web APIs
The
Networking
Industry
Device APIs
rpc/rmi
6. Virtualization - a game changer
Moving a server from U.S.A. to India
With maintained state
What happened to the network?
Copyright © 2012 - 2013 Twobo Technologies AB
7. Virtualization
Not a new problem
Just a new focus
Solutions popped up
Copyright © 2012 - 2013 Twobo Technologies AB
vSwitch
OpenFlow
JSON REST
8. History again
Let’s take one step back further
The networking industry had this talk 10 year ago
RFC 3535
Content:
How does the industry Automate network
management?
SNMP has failed
• CLI scripting
• Proprietary drivers
• Error handling
Copyright © 2012 - 2013 Twobo Technologies AB
RFC 3535
RFC 3535
9. History again
The outcome of RFC 3535
NETCONF – RFC 6241
Two types of data with clear separation
• Operational Data
• Configurational Data
Transactions
• Implied
Validation of input data
• Ability to compare, even between devices
Ease of use
Backup / Restore
Copyright © 2013 Twobo Technologies AB. All rights reserved
10. NETCONF
Configuration
Pre-provisioning
Operational Data
RPCs / Actions
All modelled in YANG (rfc6020)
Copyright © 2013 Twobo Technologies AB. All rights reserved
Configuration
Operational state
Action
(eg. reboot)
{ interfaces interface eth0 ip 10.0.0.1 }
{ interfaces interface eth0 rx_faults }
11. Web APIs
I.e. RESTful APIs
Copyright © 2013 Twobo Technologies AB. All rights reserved
Free
Web APIs
The
Networking
Industry
Device APIs
rpc/rmi
12. Web APIs
Today:
The most commonly used API architecture is REST
REST:
No uniform standard
NOT A PROTOCOL
Copyright © 2013 Twobo Technologies AB. All rights reserved
13. Resource or service
Copyright © 2013 Twobo Technologies AB. All rights reserved http://martinfowler.com/articles/richardsonMaturityModel.html
Level 0: The Swamp of POX
Level 1: Resource
Level 2: HTTP Verbs
Level 3: Hypermedia Controls
Glory of Rest
14. Level 0 Swamp of POX
Copyright © 2013 Twobo Technologies AB. All rights reserved
Copyright © 2013 Twobo Technologies AB. All
rights reserved
POST <getBook>
POST <deleteUser>
<book ...
<ok ...
/api
XML RPC all over again
15. Level 1 Resources
URIs
But still XML messages as operations
Copyright © 2013 Twobo Technologies AB. All
rights reserved
POST <getBook>
POST <deleteUser>
<book ...
<ok ...
/books/2
/users/24
16. Level 2 HTTP Verbs
Utilizes the semantics of HTTP
Copyright © 2013 Twobo Technologies AB. All rights reserved
GET - Read a resource
HEAD – Read metadata about resource
OPTIONS – Read what operations are available
POST – Add a new resource, or run operation
PUT – Replace existing resource completely
DELETE – Remove resource
(PATCH – Update existing resource in place)
GET ?pagesize=A4
DELETE
200 OK <book ...
201 No Content
/books/2
/users/32
17. Level 3 The Glory of REST
HATEOAS
Hypermedia As The Engine Of Application State
Or simply: Hypermedia
Let the Media Type tell you what to do
Hyperlink, hyperlink hyperlink
Copyright © 2013 Twobo Technologies AB. All rights reserved
18. Example
Copyright © 2013 Twobo Technologies AB. All rights reserved
curl –v http://localhost/stuff
<stuff xmlns:tt=http://example.com/rest tt:rel=”/stuff">
<more-stuff tt:rel="/stuff/more-stuff"/>
<other-stuff tt:=”/stuff/other-stuff"/>
<data>
<entry>Interesting 1</entry>
<entry>Interesting 2</entry>
</stuff>
curl –v http://localhost/stuff/more-stuff
<more-stuff xmlns:tt=http://example.com/rest tt:rel=”/stuff/more-stuff">
<things tt:rel="/stuff/more-stuff/things"/>
</more-stuff>
19. Ring a bell?
Copyright © 2013 Twobo Technologies AB. All rights reserved
curl –v http://localhost/v2/stuff
<html>
<div id=“stuff”>
<a href=“/stuff/more-stuff”/>
<a href=“/stuff/other-stuff/>
<ol id=“data”>
<li id=“entry1”>Interesting 1</li>
<li id=“entry2”>Interesting 2</li>
</ol>
<form action=“/stuff” >
<input type=“text” name=“value” />
</form>
</div>
</html>
20. Device APIs
But a device isn’t an APP
What you are designing isn’t a user interface
A system can contain Thousands / Millions / Billons of devices
The device may be placed in odd locations
Must be replaceable
Copyright © 2013 Twobo Technologies AB. All rights reserved
21. Device APIs
Letting your device
BECOME an API
Copyright © 2013 Twobo Technologies AB. All rights reserved
Free
Web APIs
The
Networking
Industry
Device APIs
rpc/rmi
22. Services
High level abstractions
Not directly map able to a single device
Copyright © 2013 Twobo Technologies AB. All rights reserved
SERVICE
Fuel optimization
SERVICE
Health assistance
SERVICE
Plant watering
system
CAR GPS
Stop lights
Turbo injector
Thermometer
Calendar
Medicine dosage
Weather services
Garden sensors
Water tap
24. Example: Networks
Network wide transactions
All or nothing
Setup VPN
All participating Routers
must be updated
ACID
Copyright © 2013 Twobo Technologies AB. All rights reserved
Tail-f:
NCS
Cisco Juniper ALU Compass
Customer orders new
VPN in Web Portal
Controller calculates changes
and updates relevant devices
If one device fails to update config
all of them roll back
25. An API for Things
Requirements:
1. Must be consumed by machines
2. Replaceable
Dump all settings
Restore in other device
3. Robust
Copyright © 2013 Twobo Technologies AB. All rights reserved
26. An API for Things
Requirements:
1. Must be consumed by machines
Copyright © 2013 Twobo Technologies AB. All rights reserved
Resource based
Level 2,5
Clear separation
of Configurational
and Operational
data
What you need is a DataModel => Think of it like a Site Map with meta-data about each sub-page
27. An API for Things
Copyright © 2013 Twobo Technologies AB. All rights reserved
Requirements:
2. Replaceable
Dump all settings
Restore in other device
Defined by data-model
No side-effects of
configuration in other
configuration
28. An API for Things
Copyright © 2013 Twobo Technologies AB. All rights reserved
Requirements:
3. Robust
All or nothing
No unexpected states
Transactions
Cannot rely on
ordering of incoming
data
29. An API for Things
Make sure your device can participate in the
services that will be the Internet of Things!
Copyright © 2013 Twobo Technologies AB. All rights reserved
30. Summary
The game-changers
Learning for Networking (NETCONF)
REST but not necessarily Hypermedia
Devices are volatile!
Copyright © 2013 Twobo Technologies AB. All rights reserved