From 93f67c2281ca19ef3f6b6ea5a614f97a872e9a6e Mon Sep 17 00:00:00 2001 From: Russ Cam Date: Wed, 23 Oct 2019 10:01:35 +1000 Subject: [PATCH] Convert SLM API dates returned as long to DateTimeOffset This commit updates the SLM API responses to convert date properties that are returned long values representing milliseconds since epoch to DateTimeOffset. This is consistent with other API responses where longs are returned. What is slightly different with this API is that Human=true can be specified on the request to also return the properties as string values. With this change, the client now effectively ignores these values as they serve little purpose, since both would end up being converted to DateTimeOffset when deserialized. --- .../Slm/SnapshotLifecyclePolicyMetadata.cs | 27 +++++-------------- src/Tests/Tests/XPack/Slm/SlmApiTests.cs | 2 -- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/Nest/XPack/Slm/SnapshotLifecyclePolicyMetadata.cs b/src/Nest/XPack/Slm/SnapshotLifecyclePolicyMetadata.cs index 33a3cb8840e..53d5f073d4d 100644 --- a/src/Nest/XPack/Slm/SnapshotLifecyclePolicyMetadata.cs +++ b/src/Nest/XPack/Slm/SnapshotLifecyclePolicyMetadata.cs @@ -11,29 +11,17 @@ public class SnapshotLifecyclePolicyMetadata { /// /// The modified date. - /// Returned only when Human is set to true on the request - /// - [DataMember(Name = "modified_date")] - public DateTimeOffset? ModifiedDate { get; internal set; } - - /// - /// The modified date in milliseconds /// [DataMember(Name = "modified_date_millis")] - public long ModifiedDateInMilliseconds { get; internal set; } + [JsonFormatter(typeof(DateTimeOffsetEpochMillisecondsFormatter))] + public DateTimeOffset ModifiedDate { get; internal set; } /// /// The next execution date. - /// Returned only when Human is set to true on the request - /// - [DataMember(Name = "next_execution")] - public DateTimeOffset? NextExecution { get; internal set; } - - /// - /// The next execution date in milliseconds /// [DataMember(Name = "next_execution_millis")] - public long NextExecutionInMilliseconds { get; internal set; } + [JsonFormatter(typeof(DateTimeOffsetEpochMillisecondsFormatter))] + public DateTimeOffset NextExecution { get; internal set; } /// /// The snapshot lifecycle policy @@ -51,7 +39,7 @@ public class SnapshotLifecyclePolicyMetadata /// If a snapshot is currently in progress this will return information about the snapshot. /// [DataMember(Name = "in_progress")] - public LifecycleSnapshotInProgress InProgress { get; internal set; } + public SnapshotLifecycleInProgress InProgress { get; internal set; } /// /// Information about the last time the policy successfully initiated a snapshot. @@ -80,13 +68,13 @@ public class SnapshotLifecycleInvocationRecord /// If a snapshot is in progress when calling the Get Snapshot Lifecycle metadata /// this will hold some minimal information about the in flight snapshot /// - public class LifecycleSnapshotInProgress + public class SnapshotLifecycleInProgress { /// The name of the snapshot currently being taken [DataMember(Name = "name")] public string Name { get; internal set; } - /// The UUI of the snapshot currently being taken + /// The UUID of the snapshot currently being taken [DataMember(Name = "uuid")] public string UUID { get; internal set; } @@ -98,6 +86,5 @@ public class LifecycleSnapshotInProgress [DataMember(Name = "start_time_millis")] [JsonFormatter(typeof(DateTimeOffsetEpochMillisecondsFormatter))] public DateTimeOffset StartTime { get; internal set; } - } } diff --git a/src/Tests/Tests/XPack/Slm/SlmApiTests.cs b/src/Tests/Tests/XPack/Slm/SlmApiTests.cs index ad8ee659f19..095ad1d6b55 100644 --- a/src/Tests/Tests/XPack/Slm/SlmApiTests.cs +++ b/src/Tests/Tests/XPack/Slm/SlmApiTests.cs @@ -153,9 +153,7 @@ [I] public async Task GetSnapshotLifecycleResponse() => await Assert