Example #1
0
		public static RestApiSpec GetRestSpec(bool useCache)
		{
			Console.WriteLine("Getting a listing of all the api endpoints from the elasticsearch-rest-api-spec repos");

			string html = string.Empty;
			using (var client = new WebClient())
				html = client.DownloadString(useCache ? LocalUri("root.html") : _listingUrl);

			var dom = CQ.Create(html);
			if (!useCache)
				WriteToCache("root.html", html);

			var endpoints = dom[".js-directory-link"]
				.Select(s => s.InnerText)
				.Where(s => !string.IsNullOrEmpty(s) && s.EndsWith(".json"))
				.Select(s => CreateApiDocumentation(useCache, s))
				.ToDictionary(d => d.Key, d => d.Value);

			var restSpec = new RestApiSpec
			{
				Endpoints = endpoints,
				Commit = dom[".sha:first"].Text()
			};


			return restSpec;
		}
		public static RestApiSpec GetRestApiSpec()
		{
			var spec = new RestApiSpec
			{
				Commit = CQ.Create(LocalUri("root.html"))[".sha:first"].Text(),
				Endpoints = Directory.GetFiles(_apiEndpointsFolder)
					.Where(f => f.EndsWith(".json"))
					.Select(f => CreateApiEndpoint(f))
					.ToDictionary(d => d.Key, d => d.Value)
			};

			return spec;
		}
Example #3
0
		public static void GenerateEnums(RestApiSpec model)
		{
			var targetFile = _esNetFolder + @"Domain\Enums.Generated.cs";
			var source = _razorMachine.Execute(File.ReadAllText(_viewFolder + @"Enums.Generated.cshtml"), model).ToString();
			File.WriteAllText(targetFile, source);
		}
Example #4
0
		public static void GenerateRequestParametersExtensions(RestApiSpec model)
		{
			var targetFile = _nestFolder + @"Domain\RequestParametersExtensions.Generated.cs";
			var source = _razorMachine.Execute(File.ReadAllText(_viewFolder + @"RequestParametersExtensions.Generated.cshtml"), model).ToString();
			File.WriteAllText(targetFile, source);
		}
Example #5
0
		public static void GenerateDescriptors(RestApiSpec model)
		{
			var targetFile = _nestFolder + @"DSL\_Descriptors.Generated.cs";
			var source = _razorMachine.Execute(File.ReadAllText(_viewFolder + @"_Descriptors.Generated.cshtml"), model).ToString();
			File.WriteAllText(targetFile, source);
		}
Example #6
0
		public static void GenerateRawClient(RestApiSpec model)
		{
			var targetFile = _esNetFolder + @"ElasticsearchClient.Generated.cs";
			var source = _razorMachine.Execute(File.ReadAllText(_viewFolder + @"ElasticsearchClient.Generated.cshtml"), model).ToString();
			File.WriteAllText(targetFile, source);
		}
Example #7
0
		public static void GenerateRawDispatch(RestApiSpec model)
		{
			var targetFile = _nestFolder + @"RawDispatch.Generated.cs";
			var source = _razorMachine.Execute(File.ReadAllText(_viewFolder + @"RawDispatch.Generated.cshtml"), model).ToString();
			File.WriteAllText(targetFile, source);
		}
Example #8
0
		private static void GenerateClientInterface(RestApiSpec model)
		{
			var targetFile = CodeConfiguration.EsNetFolder + @"IElasticLowLevelClient.Generated.cs";
			var source = RazorHelper.Execute(File.ReadAllText(CodeConfiguration.ViewFolder + @"IElasticLowLevelClient.Generated.cshtml"), model).ToString();
			File.WriteAllText(targetFile, source);
		}
Example #9
0
		private static void GenerateEnums(RestApiSpec model)
		{
			var targetFile = CodeConfiguration.EsNetFolder + @"Domain\Enums.Generated.cs";
			var source = RazorHelper.Execute(File.ReadAllText(CodeConfiguration.ViewFolder + @"Enums.Generated.cshtml"), model).ToString();
			File.WriteAllText(targetFile, source);
		}
Example #10
0
		private static void GenerateRequestParametersExtensions(RestApiSpec model)
		{
			var targetFile = CodeConfiguration.NestFolder + @"_Generated\_RequestParametersExtensions.Generated.cs";
			var source = RazorHelper.Execute(File.ReadAllText(CodeConfiguration.ViewFolder + @"_RequestParametersExtensions.Generated.cshtml"), model).ToString();
			File.WriteAllText(targetFile, source);
		}
Example #11
0
		private static void GenerateDescriptors(RestApiSpec model)
		{
			var targetFile = CodeConfiguration.NestFolder + @"_Generated\_Descriptors.Generated.cs";
			var source = RazorHelper.Execute(File.ReadAllText(CodeConfiguration.ViewFolder + @"_Descriptors.Generated.cshtml"), model).ToString();
			File.WriteAllText(targetFile, source);
		}
Example #12
0
		private static void GenerateRawDispatch(RestApiSpec model)
		{
			var targetFile = CodeConfiguration.NestFolder + @"_Generated/_LowLevelDispatch.Generated.cs";
			var source = RazorHelper.Execute(File.ReadAllText(CodeConfiguration.ViewFolder + @"_LowLevelDispatch.Generated.cshtml"), model).ToString();
			File.WriteAllText(targetFile, source);
		}
Example #13
0
		public void GenerateRequestParameters(RestApiSpec model)
		{
			var targetFile = EsNetFolder + @"Domain\RequestParameters\RequestParameters.Generated.cs";
			var source = RazorHelper.Execute(File.ReadAllText(ViewFolder + @"RequestParameters.Generated.cshtml"), model).ToString();
			File.WriteAllText(targetFile, source);
		}
Example #14
0
		public void GenerateRequests(RestApiSpec model)
		{
			var targetFile = NestFolder + @"_Generated\_Requests.Generated.cs";
			var source = RazorHelper.Execute(File.ReadAllText(ViewFolder + @"_Requests.Generated.cshtml"), model).ToString();
			File.WriteAllText(targetFile, source);
		}
Example #15
0
		public void GenerateRawClient(RestApiSpec model)
		{
			var targetFile = EsNetFolder + @"ElasticLowLevelClient.Generated.cs";
			var source = RazorHelper.Execute(File.ReadAllText(ViewFolder + @"ElasticLowLevelClient.Generated.cshtml"), model).ToString();
			File.WriteAllText(targetFile, source);
		}
		public static void GenerateClientInterface(RestApiSpec model)
		{
			var targetFile = EsNetFolder + @"IElasticsearchClient.Generated.cs";
			var source = RazorHelper.Execute(File.ReadAllText(ViewFolder + @"IElasticsearchClient.Generated.cshtml"), model).ToString();
			File.WriteAllText(targetFile, source);
		}