VMware, Inc. 207
B
REST,anacronymforRepresentationalStateTransfer,isatermthathasbeenwidelyemployedtodescribean
architecturalstylecharacteristicofprogramsthatrelyontheinherentpropertiesofhypermediatocreateand
modifythestateofanobjectthatisaccessibleataURL.
Thisappendixincludesthefollowing
topics:
“HowRESTWorks”onpage 207
“UsingthevCloudRESTAPI”onpage 207
“ForMoreInformationAboutREST”onpage 208
How REST Works
IfaURLofsuchanobjectisknowntoaclient,theclientcanuseanHTTPGETrequesttodiscoverthe
propertiesoftheobject.ThesepropertiesaretypicallycommunicatedinastructureddocumentwithanHTTP
Content‐TypeofXMLorJSON,thatprovidesarepresentationofthe
stateoftheobject.InaRESTfulworkflow,
documents(representationsofobjectstate)arepassedbackandforth(transferred)betweenaclientanda
servicewiththeexplicitassumptionthatneitherpartyneedknowanythingaboutanobjectotherthanwhatis
presentedinasinglerequestorresponse.The
URLsatwhichthesedocumentsareavailableareoften“sticky,”
inthattheypersistbeyondthelifetimeoftherequestorresponsethatincludesthem.Theothercontentofthe
documentsisnominallyvaliduntiltheexpirationdatenotedintheHTTPExpiresheader.
Using the vCloud REST API
A“RESTAPI”isinsomewaysanunfortunateterm,sincetheapplicationprogramswrittentoaRESTAPI
actuallyuseHTTPrequests(whichareoftenexecutedbyascriptorotherhigher‐levellanguage)asawayof
makingwhatareessentiallyremoteprocedurecallsthatcreate,modify,ordelete
theobjectsdefinedbythe
API.ThisRESTAPI(andothers)isdefinedbyacollectionofXMLdocumentsthatrepresenttheobjectson
whichtheAPIoperates.Theoperationsthemselves(HTTPrequests)aregenerictoallHTTPclients.
TowriteaRESTfulclient,youneedtounderstandonlytheHTTP
protocolandthesemanticsofstandard
HTMLmarkup.TousethevCloudAPIeffectivelyinsuchaclient,youneedtoknowthreethings
thesetofobjectsthattheAPIsupports,andwhattheyrepresent(WhatisavDC?Howdoesitrelatetoan
organizationorcatalog?)
howtheAPIrepresentstheseobjects(WhatdoestheXMLschemaforanOrglooklike?Whatdothe
individualelementsandattributesrepresent?)
howtheclientreferstoanobjectonwhichitwantstooperate(WherearethelinkstoobjectsinavDC?
Howdoesaclientobtainandusethem?)
Toanswerthesequestions,youneedtounderstandthevCloudAPIXMLschemas.Theseschemasdefinea
numberofXMLtypes,
manyofwhichareextendedbyothertypes.ThevCloudAPIschemasalsouseand
extendtypesdefinedbytheOpenVirtualizationFormat.TheXMLelementsdefinedintheseschemas,along
withtheirattributesandcompositionrules(minimumandmaximumnumberofelementsorattributes,for
An Introduction to REST for vCloud
API Users
B