Search in sources :

Example 1 with RegionResponse

use of com.sequenceiq.cloudbreak.api.model.RegionResponse in project cloudbreak by hortonworks.

the class PlatformRegionsToRegionResponseConverter method convert.

@Override
public RegionResponse convert(CloudRegions source) {
    RegionResponse json = new RegionResponse();
    Set<String> regions = new HashSet<>();
    for (Region region : source.getCloudRegions().keySet()) {
        regions.add(region.value());
    }
    Map<String, Collection<String>> availabilityZones = new HashMap<>();
    for (Entry<Region, List<AvailabilityZone>> regionListEntry : source.getCloudRegions().entrySet()) {
        Collection<String> azs = new ArrayList<>();
        for (AvailabilityZone availabilityZone : regionListEntry.getValue()) {
            azs.add(availabilityZone.value());
        }
        availabilityZones.put(regionListEntry.getKey().value(), azs);
    }
    Map<String, String> displayNames = new HashMap<>();
    for (Entry<Region, String> regionStringEntry : source.getDisplayNames().entrySet()) {
        displayNames.put(regionStringEntry.getKey().value(), regionStringEntry.getValue());
    }
    json.setRegions(regions);
    json.setAvailabilityZones(availabilityZones);
    json.setDefaultRegion(source.getDefaultRegion());
    json.setDisplayNames(displayNames);
    return json;
}
Also used : RegionResponse(com.sequenceiq.cloudbreak.api.model.RegionResponse) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AvailabilityZone(com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone) Region(com.sequenceiq.cloudbreak.cloud.model.Region) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet)

Aggregations

RegionResponse (com.sequenceiq.cloudbreak.api.model.RegionResponse)1 AvailabilityZone (com.sequenceiq.cloudbreak.cloud.model.AvailabilityZone)1 Region (com.sequenceiq.cloudbreak.cloud.model.Region)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1