From 3fc77a55b77fec58d737faf4546272e162b07761 Mon Sep 17 00:00:00 2001 From: Markus Dippold Date: Mon, 5 Dec 2022 09:58:46 +0100 Subject: [PATCH 1/5] Changed property visibility to public to have them serialized. --- Minio/DataModel/ILM/NoncurrentVersionExpiration.cs | 4 +++- Minio/DataModel/ILM/NoncurrentVersionTransition.cs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Minio/DataModel/ILM/NoncurrentVersionExpiration.cs b/Minio/DataModel/ILM/NoncurrentVersionExpiration.cs index 53d46b9bf..c371e23c6 100644 --- a/Minio/DataModel/ILM/NoncurrentVersionExpiration.cs +++ b/Minio/DataModel/ILM/NoncurrentVersionExpiration.cs @@ -25,6 +25,8 @@ namespace Minio.DataModel.ILM; +[Serializable] +[XmlRoot(ElementName = "NoncurrentVersionExpiration")] public class NoncurrentVersionExpiration { public NoncurrentVersionExpiration() @@ -38,5 +40,5 @@ public NoncurrentVersionExpiration(uint nonCurrentDays) } [XmlElement(ElementName = "NoncurrentDays", IsNullable = true)] - internal uint? NoncurrentDays { get; set; } + public uint? NoncurrentDays { get; set; } } \ No newline at end of file diff --git a/Minio/DataModel/ILM/NoncurrentVersionTransition.cs b/Minio/DataModel/ILM/NoncurrentVersionTransition.cs index c17e6d248..4e16387d3 100644 --- a/Minio/DataModel/ILM/NoncurrentVersionTransition.cs +++ b/Minio/DataModel/ILM/NoncurrentVersionTransition.cs @@ -44,5 +44,5 @@ public NoncurrentVersionTransition(uint nonCurrentDays, string storageClass) : b } [XmlElement(ElementName = "StorageClass", IsNullable = true)] - internal string StorageClass { get; set; } + public string StorageClass { get; set; } } \ No newline at end of file From cec8dc712f57adde42d50827c021f1ecc55e1bf7 Mon Sep 17 00:00:00 2001 From: Markus Dippold Date: Mon, 12 Dec 2022 07:42:40 +0100 Subject: [PATCH 2/5] added missing using --- Minio/DataModel/ILM/NoncurrentVersionExpiration.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Minio/DataModel/ILM/NoncurrentVersionExpiration.cs b/Minio/DataModel/ILM/NoncurrentVersionExpiration.cs index c371e23c6..6e21c58e1 100644 --- a/Minio/DataModel/ILM/NoncurrentVersionExpiration.cs +++ b/Minio/DataModel/ILM/NoncurrentVersionExpiration.cs @@ -14,6 +14,7 @@ * limitations under the License. */ +using System; using System.Xml.Serialization; /* From da4ea897cc5dce6fa94547fbd3d3d5995ee507e8 Mon Sep 17 00:00:00 2001 From: Markus Dippold Date: Mon, 19 Dec 2022 13:22:27 +0100 Subject: [PATCH 3/5] Add optional NewerNoncurrentVersions to NoncurrentVersionExpiration to have the same properties as minio-go --- Minio/DataModel/ILM/NoncurrentVersionExpiration.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Minio/DataModel/ILM/NoncurrentVersionExpiration.cs b/Minio/DataModel/ILM/NoncurrentVersionExpiration.cs index 6e21c58e1..673c2c281 100644 --- a/Minio/DataModel/ILM/NoncurrentVersionExpiration.cs +++ b/Minio/DataModel/ILM/NoncurrentVersionExpiration.cs @@ -33,13 +33,18 @@ public class NoncurrentVersionExpiration public NoncurrentVersionExpiration() { NoncurrentDays = null; + NewerNoncurrentVersions = null; } - public NoncurrentVersionExpiration(uint nonCurrentDays) + public NoncurrentVersionExpiration(uint nonCurrentDays, uint? newerNoncurrentVersions = null) { NoncurrentDays = nonCurrentDays; + NewerNoncurrentVersions = newerNoncurrentVersions; } [XmlElement(ElementName = "NoncurrentDays", IsNullable = true)] public uint? NoncurrentDays { get; set; } + + [XmlElement(ElementName = "NewerNoncurrentVersions", IsNullable = true)] + public uint? NewerNoncurrentVersions { get; set; } } \ No newline at end of file From 7d47befaf67ce860fecf11a67fc51c78d142513d Mon Sep 17 00:00:00 2001 From: Markus Dippold Date: Mon, 19 Dec 2022 13:41:07 +0100 Subject: [PATCH 4/5] Filter must not be missing, even if it is empty. --- Minio/DataModel/ILM/LifecycleRule.cs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Minio/DataModel/ILM/LifecycleRule.cs b/Minio/DataModel/ILM/LifecycleRule.cs index 694dea4cc..2fc2a2cc2 100644 --- a/Minio/DataModel/ILM/LifecycleRule.cs +++ b/Minio/DataModel/ILM/LifecycleRule.cs @@ -33,8 +33,11 @@ public class LifecycleRule public static readonly string LIFECYCLE_RULE_STATUS_ENABLED = "Enabled"; public static readonly string LIFECYCLE_RULE_STATUS_DISABLED = "Disabled"; + private RuleFilter _ruleFilter; + public LifecycleRule() { + _ruleFilter = new RuleFilter(); } public LifecycleRule(AbortIncompleteMultipartUpload abortIncompleteMultipartUpload, string id, @@ -67,7 +70,22 @@ public LifecycleRule(AbortIncompleteMultipartUpload abortIncompleteMultipartUplo public Transition TransitionObject { get; set; } [XmlElement("Filter", IsNullable = true)] - public RuleFilter Filter { get; set; } + public RuleFilter Filter + { + get { return _ruleFilter; } + set + { + // The filter must not be missing, even if it is empty. + if (value == null) + { + _ruleFilter = new RuleFilter(); + } + else + { + _ruleFilter = value; + } + } + } [XmlElement("NoncurrentVersionExpiration", IsNullable = true)] public NoncurrentVersionExpiration NoncurrentVersionExpirationObject { get; set; } @@ -75,5 +93,6 @@ public LifecycleRule(AbortIncompleteMultipartUpload abortIncompleteMultipartUplo [XmlElement("NoncurrentVersionTransition", IsNullable = true)] public NoncurrentVersionTransition NoncurrentVersionTransitionObject { get; set; } - [XmlElement("Status")] public string Status { get; set; } + [XmlElement("Status")] + public string Status { get; set; } } \ No newline at end of file From 0e62a2fc64bffe4f462bb061054741592b24c7b0 Mon Sep 17 00:00:00 2001 From: Markus Dippold Date: Mon, 19 Dec 2022 15:08:19 +0100 Subject: [PATCH 5/5] lint changes --- Minio/DataModel/ILM/LifecycleRule.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Minio/DataModel/ILM/LifecycleRule.cs b/Minio/DataModel/ILM/LifecycleRule.cs index 2fc2a2cc2..2033f5a51 100644 --- a/Minio/DataModel/ILM/LifecycleRule.cs +++ b/Minio/DataModel/ILM/LifecycleRule.cs @@ -72,18 +72,14 @@ public LifecycleRule(AbortIncompleteMultipartUpload abortIncompleteMultipartUplo [XmlElement("Filter", IsNullable = true)] public RuleFilter Filter { - get { return _ruleFilter; } + get => _ruleFilter; set { // The filter must not be missing, even if it is empty. if (value == null) - { _ruleFilter = new RuleFilter(); - } else - { _ruleFilter = value; - } } } @@ -93,6 +89,5 @@ public RuleFilter Filter [XmlElement("NoncurrentVersionTransition", IsNullable = true)] public NoncurrentVersionTransition NoncurrentVersionTransitionObject { get; set; } - [XmlElement("Status")] - public string Status { get; set; } + [XmlElement("Status")] public string Status { get; set; } } \ No newline at end of file