Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -15,8 +15,8 @@ public static class ApiEndpointsThatAllow404
"IndexTemplateExists",
"TypeExists",
"Exists",
//"Get"
//"Delete",
"Get",
"Delete",
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"refresh": {
"type" : "boolean",
"description" : "Refresh the index after performing the operation"
"description" : "Refresh the affected shards after performing the operation"
},
"routing": {
"type" : "string",
Expand Down
601 changes: 347 additions & 254 deletions src/CodeGeneration/ApiGenerator/RestSpecification/Core/root.html

Large diffs are not rendered by default.

330 changes: 227 additions & 103 deletions src/CodeGeneration/ApiGenerator/RestSpecification/DeleteByQuery/root.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.4.0
v2.4.1
2 changes: 1 addition & 1 deletion src/Elasticsearch.Net/Domain/Enums.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

///This file contains all the typed enums that the client rest api spec exposes.
///This file is automatically generated from https://github.com/elasticsearch/elasticsearch-rest-api-spec
///Generated of commit v2.4.0
///Generated of commit v2.4.1
namespace Elasticsearch.Net
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using System.Linq.Expressions;

///This file contains all the typed querystring parameters that are generated of the client spec.
///This file is automatically generated from https://github.com/elastic/elasticsearch/tree/v2.4.0/rest-api-spec
///Generated of commit v2.4.0
///This file is automatically generated from https://github.com/elastic/elasticsearch/tree/v2.4.1/rest-api-spec
///Generated of commit v2.4.1

namespace Elasticsearch.Net
{
Expand Down
8 changes: 4 additions & 4 deletions src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,7 @@ public Task<ElasticsearchResponse<T>> CountPercolateAsync<T>(string index, strin
///<param name="id">The document ID</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public ElasticsearchResponse<T> Delete<T>(string index, string type, string id, Func<DeleteRequestParameters, DeleteRequestParameters> requestParameters = null)
where T : class => this.DoRequest<T>(DELETE, Url($"{index.NotNull("index")}/{type.NotNull("type")}/{id.NotNull("id")}"), null, _params(requestParameters));
where T : class => this.DoRequest<T>(DELETE, Url($"{index.NotNull("index")}/{type.NotNull("type")}/{id.NotNull("id")}"), null, _params(requestParameters, allow404: true));

///<summary>Represents a DELETE on /{index}/{type}/{id}
///<para></para>Returns: A task of ElasticsearchResponse&lt;T&gt; where the behaviour depends on the type of T:
Expand All @@ -1551,7 +1551,7 @@ public ElasticsearchResponse<T> Delete<T>(string index, string type, string id,
///<param name="id">The document ID</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public Task<ElasticsearchResponse<T>> DeleteAsync<T>(string index, string type, string id, Func<DeleteRequestParameters, DeleteRequestParameters> requestParameters = null)
where T : class => this.DoRequestAsync<T>(DELETE, Url($"{index.NotNull("index")}/{type.NotNull("type")}/{id.NotNull("id")}"), null, _params(requestParameters));
where T : class => this.DoRequestAsync<T>(DELETE, Url($"{index.NotNull("index")}/{type.NotNull("type")}/{id.NotNull("id")}"), null, _params(requestParameters, allow404: true));

///<summary>Represents a DELETE on /_scripts/{lang}/{id}
///<para></para>Returns: ElasticsearchResponse&lt;T&gt; where the behavior depends on the type of T:
Expand Down Expand Up @@ -1835,7 +1835,7 @@ public Task<ElasticsearchResponse<T>> FieldStatsAsync<T>(string index, PostData<
///<param name="id">The document ID</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public ElasticsearchResponse<T> Get<T>(string index, string type, string id, Func<GetRequestParameters, GetRequestParameters> requestParameters = null)
where T : class => this.DoRequest<T>(GET, Url($"{index.NotNull("index")}/{type.NotNull("type")}/{id.NotNull("id")}"), null, _params(requestParameters));
where T : class => this.DoRequest<T>(GET, Url($"{index.NotNull("index")}/{type.NotNull("type")}/{id.NotNull("id")}"), null, _params(requestParameters, allow404: true));

///<summary>Represents a GET on /{index}/{type}/{id}
///<para></para>Returns: A task of ElasticsearchResponse&lt;T&gt; where the behaviour depends on the type of T:
Expand All @@ -1851,7 +1851,7 @@ public ElasticsearchResponse<T> Get<T>(string index, string type, string id, Fun
///<param name="id">The document ID</param>
///<param name="requestParameters">A func that allows you to describe the querystring parameters &amp; request specific connection settings.</param>
public Task<ElasticsearchResponse<T>> GetAsync<T>(string index, string type, string id, Func<GetRequestParameters, GetRequestParameters> requestParameters = null)
where T : class => this.DoRequestAsync<T>(GET, Url($"{index.NotNull("index")}/{type.NotNull("type")}/{id.NotNull("id")}"), null, _params(requestParameters));
where T : class => this.DoRequestAsync<T>(GET, Url($"{index.NotNull("index")}/{type.NotNull("type")}/{id.NotNull("id")}"), null, _params(requestParameters, allow404: true));

///<summary>Represents a GET on /_scripts/{lang}/{id}
///<para></para>Returns: ElasticsearchResponse&lt;T&gt; where the behavior depends on the type of T:
Expand Down
2 changes: 1 addition & 1 deletion src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Elasticsearch.Net
///This file is automatically generated from https://github.com/elasticsearch/elasticsearch-rest-api-spec
///</pre>
///<pre>
///Generated of commit v2.4.0
///Generated of commit v2.4.1
///</pre>
///</summary>
public partial interface IElasticLowLevelClient
Expand Down
2 changes: 1 addition & 1 deletion src/Nest/_Generated/_Descriptors.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

//This file lays the base for all the descriptors based on the query string parameters in the spec for IElasticClient.
//This file is automatically generated from https://github.com/elasticsearch/elasticsearch-rest-api-spec
//Generated of commit v2.4.0
//Generated of commit v2.4.1

namespace Nest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

///This file contains all the typed request parameters that are generated of the client spec.
///This file is automatically generated from https://github.com/elasticsearch/elasticsearch-rest-api-spec
///Generated of commit v2.4.0
///Generated of commit v2.4.1

namespace Nest
{
Expand Down
2 changes: 1 addition & 1 deletion src/Nest/_Generated/_Requests.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

//This file contains all the typed querystring parameters that are generated of the client spec.
//This file is automatically generated from https://github.com/elasticsearch/elasticsearch-rest-api-spec
//Generated of commit v2.4.0
//Generated of commit v2.4.1

namespace Nest
{
Expand Down
31 changes: 31 additions & 0 deletions src/Tests/Document/Single/Delete/DeleteApiTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Elasticsearch.Net;
using FluentAssertions;
using Nest;
using Tests.Framework;
using Tests.Framework.Integration;
Expand Down Expand Up @@ -35,5 +36,35 @@ protected override LazyResponses ClientUsage() => Calls(

protected override Func<DeleteDescriptor<Project>, IDeleteRequest> Fluent => null;
protected override DeleteRequest<Project> Initializer => new DeleteRequest<Project>(CallIsolatedValue);
}

public class DeleteNonExistentDocumentApiTests : ApiIntegrationTestBase<ReadOnlyCluster, IDeleteResponse, IDeleteRequest, DeleteDescriptor<Project>, DeleteRequest<Project>>
{
public DeleteNonExistentDocumentApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { }

protected override LazyResponses ClientUsage() => Calls(
fluent: (client, f) => client.Delete<Project>(CallIsolatedValue),
fluentAsync: (client, f) => client.DeleteAsync<Project>(CallIsolatedValue),
request: (client, r) => client.Delete(r),
requestAsync: (client, r) => client.DeleteAsync(r)
);

protected override bool ExpectIsValid => true;
protected override int ExpectStatusCode => 404;
protected override HttpMethod HttpMethod => HttpMethod.DELETE;
protected override string UrlPath => $"/project/project/{CallIsolatedValue}";

protected override bool SupportsDeserialization => false;

protected override Func<DeleteDescriptor<Project>, IDeleteRequest> Fluent => null;
protected override DeleteRequest<Project> Initializer => new DeleteRequest<Project>(CallIsolatedValue);

protected override void ExpectResponse(IDeleteResponse response)
{
response.Found.Should().BeFalse();
response.Index.Should().Be("project");
response.Type.Should().Be("project");
response.Id.Should().Be(this.CallIsolatedValue);
}
}
}
4 changes: 4 additions & 0 deletions src/Tests/Document/Single/DocumentCrudTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,9 @@ [I] protected async Task DocumentIsUpdated() => await this.AssertOnGetAfterUpdat
[I] protected async Task DocumentIsDeleted() => await this.AssertOnGetAfterDelete(r =>
r.Found.Should().BeFalse()
);

[I] protected override async Task GetAfterDeleteIsValid() => await this.AssertOnGetAfterDelete(r =>
r.ShouldBeValid()
);
}
}
34 changes: 34 additions & 0 deletions src/Tests/Document/Single/Get/GetApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,40 @@ protected override void ExpectResponse(IGetResponse<Project> response)
}
}

public class GetNonExistentDocumentApiTests : ApiIntegrationTestBase<ReadOnlyCluster, IGetResponse<Project>, IGetRequest, GetDescriptor<Project>, GetRequest<Project>>
{
protected string ProjectId => this.CallIsolatedValue;

protected string ProjectIdForUrl => Uri.EscapeDataString(this.ProjectId);

public GetNonExistentDocumentApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { }
protected override LazyResponses ClientUsage() => Calls(
fluent: (client, f) => client.Get<Project>(this.ProjectId, f),
fluentAsync: (client, f) => client.GetAsync<Project>(this.ProjectId, f),
request: (client, r) => client.Get<Project>(r),
requestAsync: (client, r) => client.GetAsync<Project>(r)
);

protected override bool ExpectIsValid => true;
protected override int ExpectStatusCode => 404;
protected override HttpMethod HttpMethod => HttpMethod.GET;
protected override string UrlPath => $"/project/project/{ProjectIdForUrl}";

protected override bool SupportsDeserialization => false;

protected override Func<GetDescriptor<Project>, IGetRequest> Fluent => null;

protected override GetRequest<Project> Initializer => new GetRequest<Project>(this.ProjectId);

protected override void ExpectResponse(IGetResponse<Project> response)
{
response.Found.Should().BeFalse();
response.Index.Should().Be("project");
response.Type.Should().Be("project");
response.Id.Should().Be(this.CallIsolatedValue);
}
}

public class GetApiParentTests : ApiIntegrationTestBase<ReadOnlyCluster, IGetResponse<CommitActivity>, IGetRequest, GetDescriptor<CommitActivity>, GetRequest<CommitActivity>>
{
protected CommitActivity CommitActivity => CommitActivity.CommitActivities.First();
Expand Down
31 changes: 31 additions & 0 deletions src/Tests/Reproduce/GithubIssue2306.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using FluentAssertions;
using Tests.Framework;
using Tests.Framework.Integration;
using Tests.Framework.MockData;
using Xunit;

namespace Tests.Reproduce
{
public class GithubIssue2306 : IClusterFixture<ReadOnlyCluster>
{
private readonly ReadOnlyCluster _cluster;

public GithubIssue2306(ReadOnlyCluster cluster)
{
_cluster = cluster;
}

[I]
public void DeleteNonExistentDocumentReturnsNotFound()
{
var client = _cluster.Client;
var response = client.Delete<Project>("non-existent-id");

response.ShouldBeValid();
response.Found.Should().BeFalse();
response.Index.Should().Be("project");
response.Type.Should().Be("project");
response.Id.Should().Be("non-existent-id");
}
}
}
1 change: 1 addition & 0 deletions src/Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@
<Compile Include="Document\Multiple\ReindexOnServer\ReindexOnServerApiTests.cs" />
<Compile Include="Document\Multiple\UpdateByQuery\UpdateByQueryApiTests.cs" />
<Compile Include="Document\Multiple\UpdateByQuery\UpdateByQueryUrlTests.cs" />
<Compile Include="Reproduce\GithubIssue2306.cs" />
<Compile Include="Reproduce\GithubIssue2309.cs" />
<Compile Include="Framework\Extensions\UriExtensions.cs" />
<Compile Include="Framework\Integration\CallUniqueValues.cs" />
Expand Down