OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

24
Universal Data Solvent or Clunky Enterprise Goo? Pat Patterson Developer Evangelist Architect, Salesforce @metadaddy

Transcript of OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

Page 1: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

Universal Data Solvent or Clunky Enterprise Goo?

Pat PattersonDeveloper Evangelist Architect,

Salesforce@metadaddy

Page 2: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

RESTful APIs are GREAT!

$ curl -H 'X-PrettyPrint:1' \-H 'Authorization: Bearer ACCESS_TOKEN' \https://na1.salesforce.com/services/data/v31.0/sobjects/Account/001E0000002Jv2eIAC{ "Id" : "001E0000002Jv2eIAC”, "Name" : "Edge Communications", "AccountNumber" : "CD451796", …}

Page 3: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

BUT…

• REST is a style, not a standard• RESTful, RESTlike, RESTish• URL parameters?– e.g. retrieve only a subset of properties

• Retrieve a set of records via a query?• Metadata– WADL?– RAML?– Swagger?

Page 4: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

Enter… OData

“OData is a standardized protocol for creating and consuming data APIs.

OData builds on core protocols like HTTP and commonly accepted methodologies like REST.

The result is a uniform way to expose full-featured data APIs.”

www.odata.org

Page 5: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

OData

• Proposed by Microsoft– 2009

• Standardized by OASIS– OData 4.0, 2014

Page 6: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

OData

• URIs for resource identity

http://services.odata.org/V4/OData/OData.svc/Products

?$filter=Rating+eq+3&$select=Rating,+Name

Page 7: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

7

OData System Query Options

• $search• $filter• $count• $orderby• $skip

• $top• $expand• $select• $format

Page 8: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

OData

• HTTP transport– GET, POST, PUT/PATCH/MERGE, DELETE

GET /V4/OData/OData.svc/Products(1) HTTP/1.1Host: services.odata.org HTTP/1.1 200 OK...

Page 9: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

OData• Atom XML/JSON representation

Page 10: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

10

OData ExamplesLet’s play with curl!

Page 11: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

OData Examples

$ curl 'http://services.odata.org/V4/OData/OData.svc/'{ "@odata.context": "http://services.odata.org/V4/OData/OData.svc/$metadata", "value": [ { "kind": "EntitySet", "name": "Products", "url": "Products" }, { "kind": "EntitySet", "name": "ProductDetails", "url": "ProductDetails" }, ...

Service Document (JSON)

Page 12: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

OData Examples

$ curl 'http://services.odata.org/V4/OData/OData.svc/?$format=xml'<?xml version="1.0" encoding="utf-8"?><service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:m="http://docs.oasis-open.org/odata/ns/metadata" xml:base="http://services.odata.org/V4/OData/OData.svc/" m:context="http://services.odata.org/V4/OData/OData.svc/$metadata"> <workspace> <atom:title type="text">Default</atom:title> <collection href="Products"> <atom:title type="text">Products</atom:title> </collection> <collection href="ProductDetails"> <atom:title type="text">ProductDetails</atom:title> </collection> ...

Service Document (XML)

Page 13: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

OData Examples

$ curl 'http://services.odata.org/V4/OData/OData.svc/$metadata'<?xml version="1.0" encoding="utf-8"?><edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0"> <edmx:DataServices> <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="ODataDemo"> <EntityType Name="Product"> <Key> <PropertyRef Name="ID"/> </Key> <Property Name="ID" Type="Edm.Int32" Nullable="false"/> <Property Name="Name" Type="Edm.String"/> ...

Metadata (XML Only )

Page 14: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

OData Examples

$ curl 'http://services.odata.org/V4/OData/OData.svc/Products?$filter=Rating+eq+3&$select=Rating,+Name'{ "@odata.context": "http://services.odata.org/V4/OData/OData.svc/$metadata#Products(Rating,Name)", "value": [ { "Name": "Milk", "Rating": 3 }, { "Name": "Vint soda", "Rating": 3 }, ...

Query

Page 15: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

OData Examples

$ curl 'http://services.odata.org/V4/OData/OData.svc/Products(1)'{ "@odata.context": "http://services.odata.org/V4/OData/OData.svc/$metadata#Products/$entity", "ID": 1, "Name": "Milk", "Description": "Low fat milk", "ReleaseDate": "1995-10-01T00:00:00Z", "DiscontinuedDate": null, "Rating": 3, "Price": 3.5}

Get Individual Entity

Page 16: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

OData Examples

$ curl -w "Status: %{http_code}\\n” \ -H 'Content-Type: application/json' \ -X PATCH \ -d '{"@odata.type":"ODataDemo.Product","Price":"2.99"}' \ 'http://services.odata.org/V4/OData/OData.svc/Products(1)’

Status: 204

Update Entity

Page 17: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

OData Examples

$ curl -H 'Prefer: odata.track-changes' -H 'Prefer: odata.callback; url="https://myserver/cb?token=123"' 'http://services.odata.org/V4/OData/OData.svc/Products’

Server will POST notifications to the callback URL

Change Tracking

Page 18: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

OData Adoption

•Microsoft• SAP• Salesforce• IBM• RedHat• Socrata

Page 19: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

OData-Supporting Products

• Microsoft SQL Server• Windows Azure Active Directory• SAP NetWeaver• IBM WebSphere• JBoss Teiid• Salesforce1 Lightning Connect• Socrata Open Data Portal

Page 20: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

OData Libraries

– Java– .Net– JavaScript– Objective-C– Python– Ruby– Node.js– PHP– C++

www.odata.org/libraries

Page 21: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

OData in Actionhttp://open.whitehouse.gov/

Page 22: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

OData Summary

• Standardizes data-centric web services• Exposes Data and Metadata• JSON or XML (Atom/AtomPub) representation over

HTTP• Wide industry support• Really not that clunky!

Page 23: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

OData Resources

• OData– http://www.odata.org/

• Apache Olingo– http://olingo.apache.org/

Page 24: OData: Universal Data Solvent or Clunky Enterprise Goo? (GlueCon 2015)

Thank You!

Pat PattersonDeveloper Evangelist Architect, Salesforce@metadaddy