using System.ComponentModel.DataAnnotations;
namespace Extrudex.API.DTOs.Printers;
///
/// Response DTO for a Printer entity. Contains all printer details
/// including connection configuration and operational status.
///
public class PrinterResponse
{
/// Unique identifier for the printer.
public Guid Id { get; set; }
/// Current operational status (Idle, Printing, Offline, Error, Paused).
public string Status { get; set; } = string.Empty;
/// Human-readable name (e.g., "Bambu X1C #1", "Elegoo Centauri").
public string Name { get; set; } = string.Empty;
/// Manufacturer/brand (e.g., "Bambu Lab", "Elegoo").
public string Manufacturer { get; set; } = string.Empty;
/// Model name (e.g., "X1 Carbon", "Centauri Carbon").
public string Model { get; set; } = string.Empty;
/// Printer hardware type ("Fdm" or "Resin").
public string PrinterType { get; set; } = string.Empty;
/// Connectivity protocol ("Mqtt" or "Moonraker").
public string ConnectionType { get; set; } = string.Empty;
/// Hostname or IP address for printer connection.
public string HostnameOrIp { get; set; } = string.Empty;
/// Port number for the connection (8883 for MQTT/TLS, 7125 for Moonraker).
public int Port { get; set; }
/// Whether the printer is currently active and available for jobs.
public bool IsActive { get; set; }
/// Timestamp of the last status update received from the printer (UTC).
public DateTime? LastSeenAt { get; set; }
/// Timestamp when this record was created (UTC).
public DateTime CreatedAt { get; set; }
/// Timestamp when this record was last modified (UTC).
public DateTime UpdatedAt { get; set; }
}
///
/// Lightweight response DTO for printer status. Optimized for polling
/// and dashboard displays. For real-time updates, use the SignalR PrinterHub.
///
public class PrinterStatusResponse
{
/// Unique identifier for the printer.
public Guid Id { get; set; }
/// Human-readable name of the printer.
public string Name { get; set; } = string.Empty;
/// Current operational status (Idle, Printing, Offline, Error, Paused).
public string Status { get; set; } = string.Empty;
/// Timestamp of the last status update received from the printer (UTC).
public DateTime? LastSeenAt { get; set; }
/// Whether the printer is currently active and available for jobs.
public bool IsActive { get; set; }
}
///
/// Request DTO for registering a new printer in the fleet.
/// All string enums accept: PrinterType = "Fdm"|"Resin",
/// ConnectionType = "Mqtt"|"Moonraker" (case-insensitive).
///
public class CreatePrinterRequest
{
/// Human-readable name for the printer. Required, max 100 characters.
[Required(ErrorMessage = "Name is required.")]
[StringLength(100, MinimumLength = 1, ErrorMessage = "Name must be between 1 and 100 characters.")]
public string Name { get; set; } = string.Empty;
/// Manufacturer/brand (e.g., "Bambu Lab", "Elegoo"). Required, max 50 characters.
[Required(ErrorMessage = "Manufacturer is required.")]
[StringLength(50, MinimumLength = 1, ErrorMessage = "Manufacturer must be between 1 and 50 characters.")]
public string Manufacturer { get; set; } = string.Empty;
/// Model name (e.g., "X1 Carbon", "Centauri Carbon"). Required, max 50 characters.
[Required(ErrorMessage = "Model is required.")]
[StringLength(50, MinimumLength = 1, ErrorMessage = "Model must be between 1 and 50 characters.")]
public string Model { get; set; } = string.Empty;
/// Printer hardware type: "Fdm" or "Resin". Defaults to "Fdm".
[Required(ErrorMessage = "PrinterType is required.")]
[RegularExpression("^(Fdm|Resin)$", ErrorMessage = "PrinterType must be 'Fdm' or 'Resin'.")]
public string PrinterType { get; set; } = "Fdm";
/// Connectivity protocol: "Mqtt" or "Moonraker". Defaults to "Mqtt".
[Required(ErrorMessage = "ConnectionType is required.")]
[RegularExpression("^(Mqtt|Moonraker)$", ErrorMessage = "ConnectionType must be 'Mqtt' or 'Moonraker'.")]
public string ConnectionType { get; set; } = "Mqtt";
/// Hostname or IP address for printer connection. Required, max 253 characters.
[Required(ErrorMessage = "HostnameOrIp is required.")]
[StringLength(253, MinimumLength = 1, ErrorMessage = "HostnameOrIp must be between 1 and 253 characters.")]
public string HostnameOrIp { get; set; } = string.Empty;
/// Port number. Defaults: 8883 (MQTT/TLS), 7125 (Moonraker) if zero.
[Range(0, 65535, ErrorMessage = "Port must be between 0 and 65535.")]
public int Port { get; set; }
/// MQTT username for Bambu Lab authentication. Used only for MQTT connection type.
[StringLength(100, ErrorMessage = "MqttUsername must be at most 100 characters.")]
public string MqttUsername { get; set; } = string.Empty;
/// MQTT password for Bambu Lab authentication. Used only for MQTT connection type.
[StringLength(200, ErrorMessage = "MqttPassword must be at most 200 characters.")]
public string MqttPassword { get; set; } = string.Empty;
/// Whether to use TLS for MQTT. Bambu Lab printers require TLS on port 8883.
public bool MqttUseTls { get; set; }
/// Moonraker API key for Elegoo Centauri Carbon. Used only for Moonraker connection type.
[StringLength(100, ErrorMessage = "ApiKey must be at most 100 characters.")]
public string ApiKey { get; set; } = string.Empty;
/// Whether the printer is active and available for jobs. Defaults to true.
public bool IsActive { get; set; } = true;
}
///
/// Request DTO for updating an existing printer's configuration and connection info.
/// All fields are provided on update (full replacement semantics).
///
public class UpdatePrinterRequest
{
/// Human-readable name for the printer. Required, max 100 characters.
[Required(ErrorMessage = "Name is required.")]
[StringLength(100, MinimumLength = 1, ErrorMessage = "Name must be between 1 and 100 characters.")]
public string Name { get; set; } = string.Empty;
/// Manufacturer/brand. Required, max 50 characters.
[Required(ErrorMessage = "Manufacturer is required.")]
[StringLength(50, MinimumLength = 1, ErrorMessage = "Manufacturer must be between 1 and 50 characters.")]
public string Manufacturer { get; set; } = string.Empty;
/// Model name. Required, max 50 characters.
[Required(ErrorMessage = "Model is required.")]
[StringLength(50, MinimumLength = 1, ErrorMessage = "Model must be between 1 and 50 characters.")]
public string Model { get; set; } = string.Empty;
/// Printer hardware type: "Fdm" or "Resin".
[Required(ErrorMessage = "PrinterType is required.")]
[RegularExpression("^(Fdm|Resin)$", ErrorMessage = "PrinterType must be 'Fdm' or 'Resin'.")]
public string PrinterType { get; set; } = "Fdm";
/// Connectivity protocol: "Mqtt" or "Moonraker".
[Required(ErrorMessage = "ConnectionType is required.")]
[RegularExpression("^(Mqtt|Moonraker)$", ErrorMessage = "ConnectionType must be 'Mqtt' or 'Moonraker'.")]
public string ConnectionType { get; set; } = "Mqtt";
/// Hostname or IP address. Required, max 253 characters.
[Required(ErrorMessage = "HostnameOrIp is required.")]
[StringLength(253, MinimumLength = 1, ErrorMessage = "HostnameOrIp must be between 1 and 253 characters.")]
public string HostnameOrIp { get; set; } = string.Empty;
/// Port number. Defaults: 8883 (MQTT/TLS), 7125 (Moonraker) if zero.
[Range(0, 65535, ErrorMessage = "Port must be between 0 and 65535.")]
public int Port { get; set; }
/// MQTT username. Used only for MQTT connection type.
[StringLength(100, ErrorMessage = "MqttUsername must be at most 100 characters.")]
public string MqttUsername { get; set; } = string.Empty;
/// MQTT password. Used only for MQTT connection type.
[StringLength(200, ErrorMessage = "MqttPassword must be at most 200 characters.")]
public string MqttPassword { get; set; } = string.Empty;
/// Whether to use TLS for MQTT.
public bool MqttUseTls { get; set; }
/// Moonraker API key. Used only for Moonraker connection type.
[StringLength(100, ErrorMessage = "ApiKey must be at most 100 characters.")]
public string ApiKey { get; set; } = string.Empty;
/// Whether the printer is active and available for jobs.
public bool IsActive { get; set; } = true;
}