java.lang.Object
org.elasticsearch.xpack.core.template.TemplateUtils
Handling versioned templates for time-based indices in x-pack
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA template parser leveraging aTemplate.TemplateDecoratorto modify templates during parsing. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckTemplateExistsAndVersionIsGTECurrentVersion(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.static StringLoads a built-in template and returns its source after replacing given variables.static StringloadTemplate(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.static <T> TloadTemplate(String resource, String version, String versionProperty, Map<String, String> variables, boolean validateVersion, TemplateUtils.TemplateParser<T> templateParser) Loads a built-in template, replaces given variables and parses it using the providedTemplateUtils.TemplateParser.
-
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. IfvalidateVersionis 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 IOExceptionLoads a built-in template, replaces given variables and parses it using the providedTemplateUtils.TemplateParser. IfvalidateVersionis 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 templatestate- Cluster statecurrentVersion- The current version to check against
-