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
10 changes: 5 additions & 5 deletions src/Elasticsearch.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.9
VisualStudioVersion = 15.0.26430.6
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nest", "Nest\Nest.csproj", "{072BA7DA-7B60-407D-8B6E-95E3186BE70C}"
EndProject
Expand Down Expand Up @@ -29,7 +29,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiGenerator", "CodeGenerat
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elasticsearch.Net", "Elasticsearch.Net\Elasticsearch.Net.csproj", "{E97CCF40-0BA6-43FE-9F2D-58D454134088}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "scripts", "..\build\scripts\scripts.fsproj", "{28328694-2598-44D3-BB25-8B6C3FBDD3EF}"
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "scripts", "..\build\scripts\scripts.fsproj", "{D6997ADC-E933-418E-831C-DE1A78897493}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "Tests\Tests.csproj", "{37164C11-88EF-4428-803A-9AA24FB8B44D}"
EndProject
Expand All @@ -53,8 +53,8 @@ Global
{E97CCF40-0BA6-43FE-9F2D-58D454134088}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E97CCF40-0BA6-43FE-9F2D-58D454134088}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E97CCF40-0BA6-43FE-9F2D-58D454134088}.Release|Any CPU.Build.0 = Release|Any CPU
{28328694-2598-44D3-BB25-8B6C3FBDD3EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28328694-2598-44D3-BB25-8B6C3FBDD3EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6997ADC-E933-418E-831C-DE1A78897493}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6997ADC-E933-418E-831C-DE1A78897493}.Release|Any CPU.ActiveCfg = Release|Any CPU
{37164C11-88EF-4428-803A-9AA24FB8B44D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{37164C11-88EF-4428-803A-9AA24FB8B44D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{37164C11-88EF-4428-803A-9AA24FB8B44D}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -69,7 +69,7 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{56A87048-9065-459B-826D-3DF68B409845} = {93331BEE-0AA0-47B7-B1D2-BD5BD31634D1}
{28328694-2598-44D3-BB25-8B6C3FBDD3EF} = {432D5575-2347-4D3C-BF8C-3E38410C46CA}
{D6997ADC-E933-418E-831C-DE1A78897493} = {432D5575-2347-4D3C-BF8C-3E38410C46CA}
{98400F59-4BA8-4534-9A78-9C7FA0B42901} = {93331BEE-0AA0-47B7-B1D2-BD5BD31634D1}
EndGlobalSection
EndGlobal
45 changes: 45 additions & 0 deletions src/Nest/Indices/AliasManagement/Alias/Actions/AliasRemoveIndex.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using Newtonsoft.Json;

namespace Nest
{
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public interface IAliasRemoveIndexAction : IAliasAction
{
[JsonProperty("remove_index")]
AliasRemoveIndexOperation RemoveIndex { get; set; }
}

public class AliasRemoveIndexAction : IAliasRemoveIndexAction
{
public AliasRemoveIndexOperation RemoveIndex { get; set; }
}

public class AliasRemoveIndexDescriptor : DescriptorBase<AliasRemoveIndexDescriptor, IAliasRemoveIndexAction>, IAliasRemoveIndexAction
{
AliasRemoveIndexOperation IAliasRemoveIndexAction.RemoveIndex { get; set; }

public AliasRemoveIndexDescriptor()
{
Self.RemoveIndex = new AliasRemoveIndexOperation();
}

public AliasRemoveIndexDescriptor Index(IndexName index)
{
Self.RemoveIndex.Index = index;
return this;
}

public AliasRemoveIndexDescriptor Index(Type index)
{
Self.RemoveIndex.Index = index;
return this;
}

public AliasRemoveIndexDescriptor Index<T>() where T : class
{
Self.RemoveIndex.Index = typeof(T);
return this;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Newtonsoft.Json;

namespace Nest
{
public class AliasRemoveIndexOperation
{
[JsonProperty("index")]
public IndexName Index { get; set; }
}
}
11 changes: 7 additions & 4 deletions src/Nest/Indices/AliasManagement/Alias/BulkAliasRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,31 @@

namespace Nest
{
public partial interface IBulkAliasRequest
public partial interface IBulkAliasRequest
{
[JsonProperty("actions")]
IList<IAliasAction> Actions { get; set; }
}

public partial class BulkAliasRequest
public partial class BulkAliasRequest
{
public IList<IAliasAction> Actions { get; set; }
}


[DescriptorFor("IndicesUpdateAliases")]
public partial class BulkAliasDescriptor
public partial class BulkAliasDescriptor
{
public BulkAliasDescriptor Add(IAliasAction action) =>
public BulkAliasDescriptor Add(IAliasAction action) =>
Fluent.Assign<BulkAliasDescriptor, IBulkAliasRequest>(this, a=> a.Actions.AddIfNotNull(action));

IList<IAliasAction> IBulkAliasRequest.Actions { get; set; } = new List<IAliasAction>();

public BulkAliasDescriptor Add(Func<AliasAddDescriptor, IAliasAddAction> addSelector) => Add(addSelector?.Invoke(new AliasAddDescriptor()));

public BulkAliasDescriptor Remove(Func<AliasRemoveDescriptor, IAliasRemoveAction> removeSelector)=> Add(removeSelector?.Invoke(new AliasRemoveDescriptor()));

public IBulkAliasRequest RemoveIndex(Func<AliasRemoveIndexDescriptor, IAliasRemoveIndexAction> removeIndexSelector) =>
Add(removeIndexSelector?.Invoke(new AliasRemoveIndexDescriptor()));
}
}
2 changes: 1 addition & 1 deletion src/Nest/Nest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
<PackageReference Include="System.Linq.Queryable" Version="4.0.1" />
</ItemGroup>
<!--<Import Project="..\..\.paket\Paket.Restore.targets" />-->
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using Elasticsearch.Net;
using Nest;
using Tests.Framework;
using Tests.Framework.Integration;
using Tests.Framework.ManagedElasticsearch.Clusters;

namespace Tests.Indices.AliasManagement.Alias
{
public class AliasApiRemoveIndexTests : ApiIntegrationAgainstNewIndexTestBase<WritableCluster, IBulkAliasResponse, IBulkAliasRequest, BulkAliasDescriptor, BulkAliasRequest>
{
public AliasApiRemoveIndexTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { }

protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values)
{
foreach (var value in values.Values)
{
var createIndexResponse = client.CreateIndex(value + "-1", c => c);
if (!createIndexResponse.IsValid)
throw new Exception(createIndexResponse.DebugInformation);

createIndexResponse = client.CreateIndex(value + "-2", c => c);
if (!createIndexResponse.IsValid)
throw new Exception(createIndexResponse.DebugInformation);
}
}

protected override LazyResponses ClientUsage() => Calls(
fluent: (client, f) => client.Alias(f),
fluentAsync: (client, f) => client.AliasAsync(f),
request: (client, r) => client.Alias(r),
requestAsync: (client, r) => client.AliasAsync(r)
);

protected override bool ExpectIsValid => true;
protected override int ExpectStatusCode => 200;
protected override HttpMethod HttpMethod => HttpMethod.POST;
protected override string UrlPath => $"/_aliases";

protected override bool SupportsDeserialization => false;

protected override object ExpectJson => new
{
actions = new object[]
{
new Dictionary<string, object> { { "add", new { alias = CallIsolatedValue + "-1", index = CallIsolatedValue + "-2" } } },
new Dictionary<string, object> { { "remove_index", new { index = CallIsolatedValue + "-1"} } },
}
};

protected override Func<BulkAliasDescriptor, IBulkAliasRequest> Fluent => d => d
.Add(a=>a.Alias(CallIsolatedValue + "-1").Index(CallIsolatedValue + "-2"))
.RemoveIndex(a => a.Index(CallIsolatedValue + "-1"))
;

protected override BulkAliasRequest Initializer => new BulkAliasRequest
{
Actions = new List<IAliasAction>
{
new AliasAddAction { Add = new AliasAddOperation {Alias = CallIsolatedValue + "-1", Index = CallIsolatedValue + "-2"} },
new AliasRemoveIndexAction {RemoveIndex = new AliasRemoveIndexOperation {Index = Infer.Index(CallIsolatedValue + "-1") }},
}
};
}
}