26
Adding Rules on Existing Hypermedia APIs Michael Petychakis, Fenareti Lampathaki, Dimitrios Askounis National Technical University of Athens WS-REST, 18 th May 2015, Florence Italy

Adding Rules on Existing Hypermedia APIs

Embed Size (px)

Citation preview

Page 1: Adding Rules on Existing Hypermedia APIs

Adding Rules on Existing Hypermedia APIsMichael Petychakis, Fenareti Lampathaki, Dimitrios AskounisNational Technical University of AthensWS-REST, 18th May 2015, Florence Italy

Page 2: Adding Rules on Existing Hypermedia APIs

Who I am

Michael PetychakisResearcher in DSS lab, National Technical University of Athens (NTUA)PhD Candidate in NTUAElectrical and Computer Engineer, Dipl.-M.Eng., NTUA

Research InterestsAPIs/Linked Data/Web 3.0

@mpetyx

Page 3: Adding Rules on Existing Hypermedia APIs

Web, APIs, IoT and .. Hypermedia

Page 4: Adding Rules on Existing Hypermedia APIs

REST (as was supposed to be)

Level 3: Hypermedia

Level 2: HTTP Verbs

Level 1: Resources

Level 0: POX

Page 5: Adding Rules on Existing Hypermedia APIs

REST (today)

Level 3: Hypermedia

Level 2: HTTP Verbs

Level 1: Resources

Level 0: POX

Page 6: Adding Rules on Existing Hypermedia APIs

Hypermedia as FSM

"hydra:member" : [ { "@type": "schema:Basket", "schema:contains": [ { "@id": "/books/1", "@type": "schema:Book", "schema:author": "James Joyce", "schema:title": "Ulysses" },

Page 7: Adding Rules on Existing Hypermedia APIs

Rules are Good for FSM

If Thisthen That

If

Basket_Contains( ?Book ) loggen_in_validated_user( ?Michael ) paypal_account_integrated( ?Michael )

Then

Checkout( ?Michael, ?Book )

Page 8: Adding Rules on Existing Hypermedia APIs

Rules on the Web

dc:description

Rules

SWRL

RulemlRIF

Rule Inference

Producing valid statements within rule based system

Page 9: Adding Rules on Existing Hypermedia APIs

Rules are there for a Loong Time

Not Web Web

prolog

datalog

Drools

Clips

SWRL

Ruleml

RIF

Page 10: Adding Rules on Existing Hypermedia APIs

Blending Rules and APIs

Hydra/JSON_LD

SWRL

DeepGraphs

Page 11: Adding Rules on Existing Hypermedia APIs

DeepGraphs Approach

Goal: Modelling Hypermedia Responses

1 Vocabulary Hydra Documents SWRL Rules JSON-LD Responses

1 Vocabulary

Page 12: Adding Rules on Existing Hypermedia APIs

Vocabulary

• Affordances

• Duration(maxAllowedDuration)• According to latest updates on Http 1.1• Parallel Processes• Synchronizing multiple FSM Clients• Constraints• The Actual Rules

Schema:activity Hydra:Resource dg:affordances

Page 13: Adding Rules on Existing Hypermedia APIs

Similar Approaches/ Media Types

DeepGraphs

Mason

Uber

JSON-LD

JSON API

Siren

HAL

Collection JSON

JSON Schema

JSON Hyper

Schema

XML Schema

Page 14: Adding Rules on Existing Hypermedia APIs

Example: Bookstore

"dg:affordances": [ { "@type": ["schema:Action","hydra:Operation"], "@id": "/RemoveBook", "hydra:method": "DELETE", "hydra:expects": "schema:Book", "hydra:title": "Deletes a Book resource.", "hydra:returns": "owl:Nothing", "rdfs:label": "Deletes the Book resource." },

Page 15: Adding Rules on Existing Hypermedia APIs

Example in Diagrams

Page 16: Adding Rules on Existing Hypermedia APIs

Complexity grows Exponentially

ClientsBookstorePaypalSmsAgentEmailFacebookTwitter

ServersBookstorePaypalSms - EmailFacebookTwitter

Page 17: Adding Rules on Existing Hypermedia APIs

Complexity grows Exponentially

ClientsBookstorePaypalSmsAgentEmailFacebookTwitter

ServersBookstorePaypalSms - EmailFacebookTwitter

Can We Avoid Building one Client per Server and Vice Versa?

Page 18: Adding Rules on Existing Hypermedia APIs

DeepGraphs Generic Server Implementations

• Developer Designs the FSM• A designer’s console for: Designing the API Atlas Verification of API FSM Validation (Running Example Workflows) Adding Integrity Constraints

Defining the Business Logic through Rules

Page 19: Adding Rules on Existing Hypermedia APIs

API Designer

http://api-builder.tools.epu.ntua.gr/web/

Page 20: Adding Rules on Existing Hypermedia APIs

DeepGraphs Generic AI ClientsSW

Interoperabilty

Reasoning

REST

Multiple Servers

Multiple Transactions

Page 21: Adding Rules on Existing Hypermedia APIs

In APIs We Trust

Page 22: Adding Rules on Existing Hypermedia APIs

Tools Around Spec

● API Builder● PyAPI

o from [Swagger, API Blueprints, Hydra, WADL, RAML] to [Swagger, API Blueprints, Hydra, RAML]

● PyRIFo from [RuleML, RIF, SWRL] to [RuleML, RIF, SWRL]

● DeepGraphs Parser ( Soon )● DeepGraphs Reasoner ( Soon )

o Datalog Approacho FSM resolver implemented nowo Fluent Editor has been used for Evaluation

Page 23: Adding Rules on Existing Hypermedia APIs

Dereferencable Rules on the Web

SWRL and Rif Solution:

Declare 1 Rule within a Graph, and Reference this. Status: Working, But..

dg:constrainthttp://deepgraphs.org/repository/rule1

Page 24: Adding Rules on Existing Hypermedia APIs

Advances of the Methodology

• DeepGraphs is not only RESTXMPPMQTTCoAP, DDS, AMQP (and more!)

• DeepGraphs aims into reusing Existing APIs that speak Swagger, RAML, etc

• DeepGraphs aims to facilitate:• Distributed Reasoning over the web with Affordances

Page 25: Adding Rules on Existing Hypermedia APIs

Next Steps

1. First Release of the Specification on June 2. Create a public Community Group3. DeepGraphs Tools• Parser• Client• Reasoner• Designer4. More Events5. Address Rule Dereferencability by open discussion

Page 26: Adding Rules on Existing Hypermedia APIs

Thank you

Michael Petychakis

<a href="mailto:[email protected]?Subject=Hello" target="_top">Drop me an e-mail</a>

@mpetyx

This work has been created in the context of the EU-fundedproject OPENi (Open-Source, Web-Based, Framework forIntegrating Applications with Social Media Services and PersonalCloudlets), Contract No: FP7-ICT-317883.