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, Map<String,String> variables)
      Loads a built-in template and returns its source after replacing given variables.
    • loadTemplate

      public static String loadTemplate(String resource, String version, String versionProperty, Map<String,String> variables, boolean validateVersion)
      Loads a built-in template and returns its source after replacing given variables. If validateVersion is true and assertions are enabled, a root version field with the provided version is expected to exist after applying substitutions.
    • loadTemplate

      public static <T> T loadTemplate(String resource, String version, String versionProperty, Map<String,String> variables, boolean validateVersion, TemplateUtils.TemplateParser<T> templateParser) throws IOException
      Loads a built-in template, replaces given variables and parses it using the provided TemplateUtils.TemplateParser. If validateVersion is true and assertions are enabled, a root version field with the provided version is expected to exist after applying substitutions.
      Throws:
      IOException
    • 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