-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Voting Config Exclusions APIs (#4738)
Relates: #4718, elastic/elasticsearch#55760 This commit adds the voting config exclusions APIs to the high level client. Custom response builder types are required because the APIs return \n as the response, which the client will attempt to deserialize to a response object.
- Loading branch information
1 parent
d593130
commit e4b98e3
Showing
11 changed files
with
361 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...otingConfigExclusions/DeleteVotingConfigExclusions/DeleteVotingConfigExclusionsRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// 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.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Elasticsearch.Net; | ||
using Elasticsearch.Net.Specification.ClusterApi; | ||
|
||
namespace Nest | ||
{ | ||
[MapsApi("cluster.delete_voting_config_exclusions")] | ||
public partial interface IDeleteVotingConfigExclusionsRequest { } | ||
|
||
public partial class DeleteVotingConfigExclusionsRequest | ||
{ | ||
protected sealed override void RequestDefaults(DeleteVotingConfigExclusionsRequestParameters parameters) => | ||
parameters.CustomResponseBuilder = new DeleteVotingConfigExclusionsResponseBuilder(); | ||
} | ||
|
||
public partial class DeleteVotingConfigExclusionsDescriptor | ||
{ | ||
protected sealed override void RequestDefaults(DeleteVotingConfigExclusionsRequestParameters parameters) => | ||
parameters.CustomResponseBuilder = new DeleteVotingConfigExclusionsResponseBuilder(); | ||
} | ||
|
||
/// <summary> | ||
/// Response is a single newline character, so skip trying to deserialize to an object | ||
/// </summary> | ||
internal class DeleteVotingConfigExclusionsResponseBuilder : CustomResponseBuilderBase | ||
{ | ||
public override object DeserializeResponse(IElasticsearchSerializer builtInSerializer, IApiCallDetails response, Stream stream) => | ||
new DeleteVotingConfigExclusionsResponse(); | ||
|
||
public override Task<object> DeserializeResponseAsync(IElasticsearchSerializer builtInSerializer, IApiCallDetails response, Stream stream, CancellationToken ctx = default) => | ||
Task.FromResult<object>(new DeleteVotingConfigExclusionsResponse()); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...tingConfigExclusions/DeleteVotingConfigExclusions/DeleteVotingConfigExclusionsResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// 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 | ||
|
||
namespace Nest | ||
{ | ||
public class DeleteVotingConfigExclusionsResponse : ResponseBase | ||
{ | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...er/VotingConfigExclusions/PostVotingConfigExclusions/PostVotingConfigExclusionsRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// 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.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Elasticsearch.Net; | ||
using Elasticsearch.Net.Specification.ClusterApi; | ||
|
||
namespace Nest | ||
{ | ||
[MapsApi("cluster.post_voting_config_exclusions")] | ||
public partial interface IPostVotingConfigExclusionsRequest { } | ||
|
||
public partial class PostVotingConfigExclusionsRequest | ||
{ | ||
protected sealed override void RequestDefaults(PostVotingConfigExclusionsRequestParameters parameters) => | ||
parameters.CustomResponseBuilder = new PostVotingConfigExclusionsResponseBuilder(); | ||
} | ||
|
||
public partial class PostVotingConfigExclusionsDescriptor | ||
{ | ||
protected sealed override void RequestDefaults(PostVotingConfigExclusionsRequestParameters parameters) => | ||
parameters.CustomResponseBuilder = new PostVotingConfigExclusionsResponseBuilder(); | ||
} | ||
|
||
/// <summary> | ||
/// Response is a single newline character, so skip trying to deserialize to an object | ||
/// </summary> | ||
internal class PostVotingConfigExclusionsResponseBuilder : CustomResponseBuilderBase | ||
{ | ||
public override object DeserializeResponse(IElasticsearchSerializer builtInSerializer, IApiCallDetails response, Stream stream) => | ||
new PostVotingConfigExclusionsResponse(); | ||
|
||
public override Task<object> DeserializeResponseAsync(IElasticsearchSerializer builtInSerializer, IApiCallDetails response, Stream stream, CancellationToken ctx = default) => | ||
Task.FromResult<object>(new PostVotingConfigExclusionsResponse()); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...r/VotingConfigExclusions/PostVotingConfigExclusions/PostVotingConfigExclusionsResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// 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 | ||
|
||
namespace Nest | ||
{ | ||
public class PostVotingConfigExclusionsResponse : ResponseBase | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...tingConfigExclusions/DeleteVotingConfigExclusions/DeleteVotingConfigExclusionsApiTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// 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.Threading; | ||
using Elasticsearch.Net; | ||
using FluentAssertions; | ||
using Nest; | ||
using Tests.Cluster.TaskManagement.GetTask; | ||
using Tests.Core.Extensions; | ||
using Tests.Core.ManagedElasticsearch.Clusters; | ||
using Tests.Core.ManagedElasticsearch.NodeSeeders; | ||
using Tests.Domain; | ||
using Tests.Framework.EndpointTests; | ||
using Tests.Framework.EndpointTests.TestState; | ||
|
||
namespace Tests.Cluster.VotingConfigExclusions.DeleteVotingConfigExclusions | ||
{ | ||
public class DeleteVotingConfigExclusionsApiTests : ApiIntegrationTestBase<WritableCluster, DeleteVotingConfigExclusionsResponse, IDeleteVotingConfigExclusionsRequest, DeleteVotingConfigExclusionsDescriptor, DeleteVotingConfigExclusionsRequest> | ||
{ | ||
public DeleteVotingConfigExclusionsApiTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { } | ||
|
||
protected override bool ExpectIsValid => true; | ||
protected override int ExpectStatusCode => 200; | ||
|
||
protected override Func<DeleteVotingConfigExclusionsDescriptor, IDeleteVotingConfigExclusionsRequest> Fluent => s => s | ||
.WaitForRemoval(); | ||
|
||
protected override HttpMethod HttpMethod => HttpMethod.DELETE; | ||
|
||
protected override DeleteVotingConfigExclusionsRequest Initializer => new DeleteVotingConfigExclusionsRequest { WaitForRemoval = true }; | ||
protected override string UrlPath => $"/_cluster/voting_config_exclusions?wait_for_removal=true"; | ||
|
||
protected override LazyResponses ClientUsage() => Calls( | ||
(client, f) => client.Cluster.DeleteVotingConfigExclusions(f), | ||
(client, f) => client.Cluster.DeleteVotingConfigExclusionsAsync(f), | ||
(client, r) => client.Cluster.DeleteVotingConfigExclusions(r), | ||
(client, r) => client.Cluster.DeleteVotingConfigExclusionsAsync(r) | ||
); | ||
|
||
protected override void ExpectResponse(DeleteVotingConfigExclusionsResponse response) => response.ShouldBeValid(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...tingConfigExclusions/DeleteVotingConfigExclusions/DeleteingVotingConfigExclusionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// 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.Threading.Tasks; | ||
using Elastic.Elasticsearch.Xunit.XunitPlumbing; | ||
using Nest; | ||
using Tests.Framework.EndpointTests; | ||
using static Tests.Framework.EndpointTests.UrlTester; | ||
|
||
namespace Tests.Cluster.VotingConfigExclusions.DeleteVotingConfigExclusions | ||
{ | ||
public class DeleteingVotingConfigExclusionsTests : UrlTestsBase | ||
{ | ||
[U] public override async Task Urls() => | ||
await DELETE("/_cluster/voting_config_exclusions") | ||
.Fluent(c => c.Cluster.DeleteVotingConfigExclusions()) | ||
.Request(c => c.Cluster.DeleteVotingConfigExclusions(new DeleteVotingConfigExclusionsRequest())) | ||
.FluentAsync(c => c.Cluster.DeleteVotingConfigExclusionsAsync()) | ||
.RequestAsync(c => c.Cluster.DeleteVotingConfigExclusionsAsync(new DeleteVotingConfigExclusionsRequest())); | ||
} | ||
} |
Oops, something went wrong.