using System;
namespace PSMinIO.Models
{
///
/// Represents statistical information about MinIO storage
///
public class MinIOStats
{
///
/// Total number of buckets
///
public int TotalBuckets { get; set; }
///
/// Total number of objects across all buckets
///
public long TotalObjects { get; set; }
///
/// Total size of all objects in bytes
///
public long TotalSize { get; set; }
///
/// When these statistics were last updated
///
public DateTime LastUpdated { get; set; }
///
/// MinIO server endpoint
///
public string Endpoint { get; set; } = string.Empty;
///
/// Whether SSL is being used
///
public bool UseSSL { get; set; }
///
/// Connection status
///
public string ConnectionStatus { get; set; } = "Unknown";
///
/// Creates a new MinIOStats instance
///
public MinIOStats()
{
LastUpdated = DateTime.UtcNow;
}
///
/// Creates a new MinIOStats instance with specified values
///
/// Total number of buckets
/// Total number of objects
/// Total size in bytes
/// MinIO endpoint
/// Whether SSL is used
public MinIOStats(int totalBuckets, long totalObjects, long totalSize, string endpoint, bool useSSL)
{
TotalBuckets = totalBuckets;
TotalObjects = totalObjects;
TotalSize = totalSize;
Endpoint = endpoint ?? string.Empty;
UseSSL = useSSL;
LastUpdated = DateTime.UtcNow;
ConnectionStatus = "Connected";
}
///
/// Gets the average object size in bytes
///
public double AverageObjectSize => TotalObjects > 0 ? (double)TotalSize / TotalObjects : 0;
///
/// Gets the average objects per bucket
///
public double AverageObjectsPerBucket => TotalBuckets > 0 ? (double)TotalObjects / TotalBuckets : 0;
///
/// Returns a string representation of the statistics
///
public override string ToString()
{
return $"MinIO Stats: {TotalBuckets} buckets, {TotalObjects} objects, {Utils.SizeFormatter.FormatBytes(TotalSize)} total";
}
}
}