class AwsRDSUtils {

    public static String generateSnapshotName (@NotNull String identifier) {
        String timestamp = new DateTimeFormatterBuilder().appendInstant(3).toFormatter().format(Instant.now());
        String output = String.format("ChaosSnapshot-%s-%s", identifier, timestamp).replace(":", "-").replace(",", "-")
                              .replaceAll("\\.", "-")
                              .replaceAll("--+", "-");
        int identifierTrim = 0;
        while (!isValidSnapshotName(output)) {
            output = String.format("ChaosSnapshot-%s-%s",
                    identifier.substring(0, identifier.length() - ++identifierTrim),
                    timestamp).replace(":", "-").replace(",", "-")
                           .replaceAll("\\.", "-")
                           .replaceAll("--+", "-");
            if (identifierTrim == identifier.length()) {
                /*
                I could not find a way to trigger this! Exception is here just in case, but I can't find a way to
                make this happen.
                */
                throw new ChaosException(AwsChaosErrorCode.INVALID_SNAPSHOT_NAME);
            }
        }
        return output;
    }

    private  AwsRDSUtils();

}