vShield API Programming Guide
16 VMware, Inc.
About the REST API
RESTAPIsuseHTTPrequests(oftensentbyscriptorhigh‐levellanguage)asawayofmakingidempotent
remoteprocedurecallsthatcreate,modify,ordeleteobjectsdefinedbytheAPI.ARESTAPIisdefinedbya
collectionofXMLdocumentsthatrepresenttheobjectsonwhichtheAPI
operates.TheHTTPoperations
themselvesaregenerictoallHTTPclients.TowriteaRESTfulclient,youshouldunderstandHTTPprotocol
andthesemanticsofstandardHTMLmarkup.ForvShieldRESTAPI,youmustknowthreethings:
ThesetofobjectsthattheAPIsupports,andwhattheyrepresent.Forexample,whatarevDCandOrg?
HowtheAPIrepresentstheseobjects.Forinstance,whatistheXMLschemaforthevShieldEdgefirewall
ruleset?Whatdotheindividualelementsandattributesrepresent?
Howtheclientreferstoanobjectonwhichitwantstooperate.Forexample,whatisamanagedobjectID?
Toanswerthesequestions,youlookatvShieldAPIresourceschemas.TheseschemasdefineanumberofXML
types,manyofwhichareextendedbyothertypes.TheXMLelements
definedintheseschemas,alongwith
theirattributesandcompositionrules(minimumandmaximumnumberofelementsorattributes,orthe
prescribedhierarchywithwhichelementscanbenested)representthedatastructuresofvShieldobjects.A
clientcan“read”anobjectbymakinganHTTPGETrequesttotheobject’s
resourceURL.Aclientcan“write”
(createormodify)anobjectwithanHTTPPUTorPOSTrequestthatincludesaneworchangedXMLbody
documentfortheobject.UsuallyaclientcandeleteanobjectwithanHTTPDELETErequest.
Thisdocumentpresentsexamplerequestsandresponses,andprovides
referenceinformationontheXML
schemasthatdefinetherequestandresponsebodies.
RESTful Workflow Patterns
AllRESTfulworkflowsfallintoapatternthatincludesonlytwofundamentaloperations,whichyourepeatin
thisorderforaslongasnecessary.
MakeanHTTPrequest(GET,PUT,POST,orDELETE).Thetargetofthisrequestiseitherawell‐known
URL(suchasvShieldManager)oralinkobtainedfromtheresponsetoapreviousrequest.Forexample,
aGETrequesttoanOrgURLreturnslinkstovDCobjectscontainedby
theOrg.
Examinetheresponse,whichcanbeanXMLdocumentoranHTTPresponsecode.Iftheresponseisan
XMLdocument,itmaycontainlinksorotherinformationaboutthestateofanobject.Iftheresponseis
anHTTPresponsecode,itindicateswhethertherequestsucceededorfailed,and
maybeaccompanied
byaURLthatpointstoalocationfromwhichadditionalinformationcanberetrieved.
For More Information About REST
ForacomprehensivediscussionofRESTfrombothclientandserverperspectives,seeRESTfulWebServicesby
LeonardRichardsonandSamRuby,published2007byOʹReillyMedia.
TherearealsomanysourcesofinformationaboutRESTontheWeb,including:
http://www.infoq.com/articles/rest‐introduction
http://www.infoq.com/articles/subbu‐allamaraju‐rest
http://www.stucharlton.com/blog/archives/000141.html