vShield API Programming Guide
16 VMware, Inc.
servicewiththeexplicitassumptionthatneitherpartyneedknowanythingaboutanentityotherthanwhatis
presentedinasinglerequestorresponse.TheURLsatwhichthesedocumentsareavailableareoften“sticky,”
inthattheypersistbeyondthelifetimeoftherequestorresponsethatincludesthem.
Theothercontentofthe
documentsisnominallyvaliduntiltheexpirationdatenotedintheHTTPExpiresheader.
Using the vShield REST API
YouhaveseveralchoicesforprogrammingthevShieldRESTAPI:usingFirefox,Chrome,orcurl.Tomake
XMLresponsesmorelegible,youcancopyandpastethemintoxmlcopyeditororpspad.
To use the REST API in Firefox
1 LocatetheRESTClientMozillaadd‐on,andaddittoFirefox.
2ClickTools>RESTClienttostartthe
add‐on.
3ClickLoginandenterthevShieldlogincredentials,whichthenappearencodedintheRequestHeader.
4 SelectamethodsuchasGET,POST,orPUT,andtypetheURLofaRESTAPI.Youmightbeaskedtoaccept
orignorethelackofSSLcertificate.ClickSend.
ResponseHeader,
ResponseBody,andRenderedHTMLappearinthebottomwindow.
To use the REST API in Chrome
1SearchtheWebtofindtheSimpleRESTClient,andaddittoChrome.
2Clickitsglobe‐likeicontostartitinatab.
3TheSimpleRESTClientprovidesnocertificate‐checkinginterface,souseanotherChrometabtoaccept
orignorethelackofSSLcertificate.
4TypetheURLofaRESTAPI,andselectamethodsuchasGET,POST,orPUT.
5IntheHeadersfield,typethebasicauthorizationline,asintheImportantnoteabove.ClickSend.
Status,Headers,andDataappearintheResponsewindow.
To use the REST API in curl
1Install
curlifnotalreadyinstalled.
2InfrontoftheRESTURL,the‐koptionavoidscertificatechecking,andthe‐uoptionspecifiescredentials.
curl -k -u admin:default https://<vsm-ip>/api/2.0/services/usermgmt/user/admin
Ports Required for vShield REST API
ThevShieldManagerrequiresport443/TCPforRESTAPIrequests.
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?
I
MPORTANTAllvShieldRESTrequestsrequireauthorization.ThedefaultvShieldManagerlogincredentials
areuseradminpassworddefault.Unlessyouchangedthese,youcanusethefollowingbasicauthorization,
whereYWRtaW46ZGVmYXVsdA==istheBase64encodingofthedefaultcredentialsadmin:default.
Authorization: Basic YWRtaW46ZGVmYXVsdA==