Skip to content

Commit

Permalink
Add metadata to snapshots. (#4072)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebrain committed Sep 3, 2019
1 parent 6a4ad4d commit 45f6140
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Nest/Modules/SnapshotAndRestore/Snapshot/Snapshot.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Elasticsearch.Net;

namespace Nest
{
Expand Down Expand Up @@ -35,5 +36,8 @@ public class Snapshot

[DataMember(Name ="state")]
public string State { get; internal set; }

[DataMember(Name ="metadata")]
public IReadOnlyDictionary<string, object> Metadata { get; internal set; } = EmptyReadOnly<string, object>.Dictionary;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Runtime.Serialization;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Elasticsearch.Net.Utf8Json;

namespace Nest
Expand All @@ -18,6 +20,9 @@ public partial interface ISnapshotRequest

[DataMember(Name ="partial")]
bool? Partial { get; set; }

[DataMember(Name = "metadata")]
IDictionary<string, object> Metadata { get; set; }
}

public partial class SnapshotRequest
Expand All @@ -28,6 +33,8 @@ public partial class SnapshotRequest
public Indices Indices { get; set; }

public bool? Partial { get; set; }

public IDictionary<string, object> Metadata { get; set; }
}

public partial class SnapshotDescriptor
Expand All @@ -39,6 +46,8 @@ public partial class SnapshotDescriptor

bool? ISnapshotRequest.Partial { get; set; }

IDictionary<string, object> ISnapshotRequest.Metadata { get; set; }

public SnapshotDescriptor Index(IndexName index) => Indices(index);

public SnapshotDescriptor Index<T>() where T : class => Indices(typeof(T));
Expand All @@ -50,5 +59,10 @@ public partial class SnapshotDescriptor
public SnapshotDescriptor IncludeGlobalState(bool? includeGlobalState = true) => Assign(includeGlobalState, (a, v) => a.IncludeGlobalState = v);

public SnapshotDescriptor Partial(bool? partial = true) => Assign(partial, (a, v) => a.Partial = v);

public SnapshotDescriptor Metadata(IDictionary<string, object> metadata) => Assign(metadata, (a, v) => a.Metadata = v);

public SnapshotDescriptor Metadata(Func<FluentDictionary<string, object>, IDictionary<string, object>> selector) =>
Assign(selector, (a, v) => a.Metadata = v?.Invoke(new FluentDictionary<string, object>()));
}
}

0 comments on commit 45f6140

Please sign in to comment.