59 lines
1.5 KiB
Rust
59 lines
1.5 KiB
Rust
|
|
// Update management module
|
||
|
|
// Provides operations for managing Proxmox updates
|
||
|
|
|
||
|
|
use serde::{Deserialize, Serialize};
|
||
|
|
|
||
|
|
/// Update information
|
||
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
|
pub struct UpdateInfo {
|
||
|
|
pub package: String,
|
||
|
|
pub version: String,
|
||
|
|
pub available_version: String,
|
||
|
|
pub size: u64,
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Update status
|
||
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||
|
|
pub struct UpdateStatus {
|
||
|
|
pub checked_at: String,
|
||
|
|
pub updates: Vec<UpdateInfo>,
|
||
|
|
pub update_count: u32,
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Check for updates
|
||
|
|
pub async fn check_updates(
|
||
|
|
_client: &crate::proxmox::client::ProxmoxClient,
|
||
|
|
_ticket: &str,
|
||
|
|
) -> Result<UpdateStatus, String> {
|
||
|
|
Err("Not implemented yet".to_string())
|
||
|
|
}
|
||
|
|
|
||
|
|
/// List available updates
|
||
|
|
pub async fn list_updates(
|
||
|
|
_client: &crate::proxmox::client::ProxmoxClient,
|
||
|
|
_ticket: &str,
|
||
|
|
) -> Result<Vec<UpdateInfo>, String> {
|
||
|
|
Err("Not implemented yet".to_string())
|
||
|
|
}
|
||
|
|
|
||
|
|
#[cfg(test)]
|
||
|
|
mod tests {
|
||
|
|
use super::*;
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_update_info_serialization() {
|
||
|
|
let update = UpdateInfo {
|
||
|
|
package: "proxmox-ve".to_string(),
|
||
|
|
version: "7.4-15".to_string(),
|
||
|
|
available_version: "7.4-16".to_string(),
|
||
|
|
size: 50000000,
|
||
|
|
};
|
||
|
|
|
||
|
|
let json = serde_json::to_string(&update).unwrap();
|
||
|
|
let deserialized: UpdateInfo = serde_json::from_str(&json).unwrap();
|
||
|
|
|
||
|
|
assert_eq!(update.package, deserialized.package);
|
||
|
|
assert_eq!(update.available_version, deserialized.available_version);
|
||
|
|
}
|
||
|
|
}
|