using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;

namespace Nalu.Web.Data.Models;

public class ApiKey
{
    [BsonId]
    [BsonRepresentation(BsonType.ObjectId)]
    public string Id { get; set; } = ObjectId.GenerateNewId().ToString();

    [BsonElement("key")]
    public required string Key { get; set; }

    [BsonElement("plan")]
    public required string Plan { get; set; }

    [BsonElement("owner")]
    public required string Owner { get; set; }

    [BsonElement("user_id")]
    public string? UserId { get; set; }

    [BsonElement("label")]
    public string? Label { get; set; }

    [BsonElement("is_active")]
    public bool IsActive { get; set; } = true;

    [BsonElement("created_at")]
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    [BsonElement("last_used_at")]
    public DateTime? LastUsedAt { get; set; }
}
