class CloudInfoFromAAI {

    protected Optional<CloudRegion> getRelatedCloudRegionAndTenant(Relationships relationships) {
        CloudRegion cloudRegion = new CloudRegion();
        List<AAIResultWrapper> cloudRegions = relationships.getByType(Types.CLOUD_REGION);
        List<AAIResultWrapper> tenants = relationships.getByType(Types.TENANT);
        if (!cloudRegions.isEmpty()) {
            AAIResultWrapper cloudRegionWrapper = cloudRegions.get(0);
            Optional<org.onap.aai.domain.yang.CloudRegion> aaiCloudRegionOp =
                    cloudRegionWrapper.asBean(org.onap.aai.domain.yang.CloudRegion.class);
            if (aaiCloudRegionOp.isPresent()) {
                org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = aaiCloudRegionOp.get();
                cloudRegion.setCloudOwner(aaiCloudRegion.getCloudOwner());
                cloudRegion.setCloudRegionVersion(aaiCloudRegion.getCloudRegionVersion());
                cloudRegion.setLcpCloudRegionId(aaiCloudRegion.getCloudRegionId());
                cloudRegion.setComplex(aaiCloudRegion.getComplexName());
            }
        }
        if (!tenants.isEmpty()) {
            AAIResultWrapper tenantWrapper = tenants.get(0);
            Optional<org.onap.aai.domain.yang.Tenant> aaiTenantOp =
                    tenantWrapper.asBean(org.onap.aai.domain.yang.Tenant.class);
            if (aaiTenantOp.isPresent()) {
                org.onap.aai.domain.yang.Tenant aaiTenant = aaiTenantOp.get();
                cloudRegion.setTenantId(aaiTenant.getTenantId());
            }
        }
        return Optional.of(cloudRegion);
    }

}