Skip to content

Commit 53a828e

Browse files
committed
Fix compile errors
1 parent bef1cb0 commit 53a828e

File tree

7 files changed

+218
-1
lines changed

7 files changed

+218
-1
lines changed

src/ApiGenerator/Configuration/CodeConfiguration.cs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,21 @@ public static class CodeConfiguration
7474
"transform.update_transform.json",
7575
};
7676

77+
/// <summary>
78+
/// Map API default names for API's we are only supporting on the low level client first
79+
/// </summary>
80+
private static readonly Dictionary<string, string> LowLevelApiNameMapping = new Dictionary<string, string>
81+
{
82+
{ "indices.delete_index_template", "DeleteIndexTemplateV2" },
83+
{ "indices.get_index_template", "GetIndexTemplateV2" },
84+
{ "indices.put_index_template", "PutIndexTemplateV2" }
85+
};
7786

7887
/// <summary>
7988
/// Scan all nest source code files for Requests and look for the [MapsApi(filename)] attribute.
8089
/// The class name minus Request is used as the canonical .NET name for the API.
8190
/// </summary>
82-
public static readonly Dictionary<string, string> ApiNameMapping =
91+
public static readonly Dictionary<string, string> HighLevelApiNameMapping =
8392
(from f in new DirectoryInfo(GeneratorLocations.NestFolder).GetFiles("*.cs", SearchOption.AllDirectories)
8493
let contents = File.ReadAllText(f.FullName)
8594
let c = Regex.Replace(contents, @"^.+\[MapsApi\(""([^ \r\n]+)""\)\].*$", "$1", RegexOptions.Singleline)
@@ -88,6 +97,26 @@ public static class CodeConfiguration
8897
.DistinctBy(v => v.Key)
8998
.ToDictionary(k => k.Key, v => v.Value.Replace(".cs", ""));
9099

100+
private static Dictionary<string, string> _apiNameMapping;
101+
102+
public static Dictionary<string, string> ApiNameMapping
103+
{
104+
get
105+
{
106+
if (_apiNameMapping != null) return _apiNameMapping;
107+
lock (LowLevelApiNameMapping)
108+
{
109+
if (_apiNameMapping != null) return _apiNameMapping;
110+
111+
var mapping = HighLevelApiNameMapping;
112+
foreach (var (k, v) in LowLevelApiNameMapping)
113+
mapping[k] = v;
114+
_apiNameMapping = mapping;
115+
return _apiNameMapping;
116+
}
117+
}
118+
}
119+
91120
private static readonly string ResponseBuilderAttributeRegex = @"^.+\[ResponseBuilderWithGeneric\(""([^ \r\n]+)""\)\].*$";
92121
/// <summary>
93122
/// Scan all nest source code files for Requests and look for the [MapsApi(filename)] attribute.

src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Indices.cs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,43 @@ public TimeSpan MasterTimeout
434434
}
435435
}
436436

437+
///<summary>Request options for ExistsType <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-types-exists.html</para></summary>
438+
public class ExistsTypeRequestParameters : RequestParameters<ExistsTypeRequestParameters>
439+
{
440+
public override HttpMethod DefaultHttpMethod => HttpMethod.HEAD;
441+
public override bool SupportsBody => false;
442+
///<summary>
443+
/// Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have
444+
/// been specified)
445+
///</summary>
446+
public bool? AllowNoIndices
447+
{
448+
get => Q<bool? >("allow_no_indices");
449+
set => Q("allow_no_indices", value);
450+
}
451+
452+
///<summary>Whether to expand wildcard expression to concrete indices that are open, closed or both.</summary>
453+
public ExpandWildcards? ExpandWildcards
454+
{
455+
get => Q<ExpandWildcards? >("expand_wildcards");
456+
set => Q("expand_wildcards", value);
457+
}
458+
459+
///<summary>Whether specified concrete indices should be ignored when unavailable (missing or closed)</summary>
460+
public bool? IgnoreUnavailable
461+
{
462+
get => Q<bool? >("ignore_unavailable");
463+
set => Q("ignore_unavailable", value);
464+
}
465+
466+
///<summary>Return local information, do not retrieve the state from master node (default: false)</summary>
467+
public bool? Local
468+
{
469+
get => Q<bool? >("local");
470+
set => Q("local", value);
471+
}
472+
}
473+
437474
///<summary>Request options for Flush <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-flush.html</para></summary>
438475
public class FlushRequestParameters : RequestParameters<FlushRequestParameters>
439476
{
@@ -1185,6 +1222,36 @@ public bool? IgnoreUnavailable
11851222
}
11861223
}
11871224

1225+
///<summary>Request options for ReloadSearchAnalyzers <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html</para></summary>
1226+
public class ReloadSearchAnalyzersRequestParameters : RequestParameters<ReloadSearchAnalyzersRequestParameters>
1227+
{
1228+
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
1229+
public override bool SupportsBody => false;
1230+
///<summary>
1231+
/// Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have
1232+
/// been specified)
1233+
///</summary>
1234+
public bool? AllowNoIndices
1235+
{
1236+
get => Q<bool? >("allow_no_indices");
1237+
set => Q("allow_no_indices", value);
1238+
}
1239+
1240+
///<summary>Whether to expand wildcard expression to concrete indices that are open, closed or both.</summary>
1241+
public ExpandWildcards? ExpandWildcards
1242+
{
1243+
get => Q<ExpandWildcards? >("expand_wildcards");
1244+
set => Q("expand_wildcards", value);
1245+
}
1246+
1247+
///<summary>Whether specified concrete indices should be ignored when unavailable (missing or closed)</summary>
1248+
public bool? IgnoreUnavailable
1249+
{
1250+
get => Q<bool? >("ignore_unavailable");
1251+
set => Q("ignore_unavailable", value);
1252+
}
1253+
}
1254+
11881255
///<summary>Request options for Rollover <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html</para></summary>
11891256
public class RolloverIndexRequestParameters : RequestParameters<RolloverIndexRequestParameters>
11901257
{

src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.NoNamespace.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,43 @@ public TimeSpan Timeout
14441444
}
14451445
}
14461446

1447+
///<summary>Request options for RankEval <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html</para></summary>
1448+
public class RankEvalRequestParameters : RequestParameters<RankEvalRequestParameters>
1449+
{
1450+
public override HttpMethod DefaultHttpMethod => HttpMethod.POST;
1451+
public override bool SupportsBody => true;
1452+
///<summary>
1453+
/// Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have
1454+
/// been specified)
1455+
///</summary>
1456+
public bool? AllowNoIndices
1457+
{
1458+
get => Q<bool? >("allow_no_indices");
1459+
set => Q("allow_no_indices", value);
1460+
}
1461+
1462+
///<summary>Whether to expand wildcard expression to concrete indices that are open, closed or both.</summary>
1463+
public ExpandWildcards? ExpandWildcards
1464+
{
1465+
get => Q<ExpandWildcards? >("expand_wildcards");
1466+
set => Q("expand_wildcards", value);
1467+
}
1468+
1469+
///<summary>Whether specified concrete indices should be ignored when unavailable (missing or closed)</summary>
1470+
public bool? IgnoreUnavailable
1471+
{
1472+
get => Q<bool? >("ignore_unavailable");
1473+
set => Q("ignore_unavailable", value);
1474+
}
1475+
1476+
///<summary>Search operation type</summary>
1477+
public SearchType? SearchType
1478+
{
1479+
get => Q<SearchType? >("search_type");
1480+
set => Q("search_type", value);
1481+
}
1482+
}
1483+
14471484
///<summary>Request options for ReindexOnServer <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html</para></summary>
14481485
public class ReindexOnServerRequestParameters : RequestParameters<ReindexOnServerRequestParameters>
14491486
{

src/Elasticsearch.Net/ElasticLowLevelClient.Indices.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,19 @@ public TResponse TemplateExistsForAll<TResponse>(string name, IndexTemplateExist
246246
[MapsApi("indices.exists_template", "name")]
247247
public Task<TResponse> TemplateExistsForAllAsync<TResponse>(string name, IndexTemplateExistsRequestParameters requestParameters = null, CancellationToken ctx = default)
248248
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(HEAD, Url($"_template/{name:name}"), ctx, null, RequestParams(requestParameters));
249+
///<summary>HEAD on /{index}/_mapping/{type} <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-types-exists.html</para></summary>
250+
///<param name = "index">A comma-separated list of index names; use `_all` to check the types across all indices</param>
251+
///<param name = "type">A comma-separated list of document types to check</param>
252+
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
253+
public TResponse ExistsType<TResponse>(string index, string type, ExistsTypeRequestParameters requestParameters = null)
254+
where TResponse : class, IElasticsearchResponse, new() => DoRequest<TResponse>(HEAD, Url($"{index:index}/_mapping/{type:type}"), null, RequestParams(requestParameters));
255+
///<summary>HEAD on /{index}/_mapping/{type} <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-types-exists.html</para></summary>
256+
///<param name = "index">A comma-separated list of index names; use `_all` to check the types across all indices</param>
257+
///<param name = "type">A comma-separated list of document types to check</param>
258+
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
259+
[MapsApi("indices.exists_type", "index, type")]
260+
public Task<TResponse> ExistsTypeAsync<TResponse>(string index, string type, ExistsTypeRequestParameters requestParameters = null, CancellationToken ctx = default)
261+
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(HEAD, Url($"{index:index}/_mapping/{type:type}"), ctx, null, RequestParams(requestParameters));
249262
///<summary>POST on /_flush <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-flush.html</para></summary>
250263
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
251264
public TResponse FlushForAll<TResponse>(FlushRequestParameters requestParameters = null)
@@ -653,6 +666,17 @@ public TResponse Refresh<TResponse>(string index, RefreshRequestParameters reque
653666
[MapsApi("indices.refresh", "index")]
654667
public Task<TResponse> RefreshAsync<TResponse>(string index, RefreshRequestParameters requestParameters = null, CancellationToken ctx = default)
655668
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(POST, Url($"{index:index}/_refresh"), ctx, null, RequestParams(requestParameters));
669+
///<summary>POST on /{index}/_reload_search_analyzers <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html</para></summary>
670+
///<param name = "index">A comma-separated list of index names to reload analyzers for</param>
671+
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
672+
public TResponse ReloadSearchAnalyzers<TResponse>(string index, ReloadSearchAnalyzersRequestParameters requestParameters = null)
673+
where TResponse : class, IElasticsearchResponse, new() => DoRequest<TResponse>(POST, Url($"{index:index}/_reload_search_analyzers"), null, RequestParams(requestParameters));
674+
///<summary>POST on /{index}/_reload_search_analyzers <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html</para></summary>
675+
///<param name = "index">A comma-separated list of index names to reload analyzers for</param>
676+
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
677+
[MapsApi("indices.reload_search_analyzers", "index")]
678+
public Task<TResponse> ReloadSearchAnalyzersAsync<TResponse>(string index, ReloadSearchAnalyzersRequestParameters requestParameters = null, CancellationToken ctx = default)
679+
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(POST, Url($"{index:index}/_reload_search_analyzers"), ctx, null, RequestParams(requestParameters));
656680
///<summary>POST on /{alias}/_rollover <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html</para></summary>
657681
///<param name = "alias">The name of the alias to rollover</param>
658682
///<param name = "body">The conditions that needs to be met for executing rollover</param>

src/Elasticsearch.Net/ElasticLowLevelClient.NoNamespace.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,34 @@ public TResponse PutScript<TResponse>(string id, string context, PostData body,
741741
[MapsApi("put_script", "id, context, body")]
742742
public Task<TResponse> PutScriptAsync<TResponse>(string id, string context, PostData body, PutScriptRequestParameters requestParameters = null, CancellationToken ctx = default)
743743
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(PUT, Url($"_scripts/{id:id}/{context:context}"), ctx, body, RequestParams(requestParameters));
744+
///<summary>POST on /_rank_eval <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html</para></summary>
745+
///<param name = "body">The ranking evaluation search definition, including search requests, document ratings and ranking metric definition.</param>
746+
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
747+
///<remarks>Note: Experimental within the Elasticsearch server, this functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features. This functionality is subject to potential breaking changes within a minor version, meaning that your referencing code may break when this library is upgraded.</remarks>
748+
public TResponse RankEval<TResponse>(PostData body, RankEvalRequestParameters requestParameters = null)
749+
where TResponse : class, IElasticsearchResponse, new() => DoRequest<TResponse>(POST, "_rank_eval", body, RequestParams(requestParameters));
750+
///<summary>POST on /_rank_eval <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html</para></summary>
751+
///<param name = "body">The ranking evaluation search definition, including search requests, document ratings and ranking metric definition.</param>
752+
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
753+
///<remarks>Note: Experimental within the Elasticsearch server, this functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features. This functionality is subject to potential breaking changes within a minor version, meaning that your referencing code may break when this library is upgraded.</remarks>
754+
[MapsApi("rank_eval", "body")]
755+
public Task<TResponse> RankEvalAsync<TResponse>(PostData body, RankEvalRequestParameters requestParameters = null, CancellationToken ctx = default)
756+
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(POST, "_rank_eval", ctx, body, RequestParams(requestParameters));
757+
///<summary>POST on /{index}/_rank_eval <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html</para></summary>
758+
///<param name = "index">A comma-separated list of index names to search; use the special string `_all` or Indices.All to perform the operation on all indices</param>
759+
///<param name = "body">The ranking evaluation search definition, including search requests, document ratings and ranking metric definition.</param>
760+
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
761+
///<remarks>Note: Experimental within the Elasticsearch server, this functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features. This functionality is subject to potential breaking changes within a minor version, meaning that your referencing code may break when this library is upgraded.</remarks>
762+
public TResponse RankEval<TResponse>(string index, PostData body, RankEvalRequestParameters requestParameters = null)
763+
where TResponse : class, IElasticsearchResponse, new() => DoRequest<TResponse>(POST, Url($"{index:index}/_rank_eval"), body, RequestParams(requestParameters));
764+
///<summary>POST on /{index}/_rank_eval <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html</para></summary>
765+
///<param name = "index">A comma-separated list of index names to search; use the special string `_all` or Indices.All to perform the operation on all indices</param>
766+
///<param name = "body">The ranking evaluation search definition, including search requests, document ratings and ranking metric definition.</param>
767+
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
768+
///<remarks>Note: Experimental within the Elasticsearch server, this functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features. This functionality is subject to potential breaking changes within a minor version, meaning that your referencing code may break when this library is upgraded.</remarks>
769+
[MapsApi("rank_eval", "index, body")]
770+
public Task<TResponse> RankEvalAsync<TResponse>(string index, PostData body, RankEvalRequestParameters requestParameters = null, CancellationToken ctx = default)
771+
where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync<TResponse>(POST, Url($"{index:index}/_rank_eval"), ctx, body, RequestParams(requestParameters));
744772
///<summary>POST on /_reindex <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html</para></summary>
745773
///<param name = "body">The search definition using the Query DSL and the prototype for the index request.</param>
746774
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>

0 commit comments

Comments
 (0)