From c5fa7fafe0efab9a087098d3d47cb88d1c61d63f Mon Sep 17 00:00:00 2001 From: codebrain Date: Fri, 10 Nov 2017 13:28:13 +1100 Subject: [PATCH 1/6] Implementation of: IngestGrokProcessor, NodesUsage and DeprecationInfo --- .../RequestParameters.Generated.cs | 12 +-- .../ElasticLowLevelClient.Generated.cs | 8 +- .../IElasticLowLevelClient.Generated.cs | 8 +- .../NodesUsage/ElasticClient-NodesUsage.cs | 55 +++++++++++++ .../Cluster/NodesUsage/NodeUsageResponse.cs | 53 ++++++++++++ .../Cluster/NodesUsage/NodesUsageRequest.cs | 9 ++ .../ElasticClient-IngestProcessorGrok.cs | 55 +++++++++++++ .../Processor/IngestProcessorGrokRequest.cs | 9 ++ .../Processor/IngestProcessorGrokResponse.cs | 17 ++++ .../DeprecationInfo/DeprecationInfoRequest.cs | 9 ++ .../DeprecationInfoResponse.cs | 56 +++++++++++++ .../ElasticClient-DeprecationInfo.cs | 48 +++++++++++ src/Nest/_Generated/_Descriptors.generated.cs | 29 +++---- .../_Generated/_LowLevelDispatch.generated.cs | 4 +- src/Nest/_Generated/_Requests.generated.cs | 82 +++++++++---------- .../Cluster/NodesUsage/NodesUsageApiTests.cs | 46 +++++++++++ .../Cluster/NodesUsage/NodesUsageUnitTests.cs | 40 +++++++++ .../Cluster/NodesUsage/NodesUsageUrlTests.cs | 44 ++++++++++ .../CodeStandards/NamingConventions.doc.cs | 8 +- src/Tests/Framework/TestClient.cs | 17 +++- .../Processor/IngestProcessorGrokApiTests.cs | 32 ++++++++ .../Processor/IngestProcessorGrokTests.cs | 20 +++++ .../Processor/IngestProcessorGrokUnitTests.cs | 26 ++++++ src/Tests/Tests.csproj | 4 +- .../DeprecationInfoUnitTests.cs | 42 ++++++++++ .../DeprecationInfoUrlTests.cs | 31 +++++++ 26 files changed, 672 insertions(+), 92 deletions(-) create mode 100644 src/Nest/Cluster/NodesUsage/ElasticClient-NodesUsage.cs create mode 100644 src/Nest/Cluster/NodesUsage/NodeUsageResponse.cs create mode 100644 src/Nest/Cluster/NodesUsage/NodesUsageRequest.cs create mode 100644 src/Nest/Ingest/Processor/ElasticClient-IngestProcessorGrok.cs create mode 100644 src/Nest/Ingest/Processor/IngestProcessorGrokRequest.cs create mode 100644 src/Nest/Ingest/Processor/IngestProcessorGrokResponse.cs create mode 100644 src/Nest/XPack/DeprecationInfo/DeprecationInfoRequest.cs create mode 100644 src/Nest/XPack/DeprecationInfo/DeprecationInfoResponse.cs create mode 100644 src/Nest/XPack/DeprecationInfo/ElasticClient-DeprecationInfo.cs create mode 100644 src/Tests/Cluster/NodesUsage/NodesUsageApiTests.cs create mode 100644 src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs create mode 100644 src/Tests/Cluster/NodesUsage/NodesUsageUrlTests.cs create mode 100644 src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs create mode 100644 src/Tests/Ingest/Processor/IngestProcessorGrokTests.cs create mode 100644 src/Tests/Ingest/Processor/IngestProcessorGrokUnitTests.cs create mode 100644 src/Tests/XPack/DeprecationInfo/DeprecationInfoUnitTests.cs create mode 100644 src/Tests/XPack/DeprecationInfo/DeprecationInfoUrlTests.cs diff --git a/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs b/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs index 23f5748c186..eec06e2a4d9 100644 --- a/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs +++ b/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs @@ -6295,28 +6295,28 @@ public class GraphExploreRequestParameters : FluentRequestParameters /// - public class XpackDeprecationInfoRequestParameters : FluentRequestParameters + public class DeprecationInfoRequestParameters : FluentRequestParameters { public override HttpMethod DefaultHttpMethod => HttpMethod.GET; ///Pretty format the returned JSON response. - public XpackDeprecationInfoRequestParameters Pretty(bool pretty) => this.AddQueryString("pretty", pretty); + public DeprecationInfoRequestParameters Pretty(bool pretty) => this.AddQueryString("pretty", pretty); ///Return human readable values for statistics. - public XpackDeprecationInfoRequestParameters Human(bool human) => this.AddQueryString("human", human); + public DeprecationInfoRequestParameters Human(bool human) => this.AddQueryString("human", human); ///Include the stack trace of returned errors. - public XpackDeprecationInfoRequestParameters ErrorTrace(bool error_trace) => this.AddQueryString("error_trace", error_trace); + public DeprecationInfoRequestParameters ErrorTrace(bool error_trace) => this.AddQueryString("error_trace", error_trace); ///The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - public XpackDeprecationInfoRequestParameters Source(string source) => this.AddQueryString("source", source); + public DeprecationInfoRequestParameters Source(string source) => this.AddQueryString("source", source); ///A comma-separated list of filters used to reduce the respone. - public XpackDeprecationInfoRequestParameters FilterPath(params string[] filter_path) => this.AddQueryString("filter_path", filter_path); + public DeprecationInfoRequestParameters FilterPath(params string[] filter_path) => this.AddQueryString("filter_path", filter_path); } diff --git a/src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs b/src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs index 7615bf2fd03..ee967a3008b 100644 --- a/src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs +++ b/src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs @@ -7794,7 +7794,7 @@ public ElasticsearchResponse XpackGraphExplore(string index, string type, ///See also: http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html /// ///A func that allows you to describe the querystring parameters & request specific connection settings. - public ElasticsearchResponse XpackDeprecationInfo(Func requestParameters = null) + public ElasticsearchResponse XpackDeprecationInfo(Func requestParameters = null) where T : class => this.DoRequest(GET, Url($"_xpack/migration/deprecations"), null, _params(requestParameters)); ///Represents a GET on /_xpack/migration/deprecations @@ -7807,7 +7807,7 @@ public ElasticsearchResponse XpackDeprecationInfo(FuncSee also: http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html /// ///A func that allows you to describe the querystring parameters & request specific connection settings. - public Task> XpackDeprecationInfoAsync(Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) + public Task> XpackDeprecationInfoAsync(Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class => this.DoRequestAsync(GET, Url($"_xpack/migration/deprecations"), cancellationToken, null, _params(requestParameters)); ///Represents a GET on /{index}/_xpack/migration/deprecations @@ -7821,7 +7821,7 @@ public ElasticsearchResponse XpackDeprecationInfo(Func ///Index pattern ///A func that allows you to describe the querystring parameters & request specific connection settings. - public ElasticsearchResponse XpackDeprecationInfo(string index, Func requestParameters = null) + public ElasticsearchResponse XpackDeprecationInfo(string index, Func requestParameters = null) where T : class => this.DoRequest(GET, Url($"{index.NotNull("index")}/_xpack/migration/deprecations"), null, _params(requestParameters)); ///Represents a GET on /{index}/_xpack/migration/deprecations @@ -7835,7 +7835,7 @@ public ElasticsearchResponse XpackDeprecationInfo(string index, Func ///Index pattern ///A func that allows you to describe the querystring parameters & request specific connection settings. - public Task> XpackDeprecationInfoAsync(string index, Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) + public Task> XpackDeprecationInfoAsync(string index, Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class => this.DoRequestAsync(GET, Url($"{index.NotNull("index")}/_xpack/migration/deprecations"), cancellationToken, null, _params(requestParameters)); ///Represents a GET on /_xpack diff --git a/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs b/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs index 0b1fe8c2cb5..862c7caec57 100644 --- a/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs +++ b/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs @@ -7257,7 +7257,7 @@ public partial interface IElasticLowLevelClient ///See also: http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html /// ///A func that allows you to describe the querystring parameters & request specific connection settings. - ElasticsearchResponse XpackDeprecationInfo(Func requestParameters = null) where T : class; + ElasticsearchResponse XpackDeprecationInfo(Func requestParameters = null) where T : class; ///Represents a GET on /_xpack/migration/deprecations ///Returns: A task of ElasticsearchResponse<T> where the behaviour depends on the type of T: @@ -7269,7 +7269,7 @@ public partial interface IElasticLowLevelClient ///See also: http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html /// ///A func that allows you to describe the querystring parameters & request specific connection settings. - Task> XpackDeprecationInfoAsync(Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class; + Task> XpackDeprecationInfoAsync(Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class; ///Represents a GET on /{index}/_xpack/migration/deprecations ///Returns: ElasticsearchResponse<T> where the behavior depends on the type of T: @@ -7282,7 +7282,7 @@ public partial interface IElasticLowLevelClient /// ///Index pattern ///A func that allows you to describe the querystring parameters & request specific connection settings. - ElasticsearchResponse XpackDeprecationInfo(string index, Func requestParameters = null) where T : class; + ElasticsearchResponse XpackDeprecationInfo(string index, Func requestParameters = null) where T : class; ///Represents a GET on /{index}/_xpack/migration/deprecations ///Returns: A task of ElasticsearchResponse<T> where the behaviour depends on the type of T: @@ -7295,7 +7295,7 @@ public partial interface IElasticLowLevelClient /// ///Index pattern ///A func that allows you to describe the querystring parameters & request specific connection settings. - Task> XpackDeprecationInfoAsync(string index, Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class; + Task> XpackDeprecationInfoAsync(string index, Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class; ///Represents a GET on /_xpack ///Returns: ElasticsearchResponse<T> where the behavior depends on the type of T: diff --git a/src/Nest/Cluster/NodesUsage/ElasticClient-NodesUsage.cs b/src/Nest/Cluster/NodesUsage/ElasticClient-NodesUsage.cs new file mode 100644 index 00000000000..8c75b05cf8f --- /dev/null +++ b/src/Nest/Cluster/NodesUsage/ElasticClient-NodesUsage.cs @@ -0,0 +1,55 @@ +using System; +using System.IO; +using System.Threading.Tasks; +using Elasticsearch.Net; + +namespace Nest +{ + using System.Threading; + using NodesHotThreadConverter = Func; + + public partial interface IElasticClient + { + /// + /// The cluster nodes usage API allows to retrieve information on the usage of features for each node. + /// https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html + /// + /// An optional descriptor to further describe the nodes usage operation + INodesUsageResponse NodesUsage(Func selector = null); + + /// + INodesUsageResponse NodesUsage(INodesUsageRequest request); + + /// + Task NodesUsageAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + Task NodesUsageAsync(INodesUsageRequest request, CancellationToken cancellationToken = default(CancellationToken)); + } + + public partial class ElasticClient + { + /// + public INodesUsageResponse NodesUsage(Func selector = null) => + this.NodesUsage(selector.InvokeOrDefault(new NodesUsageDescriptor())); + + /// + public INodesUsageResponse NodesUsage(INodesUsageRequest request) => + this.Dispatcher.Dispatch( + request, + (p, d) => this.LowLevelDispatch.NodesUsageDispatch(p) + ); + + /// + public Task NodesUsageAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => + this.NodesUsageAsync(selector.InvokeOrDefault(new NodesUsageDescriptor()), cancellationToken); + + /// + public Task NodesUsageAsync(INodesUsageRequest request, CancellationToken cancellationToken = default(CancellationToken)) => + this.Dispatcher.DispatchAsync( + request, + cancellationToken, + (p, d, c) => this.LowLevelDispatch.NodesUsageDispatchAsync(p, c) + ); + } +} diff --git a/src/Nest/Cluster/NodesUsage/NodeUsageResponse.cs b/src/Nest/Cluster/NodesUsage/NodeUsageResponse.cs new file mode 100644 index 00000000000..0df47455066 --- /dev/null +++ b/src/Nest/Cluster/NodesUsage/NodeUsageResponse.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Nest +{ + public class NodeUsageMetadata + { + [JsonProperty(PropertyName = "total")] + public int Total { get; internal set; } + + [JsonProperty(PropertyName = "successful")] + public int Successful { get; internal set; } + + [JsonProperty(PropertyName = "failed")] + public int Failed { get; internal set; } + } + + public class NodeUsageInformation + { + [JsonProperty(PropertyName = "timestamp")] + [JsonConverter(typeof(EpochMillisecondsDateTimeJsonConverter))] + public DateTimeOffset Timestamp { get; internal set; } + + [JsonProperty(PropertyName = "since")] + [JsonConverter(typeof(EpochMillisecondsDateTimeJsonConverter))] + public DateTimeOffset Since { get; internal set; } + + [JsonProperty(PropertyName = "rest_actions")] + public IReadOnlyDictionary RestActions { get; internal set; } + } + + public interface INodesUsageResponse : IResponse + { + string ClusterName { get; } + + IReadOnlyDictionary Nodes { get; } + + NodeUsageMetadata NodeMetadata { get; } + } + + public class NodesUsageResponse : ResponseBase, INodesUsageResponse + { + [JsonProperty(PropertyName = "cluster_name")] + public string ClusterName { get; internal set; } + + [JsonProperty(PropertyName = "nodes")] + public IReadOnlyDictionary Nodes { get; internal set; } = EmptyReadOnly.Dictionary; + + [JsonProperty(PropertyName = "_nodes")] + public NodeUsageMetadata NodeMetadata { get; internal set; } + } +} diff --git a/src/Nest/Cluster/NodesUsage/NodesUsageRequest.cs b/src/Nest/Cluster/NodesUsage/NodesUsageRequest.cs new file mode 100644 index 00000000000..0ff28c31084 --- /dev/null +++ b/src/Nest/Cluster/NodesUsage/NodesUsageRequest.cs @@ -0,0 +1,9 @@ +namespace Nest +{ + public partial interface INodesUsageRequest { } + + public partial class NodesUsageRequest { } + + [DescriptorFor("NodesUsage")] + public partial class NodesUsageDescriptor { } +} diff --git a/src/Nest/Ingest/Processor/ElasticClient-IngestProcessorGrok.cs b/src/Nest/Ingest/Processor/ElasticClient-IngestProcessorGrok.cs new file mode 100644 index 00000000000..9dd447745ef --- /dev/null +++ b/src/Nest/Ingest/Processor/ElasticClient-IngestProcessorGrok.cs @@ -0,0 +1,55 @@ +using System; +using System.IO; +using System.Threading.Tasks; +using Elasticsearch.Net; + +namespace Nest +{ + using System.Threading; + using NodesHotThreadConverter = Func; + + public partial interface IElasticClient + { + /// + /// Retrieving which patterns which the grok processor is packaged with, useful as different versions are bundled with different processors. + /// https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html + /// + /// An optional descriptor to further describe the endpoint usage operation + IIngestProcessorGrokResponse IngestProcessorGrok(Func selector = null); + + /// + IIngestProcessorGrokResponse IngestProcessorGrok(IIngestProcessorGrokRequest request); + + /// + Task IngestProcessorGrokAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + Task IngestProcessorGrokAsync(IIngestProcessorGrokRequest request, CancellationToken cancellationToken = default(CancellationToken)); + } + + public partial class ElasticClient + { + /// + public IIngestProcessorGrokResponse IngestProcessorGrok(Func selector = null) => + this.IngestProcessorGrok(selector.InvokeOrDefault(new IngestProcessorGrokDescriptor())); + + /// + public IIngestProcessorGrokResponse IngestProcessorGrok(IIngestProcessorGrokRequest request) => + this.Dispatcher.Dispatch( + request, + (p, d) => this.LowLevelDispatch.IngestProcessorGrokDispatch(p) + ); + + /// + public Task IngestProcessorGrokAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => + this.IngestProcessorGrokAsync(selector.InvokeOrDefault(new IngestProcessorGrokDescriptor()), cancellationToken); + + /// + public Task IngestProcessorGrokAsync(IIngestProcessorGrokRequest request, CancellationToken cancellationToken = default(CancellationToken)) => + this.Dispatcher.DispatchAsync( + request, + cancellationToken, + (p, d, c) => this.LowLevelDispatch.IngestProcessorGrokDispatchAsync(p, c) + ); + } +} diff --git a/src/Nest/Ingest/Processor/IngestProcessorGrokRequest.cs b/src/Nest/Ingest/Processor/IngestProcessorGrokRequest.cs new file mode 100644 index 00000000000..a8862b3ff04 --- /dev/null +++ b/src/Nest/Ingest/Processor/IngestProcessorGrokRequest.cs @@ -0,0 +1,9 @@ +namespace Nest +{ + public partial interface IIngestProcessorGrokRequest { } + + public partial class IngestProcessorGrokRequest { } + + [DescriptorFor("IngestProcessorGrok")] + public partial class IngestProcessorGrokDescriptor { } +} diff --git a/src/Nest/Ingest/Processor/IngestProcessorGrokResponse.cs b/src/Nest/Ingest/Processor/IngestProcessorGrokResponse.cs new file mode 100644 index 00000000000..cb4e7c47674 --- /dev/null +++ b/src/Nest/Ingest/Processor/IngestProcessorGrokResponse.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Nest +{ + public interface IIngestProcessorGrokResponse : IResponse + { + IReadOnlyDictionary Patterns { get; } + } + + public class IngestProcessorGrokResponse : ResponseBase, IIngestProcessorGrokResponse + { + [JsonProperty(PropertyName = "patterns")] + public IReadOnlyDictionary Patterns { get; internal set; } = EmptyReadOnly.Dictionary; + } +} diff --git a/src/Nest/XPack/DeprecationInfo/DeprecationInfoRequest.cs b/src/Nest/XPack/DeprecationInfo/DeprecationInfoRequest.cs new file mode 100644 index 00000000000..c06d0dd4609 --- /dev/null +++ b/src/Nest/XPack/DeprecationInfo/DeprecationInfoRequest.cs @@ -0,0 +1,9 @@ +namespace Nest +{ + public partial interface IDeprecationInfoRequest { } + + public partial class DeprecationInfoRequest { } + + [DescriptorFor("XpackDeprecationInfo")] + public partial class DeprecationInfoDescriptor : IDeprecationInfoRequest { } +} diff --git a/src/Nest/XPack/DeprecationInfo/DeprecationInfoResponse.cs b/src/Nest/XPack/DeprecationInfo/DeprecationInfoResponse.cs new file mode 100644 index 00000000000..29da3c1459b --- /dev/null +++ b/src/Nest/XPack/DeprecationInfo/DeprecationInfoResponse.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Nest +{ + [JsonConverter(typeof(StringEnumConverter))] + public enum DeprecationWarningLevel + { + [EnumMember(Value = "none")] + None, + [EnumMember(Value = "info")] + Information, + [EnumMember(Value = "warning")] + Warning, + [EnumMember(Value = "critical")] + Critical + } + + public class DeprecationInfoItem + { + [JsonProperty("level")] + public DeprecationWarningLevel Level { get; internal set; } + + [JsonProperty("message")] + public string Message { get; internal set; } + + [JsonProperty("url")] + public string Url { get; internal set; } + + [JsonProperty("details")] + public string Details { get; internal set; } + } + + public interface IDeprecationInfoResponse : IResponse + { + [JsonProperty("cluster_settings")] + IReadOnlyCollection ClusterSettings { get; } + + [JsonProperty("node_settings")] + IReadOnlyCollection NodeSettings { get; } + + [JsonProperty("index_settings")] + IReadOnlyDictionary> IndexSettings { get; } + } + + public class DeprecationInfoResponse : ResponseBase, IDeprecationInfoResponse + { + public IReadOnlyCollection ClusterSettings { get; internal set; } = EmptyReadOnly.Collection; + public IReadOnlyCollection NodeSettings { get; internal set; } = EmptyReadOnly.Collection; + public IReadOnlyDictionary> IndexSettings { get; internal set; } = EmptyReadOnly>.Dictionary; + } +} diff --git a/src/Nest/XPack/DeprecationInfo/ElasticClient-DeprecationInfo.cs b/src/Nest/XPack/DeprecationInfo/ElasticClient-DeprecationInfo.cs new file mode 100644 index 00000000000..48a580d4505 --- /dev/null +++ b/src/Nest/XPack/DeprecationInfo/ElasticClient-DeprecationInfo.cs @@ -0,0 +1,48 @@ +using System; +using System.Threading.Tasks; +using Elasticsearch.Net; +using System.Threading; + +namespace Nest +{ + public partial interface IElasticClient + { + /// + IDeprecationInfoResponse DeprecationInfo(Func selector = null); + + /// + IDeprecationInfoResponse DeprecationInfo(IDeprecationInfoRequest request); + + /// + Task DeprecationInfoAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + Task DeprecationInfoAsync(IDeprecationInfoRequest request, CancellationToken cancellationToken = default(CancellationToken)); + } + + public partial class ElasticClient + { + /// + public IDeprecationInfoResponse DeprecationInfo(Func selector = null) => + this.DeprecationInfo(selector.InvokeOrDefault(new DeprecationInfoDescriptor())); + + /// + public IDeprecationInfoResponse DeprecationInfo(IDeprecationInfoRequest request) => + this.Dispatcher.Dispatch( + request, + (p, d) =>this.LowLevelDispatch.XpackDeprecationInfoDispatch(p) + ); + + /// + public Task DeprecationInfoAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => + this.DeprecationInfoAsync(selector.InvokeOrDefault(new DeprecationInfoDescriptor()), cancellationToken); + + /// + public Task DeprecationInfoAsync(IDeprecationInfoRequest request, CancellationToken cancellationToken = default(CancellationToken)) => + this.Dispatcher.DispatchAsync( + request, + cancellationToken, + (p, d, c) => this.LowLevelDispatch.XpackDeprecationInfoDispatchAsync(p, c) + ); + } +} diff --git a/src/Nest/_Generated/_Descriptors.generated.cs b/src/Nest/_Generated/_Descriptors.generated.cs index 6cf3cced28e..f2afcbe66e9 100644 --- a/src/Nest/_Generated/_Descriptors.generated.cs +++ b/src/Nest/_Generated/_Descriptors.generated.cs @@ -4335,9 +4335,6 @@ public partial class IngestProcessorGrokDescriptor : RequestDescriptorBaseA comma-separated list of filters used to reduce the respone. public IngestProcessorGrokDescriptor FilterPath(params string[] filter_path) => AssignParam(p=>p.FilterPath(filter_path)); - - //TODO THIS METHOD IS UNMAPPED! - } @@ -4863,9 +4860,6 @@ public NodesUsageDescriptor() : base(){} ///A comma-separated list of filters used to reduce the respone. public NodesUsageDescriptor FilterPath(params string[] filter_path) => AssignParam(p=>p.FilterPath(filter_path)); - - //TODO THIS METHOD IS UNMAPPED! - } @@ -6135,37 +6129,34 @@ public GraphExploreDescriptor(Indices index) : base(r=>r.Required("index", index } ///descriptor for XpackDeprecationInfo
http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html
- public partial class XpackDeprecationInfoDescriptor : RequestDescriptorBase, IXpackDeprecationInfoRequest + public partial class DeprecationInfoDescriptor : RequestDescriptorBase, IDeprecationInfoRequest { - IndexName IXpackDeprecationInfoRequest.Index => Self.RouteValues.Get("index"); + IndexName IDeprecationInfoRequest.Index => Self.RouteValues.Get("index"); /// /_xpack/migration/deprecations - public XpackDeprecationInfoDescriptor() : base(){} + public DeprecationInfoDescriptor() : base(){} ///Index pattern - public XpackDeprecationInfoDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Optional("index", index)); + public DeprecationInfoDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Optional("index", index)); ///a shortcut into calling Index(typeof(TOther)) - public XpackDeprecationInfoDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (IndexName)typeof(TOther))); + public DeprecationInfoDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (IndexName)typeof(TOther))); ///Pretty format the returned JSON response. - public XpackDeprecationInfoDescriptor Pretty(bool pretty = true) => AssignParam(p=>p.Pretty(pretty)); + public DeprecationInfoDescriptor Pretty(bool pretty = true) => AssignParam(p=>p.Pretty(pretty)); ///Return human readable values for statistics. - public XpackDeprecationInfoDescriptor Human(bool human = true) => AssignParam(p=>p.Human(human)); + public DeprecationInfoDescriptor Human(bool human = true) => AssignParam(p=>p.Human(human)); ///Include the stack trace of returned errors. - public XpackDeprecationInfoDescriptor ErrorTrace(bool error_trace = true) => AssignParam(p=>p.ErrorTrace(error_trace)); + public DeprecationInfoDescriptor ErrorTrace(bool error_trace = true) => AssignParam(p=>p.ErrorTrace(error_trace)); ///The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - public XpackDeprecationInfoDescriptor Source(string source) => AssignParam(p=>p.Source(source)); + public DeprecationInfoDescriptor Source(string source) => AssignParam(p=>p.Source(source)); ///A comma-separated list of filters used to reduce the respone. - public XpackDeprecationInfoDescriptor FilterPath(params string[] filter_path) => AssignParam(p=>p.FilterPath(filter_path)); - - //TODO THIS METHOD IS UNMAPPED! - + public DeprecationInfoDescriptor FilterPath(params string[] filter_path) => AssignParam(p=>p.FilterPath(filter_path)); } diff --git a/src/Nest/_Generated/_LowLevelDispatch.generated.cs b/src/Nest/_Generated/_LowLevelDispatch.generated.cs index cfe0fab3756..1f961e6e4c0 100644 --- a/src/Nest/_Generated/_LowLevelDispatch.generated.cs +++ b/src/Nest/_Generated/_LowLevelDispatch.generated.cs @@ -3182,7 +3182,7 @@ internal Task> XpackGraphExploreDispatchAsync(IReque throw InvalidDispatch("XpackGraphExplore", p, new [] { GET, POST }, "/{index}/_xpack/graph/_explore", "/{index}/{type}/_xpack/graph/_explore"); } - internal ElasticsearchResponse XpackDeprecationInfoDispatch(IRequest p ) where T : class + internal ElasticsearchResponse XpackDeprecationInfoDispatch(IRequest p ) where T : class { switch(p.HttpMethod) { @@ -3194,7 +3194,7 @@ internal ElasticsearchResponse XpackDeprecationInfoDispatch(IRequest> XpackDeprecationInfoDispatchAsync(IRequest p , CancellationToken cancellationToken) where T : class + internal Task> XpackDeprecationInfoDispatchAsync(IRequest p , CancellationToken cancellationToken) where T : class { switch(p.HttpMethod) { diff --git a/src/Nest/_Generated/_Requests.generated.cs b/src/Nest/_Generated/_Requests.generated.cs index 6e77d012df7..6063b3f3278 100644 --- a/src/Nest/_Generated/_Requests.generated.cs +++ b/src/Nest/_Generated/_Requests.generated.cs @@ -3338,6 +3338,42 @@ public DeleteWatchRequest(Id id) : base(r=>r.Required("id", id)){} } + [JsonObject(MemberSerialization = MemberSerialization.OptIn)] + public partial interface IDeprecationInfoRequest : IRequest + { + IndexName Index { get; } + } + ///Request parameters for XpackDeprecationInfo
http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html
+ public partial class DeprecationInfoRequest : PlainRequestBase, IDeprecationInfoRequest + { + protected IDeprecationInfoRequest Self => this; + IndexName IDeprecationInfoRequest.Index => Self.RouteValues.Get("index"); + /// /_xpack/migration/deprecations + public DeprecationInfoRequest() : base(){} + + + /// /{index}/_xpack/migration/deprecations +///Optional, accepts null + public DeprecationInfoRequest(IndexName index) : base(r=>r.Optional("index", index)){} + + + ///Pretty format the returned JSON response. + public bool Pretty { get { return Q("pretty"); } set { Q("pretty", value); } } + + ///Return human readable values for statistics. + public bool Human { get { return Q("human"); } set { Q("human", value); } } + + ///Include the stack trace of returned errors. + public bool ErrorTrace { get { return Q("error_trace"); } set { Q("error_trace", value); } } + + ///The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + public string Source { get { return Q("source"); } set { Q("source", value); } } + + ///A comma-separated list of filters used to reduce the respone. + public string[] FilterPath { get { return Q< string[]>("filter_path"); } set { Q("filter_path", value); } } + + } + [JsonObject(MemberSerialization = MemberSerialization.OptIn)] public partial interface IDisableUserRequest : IRequest { @@ -5463,9 +5499,7 @@ public partial class IngestProcessorGrokRequest : PlainRequestBaseA comma-separated list of filters used to reduce the respone.
public string[] FilterPath { get { return Q< string[]>("filter_path"); } set { Q("filter_path", value); } } - //TODO THIS METHOD IS UNMAPPED! - - } + } [JsonObject(MemberSerialization = MemberSerialization.OptIn)] public partial interface IInvalidateUserAccessTokenRequest : IRequest @@ -6042,9 +6076,7 @@ public NodesUsageRequest(NodeIds node_id, NodesUsageMetric metric) : base(r=>r.O ///A comma-separated list of filters used to reduce the respone. public string[] FilterPath { get { return Q< string[]>("filter_path"); } set { Q("filter_path", value); } } - //TODO THIS METHOD IS UNMAPPED! - - } + } [JsonObject(MemberSerialization = MemberSerialization.OptIn)] public partial interface IOpenIndexRequest : IRequest @@ -9223,44 +9255,6 @@ public WatcherStatsRequest(WatcherStatsMetric watcher_stats_metric) : base(r=>r. } - [JsonObject(MemberSerialization = MemberSerialization.OptIn)] - public partial interface IXpackDeprecationInfoRequest : IRequest - { - IndexName Index { get; } - } - ///Request parameters for XpackDeprecationInfo
http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html
- public partial class XpackDeprecationInfoRequest : PlainRequestBase, IXpackDeprecationInfoRequest - { - protected IXpackDeprecationInfoRequest Self => this; - IndexName IXpackDeprecationInfoRequest.Index => Self.RouteValues.Get("index"); - /// /_xpack/migration/deprecations - public XpackDeprecationInfoRequest() : base(){} - - - /// /{index}/_xpack/migration/deprecations -///Optional, accepts null - public XpackDeprecationInfoRequest(IndexName index) : base(r=>r.Optional("index", index)){} - - - ///Pretty format the returned JSON response. - public bool Pretty { get { return Q("pretty"); } set { Q("pretty", value); } } - - ///Return human readable values for statistics. - public bool Human { get { return Q("human"); } set { Q("human", value); } } - - ///Include the stack trace of returned errors. - public bool ErrorTrace { get { return Q("error_trace"); } set { Q("error_trace", value); } } - - ///The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - public string Source { get { return Q("source"); } set { Q("source", value); } } - - ///A comma-separated list of filters used to reduce the respone. - public string[] FilterPath { get { return Q< string[]>("filter_path"); } set { Q("filter_path", value); } } - - //TODO THIS METHOD IS UNMAPPED! - - } - [JsonObject(MemberSerialization = MemberSerialization.OptIn)] public partial interface IXPackInfoRequest : IRequest { diff --git a/src/Tests/Cluster/NodesUsage/NodesUsageApiTests.cs b/src/Tests/Cluster/NodesUsage/NodesUsageApiTests.cs new file mode 100644 index 00000000000..3a3958542ec --- /dev/null +++ b/src/Tests/Cluster/NodesUsage/NodesUsageApiTests.cs @@ -0,0 +1,46 @@ +using System; +using System.Linq; +using Elasticsearch.Net; +using FluentAssertions; +using Nest; +using Tests.Framework; +using Tests.Framework.Integration; +using Tests.Framework.ManagedElasticsearch.Clusters; +using Xunit; + +namespace Tests.Cluster.NodesUsage +{ + public class NodesUsageApiTests : ApiIntegrationTestBase + { + public NodesUsageApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + protected override LazyResponses ClientUsage() => Calls( + fluent: (client, f) => client.NodesUsage(), + fluentAsync: (client, f) => client.NodesUsageAsync(), + request: (client, r) => client.NodesUsage(r), + requestAsync: (client, r) => client.NodesUsageAsync(r) + ); + + protected override bool ExpectIsValid => true; + protected override int ExpectStatusCode => 200; + protected override HttpMethod HttpMethod => HttpMethod.GET; + protected override string UrlPath => "/_nodes/usage"; + + protected override void ExpectResponse(INodesUsageResponse response) + { + response.ClusterName.Should().NotBeEmpty(); + + response.NodeMetadata.Should().NotBeNull(); + response.NodeMetadata.Total.Should().Be(1); + response.NodeMetadata.Successful.Should().Be(1); + response.NodeMetadata.Failed.Should().Be(0); + + response.Nodes.Should().NotBeNull(); + response.Nodes.Should().HaveCount(1); + + response.Nodes.First().Value.Timestamp.Should().BeBefore(DateTimeOffset.UtcNow); + response.Nodes.First().Value.Since.Should().BeBefore(DateTimeOffset.UtcNow); + response.Nodes.First().Value.RestActions.Should().NotBeNull(); + } + } + +} diff --git a/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs b/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs new file mode 100644 index 00000000000..f4c36be74fe --- /dev/null +++ b/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs @@ -0,0 +1,40 @@ +using System; +using FluentAssertions; +using Tests.Framework; + +namespace Tests.XPack.DeprecationInfo +{ + public class NodesUsageUnitTests + { + [U] + public void ShouldDeserialize() + { + const string fixedResponse = "{\"_nodes\": {\"total\": 1,\"successful\": 1,\"failed\": 0},\"cluster_name\": \"my_cluster\",\"nodes\": {\"pQHNt5rXTTWNvUgOrdynKg\": {\"timestamp\": 1492553961812,\"since\": 1492553906606,\"rest_actions\": {\"org.elasticsearch.rest.action.admin.cluster.RestNodesUsageAction\": 1,\"org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction\": 1,\"org.elasticsearch.rest.action.document.RestGetAction\": 1,\"org.elasticsearch.rest.action.search.RestSearchAction\": 19,\"org.elasticsearch.rest.action.admin.cluster.RestNodesInfoAction\": 36}}}}"; + var client = TestClient.GetFixedReturnClient(fixedResponse); + + //warmup + var response = client.NodesUsage(); + response.ShouldBeValid(); + + response.ClusterName.Should().Be("my_cluster"); + + response.NodeMetadata.Should().NotBeNull(); + response.NodeMetadata.Total.Should().Be(1); + response.NodeMetadata.Successful.Should().Be(1); + response.NodeMetadata.Failed.Should().Be(0); + + response.Nodes.Should().NotBeNull(); + response.Nodes.Should().HaveCount(1); + + const string nodeId = "pQHNt5rXTTWNvUgOrdynKg"; + + response.Nodes.Should().ContainKey(nodeId); + response.Nodes[nodeId].Timestamp.Should().Be(new DateTimeOffset(2017, 4, 18, 22, 19, 21, 812, TimeSpan.Zero)); + response.Nodes[nodeId].Since.Should().Be(new DateTimeOffset(2017, 4, 18, 22, 18, 26, 606, TimeSpan.Zero)); + response.Nodes[nodeId].RestActions.Should().NotBeNull(); + response.Nodes[nodeId].RestActions.Should().HaveCount(5); + response.Nodes[nodeId].RestActions.Should().ContainKey("org.elasticsearch.rest.action.search.RestSearchAction"); + response.Nodes[nodeId].RestActions["org.elasticsearch.rest.action.search.RestSearchAction"].Should().Be(19); + } + } +} diff --git a/src/Tests/Cluster/NodesUsage/NodesUsageUrlTests.cs b/src/Tests/Cluster/NodesUsage/NodesUsageUrlTests.cs new file mode 100644 index 00000000000..12715c3aff5 --- /dev/null +++ b/src/Tests/Cluster/NodesUsage/NodesUsageUrlTests.cs @@ -0,0 +1,44 @@ +using System.Threading.Tasks; +using Elasticsearch.Net; +using Nest; +using Tests.Framework; +using Tests.Framework.MockData; +using static Nest.Infer; +using static Tests.Framework.UrlTester; + +namespace Tests.XPack.NodesUsage +{ + public class NodesUsageUrlTests : IUrlTests + { + [U] public async Task Urls() + { + await GET("/_nodes/usage") + .Fluent(c => c.NodesUsage(d => d)) + .Request(c => c.NodesUsage(new NodesUsageRequest())) + .FluentAsync(c => c.NodesUsageAsync(d => d)) + .RequestAsync(c => c.NodesUsageAsync(new NodesUsageRequest())) + ; + + await GET("/_nodes/nodeId/usage") + .Fluent(c => c.NodesUsage(d => d.NodeId("nodeId"))) + .Request(c => c.NodesUsage(new NodesUsageRequest("nodeId"))) + .FluentAsync(c => c.NodesUsageAsync(d => d.NodeId("nodeId"))) + .RequestAsync(c => c.NodesUsageAsync(new NodesUsageRequest("nodeId"))) + ; + + await GET("/_nodes/nodeId/usage/rest_actions") + .Fluent(c => c.NodesUsage(d => d.NodeId("nodeId").Metric(NodesUsageMetric.RestActions))) + .Request(c => c.NodesUsage(new NodesUsageRequest("nodeId", NodesUsageMetric.RestActions))) + .FluentAsync(c => c.NodesUsageAsync(d => d.NodeId("nodeId").Metric(NodesUsageMetric.RestActions))) + .RequestAsync(c => c.NodesUsageAsync(new NodesUsageRequest("nodeId", NodesUsageMetric.RestActions))) + ; + + await GET("/_nodes/nodeId/usage/_all") + .Fluent(c => c.NodesUsage(d => d.NodeId("nodeId").Metric(NodesUsageMetric.All))) + .Request(c => c.NodesUsage(new NodesUsageRequest("nodeId", NodesUsageMetric.All))) + .FluentAsync(c => c.NodesUsageAsync(d => d.NodeId("nodeId").Metric(NodesUsageMetric.All))) + .RequestAsync(c => c.NodesUsageAsync(new NodesUsageRequest("nodeId", NodesUsageMetric.All))) + ; + } + } +} diff --git a/src/Tests/CodeStandards/NamingConventions.doc.cs b/src/Tests/CodeStandards/NamingConventions.doc.cs index 31f742e1d8f..7e6c4339512 100644 --- a/src/Tests/CodeStandards/NamingConventions.doc.cs +++ b/src/Tests/CodeStandards/NamingConventions.doc.cs @@ -120,13 +120,7 @@ public void ParityBetweenRequestsAndResponses() typeof(IndicesShardStoresRequest), typeof(RenderSearchTemplateRequest), typeof(MultiSearchTemplateRequest), - typeof(CreateRequest<>), - - //TODO ignored as part of new 6.0 beta 2 types that we need to add support for - typeof(IngestProcessorGrokRequest), - typeof(NodesUsageRequest), - typeof(XpackDeprecationInfoRequest), - + typeof(CreateRequest<>) }; var types = typeof(IRequest).Assembly().GetTypes(); diff --git a/src/Tests/Framework/TestClient.cs b/src/Tests/Framework/TestClient.cs index 61fd85616d7..cddaffd144b 100644 --- a/src/Tests/Framework/TestClient.cs +++ b/src/Tests/Framework/TestClient.cs @@ -169,10 +169,19 @@ public static IElasticClient GetFixedReturnClient( string contentType = "application/json", Exception exception = null) { - var serializer = Default.Serializer; - var fixedResult = contentType == "application/json" - ? serializer.SerializeToBytes(response) - : Encoding.UTF8.GetBytes(response.ToString()); + byte[] fixedResult; + + if (response.GetType() == typeof(string)) + { + fixedResult = Encoding.UTF8.GetBytes((string)response); + } + else + { + var serializer = Default.Serializer; + fixedResult = contentType == "application/json" + ? serializer.SerializeToBytes(response) + : Encoding.UTF8.GetBytes(response.ToString()); + } var connection = new InMemoryConnection(fixedResult, statusCode, exception); var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200")); diff --git a/src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs b/src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs new file mode 100644 index 00000000000..c2215346dce --- /dev/null +++ b/src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs @@ -0,0 +1,32 @@ +using System; +using Elasticsearch.Net; +using Nest; +using Tests.Framework; +using Tests.Framework.Integration; +using Tests.Framework.ManagedElasticsearch.Clusters; +using Xunit; + +namespace Tests.Ingest.IngestProcessorGrok +{ + public class IngestProcessorGrokApiTests : ApiTestBase + { + public IngestProcessorGrokApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + + protected override LazyResponses ClientUsage() => Calls( + fluent: (client, f) => client.IngestProcessorGrok(f), + fluentAsync: (client, f) => client.IngestProcessorGrokAsync(f), + request: (client, r) => client.IngestProcessorGrok(r), + requestAsync: (client, r) => client.IngestProcessorGrokAsync(r) + ); + + protected override HttpMethod HttpMethod => HttpMethod.GET; + + protected override string UrlPath => $"/_ingest/processor/grok"; + + protected override IngestProcessorGrokDescriptor NewDescriptor() => new IngestProcessorGrokDescriptor(); + + protected override Func Fluent => d => d; + + protected override IngestProcessorGrokRequest Initializer => new IngestProcessorGrokRequest(); + } +} diff --git a/src/Tests/Ingest/Processor/IngestProcessorGrokTests.cs b/src/Tests/Ingest/Processor/IngestProcessorGrokTests.cs new file mode 100644 index 00000000000..9217829ccd8 --- /dev/null +++ b/src/Tests/Ingest/Processor/IngestProcessorGrokTests.cs @@ -0,0 +1,20 @@ +using System.Threading.Tasks; +using Nest; +using Tests.Framework; +using static Tests.Framework.UrlTester; + +namespace Tests.Ingest.Processor +{ + public class IngestProcessorGrokUrlTests + { + [U] public async Task Urls() + { + await GET($"/_ingest/processor/grok") + .Fluent(c => c.IngestProcessorGrok()) + .Request(c => c.IngestProcessorGrok()) + .FluentAsync(c => c.IngestProcessorGrokAsync()) + .RequestAsync(c => c.IngestProcessorGrokAsync()) + ; + } + } +} diff --git a/src/Tests/Ingest/Processor/IngestProcessorGrokUnitTests.cs b/src/Tests/Ingest/Processor/IngestProcessorGrokUnitTests.cs new file mode 100644 index 00000000000..a862e438769 --- /dev/null +++ b/src/Tests/Ingest/Processor/IngestProcessorGrokUnitTests.cs @@ -0,0 +1,26 @@ +using System.Linq; +using FluentAssertions; +using Nest; +using Tests.Framework; + +namespace Tests.XPack.IngestProcessorGrok +{ + public class IngestProcessorGrokUnitTests + { + [U] + public void ShouldDeserialize() + { + const string fixedResponse = "{ \"patterns\" : { \"BACULA_CAPACITY\" : \"%{INT}{1,3}(,%{INT}{3})*\", \"PATH\" : \"(?:%{UNIXPATH}|%{WINPATH})\" } }"; + var client = TestClient.GetFixedReturnClient(fixedResponse); + + //warmup + var response = client.IngestProcessorGrok(); + response.ShouldBeValid(); + + response.Patterns.Should().NotBeNull(); + response.Patterns.Should().HaveCount(2); + response.Patterns.Should().ContainKey("BACULA_CAPACITY"); + response.Patterns.Should().ContainKey("PATH"); + } + } +} diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index feaf50f5960..9faabcc5b80 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -1,4 +1,4 @@ - + 1 @@ -50,4 +50,4 @@ - + \ No newline at end of file diff --git a/src/Tests/XPack/DeprecationInfo/DeprecationInfoUnitTests.cs b/src/Tests/XPack/DeprecationInfo/DeprecationInfoUnitTests.cs new file mode 100644 index 00000000000..6c1362e6935 --- /dev/null +++ b/src/Tests/XPack/DeprecationInfo/DeprecationInfoUnitTests.cs @@ -0,0 +1,42 @@ +using System.Linq; +using FluentAssertions; +using Nest; +using Tests.Framework; + +namespace Tests.XPack.DeprecationInfo +{ + public class DeprecationInfoUnitTests + { + [U] + public void ShouldDeserialize() + { + const string fixedResponse = "{ \"cluster_settings\" : [ { \"level\" : \"info\", \"message\" : \"Network settings changes\", \"url\" : \"https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_indices_changes.html#_index_templates_use_literal_index_patterns_literal_instead_of_literal_template_literal\", \"details\" : \"templates using template field: watches,.monitoring-alerts,.watch-history-6,.ml-notifications,security-index-template,triggered_watches,.monitoring-es,.ml-meta,.ml-state,.monitoring-logstash,.ml-anomalies-,.monitoring-kibana\" } ], \"node_settings\" : [ ], \"index_settings\" : { \".monitoring-es-6-2017.07.21\" : [ { \"level\" : \"info\", \"message\" : \"Coercion of boolean fields\", \"url\" : \"https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields\", \"details\" : \"\" } ] } }"; + var client = TestClient.GetFixedReturnClient(fixedResponse); + + //warmup + var response = client.DeprecationInfo(); + response.ShouldBeValid(); + + response.ClusterSettings.Should().NotBeNull(); + response.ClusterSettings.Should().HaveCount(1); + response.ClusterSettings.First().Level.Should().Be(DeprecationWarningLevel.Information); + response.ClusterSettings.First().Message.Should().Be("Network settings changes"); + response.ClusterSettings.First().Url.Should().Be("https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_indices_changes.html#_index_templates_use_literal_index_patterns_literal_instead_of_literal_template_literal"); + response.ClusterSettings.First().Details.Should().Be("templates using template field: watches,.monitoring-alerts,.watch-history-6,.ml-notifications,security-index-template,triggered_watches,.monitoring-es,.ml-meta,.ml-state,.monitoring-logstash,.ml-anomalies-,.monitoring-kibana"); + + response.NodeSettings.Should().NotBeNull(); + response.NodeSettings.Should().BeEmpty(); + + response.IndexSettings.Should().NotBeNull(); + response.IndexSettings.Should().HaveCount(1); + + const string indexName = ".monitoring-es-6-2017.07.21"; + response.IndexSettings.Should().ContainKey(indexName); + response.IndexSettings[indexName].Count.Should().Be(1); + response.IndexSettings[indexName].First().Details.Should().Be(""); + response.IndexSettings[indexName].First().Url.Should().Be("https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields"); + response.IndexSettings[indexName].First().Message.Should().Be("Coercion of boolean fields"); + response.IndexSettings[indexName].First().Level.Should().Be(DeprecationWarningLevel.Information); + } + } +} diff --git a/src/Tests/XPack/DeprecationInfo/DeprecationInfoUrlTests.cs b/src/Tests/XPack/DeprecationInfo/DeprecationInfoUrlTests.cs new file mode 100644 index 00000000000..3e3ac0e39fd --- /dev/null +++ b/src/Tests/XPack/DeprecationInfo/DeprecationInfoUrlTests.cs @@ -0,0 +1,31 @@ +using System.Threading.Tasks; +using Nest; +using Tests.Framework; +using Tests.Framework.MockData; +using static Nest.Infer; +using static Tests.Framework.UrlTester; + +namespace Tests.XPack.DeprecationInfo +{ + public class DeprecationInfoUrlTests : IUrlTests + { + [U] public async Task Urls() + { + await GET("/_xpack/migration/deprecations") + .Fluent(c => c.DeprecationInfo(d => d)) + .Request(c => c.DeprecationInfo(new DeprecationInfoRequest())) + .FluentAsync(c => c.DeprecationInfoAsync(d => d)) + .RequestAsync(c => c.DeprecationInfoAsync(new DeprecationInfoRequest())) + ; + + var index = "another-index"; + + await GET($"/{index}/_xpack/migration/deprecations") + .Fluent(c => c.DeprecationInfo(d=>d.Index(index))) + .Request(c => c.DeprecationInfo(new DeprecationInfoRequest(index))) + .FluentAsync(c => c.DeprecationInfoAsync(d=>d.Index(index))) + .RequestAsync(c => c.DeprecationInfoAsync(new DeprecationInfoRequest(index))) + ; + } + } +} From 4910944a8dfe71a9752dd0ceac339ccfb0be5f5f Mon Sep 17 00:00:00 2001 From: codebrain Date: Fri, 10 Nov 2017 13:28:13 +1100 Subject: [PATCH 2/6] Implementation of: IngestGrokProcessor, NodesUsage and DeprecationInfo --- .../RequestParameters.Generated.cs | 12 ++-- .../ElasticLowLevelClient.Generated.cs | 8 +-- .../IElasticLowLevelClient.Generated.cs | 8 +-- .../NodesUsage/ElasticClient-NodesUsage.cs | 55 ++++++++++++++++++ .../Cluster/NodesUsage/NodeUsageResponse.cs | 53 ++++++++++++++++++ .../Cluster/NodesUsage/NodesUsageRequest.cs | 9 +++ .../ElasticClient-IngestProcessorGrok.cs | 55 ++++++++++++++++++ .../Processor/IngestProcessorGrokRequest.cs | 9 +++ .../Processor/IngestProcessorGrokResponse.cs | 17 ++++++ .../DeprecationInfo/DeprecationInfoRequest.cs | 9 +++ .../DeprecationInfoResponse.cs | 56 +++++++++++++++++++ .../ElasticClient-DeprecationInfo.cs | 48 ++++++++++++++++ .../_Generated/_LowLevelDispatch.generated.cs | 4 +- .../Cluster/NodesUsage/NodesUsageApiTests.cs | 46 +++++++++++++++ .../Cluster/NodesUsage/NodesUsageUnitTests.cs | 40 +++++++++++++ .../Cluster/NodesUsage/NodesUsageUrlTests.cs | 44 +++++++++++++++ .../CodeStandards/NamingConventions.doc.cs | 8 +-- src/Tests/Framework/TestClient.cs | 17 ++++-- .../Processor/IngestProcessorGrokApiTests.cs | 32 +++++++++++ .../Processor/IngestProcessorGrokTests.cs | 20 +++++++ .../Processor/IngestProcessorGrokUnitTests.cs | 26 +++++++++ src/Tests/Tests.csproj | 2 +- .../DeprecationInfoUnitTests.cs | 42 ++++++++++++++ .../DeprecationInfoUrlTests.cs | 31 ++++++++++ 24 files changed, 623 insertions(+), 28 deletions(-) create mode 100644 src/Nest/Cluster/NodesUsage/ElasticClient-NodesUsage.cs create mode 100644 src/Nest/Cluster/NodesUsage/NodeUsageResponse.cs create mode 100644 src/Nest/Cluster/NodesUsage/NodesUsageRequest.cs create mode 100644 src/Nest/Ingest/Processor/ElasticClient-IngestProcessorGrok.cs create mode 100644 src/Nest/Ingest/Processor/IngestProcessorGrokRequest.cs create mode 100644 src/Nest/Ingest/Processor/IngestProcessorGrokResponse.cs create mode 100644 src/Nest/XPack/DeprecationInfo/DeprecationInfoRequest.cs create mode 100644 src/Nest/XPack/DeprecationInfo/DeprecationInfoResponse.cs create mode 100644 src/Nest/XPack/DeprecationInfo/ElasticClient-DeprecationInfo.cs create mode 100644 src/Tests/Cluster/NodesUsage/NodesUsageApiTests.cs create mode 100644 src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs create mode 100644 src/Tests/Cluster/NodesUsage/NodesUsageUrlTests.cs create mode 100644 src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs create mode 100644 src/Tests/Ingest/Processor/IngestProcessorGrokTests.cs create mode 100644 src/Tests/Ingest/Processor/IngestProcessorGrokUnitTests.cs create mode 100644 src/Tests/XPack/DeprecationInfo/DeprecationInfoUnitTests.cs create mode 100644 src/Tests/XPack/DeprecationInfo/DeprecationInfoUrlTests.cs diff --git a/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs b/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs index 23f5748c186..eec06e2a4d9 100644 --- a/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs +++ b/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs @@ -6295,28 +6295,28 @@ public class GraphExploreRequestParameters : FluentRequestParameters ///
- public class XpackDeprecationInfoRequestParameters : FluentRequestParameters + public class DeprecationInfoRequestParameters : FluentRequestParameters { public override HttpMethod DefaultHttpMethod => HttpMethod.GET; ///Pretty format the returned JSON response. - public XpackDeprecationInfoRequestParameters Pretty(bool pretty) => this.AddQueryString("pretty", pretty); + public DeprecationInfoRequestParameters Pretty(bool pretty) => this.AddQueryString("pretty", pretty); ///Return human readable values for statistics. - public XpackDeprecationInfoRequestParameters Human(bool human) => this.AddQueryString("human", human); + public DeprecationInfoRequestParameters Human(bool human) => this.AddQueryString("human", human); ///Include the stack trace of returned errors. - public XpackDeprecationInfoRequestParameters ErrorTrace(bool error_trace) => this.AddQueryString("error_trace", error_trace); + public DeprecationInfoRequestParameters ErrorTrace(bool error_trace) => this.AddQueryString("error_trace", error_trace); ///The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - public XpackDeprecationInfoRequestParameters Source(string source) => this.AddQueryString("source", source); + public DeprecationInfoRequestParameters Source(string source) => this.AddQueryString("source", source); ///A comma-separated list of filters used to reduce the respone. - public XpackDeprecationInfoRequestParameters FilterPath(params string[] filter_path) => this.AddQueryString("filter_path", filter_path); + public DeprecationInfoRequestParameters FilterPath(params string[] filter_path) => this.AddQueryString("filter_path", filter_path); } diff --git a/src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs b/src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs index 7615bf2fd03..ee967a3008b 100644 --- a/src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs +++ b/src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs @@ -7794,7 +7794,7 @@ public ElasticsearchResponse XpackGraphExplore(string index, string type, ///See also: http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html /// ///A func that allows you to describe the querystring parameters & request specific connection settings. - public ElasticsearchResponse XpackDeprecationInfo(Func requestParameters = null) + public ElasticsearchResponse XpackDeprecationInfo(Func requestParameters = null) where T : class => this.DoRequest(GET, Url($"_xpack/migration/deprecations"), null, _params(requestParameters)); ///Represents a GET on /_xpack/migration/deprecations @@ -7807,7 +7807,7 @@ public ElasticsearchResponse XpackDeprecationInfo(FuncSee also: http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html /// ///A func that allows you to describe the querystring parameters & request specific connection settings. - public Task> XpackDeprecationInfoAsync(Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) + public Task> XpackDeprecationInfoAsync(Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class => this.DoRequestAsync(GET, Url($"_xpack/migration/deprecations"), cancellationToken, null, _params(requestParameters)); ///Represents a GET on /{index}/_xpack/migration/deprecations @@ -7821,7 +7821,7 @@ public ElasticsearchResponse XpackDeprecationInfo(Func ///Index pattern ///A func that allows you to describe the querystring parameters & request specific connection settings. - public ElasticsearchResponse XpackDeprecationInfo(string index, Func requestParameters = null) + public ElasticsearchResponse XpackDeprecationInfo(string index, Func requestParameters = null) where T : class => this.DoRequest(GET, Url($"{index.NotNull("index")}/_xpack/migration/deprecations"), null, _params(requestParameters)); ///Represents a GET on /{index}/_xpack/migration/deprecations @@ -7835,7 +7835,7 @@ public ElasticsearchResponse XpackDeprecationInfo(string index, Func ///Index pattern ///A func that allows you to describe the querystring parameters & request specific connection settings. - public Task> XpackDeprecationInfoAsync(string index, Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) + public Task> XpackDeprecationInfoAsync(string index, Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class => this.DoRequestAsync(GET, Url($"{index.NotNull("index")}/_xpack/migration/deprecations"), cancellationToken, null, _params(requestParameters)); ///Represents a GET on /_xpack diff --git a/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs b/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs index 0b1fe8c2cb5..862c7caec57 100644 --- a/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs +++ b/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs @@ -7257,7 +7257,7 @@ public partial interface IElasticLowLevelClient ///See also: http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html /// ///A func that allows you to describe the querystring parameters & request specific connection settings. - ElasticsearchResponse XpackDeprecationInfo(Func requestParameters = null) where T : class; + ElasticsearchResponse XpackDeprecationInfo(Func requestParameters = null) where T : class; ///Represents a GET on /_xpack/migration/deprecations ///Returns: A task of ElasticsearchResponse<T> where the behaviour depends on the type of T: @@ -7269,7 +7269,7 @@ public partial interface IElasticLowLevelClient ///See also: http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html /// ///A func that allows you to describe the querystring parameters & request specific connection settings. - Task> XpackDeprecationInfoAsync(Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class; + Task> XpackDeprecationInfoAsync(Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class; ///Represents a GET on /{index}/_xpack/migration/deprecations ///Returns: ElasticsearchResponse<T> where the behavior depends on the type of T: @@ -7282,7 +7282,7 @@ public partial interface IElasticLowLevelClient /// ///Index pattern ///A func that allows you to describe the querystring parameters & request specific connection settings. - ElasticsearchResponse XpackDeprecationInfo(string index, Func requestParameters = null) where T : class; + ElasticsearchResponse XpackDeprecationInfo(string index, Func requestParameters = null) where T : class; ///Represents a GET on /{index}/_xpack/migration/deprecations ///Returns: A task of ElasticsearchResponse<T> where the behaviour depends on the type of T: @@ -7295,7 +7295,7 @@ public partial interface IElasticLowLevelClient /// ///Index pattern ///A func that allows you to describe the querystring parameters & request specific connection settings. - Task> XpackDeprecationInfoAsync(string index, Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class; + Task> XpackDeprecationInfoAsync(string index, Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class; ///Represents a GET on /_xpack ///Returns: ElasticsearchResponse<T> where the behavior depends on the type of T: diff --git a/src/Nest/Cluster/NodesUsage/ElasticClient-NodesUsage.cs b/src/Nest/Cluster/NodesUsage/ElasticClient-NodesUsage.cs new file mode 100644 index 00000000000..8c75b05cf8f --- /dev/null +++ b/src/Nest/Cluster/NodesUsage/ElasticClient-NodesUsage.cs @@ -0,0 +1,55 @@ +using System; +using System.IO; +using System.Threading.Tasks; +using Elasticsearch.Net; + +namespace Nest +{ + using System.Threading; + using NodesHotThreadConverter = Func; + + public partial interface IElasticClient + { + /// + /// The cluster nodes usage API allows to retrieve information on the usage of features for each node. + /// https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html + /// + /// An optional descriptor to further describe the nodes usage operation + INodesUsageResponse NodesUsage(Func selector = null); + + /// + INodesUsageResponse NodesUsage(INodesUsageRequest request); + + /// + Task NodesUsageAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + Task NodesUsageAsync(INodesUsageRequest request, CancellationToken cancellationToken = default(CancellationToken)); + } + + public partial class ElasticClient + { + /// + public INodesUsageResponse NodesUsage(Func selector = null) => + this.NodesUsage(selector.InvokeOrDefault(new NodesUsageDescriptor())); + + /// + public INodesUsageResponse NodesUsage(INodesUsageRequest request) => + this.Dispatcher.Dispatch( + request, + (p, d) => this.LowLevelDispatch.NodesUsageDispatch(p) + ); + + /// + public Task NodesUsageAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => + this.NodesUsageAsync(selector.InvokeOrDefault(new NodesUsageDescriptor()), cancellationToken); + + /// + public Task NodesUsageAsync(INodesUsageRequest request, CancellationToken cancellationToken = default(CancellationToken)) => + this.Dispatcher.DispatchAsync( + request, + cancellationToken, + (p, d, c) => this.LowLevelDispatch.NodesUsageDispatchAsync(p, c) + ); + } +} diff --git a/src/Nest/Cluster/NodesUsage/NodeUsageResponse.cs b/src/Nest/Cluster/NodesUsage/NodeUsageResponse.cs new file mode 100644 index 00000000000..0df47455066 --- /dev/null +++ b/src/Nest/Cluster/NodesUsage/NodeUsageResponse.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Nest +{ + public class NodeUsageMetadata + { + [JsonProperty(PropertyName = "total")] + public int Total { get; internal set; } + + [JsonProperty(PropertyName = "successful")] + public int Successful { get; internal set; } + + [JsonProperty(PropertyName = "failed")] + public int Failed { get; internal set; } + } + + public class NodeUsageInformation + { + [JsonProperty(PropertyName = "timestamp")] + [JsonConverter(typeof(EpochMillisecondsDateTimeJsonConverter))] + public DateTimeOffset Timestamp { get; internal set; } + + [JsonProperty(PropertyName = "since")] + [JsonConverter(typeof(EpochMillisecondsDateTimeJsonConverter))] + public DateTimeOffset Since { get; internal set; } + + [JsonProperty(PropertyName = "rest_actions")] + public IReadOnlyDictionary RestActions { get; internal set; } + } + + public interface INodesUsageResponse : IResponse + { + string ClusterName { get; } + + IReadOnlyDictionary Nodes { get; } + + NodeUsageMetadata NodeMetadata { get; } + } + + public class NodesUsageResponse : ResponseBase, INodesUsageResponse + { + [JsonProperty(PropertyName = "cluster_name")] + public string ClusterName { get; internal set; } + + [JsonProperty(PropertyName = "nodes")] + public IReadOnlyDictionary Nodes { get; internal set; } = EmptyReadOnly.Dictionary; + + [JsonProperty(PropertyName = "_nodes")] + public NodeUsageMetadata NodeMetadata { get; internal set; } + } +} diff --git a/src/Nest/Cluster/NodesUsage/NodesUsageRequest.cs b/src/Nest/Cluster/NodesUsage/NodesUsageRequest.cs new file mode 100644 index 00000000000..0ff28c31084 --- /dev/null +++ b/src/Nest/Cluster/NodesUsage/NodesUsageRequest.cs @@ -0,0 +1,9 @@ +namespace Nest +{ + public partial interface INodesUsageRequest { } + + public partial class NodesUsageRequest { } + + [DescriptorFor("NodesUsage")] + public partial class NodesUsageDescriptor { } +} diff --git a/src/Nest/Ingest/Processor/ElasticClient-IngestProcessorGrok.cs b/src/Nest/Ingest/Processor/ElasticClient-IngestProcessorGrok.cs new file mode 100644 index 00000000000..9dd447745ef --- /dev/null +++ b/src/Nest/Ingest/Processor/ElasticClient-IngestProcessorGrok.cs @@ -0,0 +1,55 @@ +using System; +using System.IO; +using System.Threading.Tasks; +using Elasticsearch.Net; + +namespace Nest +{ + using System.Threading; + using NodesHotThreadConverter = Func; + + public partial interface IElasticClient + { + /// + /// Retrieving which patterns which the grok processor is packaged with, useful as different versions are bundled with different processors. + /// https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html + /// + /// An optional descriptor to further describe the endpoint usage operation + IIngestProcessorGrokResponse IngestProcessorGrok(Func selector = null); + + /// + IIngestProcessorGrokResponse IngestProcessorGrok(IIngestProcessorGrokRequest request); + + /// + Task IngestProcessorGrokAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + Task IngestProcessorGrokAsync(IIngestProcessorGrokRequest request, CancellationToken cancellationToken = default(CancellationToken)); + } + + public partial class ElasticClient + { + /// + public IIngestProcessorGrokResponse IngestProcessorGrok(Func selector = null) => + this.IngestProcessorGrok(selector.InvokeOrDefault(new IngestProcessorGrokDescriptor())); + + /// + public IIngestProcessorGrokResponse IngestProcessorGrok(IIngestProcessorGrokRequest request) => + this.Dispatcher.Dispatch( + request, + (p, d) => this.LowLevelDispatch.IngestProcessorGrokDispatch(p) + ); + + /// + public Task IngestProcessorGrokAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => + this.IngestProcessorGrokAsync(selector.InvokeOrDefault(new IngestProcessorGrokDescriptor()), cancellationToken); + + /// + public Task IngestProcessorGrokAsync(IIngestProcessorGrokRequest request, CancellationToken cancellationToken = default(CancellationToken)) => + this.Dispatcher.DispatchAsync( + request, + cancellationToken, + (p, d, c) => this.LowLevelDispatch.IngestProcessorGrokDispatchAsync(p, c) + ); + } +} diff --git a/src/Nest/Ingest/Processor/IngestProcessorGrokRequest.cs b/src/Nest/Ingest/Processor/IngestProcessorGrokRequest.cs new file mode 100644 index 00000000000..a8862b3ff04 --- /dev/null +++ b/src/Nest/Ingest/Processor/IngestProcessorGrokRequest.cs @@ -0,0 +1,9 @@ +namespace Nest +{ + public partial interface IIngestProcessorGrokRequest { } + + public partial class IngestProcessorGrokRequest { } + + [DescriptorFor("IngestProcessorGrok")] + public partial class IngestProcessorGrokDescriptor { } +} diff --git a/src/Nest/Ingest/Processor/IngestProcessorGrokResponse.cs b/src/Nest/Ingest/Processor/IngestProcessorGrokResponse.cs new file mode 100644 index 00000000000..cb4e7c47674 --- /dev/null +++ b/src/Nest/Ingest/Processor/IngestProcessorGrokResponse.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Nest +{ + public interface IIngestProcessorGrokResponse : IResponse + { + IReadOnlyDictionary Patterns { get; } + } + + public class IngestProcessorGrokResponse : ResponseBase, IIngestProcessorGrokResponse + { + [JsonProperty(PropertyName = "patterns")] + public IReadOnlyDictionary Patterns { get; internal set; } = EmptyReadOnly.Dictionary; + } +} diff --git a/src/Nest/XPack/DeprecationInfo/DeprecationInfoRequest.cs b/src/Nest/XPack/DeprecationInfo/DeprecationInfoRequest.cs new file mode 100644 index 00000000000..c06d0dd4609 --- /dev/null +++ b/src/Nest/XPack/DeprecationInfo/DeprecationInfoRequest.cs @@ -0,0 +1,9 @@ +namespace Nest +{ + public partial interface IDeprecationInfoRequest { } + + public partial class DeprecationInfoRequest { } + + [DescriptorFor("XpackDeprecationInfo")] + public partial class DeprecationInfoDescriptor : IDeprecationInfoRequest { } +} diff --git a/src/Nest/XPack/DeprecationInfo/DeprecationInfoResponse.cs b/src/Nest/XPack/DeprecationInfo/DeprecationInfoResponse.cs new file mode 100644 index 00000000000..29da3c1459b --- /dev/null +++ b/src/Nest/XPack/DeprecationInfo/DeprecationInfoResponse.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Nest +{ + [JsonConverter(typeof(StringEnumConverter))] + public enum DeprecationWarningLevel + { + [EnumMember(Value = "none")] + None, + [EnumMember(Value = "info")] + Information, + [EnumMember(Value = "warning")] + Warning, + [EnumMember(Value = "critical")] + Critical + } + + public class DeprecationInfoItem + { + [JsonProperty("level")] + public DeprecationWarningLevel Level { get; internal set; } + + [JsonProperty("message")] + public string Message { get; internal set; } + + [JsonProperty("url")] + public string Url { get; internal set; } + + [JsonProperty("details")] + public string Details { get; internal set; } + } + + public interface IDeprecationInfoResponse : IResponse + { + [JsonProperty("cluster_settings")] + IReadOnlyCollection ClusterSettings { get; } + + [JsonProperty("node_settings")] + IReadOnlyCollection NodeSettings { get; } + + [JsonProperty("index_settings")] + IReadOnlyDictionary> IndexSettings { get; } + } + + public class DeprecationInfoResponse : ResponseBase, IDeprecationInfoResponse + { + public IReadOnlyCollection ClusterSettings { get; internal set; } = EmptyReadOnly.Collection; + public IReadOnlyCollection NodeSettings { get; internal set; } = EmptyReadOnly.Collection; + public IReadOnlyDictionary> IndexSettings { get; internal set; } = EmptyReadOnly>.Dictionary; + } +} diff --git a/src/Nest/XPack/DeprecationInfo/ElasticClient-DeprecationInfo.cs b/src/Nest/XPack/DeprecationInfo/ElasticClient-DeprecationInfo.cs new file mode 100644 index 00000000000..48a580d4505 --- /dev/null +++ b/src/Nest/XPack/DeprecationInfo/ElasticClient-DeprecationInfo.cs @@ -0,0 +1,48 @@ +using System; +using System.Threading.Tasks; +using Elasticsearch.Net; +using System.Threading; + +namespace Nest +{ + public partial interface IElasticClient + { + /// + IDeprecationInfoResponse DeprecationInfo(Func selector = null); + + /// + IDeprecationInfoResponse DeprecationInfo(IDeprecationInfoRequest request); + + /// + Task DeprecationInfoAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + Task DeprecationInfoAsync(IDeprecationInfoRequest request, CancellationToken cancellationToken = default(CancellationToken)); + } + + public partial class ElasticClient + { + /// + public IDeprecationInfoResponse DeprecationInfo(Func selector = null) => + this.DeprecationInfo(selector.InvokeOrDefault(new DeprecationInfoDescriptor())); + + /// + public IDeprecationInfoResponse DeprecationInfo(IDeprecationInfoRequest request) => + this.Dispatcher.Dispatch( + request, + (p, d) =>this.LowLevelDispatch.XpackDeprecationInfoDispatch(p) + ); + + /// + public Task DeprecationInfoAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => + this.DeprecationInfoAsync(selector.InvokeOrDefault(new DeprecationInfoDescriptor()), cancellationToken); + + /// + public Task DeprecationInfoAsync(IDeprecationInfoRequest request, CancellationToken cancellationToken = default(CancellationToken)) => + this.Dispatcher.DispatchAsync( + request, + cancellationToken, + (p, d, c) => this.LowLevelDispatch.XpackDeprecationInfoDispatchAsync(p, c) + ); + } +} diff --git a/src/Nest/_Generated/_LowLevelDispatch.generated.cs b/src/Nest/_Generated/_LowLevelDispatch.generated.cs index cfe0fab3756..1f961e6e4c0 100644 --- a/src/Nest/_Generated/_LowLevelDispatch.generated.cs +++ b/src/Nest/_Generated/_LowLevelDispatch.generated.cs @@ -3182,7 +3182,7 @@ internal Task> XpackGraphExploreDispatchAsync(IReque throw InvalidDispatch("XpackGraphExplore", p, new [] { GET, POST }, "/{index}/_xpack/graph/_explore", "/{index}/{type}/_xpack/graph/_explore"); } - internal ElasticsearchResponse XpackDeprecationInfoDispatch(IRequest p ) where T : class + internal ElasticsearchResponse XpackDeprecationInfoDispatch(IRequest p ) where T : class { switch(p.HttpMethod) { @@ -3194,7 +3194,7 @@ internal ElasticsearchResponse XpackDeprecationInfoDispatch(IRequest> XpackDeprecationInfoDispatchAsync(IRequest p , CancellationToken cancellationToken) where T : class + internal Task> XpackDeprecationInfoDispatchAsync(IRequest p , CancellationToken cancellationToken) where T : class { switch(p.HttpMethod) { diff --git a/src/Tests/Cluster/NodesUsage/NodesUsageApiTests.cs b/src/Tests/Cluster/NodesUsage/NodesUsageApiTests.cs new file mode 100644 index 00000000000..3a3958542ec --- /dev/null +++ b/src/Tests/Cluster/NodesUsage/NodesUsageApiTests.cs @@ -0,0 +1,46 @@ +using System; +using System.Linq; +using Elasticsearch.Net; +using FluentAssertions; +using Nest; +using Tests.Framework; +using Tests.Framework.Integration; +using Tests.Framework.ManagedElasticsearch.Clusters; +using Xunit; + +namespace Tests.Cluster.NodesUsage +{ + public class NodesUsageApiTests : ApiIntegrationTestBase + { + public NodesUsageApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + protected override LazyResponses ClientUsage() => Calls( + fluent: (client, f) => client.NodesUsage(), + fluentAsync: (client, f) => client.NodesUsageAsync(), + request: (client, r) => client.NodesUsage(r), + requestAsync: (client, r) => client.NodesUsageAsync(r) + ); + + protected override bool ExpectIsValid => true; + protected override int ExpectStatusCode => 200; + protected override HttpMethod HttpMethod => HttpMethod.GET; + protected override string UrlPath => "/_nodes/usage"; + + protected override void ExpectResponse(INodesUsageResponse response) + { + response.ClusterName.Should().NotBeEmpty(); + + response.NodeMetadata.Should().NotBeNull(); + response.NodeMetadata.Total.Should().Be(1); + response.NodeMetadata.Successful.Should().Be(1); + response.NodeMetadata.Failed.Should().Be(0); + + response.Nodes.Should().NotBeNull(); + response.Nodes.Should().HaveCount(1); + + response.Nodes.First().Value.Timestamp.Should().BeBefore(DateTimeOffset.UtcNow); + response.Nodes.First().Value.Since.Should().BeBefore(DateTimeOffset.UtcNow); + response.Nodes.First().Value.RestActions.Should().NotBeNull(); + } + } + +} diff --git a/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs b/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs new file mode 100644 index 00000000000..f4c36be74fe --- /dev/null +++ b/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs @@ -0,0 +1,40 @@ +using System; +using FluentAssertions; +using Tests.Framework; + +namespace Tests.XPack.DeprecationInfo +{ + public class NodesUsageUnitTests + { + [U] + public void ShouldDeserialize() + { + const string fixedResponse = "{\"_nodes\": {\"total\": 1,\"successful\": 1,\"failed\": 0},\"cluster_name\": \"my_cluster\",\"nodes\": {\"pQHNt5rXTTWNvUgOrdynKg\": {\"timestamp\": 1492553961812,\"since\": 1492553906606,\"rest_actions\": {\"org.elasticsearch.rest.action.admin.cluster.RestNodesUsageAction\": 1,\"org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction\": 1,\"org.elasticsearch.rest.action.document.RestGetAction\": 1,\"org.elasticsearch.rest.action.search.RestSearchAction\": 19,\"org.elasticsearch.rest.action.admin.cluster.RestNodesInfoAction\": 36}}}}"; + var client = TestClient.GetFixedReturnClient(fixedResponse); + + //warmup + var response = client.NodesUsage(); + response.ShouldBeValid(); + + response.ClusterName.Should().Be("my_cluster"); + + response.NodeMetadata.Should().NotBeNull(); + response.NodeMetadata.Total.Should().Be(1); + response.NodeMetadata.Successful.Should().Be(1); + response.NodeMetadata.Failed.Should().Be(0); + + response.Nodes.Should().NotBeNull(); + response.Nodes.Should().HaveCount(1); + + const string nodeId = "pQHNt5rXTTWNvUgOrdynKg"; + + response.Nodes.Should().ContainKey(nodeId); + response.Nodes[nodeId].Timestamp.Should().Be(new DateTimeOffset(2017, 4, 18, 22, 19, 21, 812, TimeSpan.Zero)); + response.Nodes[nodeId].Since.Should().Be(new DateTimeOffset(2017, 4, 18, 22, 18, 26, 606, TimeSpan.Zero)); + response.Nodes[nodeId].RestActions.Should().NotBeNull(); + response.Nodes[nodeId].RestActions.Should().HaveCount(5); + response.Nodes[nodeId].RestActions.Should().ContainKey("org.elasticsearch.rest.action.search.RestSearchAction"); + response.Nodes[nodeId].RestActions["org.elasticsearch.rest.action.search.RestSearchAction"].Should().Be(19); + } + } +} diff --git a/src/Tests/Cluster/NodesUsage/NodesUsageUrlTests.cs b/src/Tests/Cluster/NodesUsage/NodesUsageUrlTests.cs new file mode 100644 index 00000000000..12715c3aff5 --- /dev/null +++ b/src/Tests/Cluster/NodesUsage/NodesUsageUrlTests.cs @@ -0,0 +1,44 @@ +using System.Threading.Tasks; +using Elasticsearch.Net; +using Nest; +using Tests.Framework; +using Tests.Framework.MockData; +using static Nest.Infer; +using static Tests.Framework.UrlTester; + +namespace Tests.XPack.NodesUsage +{ + public class NodesUsageUrlTests : IUrlTests + { + [U] public async Task Urls() + { + await GET("/_nodes/usage") + .Fluent(c => c.NodesUsage(d => d)) + .Request(c => c.NodesUsage(new NodesUsageRequest())) + .FluentAsync(c => c.NodesUsageAsync(d => d)) + .RequestAsync(c => c.NodesUsageAsync(new NodesUsageRequest())) + ; + + await GET("/_nodes/nodeId/usage") + .Fluent(c => c.NodesUsage(d => d.NodeId("nodeId"))) + .Request(c => c.NodesUsage(new NodesUsageRequest("nodeId"))) + .FluentAsync(c => c.NodesUsageAsync(d => d.NodeId("nodeId"))) + .RequestAsync(c => c.NodesUsageAsync(new NodesUsageRequest("nodeId"))) + ; + + await GET("/_nodes/nodeId/usage/rest_actions") + .Fluent(c => c.NodesUsage(d => d.NodeId("nodeId").Metric(NodesUsageMetric.RestActions))) + .Request(c => c.NodesUsage(new NodesUsageRequest("nodeId", NodesUsageMetric.RestActions))) + .FluentAsync(c => c.NodesUsageAsync(d => d.NodeId("nodeId").Metric(NodesUsageMetric.RestActions))) + .RequestAsync(c => c.NodesUsageAsync(new NodesUsageRequest("nodeId", NodesUsageMetric.RestActions))) + ; + + await GET("/_nodes/nodeId/usage/_all") + .Fluent(c => c.NodesUsage(d => d.NodeId("nodeId").Metric(NodesUsageMetric.All))) + .Request(c => c.NodesUsage(new NodesUsageRequest("nodeId", NodesUsageMetric.All))) + .FluentAsync(c => c.NodesUsageAsync(d => d.NodeId("nodeId").Metric(NodesUsageMetric.All))) + .RequestAsync(c => c.NodesUsageAsync(new NodesUsageRequest("nodeId", NodesUsageMetric.All))) + ; + } + } +} diff --git a/src/Tests/CodeStandards/NamingConventions.doc.cs b/src/Tests/CodeStandards/NamingConventions.doc.cs index 31f742e1d8f..7e6c4339512 100644 --- a/src/Tests/CodeStandards/NamingConventions.doc.cs +++ b/src/Tests/CodeStandards/NamingConventions.doc.cs @@ -120,13 +120,7 @@ public void ParityBetweenRequestsAndResponses() typeof(IndicesShardStoresRequest), typeof(RenderSearchTemplateRequest), typeof(MultiSearchTemplateRequest), - typeof(CreateRequest<>), - - //TODO ignored as part of new 6.0 beta 2 types that we need to add support for - typeof(IngestProcessorGrokRequest), - typeof(NodesUsageRequest), - typeof(XpackDeprecationInfoRequest), - + typeof(CreateRequest<>) }; var types = typeof(IRequest).Assembly().GetTypes(); diff --git a/src/Tests/Framework/TestClient.cs b/src/Tests/Framework/TestClient.cs index 1c60139e638..bc0548fdab3 100644 --- a/src/Tests/Framework/TestClient.cs +++ b/src/Tests/Framework/TestClient.cs @@ -179,10 +179,19 @@ public static IElasticClient GetFixedReturnClient( string contentType = "application/json", Exception exception = null) { - var serializer = Default.Serializer; - var fixedResult = contentType == "application/json" - ? serializer.SerializeToBytes(response) - : Encoding.UTF8.GetBytes(response.ToString()); + byte[] fixedResult; + + if (response.GetType() == typeof(string)) + { + fixedResult = Encoding.UTF8.GetBytes((string)response); + } + else + { + var serializer = Default.Serializer; + fixedResult = contentType == "application/json" + ? serializer.SerializeToBytes(response) + : Encoding.UTF8.GetBytes(response.ToString()); + } var connection = new InMemoryConnection(fixedResult, statusCode, exception); var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200")); diff --git a/src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs b/src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs new file mode 100644 index 00000000000..c2215346dce --- /dev/null +++ b/src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs @@ -0,0 +1,32 @@ +using System; +using Elasticsearch.Net; +using Nest; +using Tests.Framework; +using Tests.Framework.Integration; +using Tests.Framework.ManagedElasticsearch.Clusters; +using Xunit; + +namespace Tests.Ingest.IngestProcessorGrok +{ + public class IngestProcessorGrokApiTests : ApiTestBase + { + public IngestProcessorGrokApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + + protected override LazyResponses ClientUsage() => Calls( + fluent: (client, f) => client.IngestProcessorGrok(f), + fluentAsync: (client, f) => client.IngestProcessorGrokAsync(f), + request: (client, r) => client.IngestProcessorGrok(r), + requestAsync: (client, r) => client.IngestProcessorGrokAsync(r) + ); + + protected override HttpMethod HttpMethod => HttpMethod.GET; + + protected override string UrlPath => $"/_ingest/processor/grok"; + + protected override IngestProcessorGrokDescriptor NewDescriptor() => new IngestProcessorGrokDescriptor(); + + protected override Func Fluent => d => d; + + protected override IngestProcessorGrokRequest Initializer => new IngestProcessorGrokRequest(); + } +} diff --git a/src/Tests/Ingest/Processor/IngestProcessorGrokTests.cs b/src/Tests/Ingest/Processor/IngestProcessorGrokTests.cs new file mode 100644 index 00000000000..9217829ccd8 --- /dev/null +++ b/src/Tests/Ingest/Processor/IngestProcessorGrokTests.cs @@ -0,0 +1,20 @@ +using System.Threading.Tasks; +using Nest; +using Tests.Framework; +using static Tests.Framework.UrlTester; + +namespace Tests.Ingest.Processor +{ + public class IngestProcessorGrokUrlTests + { + [U] public async Task Urls() + { + await GET($"/_ingest/processor/grok") + .Fluent(c => c.IngestProcessorGrok()) + .Request(c => c.IngestProcessorGrok()) + .FluentAsync(c => c.IngestProcessorGrokAsync()) + .RequestAsync(c => c.IngestProcessorGrokAsync()) + ; + } + } +} diff --git a/src/Tests/Ingest/Processor/IngestProcessorGrokUnitTests.cs b/src/Tests/Ingest/Processor/IngestProcessorGrokUnitTests.cs new file mode 100644 index 00000000000..a862e438769 --- /dev/null +++ b/src/Tests/Ingest/Processor/IngestProcessorGrokUnitTests.cs @@ -0,0 +1,26 @@ +using System.Linq; +using FluentAssertions; +using Nest; +using Tests.Framework; + +namespace Tests.XPack.IngestProcessorGrok +{ + public class IngestProcessorGrokUnitTests + { + [U] + public void ShouldDeserialize() + { + const string fixedResponse = "{ \"patterns\" : { \"BACULA_CAPACITY\" : \"%{INT}{1,3}(,%{INT}{3})*\", \"PATH\" : \"(?:%{UNIXPATH}|%{WINPATH})\" } }"; + var client = TestClient.GetFixedReturnClient(fixedResponse); + + //warmup + var response = client.IngestProcessorGrok(); + response.ShouldBeValid(); + + response.Patterns.Should().NotBeNull(); + response.Patterns.Should().HaveCount(2); + response.Patterns.Should().ContainKey("BACULA_CAPACITY"); + response.Patterns.Should().ContainKey("PATH"); + } + } +} diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index e3410cd18af..077364dfdea 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -1,4 +1,4 @@ - + 1 diff --git a/src/Tests/XPack/DeprecationInfo/DeprecationInfoUnitTests.cs b/src/Tests/XPack/DeprecationInfo/DeprecationInfoUnitTests.cs new file mode 100644 index 00000000000..6c1362e6935 --- /dev/null +++ b/src/Tests/XPack/DeprecationInfo/DeprecationInfoUnitTests.cs @@ -0,0 +1,42 @@ +using System.Linq; +using FluentAssertions; +using Nest; +using Tests.Framework; + +namespace Tests.XPack.DeprecationInfo +{ + public class DeprecationInfoUnitTests + { + [U] + public void ShouldDeserialize() + { + const string fixedResponse = "{ \"cluster_settings\" : [ { \"level\" : \"info\", \"message\" : \"Network settings changes\", \"url\" : \"https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_indices_changes.html#_index_templates_use_literal_index_patterns_literal_instead_of_literal_template_literal\", \"details\" : \"templates using template field: watches,.monitoring-alerts,.watch-history-6,.ml-notifications,security-index-template,triggered_watches,.monitoring-es,.ml-meta,.ml-state,.monitoring-logstash,.ml-anomalies-,.monitoring-kibana\" } ], \"node_settings\" : [ ], \"index_settings\" : { \".monitoring-es-6-2017.07.21\" : [ { \"level\" : \"info\", \"message\" : \"Coercion of boolean fields\", \"url\" : \"https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields\", \"details\" : \"\" } ] } }"; + var client = TestClient.GetFixedReturnClient(fixedResponse); + + //warmup + var response = client.DeprecationInfo(); + response.ShouldBeValid(); + + response.ClusterSettings.Should().NotBeNull(); + response.ClusterSettings.Should().HaveCount(1); + response.ClusterSettings.First().Level.Should().Be(DeprecationWarningLevel.Information); + response.ClusterSettings.First().Message.Should().Be("Network settings changes"); + response.ClusterSettings.First().Url.Should().Be("https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_indices_changes.html#_index_templates_use_literal_index_patterns_literal_instead_of_literal_template_literal"); + response.ClusterSettings.First().Details.Should().Be("templates using template field: watches,.monitoring-alerts,.watch-history-6,.ml-notifications,security-index-template,triggered_watches,.monitoring-es,.ml-meta,.ml-state,.monitoring-logstash,.ml-anomalies-,.monitoring-kibana"); + + response.NodeSettings.Should().NotBeNull(); + response.NodeSettings.Should().BeEmpty(); + + response.IndexSettings.Should().NotBeNull(); + response.IndexSettings.Should().HaveCount(1); + + const string indexName = ".monitoring-es-6-2017.07.21"; + response.IndexSettings.Should().ContainKey(indexName); + response.IndexSettings[indexName].Count.Should().Be(1); + response.IndexSettings[indexName].First().Details.Should().Be(""); + response.IndexSettings[indexName].First().Url.Should().Be("https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields"); + response.IndexSettings[indexName].First().Message.Should().Be("Coercion of boolean fields"); + response.IndexSettings[indexName].First().Level.Should().Be(DeprecationWarningLevel.Information); + } + } +} diff --git a/src/Tests/XPack/DeprecationInfo/DeprecationInfoUrlTests.cs b/src/Tests/XPack/DeprecationInfo/DeprecationInfoUrlTests.cs new file mode 100644 index 00000000000..3e3ac0e39fd --- /dev/null +++ b/src/Tests/XPack/DeprecationInfo/DeprecationInfoUrlTests.cs @@ -0,0 +1,31 @@ +using System.Threading.Tasks; +using Nest; +using Tests.Framework; +using Tests.Framework.MockData; +using static Nest.Infer; +using static Tests.Framework.UrlTester; + +namespace Tests.XPack.DeprecationInfo +{ + public class DeprecationInfoUrlTests : IUrlTests + { + [U] public async Task Urls() + { + await GET("/_xpack/migration/deprecations") + .Fluent(c => c.DeprecationInfo(d => d)) + .Request(c => c.DeprecationInfo(new DeprecationInfoRequest())) + .FluentAsync(c => c.DeprecationInfoAsync(d => d)) + .RequestAsync(c => c.DeprecationInfoAsync(new DeprecationInfoRequest())) + ; + + var index = "another-index"; + + await GET($"/{index}/_xpack/migration/deprecations") + .Fluent(c => c.DeprecationInfo(d=>d.Index(index))) + .Request(c => c.DeprecationInfo(new DeprecationInfoRequest(index))) + .FluentAsync(c => c.DeprecationInfoAsync(d=>d.Index(index))) + .RequestAsync(c => c.DeprecationInfoAsync(new DeprecationInfoRequest(index))) + ; + } + } +} From 151ba839059cecfda00886ff1743703878f4529e Mon Sep 17 00:00:00 2001 From: codebrain Date: Fri, 10 Nov 2017 13:33:32 +1100 Subject: [PATCH 3/6] Fix generated code --- src/Nest/_Generated/_Descriptors.generated.cs | 29 +++---- src/Nest/_Generated/_Requests.generated.cs | 82 +++++++++---------- 2 files changed, 48 insertions(+), 63 deletions(-) diff --git a/src/Nest/_Generated/_Descriptors.generated.cs b/src/Nest/_Generated/_Descriptors.generated.cs index 49173450b9f..ce9bd6397be 100644 --- a/src/Nest/_Generated/_Descriptors.generated.cs +++ b/src/Nest/_Generated/_Descriptors.generated.cs @@ -4335,9 +4335,6 @@ public partial class IngestProcessorGrokDescriptor : RequestDescriptorBaseA comma-separated list of filters used to reduce the respone. public IngestProcessorGrokDescriptor FilterPath(params string[] filter_path) => AssignParam(p=>p.FilterPath(filter_path)); - - //TODO THIS METHOD IS UNMAPPED! - } @@ -4863,9 +4860,6 @@ public NodesUsageDescriptor() : base(){} ///A comma-separated list of filters used to reduce the respone. public NodesUsageDescriptor FilterPath(params string[] filter_path) => AssignParam(p=>p.FilterPath(filter_path)); - - //TODO THIS METHOD IS UNMAPPED! - } @@ -6135,37 +6129,34 @@ public GraphExploreDescriptor(Indices index) : base(r=>r.Required("index", index } ///descriptor for XpackDeprecationInfo
http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html
- public partial class XpackDeprecationInfoDescriptor : RequestDescriptorBase, IXpackDeprecationInfoRequest + public partial class DeprecationInfoDescriptor : RequestDescriptorBase, IDeprecationInfoRequest { - IndexName IXpackDeprecationInfoRequest.Index => Self.RouteValues.Get("index"); + IndexName IDeprecationInfoRequest.Index => Self.RouteValues.Get("index"); /// /_xpack/migration/deprecations - public XpackDeprecationInfoDescriptor() : base(){} + public DeprecationInfoDescriptor() : base(){} ///Index pattern - public XpackDeprecationInfoDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Optional("index", index)); + public DeprecationInfoDescriptor Index(IndexName index) => Assign(a=>a.RouteValues.Optional("index", index)); ///a shortcut into calling Index(typeof(TOther)) - public XpackDeprecationInfoDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (IndexName)typeof(TOther))); + public DeprecationInfoDescriptor Index() where TOther : class => Assign(a=>a.RouteValues.Optional("index", (IndexName)typeof(TOther))); ///Pretty format the returned JSON response. - public XpackDeprecationInfoDescriptor Pretty(bool pretty = true) => AssignParam(p=>p.Pretty(pretty)); + public DeprecationInfoDescriptor Pretty(bool pretty = true) => AssignParam(p=>p.Pretty(pretty)); ///Return human readable values for statistics. - public XpackDeprecationInfoDescriptor Human(bool human = true) => AssignParam(p=>p.Human(human)); + public DeprecationInfoDescriptor Human(bool human = true) => AssignParam(p=>p.Human(human)); ///Include the stack trace of returned errors. - public XpackDeprecationInfoDescriptor ErrorTrace(bool error_trace = true) => AssignParam(p=>p.ErrorTrace(error_trace)); + public DeprecationInfoDescriptor ErrorTrace(bool error_trace = true) => AssignParam(p=>p.ErrorTrace(error_trace)); ///The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - public XpackDeprecationInfoDescriptor SourceQueryString(string source) => AssignParam(p=>p.Source(source)); + public DeprecationInfoDescriptor SourceQueryString(string source) => AssignParam(p=>p.Source(source)); ///A comma-separated list of filters used to reduce the respone. - public XpackDeprecationInfoDescriptor FilterPath(params string[] filter_path) => AssignParam(p=>p.FilterPath(filter_path)); - - //TODO THIS METHOD IS UNMAPPED! - + public DeprecationInfoDescriptor FilterPath(params string[] filter_path) => AssignParam(p=>p.FilterPath(filter_path)); } diff --git a/src/Nest/_Generated/_Requests.generated.cs b/src/Nest/_Generated/_Requests.generated.cs index aca37cbbc8a..d89ee537081 100644 --- a/src/Nest/_Generated/_Requests.generated.cs +++ b/src/Nest/_Generated/_Requests.generated.cs @@ -3338,6 +3338,42 @@ public DeleteWatchRequest(Id id) : base(r=>r.Required("id", id)){} } + [JsonObject(MemberSerialization = MemberSerialization.OptIn)] + public partial interface IDeprecationInfoRequest : IRequest + { + IndexName Index { get; } + } + ///Request parameters for XpackDeprecationInfo
http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html
+ public partial class DeprecationInfoRequest : PlainRequestBase, IDeprecationInfoRequest + { + protected IDeprecationInfoRequest Self => this; + IndexName IDeprecationInfoRequest.Index => Self.RouteValues.Get("index"); + /// /_xpack/migration/deprecations + public DeprecationInfoRequest() : base(){} + + + /// /{index}/_xpack/migration/deprecations +///Optional, accepts null + public DeprecationInfoRequest(IndexName index) : base(r=>r.Optional("index", index)){} + + + ///Pretty format the returned JSON response. + public bool Pretty { get { return Q("pretty"); } set { Q("pretty", value); } } + + ///Return human readable values for statistics. + public bool Human { get { return Q("human"); } set { Q("human", value); } } + + ///Include the stack trace of returned errors. + public bool ErrorTrace { get { return Q("error_trace"); } set { Q("error_trace", value); } } + + ///The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + public string SourceQueryString { get { return Q("source"); } set { Q("source", value); } } + + ///A comma-separated list of filters used to reduce the respone. + public string[] FilterPath { get { return Q< string[]>("filter_path"); } set { Q("filter_path", value); } } + + } + [JsonObject(MemberSerialization = MemberSerialization.OptIn)] public partial interface IDisableUserRequest : IRequest { @@ -5463,9 +5499,7 @@ public partial class IngestProcessorGrokRequest : PlainRequestBaseA comma-separated list of filters used to reduce the respone.
public string[] FilterPath { get { return Q< string[]>("filter_path"); } set { Q("filter_path", value); } } - //TODO THIS METHOD IS UNMAPPED! - - } + } [JsonObject(MemberSerialization = MemberSerialization.OptIn)] public partial interface IInvalidateUserAccessTokenRequest : IRequest @@ -6042,9 +6076,7 @@ public NodesUsageRequest(NodeIds node_id, NodesUsageMetric metric) : base(r=>r.O ///A comma-separated list of filters used to reduce the respone. public string[] FilterPath { get { return Q< string[]>("filter_path"); } set { Q("filter_path", value); } } - //TODO THIS METHOD IS UNMAPPED! - - } + } [JsonObject(MemberSerialization = MemberSerialization.OptIn)] public partial interface IOpenIndexRequest : IRequest @@ -9223,44 +9255,6 @@ public WatcherStatsRequest(WatcherStatsMetric watcher_stats_metric) : base(r=>r. } - [JsonObject(MemberSerialization = MemberSerialization.OptIn)] - public partial interface IXpackDeprecationInfoRequest : IRequest - { - IndexName Index { get; } - } - ///Request parameters for XpackDeprecationInfo
http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html
- public partial class XpackDeprecationInfoRequest : PlainRequestBase, IXpackDeprecationInfoRequest - { - protected IXpackDeprecationInfoRequest Self => this; - IndexName IXpackDeprecationInfoRequest.Index => Self.RouteValues.Get("index"); - /// /_xpack/migration/deprecations - public XpackDeprecationInfoRequest() : base(){} - - - /// /{index}/_xpack/migration/deprecations -///Optional, accepts null - public XpackDeprecationInfoRequest(IndexName index) : base(r=>r.Optional("index", index)){} - - - ///Pretty format the returned JSON response. - public bool Pretty { get { return Q("pretty"); } set { Q("pretty", value); } } - - ///Return human readable values for statistics. - public bool Human { get { return Q("human"); } set { Q("human", value); } } - - ///Include the stack trace of returned errors. - public bool ErrorTrace { get { return Q("error_trace"); } set { Q("error_trace", value); } } - - ///The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - public string SourceQueryString { get { return Q("source"); } set { Q("source", value); } } - - ///A comma-separated list of filters used to reduce the respone. - public string[] FilterPath { get { return Q< string[]>("filter_path"); } set { Q("filter_path", value); } } - - //TODO THIS METHOD IS UNMAPPED! - - } - [JsonObject(MemberSerialization = MemberSerialization.OptIn)] public partial interface IXPackInfoRequest : IRequest { From ac4085d6c48f2a652f2fffd182bf906b888e64fb Mon Sep 17 00:00:00 2001 From: codebrain Date: Fri, 10 Nov 2017 14:53:58 +1100 Subject: [PATCH 4/6] Addressed PR comments --- .../ElasticClient-NodesHotThreads.cs | 2 +- .../Cluster/NodesUsage/NodeUsageResponse.cs | 24 +++++++++---------- .../ElasticClient-IngestProcessorGrok.cs | 7 ++---- .../Processor/IngestProcessorGrokResponse.cs | 2 +- .../DeprecationInfoResponse.cs | 14 +++++------ .../Cluster/NodesUsage/NodesUsageApiTests.cs | 8 +++---- .../Cluster/NodesUsage/NodesUsageUnitTests.cs | 22 +++++++++-------- .../Processor/IngestProcessorGrokApiTests.cs | 2 -- .../DeprecationInfoUnitTests.cs | 11 +++++---- .../DeprecationInfoUrlTests.cs | 4 ++-- 10 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/Nest/Cluster/NodesHotThreads/ElasticClient-NodesHotThreads.cs b/src/Nest/Cluster/NodesHotThreads/ElasticClient-NodesHotThreads.cs index 9ca44de1c28..0f47ba9dcf9 100644 --- a/src/Nest/Cluster/NodesHotThreads/ElasticClient-NodesHotThreads.cs +++ b/src/Nest/Cluster/NodesHotThreads/ElasticClient-NodesHotThreads.cs @@ -5,10 +5,10 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using Elasticsearch.Net; +using System.Threading; namespace Nest { - using System.Threading; using NodesHotThreadConverter = Func; public partial interface IElasticClient diff --git a/src/Nest/Cluster/NodesUsage/NodeUsageResponse.cs b/src/Nest/Cluster/NodesUsage/NodeUsageResponse.cs index 0df47455066..4ed0d76b814 100644 --- a/src/Nest/Cluster/NodesUsage/NodeUsageResponse.cs +++ b/src/Nest/Cluster/NodesUsage/NodeUsageResponse.cs @@ -4,29 +4,29 @@ namespace Nest { - public class NodeUsageMetadata + public class NodesMetaData { - [JsonProperty(PropertyName = "total")] + [JsonProperty("total")] public int Total { get; internal set; } - [JsonProperty(PropertyName = "successful")] + [JsonProperty("successful")] public int Successful { get; internal set; } - [JsonProperty(PropertyName = "failed")] + [JsonProperty("failed")] public int Failed { get; internal set; } } public class NodeUsageInformation { - [JsonProperty(PropertyName = "timestamp")] + [JsonProperty("timestamp")] [JsonConverter(typeof(EpochMillisecondsDateTimeJsonConverter))] public DateTimeOffset Timestamp { get; internal set; } - [JsonProperty(PropertyName = "since")] + [JsonProperty("since")] [JsonConverter(typeof(EpochMillisecondsDateTimeJsonConverter))] public DateTimeOffset Since { get; internal set; } - [JsonProperty(PropertyName = "rest_actions")] + [JsonProperty("rest_actions")] public IReadOnlyDictionary RestActions { get; internal set; } } @@ -36,18 +36,18 @@ public interface INodesUsageResponse : IResponse IReadOnlyDictionary Nodes { get; } - NodeUsageMetadata NodeMetadata { get; } + NodesMetaData NodesMetaData { get; } } public class NodesUsageResponse : ResponseBase, INodesUsageResponse { - [JsonProperty(PropertyName = "cluster_name")] + [JsonProperty("cluster_name")] public string ClusterName { get; internal set; } - [JsonProperty(PropertyName = "nodes")] + [JsonProperty("nodes")] public IReadOnlyDictionary Nodes { get; internal set; } = EmptyReadOnly.Dictionary; - [JsonProperty(PropertyName = "_nodes")] - public NodeUsageMetadata NodeMetadata { get; internal set; } + [JsonProperty("_nodes")] + public NodesMetaData NodesMetaData { get; internal set; } } } diff --git a/src/Nest/Ingest/Processor/ElasticClient-IngestProcessorGrok.cs b/src/Nest/Ingest/Processor/ElasticClient-IngestProcessorGrok.cs index 9dd447745ef..7f3277d6083 100644 --- a/src/Nest/Ingest/Processor/ElasticClient-IngestProcessorGrok.cs +++ b/src/Nest/Ingest/Processor/ElasticClient-IngestProcessorGrok.cs @@ -1,17 +1,14 @@ using System; -using System.IO; using System.Threading.Tasks; using Elasticsearch.Net; +using System.Threading; namespace Nest { - using System.Threading; - using NodesHotThreadConverter = Func; - public partial interface IElasticClient { /// - /// Retrieving which patterns which the grok processor is packaged with, useful as different versions are bundled with different processors. + /// Retrieving which patterns the grok processor is packaged with, useful as different versions are bundled with different processors. /// https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html /// /// An optional descriptor to further describe the endpoint usage operation diff --git a/src/Nest/Ingest/Processor/IngestProcessorGrokResponse.cs b/src/Nest/Ingest/Processor/IngestProcessorGrokResponse.cs index cb4e7c47674..34573191a40 100644 --- a/src/Nest/Ingest/Processor/IngestProcessorGrokResponse.cs +++ b/src/Nest/Ingest/Processor/IngestProcessorGrokResponse.cs @@ -11,7 +11,7 @@ public interface IIngestProcessorGrokResponse : IResponse public class IngestProcessorGrokResponse : ResponseBase, IIngestProcessorGrokResponse { - [JsonProperty(PropertyName = "patterns")] + [JsonProperty("patterns")] public IReadOnlyDictionary Patterns { get; internal set; } = EmptyReadOnly.Dictionary; } } diff --git a/src/Nest/XPack/DeprecationInfo/DeprecationInfoResponse.cs b/src/Nest/XPack/DeprecationInfo/DeprecationInfoResponse.cs index 29da3c1459b..3d3b8ba99af 100644 --- a/src/Nest/XPack/DeprecationInfo/DeprecationInfoResponse.cs +++ b/src/Nest/XPack/DeprecationInfo/DeprecationInfoResponse.cs @@ -20,7 +20,7 @@ public enum DeprecationWarningLevel Critical } - public class DeprecationInfoItem + public class DeprecationInfo { [JsonProperty("level")] public DeprecationWarningLevel Level { get; internal set; } @@ -38,19 +38,19 @@ public class DeprecationInfoItem public interface IDeprecationInfoResponse : IResponse { [JsonProperty("cluster_settings")] - IReadOnlyCollection ClusterSettings { get; } + IReadOnlyCollection ClusterSettings { get; } [JsonProperty("node_settings")] - IReadOnlyCollection NodeSettings { get; } + IReadOnlyCollection NodeSettings { get; } [JsonProperty("index_settings")] - IReadOnlyDictionary> IndexSettings { get; } + IReadOnlyDictionary> IndexSettings { get; } } public class DeprecationInfoResponse : ResponseBase, IDeprecationInfoResponse { - public IReadOnlyCollection ClusterSettings { get; internal set; } = EmptyReadOnly.Collection; - public IReadOnlyCollection NodeSettings { get; internal set; } = EmptyReadOnly.Collection; - public IReadOnlyDictionary> IndexSettings { get; internal set; } = EmptyReadOnly>.Dictionary; + public IReadOnlyCollection ClusterSettings { get; internal set; } = EmptyReadOnly.Collection; + public IReadOnlyCollection NodeSettings { get; internal set; } = EmptyReadOnly.Collection; + public IReadOnlyDictionary> IndexSettings { get; internal set; } = EmptyReadOnly>.Dictionary; } } diff --git a/src/Tests/Cluster/NodesUsage/NodesUsageApiTests.cs b/src/Tests/Cluster/NodesUsage/NodesUsageApiTests.cs index 3a3958542ec..9e48c2a890e 100644 --- a/src/Tests/Cluster/NodesUsage/NodesUsageApiTests.cs +++ b/src/Tests/Cluster/NodesUsage/NodesUsageApiTests.cs @@ -29,10 +29,10 @@ protected override void ExpectResponse(INodesUsageResponse response) { response.ClusterName.Should().NotBeEmpty(); - response.NodeMetadata.Should().NotBeNull(); - response.NodeMetadata.Total.Should().Be(1); - response.NodeMetadata.Successful.Should().Be(1); - response.NodeMetadata.Failed.Should().Be(0); + response.NodesMetaData.Should().NotBeNull(); + response.NodesMetaData.Total.Should().Be(1); + response.NodesMetaData.Successful.Should().Be(1); + response.NodesMetaData.Failed.Should().Be(0); response.Nodes.Should().NotBeNull(); response.Nodes.Should().HaveCount(1); diff --git a/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs b/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs index f4c36be74fe..bfe7f126b3a 100644 --- a/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs +++ b/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs @@ -18,10 +18,10 @@ public void ShouldDeserialize() response.ClusterName.Should().Be("my_cluster"); - response.NodeMetadata.Should().NotBeNull(); - response.NodeMetadata.Total.Should().Be(1); - response.NodeMetadata.Successful.Should().Be(1); - response.NodeMetadata.Failed.Should().Be(0); + response.NodesMetaData.Should().NotBeNull(); + response.NodesMetaData.Total.Should().Be(1); + response.NodesMetaData.Successful.Should().Be(1); + response.NodesMetaData.Failed.Should().Be(0); response.Nodes.Should().NotBeNull(); response.Nodes.Should().HaveCount(1); @@ -29,12 +29,14 @@ public void ShouldDeserialize() const string nodeId = "pQHNt5rXTTWNvUgOrdynKg"; response.Nodes.Should().ContainKey(nodeId); - response.Nodes[nodeId].Timestamp.Should().Be(new DateTimeOffset(2017, 4, 18, 22, 19, 21, 812, TimeSpan.Zero)); - response.Nodes[nodeId].Since.Should().Be(new DateTimeOffset(2017, 4, 18, 22, 18, 26, 606, TimeSpan.Zero)); - response.Nodes[nodeId].RestActions.Should().NotBeNull(); - response.Nodes[nodeId].RestActions.Should().HaveCount(5); - response.Nodes[nodeId].RestActions.Should().ContainKey("org.elasticsearch.rest.action.search.RestSearchAction"); - response.Nodes[nodeId].RestActions["org.elasticsearch.rest.action.search.RestSearchAction"].Should().Be(19); + + var node = response.Nodes[nodeId]; + node.Timestamp.Should().Be(new DateTimeOffset(2017, 4, 18, 22, 19, 21, 812, TimeSpan.Zero)); + node.Since.Should().Be(new DateTimeOffset(2017, 4, 18, 22, 18, 26, 606, TimeSpan.Zero)); + node.RestActions.Should().NotBeNull(); + node.RestActions.Should().HaveCount(5); + node.RestActions.Should().ContainKey("org.elasticsearch.rest.action.search.RestSearchAction"); + node.RestActions["org.elasticsearch.rest.action.search.RestSearchAction"].Should().Be(19); } } } diff --git a/src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs b/src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs index c2215346dce..861f9ec8082 100644 --- a/src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs +++ b/src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs @@ -23,8 +23,6 @@ protected override LazyResponses ClientUsage() => Calls( protected override string UrlPath => $"/_ingest/processor/grok"; - protected override IngestProcessorGrokDescriptor NewDescriptor() => new IngestProcessorGrokDescriptor(); - protected override Func Fluent => d => d; protected override IngestProcessorGrokRequest Initializer => new IngestProcessorGrokRequest(); diff --git a/src/Tests/XPack/DeprecationInfo/DeprecationInfoUnitTests.cs b/src/Tests/XPack/DeprecationInfo/DeprecationInfoUnitTests.cs index 6c1362e6935..a2f54c3e474 100644 --- a/src/Tests/XPack/DeprecationInfo/DeprecationInfoUnitTests.cs +++ b/src/Tests/XPack/DeprecationInfo/DeprecationInfoUnitTests.cs @@ -31,12 +31,15 @@ public void ShouldDeserialize() response.IndexSettings.Should().HaveCount(1); const string indexName = ".monitoring-es-6-2017.07.21"; + response.IndexSettings.Should().ContainKey(indexName); response.IndexSettings[indexName].Count.Should().Be(1); - response.IndexSettings[indexName].First().Details.Should().Be(""); - response.IndexSettings[indexName].First().Url.Should().Be("https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields"); - response.IndexSettings[indexName].First().Message.Should().Be("Coercion of boolean fields"); - response.IndexSettings[indexName].First().Level.Should().Be(DeprecationWarningLevel.Information); + + var deprecationInfo = response.IndexSettings[indexName].First(); + deprecationInfo.Details.Should().Be(""); + deprecationInfo.Url.Should().Be("https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields"); + deprecationInfo.Message.Should().Be("Coercion of boolean fields"); + deprecationInfo.Level.Should().Be(DeprecationWarningLevel.Information); } } } diff --git a/src/Tests/XPack/DeprecationInfo/DeprecationInfoUrlTests.cs b/src/Tests/XPack/DeprecationInfo/DeprecationInfoUrlTests.cs index 3e3ac0e39fd..45e0a111b6d 100644 --- a/src/Tests/XPack/DeprecationInfo/DeprecationInfoUrlTests.cs +++ b/src/Tests/XPack/DeprecationInfo/DeprecationInfoUrlTests.cs @@ -12,9 +12,9 @@ public class DeprecationInfoUrlTests : IUrlTests [U] public async Task Urls() { await GET("/_xpack/migration/deprecations") - .Fluent(c => c.DeprecationInfo(d => d)) + .Fluent(c => c.DeprecationInfo()) .Request(c => c.DeprecationInfo(new DeprecationInfoRequest())) - .FluentAsync(c => c.DeprecationInfoAsync(d => d)) + .FluentAsync(c => c.DeprecationInfoAsync()) .RequestAsync(c => c.DeprecationInfoAsync(new DeprecationInfoRequest())) ; From 9b2ab5016cf6c5bee8a8cb382dd2f6805c0af3d2 Mon Sep 17 00:00:00 2001 From: codebrain Date: Tue, 14 Nov 2017 07:15:58 +1100 Subject: [PATCH 5/6] Rename to GrokProcessorPatterns --- .../RequestParameters.Generated.cs | 12 ++--- .../ElasticLowLevelClient.Generated.cs | 4 +- .../IElasticLowLevelClient.Generated.cs | 4 +- .../ElasticClient-GrokProcessorPatterns.cs | 52 +++++++++++++++++++ .../ElasticClient-IngestProcessorGrok.cs | 52 ------------------- .../Processor/GrokProcessorPatternsRequest.cs | 9 ++++ ...se.cs => GrokProcessorPatternsResponse.cs} | 4 +- .../Processor/IngestProcessorGrokRequest.cs | 9 ---- src/Nest/_Generated/_Descriptors.generated.cs | 12 ++--- .../_Generated/_LowLevelDispatch.generated.cs | 4 +- src/Nest/_Generated/_Requests.generated.cs | 50 +++++++++--------- .../Cluster/NodesUsage/NodesUsageUnitTests.cs | 5 +- .../Processor/IngestProcessorGrokApiTests.cs | 18 +++---- .../Processor/IngestProcessorGrokTests.cs | 10 ++-- .../Processor/IngestProcessorGrokUnitTests.cs | 6 +-- 15 files changed, 125 insertions(+), 126 deletions(-) create mode 100644 src/Nest/Ingest/Processor/ElasticClient-GrokProcessorPatterns.cs delete mode 100644 src/Nest/Ingest/Processor/ElasticClient-IngestProcessorGrok.cs create mode 100644 src/Nest/Ingest/Processor/GrokProcessorPatternsRequest.cs rename src/Nest/Ingest/Processor/{IngestProcessorGrokResponse.cs => GrokProcessorPatternsResponse.cs} (67%) delete mode 100644 src/Nest/Ingest/Processor/IngestProcessorGrokRequest.cs diff --git a/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs b/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs index eec06e2a4d9..d5db6f0d037 100644 --- a/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs +++ b/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs @@ -4441,28 +4441,28 @@ public class GetPipelineRequestParameters : FluentRequestParameters ///
- public class IngestProcessorGrokRequestParameters : FluentRequestParameters + public class GrokProcessorPatternsRequestParameters : FluentRequestParameters { public override HttpMethod DefaultHttpMethod => HttpMethod.GET; ///Pretty format the returned JSON response. - public IngestProcessorGrokRequestParameters Pretty(bool pretty) => this.AddQueryString("pretty", pretty); + public GrokProcessorPatternsRequestParameters Pretty(bool pretty) => this.AddQueryString("pretty", pretty); ///Return human readable values for statistics. - public IngestProcessorGrokRequestParameters Human(bool human) => this.AddQueryString("human", human); + public GrokProcessorPatternsRequestParameters Human(bool human) => this.AddQueryString("human", human); ///Include the stack trace of returned errors. - public IngestProcessorGrokRequestParameters ErrorTrace(bool error_trace) => this.AddQueryString("error_trace", error_trace); + public GrokProcessorPatternsRequestParameters ErrorTrace(bool error_trace) => this.AddQueryString("error_trace", error_trace); ///The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - public IngestProcessorGrokRequestParameters Source(string source) => this.AddQueryString("source", source); + public GrokProcessorPatternsRequestParameters Source(string source) => this.AddQueryString("source", source); ///A comma-separated list of filters used to reduce the respone. - public IngestProcessorGrokRequestParameters FilterPath(params string[] filter_path) => this.AddQueryString("filter_path", filter_path); + public GrokProcessorPatternsRequestParameters FilterPath(params string[] filter_path) => this.AddQueryString("filter_path", filter_path); } diff --git a/src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs b/src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs index ee967a3008b..a4798e7c9a8 100644 --- a/src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs +++ b/src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs @@ -4826,7 +4826,7 @@ public ElasticsearchResponse IngestGetPipeline(string id, FuncSee also: https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html /// ///A func that allows you to describe the querystring parameters & request specific connection settings. - public ElasticsearchResponse IngestProcessorGrok(Func requestParameters = null) + public ElasticsearchResponse IngestProcessorGrok(Func requestParameters = null) where T : class => this.DoRequest(GET, Url($"_ingest/processor/grok"), null, _params(requestParameters)); ///Represents a GET on /_ingest/processor/grok @@ -4839,7 +4839,7 @@ public ElasticsearchResponse IngestProcessorGrok(FuncSee also: https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html /// ///A func that allows you to describe the querystring parameters & request specific connection settings. - public Task> IngestProcessorGrokAsync(Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) + public Task> IngestProcessorGrokAsync(Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class => this.DoRequestAsync(GET, Url($"_ingest/processor/grok"), cancellationToken, null, _params(requestParameters)); ///Represents a PUT on /_ingest/pipeline/{id} diff --git a/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs b/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs index 862c7caec57..98f0153202a 100644 --- a/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs +++ b/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs @@ -4495,7 +4495,7 @@ public partial interface IElasticLowLevelClient ///See also: https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html /// ///A func that allows you to describe the querystring parameters & request specific connection settings. - ElasticsearchResponse IngestProcessorGrok(Func requestParameters = null) where T : class; + ElasticsearchResponse IngestProcessorGrok(Func requestParameters = null) where T : class; ///Represents a GET on /_ingest/processor/grok ///Returns: A task of ElasticsearchResponse<T> where the behaviour depends on the type of T: @@ -4507,7 +4507,7 @@ public partial interface IElasticLowLevelClient ///See also: https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html /// ///A func that allows you to describe the querystring parameters & request specific connection settings. - Task> IngestProcessorGrokAsync(Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class; + Task> IngestProcessorGrokAsync(Func requestParameters = null, CancellationToken cancellationToken = default(CancellationToken)) where T : class; ///Represents a PUT on /_ingest/pipeline/{id} ///Returns: ElasticsearchResponse<T> where the behavior depends on the type of T: diff --git a/src/Nest/Ingest/Processor/ElasticClient-GrokProcessorPatterns.cs b/src/Nest/Ingest/Processor/ElasticClient-GrokProcessorPatterns.cs new file mode 100644 index 00000000000..1ebb3f3d7ea --- /dev/null +++ b/src/Nest/Ingest/Processor/ElasticClient-GrokProcessorPatterns.cs @@ -0,0 +1,52 @@ +using System; +using System.Threading.Tasks; +using Elasticsearch.Net; +using System.Threading; + +namespace Nest +{ + public partial interface IElasticClient + { + /// + /// Retrieving which patterns the grok processor is packaged with, useful as different versions are bundled with different processors. + /// https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html + /// + /// An optional descriptor to further describe the endpoint usage operation + IGrokProcessorPatternsResponse GrokProcessorPatterns(Func selector = null); + + /// + IGrokProcessorPatternsResponse GrokProcessorPatterns(IGrokProcessorPatternsRequest request); + + /// + Task GrokProcessorPatternsAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); + + /// + Task GrokProcessorPatternsAsync(IGrokProcessorPatternsRequest request, CancellationToken cancellationToken = default(CancellationToken)); + } + + public partial class ElasticClient + { + /// + public IGrokProcessorPatternsResponse GrokProcessorPatterns(Func selector = null) => + this.GrokProcessorPatterns(selector.InvokeOrDefault(new GrokProcessorPatternsDescriptor())); + + /// + public IGrokProcessorPatternsResponse GrokProcessorPatterns(IGrokProcessorPatternsRequest request) => + this.Dispatcher.Dispatch( + request, + (p, d) => this.LowLevelDispatch.IngestProcessorGrokDispatch(p) + ); + + /// + public Task GrokProcessorPatternsAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => + this.GrokProcessorPatternsAsync(selector.InvokeOrDefault(new GrokProcessorPatternsDescriptor()), cancellationToken); + + /// + public Task GrokProcessorPatternsAsync(IGrokProcessorPatternsRequest request, CancellationToken cancellationToken = default(CancellationToken)) => + this.Dispatcher.DispatchAsync( + request, + cancellationToken, + (p, d, c) => this.LowLevelDispatch.IngestProcessorGrokDispatchAsync(p, c) + ); + } +} diff --git a/src/Nest/Ingest/Processor/ElasticClient-IngestProcessorGrok.cs b/src/Nest/Ingest/Processor/ElasticClient-IngestProcessorGrok.cs deleted file mode 100644 index 7f3277d6083..00000000000 --- a/src/Nest/Ingest/Processor/ElasticClient-IngestProcessorGrok.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Threading.Tasks; -using Elasticsearch.Net; -using System.Threading; - -namespace Nest -{ - public partial interface IElasticClient - { - /// - /// Retrieving which patterns the grok processor is packaged with, useful as different versions are bundled with different processors. - /// https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html - /// - /// An optional descriptor to further describe the endpoint usage operation - IIngestProcessorGrokResponse IngestProcessorGrok(Func selector = null); - - /// - IIngestProcessorGrokResponse IngestProcessorGrok(IIngestProcessorGrokRequest request); - - /// - Task IngestProcessorGrokAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)); - - /// - Task IngestProcessorGrokAsync(IIngestProcessorGrokRequest request, CancellationToken cancellationToken = default(CancellationToken)); - } - - public partial class ElasticClient - { - /// - public IIngestProcessorGrokResponse IngestProcessorGrok(Func selector = null) => - this.IngestProcessorGrok(selector.InvokeOrDefault(new IngestProcessorGrokDescriptor())); - - /// - public IIngestProcessorGrokResponse IngestProcessorGrok(IIngestProcessorGrokRequest request) => - this.Dispatcher.Dispatch( - request, - (p, d) => this.LowLevelDispatch.IngestProcessorGrokDispatch(p) - ); - - /// - public Task IngestProcessorGrokAsync(Func selector = null, CancellationToken cancellationToken = default(CancellationToken)) => - this.IngestProcessorGrokAsync(selector.InvokeOrDefault(new IngestProcessorGrokDescriptor()), cancellationToken); - - /// - public Task IngestProcessorGrokAsync(IIngestProcessorGrokRequest request, CancellationToken cancellationToken = default(CancellationToken)) => - this.Dispatcher.DispatchAsync( - request, - cancellationToken, - (p, d, c) => this.LowLevelDispatch.IngestProcessorGrokDispatchAsync(p, c) - ); - } -} diff --git a/src/Nest/Ingest/Processor/GrokProcessorPatternsRequest.cs b/src/Nest/Ingest/Processor/GrokProcessorPatternsRequest.cs new file mode 100644 index 00000000000..b75d80aef6d --- /dev/null +++ b/src/Nest/Ingest/Processor/GrokProcessorPatternsRequest.cs @@ -0,0 +1,9 @@ +namespace Nest +{ + public partial interface IGrokProcessorPatternsRequest { } + + public partial class GrokProcessorPatternsRequest { } + + [DescriptorFor("IngestProcessorGrok")] + public partial class GrokProcessorPatternsDescriptor { } +} diff --git a/src/Nest/Ingest/Processor/IngestProcessorGrokResponse.cs b/src/Nest/Ingest/Processor/GrokProcessorPatternsResponse.cs similarity index 67% rename from src/Nest/Ingest/Processor/IngestProcessorGrokResponse.cs rename to src/Nest/Ingest/Processor/GrokProcessorPatternsResponse.cs index 34573191a40..4142e70d2fe 100644 --- a/src/Nest/Ingest/Processor/IngestProcessorGrokResponse.cs +++ b/src/Nest/Ingest/Processor/GrokProcessorPatternsResponse.cs @@ -4,12 +4,12 @@ namespace Nest { - public interface IIngestProcessorGrokResponse : IResponse + public interface IGrokProcessorPatternsResponse : IResponse { IReadOnlyDictionary Patterns { get; } } - public class IngestProcessorGrokResponse : ResponseBase, IIngestProcessorGrokResponse + public class GrokProcessorPatternsResponse : ResponseBase, IGrokProcessorPatternsResponse { [JsonProperty("patterns")] public IReadOnlyDictionary Patterns { get; internal set; } = EmptyReadOnly.Dictionary; diff --git a/src/Nest/Ingest/Processor/IngestProcessorGrokRequest.cs b/src/Nest/Ingest/Processor/IngestProcessorGrokRequest.cs deleted file mode 100644 index a8862b3ff04..00000000000 --- a/src/Nest/Ingest/Processor/IngestProcessorGrokRequest.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Nest -{ - public partial interface IIngestProcessorGrokRequest { } - - public partial class IngestProcessorGrokRequest { } - - [DescriptorFor("IngestProcessorGrok")] - public partial class IngestProcessorGrokDescriptor { } -} diff --git a/src/Nest/_Generated/_Descriptors.generated.cs b/src/Nest/_Generated/_Descriptors.generated.cs index ce9bd6397be..f07c42d4809 100644 --- a/src/Nest/_Generated/_Descriptors.generated.cs +++ b/src/Nest/_Generated/_Descriptors.generated.cs @@ -4318,23 +4318,23 @@ public GetPipelineDescriptor() : base(){} } ///descriptor for IngestProcessorGrok
https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html
- public partial class IngestProcessorGrokDescriptor : RequestDescriptorBase, IIngestProcessorGrokRequest + public partial class GrokProcessorPatternsDescriptor : RequestDescriptorBase, IGrokProcessorPatternsRequest { ///Pretty format the returned JSON response. - public IngestProcessorGrokDescriptor Pretty(bool pretty = true) => AssignParam(p=>p.Pretty(pretty)); + public GrokProcessorPatternsDescriptor Pretty(bool pretty = true) => AssignParam(p=>p.Pretty(pretty)); ///Return human readable values for statistics. - public IngestProcessorGrokDescriptor Human(bool human = true) => AssignParam(p=>p.Human(human)); + public GrokProcessorPatternsDescriptor Human(bool human = true) => AssignParam(p=>p.Human(human)); ///Include the stack trace of returned errors. - public IngestProcessorGrokDescriptor ErrorTrace(bool error_trace = true) => AssignParam(p=>p.ErrorTrace(error_trace)); + public GrokProcessorPatternsDescriptor ErrorTrace(bool error_trace = true) => AssignParam(p=>p.ErrorTrace(error_trace)); ///The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - public IngestProcessorGrokDescriptor SourceQueryString(string source) => AssignParam(p=>p.Source(source)); + public GrokProcessorPatternsDescriptor SourceQueryString(string source) => AssignParam(p=>p.Source(source)); ///A comma-separated list of filters used to reduce the respone. - public IngestProcessorGrokDescriptor FilterPath(params string[] filter_path) => AssignParam(p=>p.FilterPath(filter_path)); + public GrokProcessorPatternsDescriptor FilterPath(params string[] filter_path) => AssignParam(p=>p.FilterPath(filter_path)); } diff --git a/src/Nest/_Generated/_LowLevelDispatch.generated.cs b/src/Nest/_Generated/_LowLevelDispatch.generated.cs index 1f961e6e4c0..8494472a7a1 100644 --- a/src/Nest/_Generated/_LowLevelDispatch.generated.cs +++ b/src/Nest/_Generated/_LowLevelDispatch.generated.cs @@ -2136,7 +2136,7 @@ internal Task> IngestGetPipelineDispatchAsync(IReque throw InvalidDispatch("IngestGetPipeline", p, new [] { GET }, "/_ingest/pipeline", "/_ingest/pipeline/{id}"); } - internal ElasticsearchResponse IngestProcessorGrokDispatch(IRequest p ) where T : class + internal ElasticsearchResponse IngestProcessorGrokDispatch(IRequest p ) where T : class { switch(p.HttpMethod) { @@ -2147,7 +2147,7 @@ internal ElasticsearchResponse IngestProcessorGrokDispatch(IRequest> IngestProcessorGrokDispatchAsync(IRequest p , CancellationToken cancellationToken) where T : class + internal Task> IngestProcessorGrokDispatchAsync(IRequest p , CancellationToken cancellationToken) where T : class { switch(p.HttpMethod) { diff --git a/src/Nest/_Generated/_Requests.generated.cs b/src/Nest/_Generated/_Requests.generated.cs index d89ee537081..ed83e072864 100644 --- a/src/Nest/_Generated/_Requests.generated.cs +++ b/src/Nest/_Generated/_Requests.generated.cs @@ -5184,6 +5184,31 @@ public GraphExploreRequest(Indices index, Types type) : base(r=>r.Required("inde } + [JsonObject(MemberSerialization = MemberSerialization.OptIn)] + public partial interface IGrokProcessorPatternsRequest : IRequest + { + } + ///Request parameters for IngestProcessorGrok
https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html
+ public partial class GrokProcessorPatternsRequest : PlainRequestBase, IGrokProcessorPatternsRequest + { + protected IGrokProcessorPatternsRequest Self => this; + ///Pretty format the returned JSON response. + public bool Pretty { get { return Q("pretty"); } set { Q("pretty", value); } } + + ///Return human readable values for statistics. + public bool Human { get { return Q("human"); } set { Q("human", value); } } + + ///Include the stack trace of returned errors. + public bool ErrorTrace { get { return Q("error_trace"); } set { Q("error_trace", value); } } + + ///The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + public string SourceQueryString { get { return Q("source"); } set { Q("source", value); } } + + ///A comma-separated list of filters used to reduce the respone. + public string[] FilterPath { get { return Q< string[]>("filter_path"); } set { Q("filter_path", value); } } + + } + [JsonObject(MemberSerialization = MemberSerialization.OptIn)] public partial interface IIndexExistsRequest : IRequest { @@ -5476,31 +5501,6 @@ public IndicesStatsRequest(Indices index, IndicesStatsMetric metric) : base(r=>r } - [JsonObject(MemberSerialization = MemberSerialization.OptIn)] - public partial interface IIngestProcessorGrokRequest : IRequest - { - } - ///Request parameters for IngestProcessorGrok
https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html
- public partial class IngestProcessorGrokRequest : PlainRequestBase, IIngestProcessorGrokRequest - { - protected IIngestProcessorGrokRequest Self => this; - ///Pretty format the returned JSON response. - public bool Pretty { get { return Q("pretty"); } set { Q("pretty", value); } } - - ///Return human readable values for statistics. - public bool Human { get { return Q("human"); } set { Q("human", value); } } - - ///Include the stack trace of returned errors. - public bool ErrorTrace { get { return Q("error_trace"); } set { Q("error_trace", value); } } - - ///The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. - public string SourceQueryString { get { return Q("source"); } set { Q("source", value); } } - - ///A comma-separated list of filters used to reduce the respone. - public string[] FilterPath { get { return Q< string[]>("filter_path"); } set { Q("filter_path", value); } } - - } - [JsonObject(MemberSerialization = MemberSerialization.OptIn)] public partial interface IInvalidateUserAccessTokenRequest : IRequest { diff --git a/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs b/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs index bfe7f126b3a..3ab02f40d88 100644 --- a/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs +++ b/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs @@ -9,7 +9,8 @@ public class NodesUsageUnitTests [U] public void ShouldDeserialize() { - const string fixedResponse = "{\"_nodes\": {\"total\": 1,\"successful\": 1,\"failed\": 0},\"cluster_name\": \"my_cluster\",\"nodes\": {\"pQHNt5rXTTWNvUgOrdynKg\": {\"timestamp\": 1492553961812,\"since\": 1492553906606,\"rest_actions\": {\"org.elasticsearch.rest.action.admin.cluster.RestNodesUsageAction\": 1,\"org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction\": 1,\"org.elasticsearch.rest.action.document.RestGetAction\": 1,\"org.elasticsearch.rest.action.search.RestSearchAction\": 19,\"org.elasticsearch.rest.action.admin.cluster.RestNodesInfoAction\": 36}}}}"; + const string nodeId = "pQHNt5rXTTWNvUgOrdynKg"; + const string fixedResponse = "{\"_nodes\": {\"total\": 1,\"successful\": 1,\"failed\": 0},\"cluster_name\": \"my_cluster\",\"nodes\": {\"" + nodeId + "\": {\"timestamp\": 1492553961812,\"since\": 1492553906606,\"rest_actions\": {\"org.elasticsearch.rest.action.admin.cluster.RestNodesUsageAction\": 1,\"org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction\": 1,\"org.elasticsearch.rest.action.document.RestGetAction\": 1,\"org.elasticsearch.rest.action.search.RestSearchAction\": 19,\"org.elasticsearch.rest.action.admin.cluster.RestNodesInfoAction\": 36}}}}"; var client = TestClient.GetFixedReturnClient(fixedResponse); //warmup @@ -26,8 +27,6 @@ public void ShouldDeserialize() response.Nodes.Should().NotBeNull(); response.Nodes.Should().HaveCount(1); - const string nodeId = "pQHNt5rXTTWNvUgOrdynKg"; - response.Nodes.Should().ContainKey(nodeId); var node = response.Nodes[nodeId]; diff --git a/src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs b/src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs index 861f9ec8082..826013cbab6 100644 --- a/src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs +++ b/src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs @@ -6,25 +6,25 @@ using Tests.Framework.ManagedElasticsearch.Clusters; using Xunit; -namespace Tests.Ingest.IngestProcessorGrok +namespace Tests.Ingest.GrokProcessorPatterns { - public class IngestProcessorGrokApiTests : ApiTestBase + public class GrokProcessorPatternsApiTests : ApiTestBase { - public IngestProcessorGrokApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } + public GrokProcessorPatternsApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } protected override LazyResponses ClientUsage() => Calls( - fluent: (client, f) => client.IngestProcessorGrok(f), - fluentAsync: (client, f) => client.IngestProcessorGrokAsync(f), - request: (client, r) => client.IngestProcessorGrok(r), - requestAsync: (client, r) => client.IngestProcessorGrokAsync(r) + fluent: (client, f) => client.GrokProcessorPatterns(f), + fluentAsync: (client, f) => client.GrokProcessorPatternsAsync(f), + request: (client, r) => client.GrokProcessorPatterns(r), + requestAsync: (client, r) => client.GrokProcessorPatternsAsync(r) ); protected override HttpMethod HttpMethod => HttpMethod.GET; protected override string UrlPath => $"/_ingest/processor/grok"; - protected override Func Fluent => d => d; + protected override Func Fluent => d => d; - protected override IngestProcessorGrokRequest Initializer => new IngestProcessorGrokRequest(); + protected override GrokProcessorPatternsRequest Initializer => new GrokProcessorPatternsRequest(); } } diff --git a/src/Tests/Ingest/Processor/IngestProcessorGrokTests.cs b/src/Tests/Ingest/Processor/IngestProcessorGrokTests.cs index 9217829ccd8..d16c2ee7955 100644 --- a/src/Tests/Ingest/Processor/IngestProcessorGrokTests.cs +++ b/src/Tests/Ingest/Processor/IngestProcessorGrokTests.cs @@ -5,15 +5,15 @@ namespace Tests.Ingest.Processor { - public class IngestProcessorGrokUrlTests + public class GrokProcessorPatternsUrlTests { [U] public async Task Urls() { await GET($"/_ingest/processor/grok") - .Fluent(c => c.IngestProcessorGrok()) - .Request(c => c.IngestProcessorGrok()) - .FluentAsync(c => c.IngestProcessorGrokAsync()) - .RequestAsync(c => c.IngestProcessorGrokAsync()) + .Fluent(c => c.GrokProcessorPatterns()) + .Request(c => c.GrokProcessorPatterns()) + .FluentAsync(c => c.GrokProcessorPatternsAsync()) + .RequestAsync(c => c.GrokProcessorPatternsAsync()) ; } } diff --git a/src/Tests/Ingest/Processor/IngestProcessorGrokUnitTests.cs b/src/Tests/Ingest/Processor/IngestProcessorGrokUnitTests.cs index a862e438769..decf17cf391 100644 --- a/src/Tests/Ingest/Processor/IngestProcessorGrokUnitTests.cs +++ b/src/Tests/Ingest/Processor/IngestProcessorGrokUnitTests.cs @@ -3,9 +3,9 @@ using Nest; using Tests.Framework; -namespace Tests.XPack.IngestProcessorGrok +namespace Tests.XPack.GrokProcessorPatterns { - public class IngestProcessorGrokUnitTests + public class GrokProcessorPatternsUnitTests { [U] public void ShouldDeserialize() @@ -14,7 +14,7 @@ public void ShouldDeserialize() var client = TestClient.GetFixedReturnClient(fixedResponse); //warmup - var response = client.IngestProcessorGrok(); + var response = client.GrokProcessorPatterns(); response.ShouldBeValid(); response.Patterns.Should().NotBeNull(); From 861b13530560c7549fc4aa9a07b3b8e9bff97b08 Mon Sep 17 00:00:00 2001 From: codebrain Date: Tue, 14 Nov 2017 13:26:30 +1100 Subject: [PATCH 6/6] Replace string inputs for anonymous objects --- .../Cluster/NodesUsage/NodesUsageUnitTests.cs | 26 ++++++++++++- src/Tests/Framework/TestClient.cs | 17 ++------ ...ts.cs => GrokProcessorPatternsApiTests.cs} | 0 ...Tests.cs => GrokProcessorPatternsTests.cs} | 0 ...s.cs => GrokProcessorPatternsUnitTests.cs} | 13 ++++++- .../DeprecationInfoUnitTests.cs | 39 ++++++++++++++++--- 6 files changed, 74 insertions(+), 21 deletions(-) rename src/Tests/Ingest/Processor/{IngestProcessorGrokApiTests.cs => GrokProcessorPatternsApiTests.cs} (100%) rename src/Tests/Ingest/Processor/{IngestProcessorGrokTests.cs => GrokProcessorPatternsTests.cs} (100%) rename src/Tests/Ingest/Processor/{IngestProcessorGrokUnitTests.cs => GrokProcessorPatternsUnitTests.cs} (68%) diff --git a/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs b/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs index 3ab02f40d88..78f8f8988c2 100644 --- a/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs +++ b/src/Tests/Cluster/NodesUsage/NodesUsageUnitTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using FluentAssertions; using Tests.Framework; @@ -10,7 +11,30 @@ public class NodesUsageUnitTests public void ShouldDeserialize() { const string nodeId = "pQHNt5rXTTWNvUgOrdynKg"; - const string fixedResponse = "{\"_nodes\": {\"total\": 1,\"successful\": 1,\"failed\": 0},\"cluster_name\": \"my_cluster\",\"nodes\": {\"" + nodeId + "\": {\"timestamp\": 1492553961812,\"since\": 1492553906606,\"rest_actions\": {\"org.elasticsearch.rest.action.admin.cluster.RestNodesUsageAction\": 1,\"org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction\": 1,\"org.elasticsearch.rest.action.document.RestGetAction\": 1,\"org.elasticsearch.rest.action.search.RestSearchAction\": 19,\"org.elasticsearch.rest.action.admin.cluster.RestNodesInfoAction\": 36}}}}"; + var fixedResponse = new + { + _nodes = new { + total = 1, + successful = 1, + failed = 0 + }, + cluster_name = "my_cluster", + nodes = new Dictionary{{ + nodeId, new { + timestamp = 1492553961812, + since = 1492553906606, + rest_actions = new Dictionary + { + { "org.elasticsearch.rest.action.admin.cluster.RestNodesUsageAction", 1}, + { "org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction", 1}, + { "org.elasticsearch.rest.action.document.RestGetAction", 1}, + { "org.elasticsearch.rest.action.search.RestSearchAction", 19}, + { "org.elasticsearch.rest.action.admin.cluster.RestNodesInfoAction", 36} + } + } + } + }}; + var client = TestClient.GetFixedReturnClient(fixedResponse); //warmup diff --git a/src/Tests/Framework/TestClient.cs b/src/Tests/Framework/TestClient.cs index bc0548fdab3..1c60139e638 100644 --- a/src/Tests/Framework/TestClient.cs +++ b/src/Tests/Framework/TestClient.cs @@ -179,19 +179,10 @@ public static IElasticClient GetFixedReturnClient( string contentType = "application/json", Exception exception = null) { - byte[] fixedResult; - - if (response.GetType() == typeof(string)) - { - fixedResult = Encoding.UTF8.GetBytes((string)response); - } - else - { - var serializer = Default.Serializer; - fixedResult = contentType == "application/json" - ? serializer.SerializeToBytes(response) - : Encoding.UTF8.GetBytes(response.ToString()); - } + var serializer = Default.Serializer; + var fixedResult = contentType == "application/json" + ? serializer.SerializeToBytes(response) + : Encoding.UTF8.GetBytes(response.ToString()); var connection = new InMemoryConnection(fixedResult, statusCode, exception); var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200")); diff --git a/src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs b/src/Tests/Ingest/Processor/GrokProcessorPatternsApiTests.cs similarity index 100% rename from src/Tests/Ingest/Processor/IngestProcessorGrokApiTests.cs rename to src/Tests/Ingest/Processor/GrokProcessorPatternsApiTests.cs diff --git a/src/Tests/Ingest/Processor/IngestProcessorGrokTests.cs b/src/Tests/Ingest/Processor/GrokProcessorPatternsTests.cs similarity index 100% rename from src/Tests/Ingest/Processor/IngestProcessorGrokTests.cs rename to src/Tests/Ingest/Processor/GrokProcessorPatternsTests.cs diff --git a/src/Tests/Ingest/Processor/IngestProcessorGrokUnitTests.cs b/src/Tests/Ingest/Processor/GrokProcessorPatternsUnitTests.cs similarity index 68% rename from src/Tests/Ingest/Processor/IngestProcessorGrokUnitTests.cs rename to src/Tests/Ingest/Processor/GrokProcessorPatternsUnitTests.cs index decf17cf391..7430eb0fc87 100644 --- a/src/Tests/Ingest/Processor/IngestProcessorGrokUnitTests.cs +++ b/src/Tests/Ingest/Processor/GrokProcessorPatternsUnitTests.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using FluentAssertions; using Nest; using Tests.Framework; @@ -10,7 +11,15 @@ public class GrokProcessorPatternsUnitTests [U] public void ShouldDeserialize() { - const string fixedResponse = "{ \"patterns\" : { \"BACULA_CAPACITY\" : \"%{INT}{1,3}(,%{INT}{3})*\", \"PATH\" : \"(?:%{UNIXPATH}|%{WINPATH})\" } }"; + var fixedResponse = new + { + patterns = new Dictionary + { + { "BACULA_CAPACITY" ,"%{INT}{1,3}(,%{INT}{3})*"}, + { "PATH", "(?:%{UNIXPATH}|%{WINPATH})"} + } + }; + var client = TestClient.GetFixedReturnClient(fixedResponse); //warmup diff --git a/src/Tests/XPack/DeprecationInfo/DeprecationInfoUnitTests.cs b/src/Tests/XPack/DeprecationInfo/DeprecationInfoUnitTests.cs index a2f54c3e474..fc0abea6991 100644 --- a/src/Tests/XPack/DeprecationInfo/DeprecationInfoUnitTests.cs +++ b/src/Tests/XPack/DeprecationInfo/DeprecationInfoUnitTests.cs @@ -1,4 +1,6 @@ -using System.Linq; +using System; +using System.Collections.Generic; +using System.Linq; using FluentAssertions; using Nest; using Tests.Framework; @@ -10,7 +12,37 @@ public class DeprecationInfoUnitTests [U] public void ShouldDeserialize() { - const string fixedResponse = "{ \"cluster_settings\" : [ { \"level\" : \"info\", \"message\" : \"Network settings changes\", \"url\" : \"https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_indices_changes.html#_index_templates_use_literal_index_patterns_literal_instead_of_literal_template_literal\", \"details\" : \"templates using template field: watches,.monitoring-alerts,.watch-history-6,.ml-notifications,security-index-template,triggered_watches,.monitoring-es,.ml-meta,.ml-state,.monitoring-logstash,.ml-anomalies-,.monitoring-kibana\" } ], \"node_settings\" : [ ], \"index_settings\" : { \".monitoring-es-6-2017.07.21\" : [ { \"level\" : \"info\", \"message\" : \"Coercion of boolean fields\", \"url\" : \"https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields\", \"details\" : \"\" } ] } }"; + const string indexName = ".monitoring-es-6-2017.07.21"; + + var fixedResponse = new + { + cluster_settings = new[] + { + new + { + level = "info", + message = "Network settings changes", + url = "https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_indices_changes.html#_index_templates_use_literal_index_patterns_literal_instead_of_literal_template_literal", + details = "templates using template field: watches,.monitoring-alerts,.watch-history-6,.ml-notifications,security-index-template,triggered_watches,.monitoring-es,.ml-meta,.ml-state,.monitoring-logstash,.ml-anomalies-,.monitoring-kibana" + } + }, + node_settings = new object[0], + index_settings = new Dictionary + { + { + indexName, new object[] + { + new { + level = "info", + message = "Coercion of boolean fields", + url = "https://www.elastic.co/guide/en/elasticsearch/reference/6.0/breaking_60_mappings_changes.html#_coercion_of_boolean_fields", + details = "" + } + } + } + } + }; + var client = TestClient.GetFixedReturnClient(fixedResponse); //warmup @@ -29,9 +61,6 @@ public void ShouldDeserialize() response.IndexSettings.Should().NotBeNull(); response.IndexSettings.Should().HaveCount(1); - - const string indexName = ".monitoring-es-6-2017.07.21"; - response.IndexSettings.Should().ContainKey(indexName); response.IndexSettings[indexName].Count.Should().Be(1);