use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Deserialize)]
pub struct FileRecord {
pub id: String,
pub original_name: String,
pub size: i64,
pub compressed_size: i64,
pub sha256: String,
pub mime_type: String,
pub is_compressed: bool,
pub is_encrypted: bool,
pub tags: Vec<String>,
pub parent_path: String,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ListResult {
pub files: Vec<FileRecord>,
pub total: i64,
pub limit: i64,
pub offset: i64,
}
#[derive(Debug, Clone, Deserialize)]
pub struct SearchResult {
pub files: Vec<FileRecord>,
pub total: i64,
pub mode: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Stats {
pub total_files: i64,
pub total_size: i64,
pub compressed_size: i64,
pub saved_bytes: i64,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ApiKey {
pub id: String,
pub name: String,
pub key_prefix: String,
pub created_at: DateTime<Utc>,
pub last_used_at: Option<DateTime<Utc>>,
pub is_active: bool,
}
#[derive(Debug, Clone, Deserialize)]
pub struct CreateKeyResult {
pub id: String,
pub name: String,
pub key_prefix: String,
pub created_at: DateTime<Utc>,
pub key: String,
}
#[derive(Debug, Default, Clone)]
pub struct UploadOptions {
pub tags: Vec<String>,
pub path: Option<String>,
pub compress: Option<bool>,
pub encrypt: Option<bool>,
}
impl UploadOptions {
pub fn new() -> Self {
Self::default()
}
pub fn tags(mut self, tags: Vec<String>) -> Self {
self.tags = tags;
self
}
pub fn path(mut self, path: impl Into<String>) -> Self {
self.path = Some(path.into());
self
}
pub fn compress(mut self, c: bool) -> Self {
self.compress = Some(c);
self
}
pub fn encrypt(mut self, e: bool) -> Self {
self.encrypt = Some(e);
self
}
}
#[derive(Debug, Default, Clone)]
pub struct ListOptions {
pub limit: usize,
pub offset: usize,
}
impl ListOptions {
pub fn new() -> Self {
Self::default()
}
pub fn limit(mut self, limit: usize) -> Self {
self.limit = limit;
self
}
pub fn offset(mut self, offset: usize) -> Self {
self.offset = offset;
self
}
}
#[derive(Debug, Default, Clone)]
pub struct SearchOptions {
pub limit: usize,
pub offset: usize,
}
impl SearchOptions {
pub fn new() -> Self {
Self::default()
}
pub fn limit(mut self, limit: usize) -> Self {
self.limit = limit;
self
}
pub fn offset(mut self, offset: usize) -> Self {
self.offset = offset;
self
}
}
#[derive(Serialize)]
pub(crate) struct CreateKeyRequest<'a> {
pub name: &'a str,
}
#[derive(Serialize)]
pub(crate) struct ZipRequest<'a> {
pub ids: &'a [&'a str],
}
#[derive(Deserialize)]
pub(crate) struct KeysEnvelope {
pub keys: Vec<ApiKey>,
}