Hello,
I started to play a little bit with the RESTapi of VEEAM Ent. Server.
But by question is not pointed to the Application. It’s more about the Handling of a RESTapi get results.
My Script:
var PostResponse = BRHost.createRequest("POST", "/sessionMngr/?v=v1_1", null).execute(); var TenantsResponse = BRHost.createRequest("GET", "/cloud/tenants", null).execute(); //System.log("Tenants " + TenantsResponse.contentAsString); var XMLFile = XMLManager.fromString(TenantsResponse.contentAsString); var XMLelement = XMLFile.documentElement.getElementsByTagName("Ref"); for(i=0;i<XMLelement.getLength();i++){ var Tenant = XMLelement.item(i).getAttribute("Name") if ( Tenant == TenantName){ var UIDTenantFull = XMLelement.item(i).getAttribute("UID") var UIDTenant = UIDTenantFull.slice(-36) var RessourceResponse = BRHost.createRequest("GET", "/cloud/tenants/" + UIDTenant + "/resources", null).execute(); //System.log("Tenant Ressources: " + VMResponse.contentAsString); //System.log("Content as string: " + RessourceResponse.contentAsString); var RESdoc = XMLManager.fromString(RessourceResponse.contentAsString); var RESlist = RESdoc.documentElement.getElementsByTagName("CloudTenantResource"); System.error(RESlist.getLength()); for(j=0;j < RESlist.getLength();j++){ var RessourceID = RESlist.item(j).getAttribute("Id"); System.log("Ressource ID: " + RessourceID); var RessourceResponseDetail = BRHost.createRequest("GET", "/cloud/tenants/" + UIDTenant + "/resources/" + RessourceID, null).execute(); System.log("RessourceResponseDetail: " + RessourceResponseDetail.contentAsString); } } }
A Result Example:
<CloudTenantResource xmlns="http://www.veeam.com/ent/v1.0" Type="CloudTenantResource" Href="http://localhost:9399/api/cloud/tenants/4f90635a-7ecc-49fe-beb6-60b37eb4bd89/resources/1c7c6cd7-0cd0-4e20-8d15-a94d23299a93" Id="1c7c6cd7-0cd0-4e20-8d15-a94d23299a93"> <Links> <Link Rel="Delete" Type="CloudTenantResource" Href="http://localhost:9399/api/cloud/tenants/4f90635a-7ecc-49fe-beb6-60b37eb4bd89/resources/1c7c6cd7-0cd0-4e20-8d15-a94d23299a93" Name="Cloud repository 3" /> <Link Rel="Up" Type="CloudTenant" Href="http://localhost:9399/api/cloud/tenants/4f90635a-7ecc-49fe-beb6-60b37eb4bd89?format=Entity" Name="ABC Company" /> <Link Rel="Up" Type="BackupServer" Href="http://localhost:9399/api/backupServers/8ea5406b-a6e9-42d9-bca5-44b6a5d94af1?format=Entity" Name="localhost" /> </Links> <RepositoryQuota> <DisplayName>Cloud repository 3</DisplayName> <RepositoryUid>urn:veeam:Repository:82db96c3-445c-4a7e-9587-f2d523e839f4</RepositoryUid> <Quota>1024</Quota> <UsedQuota>0</UsedQuota> </RepositoryQuota></CloudTenantResource>
Source: http://helpcenter.veeam.com/backup/80/rest/_tenants_id_resources_2.html
My Result dos exactly look like that.
Now is the Question how to deal with the Result.
First I want to try to extract all “ <RepositoryQuota>” fields In to an array.
What is the best way to do that?