public void removeTemplate(final RemoveRequest request, final RemoveListener listener) {
clusterService.submitStateUpdateTask("remove-index-template [" + request.name + "]", new ProcessedClusterStateUpdateTask() {
@Override public ClusterState execute(ClusterState currentState) {
if (!currentState.metaData().templates().containsKey(request.name)) {
listener.onFailure(new IndexTemplateMissingException(request.name));
return currentState;
}
MetaData.Builder metaData = MetaData.builder().metaData(currentState.metaData())
.remoteTemplate(request.name);