use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SnapshotScope {
Applications,
Databases,
}
impl SnapshotScope {
pub(crate) fn as_str(self) -> &'static str {
match self {
Self::Applications => "applications",
Self::Databases => "databases",
}
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Snapshot {
pub name: String,
pub size: u64,
pub modified: DateTime<Utc>,
pub key: String,
}
impl Snapshot {
pub fn version_id(&self) -> &str {
self.key
.split('&')
.find(|s| s.starts_with("versionId="))
.and_then(|s| s.strip_prefix("versionId="))
.unwrap_or(&self.key)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct SnapshotReference {
pub url: String,
pub key: String,
}