Representational State Transfer (REST) and Activity Streams

Internet of Things: Foundations and Applications [./]
Spring 2015 — INFO 290 (CCN 41607)

Erik Wilde, Siemens Web of Things Research Group
2015-02-20

Creative Commons License [http://creativecommons.org/licenses/by/3.0/]

This work is licensed under a CC
Attribution 3.0 Unported License
[http://creativecommons.org/licenses/by/3.0/]

Contents Erik Wilde: Representational State Transfer (REST) and Activity Streams

Contents

Erik Wilde: Representational State Transfer (REST) and Activity Streams

(2) Abstract

The Web's architectural style, Representational State Transfer (REST), is one promising candidate for building open, extensible, and extensible ecosystems of services on the Web. In this picture, Web's fundamental role is that of a Service-Oriented Architecture (SOA), where resources can be accessed as a way to achieve application goals, but their implementation is of no concern to the users of the resources. Activity Streams (AS) are a developing standard that allows the sharing of activities across a variety of application domain. In this lecture the standard is discussed, and we look at specific applications of it in IoT/WoT scenarios.



Representational State Transfer (REST)

Outline (Representational State Transfer (REST))

  1. Representational State Transfer (REST) [7]
  2. Uniform Resource Identifier (URI) [4]
  3. Hypertext Transfer Protocol (HTTP) [13]
  4. Activity Streams Basics [2]
  5. Vocabularies for Activity Streams [7]
    1. Using Vocabularies [2]
    2. Defining Vocabularies [3]
Representational State Transfer (REST) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(4) Architectural Styles

Louvre Interior
  • Architecture: Louvre [http://en.wikipedia.org/wiki/Louvre]
  • Architectural Style: Baroque [http://en.wikipedia.org/wiki/Baroque_architecture]
Villa Savoye Interior
  • Architecture: Villa Savoye [http://en.wikipedia.org/wiki/Villa_Savoye]
  • Architectural Style: International Style [http://en.wikipedia.org/wiki/International_Style_(architecture)]


Representational State Transfer (REST) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(5) The REST Architectural Style

  1. Resource Identification [Resource Identification (1)]
  2. Uniform Interface [Uniform Interface (1)]
  3. Self-Describing Messages [Self-Describing Messages (1)]
  4. Hypermedia Driving Application State [Hypermedia Driving Application State (1)]
  5. Stateless Interactions [Stateless Interactions (1)]


Representational State Transfer (REST) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(6) Resource Identification



Representational State Transfer (REST) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(7) Uniform Interface



Representational State Transfer (REST) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(8) Self-Describing Messages



Representational State Transfer (REST) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(9) Hypermedia Driving Application State



Representational State Transfer (REST) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(10) Stateless Interactions



Uniform Resource Identifier (URI)

Outline (Uniform Resource Identifier (URI))

  1. Representational State Transfer (REST) [7]
  2. Uniform Resource Identifier (URI) [4]
  3. Hypertext Transfer Protocol (HTTP) [13]
  4. Activity Streams Basics [2]
  5. Vocabularies for Activity Streams [7]
    1. Using Vocabularies [2]
    2. Defining Vocabularies [3]
Uniform Resource Identifier (URI) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(12) Resource Identification

Global naming leads to global network effects... the value of an identifier increases the more it is used consistently

Architecture of the World Wide Web, Volume One [http://www.w3.org/TR/webarch/]



Uniform Resource Identifier (URI) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(13) URIs & Resources



Uniform Resource Identifier (URI) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(14) URI Schemes

URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
http://dret.net/lectures/iot-spring15/rest#uri-schemes


Uniform Resource Identifier (URI) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(15) Resources & Representations



Hypertext Transfer Protocol (HTTP)

Outline (Hypertext Transfer Protocol (HTTP))

  1. Representational State Transfer (REST) [7]
  2. Uniform Resource Identifier (URI) [4]
  3. Hypertext Transfer Protocol (HTTP) [13]
  4. Activity Streams Basics [2]
  5. Vocabularies for Activity Streams [7]
    1. Using Vocabularies [2]
    2. Defining Vocabularies [3]
Hypertext Transfer Protocol (HTTP) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(17) DNS & HTTP

The two basic protocols which every Web browser must implement are DNS [Internet and Web Layering; Domain Name System (DNS) (1)] access and HTTP [Hypertext Transfer Protocol (HTTP) (1)]. However, most operating systems provide an API for DNS access, so the browser can use this service locally and only has to implement HTTP. TCP [Internet and Web Layering; Transmission Control Protocol (TCP) (1)] support (which is required as the foundation for HTTP) is usually provided by the operating system.

browser-dns-http.png

Hypertext Transfer Protocol (HTTP) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(18) HTTP Messages

start-line
message-header *

message-body ?


Hypertext Transfer Protocol (HTTP) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(19) HTTP Header Fields



Hypertext Transfer Protocol (HTTP) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(20) HTTP Requests

Method Request-URI HTTP/Major.Minor
[Header]*

[Entity]?


Hypertext Transfer Protocol (HTTP) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(21) HTTP GET

GET / HTTP/1.1
Host: ischool.berkeley.edu


Hypertext Transfer Protocol (HTTP) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(22) HTTP Responses

HTTP/Major.Minor Status-Code Text
[Header]*

[Entity]?


Hypertext Transfer Protocol (HTTP) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(23) HTTP Performance



Hypertext Transfer Protocol (HTTP) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(24) HTTP Connection Handling

http-phttp-pipelining.png

Hypertext Transfer Protocol (HTTP) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(25) HTTP Access Control



Hypertext Transfer Protocol (HTTP) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(26) HTTP Authentication

HTTP Authentication

Hypertext Transfer Protocol (HTTP) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(27) Basic HTTP Authentication



Hypertext Transfer Protocol (HTTP) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(28) Repeated Access



Hypertext Transfer Protocol (HTTP) Erik Wilde: Representational State Transfer (REST) and Activity Streams

(29) Login Page



Activity Streams Basics

Outline (Activity Streams Basics)

  1. Representational State Transfer (REST) [7]
  2. Uniform Resource Identifier (URI) [4]
  3. Hypertext Transfer Protocol (HTTP) [13]
  4. Activity Streams Basics [2]
  5. Vocabularies for Activity Streams [7]
    1. Using Vocabularies [2]
    2. Defining Vocabularies [3]
Activity Streams Basics Erik Wilde: Representational State Transfer (REST) and Activity Streams

(31) Activity Streams 1.0



Activity Streams Basics Erik Wilde: Representational State Transfer (REST) and Activity Streams

(32) Activity Streams 2.0



Vocabularies for Activity Streams

Outline (Vocabularies for Activity Streams)

  1. Representational State Transfer (REST) [7]
  2. Uniform Resource Identifier (URI) [4]
  3. Hypertext Transfer Protocol (HTTP) [13]
  4. Activity Streams Basics [2]
  5. Vocabularies for Activity Streams [7]
    1. Using Vocabularies [2]
    2. Defining Vocabularies [3]
Vocabularies for Activity Streams Erik Wilde: Representational State Transfer (REST) and Activity Streams

(34) AS needs Vocabularies



Vocabularies for Activity Streams Erik Wilde: Representational State Transfer (REST) and Activity Streams

(35) Use, Extend, or Define?

  1. Using a well-known verb in the way how it has been defined
    • Erik just added something to an existing resource.
  2. Extending a well-known verb in ways that make sense for those knowing the extension
    • For those who know and care, here is additional info about the camera.
  3. Defining new verbs which do not mean anything for those not knowing them
    • Erik just edited the picture he added earlier.


Using Vocabularies

Using Vocabularies Erik Wilde: Representational State Transfer (REST) and Activity Streams

(37) Finding Vocabularies

snowflakes.jpg
  • There is no centralized registry of AS vocabularies
    • The AS1 core specification only defines the one verb post
    • The AS1 base schema [https://github.com/activitystreams/activity-schema/blob/master/activity-schema.md] defines a set of well-known verbs
    • AS1 activities may use verbs other than the well-know ones
    • Extensions [http://activitystrea.ms/specs/json/1.0/#extensions] can use strings or URIs as verbs (the difference is unclear)
  • Everybody is free to define their own snowflakes
    • Network effect gains depend on agreement on the level of shared understanding
    • Only invent something if you absolutely have to


Using Vocabularies Erik Wilde: Representational State Transfer (REST) and Activity Streams

(38) Adapting Vocabularies

  • Consider this when designing the activities for your course project!
  • Reuse an existing activity type (they are loosely defined)
  • Add facets to it that you need to satisfy your use case
  • Adapting without hijacking is the litmus test of proper reuse
    • If somebody does not support your extensions, does it still make sense?
    • If this test cannot be satisfied, it is better to invent something new


Defining Vocabularies

Defining Vocabularies Erik Wilde: Representational State Transfer (REST) and Activity Streams

(40) Quantified Self and Health

  • Using data from wearables to support personal well-being and health
    • Producers: Wearables (e.g., activity trackers), general-purpose devices (e.g., activity-enabled smartphones), lab visits
    • Transformers: Consuming available data and distilling reports
    • Consumers: Users, health coaches, doctors (different granularity of consumption)
  • Data production should be independent of specific devices
    • Exercise Data Format (EDF) [https://github.com/dret/exercise/tree/master/EDF] as a very simple standard for exercise data
    • The resources are linked from activities and use a different media type


Defining Vocabularies Erik Wilde: Representational State Transfer (REST) and Activity Streams

(41) Hey, I Just Exercised

  • The current design exposes exercising as an activity
    • It would also be possible to model it as adding something to an exercise log
    • Modeling always has many ways how the same information can be represented
  • Specific exercise types (e.g., running) are not part of the verb
    • Trade-off between generality and specificity
    • The exercise type is represented as additional data in the AS object


Defining Vocabularies Erik Wilde: Representational State Transfer (REST) and Activity Streams

(42) Do You Know What HIIT Is?

  • Exercise types are considered relevant but not central
    • Nike Fuel [https://github.com/dret/exercise/blob/master/types/API/nikefuel.md] thinks HIIT is a thing
    • Even Wikipedia thinks it is a thing [http://en.wikipedia.org/wiki/High-intensity_interval_training]
  • It is possible to transform proprietary into unified types
    • There is a long list of (currently 435) exercise types [https://github.com/dret/exercise/tree/master/types]
    • Consumers are mostly not interested which device/service created the exercise data
    • A transformer consumes the proprietary types and transforms them into unified types
  • A typical pattern of open and extensible system
    • Define a minimal but useful model for representing what the system is all about
    • Make this model extensible and open so that it can evolve without breaking existing components


2015-02-20 Internet of Things: Foundations and Applications [./]
Spring 2015 — INFO 290 (CCN 41607)