use of com.sequenceiq.environment.parameter.dto.GcpParametersDto in project cloudbreak by hortonworks.
the class EnvironmentDetailsToCDPEnvironmentDetailsConverter method convertGcpDetails.
private UsageProto.CDPEnvironmentGcpDetails convertGcpDetails(ParametersDto parametersDto) {
UsageProto.CDPEnvironmentGcpDetails.Builder builder = UsageProto.CDPEnvironmentGcpDetails.newBuilder();
if (parametersDto != null) {
GcpParametersDto gcpParametersDto = parametersDto.getGcpParametersDto();
if (gcpParametersDto != null) {
Optional<String> encryptionKey = Optional.of(gcpParametersDto).map(GcpParametersDto::getGcpResourceEncryptionParametersDto).map(GcpResourceEncryptionParametersDto::getEncryptionKey);
builder.setResourceEncryptionEnabled(encryptionKey.isPresent());
}
}
return builder.build();
}
use of com.sequenceiq.environment.parameter.dto.GcpParametersDto in project cloudbreak by hortonworks.
the class GcpEnvironmentParametersConverter method postConvert.
@Override
protected void postConvert(BaseParameters baseParameters, Environment environment, ParametersDto parametersDto) {
super.postConvert(baseParameters, environment, parametersDto);
GcpParameters gcpParameters = (GcpParameters) baseParameters;
Optional<GcpParametersDto> gcpParametersDto = Optional.of(parametersDto).map(ParametersDto::getGcpParametersDto);
gcpParameters.setEncryptionKey(gcpParametersDto.map(GcpParametersDto::getGcpResourceEncryptionParametersDto).map(GcpResourceEncryptionParametersDto::getEncryptionKey).orElse(null));
}
use of com.sequenceiq.environment.parameter.dto.GcpParametersDto in project cloudbreak by hortonworks.
the class GcpParameterValidator method validate.
@Override
public ValidationResult validate(EnvironmentValidationDto environmentValidationDto, ParametersDto parametersDto, ValidationResultBuilder validationResultBuilder) {
EnvironmentDto environmentDto = environmentValidationDto.getEnvironmentDto();
LOGGER.debug("ParametersDto: {}", parametersDto);
GcpParametersDto gcpParametersDto = parametersDto.getGcpParametersDto();
if (Objects.isNull(gcpParametersDto)) {
return validationResultBuilder.build();
}
ValidationResult validationResult;
GcpResourceEncryptionParametersDto gcpResourceEncryptionParametersDto = gcpParametersDto.getGcpResourceEncryptionParametersDto();
if (gcpResourceEncryptionParametersDto != null) {
validationResult = validateGcpEncryptionParameters(validationResultBuilder, gcpParametersDto, environmentDto.getAccountId());
if (validationResult.hasError()) {
return validationResult;
}
}
return validationResultBuilder.build();
}
use of com.sequenceiq.environment.parameter.dto.GcpParametersDto in project cloudbreak by hortonworks.
the class EnvironmentModificationService method editEnvironmentParameters.
private void editEnvironmentParameters(EnvironmentEditDto editDto, Environment environment) {
ParametersDto parametersDto = editDto.getParameters();
if (parametersDto != null) {
Optional<BaseParameters> original = parametersService.findByEnvironment(environment.getId());
if (original.isPresent()) {
BaseParameters originalParameters = original.get();
parametersDto.setId(originalParameters.getId());
if (originalParameters instanceof AwsParameters) {
AwsParameters awsOriginalParameters = (AwsParameters) originalParameters;
parametersDto.getAwsParametersDto().setFreeIpaSpotPercentage(awsOriginalParameters.getFreeIpaSpotPercentage());
validateAwsParameters(environment, parametersDto);
}
}
if (parametersDto.getGcpParametersDto() != null) {
String encryptionKey = Optional.of(parametersDto.getGcpParametersDto()).map(GcpParametersDto::getGcpResourceEncryptionParametersDto).map(GcpResourceEncryptionParametersDto::getEncryptionKey).orElse(null);
ValidationResult validationResult = environmentService.getValidatorService().validateEncryptionKey(encryptionKey, editDto.getAccountId());
if (validationResult.hasError()) {
throw new BadRequestException(validationResult.getFormattedErrors());
}
}
BaseParameters parameters = parametersService.saveParameters(environment, parametersDto);
if (parameters != null) {
environment.setParameters(parameters);
}
}
}
Aggregations