Skip to content

Add version to PutTemplateRequest #2971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 21, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public interface ITemplateMapping

[JsonProperty("aliases")]
IAliases Aliases { get; set; }

[JsonProperty("version")]
int? Version { get; set; }
}

public class TemplateMapping : ITemplateMapping
Expand All @@ -32,5 +35,7 @@ public class TemplateMapping : ITemplateMapping
public IMappings Mappings { get; set; }

public IAliases Aliases { get; set; }

public int? Version { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ namespace Nest
{
public partial interface IPutIndexTemplateRequest : ITemplateMapping
{
[JsonProperty("version")]
int? Version { get; set; }
}

public partial class PutIndexTemplateRequest
Expand All @@ -31,7 +29,7 @@ public partial class PutIndexTemplateDescriptor
{
int? ITemplateMapping.Order { get; set; }

int? IPutIndexTemplateRequest.Version { get; set; }
int? ITemplateMapping.Version { get; set; }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


IIndexSettings ITemplateMapping.Settings { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Linq;
using Elasticsearch.Net;
using FluentAssertions;
using Nest;
using Tests.Framework;
using Tests.Framework.Integration;
Expand All @@ -9,7 +11,7 @@
namespace Tests.Indices.IndexSettings.IndexTemplates.GetIndexTemplate
{
public class GetIndexTemplateApiTests
: ApiTestBase<WritableCluster, IGetIndexTemplateResponse, IGetIndexTemplateRequest, GetIndexTemplateDescriptor, GetIndexTemplateRequest>
: ApiIntegrationTestBase<WritableCluster, IGetIndexTemplateResponse, IGetIndexTemplateRequest, GetIndexTemplateDescriptor, GetIndexTemplateRequest>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

{
public GetIndexTemplateApiTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { }
protected override LazyResponses ClientUsage() => Calls(
Expand All @@ -25,6 +27,46 @@ protected override LazyResponses ClientUsage() => Calls(
protected override Func<GetIndexTemplateDescriptor, IGetIndexTemplateRequest> Fluent => d => d
.Name(CallIsolatedValue);

protected override int ExpectStatusCode => 200;

protected override bool ExpectIsValid => true;

protected override GetIndexTemplateRequest Initializer => new GetIndexTemplateRequest(CallIsolatedValue);

protected override object ExpectJson => new object();
Copy link
Contributor Author

@russcam russcam Dec 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to ExpectResponse, this won't be {} but will be an object with index patterns, version, template mappings and settings. Ignore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can set this to null


protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values)
{
foreach (var callUniqueValue in values)
{
var putTemplateResponse = client.PutIndexTemplate(callUniqueValue.Value, d =>
d.IndexPatterns("startingwiththis-*")
.Settings(s => s.NumberOfShards(2))
.Version(1)
);

if (!putTemplateResponse.IsValid)
throw new Exception($"Problem putting index template for integration test: {putTemplateResponse.DebugInformation}");
}
}

protected override void ExpectResponse(IGetIndexTemplateResponse response)
{
response.ShouldBeValid();

response.TemplateMappings.Should().NotBeNull();
response.TemplateMappings.Should().HaveCount(1);

var responseTemplateMapping = response.TemplateMappings[CallIsolatedValue];

responseTemplateMapping.IndexPatterns.Should().NotBeNull();
responseTemplateMapping.IndexPatterns.Should().HaveCount(1);
responseTemplateMapping.IndexPatterns.First().Should().Be("startingwiththis-*");

responseTemplateMapping.Version.Should().Be(1);

responseTemplateMapping.Settings.Should().NotBeNull();
responseTemplateMapping.Settings.NumberOfShards.Should().Be(2);
}
}
}