use of com.sequenceiq.environment.api.v1.environment.model.request.azure.ResourceGroupUsage in project cloudbreak by hortonworks.
the class DBStackToDatabaseStackConverter method buildParameters.
private Map<String, Object> buildParameters(DBStack stack) {
Json attributes = stack.getDatabaseServer().getAttributes();
Map<String, Object> params = attributes == null ? Collections.emptyMap() : attributes.getMap();
if (CloudPlatform.AZURE.name().equals(stack.getCloudPlatform())) {
DetailedEnvironmentResponse environment = getDetailedEnvironmentResponse(stack);
if (!stack.getParameters().containsKey(RESOURCE_GROUP_NAME_PARAMETER)) {
Optional<AzureResourceGroup> resourceGroupOptional = getResourceGroupFromEnv(environment);
if (resourceGroupOptional.isPresent() && !ResourceGroupUsage.MULTIPLE.equals(resourceGroupOptional.get().getResourceGroupUsage())) {
AzureResourceGroup resourceGroup = resourceGroupOptional.get();
String resourceGroupName = resourceGroup.getName();
ResourceGroupUsage resourceGroupUsage = resourceGroup.getResourceGroupUsage();
Map<String, Object> resourceGroupParameters = Map.of(RESOURCE_GROUP_NAME_PARAMETER, resourceGroupName, RESOURCE_GROUP_USAGE_PARAMETER, resourceGroupUsage.name());
params = getMergedMap(params, resourceGroupParameters);
}
}
if (azureEncryptionParametersPresent(environment)) {
Map<String, Object> encryptionParameters = Map.of(ENCRYPTION_KEY_URL, getEncryptionKeyUrlFromEnv(environment), ENCRYPTION_KEY_RESOURCE_GROUP_NAME, getEncryptionKeyResourceGroupNameFromEnv(environment));
params = getMergedMap(params, encryptionParameters);
}
} else if (CloudPlatform.GCP.name().equals(stack.getCloudPlatform())) {
DetailedEnvironmentResponse environment = getDetailedEnvironmentResponse(stack);
Optional<String> key = getGcpEncryptionKeyFromEnv(environment);
if (key.isPresent()) {
Map<String, Object> encryptionParameters = Map.of(VOLUME_ENCRYPTION_KEY_ID, key.get());
params = getMergedMap(params, encryptionParameters);
}
} else if (CloudPlatform.AWS.name().equals(stack.getCloudPlatform())) {
DetailedEnvironmentResponse environment = getDetailedEnvironmentResponse(stack);
Optional<String> key = getEncryptionKeyArnFromEnv(environment);
if (key.isPresent()) {
Map<String, Object> awsEncryptionParameters = Map.of(VOLUME_ENCRYPTION_KEY_ID, key.get());
params = getMergedMap(params, awsEncryptionParameters);
}
}
return params;
}
Aggregations