use of com.sequenceiq.environment.api.v1.platformresource.model.RegionResponse in project cloudbreak by hortonworks.
the class CredentialPlatformResourceController method getRegionsByCredential.
@Override
@CustomPermissionCheck
public RegionResponse getRegionsByCredential(String credentialName, String credentialCrn, String region, String platformVariant, String availabilityZone, boolean availabilityZonesNeeded) {
customCheckUtil.run(() -> permissionCheckByCredential(credentialName, credentialCrn));
String accountId = getAccountId();
PlatformResourceRequest request = platformParameterService.getPlatformResourceRequest(accountId, credentialName, credentialCrn, region, platformVariant, availabilityZone);
LOGGER.info("Get /platform_resources/regions, request: {}", request);
CloudRegions regions = platformParameterService.getRegionsByCredential(request, availabilityZonesNeeded);
RegionResponse response = platformRegionsToRegionV1ResponseConverter.convert(regions);
LOGGER.info("Resp /platform_resources/regions, request: {}, regions: {}, response: {}", request, regions, response);
return response;
}
use of com.sequenceiq.environment.api.v1.platformresource.model.RegionResponse in project cloudbreak by hortonworks.
the class EnvironmentPlatformResourceController method getRegionsByCredential.
@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT)
public RegionResponse getRegionsByCredential(@ResourceCrn String environmentCrn, String region, String platformVariant, String availabilityZone, boolean availabilityZonesNeeded) {
String accountId = getAccountId();
validateEnvironmentCrnPattern(environmentCrn);
PlatformResourceRequest request = platformParameterService.getPlatformResourceRequestByEnvironment(accountId, environmentCrn, region, platformVariant, availabilityZone, null);
LOGGER.info("Get /platform_resources/regions, request: {}", request);
CloudRegions regions = platformParameterService.getRegionsByCredential(request, availabilityZonesNeeded);
RegionResponse response = platformRegionsToRegionV1ResponseConverter.convert(regions);
LOGGER.info("Resp /platform_resources/regions, request: {}, regions: {}, response: {}", request, regions, response);
return response;
}
use of com.sequenceiq.environment.api.v1.platformresource.model.RegionResponse in project cloudbreak by hortonworks.
the class PlatformRegionsToRegionV1ResponseConverter method convert.
public RegionResponse convert(CloudRegions source) {
RegionResponse json = new RegionResponse();
List<String> regions = new ArrayList<>();
for (Region region : source.getCloudRegions().keySet()) {
regions.add(region.value());
}
Map<String, List<String>> availabilityZones = new HashMap<>();
for (Entry<Region, List<AvailabilityZone>> regionListEntry : source.getCloudRegions().entrySet()) {
List<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());
}
List<String> locations = new ArrayList<>();
List<String> k8sSupportedLocations = new ArrayList<>();
for (Entry<Region, Coordinate> coordinateEntry : source.getCoordinates().entrySet()) {
locations.add(coordinateEntry.getKey().getRegionName());
displayNames.put(coordinateEntry.getKey().getRegionName(), coordinateEntry.getValue().getDisplayName());
if (coordinateEntry.getValue().getK8sSupported()) {
k8sSupportedLocations.add(coordinateEntry.getKey().getRegionName());
}
}
Collections.sort(regions);
Collections.sort(locations);
Collections.sort(k8sSupportedLocations);
availabilityZones = availabilityZones.entrySet().stream().sorted(Comparator.comparing(o -> o.getKey())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, LinkedHashMap::new));
displayNames = displayNames.entrySet().stream().sorted(Comparator.comparing(o -> o.getKey())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, LinkedHashMap::new));
json.setNames(regions);
json.setAvailabilityZones(availabilityZones);
json.setDefaultRegion(source.getDefaultRegion());
json.setDisplayNames(displayNames);
json.setLocations(locations);
json.setK8sSupportedlocations(k8sSupportedLocations);
return json;
}
use of com.sequenceiq.environment.api.v1.platformresource.model.RegionResponse in project cloudbreak by hortonworks.
the class DistroXV1RequestToStackV4RequestConverterTest method createCompactRegionResponse.
private CompactRegionResponse createCompactRegionResponse() {
CompactRegionResponse regionResponse = new CompactRegionResponse();
regionResponse.setNames(List.of("myregion"));
return regionResponse;
}
Aggregations