Adding Rules on Existing Hypermedia APIs

Post on 07-Aug-2015

213 views 6 download

Tags:

Transcript of 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

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

Web, APIs, IoT and .. Hypermedia

REST (as was supposed to be)

Level 3: Hypermedia

Level 2: HTTP Verbs

Level 1: Resources

Level 0: POX

REST (today)

Level 3: Hypermedia

Level 2: HTTP Verbs

Level 1: Resources

Level 0: POX

Hypermedia as FSM

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

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 )

Rules on the Web

dc:description

Rules

SWRL

RulemlRIF

Rule Inference

Producing valid statements within rule based system

Rules are there for a Loong Time

Not Web Web

prolog

datalog

Drools

Clips

SWRL

Ruleml

RIF

Blending Rules and APIs

Hydra/JSON_LD

SWRL

DeepGraphs

DeepGraphs Approach

Goal: Modelling Hypermedia Responses

1 Vocabulary Hydra Documents SWRL Rules JSON-LD Responses

1 Vocabulary

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

Similar Approaches/ Media Types

DeepGraphs

Mason

Uber

JSON-LD

JSON API

Siren

HAL

Collection JSON

JSON Schema

JSON Hyper

Schema

XML Schema

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." },

Example in Diagrams

Complexity grows Exponentially

ClientsBookstorePaypalSmsAgentEmailFacebookTwitter

ServersBookstorePaypalSms - EmailFacebookTwitter

Complexity grows Exponentially

ClientsBookstorePaypalSmsAgentEmailFacebookTwitter

ServersBookstorePaypalSms - EmailFacebookTwitter

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

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

API Designer

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

DeepGraphs Generic AI ClientsSW

Interoperabilty

Reasoning

REST

Multiple Servers

Multiple Transactions

In APIs We Trust

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

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

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

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

Thank you

Michael Petychakis

<a href="mailto:mpetyx@epu.ntua.gr?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.