use of com.vmware.flowgate.nlyteworker.model.JsonResultForAsset in project flowgate by vmware.
the class NlyteAPIClient method getAssets.
public List<NlyteAsset> getAssets(boolean isAllData, AssetCategory category) {
initAuthenticationWebToken();
String getAssetsUrl = null;
switch(category) {
case Server:
getAssetsUrl = getNlyteServiceEndpoint() + GetServerAssetsURL;
break;
case PDU:
getAssetsUrl = getNlyteServiceEndpoint() + GetPowerStripAssetsURL;
break;
case Cabinet:
getAssetsUrl = getNlyteServiceEndpoint() + GetCabinetsURL;
break;
case Networks:
getAssetsUrl = getNlyteServiceEndpoint() + GetNetworksURL;
break;
case Chassis:
getAssetsUrl = getNlyteServiceEndpoint() + GetChassisURL;
break;
default:
throw new NlyteWorkerException("no such assets of the category ");
}
JsonResultForAsset nlyteAssetResult = this.restTemplate.exchange(getAssetsUrl, HttpMethod.GET, getDefaultEntity(), JsonResultForAsset.class).getBody();
List<NlyteAsset> nlyteAssets = new LinkedList<NlyteAsset>();
nlyteAssets = nlyteAssetResult.getValue();
if (!isAllData) {
return nlyteAssets;
}
URLDecoder decoder = new URLDecoder();
List<NlyteAsset> nextPageNlyteAssets = null;
String nextLink = nlyteAssetResult.getOdatanextLink();
while (nextLink != null && !nextLink.equals("")) {
nextLink = decoder.decode(nextLink);
nextPageNlyteAssets = new ArrayList<NlyteAsset>();
nlyteAssetResult = this.restTemplate.exchange(nextLink, HttpMethod.GET, getDefaultEntity(), JsonResultForAsset.class).getBody();
nextPageNlyteAssets = nlyteAssetResult.getValue();
nlyteAssets.addAll(nextPageNlyteAssets);
nextLink = nlyteAssetResult.getOdatanextLink();
}
HandleAssetUtil util = new HandleAssetUtil();
nlyteAssets = util.filterUnActivedAsset(nlyteAssets, category);
return nlyteAssets;
}
Aggregations