-
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.
Implement Forget Follower API (#3939)
Implement Forget Follower API
- Loading branch information
Showing
11 changed files
with
259 additions
and
1 deletion.
There are no files selected for viewing
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
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
74 changes: 74 additions & 0 deletions
74
...st/XPack/CrossClusterReplication/Follow/ForgetFollowerIndex/ForgetFollowerIndexRequest.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,74 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace Nest | ||
{ | ||
[MapsApi("ccr.forget_follower.json")] | ||
[ReadAs(typeof(ForgetFollowerIndexRequest))] | ||
public partial interface IForgetFollowerIndexRequest | ||
{ | ||
/// <summary> | ||
/// The name of the cluster containing the follower index. | ||
/// </summary> | ||
[DataMember(Name = "follower_cluster")] | ||
string FollowerCluster { get; set; } | ||
|
||
/// <summary> | ||
/// The name of the follower index. | ||
/// </summary> | ||
[DataMember(Name = "follower_index")] | ||
IndexName FollowerIndex { get; set; } | ||
|
||
/// <summary> | ||
/// The UUID of the follower index. | ||
/// </summary> | ||
[DataMember(Name = "follower_index_uuid")] | ||
string FollowerIndexUUID { get; set; } | ||
|
||
/// <summary> | ||
/// The alias (from the perspective of the cluster containing the follower index) of the remote cluster containing the leader index. | ||
/// </summary> | ||
[DataMember(Name = "leader_remote_cluster")] | ||
string LeaderRemoteCluster { get; set; } | ||
} | ||
|
||
/// <inheritdoc cref="IForgetFollowerIndexRequest"/> | ||
public partial class ForgetFollowerIndexRequest | ||
{ | ||
/// <inheritdoc cref="IForgetFollowerIndexRequest.FollowerCluster"/> | ||
public string FollowerCluster { get; set; } | ||
|
||
/// <inheritdoc cref="IForgetFollowerIndexRequest.FollowerIndex"/> | ||
public IndexName FollowerIndex { get; set; } | ||
|
||
/// <inheritdoc cref="IForgetFollowerIndexRequest.FollowerIndexUUID"/> | ||
public string FollowerIndexUUID { get; set; } | ||
|
||
/// <inheritdoc cref="IForgetFollowerIndexRequest.LeaderRemoteCluster"/> | ||
public string LeaderRemoteCluster { get; set; } | ||
} | ||
|
||
/// <inheritdoc cref="IForgetFollowerIndexRequest"/> | ||
public partial class ForgetFollowerIndexDescriptor | ||
{ | ||
string IForgetFollowerIndexRequest.FollowerCluster { get; set; } | ||
IndexName IForgetFollowerIndexRequest.FollowerIndex { get; set; } | ||
string IForgetFollowerIndexRequest.FollowerIndexUUID { get; set; } | ||
string IForgetFollowerIndexRequest.LeaderRemoteCluster { get; set; } | ||
|
||
/// <inheritdoc cref="IForgetFollowerIndexRequest.FollowerCluster"/> | ||
public ForgetFollowerIndexDescriptor FollowerCluster(string followerCluster) => | ||
Assign(followerCluster, (a, v) => a.FollowerCluster = v); | ||
|
||
/// <inheritdoc cref="IForgetFollowerIndexRequest.FollowerIndex"/> | ||
public ForgetFollowerIndexDescriptor FollowerIndex(IndexName followerIndex) => | ||
Assign(followerIndex, (a, v) => a.FollowerIndex = v); | ||
|
||
/// <inheritdoc cref="IForgetFollowerIndexRequest.FollowerIndexUUID"/> | ||
public ForgetFollowerIndexDescriptor FollowerIndexUUID(string followerIndexUUID) => | ||
Assign(followerIndexUUID, (a, v) => a.FollowerIndexUUID = v); | ||
|
||
/// <inheritdoc cref="IForgetFollowerIndexRequest.LeaderRemoteCluster"/> | ||
public ForgetFollowerIndexDescriptor LeaderRemoteCluster(string leaderRemoteCluster) => | ||
Assign(leaderRemoteCluster, (a, v) => a.LeaderRemoteCluster = v); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...t/XPack/CrossClusterReplication/Follow/ForgetFollowerIndex/ForgetFollowerIndexResponse.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 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace Nest | ||
{ | ||
public class ForgetFollowerIndexResponse : ResponseBase | ||
{ | ||
[DataMember(Name ="_shards")] | ||
public ShardStatistics Shards { get; internal set; } | ||
} | ||
} |
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
52 changes: 52 additions & 0 deletions
52
...s/XPack/CrossClusterReplication/Follow/ForgetFollowerIndex/ForgetFollowerIndexApiTests.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,52 @@ | ||
using System; | ||
using Elasticsearch.Net; | ||
using Nest; | ||
using Tests.Core.ManagedElasticsearch.Clusters; | ||
using Tests.Framework.EndpointTests; | ||
using Tests.Framework.EndpointTests.TestState; | ||
|
||
namespace Tests.XPack.CrossClusterReplication.Follow.ForgetFollowerIndex | ||
{ | ||
public class ForgetFollowerIndexApiTests : ApiTestBase<XPackCluster, ForgetFollowerIndexResponse, IForgetFollowerIndexRequest, ForgetFollowerIndexDescriptor, ForgetFollowerIndexRequest> | ||
{ | ||
public ForgetFollowerIndexApiTests(XPackCluster cluster, EndpointUsage usage) : base(cluster, usage) { } | ||
|
||
protected override object ExpectJson { get; } = new | ||
{ | ||
follower_index = "follower-index", | ||
follower_cluster = "follower-cluster", | ||
leader_remote_cluster ="leader-remote-cluster", | ||
follower_index_uuid = "follower-index-uuid", | ||
}; | ||
|
||
protected override ForgetFollowerIndexDescriptor NewDescriptor() => new ForgetFollowerIndexDescriptor("index"); | ||
|
||
protected override Func<ForgetFollowerIndexDescriptor, IForgetFollowerIndexRequest> Fluent => d => d | ||
.Index("index") | ||
.FollowerIndex("follower-index") | ||
.FollowerCluster("follower-cluster") | ||
.LeaderRemoteCluster("leader-remote-cluster") | ||
.FollowerIndexUUID("follower-index-uuid") | ||
; | ||
|
||
protected override HttpMethod HttpMethod => HttpMethod.POST; | ||
|
||
protected override ForgetFollowerIndexRequest Initializer => new ForgetFollowerIndexRequest("index") | ||
{ | ||
FollowerIndex = "follower-index", | ||
FollowerCluster = "follower-cluster", | ||
LeaderRemoteCluster ="leader-remote-cluster", | ||
FollowerIndexUUID = "follower-index-uuid", | ||
}; | ||
|
||
protected override bool SupportsDeserialization => false; | ||
protected override string UrlPath => "/index/_ccr/forget_follower"; | ||
|
||
protected override LazyResponses ClientUsage() => Calls( | ||
(client, f) => client.CrossClusterReplication.ForgetFollowerIndex("index", f), | ||
(client, f) => client.CrossClusterReplication.ForgetFollowerIndexAsync("index", f), | ||
(client, r) => client.CrossClusterReplication.ForgetFollowerIndex(r), | ||
(client, r) => client.CrossClusterReplication.ForgetFollowerIndexAsync(r) | ||
); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...s/XPack/CrossClusterReplication/Follow/ForgetFollowerIndex/ForgetFollowerIndexUrlTests.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,21 @@ | ||
using System.Threading.Tasks; | ||
using Elastic.Xunit.XunitPlumbing; | ||
using Nest; | ||
using Tests.Framework.EndpointTests; | ||
|
||
namespace Tests.XPack.CrossClusterReplication.Follow.ForgetFollowerIndex | ||
{ | ||
public class ForgetFollowerIndexUrlTests : UrlTestsBase | ||
{ | ||
[U] public override async Task Urls() | ||
{ | ||
var name = "x"; | ||
await UrlTester.POST($"/{name}/_ccr/forget_follower") | ||
.Fluent(c => c.CrossClusterReplication.ForgetFollowerIndex(name, d => d)) | ||
.Request(c => c.CrossClusterReplication.ForgetFollowerIndex(new ForgetFollowerIndexRequest(name))) | ||
.FluentAsync(c => c.CrossClusterReplication.ForgetFollowerIndexAsync(name, d => d)) | ||
.RequestAsync(c => c.CrossClusterReplication.ForgetFollowerIndexAsync(new ForgetFollowerIndexRequest(name))); | ||
|
||
} | ||
} | ||
} |