Skip to content

Commit

Permalink
Minor cleanups (#770)
Browse files Browse the repository at this point in the history
  • Loading branch information
martijn00 authored Apr 24, 2023
1 parent b505805 commit 5054421
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 38 deletions.
3 changes: 2 additions & 1 deletion Minio.Examples/Cases/SetBucketReplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

using System.Collections.ObjectModel;
using System.Diagnostics;
using Minio.DataModel.Replication;

Expand Down Expand Up @@ -110,7 +111,7 @@ public static async Task Run(IMinioClient minio,
SseKmsEncryptedObjects.StatusEnabled)),
ReplicationRule.StatusEnabled
);
var rules = new List<ReplicationRule>
var rules = new Collection<ReplicationRule>
{
rule
};
Expand Down
7 changes: 4 additions & 3 deletions Minio/DataModel/DeleteObjectsRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

using System.Collections.ObjectModel;
using System.Xml.Serialization;

namespace Minio.DataModel;
Expand All @@ -22,7 +23,7 @@ namespace Minio.DataModel;
[XmlType(TypeName = "Delete")]
public class DeleteObjectsRequest
{
public DeleteObjectsRequest(List<DeleteObject> objectsList, bool quiet = true)
public DeleteObjectsRequest(Collection<DeleteObject> objectsList, bool quiet = true)
{
Quiet = quiet;
Objects = objectsList;
Expand All @@ -31,10 +32,10 @@ public DeleteObjectsRequest(List<DeleteObject> objectsList, bool quiet = true)
public DeleteObjectsRequest()
{
Quiet = true;
Objects = new List<DeleteObject>();
Objects = new Collection<DeleteObject>();
}

[XmlElement("Quiet")] public bool Quiet { get; set; }

[XmlElement("Object")] public List<DeleteObject> Objects { get; set; }
[XmlElement("Object")] public Collection<DeleteObject> Objects { get; set; }
}
16 changes: 3 additions & 13 deletions Minio/DataModel/DeleteObjectsResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

using System.Collections.ObjectModel;
using System.Xml.Serialization;
using Minio.Exceptions;

Expand All @@ -23,17 +24,6 @@ namespace Minio.DataModel;
[XmlRoot(ElementName = "DeleteResult", Namespace = "http://s3.amazonaws.com/doc/2006-03-01/")]
public class DeleteObjectsResult
{
[XmlElement("Deleted")] public List<DeletedObject> objectsList;
[XmlElement("Error")] public List<DeleteError> errorList;


public IList<DeletedObject> ObjectsList()
{
return objectsList;
}

public IList<DeleteError> ErrorList()
{
return errorList;
}
[XmlElement("Deleted")] public Collection<DeletedObject> ObjectsList { get; set; }
[XmlElement("Error")] public Collection<DeleteError> ErrorList { get; set; }
}
5 changes: 3 additions & 2 deletions Minio/DataModel/ILM/AndOperator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

using System.Collections.ObjectModel;
using System.Xml.Serialization;
using Minio.DataModel.Tags;

Expand All @@ -37,7 +38,7 @@ public AndOperator()
public AndOperator(string prefix, IList<Tag> tag)
{
Prefix = prefix;
if (tag?.Count > 0) Tags = new List<Tag>(tag);
if (tag?.Count > 0) Tags = new Collection<Tag>(tag);
}

public AndOperator(string prefix, IDictionary<string, string> tags)
Expand All @@ -51,5 +52,5 @@ public AndOperator(string prefix, IDictionary<string, string> tags)
[XmlElement("Prefix")] internal string Prefix { get; set; }

[XmlElement(ElementName = "Tag", IsNullable = false)]
public List<Tag> Tags { get; set; }
public Collection<Tag> Tags { get; set; }
}
5 changes: 3 additions & 2 deletions Minio/DataModel/ILM/LifecycleConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

using System.Collections.ObjectModel;
using System.Globalization;
using System.Xml;
using System.Xml.Serialization;
Expand Down Expand Up @@ -41,10 +42,10 @@ public LifecycleConfiguration(IList<LifecycleRule> rules)
throw new ArgumentNullException(nameof(rules),
"Rules object cannot be empty. A finite set of Lifecycle Rules are needed for LifecycleConfiguration.");

Rules = new List<LifecycleRule>(rules);
Rules = new Collection<LifecycleRule>(rules);
}

[XmlElement("Rule")] public List<LifecycleRule> Rules { get; set; }
[XmlElement("Rule")] public Collection<LifecycleRule> Rules { get; set; }

public string MarshalXML()
{
Expand Down
3 changes: 2 additions & 1 deletion Minio/DataModel/ListAllMyBucketsResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

using System.Collections.ObjectModel;
using System.Xml.Serialization;

namespace Minio.DataModel;
Expand All @@ -27,5 +28,5 @@ public class ListAllMyBucketsResult

[XmlArray("Buckets")]
[XmlArrayItem(typeof(Bucket))]
public List<Bucket> Buckets { get; set; }
public Collection<Bucket> Buckets { get; set; }
}
3 changes: 2 additions & 1 deletion Minio/DataModel/ListVersionsResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

using System.Collections.ObjectModel;
using System.Xml.Serialization;

namespace Minio.DataModel;
Expand All @@ -31,7 +32,7 @@ public class ListVersionsResult
public bool IsTruncated { get; set; }
public string EncodingType { get; set; }

[XmlElement("Version")] public List<Item> Versions { get; set; }
[XmlElement("Version")] public Collection<Item> Versions { get; set; }

public string NextKeyMarker { get; set; }
public string NextVersionIdMarker { get; set; }
Expand Down
3 changes: 2 additions & 1 deletion Minio/DataModel/MinioNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;

Expand Down Expand Up @@ -42,7 +43,7 @@ public MinioNotificationRaw(string json)
public class MinioNotification
{
public string Err { get; set; }
public List<NotificationEvent> Records { get; set; }
public Collection<NotificationEvent> Records { get; set; }
}

public class NotificationEvent
Expand Down
7 changes: 4 additions & 3 deletions Minio/DataModel/Notification/S3Key.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

using System.Collections.ObjectModel;
using System.Xml.Serialization;

namespace Minio.DataModel;
Expand All @@ -25,14 +26,14 @@ namespace Minio.DataModel;
[Serializable]
public class S3Key
{
private List<FilterRule> filterRules;
private Collection<FilterRule> filterRules;

[XmlElement("FilterRule")]
public List<FilterRule> FilterRules
public Collection<FilterRule> FilterRules
{
get
{
filterRules ??= new List<FilterRule>();
filterRules ??= new Collection<FilterRule>();

return filterRules;
}
Expand Down
9 changes: 6 additions & 3 deletions Minio/DataModel/Replication/AndOperator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

using System.Collections.ObjectModel;
using System.Xml.Serialization;
using Minio.DataModel.Tags;

Expand All @@ -37,11 +38,13 @@ public AndOperator()

public AndOperator(string prefix, Tagging tagObj)
{
if (tagObj is null) throw new ArgumentNullException(nameof(tagObj));

Prefix = prefix;
Tags = new List<Tag>(tagObj.TaggingSet.Tag);
Tags = new Collection<Tag>(tagObj.TaggingSet.Tag);
}

public AndOperator(string prefix, List<Tag> tag)
public AndOperator(string prefix, Collection<Tag> tag)
{
Prefix = prefix;
Tags = tag;
Expand All @@ -55,5 +58,5 @@ public AndOperator(string prefix, IDictionary<string, string> tags)

[XmlElement("Prefix")] internal string Prefix { get; set; }

[XmlElement("Tag")] public List<Tag> Tags { get; set; }
[XmlElement("Tag")] public Collection<Tag> Tags { get; set; }
}
11 changes: 6 additions & 5 deletions Minio/DataModel/Replication/ReplicationConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

using System.Collections.ObjectModel;
using System.Globalization;
using System.Xml;
using System.Xml.Serialization;
Expand All @@ -36,23 +37,23 @@ public ReplicationConfiguration()
{
}

public ReplicationConfiguration(string role, List<ReplicationRule> rules)
public ReplicationConfiguration(string role, Collection<ReplicationRule> rules)
{
if (string.IsNullOrEmpty(role) || string.IsNullOrWhiteSpace(role))
throw new ArgumentNullException(nameof(Role) + " member cannot be empty.");
throw new ArgumentNullException(nameof(role) + " member cannot be empty.");
if (rules == null || rules.Count == 0)
throw new ArgumentNullException(nameof(Rules) + " member cannot be an empty list.");
throw new ArgumentNullException(nameof(rules) + " member cannot be an empty list.");
if (rules.Count >= 1000)
throw new ArgumentOutOfRangeException(
nameof(Rules) + " Count of rules cannot exceed maximum limit of 1000.");
nameof(rules) + " Count of rules cannot exceed maximum limit of 1000.");

Role = role;
Rules = rules;
}

[XmlElement("Role")] public string Role { get; set; }

[XmlElement("Rule")] public List<ReplicationRule> Rules { get; set; }
[XmlElement("Rule")] public Collection<ReplicationRule> Rules { get; set; }

public string MarshalXML()
{
Expand Down
5 changes: 3 additions & 2 deletions Minio/DataModel/Tags/TagSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

using System.Collections.ObjectModel;
using System.Xml.Serialization;

namespace Minio.DataModel.Tags;
Expand All @@ -30,9 +31,9 @@ public TagSet()
public TagSet(IDictionary<string, string> tags)
{
if (tags == null || tags.Count == 0) return;
Tag = new List<Tag>();
Tag = new Collection<Tag>();
foreach (var item in tags) Tag.Add(new Tag(item.Key, item.Value));
}

[XmlElement("Tag")] public List<Tag> Tag { get; set; }
[XmlElement("Tag")] public Collection<Tag> Tag { get; set; }
}
2 changes: 1 addition & 1 deletion Minio/Helper/OperationsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private async Task<IList<DeleteError>> removeObjectsAsync(RemoveObjectsArgs args
await ExecuteTaskAsync(NoErrorHandlers, requestMessageBuilder, cancellationToken: cancellationToken)
.ConfigureAwait(false);
var removeObjectsResponse = new RemoveObjectsResponse(response.StatusCode, response.Content);
return removeObjectsResponse.DeletedObjectsResult.errorList;
return removeObjectsResponse.DeletedObjectsResult.ErrorList;
}

/// <summary>
Expand Down

0 comments on commit 5054421

Please sign in to comment.