How to Design REST API? Written Date : March 23, 2015

Similar documents
File Manager Quick Reference Guide. June Prepared for the Mayo Clinic Enterprise Kahua Deployment

vcloud Director Service Provider Admin Portal Guide vcloud Director 9.1

OPERATION MANUAL. DIGIFORCE 9307 PROFINET Integration into TIA Portal

Agilent Mass Hunter Software

TECHNICAL NOTE MANAGING JUNIPER SRX PCAP DATA. Displaying the PCAP Data Column

style type="text/css".wpb_animate_when_almost_visible { opacity: 1; }/style

EasyMP Multi PC Projection Operation Guide

Lab 1 - Counter. Create a project. Add files to the project. Compile design files. Run simulation. Debug results

Epson iprojection Operation Guide (Windows/Mac)

Deposit a Technical Report in PubRep

Sage CRM 2018 R1 Software Requirements and Mobile Features. Updated: May 2018

vcloud Director Service Provider Admin Portal Guide 04 OCT 2018 vcloud Director 9.5

Migrating vrealize Automation to 7.3 or March 2018 vrealize Automation 7.3

CS201 Discussion 10 DRAWTREE + TRIES

EasyMP Network Projection Operation Guide

Sage CRM 2017 R3 Software Requirements and Mobile Features. Updated: August 2017

Registering as an HPE Reseller

OUTPUT DELIVERY SYSTEM

NOTES. Figure 1 illustrates typical hardware component connections required when using the JCM ICB Asset Ticket Generator software application.

Tool Vendor Perspectives SysML Thus Far

Engineer To Engineer Note

Sage CRM 2017 R2 Software Requirements and Mobile Features. Revision: IMP-MAT-ENG-2017R2-2.0 Updated: August 2017

Installation Guide AT-VTP-800

Online Portal Guide. Access your policy information, documentation, claim forms and claims history easily and securely.

License Manager Installation and Setup

INTRODUCTION TO SIMPLICIAL COMPLEXES

vcloud Director Tenant Portal Guide vcloud Director 9.1

- 2 U NIX FILES 1. Explin different file types vilble in UNIX or P OSIX s ystem. ( 08 mrks) ( My-08/Dec-08/My-10/My- 12) 2. Wht is n API? How is it di

Fig.25: the Role of LEX

Data sharing in OpenMP

Creating Flexible Interfaces. Friday, 24 April 2015

Welch Allyn CardioPerfect Workstation Installation Guide

LINX MATRIX SWITCHERS FIRMWARE UPDATE INSTRUCTIONS FIRMWARE VERSION

vcloud Director Tenant Portal Guide vcloud Director 9.0

ECE 468/573 Midterm 1 September 28, 2012

Simrad ES80. Software Release Note Introduction

Definition of Regular Expression

Epson Projector Content Manager Operation Guide

Address/Data Control. Port latch. Multiplexer

McAfee Network Security Platform

IST 220: Ch3-Transport Layer

Bruce McCarl's GAMS Newsletter Number 37

In the last lecture, we discussed how valid tokens may be specified by regular expressions.

Distributed Systems Principles and Paradigms

EasyMP Network Projection Operation Guide

Topic 2: Lexing and Flexing

Enginner To Engineer Note

pdfapilot Server 2 Manual

UNIT 11. Query Optimization

Spring 2018 Midterm Exam 1 March 1, You may not use any books, notes, or electronic devices during this exam.

EasyMP Multi PC Projection Operation Guide

COMPUTER EDUCATION TECHNIQUES, INC. (MS_W2K3_SERVER ) SA:

UNIVERSITY OF EDINBURGH COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS INFORMATICS 1 COMPUTATION & LOGIC INSTRUCTIONS TO CANDIDATES

c360 Add-On Solutions

E201 USB Encoder Interface

Zenoss Service Impact Installation and Upgrade Guide for Resource Manager 5.x and 6.x

2 Computing all Intersections of a Set of Segments Line Segment Intersection

MA1008. Calculus and Linear Algebra for Engineers. Course Notes for Section B. Stephen Wills. Department of Mathematics. University College Cork

Sunil Shah CONTAINERISED CONTINUOUS DELIVERY AT LOW COST AND WEB SCALE! 2016 Mesosphere, Inc. All Rights Reserved.

Reference types and their characteristics Class Definition Constructors and Object Creation Special objects: Strings and Arrays

Fall 2018 Midterm 1 October 11, ˆ You may not ask questions about the exam except for language clarifications.

Digital Design. Chapter 1: Introduction. Digital Design. Copyright 2006 Frank Vahid

Registering as a HPE Reseller. Quick Reference Guide for new Partners in Asia Pacific

Introduction To Files In Pascal

Unit #9 : Definite Integral Properties, Fundamental Theorem of Calculus

CS321 Languages and Compiler Design I. Winter 2012 Lecture 5

EasyMP Multi PC Projection Operation Guide

Lecture Overview. Knowledge-based systems in Bioinformatics, 1MB602. Procedural abstraction. The sum procedure. Integration as a procedure

MIPS I/O and Interrupt

View, evaluate, and publish assignments using the Assignment dropbox.

HP Unified Functional Testing

STRM Installation Guide

PARALLEL AND DISTRIBUTED COMPUTING

Green = Sample Designer page. Select Master Sample. Master Samples. Monitoring Sample Designer. Explore. 3 Design Import Sites

CKX-CCSW Confluency checker INSTRUCTIONS. Software for research/education This software is designed to use in research and or education fields.

Media Player Using Media Player Downloading Media Files Playing Music Playing Movie Using Playlist...

LCI/USB LonWorks Commissioning Interface

McAfee Network Security Platform

Release Notes for. LANCOM Advanced VPN Client 4.10 Rel

Functor (1A) Young Won Lim 8/2/17

10.5 Graphing Quadratic Functions

Introduction to Integration

Setup Guide. * Values enclosed in [ ] are for when the stand is attached. ipf650/ipf655. ipf750/ipf755. d. 3-inch paper core attachment L

YOU ARE: AND THIS IS:

Reference Guide. Place your first order and create your account.

Engineer-to-Engineer Note

VMware Horizon JMP Server Installation and Setup Guide. Modified on 06 SEP 2018 VMware Horizon 7 7.6

CSE 401 Midterm Exam 11/5/10 Sample Solution

Midterm 2 Sample solution

McAfee Network Security Platform

Introduction to Computer Science, Shimon Schocken, IDC Herzliya. Lecture Writing Classes

Functor (1A) Young Won Lim 10/5/17

UT1553B BCRT True Dual-port Memory Interface

Basics of Logic Design Arithmetic Logic Unit (ALU)

Zenoss Resource Manager Installation Guide

ΕΠΛ323 - Θεωρία και Πρακτική Μεταγλωττιστών

Polycom RealPresence Media Editor Quick Start

Fall 2017 Midterm Exam 1 October 19, You may not use any books, notes, or electronic devices during this exam.

Engineer To Engineer Note

Discussion 1 Recap. COP4600 Discussion 2 OS concepts, System call, and Assignment 1. Questions. Questions. Outline. Outline 10/24/2010

Transcription:

Visul Prdigm How Design REST API? Turil How Design REST API? Written Dte : Mrch 23, 2015 REpresenttionl Stte Trnsfer, n rchitecturl style tht cn be used in building networked pplictions, is becoming incresingly populr nowdys. Mny leding vendors hve opened doors of ir services developers, providing m with restful ccesses different web services. This turil shows how design REST API with Visul Prdigm. The genertion of API (code nd librry) nd API documenttion will lso be covered. In this turil, we will use simple membership registrtion service s n exmple show how design REST API for such service. Designing REST API 1. The design of REST API hs done in Clss Digrm. To crete Clss Digrm, select Digrm > New from olbr. 2. In New Digrm window, select Clss Digrm nd click Next. https://www.visul-prdigm.com/turils/rest-pi-exmple-simple-registrtion-service.jsp Pge 1 of 15

Visul Prdigm How Design REST API? Turil 3. Enter Membership Registrtion API Design s digrm nme. 4. Click OK confirm. 5. Select REST Resource in digrm olbr. 6. Click on digrm crete REST Resource nd nme it Members. A REST resource is fundmentl unit of n API tht conforms REST, which is wht we clled REST API. It is n object with URI, http request method, ssocited prmeters nd request/response body. Ech of REST resources represents specific service vilble on pth specified by its URI property. Therefore, if you wnt model multiple services, plese drw multiple REST resources 7. Right click on Members REST Resource nd select Open Specifiction... from popup menu. 8. In Generl tb, fill in following: https://www.visul-prdigm.com/turils/rest-pi-exmple-simple-registrtion-service.jsp Pge 2 of 15

Visul Prdigm How Design REST API? Turil Field Vlue Remrks URI /members Ech REST hs its own URI. ccess URL ccess for REST Typiclly, RESTful URI should refer resource tht is thing insted of referring n ction. when you re deciding URI, try use https://www.visul-prdigm.com/turils/rest-pi-exmple-simple-registrtion-service.jsp Pge 3 of 15

Visul Prdigm How Design REST API? Turil noun insted of verb. Method POST Specifies ction ct on resource. GET - A GET method (or GET request) is used retrieve of resource. It should be used SOLELY for retrieving dt nd should not lter. PUT - A PUT method (or PUT https://www.visul-prdigm.com/turils/rest-pi-exmple-simple-registrtion-service.jsp Pge 4 of 15

request) is used updte resource. For instnce, if you know tht blog post resides t http:// www.exm blogs/123 you cn updte this specific post by using PUT method put new resource represent of post. POST - A POST method (or POST request) Visul Prdigm How Design REST API? Turil https://www.visul-prdigm.com/turils/rest-pi-exmple-simple-registrtion-service.jsp Pge 5 of 15

Visul Prdigm How Design REST API? Turil is used crete resource. For instnce, when you wnt dd new blog post but hve no ide where sre it, you cn use POST method post it URL nd let server decide URL. DELETE - A DELETE method https://www.visul-prdigm.com/turils/rest-pi-exmple-simple-registrtion-service.jsp Pge 6 of 15

Visul Prdigm How Design REST API? Turil (or DELETE request) is used delete resource identified by URI. Description Crete new member by providing his/her nme, ddress nd telephone number. You will receive n object tht holds nme, ddress, telephone nd member ID of member. Descriptio of resource tht will pper in generted API document It is recommen provide cler descriptio of service, so tht consumer know wht service is nd how operte with it. https://www.visul-prdigm.com/turils/rest-pi-exmple-simple-registrtion-service.jsp Pge 7 of 15

Visul Prdigm How Design REST API? Turil 9. Click OK. 10. Let's sy membership registrtion requires users provide informtion like nme, ddress nd telephone. In API level, se re prmeters required by service nd should be provided by consumer of service. Let's represent this in our design. Move your mouse pointer over REST Request Body icon nd drg out Resource Ctlog butn t p right. 11. Relese mouse butn nd select Assocition -> One Clss from Resource Ctlog. 12. Nme clss Member. https://www.visul-prdigm.com/turils/rest-pi-exmple-simple-registrtion-service.jsp Pge 8 of 15

Visul Prdigm How Design REST API? Turil 13. Add three String ttributes in Member clss s prmeters - nme, ddress nd telephone. 14. Enter description of three ttributes. You cn enter description in description edir or in ttribute specifiction window (Right click on n ttribute nd select Open Specifiction... from popup menu). The description entered will be presented in API documenttion. Attribute nme ddress Description The full nme of member. The residentil ddress of member. telephone The telephone number of member. Tht's ll for request prt. You re free crete more complex structure by creting more ssocited clsses, but normlly you don't need do this. Now, let's move on response prt. https://www.visul-prdigm.com/turils/rest-pi-exmple-simple-registrtion-service.jsp Pge 9 of 15

Visul Prdigm How Design REST API? Turil 15. Vlue(s) be returned by server, if ny, is modeled vi Response Body. Let's sy member ID will be returned by server upon cretion of membership. Move your mouse pointer over REST Response Body icon nd drg out Resource Ctlog butn t p right. 16. Relese mouse butn nd select Assocition -> One Clss from Resource Ctlog. Note: If service will return n rry of objects, select Assocition -> Mny Clss insted. 17. Nme clss MemberID. https://www.visul-prdigm.com/turils/rest-pi-exmple-simple-registrtion-service.jsp Pge 10 of 15

Visul Prdigm How Design REST API? Turil 18. Add String ttribute vlue. 19. Enter description of vlue ttribute: The member ID. Specifying Request nd Response Heder nd Exmple A HTTP messge consists of HTTP request line, collection of heder fields nd n optionl body. In order for consumers ccess REST Resource, you hve specify request heders nd request (body) exmple. The request heder nd exmple specified will be presented in generted API documenttion. Consumer cn n follow documenttion in using API. 1. Right click on Members REST Resource nd select Open Specifiction... from popup menu. 2. Open Request Body tb. 3. Enter Heder: content-type: ppliction/ json uthoriztion: Berer myken123 4. Enter Exmple in JSON: { "nme" : "Peter", "ddress" : "100, Hppy Vlley", "telephone" : "12345678" } https://www.visul-prdigm.com/turils/rest-pi-exmple-simple-registrtion-service.jsp Pge 11 of 15

Visul Prdigm How Design REST API? Turil 5. Open Response Body tb. 6. Enter Heder: content-type: ppliction/json; chrset=utf-8 sttus: 200 OK rtelimit-limit: 1200 rtelimit-remining: 1137 rtelimit-reset: 1415984218 7. Enter Exmple in JSON: { "MemberID": { "vlue": "MB-3001" } } https://www.visul-prdigm.com/turils/rest-pi-exmple-simple-registrtion-service.jsp Pge 12 of 15

Visul Prdigm How Design REST API? Turil 8. Click OK confirm chnges. Generting REST API nd API Documenttion Once you hve finished design of your REST APIs, you cn generte API nd API documenttion. 1. Select Tools > Code > Generte REST API... from olbr. 2. In REST API window, keep Provider selected for API Type. By doing so, you will be ble generte API documenttion s well s server smple code tht guides you in progrmming your service (logic). 3. Check Members resource generte API. 4. Check Generte API Documenttion generte HTML files tht shows how use selected REST Resource(s). Supposedly, you will publish generted API documenttion in your website, so tht consumers of your service cn red through it know how ccess use your APIs. 5. Enter your compny nme, which will be presented in API documenttion. 6. Enter bse URL of your services. 7. Check Generte Smple generte source code tht teches you how progrm your API. The smple code is rich nd informtive. Therefore, insted of progrmming from scrtch, we strongly recommend you generte smple code nd modify its content fit your needs. https://www.visul-prdigm.com/turils/rest-pi-exmple-simple-registrtion-service.jsp Pge 13 of 15

Visul Prdigm How Design REST API? Turil 8. Enter output pth of code. 9. Click Generte. The following folders re generted in output direcry. Folder doc lib Description The API documenttion. You should publish API documenttion in your website, so tht consumers of your service cn check documenttion lern API. In order for generted code work, Google Gson librry must be presented in your clss pth. To void ny comptibility issues, plese downlod librry mnully: https://code.google.com/p/google-gson/ nd n plce file in lib folder. smple_srcthe smple code of client nd servlet. It shows you how ccess s client nd how rect request s provider. We strongly recommend you copy code nd modify it by filling in your own service logic. src The source code of communiction model. Do not modify file content or else code my not be ble function properly. https://www.visul-prdigm.com/turils/rest-pi-exmple-simple-registrtion-service.jsp Pge 14 of 15

Visul Prdigm How Design REST API? Turil 10. Open generted API documenttion nd tke look. The design (imge), description of prmeters, request nd response heder nd exmple re presented in document. Resources 1. Downlod REST API Exmple - Simple Registrtion Service.vpp Visul Prdigm home pge (https://www.visul-prdigm.com/) Visul Prdigm turils (https://www.visul-prdigm.com/turils/) https://www.visul-prdigm.com/turils/rest-pi-exmple-simple-registrtion-service.jsp Pge 15 of 15