Skip to content

Commit bb2c4d2

Browse files
Add enrich APIs (#6203) (#6204)
Co-authored-by: Steve Gordon <sgordon@hotmail.co.uk>
1 parent 7848f14 commit bb2c4d2

23 files changed

+1467
-17
lines changed

src/Elastic.Clients.Elasticsearch/Common/Infer/Fields/Fields.cs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,28 @@
1515

1616
namespace Elastic.Clients.Elasticsearch;
1717

18-
// TODO - Converter
19-
2018
internal sealed class FieldsConverter : JsonConverter<Fields>
2119
{
2220
public override Fields? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
2321
{
24-
reader.Read();
25-
26-
if (reader.TokenType != JsonTokenType.StartArray)
22+
if (reader.TokenType == JsonTokenType.String)
2723
{
28-
return null;
24+
Fields fields = reader.GetString();
25+
return fields;
2926
}
30-
31-
var fields = new List<Field>();
32-
while (reader.Read())
27+
else if (reader.TokenType == JsonTokenType.StartArray)
3328
{
34-
if (reader.TokenType == JsonTokenType.EndArray)
35-
break;
36-
37-
var field = JsonSerializer.Deserialize(ref reader, typeof(Field), options);
38-
39-
if (field is Field f)
40-
fields.Add(f);
29+
var fields = new List<Field>();
30+
while (reader.Read() && reader.TokenType != JsonTokenType.EndArray)
31+
{
32+
var field = JsonSerializer.Deserialize<Field>(ref reader, options);
33+
fields.Add(field);
34+
}
35+
return new Fields(fields);
4136
}
4237

43-
return new Fields(fields);
38+
reader.Read();
39+
return null;
4440
}
4541

4642
public override void Write(Utf8JsonWriter writer, Fields value, JsonSerializerOptions options)

src/Elastic.Clients.Elasticsearch/Common/Infer/Indices/Indices.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ internal Indices(ManyIndices indices) : base(indices) { }
2222

2323
internal Indices(IEnumerable<IndexName> indices) : base(new ManyIndices(indices)) { }
2424

25+
internal Indices(IEnumerable<string> indices) : base(new ManyIndices(indices)) { }
26+
2527
/// <summary>All indices. Represents _all</summary>
2628
public static Indices All { get; } = new Indices(new AllIndicesMarker());
2729

@@ -153,6 +155,16 @@ internal sealed class IndicesJsonConverter : JsonConverter<Indices>
153155
Indices indices = reader.GetString();
154156
return indices;
155157
}
158+
else if (reader.TokenType == JsonTokenType.StartArray)
159+
{
160+
var indices = new List<string>();
161+
while (reader.Read() && reader.TokenType != JsonTokenType.EndArray)
162+
{
163+
var index = reader.GetString();
164+
indices.Add(index);
165+
}
166+
return new Indices(indices);
167+
}
156168

157169
reader.Read();
158170
return null;

src/Elastic.Clients.Elasticsearch/_Generated/Api/ApiUrlsLookup.g.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ internal static class ApiUrlsLookups
3232
internal static ApiUrls NoNamespaceCount = new ApiUrls(new[] { "/_count", "/{index}/_count" });
3333
internal static ApiUrls NoNamespaceCreate = new ApiUrls(new[] { "/{index}/_create/{id}" });
3434
internal static ApiUrls NoNamespaceDelete = new ApiUrls(new[] { "/{index}/_doc/{id}" });
35+
internal static ApiUrls EnrichDeletePolicy = new ApiUrls(new[] { "/_enrich/policy/{name}" });
36+
internal static ApiUrls EnrichExecutePolicy = new ApiUrls(new[] { "/_enrich/policy/{name}/_execute" });
37+
internal static ApiUrls EnrichGetPolicy = new ApiUrls(new[] { "/_enrich/policy/{name}", "/_enrich/policy" });
38+
internal static ApiUrls EnrichPutPolicy = new ApiUrls(new[] { "/_enrich/policy/{name}" });
39+
internal static ApiUrls EnrichStats = new ApiUrls(new[] { "/_enrich/_stats" });
3540
internal static ApiUrls EqlDelete = new ApiUrls(new[] { "/_eql/search/{id}" });
3641
internal static ApiUrls EqlGetStatus = new ApiUrls(new[] { "/_eql/search/status/{id}" });
3742
internal static ApiUrls EqlSearch = new ApiUrls(new[] { "/{index}/_eql/search" });
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information.
4+
//
5+
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
6+
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
7+
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
8+
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
9+
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
10+
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
11+
// ------------------------------------------------
12+
//
13+
// This file is automatically generated.
14+
// Please do not edit these files manually.
15+
//
16+
// ------------------------------------------------
17+
18+
using Elastic.Transport;
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Linq.Expressions;
22+
using System.Text.Json;
23+
using System.Text.Json.Serialization;
24+
25+
#nullable restore
26+
namespace Elastic.Clients.Elasticsearch.Enrich
27+
{
28+
public class EnrichDeletePolicyRequestParameters : RequestParameters<EnrichDeletePolicyRequestParameters>
29+
{
30+
}
31+
32+
public partial class EnrichDeletePolicyRequest : PlainRequestBase<EnrichDeletePolicyRequestParameters>
33+
{
34+
public EnrichDeletePolicyRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("name", name))
35+
{
36+
}
37+
38+
internal override ApiUrls ApiUrls => ApiUrlsLookups.EnrichDeletePolicy;
39+
protected override HttpMethod HttpMethod => HttpMethod.DELETE;
40+
protected override bool SupportsBody => false;
41+
}
42+
43+
public sealed partial class EnrichDeletePolicyRequestDescriptor : RequestDescriptorBase<EnrichDeletePolicyRequestDescriptor, EnrichDeletePolicyRequestParameters>
44+
{
45+
internal EnrichDeletePolicyRequestDescriptor(Action<EnrichDeletePolicyRequestDescriptor> configure) => configure.Invoke(this);
46+
public EnrichDeletePolicyRequestDescriptor(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("name", name))
47+
{
48+
}
49+
50+
internal EnrichDeletePolicyRequestDescriptor()
51+
{
52+
}
53+
54+
internal override ApiUrls ApiUrls => ApiUrlsLookups.EnrichDeletePolicy;
55+
protected override HttpMethod HttpMethod => HttpMethod.DELETE;
56+
protected override bool SupportsBody => false;
57+
public EnrichDeletePolicyRequestDescriptor Name(Elastic.Clients.Elasticsearch.Name name)
58+
{
59+
RouteValues.Required("name", name);
60+
return Self;
61+
}
62+
63+
protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
64+
{
65+
}
66+
}
67+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information.
4+
//
5+
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
6+
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
7+
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
8+
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
9+
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
10+
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
11+
// ------------------------------------------------
12+
//
13+
// This file is automatically generated.
14+
// Please do not edit these files manually.
15+
//
16+
// ------------------------------------------------
17+
18+
using Elastic.Transport.Products.Elasticsearch;
19+
using System.Collections.Generic;
20+
using System.Text.Json.Serialization;
21+
22+
#nullable restore
23+
namespace Elastic.Clients.Elasticsearch.Enrich
24+
{
25+
public partial class EnrichDeletePolicyResponse : ElasticsearchResponseBase
26+
{
27+
[JsonInclude]
28+
[JsonPropertyName("acknowledged")]
29+
public bool Acknowledged { get; init; }
30+
}
31+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information.
4+
//
5+
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
6+
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
7+
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
8+
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
9+
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
10+
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
11+
// ------------------------------------------------
12+
//
13+
// This file is automatically generated.
14+
// Please do not edit these files manually.
15+
//
16+
// ------------------------------------------------
17+
18+
using Elastic.Transport;
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Linq.Expressions;
22+
using System.Text.Json;
23+
using System.Text.Json.Serialization;
24+
25+
#nullable restore
26+
namespace Elastic.Clients.Elasticsearch.Enrich
27+
{
28+
public class EnrichExecutePolicyRequestParameters : RequestParameters<EnrichExecutePolicyRequestParameters>
29+
{
30+
[JsonIgnore]
31+
public bool? WaitForCompletion { get => Q<bool?>("wait_for_completion"); set => Q("wait_for_completion", value); }
32+
}
33+
34+
public partial class EnrichExecutePolicyRequest : PlainRequestBase<EnrichExecutePolicyRequestParameters>
35+
{
36+
public EnrichExecutePolicyRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("name", name))
37+
{
38+
}
39+
40+
internal override ApiUrls ApiUrls => ApiUrlsLookups.EnrichExecutePolicy;
41+
protected override HttpMethod HttpMethod => HttpMethod.PUT;
42+
protected override bool SupportsBody => false;
43+
[JsonIgnore]
44+
public bool? WaitForCompletion { get => Q<bool?>("wait_for_completion"); set => Q("wait_for_completion", value); }
45+
}
46+
47+
public sealed partial class EnrichExecutePolicyRequestDescriptor : RequestDescriptorBase<EnrichExecutePolicyRequestDescriptor, EnrichExecutePolicyRequestParameters>
48+
{
49+
internal EnrichExecutePolicyRequestDescriptor(Action<EnrichExecutePolicyRequestDescriptor> configure) => configure.Invoke(this);
50+
public EnrichExecutePolicyRequestDescriptor(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("name", name))
51+
{
52+
}
53+
54+
internal EnrichExecutePolicyRequestDescriptor()
55+
{
56+
}
57+
58+
internal override ApiUrls ApiUrls => ApiUrlsLookups.EnrichExecutePolicy;
59+
protected override HttpMethod HttpMethod => HttpMethod.PUT;
60+
protected override bool SupportsBody => false;
61+
public EnrichExecutePolicyRequestDescriptor WaitForCompletion(bool? waitForCompletion = true) => Qs("wait_for_completion", waitForCompletion);
62+
public EnrichExecutePolicyRequestDescriptor Name(Elastic.Clients.Elasticsearch.Name name)
63+
{
64+
RouteValues.Required("name", name);
65+
return Self;
66+
}
67+
68+
protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
69+
{
70+
}
71+
}
72+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information.
4+
//
5+
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
6+
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
7+
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
8+
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
9+
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
10+
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
11+
// ------------------------------------------------
12+
//
13+
// This file is automatically generated.
14+
// Please do not edit these files manually.
15+
//
16+
// ------------------------------------------------
17+
18+
using Elastic.Transport.Products.Elasticsearch;
19+
using System.Collections.Generic;
20+
using System.Text.Json.Serialization;
21+
22+
#nullable restore
23+
namespace Elastic.Clients.Elasticsearch.Enrich
24+
{
25+
public partial class EnrichExecutePolicyResponse : ElasticsearchResponseBase
26+
{
27+
[JsonInclude]
28+
[JsonPropertyName("status")]
29+
public Elastic.Clients.Elasticsearch.Enrich.ExecutePolicy.ExecuteEnrichPolicyStatus Status { get; init; }
30+
31+
[JsonInclude]
32+
[JsonPropertyName("task_id")]
33+
public Elastic.Clients.Elasticsearch.TaskId? TaskId { get; init; }
34+
}
35+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information.
4+
//
5+
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
6+
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
7+
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
8+
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
9+
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
10+
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
11+
// ------------------------------------------------
12+
//
13+
// This file is automatically generated.
14+
// Please do not edit these files manually.
15+
//
16+
// ------------------------------------------------
17+
18+
using Elastic.Transport;
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Linq.Expressions;
22+
using System.Text.Json;
23+
using System.Text.Json.Serialization;
24+
25+
#nullable restore
26+
namespace Elastic.Clients.Elasticsearch.Enrich
27+
{
28+
public class EnrichGetPolicyRequestParameters : RequestParameters<EnrichGetPolicyRequestParameters>
29+
{
30+
}
31+
32+
public partial class EnrichGetPolicyRequest : PlainRequestBase<EnrichGetPolicyRequestParameters>
33+
{
34+
public EnrichGetPolicyRequest()
35+
{
36+
}
37+
38+
public EnrichGetPolicyRequest(Elastic.Clients.Elasticsearch.Names? name) : base(r => r.Optional("name", name))
39+
{
40+
}
41+
42+
internal override ApiUrls ApiUrls => ApiUrlsLookups.EnrichGetPolicy;
43+
protected override HttpMethod HttpMethod => HttpMethod.GET;
44+
protected override bool SupportsBody => false;
45+
}
46+
47+
public sealed partial class EnrichGetPolicyRequestDescriptor : RequestDescriptorBase<EnrichGetPolicyRequestDescriptor, EnrichGetPolicyRequestParameters>
48+
{
49+
internal EnrichGetPolicyRequestDescriptor(Action<EnrichGetPolicyRequestDescriptor> configure) => configure.Invoke(this);
50+
public EnrichGetPolicyRequestDescriptor()
51+
{
52+
}
53+
54+
internal override ApiUrls ApiUrls => ApiUrlsLookups.EnrichGetPolicy;
55+
protected override HttpMethod HttpMethod => HttpMethod.GET;
56+
protected override bool SupportsBody => false;
57+
public EnrichGetPolicyRequestDescriptor Name(Elastic.Clients.Elasticsearch.Names? name)
58+
{
59+
RouteValues.Optional("name", name);
60+
return Self;
61+
}
62+
63+
protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
64+
{
65+
}
66+
}
67+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information.
4+
//
5+
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
6+
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
7+
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
8+
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
9+
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
10+
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
11+
// ------------------------------------------------
12+
//
13+
// This file is automatically generated.
14+
// Please do not edit these files manually.
15+
//
16+
// ------------------------------------------------
17+
18+
using Elastic.Transport.Products.Elasticsearch;
19+
using System.Collections.Generic;
20+
using System.Text.Json.Serialization;
21+
22+
#nullable restore
23+
namespace Elastic.Clients.Elasticsearch.Enrich
24+
{
25+
public partial class EnrichGetPolicyResponse : ElasticsearchResponseBase
26+
{
27+
[JsonInclude]
28+
[JsonPropertyName("policies")]
29+
public IReadOnlyCollection<Elastic.Clients.Elasticsearch.Enrich.Summary> Policies { get; init; }
30+
}
31+
}

0 commit comments

Comments
 (0)