Class TemplateUtils

java.lang.Object
org.elasticsearch.xpack.core.template.TemplateUtils

public class TemplateUtils extends Object
Handling versioned templates for time-based indices in x-pack
  • Method Details

    • loadTemplate

      public static String loadTemplate(String resource, String version, String versionProperty)
      Loads a built-in template and returns its source.
    • loadTemplate

      public static String loadTemplate(String resource, String version, String versionProperty, Map<String,String> variables)
      Loads a built-in template and returns its source after replacing given variables.
    • validate

      public static void validate(String source)
      Parses and validates that the source is not empty.
    • replaceVariables

      public static String replaceVariables(String input, String version, String versionProperty, Map<String,String> variables)
    • replaceVariable

      public static String replaceVariable(String input, String variable, String value)
      Replaces all occurrences of given variable with the value
    • checkTemplateExistsAndVersionIsGTECurrentVersion

      public static boolean checkTemplateExistsAndVersionIsGTECurrentVersion(String templateName, ClusterState state, long currentVersion)
      Checks if a versioned template exists, and if it exists checks if the version is greater than or equal to the current version.
      Parameters:
      templateName - Name of the index template
      state - Cluster state
      currentVersion - The current version to check against