VMware, Inc. 11
Chapter 1 Overview of VMware vShield
Using the vShield REST API
RESTAPIusesHTTPrequests(whichareoftenexecutedbyascriptorotherhigher‐levellanguage)asaway
ofmakingwhatareessentiallyidempotentremoteprocedurecallsthatcreate,modify,ordeletetheobjects
definedbytheAPI.ThisRESTAPI(andothers)isdefinedbyacollectionof
XMLdocumentsthatrepresent
theobjectsonwhichtheAPIoperates.Theoperationsthemselves(HTTPrequests)aregenerictoallHTTP
clients.
TowriteaRESTfulclient,youneedtounderstandonlytheHTTPprotocolandthesemanticsofstandard
HTMLmarkup.TousethevShieldAPIeffectivelyinsucha
client,youneedtoknowthreethings:
thesetofobjectsthattheAPIsupports,andwhattheyrepresent(WhatisavDC?Howdoesitrelatetoan
Org?)
howtheAPIrepresentstheseobjects(WhatdoestheXMLschemaforthevShieldEdgefirewallruleset
looklike?Whatdotheindividualelementsandattributesrepresent?)
howtheclientreferstoanobjectonwhichitwantstooperate
Toanswerthesequestions,youneedtounderstandthevShieldAPIresourceschemas.Theseschemasdefine
anumberofXMLtypes,manyofwhichareextendedbyothertypes.TheXMLelementsdefinedinthese
schemas,alongwith
theirattributesandcompositionrules(minimumandmaximumnumberofelementsor
attributes,forexample,ortheprescribedhierarchywithwhichelementscanbenested)representthedata
structuresofvShieldobjects.Aclientcan“read”anobjectbymakinganHTTPGETrequesttotheobject’s
resourceURL.Aclient
can“write”(createormodify)anobjectwithanHTTPPUTorPOSTrequestthat
includesaneworchangedXMLbodydocumentfortheobject.Andaclientcanusuallydeleteanobjectwith
anHTTPDELETErequest.
Inthisdocument,wepresentexamplerequestsandresponses,andalsoprovide
referenceinformationonthe
XMLschemasthatdefinetherequestandresponsebodies.
RESTful Workflow Patterns
AllRESTfulworkflowsfallintoapatternthatincludesonlytwofundamentaloperations:
MakeanHTTPrequest(typicallyGET,PUT,POST,orDELETE).Thetargetofthisrequestiseithera
well‐knownURL(suchasthevShieldManager)oralinkobtainedfromtheresponsetoaprevious
request.(Forexample,aGETrequesttoanOrgURLreturnslinkstovDCobjects
containedbytheOrg.)
Examinetheresponse,whichcanbeanXMLdocumentoranHTTPresponsecode.Iftheresponseisan
XMLdocument,itmaycontainlinksorotherinformationaboutthestateofanobject.Iftheresponseis
anHTTPresponsecode,itindicateswhethertherequestsucceededorfailed,and
maybeaccompanied
byaURLthatpointstoalocationfromwhichadditionalinformationcanberetrieved.
Thesetwooperationscanrepeat,inthisorder,foraslongasnecessary.
I
MPORTANTAllvShieldRESTrequestsrequireauthorization.Youcanusethefollowingbasicauthorization:
Authorization: Basic YWRtaW46ZGVmYXVsdA==
YWRtaW46ZGVmYXVsdA==representstheBase64encodingofthevShieldManagerdefaultlogincredentials
(admin:default).