From e0e5c1947d5becd56d89de67f40131e8b55a6af2 Mon Sep 17 00:00:00 2001 From: Jai A Date: Mon, 14 Oct 2024 13:19:45 -0700 Subject: [PATCH] Update server creation endpoint --- src/models/v3/billing.rs | 7 ++++++- src/routes/internal/billing.rs | 12 +++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/models/v3/billing.rs b/src/models/v3/billing.rs index 05ec9cbc..4c9d3b77 100644 --- a/src/models/v3/billing.rs +++ b/src/models/v3/billing.rs @@ -21,7 +21,12 @@ pub struct Product { #[serde(tag = "type", rename_all = "kebab-case")] pub enum ProductMetadata { Midas, - Pyro { ram: u32 }, + Pyro { + cpu: u32, + ram: u32, + swap: u32, + storage: u32, + }, } #[derive(Copy, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] diff --git a/src/routes/internal/billing.rs b/src/routes/internal/billing.rs index 78de9aa5..b0c544d3 100644 --- a/src/routes/internal/billing.rs +++ b/src/routes/internal/billing.rs @@ -1264,7 +1264,12 @@ pub async fn stripe_webhook( .execute(&mut *transaction) .await?; } - ProductMetadata::Pyro { ram } => { + ProductMetadata::Pyro { + ram, + cpu, + swap, + storage, + } => { if let Some(ref subscription) = metadata.user_subscription_item { let client = reqwest::Client::new(); @@ -1327,8 +1332,9 @@ pub async fn stripe_webhook( "name": server_name, "specs": { "memory_mb": ram, - "cpu": std::cmp::max(2, (ram / 1024) / 2), - "swap_mb": ram / 4, + "cpu": cpu, + "swap_mb": swap, + "storage_mb": storage, }, "source": source, }))