Search in sources :

Example 16 with EnvironmentRequest

use of com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest in project cloudbreak by hortonworks.

the class EnvironmentValidatorService method validateAwsEnvironmentRequest.

public ValidationResult validateAwsEnvironmentRequest(EnvironmentRequest environmentRequest) {
    ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    String cloudPlatform = credentialService.getCloudPlatformByCredential(environmentRequest.getCredentialName(), accountId, ENVIRONMENT);
    resultBuilder.ifError(() -> !AWS.name().equalsIgnoreCase(cloudPlatform), "Environment request is not for cloud platform AWS.");
    resultBuilder.ifError(() -> StringUtils.isBlank(Optional.ofNullable(environmentRequest.getAws()).map(AwsEnvironmentParameters::getS3guard).map(S3GuardRequestParameters::getDynamoDbTableName).orElse(null)), "S3Guard Dynamo DB table name is not found in environment request.");
    return resultBuilder.build();
}
Also used : AwsEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsEnvironmentParameters) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)

Aggregations

EnvironmentRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest)15 Test (org.junit.jupiter.api.Test)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)12 Features (com.sequenceiq.common.api.telemetry.model.Features)7 ExperimentalFeatures (com.sequenceiq.environment.environment.domain.ExperimentalFeatures)7 EnvironmentCreationDto (com.sequenceiq.environment.environment.dto.EnvironmentCreationDto)7 FreeIpaCreationDto (com.sequenceiq.environment.environment.dto.FreeIpaCreationDto)7 EnvironmentTelemetry (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry)7 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)7 AccountTelemetry (com.sequenceiq.environment.telemetry.domain.AccountTelemetry)7 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)5 AwsEnvironmentParameters (com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsEnvironmentParameters)4 EnvironmentBackup (com.sequenceiq.environment.environment.dto.EnvironmentBackup)4 EnvironmentNetworkRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentNetworkRequest)2 S3GuardRequestParameters (com.sequenceiq.environment.api.v1.environment.model.request.aws.S3GuardRequestParameters)2 ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)1 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1