Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Copyright © 2019 Oracle and/or its affiliates. All rights reserved. |
RESTful Services
Oracle Autonomous Database
Jeff Smith
Master Product Manager
Jeff.d.smith@oracle.com || @thatjeffsmith
Database Tools, Oracle Corp
1
{
"items":
[
{
"employee_id": 100,
"first_name": "Suppo0rt",
"last_name": "King",
"email": "Suppo0rt",
"phone_number": "515.123.4567",
"hire_date": "2018-08-21T11:09:58Z",
"job_id": "AD_PRES",
"salary": 49243.75,
"commission_pct": null,
"manager_id": null,
"department_id": 90,
"column1": null,
"links": [
{
"rel": "self",
"href": "http://localhost:8080/ords/hr/peeps/100“
}
]
},
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
ATP-Dedicated, Too!
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | 4
Introduction and
getting started
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
REST Data Services (ORDS)
• Publish REST APIs for your schemas
• Write your own services SQL & PL/SQL
• REST Enable tables, views, PL/SQL objects
• Secure with privs/roles
• Authenticate with DB users or ORDS OAUTH2 workflow
5
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Stuff in your DB…available via HTTPS!
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
GET https://host/ords/human/peeps/ SELECT *
FROM
EMPLOYEES
HTTP/1.1 200 OK
{ "employee_id": 100,
"first_name": "Kris"
,"last_name": "Rice",
, “email": “krisrice@oracle.com",
{json}
URI SQL & PLSQLMap & BindHTTP Request
HTTP Response Transform to JSON SQL Result Set / Standard OUT
Oracle REST Data Services
Anatomy of an ORDS Request and Response
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Available Development & Management Interfaces
SQLDev
APEX
PL/SQL API
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Day 0: Database User with Web Access out-of-the-box
HTTPS Access – to your data,
objects, and APEX apps
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Getting Started
• ADMIN account is available by default for HTTPS Access
• SQL Developer Web, APEX, and RESTful Services
10
admin
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Use ADMIN for admin, not for development
• Treat it as SYSTEM/SYS
• Do NOT use for application schema
What TO DO
1. CREATE USER JEFF…;
2. REST ENABLE
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Determining your REST Service URLs
https://some-id.adb.co-citry-1.oraclecloudapps.com/ords/tjs/_sdw/?nav=worksheet
https://some-id.adb.co-citry-1.oraclecloudapps.com/ords
• /schema/module/service-pattern/
• /schema/rest-enabled-object/
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | 13
REST Service Options –
Automatic or Manual
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Automatic: REST Enabling a TABLE
AUTO REST Advantages
•CRUD APIs, no SQL to
write
•Single ORDS package
call to create
•Maintained by US
•Feature Packed
•Optimized
• GET
• PUT
• POST
• DELETE
• DESC
• DOCS
/ords/hr/employees
/ords/hr/employees/
/ords/hr/employees/:id
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
• Schema level Metadata
• Table Metadata
• Get ( Select )
• Query ( Filtering/Order/ASOF )
• Insert
• Update
• Delete
• Load CSV
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
•All rows /
•One row /:id – PK Value
–No PK, default to ROWID
–Multi-column PK /x,y,z
•Some rows /?q={json}
Querying the TABLE
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
METHOD : PUT /:PK
REQUEST BODY : JSON
RESPONSE: 200 OK
•Location (Header)
•JSON (Body)
Table Columns in the POST body
{“column_name” : column_value }
UPDATE a row
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
RESTful Services: Your SQL & PL/SQL
RESTful Service Advantages
•You’re in charge
•Inputs, outputs, error
handling, response codes,
formatting
•Full access to SQL/PLSQL
•Easily exported, source
controlled
•Transparent
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Not just for SELECTs & Reading Data
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Security and Authentication
• Services are secured with PRIVILEGES
• ROLES are assigned PRIVILEGES and granted to users
• USERS are authenticated DB USER sessions or come in via
our OAUTH2 mechanism
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Defining Privileges
22
Protect a module or URI pattern
The ‘SQL Developer’ role is inherited by
every database authenticated REST request
in ORDS….so if I give the privilege to this
ROLE, my JEFF/P@$$w0rd BASIC Auth
request to /ords/jeff/ will be authorized.
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Trying to access a REST API w/no credentials…
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Same request w/credentials…
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
OAUTH2 – what we recommend vs DB User/BASIC Auth
25
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | 26
Live Demo
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
ORDS in Autonomous, what it’s mean?
• Installed and ready to use at startup
• ADMIN user is REST enabled, but don’t use it for apps
• All the ORDS features you know on-prem, avail in OCI
• We handle upgrades and maintenance
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | 28
Questions?

More Related Content

RESTful Services for your Oracle Autonomous Database

  • 1. Copyright © 2019 Oracle and/or its affiliates. All rights reserved. | RESTful Services Oracle Autonomous Database Jeff Smith Master Product Manager Jeff.d.smith@oracle.com || @thatjeffsmith Database Tools, Oracle Corp 1 { "items": [ { "employee_id": 100, "first_name": "Suppo0rt", "last_name": "King", "email": "Suppo0rt", "phone_number": "515.123.4567", "hire_date": "2018-08-21T11:09:58Z", "job_id": "AD_PRES", "salary": 49243.75, "commission_pct": null, "manager_id": null, "department_id": 90, "column1": null, "links": [ { "rel": "self", "href": "http://localhost:8080/ords/hr/peeps/100“ } ] },
  • 2. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
  • 3. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | ATP-Dedicated, Too!
  • 4. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | 4 Introduction and getting started
  • 5. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | REST Data Services (ORDS) • Publish REST APIs for your schemas • Write your own services SQL & PL/SQL • REST Enable tables, views, PL/SQL objects • Secure with privs/roles • Authenticate with DB users or ORDS OAUTH2 workflow 5
  • 6. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Stuff in your DB…available via HTTPS!
  • 7. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | GET https://host/ords/human/peeps/ SELECT * FROM EMPLOYEES HTTP/1.1 200 OK { "employee_id": 100, "first_name": "Kris" ,"last_name": "Rice", , “email": “krisrice@oracle.com", {json} URI SQL & PLSQLMap & BindHTTP Request HTTP Response Transform to JSON SQL Result Set / Standard OUT Oracle REST Data Services Anatomy of an ORDS Request and Response
  • 8. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Available Development & Management Interfaces SQLDev APEX PL/SQL API
  • 9. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Day 0: Database User with Web Access out-of-the-box HTTPS Access – to your data, objects, and APEX apps
  • 10. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Getting Started • ADMIN account is available by default for HTTPS Access • SQL Developer Web, APEX, and RESTful Services 10 admin
  • 11. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Use ADMIN for admin, not for development • Treat it as SYSTEM/SYS • Do NOT use for application schema What TO DO 1. CREATE USER JEFF…; 2. REST ENABLE
  • 12. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Determining your REST Service URLs https://some-id.adb.co-citry-1.oraclecloudapps.com/ords/tjs/_sdw/?nav=worksheet https://some-id.adb.co-citry-1.oraclecloudapps.com/ords • /schema/module/service-pattern/ • /schema/rest-enabled-object/
  • 13. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | 13 REST Service Options – Automatic or Manual
  • 14. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Automatic: REST Enabling a TABLE AUTO REST Advantages •CRUD APIs, no SQL to write •Single ORDS package call to create •Maintained by US •Feature Packed •Optimized • GET • PUT • POST • DELETE • DESC • DOCS /ords/hr/employees /ords/hr/employees/ /ords/hr/employees/:id
  • 15. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
  • 16. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | • Schema level Metadata • Table Metadata • Get ( Select ) • Query ( Filtering/Order/ASOF ) • Insert • Update • Delete • Load CSV
  • 17. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | •All rows / •One row /:id – PK Value –No PK, default to ROWID –Multi-column PK /x,y,z •Some rows /?q={json} Querying the TABLE
  • 18. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | METHOD : PUT /:PK REQUEST BODY : JSON RESPONSE: 200 OK •Location (Header) •JSON (Body) Table Columns in the POST body {“column_name” : column_value } UPDATE a row
  • 19. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | RESTful Services: Your SQL & PL/SQL RESTful Service Advantages •You’re in charge •Inputs, outputs, error handling, response codes, formatting •Full access to SQL/PLSQL •Easily exported, source controlled •Transparent
  • 20. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Not just for SELECTs & Reading Data
  • 21. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Security and Authentication • Services are secured with PRIVILEGES • ROLES are assigned PRIVILEGES and granted to users • USERS are authenticated DB USER sessions or come in via our OAUTH2 mechanism
  • 22. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Defining Privileges 22 Protect a module or URI pattern The ‘SQL Developer’ role is inherited by every database authenticated REST request in ORDS….so if I give the privilege to this ROLE, my JEFF/P@$$w0rd BASIC Auth request to /ords/jeff/ will be authorized.
  • 23. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Trying to access a REST API w/no credentials…
  • 24. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | Same request w/credentials…
  • 25. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | OAUTH2 – what we recommend vs DB User/BASIC Auth 25
  • 26. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | 26 Live Demo
  • 27. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | ORDS in Autonomous, what it’s mean? • Installed and ready to use at startup • ADMIN user is REST enabled, but don’t use it for apps • All the ORDS features you know on-prem, avail in OCI • We handle upgrades and maintenance
  • 28. Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | 28 Questions?