diff --git a/.github/check-license-headers.sh b/.github/check-license-headers.sh index bcd8a3c75b7..03f3880dbba 100755 --- a/.github/check-license-headers.sh +++ b/.github/check-license-headers.sh @@ -16,7 +16,7 @@ NLINES=$(wc -l .github/license-header.txt | awk '{print $1}') function check_license_header { local f f=$1 - if ! diff .github/license-header.txt <(head -$NLINES "$f") >/dev/null; then + if ! diff -a --strip-trailing-cr .github/license-header.txt <(head -$NLINES "$f") >/dev/null; then echo "check-license-headers: error: '$f' does not have required license header, see 'diff -u .github/license-header.txt <(head -$NLINES $f)'" return 1 else diff --git a/src/ApiGenerator/Configuration/CodeConfiguration.cs b/src/ApiGenerator/Configuration/CodeConfiguration.cs index f85db5084b9..22432dfd65e 100644 --- a/src/ApiGenerator/Configuration/CodeConfiguration.cs +++ b/src/ApiGenerator/Configuration/CodeConfiguration.cs @@ -99,10 +99,6 @@ public static class CodeConfiguration "cluster.get_component_template.json", // 7.8 experimental "cluster.put_component_template.json", // 7.8 experimental "cluster.exists_component_template.json", // 7.8 experimental - - "eql.search.json", // 7.9 beta - "eql.get.json", // 7.9 beta - "eql.delete.json", // 7.9 beta }; /// diff --git a/src/ApiGenerator/RestSpecification/_Patches/eql.search.patch.json b/src/ApiGenerator/RestSpecification/_Patches/eql.search.patch.json new file mode 100644 index 00000000000..df365fefc65 --- /dev/null +++ b/src/ApiGenerator/RestSpecification/_Patches/eql.search.patch.json @@ -0,0 +1,12 @@ +{ + "eql.search": { + "url": { + "parts": { + "index": { + "type" : "list", + "description" : "A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices" + } + } + } + } + } \ No newline at end of file diff --git a/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Eql.cs b/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Eql.cs index 4a23a34cdbc..5deb60a7bf4 100644 --- a/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Eql.cs +++ b/src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Eql.cs @@ -77,7 +77,7 @@ public class GetStatusRequestParameters : RequestParametersRequest options for Search https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html - public class SearchRequestParameters : RequestParameters + public class EqlSearchRequestParameters : RequestParameters { public override HttpMethod DefaultHttpMethod => HttpMethod.POST; public override bool SupportsBody => true; diff --git a/src/Elasticsearch.Net/ElasticLowLevelClient.Eql.cs b/src/Elasticsearch.Net/ElasticLowLevelClient.Eql.cs index bc0fc2ff9cc..09f6485be78 100644 --- a/src/Elasticsearch.Net/ElasticLowLevelClient.Eql.cs +++ b/src/Elasticsearch.Net/ElasticLowLevelClient.Eql.cs @@ -95,17 +95,17 @@ public TResponse GetStatus(string id, GetStatusRequestParameters requ public Task GetStatusAsync(string id, GetStatusRequestParameters requestParameters = null, CancellationToken ctx = default) where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(GET, Url($"_eql/search/status/{id:id}"), ctx, null, RequestParams(requestParameters)); ///POST on /{index}/_eql/search https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html - ///The name of the index to scope the operation + ///A comma-separated list of index names to search; use the special string `_all` or Indices.All to perform the operation on all indices ///Eql request body. Use the `query` to limit the query scope. ///Request specific configuration such as querystring parameters & request specific connection settings. - public TResponse Search(string index, PostData body, SearchRequestParameters requestParameters = null) + public TResponse Search(string index, PostData body, EqlSearchRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new() => DoRequest(POST, Url($"{index:index}/_eql/search"), body, RequestParams(requestParameters)); ///POST on /{index}/_eql/search https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html - ///The name of the index to scope the operation + ///A comma-separated list of index names to search; use the special string `_all` or Indices.All to perform the operation on all indices ///Eql request body. Use the `query` to limit the query scope. ///Request specific configuration such as querystring parameters & request specific connection settings. [MapsApi("eql.search", "index, body")] - public Task SearchAsync(string index, PostData body, SearchRequestParameters requestParameters = null, CancellationToken ctx = default) + public Task SearchAsync(string index, PostData body, EqlSearchRequestParameters requestParameters = null, CancellationToken ctx = default) where TResponse : class, IElasticsearchResponse, new() => DoRequestAsync(POST, Url($"{index:index}/_eql/search"), ctx, body, RequestParams(requestParameters)); } } \ No newline at end of file diff --git a/src/Nest/Descriptors.Eql.cs b/src/Nest/Descriptors.Eql.cs new file mode 100644 index 00000000000..68f0e0ba98c --- /dev/null +++ b/src/Nest/Descriptors.Eql.cs @@ -0,0 +1,83 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ----------------------------------------------- +// +// This file is automatically generated +// Please do not edit these files manually +// Run the following in the root of the repos: +// +// *NIX : ./build.sh codegen +// Windows : build.bat codegen +// +// ----------------------------------------------- +// ReSharper disable RedundantUsingDirective +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Linq.Expressions; +using Elasticsearch.Net; +using Elasticsearch.Net.Utf8Json; +using Elasticsearch.Net.Specification.EqlApi; + +// ReSharper disable RedundantBaseConstructorCall +// ReSharper disable UnusedTypeParameter +// ReSharper disable PartialMethodWithSinglePart +// ReSharper disable RedundantNameQualifier +namespace Nest +{ + ///Descriptor for Search https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + public partial class EqlSearchDescriptor : RequestDescriptorBase, EqlSearchRequestParameters, IEqlSearchRequest>, IEqlSearchRequest + { + internal override ApiUrls ApiUrls => ApiUrlsLookups.EqlSearch; + ////{index}/_eql/search + ///this parameter is required + public EqlSearchDescriptor(Indices index): base(r => r.Required("index", index)) + { + } + + ////{index}/_eql/search + public EqlSearchDescriptor(): this(typeof(TInferDocument)) + { + } + + // values part of the url path + Indices IEqlSearchRequest.Index => Self.RouteValues.Get("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 + public EqlSearchDescriptor Index(Indices index) => Assign(index, (a, v) => a.RouteValues.Required("index", v)); + ///a shortcut into calling Index(typeof(TOther)) + public EqlSearchDescriptor Index() + where TOther : class => Assign(typeof(TOther), (a, v) => a.RouteValues.Required("index", (Indices)v)); + ///A shortcut into calling Index(Indices.All) + public EqlSearchDescriptor AllIndices() => Index(Indices.All); + // Request parameters + ///Update the time interval in which the results (partial or final) for this search will be available + public EqlSearchDescriptor KeepAlive(Time keepalive) => Qs("keep_alive", keepalive); + ///Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) + public EqlSearchDescriptor KeepOnCompletion(bool? keeponcompletion = true) => Qs("keep_on_completion", keeponcompletion); + ///Specify the time that the request should block waiting for the final response + public EqlSearchDescriptor WaitForCompletionTimeout(Time waitforcompletiontimeout) => Qs("wait_for_completion_timeout", waitforcompletiontimeout); + } +} \ No newline at end of file diff --git a/src/Nest/ElasticClient.Eql.cs b/src/Nest/ElasticClient.Eql.cs new file mode 100644 index 00000000000..23c5b658e65 --- /dev/null +++ b/src/Nest/ElasticClient.Eql.cs @@ -0,0 +1,100 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ----------------------------------------------- +// +// This file is automatically generated +// Please do not edit these files manually +// Run the following in the root of the repos: +// +// *NIX : ./build.sh codegen +// Windows : build.bat codegen +// +// ----------------------------------------------- +// ReSharper disable RedundantUsingDirective +using System; +using System.Threading; +using System.Threading.Tasks; +using Elasticsearch.Net.Specification.EqlApi; + +// ReSharper disable once CheckNamespace +// ReSharper disable RedundantTypeArgumentsOfMethod +namespace Nest.Specification.EqlApi +{ + /// + /// Eql APIs. + /// Not intended to be instantiated directly. Use the property + /// on . + /// + /// + public class EqlNamespace : NamespacedClientProxy + { + internal EqlNamespace(ElasticClient client): base(client) + { + } + + /// + /// POST request to the eql.search API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + /// + public EqlSearchResponse Search(Func, IEqlSearchRequest> selector = null) + where TInferDocument : class where TDocument : class => Search(selector.InvokeOrDefault(new EqlSearchDescriptor())); + /// + /// POST request to the eql.search API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + /// + public Task> SearchAsync(Func, IEqlSearchRequest> selector = null, CancellationToken ct = default) + where TInferDocument : class where TDocument : class => SearchAsync(selector.InvokeOrDefault(new EqlSearchDescriptor()), ct); + /// + /// POST request to the eql.search API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + /// + public EqlSearchResponse Search(Func, IEqlSearchRequest> selector = null) + where TDocument : class => Search(selector.InvokeOrDefault(new EqlSearchDescriptor())); + /// + /// POST request to the eql.search API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + /// + public Task> SearchAsync(Func, IEqlSearchRequest> selector = null, CancellationToken ct = default) + where TDocument : class => SearchAsync(selector.InvokeOrDefault(new EqlSearchDescriptor()), ct); + /// + /// POST request to the eql.search API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + /// + public EqlSearchResponse Search(IEqlSearchRequest request) + where TDocument : class => DoRequest>(request, request.RequestParameters); + /// + /// POST request to the eql.search API, read more about this API online: + /// + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + /// + public Task> SearchAsync(IEqlSearchRequest request, CancellationToken ct = default) + where TDocument : class => DoRequestAsync>(request, request.RequestParameters, ct); + } +} \ No newline at end of file diff --git a/src/Nest/ElasticClient.NoNamespace.cs b/src/Nest/ElasticClient.NoNamespace.cs index 8c86e6ccac6..27e72e25032 100644 --- a/src/Nest/ElasticClient.NoNamespace.cs +++ b/src/Nest/ElasticClient.NoNamespace.cs @@ -43,6 +43,7 @@ using Nest.Specification.CrossClusterReplicationApi; using Nest.Specification.DanglingIndicesApi; using Nest.Specification.EnrichApi; +using Nest.Specification.EqlApi; using Nest.Specification.GraphApi; using Nest.Specification.IndexLifecycleManagementApi; using Nest.Specification.IndicesApi; @@ -111,6 +112,13 @@ public EnrichNamespace Enrich private set; } + ///Eql APIs + public EqlNamespace Eql + { + get; + private set; + } + ///Graph APIs public GraphNamespace Graph { @@ -238,6 +246,7 @@ partial void SetupNamespaces() CrossClusterReplication = new CrossClusterReplicationNamespace(this); DanglingIndices = new DanglingIndicesNamespace(this); Enrich = new EnrichNamespace(this); + Eql = new EqlNamespace(this); Graph = new GraphNamespace(this); IndexLifecycleManagement = new IndexLifecycleManagementNamespace(this); Indices = new IndicesNamespace(this); diff --git a/src/Nest/IElasticClient.Generated.cs b/src/Nest/IElasticClient.Generated.cs index 7e273093066..40b52f13fc2 100644 --- a/src/Nest/IElasticClient.Generated.cs +++ b/src/Nest/IElasticClient.Generated.cs @@ -45,6 +45,7 @@ using Nest.Specification.CrossClusterReplicationApi; using Nest.Specification.DanglingIndicesApi; using Nest.Specification.EnrichApi; +using Nest.Specification.EqlApi; using Nest.Specification.GraphApi; using Nest.Specification.IndexLifecycleManagementApi; using Nest.Specification.IndicesApi; @@ -106,6 +107,12 @@ EnrichNamespace Enrich get; } + ///Eql APIs + EqlNamespace Eql + { + get; + } + ///Graph APIs GraphNamespace Graph { diff --git a/src/Nest/Requests.Eql.cs b/src/Nest/Requests.Eql.cs new file mode 100644 index 00000000000..1d784d51c1c --- /dev/null +++ b/src/Nest/Requests.Eql.cs @@ -0,0 +1,126 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ----------------------------------------------- +// +// This file is automatically generated +// Please do not edit these files manually +// Run the following in the root of the repos: +// +// *NIX : ./build.sh codegen +// Windows : build.bat codegen +// +// ----------------------------------------------- +// ReSharper disable RedundantUsingDirective +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Linq.Expressions; +using System.Runtime.Serialization; +using Elasticsearch.Net; +using Elasticsearch.Net.Utf8Json; +using Elasticsearch.Net.Specification.EqlApi; + +// ReSharper disable RedundantBaseConstructorCall +// ReSharper disable UnusedTypeParameter +// ReSharper disable PartialMethodWithSinglePart +// ReSharper disable RedundantNameQualifier +namespace Nest +{ + [InterfaceDataContract] + public partial interface IEqlSearchRequest : IRequest + { + [IgnoreDataMember] + Indices Index + { + get; + } + } + + public partial interface IEqlSearchRequest : IEqlSearchRequest + { + } + + ///Request for Search https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html + public partial class EqlSearchRequest : PlainRequestBase, IEqlSearchRequest + { + protected IEqlSearchRequest Self => this; + internal override ApiUrls ApiUrls => ApiUrlsLookups.EqlSearch; + ////{index}/_eql/search + ///this parameter is required + public EqlSearchRequest(Indices index): base(r => r.Required("index", index)) + { + } + + ///Used for serialization purposes, making sure we have a parameterless constructor + [SerializationConstructor] + protected EqlSearchRequest(): base() + { + } + + // values part of the url path + [IgnoreDataMember] + Indices IEqlSearchRequest.Index => Self.RouteValues.Get("index"); + // Request parameters + ///Update the time interval in which the results (partial or final) for this search will be available + public Time KeepAlive + { + get => Q