class RedbeamsDbServerConfigurer {

    public RDSConfig createNewRdsConfig(Stack stack, Cluster cluster, String dbName, String dbUser, DatabaseType type) {
        DatabaseServerV4Response resp = getDatabaseServer(cluster.getDatabaseServerCrn());
        LOGGER.info("Using redbeams for remote database configuration: {}", resp.toString());
        if (Objects.nonNull(resp.getStatus()) && !resp.getStatus().isAvailable()) {
            String message = String.format("Redbeams database server is not available (%s) with message: %s", resp.getStatus(), resp.getStatusReason());
            LOGGER.warn(message);
            throw new CloudbreakServiceException(message);
        }

        RDSConfig rdsConfig = new RDSConfig();
        rdsConfig.setConnectionURL(dbCommon.getJdbcConnectionUrl(resp.getDatabaseVendor(), resp.getHost(), resp.getPort(), Optional.of(dbName)));
        rdsConfig.setConnectionUserName(dbUsernameConverterService.toConnectionUsername(resp.getHost(), dbUser));
        rdsConfig.setConnectionPassword(PasswordUtil.generatePassword());
        rdsConfig.setConnectionDriver(resp.getConnectionDriver());
        rdsConfig.setDatabaseEngine(DatabaseVendor.fromValue(resp.getDatabaseVendor()));
        rdsConfig.setStatus(ResourceStatus.DEFAULT);
        rdsConfig.setName(type.name() + '_' + stack.getName() + stack.getId());
        rdsConfig.setType(type.name());
        rdsConfig.setStatus(ResourceStatus.DEFAULT);
        rdsConfig.setCreationDate(new Date().getTime());
        rdsConfig.setClusters(Collections.singleton(cluster));
        LOGGER.info("Created RDS config {} for database type {} with connection URL {}, connection username {}",
                rdsConfig.getName(), type, rdsConfig.getConnectionURL(), rdsConfig.getConnectionUserName());
        return rdsConfig;
    }

}