//! Types related to storage paths.

use serde::{Deserialize, Serialize};

use paperless_api_macros::{CreateDto, Item, UpdateDto};

use super::MatchAlgorithm;
use super::permission::ItemPermissions;

/// A storage path
#[derive(Debug, Clone, Deserialize, Serialize, CreateDto, UpdateDto, Item)]
#[api_info(endpoint = "storage_paths")]
pub struct StoragePath {
    #[dto(skip)]
    pub id: crate::id::StoragePathId,

    #[dto(skip)]
    pub slug: String,

    pub name: String,
    pub path: String,

    #[serde(rename = "match")]
    pub match_pattern: Option<String>,
    pub matching_algorithm: MatchAlgorithm,
    pub is_insensitive: bool,

    #[dto(skip)]
    #[serde(default)]
    pub document_count: u32,

    pub owner: Option<crate::id::UserId>,

    /// The permissions for this tag.
    #[dto(skip)]
    #[serde(flatten)]
    pub permissions: ItemPermissions,
}
