use of com.sequenceiq.environment.environment.dto.EnvironmentCreationDto.Builder in project cloudbreak by hortonworks.
the class EnvironmentApiConverter method initCreationDto.
public EnvironmentCreationDto initCreationDto(EnvironmentRequest request) {
LOGGER.debug("Creating EnvironmentCreationDto from EnvironmentRequest: {}", request);
String accountId = ThreadBasedUserCrnProvider.getAccountId();
String cloudPlatform = credentialService.getCloudPlatformByCredential(request.getCredentialName(), accountId, ENVIRONMENT);
Builder builder = EnvironmentCreationDto.builder().withAccountId(accountId).withCreator(ThreadBasedUserCrnProvider.getUserCrn()).withName(request.getName()).withDescription(request.getDescription()).withCloudPlatform(cloudPlatform).withCredential(request).withCreated(System.currentTimeMillis()).withFreeIpaCreation(freeIpaConverter.convert(request.getFreeIpa(), accountId, cloudPlatform)).withLocation(locationRequestToDto(request.getLocation())).withTelemetry(telemetryApiConverter.convert(request.getTelemetry(), accountTelemetryService.getOrDefault(accountId).getFeatures(), accountId)).withBackup((request.getBackup() != null && isNotEmpty(request.getBackup().getStorageLocation())) ? backupConverter.convert(request.getBackup()) : backupConverter.convert(request.getTelemetry())).withRegions(locationRequestToRegions(request.getLocation(), cloudPlatform)).withAuthentication(authenticationRequestToDto(request.getAuthentication())).withAdminGroupName(request.getAdminGroupName()).withTags(request.getTags()).withCrn(createCrn(ThreadBasedUserCrnProvider.getAccountId())).withExperimentalFeatures(ExperimentalFeatures.builder().withIdBrokerMappingSource(request.getIdBrokerMappingSource()).withCloudStorageValidation(request.getCloudStorageValidation()).withTunnel(tunnelConverter.convert(request.getTunnel())).withOverrideTunnel(request.getOverrideTunnel()).withCcmV2TlsType(request.getCcmV2TlsType()).build()).withParameters(paramsToParametersDto(request, cloudPlatform)).withParentEnvironmentName(request.getParentEnvironmentName()).withProxyConfigName(request.getProxyConfigName());
NullUtil.doIfNotNull(request.getNetwork(), network -> builder.withNetwork(networkRequestToDto(network)));
NullUtil.doIfNotNull(request.getSecurityAccess(), securityAccess -> builder.withSecurityAccess(securityAccessRequestToDto(securityAccess)));
// TODO temporary until CCM not really integrated
if (request.getSecurityAccess() == null && !CloudPlatform.GCP.name().equals(cloudPlatform)) {
SecurityAccessDto securityAccess = SecurityAccessDto.builder().withCidr("0.0.0.0/0").build();
builder.withSecurityAccess(securityAccess);
}
return builder.build();
}
Aggregations