use of software.amazon.awssdk.services.iotsitewise.model.ListAssociatedAssetsRequest in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class SiteWiseClient method listAssociatedAssets.
/**
* Return all Associated asset Id as String list
* @param siteWiseAssetId siteWiseAssetId
* @return List which contains associated asset id
* @throws EdgeConnectorForKVSException - EdgeConnectorForKVS generic exception
*/
public List<String> listAssociatedAssets(@NonNull String siteWiseAssetId) throws EdgeConnectorForKVSException {
try {
List<String> assetHierarchiesIdList = getAssetHierarchiesIdList(siteWiseAssetId);
List<String> result = new ArrayList<>();
for (String hierarchiesId : assetHierarchiesIdList) {
final ListAssociatedAssetsRequest listAssociatedAssetsRequest = ListAssociatedAssetsRequest.builder().assetId(siteWiseAssetId).hierarchyId(hierarchiesId).build();
ListAssociatedAssetsResponse listAssociatedAssetsResponse = siteWiseClient.listAssociatedAssets(listAssociatedAssetsRequest);
result.addAll(listAssociatedAssetsResponse.assetSummaries().stream().map(AssociatedAssetsSummary::id).collect(Collectors.toList()));
}
return result;
} catch (Exception e) {
final String errorMessage = String.format("Failed to getAssetHierarchiesIdList from given siteWiseAssetId, " + "please check EdgeConnectorForKVS configuration and ensure given provide SiteWise property " + "generated from EdgeConnectorForKVSHubDeviceModel. siteWiseAssetId : %s", siteWiseAssetId);
log.error(errorMessage);
throw new EdgeConnectorForKVSException(errorMessage);
}
}
Aggregations