Skip to content

Commit c32a545

Browse files
Apply transforms from code-gen to fix index template (#7171) (#7177)
Co-authored-by: Steve Gordon <[email protected]>
1 parent 861d277 commit c32a545

File tree

4 files changed

+57
-8
lines changed

4 files changed

+57
-8
lines changed

src/Elastic.Clients.Elasticsearch/Core/UrlParameters/Name/Name.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public sealed class Name : IEquatable<Name>, IUrlParameter
2626

2727
string IUrlParameter.GetString(ITransportConfiguration? settings) => Value;
2828

29-
public override string ToString() => DebugDisplay;
29+
public override string ToString() => Value;
3030

3131
public static implicit operator Name(string name) => name.IsNullOrEmpty() ? null : new Name(name);
3232

src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateIndexTemplateRequest.g.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public SimulateIndexTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : b
6161

6262
[JsonInclude]
6363
[JsonPropertyName("composed_of")]
64-
public ICollection<Elastic.Clients.Elasticsearch.Name>? ComposedOf { get; set; }
64+
public ICollection<string>? ComposedOf { get; set; }
6565

6666
[JsonInclude]
6767
[JsonPropertyName("template")]
@@ -116,7 +116,7 @@ public SimulateIndexTemplateRequestDescriptor<TDocument> Name(Elastic.Clients.El
116116

117117
private bool? AllowAutoCreateValue { get; set; }
118118

119-
private ICollection<Elastic.Clients.Elasticsearch.Name>? ComposedOfValue { get; set; }
119+
private ICollection<string>? ComposedOfValue { get; set; }
120120

121121
private Elastic.Clients.Elasticsearch.IndexManagement.DataStreamVisibility? DataStreamValue { get; set; }
122122

@@ -166,7 +166,7 @@ public SimulateIndexTemplateRequestDescriptor<TDocument> AllowAutoCreate(bool? a
166166
return Self;
167167
}
168168

169-
public SimulateIndexTemplateRequestDescriptor<TDocument> ComposedOf(ICollection<Elastic.Clients.Elasticsearch.Name>? composedOf)
169+
public SimulateIndexTemplateRequestDescriptor<TDocument> ComposedOf(ICollection<string>? composedOf)
170170
{
171171
ComposedOfValue = composedOf;
172172
return Self;
@@ -321,7 +321,7 @@ public SimulateIndexTemplateRequestDescriptor Name(Elastic.Clients.Elasticsearch
321321

322322
private bool? AllowAutoCreateValue { get; set; }
323323

324-
private ICollection<Elastic.Clients.Elasticsearch.Name>? ComposedOfValue { get; set; }
324+
private ICollection<string>? ComposedOfValue { get; set; }
325325

326326
private Elastic.Clients.Elasticsearch.IndexManagement.DataStreamVisibility? DataStreamValue { get; set; }
327327

@@ -371,7 +371,7 @@ public SimulateIndexTemplateRequestDescriptor AllowAutoCreate(bool? allowAutoCre
371371
return Self;
372372
}
373373

374-
public SimulateIndexTemplateRequestDescriptor ComposedOf(ICollection<Elastic.Clients.Elasticsearch.Name>? composedOf)
374+
public SimulateIndexTemplateRequestDescriptor ComposedOf(ICollection<string>? composedOf)
375375
{
376376
ComposedOfValue = composedOf;
377377
return Self;

src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexTemplate.g.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ public sealed partial class IndexTemplate
3737

3838
[JsonInclude]
3939
[JsonPropertyName("composed_of")]
40-
public IReadOnlyCollection<Elastic.Clients.Elasticsearch.Name> ComposedOf { get; init; }
40+
public IReadOnlyCollection<string> ComposedOf { get; init; }
4141

4242
[JsonInclude]
4343
[JsonPropertyName("data_stream")]
4444
public Elastic.Clients.Elasticsearch.IndexManagement.IndexTemplateDataStreamConfiguration? DataStream { get; init; }
4545

4646
[JsonInclude]
4747
[JsonPropertyName("index_patterns")]
48-
public Elastic.Clients.Elasticsearch.Names IndexPatterns { get; init; }
48+
public IReadOnlyCollection<string> IndexPatterns { get; init; }
4949

5050
[JsonInclude]
5151
[JsonPropertyName("priority")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
using System.Linq;
6+
using Elastic.Clients.Elasticsearch.IndexManagement;
7+
using Tests.Serialization;
8+
9+
namespace Tests.IndexManagement.TemplateManagement;
10+
11+
public class GetTemplateResponseSerializationTests : SerializerTestBase
12+
{
13+
private const string ResponseJson = @"{
14+
""index_templates"": [
15+
{
16+
""name"": ""template_1"",
17+
""index_template"": {
18+
""index_patterns"": [
19+
""te*""
20+
],
21+
""template"": {
22+
""settings"": {
23+
""index"": {
24+
""number_of_shards"": ""2""
25+
}
26+
}
27+
},
28+
""composed_of"": [],
29+
""priority"": 1
30+
}
31+
}
32+
]
33+
}";
34+
35+
[U]
36+
public void GetIndexTemplateResponse_DeserializesCorrectly_WhenIndexPatternsAreIncluded()
37+
{
38+
var response = DeserializeJsonString<GetIndexTemplateResponse>(ResponseJson);
39+
40+
response.IndexTemplates.Should().HaveCount(1);
41+
42+
var template = response.IndexTemplates.First();
43+
44+
template.Name.Should().Be("template_1");
45+
template.IndexTemplate.IndexPatterns.Should().HaveCount(1);
46+
47+
template.IndexTemplate.IndexPatterns.First().Should().Be("te*");
48+
}
49+
}

0 commit comments

Comments
 (0)