use serde::{Deserialize, Serialize};

use crate::ids::{SecretId, UserId, WorkspaceId};

#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum SecretKind {
    Token,
    UsernamePassword,
    Header,
    Generic,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum SecretStatus {
    Active,
    Disabled,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Secret {
    pub id: SecretId,
    pub workspace_id: WorkspaceId,
    pub name: String,
    pub kind: SecretKind,
    pub status: SecretStatus,
    pub current_version: u32,
    pub created_at: String,
    pub updated_at: String,
    pub last_used_at: Option<String>,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct SecretVersion {
    pub secret_id: SecretId,
    pub version: u32,
    pub ciphertext: String,
    pub key_version: String,
    pub created_at: String,
    pub created_by: Option<UserId>,
}
