/// Modèle des métriques système
/// Correspond à SystemMetricsResponse du backend
library system_metrics_model;

import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';

part 'system_metrics_model.g.dart';

@JsonSerializable(explicitToJson: true)
class SystemMetricsModel extends Equatable {
  final double? cpuUsagePercent;
  final double? memoryUsagePercent;
  final double? diskUsagePercent;
  final double? networkUsageMbps;
  final int? activeConnections;
  final double? errorRate;
  final int? averageResponseTimeMs;
  final int? uptime;
  final String? uptimeFormatted;
  final int? totalLogs24h;
  final int? totalErrors24h;
  final int? totalWarnings24h;
  final int? totalRequests24h;
  final DateTime? timestamp;

  const SystemMetricsModel({
    this.cpuUsagePercent,
    this.memoryUsagePercent,
    this.diskUsagePercent,
    this.networkUsageMbps,
    this.activeConnections,
    this.errorRate,
    this.averageResponseTimeMs,
    this.uptime,
    this.uptimeFormatted,
    this.totalLogs24h,
    this.totalErrors24h,
    this.totalWarnings24h,
    this.totalRequests24h,
    this.timestamp,
  });

  factory SystemMetricsModel.fromJson(Map<String, dynamic> json) =>
      _$SystemMetricsModelFromJson(json);

  Map<String, dynamic> toJson() => _$SystemMetricsModelToJson(this);

  @override
  List<Object?> get props => [
        cpuUsagePercent,
        memoryUsagePercent,
        diskUsagePercent,
        networkUsageMbps,
        activeConnections,
        errorRate,
        averageResponseTimeMs,
        uptime,
        uptimeFormatted,
        totalLogs24h,
        totalErrors24h,
        totalWarnings24h,
        totalRequests24h,
        timestamp,
      ];
}
