use of com.sequenceiq.environment.environment.dto.FreeIpaCreationDto in project cloudbreak by hortonworks.
the class FreeIpaConverter method convert.
public FreeIpaCreationDto convert(AttachedFreeIpaRequest request, String accountId, String cloudPlatform) {
FreeIpaCreationDto.Builder builder = FreeIpaCreationDto.builder();
if (request != null) {
builder.withCreate(request.getCreate());
builder.withEnableMultiAz(request.isEnableMultiAz());
if (request.isEnableMultiAz()) {
if (!cloudPlatform.equalsIgnoreCase(CloudConstants.AWS)) {
throw new BadRequestException("You need to provision AWS environment to use Multi Availability Zone.");
}
if (!entitlementService.awsNativeFreeIpaEnabled(accountId)) {
throw new BadRequestException("You need to be entitled for CDP_CB_AWS_NATIVE_FREEIPA to provision FreeIPA in Multi Availability Zone.");
}
}
Optional.ofNullable(request.getInstanceCountByGroup()).ifPresent(builder::withInstanceCountByGroup);
Optional.ofNullable(request.getInstanceType()).ifPresent(builder::withInstanceType);
Optional.ofNullable(request.getAws()).map(AwsFreeIpaParameters::getSpot).ifPresent(spotParameters -> builder.withAws(FreeIpaCreationAwsParametersDto.builder().withSpot(FreeIpaCreationAwsSpotParametersDto.builder().withPercentage(spotParameters.getPercentage()).withMaxPrice(spotParameters.getMaxPrice()).build()).build()));
FreeIpaImageRequest image = request.getImage();
if (image != null) {
builder.withImageCatalog(image.getCatalog());
builder.withImageId(image.getId());
}
}
return builder.build();
}
Aggregations