Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/api/applications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ pub struct Application {
pub id: String,
pub name: String,
pub description: Option<String>,
#[allow(dead_code)]
pub logo_url: Option<String>,
// Logo URL from API - preserved for future UI enhancements
// pub logo_url: Option<String>,
pub category: Option<String>,
#[allow(dead_code)]
pub os_compatibility: Vec<String>,
// OS compatibility list from API - preserved for filtering features
// pub os_compatibility: Vec<String>,
}

/// Load available one-click applications from the API
Expand All @@ -27,21 +27,21 @@ pub async fn load_applications(
if let Some(arr) = data.get("applications").and_then(|a| a.as_array()) {
for item in arr {
if let Some(obj) = item.as_object() {
let os_compat = if let Some(compat) = obj.get("osCompatibility").and_then(|v| v.as_array()) {
compat.iter()
.filter_map(|v| v.as_str().map(|s| s.to_string()))
.collect()
} else {
Vec::new()
};
// let os_compat = if let Some(compat) = obj.get("osCompatibility").and_then(|v| v.as_array()) {
// compat.iter()
// .filter_map(|v| v.as_str().map(|s| s.to_string()))
// .collect()
// } else {
// Vec::new()
// };

applications.push(Application {
id: obj.get("id").and_then(|v| v.as_str()).unwrap_or("").to_string(),
name: obj.get("name").and_then(|v| v.as_str()).unwrap_or("").to_string(),
description: obj.get("description").and_then(|v| v.as_str()).map(|s| s.to_string()),
logo_url: obj.get("logoUrl").and_then(|v| v.as_str()).map(|s| s.to_string()),
// logo_url: obj.get("logoUrl").and_then(|v| v.as_str()).map(|s| s.to_string()),
category: obj.get("category").and_then(|v| v.as_str()).map(|s| s.to_string()),
os_compatibility: os_compat,
// os_compatibility: os_compat,
});
}
}
Expand Down
90 changes: 45 additions & 45 deletions src/api/backups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pub struct BackupProfileView {
pub schedule_frequency: Option<String>,
pub monthly_price: Option<f64>,
pub max_files: Option<i32>,
#[allow(dead_code)]
pub created_at: Option<i64>,
// Created timestamp from API - preserved for future sorting/filtering
// pub created_at: Option<i64>,
}

/// Load backup profiles from the API
Expand All @@ -33,7 +33,7 @@ pub async fn load_backups(
schedule_frequency: obj.get("scheduleFrequency").and_then(|v| v.as_str()).map(|s| s.to_string()),
monthly_price: obj.get("monthlyPrice").and_then(|v| v.as_f64()),
max_files: obj.get("maxFiles").and_then(|v| v.as_i64()).map(|i| i as i32),
created_at: obj.get("createdAt").and_then(|v| v.as_i64()),
// created_at: obj.get("createdAt").and_then(|v| v.as_i64()),
});
}
}
Expand All @@ -44,16 +44,16 @@ pub async fn load_backups(
backups
}

/// Get backup profile for instance
pub async fn get_backup_profile(
client: &reqwest::Client,
api_base_url: &str,
api_token: &str,
instance_id: &str,
) -> Value {
let endpoint = format!("/v1/backups/{}", instance_id);
api_call(client, api_base_url, api_token, "GET", &endpoint, None, None).await
}
// Get backup profile for instance - preserved for future use
// pub async fn get_backup_profile(
// client: &reqwest::Client,
// api_base_url: &str,
// api_token: &str,
// instance_id: &str,
// ) -> Value {
// let endpoint = format!("/v1/backups/{}", instance_id);
// api_call(client, api_base_url, api_token, "GET", &endpoint, None, None).await
// }

/// Create backup profile
pub async fn create_backup_profile(
Expand All @@ -78,36 +78,36 @@ pub async fn create_backup_profile(
api_call(client, api_base_url, api_token, "POST", "/v1/backups", Some(payload), None).await
}

/// Update backup profile
pub async fn update_backup_profile(
client: &reqwest::Client,
api_base_url: &str,
api_token: &str,
instance_id: &str,
schedule_frequency: &str,
period_id: i32,
schedule_week_days: Option<Vec<String>>,
) -> Value {
let mut payload = serde_json::json!({
"instanceId": instance_id,
"scheduleFrequency": schedule_frequency,
"periodId": period_id
});

if let Some(days) = schedule_week_days {
payload["scheduleWeekDays"] = Value::Array(days.into_iter().map(Value::String).collect());
}

api_call(client, api_base_url, api_token, "PUT", "/v1/backups", Some(payload), None).await
}
// Update backup profile - preserved for future use
// pub async fn update_backup_profile(
// client: &reqwest::Client,
// api_base_url: &str,
// api_token: &str,
// instance_id: &str,
// schedule_frequency: &str,
// period_id: i32,
// schedule_week_days: Option<Vec<String>>,
// ) -> Value {
// let mut payload = serde_json::json!({
// "instanceId": instance_id,
// "scheduleFrequency": schedule_frequency,
// "periodId": period_id
// });
//
// if let Some(days) = schedule_week_days {
// payload["scheduleWeekDays"] = Value::Array(days.into_iter().map(Value::String).collect());
// }
//
// api_call(client, api_base_url, api_token, "PUT", "/v1/backups", Some(payload), None).await
// }

/// Delete backup profile
pub async fn delete_backup_profile(
client: &reqwest::Client,
api_base_url: &str,
api_token: &str,
instance_id: &str,
) -> Value {
let endpoint = format!("/v1/backups/{}", instance_id);
api_call(client, api_base_url, api_token, "DELETE", &endpoint, None, None).await
}
// Delete backup profile - preserved for future use
// pub async fn delete_backup_profile(
// client: &reqwest::Client,
// api_base_url: &str,
// api_token: &str,
// instance_id: &str,
// ) -> Value {
// let endpoint = format!("/v1/backups/{}", instance_id);
// api_call(client, api_base_url, api_token, "DELETE", &endpoint, None, None).await
// }
6 changes: 3 additions & 3 deletions src/api/floating_ips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pub struct FloatingIpView {
pub instance_id: Option<String>,
pub auto_renew: bool,
pub customer_note: Option<String>,
#[allow(dead_code)]
pub created_at: Option<i64>,
// Created timestamp from API - preserved for future sorting/filtering
// pub created_at: Option<i64>,
}

/// Paginated result structure for floating IPs
Expand Down Expand Up @@ -56,7 +56,7 @@ pub async fn load_floating_ips(
instance_id: obj.get("instanceId").and_then(|v| v.as_str()).map(|s| s.to_string()),
auto_renew: obj.get("autoRenew").and_then(|v| v.as_bool()).unwrap_or(false),
customer_note: obj.get("customerNote").and_then(|v| v.as_str()).map(|s| s.to_string()),
created_at: obj.get("createdAt").and_then(|v| v.as_i64()),
// created_at: obj.get("createdAt").and_then(|v| v.as_i64()),
});
}
}
Expand Down
76 changes: 38 additions & 38 deletions src/api/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ use serde_json::Value;
/// Image view structure
#[derive(Clone, Debug)]
pub struct ImageView {
pub id: String,
// pub id: String,
pub name: String,
pub url: String,
// pub url: String,
pub status: String,
pub region_id: String,
pub format: Option<String>,
#[allow(dead_code)]
pub decompress: Option<String>,
#[allow(dead_code)]
pub created_at: Option<i64>,
// Decompress option from API - used when downloading images
// pub decompress: Option<String>,
// Created timestamp from API - preserved for future sorting/filtering
// pub created_at: Option<i64>,
}

/// Paginated result structure for images
#[derive(Clone, Debug)]
pub struct PaginatedImages {
pub images: Vec<ImageView>,
pub total_count: usize,
pub current_page: usize,
pub total_pages: usize,
pub per_page: usize,
// pub current_page: usize,
// pub total_pages: usize,
// pub per_page: usize,
}

/// Load images from the API
Expand Down Expand Up @@ -52,14 +52,14 @@ pub async fn load_images(
for item in arr {
if let Some(obj) = item.as_object() {
images.push(ImageView {
id: obj.get("id").and_then(|v| v.as_str()).unwrap_or("").to_string(),
// id: obj.get("id").and_then(|v| v.as_str()).unwrap_or("").to_string(),
name: obj.get("name").and_then(|v| v.as_str()).unwrap_or("").to_string(),
url: obj.get("url").and_then(|v| v.as_str()).unwrap_or("").to_string(),
// url: obj.get("url").and_then(|v| v.as_str()).unwrap_or("").to_string(),
status: obj.get("status").and_then(|v| v.as_str()).unwrap_or("UNKNOWN").to_string(),
region_id: obj.get("regionId").and_then(|v| v.as_str()).unwrap_or("").to_string(),
format: obj.get("format").and_then(|v| v.as_str()).map(|s| s.to_string()),
decompress: obj.get("decompress").and_then(|v| v.as_str()).map(|s| s.to_string()),
created_at: obj.get("createdAt").and_then(|v| v.as_i64()),
// decompress: obj.get("decompress").and_then(|v| v.as_str()).map(|s| s.to_string()),
// created_at: obj.get("createdAt").and_then(|v| v.as_i64()),
});
}
}
Expand All @@ -70,15 +70,15 @@ pub async fn load_images(
}

let actual_total = if total_count > 0 { total_count } else { images.len() };
let total_pages = if per_page > 0 { actual_total.div_ceil(per_page) } else { 1 };
let current_page = if page >= 1 { page } else { 1 };
// let total_pages = if per_page > 0 { actual_total.div_ceil(per_page) } else { 1 };
// let current_page = if page >= 1 { page } else { 1 };

PaginatedImages {
images,
total_count: actual_total,
current_page,
total_pages,
per_page,
// current_page,
// total_pages,
// per_page,
}
}

Expand Down Expand Up @@ -110,24 +110,24 @@ pub async fn download_image(
api_call(client, api_base_url, api_token, "POST", "/v1/images", Some(payload), None).await
}

/// Get image details
pub async fn get_image(
client: &reqwest::Client,
api_base_url: &str,
api_token: &str,
image_id: &str,
) -> Value {
let endpoint = format!("/v1/images/{}", image_id);
api_call(client, api_base_url, api_token, "GET", &endpoint, None, None).await
}
// Get image details - preserved for future use
// pub async fn get_image(
// client: &reqwest::Client,
// api_base_url: &str,
// api_token: &str,
// image_id: &str,
// ) -> Value {
// let endpoint = format!("/v1/images/{}", image_id);
// api_call(client, api_base_url, api_token, "GET", &endpoint, None, None).await
// }

/// Delete an image
pub async fn delete_image(
client: &reqwest::Client,
api_base_url: &str,
api_token: &str,
image_id: &str,
) -> Value {
let endpoint = format!("/v1/images/{}", image_id);
api_call(client, api_base_url, api_token, "DELETE", &endpoint, None, None).await
}
// Delete an image - preserved for future use
// pub async fn delete_image(
// client: &reqwest::Client,
// api_base_url: &str,
// api_token: &str,
// image_id: &str,
// ) -> Value {
// let endpoint = format!("/v1/images/{}", image_id);
// api_call(client, api_base_url, api_token, "DELETE", &endpoint, None, None).await
// }
Loading
Loading