using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Globalization;
namespace Jellyfin.Data.Entities.Security
{
///
/// An entity representing an API key.
///
public class ApiKey
{
///
/// Initializes a new instance of the class.
///
/// The name.
public ApiKey(string name)
{
Name = name;
AccessToken = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
DateCreated = DateTime.UtcNow;
}
///
/// Gets the id.
///
///
/// Identity, Indexed, Required.
///
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; private set; }
///
/// Gets or sets the date created.
///
public DateTime DateCreated { get; set; }
///
/// Gets or sets the date of last activity.
///
public DateTime DateLastActivity { get; set; }
///
/// Gets or sets the name.
///
[MaxLength(64)]
[StringLength(64)]
public string Name { get; set; }
///
/// Gets or sets the access token.
///
public string AccessToken { get; set; }
}
}