<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Nest.Resolvers.Writers;

namespace Nest
{
	public partial class ElasticClient
	{

		public ITemplateResponse GetTemplate(string templateName)
		{
			templateName.ThrowIfNull("templateName");
			//TODO validate templateName for invalid url chars?

			string path = this.PathResolver.CreateTemplatePath(templateName);
			ConnectionStatus status = this.Connection.GetSync(path);

			return this.ToParsedResponse<TemplateResponse>(status);
		}

		public IIndicesOperationResponse PutTemplate(Func<TemplateMappingDescriptor, TemplateMappingDescriptor> templateMappingSelector) // TODO: use descriptor
		{
			templateMappingSelector.ThrowIfNull("templateMappingSelector");

			var templateMappingDescriptor = templateMappingSelector(new TemplateMappingDescriptor());
			templateMappingDescriptor.ThrowIfNull("templateMappingDescriptor");

			var templateMapping = templateMappingDescriptor._TemplateMapping;
			templateMapping.ThrowIfNull("templateMapping");

			var templateName = templateMappingDescriptor._Name;

			templateName.ThrowIfNull("templateName");
			templateMapping.ThrowIfNull("templateMapping");

			string template = JsonConvert.SerializeObject(templateMapping, Formatting.None, SerializationSettings);

			return PutTemplateRaw(templateName, template);
		}

		public IIndicesOperationResponse PutTemplateRaw(string templateName, string template)
		{
			string path = this.PathResolver.CreateTemplatePath(templateName);
			ConnectionStatus status = this.Connection.PutSync(path, template);
<commit_msg>TODO has been fixed :)<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Nest.Resolvers.Writers;

namespace Nest
{
	public partial class ElasticClient
	{

		public ITemplateResponse GetTemplate(string templateName)
		{
			templateName.ThrowIfNull("templateName");
			//TODO validate templateName for invalid url chars?

			string path = this.PathResolver.CreateTemplatePath(templateName);
			ConnectionStatus status = this.Connection.GetSync(path);

			return this.ToParsedResponse<TemplateResponse>(status);
		}

		public IIndicesOperationResponse PutTemplate(Func<TemplateMappingDescriptor, TemplateMappingDescriptor> templateMappingSelector)
		{
			templateMappingSelector.ThrowIfNull("templateMappingSelector");

			var templateMappingDescriptor = templateMappingSelector(new TemplateMappingDescriptor());
			templateMappingDescriptor.ThrowIfNull("templateMappingDescriptor");

			var templateMapping = templateMappingDescriptor._TemplateMapping;
			templateMapping.ThrowIfNull("templateMapping");

			var templateName = templateMappingDescriptor._Name;

			templateName.ThrowIfNull("templateName");
			templateMapping.ThrowIfNull("templateMapping");

			string template = JsonConvert.SerializeObject(templateMapping, Formatting.None, SerializationSettings);

			return PutTemplateRaw(templateName, template);
		}

		public IIndicesOperationResponse PutTemplateRaw(string templateName, string template)
		{
			string path = this.PathResolver.CreateTemplatePath(templateName);
			ConnectionStatus status = this.Connection.PutSync(path, template);

{'fraction_non_alphanumeric': 0.0794435857805255, 'fraction_numerical': 0.0, 'mean_word_length': 6.873479318734793, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5544969', 'n_tokens_mistral': 879, 'n_tokens_neox': 776, 'n_words': 161}