From 09fcdc31cd473e6824220c5bbeb86fa4b5d5e90b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2020 12:19:38 +1000 Subject: [PATCH] Add description to ingest processors (#4871) (#4882) This commit adds description to ingest processors to allow users to explain the purpose of a specific processor instance. Co-authored-by: Russ Cam --- src/Nest/Ingest/Processor.cs | 17 ++++++++++++++++- tests/Tests/Ingest/ProcessorAssertions.cs | 9 ++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/Nest/Ingest/Processor.cs b/src/Nest/Ingest/Processor.cs index c5096a00d38..d39070a0843 100644 --- a/src/Nest/Ingest/Processor.cs +++ b/src/Nest/Ingest/Processor.cs @@ -2,7 +2,7 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information -using System; +using System; using System.Collections.Generic; using System.Runtime.Serialization; using Elasticsearch.Net.Utf8Json; @@ -18,6 +18,14 @@ public interface IProcessor [IgnoreDataMember] string Name { get; } + /// + /// A description to explain the purpose of the specific processor instance. + /// + /// Valid in Elasticsearch 7.9.0+ + /// + [DataMember(Name = "description")] + string Description { get; set; } + /// /// If a processor fails, call these processors instead. Read more about handling failures here: /// https://www.elastic.co/guide/en/elasticsearch/reference/current/handling-failure-in-pipelines.html @@ -54,6 +62,9 @@ public abstract class ProcessorBase : IProcessor /// public IEnumerable OnFailure { get; set; } protected abstract string Name { get; } + /// + public string Description { get; set; } + string IProcessor.Name => Name; } @@ -65,11 +76,15 @@ public abstract class ProcessorDescriptorBase Name; + string IProcessor.Description { get; set; } IEnumerable IProcessor.OnFailure { get; set; } string IProcessor.If { get; set; } string IProcessor.Tag { get; set; } bool? IProcessor.IgnoreFailure { get; set; } + /// + public TProcessorDescriptor Description(string description) => Assign(description, (a, v) => a.Description = v); + /// public TProcessorDescriptor OnFailure(IEnumerable processors) => Assign(processors.ToListOrNullIfEmpty(), (a, v) => a.OnFailure = v); diff --git a/tests/Tests/Ingest/ProcessorAssertions.cs b/tests/Tests/Ingest/ProcessorAssertions.cs index 9e35426b8b3..8f3733b2207 100644 --- a/tests/Tests/Ingest/ProcessorAssertions.cs +++ b/tests/Tests/Ingest/ProcessorAssertions.cs @@ -75,7 +75,7 @@ public class Append : ProcessorAssertion public override string Key => "append"; } - [SkipVersion("<7.8.0", "Empty Value bug in versions less than Elasticsearch 7.8.0")] + [SkipVersion("<7.9.0", "Description added in 7.9.0")] public class Csv : ProcessorAssertion { public override Func>> Fluent => d => d @@ -84,6 +84,7 @@ public class Csv : ProcessorAssertion .TargetFields(new[] { "targetField1", "targetField2" }) .EmptyValue("empty") .Trim() + .Description("parses CSV") ); public override IProcessor Initializer => new CsvProcessor @@ -91,7 +92,8 @@ public class Csv : ProcessorAssertion Field = "name", TargetFields = new[] { "targetField1", "targetField2" }, EmptyValue = "empty", - Trim = true + Trim = true, + Description = "parses CSV" }; public override object Json => new @@ -99,7 +101,8 @@ public class Csv : ProcessorAssertion field = "name", target_fields = new[] { "targetField1", "targetField2" }, empty_value = "empty", - trim = true + trim = true, + description = "parses CSV" }; public override string Key => "csv";