namespace Titano.Protocol;
/// POST /api/v1/auth/login. = true asks for an HttpOnly session cookie (web admin).
public sealed record LoginRequest(string Username, string Password, string ClientName, bool Cookie = false);
public sealed record LoginResponse(string? Token, UserDto User, bool MustChangePassword, DateTimeOffset ExpiresAt);
/// POST /api/v1/auth/password.
public sealed record ChangePasswordRequest(string CurrentPassword, string NewPassword);
public sealed record UserDto(
Guid Id,
string Username,
string? DisplayName,
string Role,
long Permissions,
long QuotaBytes,
long UsedBytes,
bool Disabled,
bool MustChangePassword,
DateTimeOffset Created,
DateTimeOffset? LastLogin);
/// POST /api/v1/users (admin).
public sealed record CreateUserRequest(string Username, string? DisplayName, string Role, long QuotaBytes, string? Password, bool AllowRenderNode);
/// PATCH /api/v1/users/{id} (admin); null fields stay unchanged.
public sealed record UpdateUserRequest(string? DisplayName, string? Role, long? QuotaBytes, bool? Disabled, bool? AllowRenderNode);
/// Response of POST /api/v1/users and /users/{id}/reset-password: a temporary password shown once.
public sealed record TemporaryPasswordResponse(UserDto User, string TemporaryPassword);
/// POST /api/v1/users/{id}/reset-password (admin); without a password the server generates one.
public sealed record ResetPasswordRequest(string? Password);
/// One row of the admin user list: the account plus when and from which client it was last used.
public sealed record UserSummaryDto(UserDto User, DateTimeOffset? LastSeen, string? LastClient, long UploadsLast30Days);
/// One audit log entry (who did what to which user, sequence or setting).
public sealed record AuditEntryDto(
Guid Id,
DateTimeOffset At,
Guid? UserId,
string? Username,
string Action,
string? TargetKind,
string? TargetId,
string? Details,
string? RemoteAddress);